diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /odk/examples/DevelopersGuide/Components/Addons | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'odk/examples/DevelopersGuide/Components/Addons')
16 files changed, 2160 insertions, 0 deletions
diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu new file mode 100644 index 0000000000..2568a7c4f8 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu @@ -0,0 +1,83 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you 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 . +--> +<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office"> + <node oor:name="AddonUI"> + + <node oor:name="AddonMenu"> + + <node oor:name="myAsyncJobAlias" oor:op="replace"> + + <prop oor:name="URL" oor:type="xs:string"> + + <value>vnd.sun.star.job:alias=AsyncJob</value> + + </prop> + + <prop oor:name="Title" oor:type="xs:string"> + <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. --> + <value xml:lang="x-no-translate"></value> + <value xml:lang="en-US">AsyncJob (ALIAS)...</value> + <value xml:lang="de">AsyncJob (ALIAS) ...</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + + <node oor:name="myAsyncJobEvent" oor:op="replace"> + + <prop oor:name="URL" oor:type="xs:string"> + + <value>vnd.sun.star.job:event=onMyOwnJobEvent</value> + + </prop> + + <prop oor:name="Title" oor:type="xs:string"> + <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. --> + <value xml:lang="x-no-translate"></value> + <value xml:lang="en-US">AsyncJob (EVENT)...</value> + <value xml:lang="de">AsyncJob (EVENT) ...</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + + <node oor:name="myAsyncJobService" oor:op="replace"> + + <prop oor:name="URL" oor:type="xs:string"> + + <value>vnd.sun.star.job:service=com.sun.star.comp.framework.java.services.AsyncJob</value> + + </prop> + + <prop oor:name="Title" oor:type="xs:string"> + <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. --> + <value xml:lang="x-no-translate"></value> + <value xml:lang="en-US">AsyncJob (SERVICE)...</value> + <value xml:lang="de">AsyncJob (SERVICE) ...</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + </node> + </node> +</oor:component-data> + diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components new file mode 100644 index 0000000000..c47f26b018 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<components xmlns="http://openoffice.org/2010/uno-components"> + <component loader="com.sun.star.loader.Java2" uri="AsyncJob.uno.jar"> + <implementation name="com.sun.star.comp.framework.java.services.AsyncJob"> + <service name="com.sun.star.task.AsyncJob"/> + </implementation> + </component> +</components> diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java new file mode 100644 index 0000000000..9b55929d87 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java @@ -0,0 +1,425 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.Factory; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.task.*; +import com.sun.star.uno.*; + +/** it implements a simple job component. + * + * Such jobs are executable in different ways: + * <ul> + * <li>registered for a special URL schema "vnd.sun.star.jobs:*" and used from the generic dispatch framework</li> + * <li>the global com.sun.star.task.JobExecutor service and registered for special events.</li> + * </ul> + */ +public class AsyncJob extends WeakBase implements XServiceInfo, XAsyncJob +{ + public final XComponentContext m_xCmpCtx; + + /** the const list of supported uno service names. */ + public static final String[] SERVICENAMES = {"com.sun.star.task.AsyncJob"}; + + /** the const uno implementation name. + * It must be a unique value! The best naming schema seems to use + * a registered domain in reverse order ... + */ + public static final String IMPLEMENTATIONNAME = "com.sun.star.comp.framework.java.services.AsyncJob"; + + + // interface + + /** initialize a new instance of this class with default values. */ + public AsyncJob( XComponentContext xCompContext ) + { + m_xCmpCtx = xCompContext; + } + + + + /** starts execution of this job. + * + * @param lArgs + * list which contains: + * <ul> + * <li>generic job configuration data</li> + * <li>job specific configuration data</li> + * <li>some environment information</li> + * <li>may optional arguments of a corresponding dispatch request</li> + * </ul> + * + * @params xListener + * callback to the executor of this job, which control our life time + * + * @throws com.sun.star.lang.IllegalArgumentException + * if given argument list seems to be wrong + */ + public synchronized void executeAsync(com.sun.star.beans.NamedValue[] lArgs , + com.sun.star.task.XJobListener xListener) + throws com.sun.star.lang.IllegalArgumentException + { + // For asynchronous jobs a valid listener reference is guaranteed normally ... + if (xListener == null) + throw new com.sun.star.lang.IllegalArgumentException("invalid listener"); + + // extract all possible sub list of given argument list + com.sun.star.beans.NamedValue[] lGenericConfig = null; + com.sun.star.beans.NamedValue[] lJobConfig = null; + com.sun.star.beans.NamedValue[] lEnvironment = null; + com.sun.star.beans.NamedValue[] lDynamicData = null; + + int c = lArgs.length; + for (int i=0; i<c; ++i) + { + if (lArgs[i].Name.equals("Config")) + lGenericConfig = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value); + else + if (lArgs[i].Name.equals("JobConfig")) + lJobConfig = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value); + else + if (lArgs[i].Name.equals("Environment")) + lEnvironment = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value); + else + if (lArgs[i].Name.equals("DynamicData")) + lDynamicData = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value); + } + + // Analyze the environment info. This sub list is the only guaranteed one! + if (lEnvironment == null) + throw new com.sun.star.lang.IllegalArgumentException("no environment"); + + String sEnvType = null; + String sEventName = null; + com.sun.star.frame.XFrame xFrame = null; + c = lEnvironment.length; + for (int i=0; i<c; ++i) + { + if (lEnvironment[i].Name.equals("EnvType")) + sEnvType = com.sun.star.uno.AnyConverter.toString(lEnvironment[i].Value); + else + if (lEnvironment[i].Name.equals("EventName")) + sEventName = com.sun.star.uno.AnyConverter.toString(lEnvironment[i].Value); + else + if (lEnvironment[i].Name.equals("Frame")) + xFrame = (com.sun.star.frame.XFrame)com.sun.star.uno.AnyConverter.toObject( + new com.sun.star.uno.Type(com.sun.star.frame.XFrame.class), + lEnvironment[i].Value); + } + + // Further the environment property "EnvType" is required as minimum. + if ( + (sEnvType==null) || + ( + (!sEnvType.equals("EXECUTOR")) && + (!sEnvType.equals("DISPATCH")) + ) + ) + { + String sMessage = "\"" + sEnvType + "\" isn't a valid value for EnvType"; + throw new com.sun.star.lang.IllegalArgumentException(sMessage); + } + + // Analyze the set of shared config data. + if (lGenericConfig!=null) + { + c = lGenericConfig.length; + for (int i=0; i<c; ++i) + { + if (lGenericConfig[i].Name.equals("Alias")) + com.sun.star.uno.AnyConverter.toString(lGenericConfig[i].Value); + } + } + + // do your job ... + // Here we print out all found arguments. + String sOut = formatOutArgs(lGenericConfig, lJobConfig, lEnvironment, lDynamicData); + if (xFrame != null) + showInfoModal(xFrame.getContainerWindow(), "Arguments of AsyncJob initialization ...", sOut); + else + showInfoNonModal("Arguments of AsyncJob initialization ...", sOut); + + // use return value to start different actions + // But look for the right environment. Some options make no sense inside the wrong env. + com.sun.star.beans.NamedValue aDeactivation = null; + com.sun.star.beans.NamedValue aDispatchResult = null; + com.sun.star.beans.NamedValue aSaveRequest = null; + + // SaveArguments will be made everytimes! + c = 1; + + if (lJobConfig==null) + lJobConfig = new com.sun.star.beans.NamedValue[1]; + lJobConfig[0] = new com.sun.star.beans.NamedValue(); + lJobConfig[0].Name = "arg_1"; + lJobConfig[0].Value = "val_1"; + + aSaveRequest = new com.sun.star.beans.NamedValue(); + aSaveRequest.Name = "SaveArguments"; + aSaveRequest.Value = lJobConfig; + + // Deactivation is useful inside EXECUTOR environment only + if (sEnvType.equals("EXECUTOR")) + { + ++c; + aDeactivation = new com.sun.star.beans.NamedValue(); + aDeactivation.Name = "Deactivate"; + aDeactivation.Value = java.lang.Boolean.TRUE; + } + + // Sending of result events is useful inside DISPATCH environment only + if (sEnvType.equals("DISPATCH")) + { + ++c; + aDispatchResult = new com.sun.star.beans.NamedValue(); + aDispatchResult.Name = "SendDispatchResult"; + aDispatchResult.Value = new com.sun.star.frame.DispatchResultEvent(this, com.sun.star.frame.DispatchResultState.SUCCESS, null); + } + + // pack it together for return + int i=0; + com.sun.star.beans.NamedValue[] lReturn = new com.sun.star.beans.NamedValue[c]; + lReturn[i++] = aSaveRequest; + if (aDeactivation!=null) + lReturn[i++] = aDeactivation; + if (aDispatchResult!=null) + lReturn[i++] = aDispatchResult; + + xListener.jobFinished(this, lReturn); + } + + + + /** show an info box with the UNO based toolkit. + * + * It tries to use the container window of a may well know + * office frame as parent. If such parent window could be located, + * the info box can be shown in modal mode. If a parent is missing + * (because this job is called inside an EXECUTOR environment, which + * does not set any frame context here) the info box can't be created! + * Because the toolkit needs parents for non top level windows... + * In that case the only way is to implement this info box + * native or make it non modal using java dialogs inside its own thread... + * (see showInfoNonModal() too) + * + * @param xParent + * used as parent window of the shown info box. + * + * @param sTitle + * is shown as title of the info box. + * + * @param sMessage + * included the message body, which is shown as info. + */ + + private void showInfoModal( com.sun.star.awt.XWindow xParent , + String sTitle , + String sMessage ) + { + try + { + // get access to the office toolkit environment + com.sun.star.awt.XToolkit xKit = UnoRuntime.queryInterface( + com.sun.star.awt.XToolkit.class, + m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", + m_xCmpCtx)); + + // describe the info box ini its parameters + com.sun.star.awt.WindowDescriptor aDescriptor = new com.sun.star.awt.WindowDescriptor(); + aDescriptor.WindowServiceName = "infobox"; + aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0,0,300,200); + aDescriptor.WindowAttributes = com.sun.star.awt.WindowAttribute.BORDER | + com.sun.star.awt.WindowAttribute.MOVEABLE | + com.sun.star.awt.WindowAttribute.CLOSEABLE; + aDescriptor.Type = com.sun.star.awt.WindowClass.MODALTOP; + aDescriptor.ParentIndex = 1; + aDescriptor.Parent = UnoRuntime.queryInterface( + com.sun.star.awt.XWindowPeer.class, + xParent); + + // create the info box window + com.sun.star.awt.XWindowPeer xPeer = xKit.createWindow(aDescriptor); + com.sun.star.awt.XMessageBox xInfoBox = UnoRuntime.queryInterface( + com.sun.star.awt.XMessageBox.class, + xPeer); + if (xInfoBox == null) + return; + + // fill it with all given information and show it + xInfoBox.setCaptionText(sTitle); + xInfoBox.setMessageText(sMessage); + xInfoBox.execute(); + } + catch(java.lang.Throwable exIgnore) + { + // ignore any problem, which can occur here. + // It's not really a bug for this example job, if + // it's message could not be printed out! + } + } + + + + private void showInfoNonModal( String sTitle , + String sMessage ) + { + // Couldn't be implemented really using the toolkit... + // Because we need a parent anytime. + // And showing e.g. a Java dialog can make some trouble + // inside office... but we have no chance here. + final String sFinalTitle = sTitle; + final String sFinalMessage = sMessage; + + // On macOS, AWT/Swing must not be accessed from the AppKit thread, so call + // SwingUtilities.invokeLater always on a fresh thread to avoid that problem + // (also, the current thread must not wait for that fresh thread to terminate, + // as that would cause a deadlock if this thread is the AppKit thread): + final Runnable doRun = new Runnable() { + public void run() { + javax.swing.JOptionPane.showMessageDialog(null, sFinalMessage, sFinalTitle, javax.swing.JOptionPane.INFORMATION_MESSAGE); + } + }; + + new Thread( doRun ) { + @Override + public void run() { javax.swing.SwingUtilities.invokeLater(doRun); } + }.start(); + } + + + + /** helper to print out the given argument list. + * + * @param lGenericConfig + * contains all shared configuration items for a job + * + * @param lJobConfig + * contains all job specific configuration items + * + * @param lEnvironment + * contains some environment information + * + * @param lDynamicData + * contains optional data of a might corresponding dispatch() request + */ + + private String formatOutArgs(com.sun.star.beans.NamedValue[] lGenericConfig, + com.sun.star.beans.NamedValue[] lJobConfig , + com.sun.star.beans.NamedValue[] lEnvironment , + com.sun.star.beans.NamedValue[] lDynamicData ) + { + StringBuffer sOut = new StringBuffer(1024); + + sOut.append("list \"Config\": "); + if (lGenericConfig==null) + sOut.append("0 items\n"); + else + { + int c = lGenericConfig.length; + sOut.append(c+" items\n"); + for (int i=0; i<c; ++i) + sOut.append("\t["+i+"] \""+lGenericConfig[i].Name+"\" = {"+lGenericConfig[i].Value+"}\n"); + } + sOut.append("list \"JobConfig\": "); + if (lJobConfig==null) + sOut.append("0 items\n"); + else + { + int c = lJobConfig.length; + sOut.append(c+" items\n"); + for (int i=0; i<c; ++i) + sOut.append("\t["+i+"] \""+lJobConfig[i].Name+"\" = {"+lJobConfig[i].Value+"}\n"); + } + sOut.append("list \"Environment\": "); + if (lEnvironment==null) + sOut.append("0 items\n"); + else + { + int c = lEnvironment.length; + sOut.append(c+" items\n"); + for (int i=0; i<c; ++i) + sOut.append("\t["+i+"] \""+lEnvironment[i].Name+"\" = {"+lEnvironment[i].Value+"}\n"); + } + sOut.append("list \"DynamicData\": "); + if (lDynamicData==null) + sOut.append("0 items\n"); + else + { + int c = lDynamicData.length; + sOut.append(c+" items\n"); + for (int i=0; i<c; ++i) + sOut.append("\t["+i+"] \""+lDynamicData[i].Name+"\" = {"+lDynamicData[i].Value+"}\n"); + } + + return sOut.toString(); + } + + public String[] getSupportedServiceNames() { + return SERVICENAMES; + } + + public boolean supportsService( String sService ) { + int len = SERVICENAMES.length; + + for( int i=0; i < len; i++) { + if ( sService.equals( SERVICENAMES[i] ) ) + return true; + } + + return false; + } + + public String getImplementationName() { + return( AsyncJob.class.getName() ); + } + + + + + public synchronized static com.sun.star.lang.XSingleComponentFactory __getComponentFactory(String sImplName) + { + com.sun.star.lang.XSingleComponentFactory xFactory = null; + if (sImplName.equals(AsyncJob.IMPLEMENTATIONNAME)) + xFactory = Factory.createComponentFactory(AsyncJob.class, SERVICENAMES); + + return xFactory; + } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu new file mode 100644 index 0000000000..f97f202c65 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu @@ -0,0 +1,44 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you 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 . +--> +<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" 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="Jobs"> + <node oor:name="AsyncJob" oor:op="replace"> + <prop oor:name="Service" oor:type="xs:string"> + <value>com.sun.star.comp.framework.java.services.AsyncJob</value> + </prop> + <node oor:name="Arguments"> + <prop oor:name="arg_1" oor:op="replace" oor:type="xs:string"> + <value>val_1</value> + </prop> + </node> + </node> + </node> + <node oor:name="Events"> + <node oor:name="onFirstVisibleTask" oor:op="modify"> + <node oor:name="JobList"> + <node oor:name="AsyncJob" oor:op="replace"/> + </node> + </node> + <node oor:name="onMyOwnJobEvent" oor:op="replace"> + <node oor:name="JobList"> + <node oor:name="AsyncJob" oor:op="replace"/> + </node> + </node> + </node> +</oor:component-data> diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile new file mode 100644 index 0000000000..6ee3481fcf --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile @@ -0,0 +1,136 @@ +#************************************************************************* +# +# The Contents of this file are made available subject to the terms of +# the BSD license. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Sun Microsystems, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#************************************************************************** + +# Builds the DevGuide Jobs Addon component example of the SDK. + +PRJ=../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +COMP_NAME=AsyncJob +OUT_COMP_CLASS=$(OUT_CLASS)/$(COMP_NAME) +OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME) +COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) +COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") +COMP_JAR_NAME=$(COMP_NAME).uno.jar +COMP_JAR=$(OUT_CLASS)/$(COMP_JAR_NAME) +COMP_MANIFESTFILE=$(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest +COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml +REGISTERFLAG=$(OUT_COMP_MISC)$(PS)java_$(COMP_NAME)_register_component.flag +COMP_COMPONENTS=$(COMP_NAME).components + +JAVAFILES = AsyncJob.java + +CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES)) + +SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ + $(PATH_SEPARATOR)$(OUT_COMP_CLASS)) + + +# Targets +.PHONY: ALL +ALL : DevGuideJobsAddon + +include $(SETTINGS)/stdtarget.mk + +$(OUT_COMP_CLASS)/%.Manifest : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo RegistrationClassName: $(basename $(basename $(@F)))> $@ + +$(CLASSFILES) : $(JAVAFILES) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES) + +# rule for component jar file +$(COMP_JAR) : $(COMP_MANIFESTFILE) $(CLASSFILES) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) . + +# rule for component package manifest +$(OUT_COMP_CLASS)/%/manifest.xml : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ + @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ + @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)Jobs.xcu$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@ + @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ + +# rule for component package file +$(COMP_PACKAGE) : $(COMP_JAR) Addons.xcu Jobs.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + cd $(subst /,$(PS),$(OUT_CLASS)) && $(SDK_ZIP) ../bin/$(@F) $(<F) + $(SDK_ZIP) -u $@ Addons.xcu Jobs.xcu $(COMP_COMPONENTS) + cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml + + +$(REGISTERFLAG) : $(COMP_PACKAGE) +ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(DEPLOYTOOL) $(COMP_PACKAGE_URL) + @echo flagged > $(subst /,$(PS),$@) +else + @echo -------------------------------------------------------------------------------- + @echo If you want to install your component automatically, please set the environment + @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only + @echo possible if no office instance is running. + @echo -------------------------------------------------------------------------------- +endif + +DevGuideJobsAddon : $(REGISTERFLAG) + @echo -------------------------------------------------------------------------------- + @echo The "$(QM)AsyncJob$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES. + @echo You can use this component inside your office installation, see the example + @echo description. + @echo -------------------------------------------------------------------------------- + +%.run: $(OUT_COMP_CLASS)/%.class + $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@) + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC)) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL))) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_JAR))) diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu new file mode 100644 index 0000000000..77aae07c47 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu @@ -0,0 +1,207 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you 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 . +--> +<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office"> + <node oor:name="AddonUI"> + <node oor:name="AddonMenu"> + <node oor:name="org.openoffice.Office.addon.example.function" oor:op="replace"> + <prop oor:name="Title" oor:type="xs:string"> + <value xml:lang="en-US">Add-On example</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + <node oor:name="Submenu"> + <node oor:name="m1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 1</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + <node oor:name="m2" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function2</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 2</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + </node> + </node> + </node> + <node oor:name="OfficeMenuBar"> + <node oor:name="org.openoffice.Office.addon.example" oor:op="replace"> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On example</value> + </prop> + <node oor:name="Submenu"> + <node oor:name="m1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 1</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + </node> + <node oor:name="m2" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>private:separator</value> + </prop> + </node> + <node oor:name="m3" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value/> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On sub menu</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <node oor:name="Submenu"> + <node oor:name="submenu1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function2</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 2</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.sheet.SpreadsheetDocument</value> + </prop> + </node> + </node> + </node> + </node> + </node> + </node> + <node oor:name="OfficeToolBar"> + <node oor:name="org.openoffice.Office.addon.example" oor:op="replace"> + <node oor:name="m1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Function 1</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + </node> + <node oor:name="m2" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function2</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Function 2</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + </node> + </node> + </node> + <node oor:name="Images"> + <node oor:name="com.sun.star.comp.framework.addon.image1" oor:op="replace"> + <prop oor:name="URL"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <node oor:name="UserDefinedImages"> + <prop oor:name="ImageSmall" oor:type="xs:hexBinary"> + <value>424df80000000000000076000000280000001000000010000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c0008080800000000000000080000080800000800000808000008000000080008000cccccccccccccccc2c266b181b666c2c5cc66b818b6665c555566b181b66655555566b818b66655555566b181b6665555a8666bbb6668a55a0a866666668a0a5000a8666668a000a6000a86668a000a556000a868a000a55556000a8a000a5555556000a000a55555555600000a55555555556000a55555555555560a55555550000</value> + </prop> + <prop oor:name="ImageBig" oor:type="xs:hexBinary"> + <value>424d180200000000000076000000280000001a0000001a000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c000808080000000000000008000008080000080000080800000800000008000800055555555555555555555555555999990cccccccccccccccccccccccccc9055552cc2c6666b18181b6666c2cc2c99ccccc2ccc6666b81818b66668c2cc5902cc25c2586666b18181b66668ccc5590c2cc555586666b81818b6666855555995c25555586666b18181b6666855555995555555586666b81818b6666855555005555555586666b18181b666685555590555555a5866666b181b6666685a5550955555a0a8666666bbb6666668a0a559955a5a000a866666666666668a000a5995a0a00000a8666666666668a00000a90a000600000a86666666668a00000a50900005600000a866666668a00000a5599600055600000a8666668a00000a555095600555600000a86668a00000a55559955605555600000a868a00000a5555599555655555600000a8a00000a555555005555555555600000a00000a555555590555555555556000000000a555555550955555555555560000000a555555555995555555555555600000a555555555590555555555555556000a555555555550055555555555555560a555555555555905555555555555555555555555555559055550000</value> + </prop> + <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary"> + <value>424df60000000000000076000000280000001000000010000000010004000000000080000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c00080808000000000000000800000808000008000008080000080000000800080002222222222222222222996969699922252299669669995255559969696999555555996696699955555599696969995555969996669996955969699999996969566696999996966699666969996966695596669696966695555966696966695555559666966695555555596666695555555555966695555555555559695555555</value> + </prop> + <prop oor:name="ImageBigHC" oor:type="xs:hexBinary"> + <value/> + </prop> + </node> + </node> + <node oor:name="com.sun.star.comp.framework.addon.image2" oor:op="replace"> + <prop oor:name="URL"> + <value>org.openoffice.Office.addon.example:Help</value> + </prop> + <node oor:name="UserDefinedImages"> + <prop oor:name="ImageSmall" oor:type="xs:hexBinary"> + <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcfffffffbeadee7bca8e7bcabdfb4a2f1c4b0fffffad0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffd49578b7511eb5582ed29d85ce8b6db54513ba5f32eeccb8fffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9dadc9270ba4613bf511dc99076edeae7f2dcced27b54bc4811ba5724d3ad96ffffff402d30ff00ffefeae6e9e0daeabba4ba4308cb5b28cb5f2ecc7046d99979db8f66ce6635cc5d2dbf4e1ab85225ffeee5726361b1aaaad8cbc2ffffffbf4911c65b21cf6532cc5d2bcc764edbae97dfa284ce6a3bcc5b2bcc602ebb4310d28259ffffff332124d7cbc2fffffebb2600d0703bcc612ecb5b2bca7a56dfd3cdf5f4f1e1a686cd6333ce622dc95e2abe3901ffffff2b1a1dd8cdc4ffffffbe2f00d36f40cb602dcb5928c95a29ce8666e9ded7f1dcd2d77e56cd612acc6530c43a00ffffff312125d5c8beffffffcf3f00d66e3dcc632fc95d2ccb5522c44f19cf8c6becd4ccde9b81d06435d05b26c65619ffffff251317d9cdc5fefffff09361e87437da794ad29a7edfa68ad56f3bd5835bedd5cbe3b399d36939db6126e9b395ffffff3f3033f5f2f0ded6d1fff1e4f9a36ff28b52e3b39beeefedf3e5d9f2e7def4f0eaeba87ee66d2fee9e72fffffcb28d89c7c6c6ff00ffcbb6aaffffffffebdcfec08ff6b584edcebbeddaddf3dfdff5cab3f79c66fbaa7dfce8dcffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffcfff2d1fadca3f6cf91fac588fdc68bffe4c5fffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value> + </prop> + <prop oor:name="ImageBig" oor:type="xs:hexBinary"> + <value>424d560800000000000036000000280000001a0000001a00000001001800000000002008000000000000000000000000000000000000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff524142524142524142524142524142524142524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ff524142524142bda69cd6c7bddecfc6ded7d6e7dfd6e7d7cebdbebdb59694524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ff524142fffffffffffffffffffffffffffffffffffffffffff7f7f7ffffffffffffffefefbdb6ad524142524142ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ff524142ffffffffffffffffffefefefdedfdebdb6adc6a694d6a68cdebeade7d7ceefefeff7f7f7ffffffefe7deefe7de524142ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffffffffefe7ded6a68cbd6139bd5929ce6942c6795abd5929bd5931ce8663debeadefefeffffffffff7f7efe7de524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffe7cfc6ce7142bd5929bd5929bd6139d6c7bdffffffd69e84bd5929bd5929bd5929d69e7befefefffffffffefef524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffffffffe7cfc6c66139bd5929c66131ce6131bd7152dedfdeffffffe7c7bdce6131ce6131bd5929bd5929ce8e6befefefffffffdecfc6524142ff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffefe7e7ce7142c66131ce6131ce6131ce6131c66131d6a68cefcfbdd68652ce6131ce6131ce6131c66131bd5929d6a68cffffffffffff524142ff00ffff00ffff00ff0000ff00ffdecfc6fff7f7ffffffdeae94bd5929ce6131ce6931ce6131ce6131ce6131ce6939d67142ce6131ce6131ce6131ce6131ce6131bd5929c66139f7dfd6ffffffdecfc6524142ff00ffff00ff0000ff00ffdecfc6fffffff7efefd6714ac66131ce6931ce6931ce6131ce6131c66939debeadffefe7de966bc66131ce6131ce6131ce6131ce6131bd5929deae94ffffffffefe7524142ff00ffff00ff0000ff00ffdecfc6ffffffefd7cece6131ce6931ce6931ce6131ce6131ce6131c66939d6d7d6ffffffdeb69cce6131ce6131ce6131ce6131ce6131bd5929ce8e63f7f7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131ce6939ce6931ce6131ce6131ce6131ce6131c6a694f7f7f7fff7efd68e63ce6131ce6131ce6131ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131d66939ce6931ce6131ce6131ce6131ce6131c66139debeadfffffffff7efd68e63ce6131ce6931ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffcfb5d67139d67142d66939ce6131ce6131ce6131ce6131ce6131c66939d6c7bdffffffffefefd6714ace6131d66939ce6931d68652fff7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffe7dee7794ade7142d67139ce6931ce6131ce6131ce6131ce6131ce6131ce7142f7efefffffffe7ae94ce6131d66939d66939d69673ffffffffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffffffefa67bef8652de7142d6714adebeadefdfcede9e7bce6131ce6131ce6131f7dfd6ffffffefc7add66939de7142d66939efc7b5ffffffffefef524142ff00ffff00ff0000ff00ffdecfc6f7f7f7ffffffffdfc6f7965af78e5ade794acecfceffffffffefe7d68652ce6131d69e84ffffffffffffdeae94d67139de7142ef9663fff7f7ffffffd6c7bd524142ff00ffff00ff0000ff00ffff00ffdecfc6fffffffffffff7c7adff9e6bf7965ad69e84efefeffffffffffff7ffefdeffffffffffffefe7e7ef9663e7864aef8652f7dfceffffffffffffb59694ff00ffff00ffff00ff0000ff00ffff00ffdecfc6f7f7efffffffffffffffd7adffb684ffa673efb69cdedfdeefefefefefefefefefefe7deefae8cf7965aff9663ffcfb5ffffffffffffdecfc6b59694ff00ffff00ffff00ff0000ff00ffff00ffff00ffdecfc6ffffffffffffffffffffefd6ffdfadffc794ffc794efb69cefb69cffbe9cffb684ffae7bffb68cffe7d6fffffffffffff7efe7bdb6adff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffdecfc6fffffffffffffffffffffff7ffffe7ffffd6ffefb5ffefb5ffdfadffdfadffefd6fffff7fffffffffffffff7efdecfc6ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffdecfc6fff7efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdecfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6fff7effffffffffffffffffffffffffffffffffffffffff7decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6decfc6decfc6decfc6decfc6decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000</value> + </prop> + <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary"> + <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcffffffffffffffffffffffffffffffffffffffffffd0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffffffffffffffffffff251317251317fffffffffffffffffffffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9daffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff402d30ff00ffefeae6e9e0daffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff726361b1aaaad8cbc2ffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffffffffff332124d7cbc2fffffeffffffffffffffffffffffffffffff251317251317000000ffffffffffffffffffffffffffffff2b1a1dd8cdc4ffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff312125d5c8beffffffffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffff251317d9cdc5feffffffffffffffffffffff000000000000ffffffffffff251317251317ffffffffffffffffffffffff3f3033f5f2f0ded6d1ffffffffffffffffff000000251317251317251317251317000000ffffffffffffffffffb28d89c7c6c6ff00ffcbb6aaffffffffffffffffffffffff000000251317251317000000ffffffffffffffffffffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffffffffffffffffffffffffffffffffffffffffffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value> + </prop> + <prop oor:name="ImageBigHC" oor:type="xs:hexBinary"> + <value/> + </prop> + </node> + </node> + </node> + <node oor:name="OfficeHelp"> + <node oor:name="com.sun.star.comp.framework.addon" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Help</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. --> + <value xml:lang="x-no-translate"></value> <value xml:lang="x-no-translate"></value> + <value xml:lang="de">Über Add-On Beispiel</value> + <value xml:lang="en-US">About Add-On Example</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + </node> + </node> +</oor:component-data> diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile new file mode 100644 index 0000000000..239b7e283e --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile @@ -0,0 +1,153 @@ +#************************************************************************* +# +# The Contents of this file are made available subject to the terms of +# the BSD license. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Sun Microsystems, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#************************************************************************** + +# Builds the ProtocolHandlerAddon C++ component example of the SDK. + +PRJ=../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +COMP_NAME=ProtocolHandlerAddon_cpp +COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT) +OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME) +OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME) +OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME) +COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) +COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") +COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml +COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components + +REGISTERFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_register_component.flag + +CXXFILES = component.cxx \ + addon.cxx + +SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES)) + +# Targets +.PHONY: ALL +ALL : \ + Example + +include $(SETTINGS)/stdtarget.mk + +$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< + +ifeq "$(OS)" "WIN" +$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) + -$(MKDIR) $(subst /,$(PS),$(@D)) + -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)) + $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \ + /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \ + $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcprt.lib $(LIBO_SDK_LDFLAGS_STDLIBS) + $(LINK_MANIFEST) +else +$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \ + $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB) +ifeq "$(OS)" "MACOSX" + $(INSTALL_NAME_URELIBS) $@ +endif +endif + +# rule for component package manifest +$(OUT_COMP_GEN)/%/manifest.xml : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ + @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ + @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@ + @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ + +$(COMP_COMPONENTS) : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ + @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)org.openoffice.Office.addon.example$(QM)"$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)com.sun.star.frame.ProtocolHandler$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@ + @echo $(OSEP)/components$(CSEP) >> $@ + +# rule for component package file +$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) + -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM)) + $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM)) + cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components + cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F) + $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu + cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml + +$(REGISTERFLAG) : $(COMP_PACKAGE) +ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + $(DEPLOYTOOL) $(COMP_PACKAGE_URL) + @echo flagged > $(subst /,$(PS),$@) +else + @echo -------------------------------------------------------------------------------- + @echo If you want to install your component automatically, please set the environment + @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only + @echo possible if no office instance is running. + @echo -------------------------------------------------------------------------------- +endif + +Example : $(REGISTERFLAG) + @echo -------------------------------------------------------------------------------- + @echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES. + @echo You can use this component inside your office installation, see the example + @echo description. + @echo -------------------------------------------------------------------------------- + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO)) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL))) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS))) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG))) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*)) diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu new file mode 100644 index 0000000000..eecd51fcfb --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu @@ -0,0 +1,27 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you 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 . +--> +<oor:component-data oor:name="ProtocolHandler" oor:package="org.openoffice.Office" 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="HandlerSet"> + <node oor:name="org.openoffice.Office.addon.example" oor:op="replace"> + <prop oor:name="Protocols" oor:type="oor:string-list"> + <value>org.openoffice.Office.addon.example:*</value> + </prop> + </node> + </node> +</oor:component-data> diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx new file mode 100644 index 0000000000..426caaf361 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +#include <addon.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/awt/Toolkit.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/awt/XMessageBox.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/supportsservice.hxx> +#include <rtl/ustring.hxx> + +using rtl::OUString; +using namespace com::sun::star::uno; +using namespace com::sun::star::frame; +using namespace com::sun::star::awt; +using com::sun::star::beans::PropertyValue; +using com::sun::star::util::URL; + +// This is the service name an Add-On has to implement +#define SERVICE_NAME "com.sun.star.frame.ProtocolHandler" + + +/** + * Show a message box with the UNO based toolkit + */ +static void ShowMessageBox( const Reference< XToolkit >& rToolkit, const Reference< XFrame >& rFrame, const OUString& aTitle, const OUString& aMsgText ) +{ + if ( rFrame.is() && rToolkit.is() ) + { + // describe window properties. + WindowDescriptor aDescriptor; + aDescriptor.Type = WindowClass_MODALTOP; + aDescriptor.WindowServiceName = "infobox"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ); + aDescriptor.Bounds = Rectangle(0,0,300,200); + aDescriptor.WindowAttributes = WindowAttribute::BORDER | +WindowAttribute::MOVEABLE | +WindowAttribute::CLOSEABLE; + + Reference< XWindowPeer > xPeer = rToolkit->createWindow( aDescriptor ); + if ( xPeer.is() ) + { + Reference< XMessageBox > xMsgBox( xPeer, UNO_QUERY ); + if ( xMsgBox.is() ) + { + xMsgBox->setCaptionText( aTitle ); + xMsgBox->setMessageText( aMsgText ); + xMsgBox->execute(); + } + } + } +} + +/** + * Called by the Office framework. + * One-time initialization. We have to store the context information + * given, like the frame we are bound to, into our members. + */ +void SAL_CALL Addon::initialize( const Sequence< Any >& aArguments ) +{ + Reference < XFrame > xFrame; + if ( aArguments.getLength() ) + { + aArguments[0] >>= xFrame; + mxFrame = xFrame; + } + + // Create the toolkit to have access to it later + mxToolkit = Reference< XToolkit >( Toolkit::create(mxContext), UNO_QUERY_THROW ); +} + +/** + * Called by the Office framework. + * We are ask to query the given URL and return a dispatch object if the URL + * contains an Add-On command. + */ +Reference< XDispatch > SAL_CALL Addon::queryDispatch( const URL& aURL, const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags ) +{ + Reference < XDispatch > xRet; + if ( aURL.Protocol.equalsAscii("org.openoffice.Office.addon.example:") ) + { + if ( aURL.Path.equalsAscii( "Function1" ) ) + xRet = this; + else if ( aURL.Path.equalsAscii( "Function2" ) ) + xRet = this; + else if ( aURL.Path.equalsAscii( "Help" ) ) + xRet = this; + } + + return xRet; +} + +/** + * Called by the Office framework. + * We are ask to execute the given Add-On command URL. + */ +void SAL_CALL Addon::dispatch( const URL& aURL, const Sequence < PropertyValue >& lArgs ) +{ + if ( aURL.Protocol.equalsAscii("org.openoffice.Office.addon.example:") ) + { + if ( aURL.Path.equalsAscii( "Function1" ) ) + { + ShowMessageBox( mxToolkit, mxFrame, + OUString( "SDK Add-On example" ), + OUString( "Function 1 activated" ) ); + } + else if ( aURL.Path.equalsAscii( "Function2" ) ) + { + ShowMessageBox( mxToolkit, mxFrame, + OUString( "SDK Add-On example" ), + OUString( "Function 2 activated" ) ); + } + else if ( aURL.Path.equalsAscii( "Help" ) ) + { + // Show info box + ShowMessageBox( mxToolkit, mxFrame, + OUString( "About SDK Add-On example" ), + OUString( "This is the SDK Add-On example" ) ); + } + } +} + +/** + * Called by the Office framework. + * We are ask to query the given sequence of URLs and return dispatch objects if the URLs + * contain Add-On commands. + */ +Sequence < Reference< XDispatch > > SAL_CALL Addon::queryDispatches( const Sequence < DispatchDescriptor >& seqDescripts ) +{ + sal_Int32 nCount = seqDescripts.getLength(); + Sequence < Reference < XDispatch > > lDispatcher( nCount ); + + for( sal_Int32 i=0; i<nCount; ++i ) + lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags ); + + return lDispatcher; +} + +/** + * Called by the Office framework. + * We are ask to query the given sequence of URLs and return dispatch objects if the URLs + * contain Add-On commands. + */ +void SAL_CALL Addon::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) +{ +} + +/** + * Called by the Office framework. + * We are ask to query the given sequence of URLs and return dispatch objects if the URLs + * contain Add-On commands. + */ +void SAL_CALL Addon::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) +{ +} + +// Helper functions for the implementation of UNO component interfaces. +OUString Addon_getImplementationName() +{ + return OUString ( IMPLEMENTATION_NAME ); +} + +Sequence< ::rtl::OUString > SAL_CALL Addon_getSupportedServiceNames() +{ + Sequence < ::rtl::OUString > aRet(1); + ::rtl::OUString* pArray = aRet.getArray(); + pArray[0] = OUString ( SERVICE_NAME ); + return aRet; +} + +Reference< XInterface > SAL_CALL Addon_createInstance( const Reference< XComponentContext > & rContext) +{ + return (cppu::OWeakObject*) new Addon( rContext ); +} + +// Implementation of the recommended/mandatory interfaces of a UNO component. +// XServiceInfo +::rtl::OUString SAL_CALL Addon::getImplementationName( ) +{ + return Addon_getImplementationName(); +} + +sal_Bool SAL_CALL Addon::supportsService( const ::rtl::OUString& rServiceName ) +{ + return cppu::supportsService(this, rServiceName); +} + +Sequence< ::rtl::OUString > SAL_CALL Addon::getSupportedServiceNames( ) +{ + return Addon_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx new file mode 100644 index 0000000000..427b47b2ab --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +#ifndef INCLUDED_EXAMPLES_COMPONENTS_ADDONS_PROTOCOLHANDLERADDON_CPP_ADDON_HXX +#define INCLUDED_EXAMPLES_COMPONENTS_ADDONS_PROTOCOLHANDLERADDON_CPP_ADDON_HXX + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase4.hxx> + +#define IMPLEMENTATION_NAME "org.openoffice.Office.addon.example" + +namespace com +{ + namespace sun + { + namespace star + { + namespace frame + { + class XFrame; + } + namespace awt + { + class XToolkit; + } + namespace uno + { + class XComponentContext; + } + } + } +} + +class Addon : public cppu::WeakImplHelper4 +< + com::sun::star::frame::XDispatchProvider, + com::sun::star::frame::XDispatch, + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo +> +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit; + +public: + Addon( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext) + : mxContext( rxContext ) {} + + // XDispatchProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > + SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, + const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags ); + virtual ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > + SAL_CALL queryDispatches( + const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor ); + + // XDispatch + virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs ); + virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, + const ::com::sun::star::util::URL& aURL ); + virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, + const ::com::sun::star::util::URL& aURL ); + + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); +}; + +::rtl::OUString Addon_getImplementationName(); + +sal_Bool SAL_CALL Addon_supportsService( const ::rtl::OUString& ServiceName ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Addon_getSupportedServiceNames( ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL Addon_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext); + +#endif // INCLUDED_EXAMPLES_COMPONENTS_ADDONS_PROTOCOLHANDLERADDON_CPP_ADDON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx new file mode 100644 index 0000000000..4d34b55219 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +#include <stdio.h> +#include <rtl/ustring.hxx> +#include <uno/lbnames.h> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/factory.hxx> +// generated c++ interfaces +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> + +// include our specific addon header to get access to functions and definitions +#include <addon.hxx> + +using namespace ::rtl; +using namespace ::osl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +/** + * This function is called to get service factories for an implementation. + * + * @param pImplName name of implementation + * @param pServiceManager a service manager, need for component creation + * @param pRegistryKey the registry key for this component, need for persistent data + * @return a component factory + */ +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(const char * pImplName, void * /*pServiceManager*/, void * pRegistryKey) +{ + void * pRet = 0; + + if (rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0) + { + Reference< XSingleComponentFactory > xFactory( createSingleComponentFactory( + Addon_createInstance, + OUString( IMPLEMENTATION_NAME ), + Addon_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu new file mode 100644 index 0000000000..8f302612c7 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu @@ -0,0 +1,207 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you 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 . +--> +<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office"> + <node oor:name="AddonUI"> + <node oor:name="AddonMenu"> + <node oor:name="org.openoffice.Office.addon.example.function" oor:op="replace"> + <prop oor:name="Title" oor:type="xs:string"> + <value xml:lang="en-US">Add-On example</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + <node oor:name="Submenu"> + <node oor:name="m1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 1</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + <node oor:name="m2" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function2</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 2</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + </node> + </node> + </node> + <node oor:name="OfficeMenuBar"> + <node oor:name="org.openoffice.Office.addon.example" oor:op="replace"> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On example</value> + </prop> + <node oor:name="Submenu"> + <node oor:name="m1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 1</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + </node> + <node oor:name="m2" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>private:separator</value> + </prop> + </node> + <node oor:name="m3" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value/> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On sub menu</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <node oor:name="Submenu"> + <node oor:name="submenu1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function2</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Add-On Function 2</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.sheet.SpreadsheetDocument</value> + </prop> + </node> + </node> + </node> + </node> + </node> + </node> + <node oor:name="OfficeToolBar"> + <node oor:name="org.openoffice.Office.addon.example" oor:op="replace"> + <node oor:name="m1" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Function 1</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + </node> + <node oor:name="m2" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Function2</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <value/> + <value xml:lang="en-US">Function 2</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + <prop oor:name="Context" oor:type="xs:string"> + <value>com.sun.star.text.TextDocument</value> + </prop> + </node> + </node> + </node> + <node oor:name="Images"> + <node oor:name="com.sun.star.comp.framework.addon.image1" oor:op="replace"> + <prop oor:name="URL"> + <value>org.openoffice.Office.addon.example:Function1</value> + </prop> + <node oor:name="UserDefinedImages"> + <prop oor:name="ImageSmall" oor:type="xs:hexBinary"> + <value>424df80000000000000076000000280000001000000010000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c0008080800000000000000080000080800000800000808000008000000080008000cccccccccccccccc2c266b181b666c2c5cc66b818b6665c555566b181b66655555566b818b66655555566b181b6665555a8666bbb6668a55a0a866666668a0a5000a8666668a000a6000a86668a000a556000a868a000a55556000a8a000a5555556000a000a55555555600000a55555555556000a55555555555560a55555550000</value> + </prop> + <prop oor:name="ImageBig" oor:type="xs:hexBinary"> + <value>424d180200000000000076000000280000001a0000001a000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c000808080000000000000008000008080000080000080800000800000008000800055555555555555555555555555999990cccccccccccccccccccccccccc9055552cc2c6666b18181b6666c2cc2c99ccccc2ccc6666b81818b66668c2cc5902cc25c2586666b18181b66668ccc5590c2cc555586666b81818b6666855555995c25555586666b18181b6666855555995555555586666b81818b6666855555005555555586666b18181b666685555590555555a5866666b181b6666685a5550955555a0a8666666bbb6666668a0a559955a5a000a866666666666668a000a5995a0a00000a8666666666668a00000a90a000600000a86666666668a00000a50900005600000a866666668a00000a5599600055600000a8666668a00000a555095600555600000a86668a00000a55559955605555600000a868a00000a5555599555655555600000a8a00000a555555005555555555600000a00000a555555590555555555556000000000a555555550955555555555560000000a555555555995555555555555600000a555555555590555555555555556000a555555555550055555555555555560a555555555555905555555555555555555555555555559055550000</value> + </prop> + <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary"> + <value>424df60000000000000076000000280000001000000010000000010004000000000080000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c00080808000000000000000800000808000008000008080000080000000800080002222222222222222222996969699922252299669669995255559969696999555555996696699955555599696969995555969996669996955969699999996969566696999996966699666969996966695596669696966695555966696966695555559666966695555555596666695555555555966695555555555559695555555</value> + </prop> + <prop oor:name="ImageBigHC" oor:type="xs:hexBinary"> + <value/> + </prop> + </node> + </node> + <node oor:name="com.sun.star.comp.framework.addon.image2" oor:op="replace"> + <prop oor:name="URL"> + <value>org.openoffice.Office.addon.example:Help</value> + </prop> + <node oor:name="UserDefinedImages"> + <prop oor:name="ImageSmall" oor:type="xs:hexBinary"> + <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcfffffffbeadee7bca8e7bcabdfb4a2f1c4b0fffffad0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffd49578b7511eb5582ed29d85ce8b6db54513ba5f32eeccb8fffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9dadc9270ba4613bf511dc99076edeae7f2dcced27b54bc4811ba5724d3ad96ffffff402d30ff00ffefeae6e9e0daeabba4ba4308cb5b28cb5f2ecc7046d99979db8f66ce6635cc5d2dbf4e1ab85225ffeee5726361b1aaaad8cbc2ffffffbf4911c65b21cf6532cc5d2bcc764edbae97dfa284ce6a3bcc5b2bcc602ebb4310d28259ffffff332124d7cbc2fffffebb2600d0703bcc612ecb5b2bca7a56dfd3cdf5f4f1e1a686cd6333ce622dc95e2abe3901ffffff2b1a1dd8cdc4ffffffbe2f00d36f40cb602dcb5928c95a29ce8666e9ded7f1dcd2d77e56cd612acc6530c43a00ffffff312125d5c8beffffffcf3f00d66e3dcc632fc95d2ccb5522c44f19cf8c6becd4ccde9b81d06435d05b26c65619ffffff251317d9cdc5fefffff09361e87437da794ad29a7edfa68ad56f3bd5835bedd5cbe3b399d36939db6126e9b395ffffff3f3033f5f2f0ded6d1fff1e4f9a36ff28b52e3b39beeefedf3e5d9f2e7def4f0eaeba87ee66d2fee9e72fffffcb28d89c7c6c6ff00ffcbb6aaffffffffebdcfec08ff6b584edcebbeddaddf3dfdff5cab3f79c66fbaa7dfce8dcffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffcfff2d1fadca3f6cf91fac588fdc68bffe4c5fffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value> + </prop> + <prop oor:name="ImageBig" oor:type="xs:hexBinary"> + <value>424d560800000000000036000000280000001a0000001a00000001001800000000002008000000000000000000000000000000000000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff524142524142524142524142524142524142524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ff524142524142bda69cd6c7bddecfc6ded7d6e7dfd6e7d7cebdbebdb59694524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ff524142fffffffffffffffffffffffffffffffffffffffffff7f7f7ffffffffffffffefefbdb6ad524142524142ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ff524142ffffffffffffffffffefefefdedfdebdb6adc6a694d6a68cdebeade7d7ceefefeff7f7f7ffffffefe7deefe7de524142ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffffffffefe7ded6a68cbd6139bd5929ce6942c6795abd5929bd5931ce8663debeadefefeffffffffff7f7efe7de524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffe7cfc6ce7142bd5929bd5929bd6139d6c7bdffffffd69e84bd5929bd5929bd5929d69e7befefefffffffffefef524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffffffffe7cfc6c66139bd5929c66131ce6131bd7152dedfdeffffffe7c7bdce6131ce6131bd5929bd5929ce8e6befefefffffffdecfc6524142ff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffefe7e7ce7142c66131ce6131ce6131ce6131c66131d6a68cefcfbdd68652ce6131ce6131ce6131c66131bd5929d6a68cffffffffffff524142ff00ffff00ffff00ff0000ff00ffdecfc6fff7f7ffffffdeae94bd5929ce6131ce6931ce6131ce6131ce6131ce6939d67142ce6131ce6131ce6131ce6131ce6131bd5929c66139f7dfd6ffffffdecfc6524142ff00ffff00ff0000ff00ffdecfc6fffffff7efefd6714ac66131ce6931ce6931ce6131ce6131c66939debeadffefe7de966bc66131ce6131ce6131ce6131ce6131bd5929deae94ffffffffefe7524142ff00ffff00ff0000ff00ffdecfc6ffffffefd7cece6131ce6931ce6931ce6131ce6131ce6131c66939d6d7d6ffffffdeb69cce6131ce6131ce6131ce6131ce6131bd5929ce8e63f7f7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131ce6939ce6931ce6131ce6131ce6131ce6131c6a694f7f7f7fff7efd68e63ce6131ce6131ce6131ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131d66939ce6931ce6131ce6131ce6131ce6131c66139debeadfffffffff7efd68e63ce6131ce6931ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffcfb5d67139d67142d66939ce6131ce6131ce6131ce6131ce6131c66939d6c7bdffffffffefefd6714ace6131d66939ce6931d68652fff7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffe7dee7794ade7142d67139ce6931ce6131ce6131ce6131ce6131ce6131ce7142f7efefffffffe7ae94ce6131d66939d66939d69673ffffffffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffffffefa67bef8652de7142d6714adebeadefdfcede9e7bce6131ce6131ce6131f7dfd6ffffffefc7add66939de7142d66939efc7b5ffffffffefef524142ff00ffff00ff0000ff00ffdecfc6f7f7f7ffffffffdfc6f7965af78e5ade794acecfceffffffffefe7d68652ce6131d69e84ffffffffffffdeae94d67139de7142ef9663fff7f7ffffffd6c7bd524142ff00ffff00ff0000ff00ffff00ffdecfc6fffffffffffff7c7adff9e6bf7965ad69e84efefeffffffffffff7ffefdeffffffffffffefe7e7ef9663e7864aef8652f7dfceffffffffffffb59694ff00ffff00ffff00ff0000ff00ffff00ffdecfc6f7f7efffffffffffffffd7adffb684ffa673efb69cdedfdeefefefefefefefefefefe7deefae8cf7965aff9663ffcfb5ffffffffffffdecfc6b59694ff00ffff00ffff00ff0000ff00ffff00ffff00ffdecfc6ffffffffffffffffffffefd6ffdfadffc794ffc794efb69cefb69cffbe9cffb684ffae7bffb68cffe7d6fffffffffffff7efe7bdb6adff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffdecfc6fffffffffffffffffffffff7ffffe7ffffd6ffefb5ffefb5ffdfadffdfadffefd6fffff7fffffffffffffff7efdecfc6ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffdecfc6fff7efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdecfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6fff7effffffffffffffffffffffffffffffffffffffffff7decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6decfc6decfc6decfc6decfc6decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000</value> + </prop> + <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary"> + <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcffffffffffffffffffffffffffffffffffffffffffd0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffffffffffffffffffff251317251317fffffffffffffffffffffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9daffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff402d30ff00ffefeae6e9e0daffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff726361b1aaaad8cbc2ffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffffffffff332124d7cbc2fffffeffffffffffffffffffffffffffffff251317251317000000ffffffffffffffffffffffffffffff2b1a1dd8cdc4ffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff312125d5c8beffffffffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffff251317d9cdc5feffffffffffffffffffffff000000000000ffffffffffff251317251317ffffffffffffffffffffffff3f3033f5f2f0ded6d1ffffffffffffffffff000000251317251317251317251317000000ffffffffffffffffffb28d89c7c6c6ff00ffcbb6aaffffffffffffffffffffffff000000251317251317000000ffffffffffffffffffffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffffffffffffffffffffffffffffffffffffffffffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value> + </prop> + <prop oor:name="ImageBigHC" oor:type="xs:hexBinary"> + <value/> + </prop> + </node> + </node> + </node> + <node oor:name="OfficeHelp"> + <node oor:name="com.sun.star.comp.framework.addon" oor:op="replace"> + <prop oor:name="URL" oor:type="xs:string"> + <value>org.openoffice.Office.addon.example:Help</value> + </prop> + <prop oor:name="Title" oor:type="xs:string"> + <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. --> + <value xml:lang="x-no-translate"></value> + <value xml:lang="de">Über Add-On Beispiel</value> + <value xml:lang="en-US">About Add-On Example</value> + </prop> + <prop oor:name="Target" oor:type="xs:string"> + <value>_self</value> + </prop> + </node> + </node> + </node> +</oor:component-data> diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile new file mode 100644 index 0000000000..fb1edb6b8f --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile @@ -0,0 +1,138 @@ +#************************************************************************* +# +# The Contents of this file are made available subject to the terms of +# the BSD license. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Sun Microsystems, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#************************************************************************** + +# Builds the ProtocolHandlerAddon Java component example of the SDK. + +PRJ=../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +COMP_NAME=ProtocolHandlerAddon_java +OUT_COMP_CLASS=$(OUT_CLASS)/$(COMP_NAME) +OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME) +COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) +COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") +COMP_JAR_NAME=$(COMP_NAME).uno.jar +COMP_JAR=$(OUT_CLASS)/$(COMP_JAR_NAME) +COMP_MANIFESTFILE=$(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest +COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml +COMP_COMPONENTS=$(COMP_NAME).components + +REGISTERFLAG=$(OUT_COMP_MISC)$(PS)java_$(COMP_NAME)_register_component.flag + +JAVAFILES = ProtocolHandlerAddon.java + +CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES)) + +SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ + $(PATH_SEPARATOR)$(OUT_COMP_CLASS)) + + +# Targets +.PHONY: ALL +ALL : DevGuideProtocolHandlerAddon + +include $(SETTINGS)/stdtarget.mk + +$(OUT_COMP_CLASS)/%.Manifest : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo RegistrationClassName: ProtocolHandlerAddon> $@ + +$(CLASSFILES) : $(JAVAFILES) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES) + +# rule for component jar file +$(COMP_JAR) : $(COMP_MANIFESTFILE) $(CLASSFILES) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) . + +# rule for component package manifest +$(OUT_COMP_CLASS)/%/manifest.xml : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ + @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ + @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@ + @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@ + @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@ + @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ + +# rule for component package file +$(COMP_PACKAGE) : $(COMP_JAR) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC)) + $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_MISC)) + cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) ../../bin/$(@F) $(<F) + $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu $(COMP_COMPONENTS) + cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml + +$(REGISTERFLAG) : $(COMP_PACKAGE) +ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(DEPLOYTOOL) $(COMP_PACKAGE_URL) + @echo flagged > $(subst /,$(PS),$@) +else + @echo -------------------------------------------------------------------------------- + @echo If you want to install your component automatically, please set the environment + @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only + @echo possible if no office instance is running. + @echo -------------------------------------------------------------------------------- +endif + +DevGuideProtocolHandlerAddon : $(REGISTERFLAG) + @echo -------------------------------------------------------------------------------- + @echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES. + @echo You can use this component inside your office installation, see the example + @echo description. + @echo -------------------------------------------------------------------------------- + +%.run: $(OUT_COMP_CLASS)/%.class + $SDJ_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@) + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC)) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL))) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_JAR))) diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu new file mode 100644 index 0000000000..7974c3e958 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu @@ -0,0 +1,27 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you 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 . +--> +<oor:component-data oor:name="ProtocolHandler" oor:package="org.openoffice.Office" 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="HandlerSet"> + <node oor:name="ProtocolHandlerAddon$ProtocolHandlerAddonImpl" oor:op="replace"> + <prop oor:name="Protocols" oor:type="oor:string-list"> + <value>org.openoffice.Office.addon.example:*</value> + </prop> + </node> + </node> +</oor:component-data> diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java new file mode 100644 index 0000000000..c12c69288f --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java @@ -0,0 +1,254 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the BSD license. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.Factory; +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.frame.XStatusListener; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.DispatchDescriptor; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.awt.XMessageBox; +import com.sun.star.awt.WindowAttribute; +import com.sun.star.awt.WindowClass; +import com.sun.star.awt.WindowDescriptor; +import com.sun.star.awt.Rectangle; + +public class ProtocolHandlerAddon { + /** This class implements the component. At least the interfaces XServiceInfo, + * XTypeProvider, and XInitialization should be provided by the service. + */ + public static class ProtocolHandlerAddonImpl extends WeakBase implements + XDispatchProvider, + XDispatch, + XInitialization, + XServiceInfo { + + /** The service name, that must be used to get an instance of this service. + */ + private static final String[] m_serviceNames = { "com.sun.star.frame.ProtocolHandler" }; + + /** The component context, that gives access to the service manager and all registered services. + */ + private final XComponentContext m_xCmpCtx; + + /** The toolkit, that we can create UNO dialogs. + */ + private XToolkit m_xToolkit; + + /** The frame where the addon depends on. + */ + private XFrame m_xFrame; + + + /** The constructor of the inner class has a XMultiServiceFactory parameter. + * @param xComponentContext A special service factory + * could be introduced while initializing. + */ + public ProtocolHandlerAddonImpl( XComponentContext xComponentContext ) { + m_xCmpCtx = xComponentContext; + } + + /** This method is a member of the interface for initializing an object + * directly after its creation. + * @param object This array of arbitrary objects will be passed to the + * component after its creation. + * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be + * passed to the caller. + */ + public void initialize( Object[] object ) + throws com.sun.star.uno.Exception { + + if ( object.length > 0 ) + { + m_xFrame = UnoRuntime.queryInterface( + XFrame.class, object[ 0 ] ); + } + + // Create the toolkit to have access to it later + m_xToolkit = UnoRuntime.queryInterface( + XToolkit.class, + m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", + m_xCmpCtx)); + } + + /** This method returns an array of all supported service names. + * @return Array of supported service names. + */ + public String[] getSupportedServiceNames() { + return getServiceNames(); + } + + public static String[] getServiceNames() { + return m_serviceNames; + } + + /** This method returns true, if the given service will be + * supported by the component. + * @return True, if the given service name will be supported. + */ + public boolean supportsService( String sService ) { + int len = m_serviceNames.length; + + for( int i=0; i < len; i++) { + if ( sService.equals( m_serviceNames[i] ) ) + return true; + } + + return false; + } + + /** Return the class name of the component. + * @return Class name of the component. + */ + public String getImplementationName() { + return ProtocolHandlerAddonImpl.class.getName(); + } + + // XDispatchProvider + public XDispatch queryDispatch( /*IN*/com.sun.star.util.URL aURL, + /*IN*/String sTargetFrameName, + /*IN*/int iSearchFlags ) { + XDispatch xRet = null; + if ( aURL.Protocol.equals("org.openoffice.Office.addon.example:") ) { + if ( aURL.Path.equals( "Function1" ) ) + xRet = this; + if ( aURL.Path.equals( "Function2" ) ) + xRet = this; + if ( aURL.Path.equals( "Help" ) ) + xRet = this; + } + return xRet; + } + + public XDispatch[] queryDispatches( /*IN*/DispatchDescriptor[] seqDescripts ) { + int nCount = seqDescripts.length; + XDispatch[] lDispatcher = new XDispatch[nCount]; + + for( int i=0; i<nCount; ++i ) + lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, + seqDescripts[i].FrameName, + seqDescripts[i].SearchFlags ); + + return lDispatcher; + } + + // XDispatch + public void dispatch( /*IN*/com.sun.star.util.URL aURL, + /*IN*/com.sun.star.beans.PropertyValue[] aArguments ) { + + if ( aURL.Protocol.equals("org.openoffice.Office.addon.example:") ) + { + if ( aURL.Path.equals( "Function1" ) ) + { + showMessageBox("SDK DevGuide Add-On example", "Function 1 activated"); + } + if ( aURL.Path.equals( "Function2" ) ) + { + showMessageBox("SDK DevGuide Add-On example", "Function 2 activated"); + } + if ( aURL.Path.equals( "Help" ) ) + { + showMessageBox("About SDK DevGuide Add-On example", "This is the SDK Add-On example"); + } + } + } + + public void addStatusListener( /*IN*/XStatusListener xControl, + /*IN*/com.sun.star.util.URL aURL ) { + } + + public void removeStatusListener( /*IN*/XStatusListener xControl, + /*IN*/com.sun.star.util.URL aURL ) { + } + + public void showMessageBox(String sTitle, String sMessage) { + if ( null == m_xFrame || null == m_xToolkit ) { + return; + } + // describe window properties. + WindowDescriptor aDescriptor = new WindowDescriptor(); + aDescriptor.Type = WindowClass.MODALTOP; + aDescriptor.WindowServiceName = "infobox"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = UnoRuntime.queryInterface( + XWindowPeer.class, m_xFrame.getContainerWindow()); + aDescriptor.Bounds = new Rectangle(0,0,300,200); + aDescriptor.WindowAttributes = WindowAttribute.BORDER | + WindowAttribute.MOVEABLE | + WindowAttribute.CLOSEABLE; + + XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); + if ( null != xPeer ) { + XMessageBox xMsgBox = UnoRuntime.queryInterface( + XMessageBox.class, xPeer); + if ( null != xMsgBox ) + { + xMsgBox.setCaptionText( sTitle ); + xMsgBox.setMessageText( sMessage ); + xMsgBox.execute(); + } + } + } + } + + + /** Gives a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return Returns a <code>XSingleServiceFactory</code> for creating the + * component. + * @see com.sun.star.comp.loader.JavaLoader + * @param sImplementationName The implementation name of the component. + */ + public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) { + XSingleComponentFactory xFactory = null; + + if ( sImplementationName.equals( ProtocolHandlerAddonImpl.class.getName() ) ) + xFactory = Factory.createComponentFactory(ProtocolHandlerAddonImpl.class, + ProtocolHandlerAddonImpl.getServiceNames()); + + return xFactory; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components new file mode 100644 index 0000000000..13665ebbc3 --- /dev/null +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<components xmlns="http://openoffice.org/2010/uno-components"> + <component loader="com.sun.star.loader.Java2" uri="ProtocolHandlerAddon_java.uno.jar"> + <implementation name="ProtocolHandlerAddon$ProtocolHandlerAddonImpl"> + <service name="com.sun.star.frame.ProtocolHandler"/> + </implementation> + </component> +</components> |