summaryrefslogtreecommitdiffstats
path: root/odk/examples/cpp/complextoolbarcontrols
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/cpp/complextoolbarcontrols')
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/Addons.xcu187
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx32
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu38
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/Jobs.xcu39
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx138
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h85
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/Makefile182
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyJob.cxx97
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyJob.h91
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyListener.cxx134
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyListener.h116
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx501
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h161
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/ProtocolHandler.xcu27
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx40
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu38
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/description.xml26
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/exports.cxx68
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/logo_big.pngbin0 -> 616 bytes
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/logo_small.pngbin0 -> 585 bytes
20 files changed, 2000 insertions, 0 deletions
diff --git a/odk/examples/cpp/complextoolbarcontrols/Addons.xcu b/odk/examples/cpp/complextoolbarcontrols/Addons.xcu
new file mode 100644
index 000000000..786c3ad29
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/Addons.xcu
@@ -0,0 +1,187 @@
+<?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="OfficeToolBar">
+ <node oor:name="com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:ImageButtonCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Image Button</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>ImageButton</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:ComboboxCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">ComboBox</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Combobox</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>200</value>
+ </prop>
+ </node>
+ <node oor:name="m3" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m4" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:SpinfieldCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Spinfield</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Spinfield</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>150</value>
+ </prop>
+ </node>
+ <node oor:name="m5" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m6" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:EditfieldCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Editfield</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Editfield</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>130</value>
+ </prop>
+ </node>
+ <node oor:name="m7" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m8" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:DropdownboxCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Dropdownbox</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Dropdownbox</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>80</value>
+ </prop>
+ </node>
+ <node oor:name="m9" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:ToggleDropdownButtonCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Toggle Dropdown Button</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>ToggleDropdownButton</value>
+ </prop>
+ </node>
+ <node oor:name="m10" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:DropdownButtonCmd</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Dropdown Button</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>DropdownButton</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Images">
+ <node oor:name="vnd.demo.complextoolbarcontrols.image1" oor:op="replace">
+ <prop oor:name="URL">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:ImageButtonCmd</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmallURL" oor:type="xs:string">
+ <value>%origin%/logo_small.png</value>
+ </prop>
+ <prop oor:name="ImageBigURL" oor:type="xs:string">
+ <value>%origin%/logo_big.png</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx b/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx
new file mode 100644
index 000000000..e02a5d695
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+
+#include "MyListener.h"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+void SAL_CALL CalcListener::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL CalcListener::disposing( const com::sun::star::lang::EventObject& aSource ) throw( com::sun::star::uno::RuntimeException )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu b/odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu
new file mode 100644
index 000000000..4d9f71c29
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu
@@ -0,0 +1,38 @@
+<?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="CalcWindowState" oor:package="org.openoffice.Office.UI">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolbar/addon_com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
+ <prop oor:name="ContextSensitive" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">Complex Toolbar Controls</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ <prop oor:name="Docked" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data> \ No newline at end of file
diff --git a/odk/examples/cpp/complextoolbarcontrols/Jobs.xcu b/odk/examples/cpp/complextoolbarcontrols/Jobs.xcu
new file mode 100644
index 000000000..976e48434
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/Jobs.xcu
@@ -0,0 +1,39 @@
+<?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="DemoAddOn" oor:op="replace">
+ <prop oor:name="Service">
+ <value>vnd.demo.NewDocListener</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="OnNew" oor:op="replace">
+ <node oor:name="JobList">
+ <node oor:name="DemoAddOn" oor:op="replace"/>
+ </node>
+ </node>
+ <node oor:name="OnLoad" oor:op="replace">
+ <node oor:name="JobList">
+ <node oor:name="DemoAddOn" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx
new file mode 100644
index 000000000..0ee09734a
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+#include <osl/diagnose.h>
+
+#include "ListenerHelper.h"
+
+using com::sun::star::frame::XFrame;
+using com::sun::star::frame::XDispatch;
+using com::sun::star::frame::XStatusListener;
+using com::sun::star::lang::EventObject;
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::frame::FeatureStateEvent;
+
+static AllListeners aListeners;
+
+void ListenerHelper::AddListener(
+ const Reference < XFrame >& xFrame,
+ const Reference < XStatusListener > xControl,
+ const ::rtl::OUString& aCommand )
+{
+ sal_uInt32 i=0;
+ sal_uInt32 nSize = aListeners.size();
+ for ( i=0; i<nSize; i++ )
+ if ( aListeners[i].xFrame == xFrame )
+ break;
+
+ OSL_ENSURE( i<nSize, "No dispatch found for this listener!" );
+ aListeners[i].aContainer[aCommand].push_back( xControl );
+}
+
+void ListenerHelper::RemoveListener(
+ const Reference < XFrame >& xFrame,
+ const Reference < XStatusListener > xControl,
+ const ::rtl::OUString& aCommand )
+{
+ sal_uInt32 nSize = aListeners.size();
+ for ( sal_uInt32 i=0; i<nSize; i++ )
+ {
+ if ( aListeners[i].xFrame == xFrame )
+ {
+ StatusListeners& aL = aListeners[i].aContainer[aCommand];
+ StatusListeners::iterator aIter = aL.begin();
+ while ( aIter != aL.end() )
+ {
+ if ( (*aIter) == xControl )
+ {
+ aL.erase( aIter );
+ break;
+ }
+
+ ++aIter;
+ }
+ }
+ }
+}
+
+void ListenerHelper::Notify(
+ const Reference < XFrame >& xFrame,
+ const ::rtl::OUString& aCommand,
+ FeatureStateEvent& rEvent )
+{
+ sal_uInt32 nSize = aListeners.size();
+ for ( sal_uInt32 i=0; i<nSize; i++ )
+ {
+ if ( aListeners[i].xFrame == xFrame )
+ {
+ rEvent.Source = aListeners[i].xDispatch;
+ StatusListeners& aL = aListeners[i].aContainer[aCommand];
+ StatusListeners::iterator aIter = aL.begin();
+ while ( aIter != aL.end() )
+ {
+ (*aIter)->statusChanged( rEvent );
+ ++aIter;
+ }
+ }
+ }
+}
+
+com::sun::star::uno::Reference < XDispatch > ListenerHelper::GetDispatch(
+ const Reference < XFrame >& xFrame,
+ const ::rtl::OUString& aCommand )
+{
+ sal_uInt32 nSize = aListeners.size();
+ for ( sal_uInt32 i=0; i<nSize; i++ )
+ {
+ if ( aListeners[i].xFrame == xFrame )
+ return aListeners[i].xDispatch;
+ }
+
+ return Reference < XDispatch >();
+}
+
+void ListenerHelper::AddDispatch(
+ const Reference < XDispatch > xDispatch,
+ const Reference < XFrame >& xFrame,
+ const ::rtl::OUString& aCommand )
+{
+ ListenerItem aItem;
+ aItem.xFrame = xFrame;
+ aItem.xDispatch = xDispatch;
+ aListeners.push_back( aItem );
+ xFrame->addEventListener( new ListenerItemEventListener( xFrame ) );
+}
+
+void SAL_CALL ListenerItemEventListener::disposing( const EventObject& aEvent) throw (RuntimeException)
+{
+ AllListeners::iterator aIter = aListeners.begin();
+ while ( aIter != aListeners.end() )
+ {
+ if ( (*aIter).xFrame == mxFrame )
+ {
+ aListeners.erase( aIter );
+ break;
+ }
+
+ ++aIter;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h
new file mode 100644
index 000000000..f24150df7
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+#ifndef INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_LISTENERHELPER_H
+#define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_LISTENERHELPER_H
+
+#include <map>
+#include <vector>
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+typedef std::vector < com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > > StatusListeners;
+
+typedef std::map < ::rtl::OUString, StatusListeners > ListenerMap;
+
+// For every frame there is *one* Dispatch object for all possible commands
+// this struct contains an array of listeners for every supported command
+// these arrays are accessed by a std::map (with the command string as index)
+struct ListenerItem
+{
+ ListenerMap aContainer;
+ ::com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > xDispatch;
+ ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame;
+};
+
+typedef std::vector < ListenerItem > AllListeners;
+
+class ListenerHelper
+{
+public:
+ void AddListener(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
+ const ::rtl::OUString& aCommand );
+ void RemoveListener(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
+ const ::rtl::OUString& aCommand );
+ void Notify(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const ::rtl::OUString& aCommand,
+ com::sun::star::frame::FeatureStateEvent& rEvent );
+ com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > GetDispatch(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const ::rtl::OUString& aCommand );
+ void AddDispatch(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xDispatch,
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const ::rtl::OUString& aCommand );
+};
+
+class ListenerItemEventListener : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XEventListener >
+{
+ ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame;
+public:
+ ListenerItemEventListener( const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame)
+ : mxFrame(xFrame)
+ {}
+ virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/Makefile b/odk/examples/cpp/complextoolbarcontrols/Makefile
new file mode 100644
index 000000000..ad75987cf
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/Makefile
@@ -0,0 +1,182 @@
+ #*************************************************************************
+#
+# 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 complextoolbarcontrols C++ component example of the SDK.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/platform.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=complextoolbarcontrols
+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_UNOPKG_DESCRIPTION = $(OUT_COMP_GEN)/$(COMPONENT_NAME)/description.xml
+COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
+COMP_REGISTERFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_register_component.flag
+COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
+
+CXXFILES = \
+ MyProtocolHandler.cxx \
+ MyJob.cxx \
+ MyListener.cxx \
+ WriterListener.cxx \
+ CalcListener.cxx \
+ ListenerHelper.cxx \
+ exports.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) $(STL_INCLUDES) $(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 extension description.xml
+$(COMP_UNOPKG_DESCRIPTION) : description.xml
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_CAT) $< | $(SDK_SED) -e "s/#EXTENSION_PLATFORM#/$(EXTENSION_PLATFORM)/" > $@
+
+# 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)WriterWindowState.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)CalcWindowState.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 $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
+# @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_GEN)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(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)vnd.My.impl.NewDocListener$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)vnd.My.NewDocListener$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)vnd.demo.Impl.ProtocolHandler$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)vnd.demo.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 WriterWindowState.xcu CalcWindowState.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) $(COMP_UNOPKG_DESCRIPTION)
+ -$(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) -u ../../bin/$(@F) $(COMP_NAME).components description.xml
+ $(CD) $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
+ $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu WriterWindowState.xcu CalcWindowState.xcu logo_small.png logo_big.png
+ $(CD) $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_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 : $(COMP_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: $(COMP1_COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" --writer
+
+
+.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_REGISTERFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx b/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx
new file mode 100644
index 000000000..656eb6942
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+
+#include "MyJob.h"
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+using rtl::OUString;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::Any;
+using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::Exception;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::lang::IllegalArgumentException;
+using com::sun::star::lang::XMultiServiceFactory;
+using com::sun::star::beans::NamedValue;
+using com::sun::star::document::XEventBroadcaster;
+
+Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
+ throw ( IllegalArgumentException, Exception, RuntimeException )
+{
+ Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(
+ "com.sun.star.frame.GlobalEventBroadcaster" ), UNO_QUERY );
+ Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
+ "com.sun.star.comp.Office.MyListener" ), UNO_QUERY );
+ if ( xBrd.is() )
+ xBrd->addEventListener( xLstner );
+ return Any();
+}
+
+OUString MyJob_getImplementationName ()
+ throw (RuntimeException)
+{
+ return OUString( "com.sun.star.comp.Office.MyJob" );
+}
+
+#define SERVICE_NAME "com.sun.star.task.Job"
+
+Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence < OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString( SERVICE_NAME );
+ return aRet;
+}
+
+#undef SERVICE_NAME
+
+Reference< XInterface > SAL_CALL MyJob_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new MyJob( rSMgr );
+}
+
+// XServiceInfo
+OUString SAL_CALL MyJob::getImplementationName( )
+ throw (RuntimeException)
+{
+ return MyJob_getImplementationName();
+}
+
+sal_Bool SAL_CALL MyJob::supportsService( const OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SAL_CALL MyJob::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return MyJob_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyJob.h b/odk/examples/cpp/complextoolbarcontrols/MyJob.h
new file mode 100644
index 000000000..0741e5eed
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyJob.h
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+#ifndef INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYJOB_H
+#define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYJOB_H
+
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace frame
+ {
+ class XModel;
+ class XFrame;
+ }
+ namespace beans
+ {
+ struct NamedValue;
+ }
+ }
+ }
+}
+
+class MyJob : public cppu::WeakImplHelper2
+<
+ com::sun::star::task::XJob,
+ com::sun::star::lang::XServiceInfo
+>
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+
+public:
+ MyJob( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF ) {}
+ virtual ~MyJob() {}
+
+ // XJob
+ virtual ::com::sun::star::uno::Any SAL_CALL execute(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+::rtl::OUString MyJob_getImplementationName()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL MyJob_supportsService( const ::rtl::OUString& ServiceName )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyJob_getSupportedServiceNames( )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL MyJob_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+ throw ( ::com::sun::star::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx b/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx
new file mode 100644
index 000000000..82f8d01a3
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+
+#include "MyListener.h"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+MyListener::MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+ : m_xSMGR(xSMGR)
+{}
+
+MyListener::~MyListener()
+{}
+
+css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::Exception,
+ css::uno::RuntimeException)
+{
+ css::uno::Sequence< css::beans::NamedValue > lEnv;
+
+ sal_Int32 i = 0;
+ sal_Int32 c = lArguments.getLength();
+ const css::beans::NamedValue* p = lArguments.getConstArray();
+ for (i=0; i<c; ++i)
+ {
+ if ( p[i].Name == "Environment" )
+ {
+ p[i].Value >>= lEnv;
+ break;
+ }
+ }
+
+ css::uno::Reference< css::frame::XModel > xModel;
+
+ c = lEnv.getLength();
+ p = lEnv.getConstArray();
+ for (i=0; i<c; ++i)
+ {
+ if ( p[i].Name == "Model" )
+ {
+ p[i].Value >>= xModel;
+ break;
+ }
+ if ( p[i].Name == "Frame" )
+ {
+ css::uno::Reference< css::frame::XController > xController;
+ css::uno::Reference< css::frame::XFrame > xFrame;
+ p[i].Value >>= xFrame;
+ if (xFrame.is())
+ xController = xFrame->getController();
+ if (xController.is())
+ xModel = xController->getModel();
+ break;
+ }
+ }
+
+ if (!xModel.is())
+ return css::uno::Any();
+
+ css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
+ sal_Bool bCalc = xInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument");
+ sal_Bool bWriter = ( xInfo->supportsService("com.sun.star.text.TextDocument") &&
+ !xInfo->supportsService("com.sun.star.text.WebDocument") &&
+ !xInfo->supportsService("com.sun.star.text.GlobalDocument") );
+
+ // We are interested only in Writer and Calc. However, here we are
+ // notified of all newly opened Documents...
+ if (!bCalc && !bWriter)
+ return css::uno::Any();
+
+ void* pListener = 0;
+ if (bCalc)
+ pListener = (void*)(new CalcListener(m_xSMGR));
+ else
+ if (bWriter)
+ pListener = (void*)(new WriterListener(m_xSMGR));
+
+ css::uno::Reference< css::document::XEventListener > xDocListener (static_cast< css::document::XEventListener* >(pListener), css::uno::UNO_QUERY);
+ css::uno::Reference< css::document::XEventBroadcaster > xDocBroadcaster (xModel , css::uno::UNO_QUERY);
+
+ xDocBroadcaster->addEventListener(xDocListener);
+
+ return css::uno::Any();
+}
+
+::rtl::OUString SAL_CALL MyListener::getImplementationName()
+ throw (css::uno::RuntimeException)
+{
+ return ::rtl::OUString( MYLISTENER_IMPLEMENTATIONNAME );
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL MyListener::getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = ::rtl::OUString( MYLISTENER_SERVICENAME );
+ return lNames;
+}
+
+sal_Bool SAL_CALL MyListener::supportsService(const ::rtl::OUString& sServiceName)
+ throw (css::uno::RuntimeException)
+{
+ return cppu::supportsService(this, sServiceName);
+}
+
+css::uno::Reference< css::uno::XInterface > MyListener::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+{
+ MyListener* pListener = new MyListener(xSMGR);
+ css::uno::Reference< css::uno::XInterface > xListener(static_cast< css::task::XJob* >(pListener), css::uno::UNO_QUERY);
+ return xListener;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyListener.h b/odk/examples/cpp/complextoolbarcontrols/MyListener.h
new file mode 100644
index 000000000..428693dac
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyListener.h
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+#ifndef INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYLISTENER_H
+#define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYLISTENER_H
+
+#include <sal/config.h>
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
+#define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
+
+/**
+ * Register in the Office configuration as job.
+ * This is called automatically for all new opened documents. You receive
+ * a reference of the opened document and then you can check if it's a
+ * supported format. (We are only interested in Writer/Calc documents.)
+ *
+ * @see CalcListener
+ * @see WriterListener
+ */
+class MyListener : public cppu::WeakImplHelper2< css::task::XJob ,
+ css::lang::XServiceInfo >
+{
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
+ public:
+ MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+ virtual ~MyListener();
+
+ // XJob
+ virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::Exception,
+ css::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException);
+
+ public:
+
+ static css::uno::Reference< css::uno::XInterface > st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+};
+
+class CalcListener : public cppu::WeakImplHelper1< css::document::XEventListener >
+{
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+
+
+ public:
+ CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF )
+ {}
+
+ virtual ~CalcListener()
+ {}
+
+ // document.XEventListener
+ virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+};
+
+class WriterListener : public cppu::WeakImplHelper1< css::document::XEventListener >
+{
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
+
+ public:
+ WriterListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMSF);
+
+ virtual ~WriterListener()
+ {}
+
+ // document.XEventListener
+ virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
new file mode 100644
index 000000000..4020953b6
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
@@ -0,0 +1,501 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+
+#include "ListenerHelper.h"
+#include "MyProtocolHandler.h"
+
+#include <com/sun/star/awt/MessageBoxButtons.hpp>
+#include <com/sun/star/awt/Toolkit.hpp>
+#include <com/sun/star/awt/XMessageBoxFactory.hpp>
+#include <com/sun/star/frame/ControlCommand.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/system/SystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace com::sun::star::awt;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::system;
+using namespace com::sun::star::uno;
+
+using com::sun::star::beans::NamedValue;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::sheet::XSpreadsheetView;
+using com::sun::star::text::XTextViewCursorSupplier;
+using com::sun::star::util::URL;
+
+ListenerHelper aListenerHelper;
+
+void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
+{
+ if ( !mxToolkit.is() )
+ mxToolkit = Toolkit::create(mxContext);
+ Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY );
+ if ( rFrame.is() && xMsgBoxFactory.is() )
+ {
+ Reference< XMessageBox > xMsgBox = xMsgBoxFactory->createMessageBox(
+ Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ),
+ com::sun::star::awt::MessageBoxType_INFOBOX,
+ MessageBoxButtons::BUTTONS_OK,
+ aTitle,
+ aMsgText );
+
+ if ( xMsgBox.is() )
+ xMsgBox->execute();
+ }
+}
+
+void BaseDispatch::SendCommand( const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const Sequence< NamedValue >& rArgs, sal_Bool bEnabled )
+{
+ Reference < XDispatch > xDispatch =
+ aListenerHelper.GetDispatch( mxFrame, aURL.Path );
+
+ FeatureStateEvent aEvent;
+
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = xDispatch;
+ aEvent.IsEnabled = bEnabled;
+ aEvent.Requery = sal_False;
+
+ ControlCommand aCtrlCmd;
+ aCtrlCmd.Command = rCommand;
+ aCtrlCmd.Arguments = rArgs;
+
+ aEvent.State <<= aCtrlCmd;
+ aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent );
+}
+
+void BaseDispatch::SendCommandTo( const Reference< XStatusListener >& xControl, const URL& aURL, const ::rtl::OUString& rCommand, const Sequence< NamedValue >& rArgs, sal_Bool bEnabled )
+{
+ FeatureStateEvent aEvent;
+
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = bEnabled;
+ aEvent.Requery = sal_False;
+
+ ControlCommand aCtrlCmd;
+ aCtrlCmd.Command = rCommand;
+ aCtrlCmd.Arguments = rArgs;
+
+ aEvent.State <<= aCtrlCmd;
+ xControl->statusChanged( aEvent );
+}
+
+void SAL_CALL MyProtocolHandler::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException)
+{
+ Reference < XFrame > xFrame;
+ if ( aArguments.getLength() )
+ {
+ // the first Argument is always the Frame, as a ProtocolHandler needs to have access
+ // to the context in which it is invoked.
+ aArguments[0] >>= xFrame;
+ mxFrame = xFrame;
+ }
+}
+
+Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& aURL, const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
+ throw( RuntimeException )
+{
+ Reference < XDispatch > xRet;
+ if ( !mxFrame.is() )
+ return 0;
+
+ Reference < XController > xCtrl = mxFrame->getController();
+ if ( xCtrl.is() && aURL.Protocol == "vnd.demo.complextoolbarcontrols.demoaddon:" )
+ {
+ Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY );
+ Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY );
+ if ( !xCursor.is() && !xView.is() )
+ // without an appropriate corresponding document the handler doesn't function
+ return xRet;
+
+ if ( aURL.Path == "ImageButtonCmd" ||
+ aURL.Path == "ComboboxCmd" ||
+ aURL.Path == "ToggleDropdownButtonCmd" ||
+ aURL.Path == "DropdownButtonCmd" ||
+ aURL.Path == "SpinfieldCmd" ||
+ aURL.Path == "EditfieldCmd" ||
+ aURL.Path == "DropdownboxCmd" )
+ {
+ xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
+ if ( !xRet.is() )
+ {
+ xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxContext, mxFrame ) :
+ (BaseDispatch*) new CalcDispatch( mxContext, mxFrame );
+ aListenerHelper.AddDispatch( xRet, mxFrame, aURL.Path );
+ }
+ }
+ }
+
+ return xRet;
+}
+
+Sequence < Reference< XDispatch > > SAL_CALL MyProtocolHandler::queryDispatches( const Sequence < DispatchDescriptor >& seqDescripts )
+ throw( RuntimeException )
+{
+ 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;
+}
+
+::rtl::OUString MyProtocolHandler_getImplementationName ()
+ throw (RuntimeException)
+{
+ return ::rtl::OUString( MYPROTOCOLHANDLER_IMPLEMENTATIONNAME );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence < ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( MYPROTOCOLHANDLER_SERVICENAME );
+ return aRet;
+}
+
+#undef SERVICE_NAME
+
+Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XComponentContext > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new MyProtocolHandler( rSMgr );
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL MyProtocolHandler::getImplementationName( )
+ throw (RuntimeException)
+{
+ return MyProtocolHandler_getImplementationName();
+}
+
+sal_Bool SAL_CALL MyProtocolHandler::supportsService( const ::rtl::OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return MyProtocolHandler_getSupportedServiceNames();
+}
+
+void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < PropertyValue >& lArgs ) throw (RuntimeException)
+{
+ /* It's necessary to hold this object alive, till this method finishes.
+ May the outside dispatch cache (implemented by the menu/toolbar!)
+ forget this instance during de-/activation of frames (focus!).
+
+ E.g. An open db beamer in combination with the My-Dialog
+ can force such strange situation :-(
+ */
+ Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
+
+ if ( aURL.Protocol == "vnd.demo.complextoolbarcontrols.demoaddon:" )
+ {
+ if ( aURL.Path == "ImageButtonCmd" )
+ {
+ // open the LibreOffice web page
+ ::rtl::OUString sURL("http://www.libreoffice.org");
+ Reference< XSystemShellExecute > xSystemShellExecute(
+ SystemShellExecute::create(mxContext) );
+ try
+ {
+ xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::URIS_ONLY );
+ }
+ catch( Exception& rEx )
+ {
+ (void)rEx;
+ }
+ }
+ else if ( aURL.Path == "ComboboxCmd" )
+ {
+ // remove the text if it's in our list
+ Sequence< NamedValue > aRemoveArgs( 1 );
+ aRemoveArgs[0].Name = rtl::OUString( "Text" );
+ aRemoveArgs[0].Value <<= maComboBoxText;
+ SendCommand( aURL, ::rtl::OUString( "RemoveEntryText" ), aRemoveArgs, sal_True );
+
+ // add the new text to the start of the list
+ Sequence< NamedValue > aInsertArgs( 2 );
+ aInsertArgs[0].Name = rtl::OUString( "Pos" );
+ aInsertArgs[0].Value <<= sal_Int32( 0 );
+ aInsertArgs[1].Name = rtl::OUString( "Text" );
+ aInsertArgs[1].Value <<= maComboBoxText;
+ SendCommand( aURL, ::rtl::OUString("InsertEntry"), aInsertArgs, sal_True );
+ }
+ else if ( aURL.Path == "InsertEntry" )
+ {
+ // Retrieve the text argument from the sequence property value
+ rtl::OUString aText;
+ for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
+ {
+ if ( lArgs[i].Name == "Text" )
+ {
+ lArgs[i].Value >>= aText;
+ break;
+ }
+ }
+
+ // create new URL to address the combox box
+ URL aCmdURL;
+ aCmdURL.Path = "ComboboxCmd";
+ aCmdURL.Protocol = "vnd.demo.complextoolbarcontrols.demoaddon:";
+ aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
+
+ // set the selected item as text into the combobox
+ Sequence< NamedValue > aArgs( 1 );
+ aArgs[0].Name = "Text";
+ aArgs[0].Value <<= aText;
+ SendCommand( aCmdURL, ::rtl::OUString( "SetText" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path == "DropdownButtonCmd" )
+ {
+ // Retrieve the text argument from the sequence property value
+ rtl::OUString aText;
+ for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
+ {
+ if ( lArgs[i].Name == "Text" )
+ {
+ lArgs[i].Value >>= aText;
+ break;
+ }
+ }
+
+ // just enable this command
+
+ // set enable flag according to selection
+ if ( aText == "Button Disabled" )
+ mbButtonEnabled = sal_False;
+ else
+ mbButtonEnabled = sal_True;
+
+ // create new URL to address the image button
+ URL aCmdURL;
+ aCmdURL.Path = "Command1";
+ aCmdURL.Protocol = "vnd.demo.complextoolbarcontrols.demoaddon:";
+ aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
+
+ // create and initialize FeatureStateEvent with IsEnabled
+ ::com::sun::star::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aCmdURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = mbButtonEnabled;
+ aEvent.Requery = sal_False;
+ aEvent.State = Any();
+
+ // Notify listener about new state
+ Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
+ aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent );
+ }
+ else if ( aURL.Path == "SpinfieldCmd" )
+ {
+ }
+ else if ( aURL.Path == "DropdownboxCmd" )
+ {
+ // Retrieve the text argument from the sequence property value
+ rtl::OUString aText;
+ for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
+ {
+ if ( lArgs[i].Name == "Text" )
+ {
+ lArgs[i].Value >>= aText;
+ break;
+ }
+ }
+ }
+ }
+}
+
+void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
+{
+ if ( aURL.Protocol == "vnd.demo.complextoolbarcontrols.demoaddon:" )
+ {
+ if ( aURL.Path == "ImageButtonCmd" )
+ {
+ // just enable this command
+ ::com::sun::star::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = mbButtonEnabled;
+ aEvent.Requery = sal_False;
+ aEvent.State = Any();
+ xControl->statusChanged( aEvent );
+ }
+ else if ( aURL.Path == "ComboboxCmd" )
+ {
+ // just enable this command
+ ::com::sun::star::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.State = Any();
+ xControl->statusChanged( aEvent );
+ }
+ else if ( aURL.Path == "ToggleDropdownButtonCmd" )
+ {
+ // A toggle dropdown box is normally used for a group of commands
+ // where the user can select the last issued command easily.
+ // E.g. a typical command group would be "Insert shape"
+ Sequence< NamedValue > aArgs( 1 );
+
+ // send command to set context menu content
+ Sequence< rtl::OUString > aContextMenu( 3 );
+ aContextMenu[0] = "Command 1";
+ aContextMenu[1] = "Command 2";
+ aContextMenu[2] = "Command 3";
+
+ aArgs[0].Name = "List";
+ aArgs[0].Value <<= aContextMenu;
+ SendCommandTo( xControl, aURL, rtl::OUString( "SetList" ), aArgs, sal_True );
+
+ // send command to check item on pos=0
+ aArgs[0].Name = rtl::OUString( "Pos" );
+ aArgs[0].Value <<= sal_Int32( 0 );
+ SendCommandTo( xControl, aURL, ::rtl::OUString( "CheckItemPos" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path == "DropdownButtonCmd" )
+ {
+ // A dropdown box is normally used for a group of dependent modes, where
+ // the user can only select one. The modes cannot be combined.
+ // E.g. a typical group would be left,right,center,block.
+ Sequence< NamedValue > aArgs( 1 );
+
+ // send command to set context menu content
+ Sequence< rtl::OUString > aContextMenu( 2 );
+ aContextMenu[0] = "Button Enabled";
+ aContextMenu[1] = "Button Disabled";
+
+ aArgs[0].Name = "List";
+ aArgs[0].Value <<= aContextMenu;
+ SendCommandTo( xControl, aURL, rtl::OUString( "SetList" ), aArgs, sal_True );
+
+ // set position according to enable/disable state of button
+ sal_Int32 nPos( mbButtonEnabled ? 0 : 1 );
+
+ // send command to check item on pos=0
+ aArgs[0].Name = "Pos";
+ aArgs[0].Value <<= nPos;
+ SendCommandTo( xControl, aURL, ::rtl::OUString( "CheckItemPos" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path == "SpinfieldCmd" )
+ {
+ // A spin button
+ Sequence< NamedValue > aArgs( 5 );
+
+ // send command to initialize spin button
+ aArgs[0].Name = "Value";
+ aArgs[0].Value <<= double( 0.0 );
+ aArgs[1].Name = "UpperLimit";
+ aArgs[1].Value <<= double( 10.0 );
+ aArgs[2].Name = "LowerLimit";
+ aArgs[2].Value <<= double( 0.0 );
+ aArgs[3].Name = "Step";
+ aArgs[3].Value <<= double( 0.1 );
+ aArgs[4].Name = "OutputFormat";
+ aArgs[4].Value <<= rtl::OUString("%.2f cm");
+
+ SendCommandTo( xControl, aURL, rtl::OUString( "SetValues" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path == "DropdownboxCmd" )
+ {
+ // A dropdown box is normally used for a group of commands
+ // where the user can select one of a defined set.
+ Sequence< NamedValue > aArgs( 1 );
+
+ // send command to set context menu content
+ Sequence< rtl::OUString > aList( 10 );
+ aList[0] = "White";
+ aList[1] = "Black";
+ aList[2] = "Red";
+ aList[3] = "Blue";
+ aList[4] = "Green";
+ aList[5] = "Grey";
+ aList[6] = "Yellow";
+ aList[7] = "Orange";
+ aList[8] = "Brown";
+ aList[9] = "Pink";
+
+ aArgs[0].Name = "List";
+ aArgs[0].Value <<= aList;
+ SendCommandTo( xControl, aURL, rtl::OUString( "SetList" ), aArgs, sal_True );
+ }
+
+ aListenerHelper.AddListener( mxFrame, xControl, aURL.Path );
+ }
+}
+
+void SAL_CALL BaseDispatch::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
+{
+ aListenerHelper.RemoveListener( mxFrame, xControl, aURL.Path );
+}
+
+void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException)
+{
+ if ( Event.aURL.Protocol == "vnd.demo.complextoolbarcontrols.demoaddon:" )
+ {
+ if ( Event.aURL.Path == "ComboboxCmd" )
+ {
+ // We get notifications whenever the text inside the combobox has been changed.
+ // We store the new text into a member.
+ if ( Event.Event == "TextChanged" )
+ {
+ rtl::OUString aNewText;
+ sal_Bool bHasText( sal_False );
+ for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ )
+ {
+ if ( Event.aInformation[i].Name == "Text" )
+ {
+ bHasText = Event.aInformation[i].Value >>= aNewText;
+ break;
+ }
+ }
+
+ if ( bHasText )
+ maComboBoxText = aNewText;
+ }
+ }
+ }
+}
+
+BaseDispatch::BaseDispatch( const Reference< XComponentContext > &rxContext,
+ const Reference< XFrame >& xFrame,
+ const ::rtl::OUString& rServiceName )
+ : mxContext( rxContext )
+ , mxFrame( xFrame )
+ , msDocService( rServiceName )
+ , mbButtonEnabled( sal_True )
+{
+}
+
+BaseDispatch::~BaseDispatch()
+{
+ mxFrame.clear();
+ mxContext.clear();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
new file mode 100644
index 000000000..4ee22a0fe
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+#ifndef INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYPROTOCOLHANDLER_H
+#define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYPROTOCOLHANDLER_H
+
+#include <com/sun/star/awt/XToolkit2.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XControlNotificationListener.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+#define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME "vnd.demo.Impl.ProtocolHandler"
+#define MYPROTOCOLHANDLER_SERVICENAME "vnd.demo.ProtocolHandler"
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace frame
+ {
+ class XModel;
+ class XFrame;
+ }
+ namespace uno { class XComponentContext; }
+ }
+ }
+}
+
+
+class MyProtocolHandler : public cppu::WeakImplHelper3
+<
+ com::sun::star::frame::XDispatchProvider,
+ 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;
+
+public:
+ MyProtocolHandler( 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 )
+ throw( ::com::sun::star::uno::RuntimeException );
+ 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 )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+::rtl::OUString MyProtocolHandler_getImplementationName()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames( )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
+ throw ( ::com::sun::star::uno::Exception );
+
+class BaseDispatch : public cppu::WeakImplHelper2
+<
+ ::com::sun::star::frame::XDispatch,
+ ::com::sun::star::frame::XControlNotificationListener
+>
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit2 > mxToolkit;
+ ::rtl::OUString msDocService;
+ ::rtl::OUString maComboBoxText;
+ sal_Bool mbButtonEnabled;
+
+public:
+ BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName );
+
+ virtual ~BaseDispatch();
+
+ void ShowMessageBox( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText );
+ void SendCommand( const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rArgs, sal_Bool bEnabled );
+ void SendCommandTo( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xControl, const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rArgs, sal_Bool bEnabled );
+
+ // 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 )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
+ const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
+ const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XControlNotificationListener
+ virtual void SAL_CALL controlEvent( const ::com::sun::star::frame::ControlEvent& Event )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+class WriterDispatch : public BaseDispatch
+{
+public:
+ WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
+ : BaseDispatch( rxContext, xFrame, rtl::OUString( "com.sun.star.text.TextDocument" ) )
+ {}
+};
+
+class CalcDispatch : public BaseDispatch
+{
+public:
+ CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
+ : BaseDispatch( rxContext, xFrame, rtl::OUString( "com.sun.star.sheet.SpreadSheetDocument" ) )
+ {}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/ProtocolHandler.xcu b/odk/examples/cpp/complextoolbarcontrols/ProtocolHandler.xcu
new file mode 100644
index 000000000..293e0185c
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/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="vnd.demo.ProtocolHandler" oor:op="replace">
+ <prop oor:name="Protocols" oor:type="oor:string-list">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:*</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx b/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx
new file mode 100644
index 000000000..31be46c6a
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+
+#include "MyListener.h"
+
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+void SAL_CALL WriterListener::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL WriterListener::disposing( const com::sun::star::lang::EventObject& aSource ) throw( com::sun::star::uno::RuntimeException )
+{
+}
+
+WriterListener::WriterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF )
+{
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu b/odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu
new file mode 100644
index 000000000..e590f6545
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu
@@ -0,0 +1,38 @@
+<?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="WriterWindowState" oor:package="org.openoffice.Office.UI">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolbar/addon_com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
+ <prop oor:name="ContextSensitive" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">Complex Toolbar Controls</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ <prop oor:name="Docked" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data> \ No newline at end of file
diff --git a/odk/examples/cpp/complextoolbarcontrols/description.xml b/odk/examples/cpp/complextoolbarcontrols/description.xml
new file mode 100644
index 000000000..40539382b
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/description.xml
@@ -0,0 +1,26 @@
+<?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 .
+-->
+<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:d="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <version value="0.0.1"/>
+ <identifier value="org.apache.openoffice.framework.complextoolbarcontrols"/>
+ <platform value="#EXTENSION_PLATFORM#"/>
+ <display-name>
+ <name lang="en-US">Complex Toolbar Controls Demo</name>
+ </display-name>
+</description>
diff --git a/odk/examples/cpp/complextoolbarcontrols/exports.cxx b/odk/examples/cpp/complextoolbarcontrols/exports.cxx
new file mode 100644
index 000000000..c88013b64
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/exports.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ *
+ * 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 .
+ */
+
+#include <cppuhelper/factory.hxx>
+#include <uno/lbnames.h>
+
+#include "MyProtocolHandler.h"
+#include "MyListener.h"
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const char* pImplName ,
+ void* pServiceManager,
+ void* pRegistryKey )
+{
+ if ( !pServiceManager || !pImplName )
+ return 0;
+
+ css::uno::Reference< css::uno::XInterface > xFactory ;
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (reinterpret_cast< css::lang::XMultiServiceFactory* >(pServiceManager), css::uno::UNO_QUERY);
+ ::rtl::OUString sImplName = ::rtl::OUString::createFromAscii(pImplName);
+
+ if (sImplName == MYLISTENER_IMPLEMENTATIONNAME)
+ {
+ css::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = MYLISTENER_IMPLEMENTATIONNAME;
+ xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyListener::st_createInstance, lNames);
+ }
+ else if (sImplName == MYPROTOCOLHANDLER_IMPLEMENTATIONNAME)
+ {
+ css::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = MYPROTOCOLHANDLER_SERVICENAME;
+ xFactory = ::cppu::createSingleComponentFactory(MyProtocolHandler_createInstance, sImplName, lNames);
+ }
+
+ if (!xFactory.is())
+ return 0;
+
+ xFactory->acquire();
+ return xFactory.get();
+}
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+} // extern C
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/logo_big.png b/odk/examples/cpp/complextoolbarcontrols/logo_big.png
new file mode 100644
index 000000000..23dd24109
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/logo_big.png
Binary files differ
diff --git a/odk/examples/cpp/complextoolbarcontrols/logo_small.png b/odk/examples/cpp/complextoolbarcontrols/logo_small.png
new file mode 100644
index 000000000..c24b4e275
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/logo_small.png
Binary files differ