diff options
Diffstat (limited to '')
7 files changed, 410 insertions, 0 deletions
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/basic/FirstUnoContact.bas b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/basic/FirstUnoContact.bas new file mode 100644 index 0000000000..ba8f542d83 --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/basic/FirstUnoContact.bas @@ -0,0 +1,17 @@ +' +' 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/. +' + +Sub Main + Set oContext = GetDefaultContext() + MsgBox "Connected to a running office..." + Set oServiceManager=oContext.GetServiceManager() + If IsNull(oServiceManager) Then + bAvailable = "not " + End If + MsgBox "ServiceManager is " + bAvailable + "available" +End Sub
\ No newline at end of file diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/cxx/FirstUnoContact.cxx b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/cxx/FirstUnoContact.cxx new file mode 100644 index 0000000000..a19bfbb023 --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/cxx/FirstUnoContact.cxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; + * fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <cppuhelper/bootstrap.hxx> +#include <cstddef> +#include <iostream> +#include <sal/main.h> + +SAL_IMPLEMENT_MAIN() +{ + try + { + css::uno::Reference<css::uno::XComponentContext> xContext(cppu::bootstrap()); + std::cout << "Connected to a running office ..." << std::endl; + css::uno::Reference<css::lang::XMultiComponentFactory> xMCF = xContext->getServiceManager(); + std::string available = xMCF != NULL ? "available" : "not available"; + std::cout << "remote ServiceManager is " + available << std::endl; + } + catch (css::uno::Exception& e) + { + std::cout << e.Message << std::endl; + return 1; + } + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s + * cinkeys+=0=break: */ diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/cxx/Makefile b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/cxx/Makefile new file mode 100644 index 0000000000..a996044c60 --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/cxx/Makefile @@ -0,0 +1,100 @@ +#************************************************************************* +# +# 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 FirstUnoContact example of the SDK. + +PRJ=../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +APP_NAME=FirstUnoContact + +OUT_APP_INC = $(OUT_INC)/$(APP_NAME) +OUT_APP_GEN = $(OUT_MISC)/$(APP_NAME) +OUT_APP_OBJ=$(OUT_OBJ)/$(APP_NAME) + +CXXFILES = FirstUnoContact.cxx + +OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES)) + +# Targets +.PHONY: ALL +ALL : \ + FirstUnoContact + +include $(SETTINGS)/stdtarget.mk + +$(OUT_APP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_APP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< + +$(OUT_BIN)/_$(APP_NAME)$(EXE_EXT) : $(OUT_APP_OBJ)/$(APP_NAME).$(OBJ_EXT) + -$(MKDIR) $(subst /,$(PS),$(@D)) + -$(MKDIR) $(subst /,$(PS),$(OUT_APP_GEN)) +ifeq "$(OS)" "WIN" + $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_APP_GEN)/$(basename $(@F)).map \ + $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) +else + $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \ + $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB) +ifeq "$(OS)" "MACOSX" + $(INSTALL_NAME_URELIBS_BIN) $@ +endif +endif + +$(OUT_BIN)/$(APP_NAME)$(EXE_EXT) : $(OUT_BIN)/_$(APP_NAME)$(EXE_EXT) + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst /,$(PS),$@) +# workaround for touch problem under Windows with full qualified paths + make -t $@ + +FirstUnoContact : $(OUT_BIN)/$(APP_NAME)$(EXE_EXT) + @echo -------------------------------------------------------------------------------- + @echo Please use the following command to execute the example! + @echo - + @echo $(MAKE) FirstUnoContact.run + @echo -------------------------------------------------------------------------------- + +%.run: $(OUT_BIN)/FirstUnoContact$(EXE_EXT) + cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_INC)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_GEN)) + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_OBJ)) + -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*FirstUnoContact*)) diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/FirstUnoContact.java b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/FirstUnoContact.java new file mode 100644 index 0000000000..9f4de1a6e6 --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/FirstUnoContact.java @@ -0,0 +1,61 @@ +/* -*- 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. + * + *************************************************************************/ + +public class FirstUnoContact { + + public static void main(String[] args) { + try { + // get the remote office component context + com.sun.star.uno.XComponentContext xContext = + com.sun.star.comp.helper.Bootstrap.bootstrap(); + + System.out.println("Connected to a running office ..."); + + com.sun.star.lang.XMultiComponentFactory xMCF = + xContext.getServiceManager(); + + String available = (xMCF != null ? "available" : "not available"); + System.out.println( "remote ServiceManager is " + available ); + } + catch (java.lang.Exception e){ + e.printStackTrace(); + } + finally { + System.exit(0); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/Makefile b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/Makefile new file mode 100644 index 0000000000..eae7d4452f --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/Makefile @@ -0,0 +1,92 @@ +#************************************************************************* +# +# 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 FirstSteps examples of the Developers Guide. + +PRJ=../../../../.. +SETTINGS=$(PRJ)/settings + +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk + +# Define non-platform/compiler specific settings +EXAMPLE_NAME=FirstUnoContact +OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME) + +APP_NAME=FirstUnoContact +APP_JAR=$(OUT_APP_CLASS)/$(APP_NAME).jar + +SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ + $(PATH_SEPARATOR)$(OUT_APP_CLASS)) + + +# Targets +.PHONY: ALL +ALL : \ + $(EXAMPLE_NAME) + +include $(SETTINGS)/stdtarget.mk + +$(OUT_APP_CLASS)/%.class : %.java + -$(MKDIR) $(subst /,$(PS),$(@D)) + $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $< + +$(OUT_APP_CLASS)/%.mf : + -$(MKDIR) $(subst /,$(PS),$(@D)) + @echo Main-Class: com.sun.star.lib.loader.Loader> $@ + $(ECHOLINE)>> $@ + @echo Name: com/sun/star/lib/loader/Loader.class>> $@ + @echo Application-Class: $*>> $@ + +$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class + -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) + -$(MKDIR) $(subst /,$(PS),$(@D)) + +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class + +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) + +$(APP_JAR) : $(OUT_APP_CLASS)/$(APP_NAME).mf $(OUT_APP_CLASS)/$(APP_NAME).class + +$(EXAMPLE_NAME) : $(APP_JAR) + @echo -------------------------------------------------------------------------------- + @echo Please use the following command to execute the example! + @echo - + @echo $(MAKE) $(APP_NAME).run + @echo -------------------------------------------------------------------------------- + +%.run: $(OUT_APP_CLASS)/%.jar + $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< + +.PHONY: clean +clean : + -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS)) diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/build.xml b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/build.xml new file mode 100644 index 0000000000..ec0eba70ad --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/java/build.xml @@ -0,0 +1,80 @@ +<?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 . +--> +<project basedir="." default="all" name="FirstUnoContact"> + + <property environment="env"/> + <property name="OFFICE_HOME" value="${env.OFFICE_HOME}"/> + <property name="OO_SDK_HOME" value="${env.OO_SDK_HOME}"/> + + <target name="init"> + <property name="OUTDIR" value="${OO_SDK_HOME}/WINExample.out/class/FirstUnoContact"/> + </target> + + <path id="office.class.path"> + <filelist dir="${OFFICE_HOME}/program/classes" + files="libreoffice.jar"/> + </path> + + <fileset id="bootstrap.glue.code" dir="${OO_SDK_HOME}/classes"> + <patternset> + <include name="com/sun/star/lib/loader/*.class"/> + </patternset> + </fileset> + + <target name="compile" depends="init"> + <mkdir dir="${OUTDIR}"/> + <javac debug="true" deprecation="true" destdir="${OUTDIR}" srcdir="."> + <classpath refid="office.class.path"/> + </javac> + </target> + + <target name="jar" depends="init,compile"> + <jar basedir="${OUTDIR}" compress="true" + jarfile="${OUTDIR}/FirstUnoContact.jar"> + <exclude name="**/*.java"/> + <exclude name="*.jar"/> + <fileset refid="bootstrap.glue.code"/> + <manifest> + <attribute name="Main-Class" value="com.sun.star.lib.loader.Loader"/> + <section name="com/sun/star/lib/loader/Loader.class"> + <attribute name="Application-Class" value="FirstUnoContact"/> + </section> + </manifest> + </jar> + </target> + + <target name="all" description="Build everything." depends="init,compile,jar"> + <echo message="Application built. FirstUnoContact!"/> + </target> + + <target name="run" description="Try running it." depends="init,all"> + <java jar="${OUTDIR}/FirstUnoContact.jar" failonerror="true" fork="true"> + </java> + </target> + + <target name="clean" description="Clean all build products." depends="init"> + <delete> + <fileset dir="${OUTDIR}"> + <include name="**/*.class"/> + </fileset> + </delete> + <delete file="${OUTDIR}/FirstUnoContact.jar"/> + </target> + +</project> diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/python/FirstUnoContact.py b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/python/FirstUnoContact.py new file mode 100644 index 0000000000..06cd0bc5a7 --- /dev/null +++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact/python/FirstUnoContact.py @@ -0,0 +1,24 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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/. +# + +import uno +import officehelper + +try: + xContext = officehelper.bootstrap() + print("Connected to a running office ...") + xMCF = xContext.getServiceManager() + available = "not available" if xMCF is None else "available" + print("remote ServiceManager is " + available) + +except Exception as e: + print(e) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: + |