View | Details | Raw Unified | Return to issue 104788
Collapse All | Expand All

(-)a/odk/examples/cpp/complextoolbarcontrols/Addons.xcu (-8 / +8 lines)
Lines 5-11 Link Here
5
			<node oor:name="com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
5
			<node oor:name="com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
6
				<node oor:name="m1" oor:op="replace">
6
				<node oor:name="m1" oor:op="replace">
7
					<prop oor:name="URL" oor:type="xs:string">
7
					<prop oor:name="URL" oor:type="xs:string">
8
						<value>vnd.demo.complextoolbarcontrols.demoaddon:Command1</value>
8
						<value>vnd.demo.complextoolbarcontrols.demoaddon:ImageButtonCmd</value>
9
					</prop>
9
					</prop>
10
					<prop oor:name="Title" oor:type="xs:string">
10
					<prop oor:name="Title" oor:type="xs:string">
11
						<value xml:lang="en-US">Image Button</value>
11
						<value xml:lang="en-US">Image Button</value>
Lines 22-28 Link Here
22
				</node>
22
				</node>
23
				<node oor:name="m2" oor:op="replace">
23
				<node oor:name="m2" oor:op="replace">
24
					<prop oor:name="URL" oor:type="xs:string">
24
					<prop oor:name="URL" oor:type="xs:string">
25
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:Command2</value>
25
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:ComboboxCmd</value>
26
					</prop>
26
					</prop>
27
					<prop oor:name="Title" oor:type="xs:string">
27
					<prop oor:name="Title" oor:type="xs:string">
28
						<value xml:lang="en-US">ComboBox</value>
28
						<value xml:lang="en-US">ComboBox</value>
Lines 47-53 Link Here
47
				</node>
47
				</node>
48
				<node oor:name="m4" oor:op="replace">
48
				<node oor:name="m4" oor:op="replace">
49
					<prop oor:name="URL" oor:type="xs:string">
49
					<prop oor:name="URL" oor:type="xs:string">
50
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:Command5</value>
50
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:SpinfieldCmd</value>
51
					</prop>
51
					</prop>
52
					<prop oor:name="Title" oor:type="xs:string">
52
					<prop oor:name="Title" oor:type="xs:string">
53
						<value xml:lang="en-US">Spinfield</value>
53
						<value xml:lang="en-US">Spinfield</value>
Lines 72-78 Link Here
72
				</node>
72
				</node>
73
				<node oor:name="m6" oor:op="replace">
73
				<node oor:name="m6" oor:op="replace">
74
					<prop oor:name="URL" oor:type="xs:string">
74
					<prop oor:name="URL" oor:type="xs:string">
75
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:Command6</value>
75
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:EditfieldCmd</value>
76
					</prop>
76
					</prop>
77
					<prop oor:name="Title" oor:type="xs:string">
77
					<prop oor:name="Title" oor:type="xs:string">
78
						<value xml:lang="en-US">Editfield</value>
78
						<value xml:lang="en-US">Editfield</value>
Lines 97-103 Link Here
97
				</node>
97
				</node>
98
				<node oor:name="m8" oor:op="replace">
98
				<node oor:name="m8" oor:op="replace">
99
					<prop oor:name="URL" oor:type="xs:string">
99
					<prop oor:name="URL" oor:type="xs:string">
100
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:Command7</value>
100
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:DropdownboxCmd</value>
101
					</prop>
101
					</prop>
102
					<prop oor:name="Title" oor:type="xs:string">
102
					<prop oor:name="Title" oor:type="xs:string">
103
						<value xml:lang="en-US">Dropdownbox</value>
103
						<value xml:lang="en-US">Dropdownbox</value>
Lines 117-123 Link Here
117
				</node>
117
				</node>
118
				<node oor:name="m9" oor:op="replace">
118
				<node oor:name="m9" oor:op="replace">
119
					<prop oor:name="URL" oor:type="xs:string">
119
					<prop oor:name="URL" oor:type="xs:string">
120
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:Command3</value>
120
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:ToggleDropdownButtonCmd</value>
121
					</prop>
121
					</prop>
122
					<prop oor:name="Title" oor:type="xs:string">
122
					<prop oor:name="Title" oor:type="xs:string">
123
						<value xml:lang="en-US">Toggle Dropdown Button</value>
123
						<value xml:lang="en-US">Toggle Dropdown Button</value>
Lines 134-140 Link Here
134
				</node>
134
				</node>
135
				<node oor:name="m10" oor:op="replace">
135
				<node oor:name="m10" oor:op="replace">
136
					<prop oor:name="URL" oor:type="xs:string">
136
					<prop oor:name="URL" oor:type="xs:string">
137
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:Command4</value>
137
                        <value>vnd.demo.complextoolbarcontrols.demoaddon:DropdownButtonCmd</value>
138
					</prop>
138
					</prop>
139
					<prop oor:name="Title" oor:type="xs:string">
139
					<prop oor:name="Title" oor:type="xs:string">
140
						<value xml:lang="en-US">Dropdown Button</value>
140
						<value xml:lang="en-US">Dropdown Button</value>
Lines 154-160 Link Here
154
		<node oor:name="Images">
154
		<node oor:name="Images">
155
            <node oor:name="vnd.demo.complextoolbarcontrols.image1" oor:op="replace">
155
            <node oor:name="vnd.demo.complextoolbarcontrols.image1" oor:op="replace">
156
				<prop oor:name="URL">
156
				<prop oor:name="URL">
157
                    <value>vnd.demo.complextoolbarcontrols.demoaddon:Command1</value>
157
                    <value>vnd.demo.complextoolbarcontrols.demoaddon:ImageButtonCmd</value>
158
				</prop>
158
				</prop>
159
				<node oor:name="UserDefinedImages">
159
				<node oor:name="UserDefinedImages">
160
					<prop oor:name="ImageSmallURL" oor:type="xs:string">
160
					<prop oor:name="ImageSmallURL" oor:type="xs:string">
(-)a/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h (-24 / +5 lines)
Lines 1-39 Link Here
1
#include <vector>
1
#include <vector>
2
#include <hash_map>
2
#include <hash_map>
3
3
#include <com/sun/star/frame/XFrame.hpp>
4
#include <com/sun/star/frame/XFrame.hpp>
4
#include <com/sun/star/frame/XStatusListener.hpp>
5
#include <com/sun/star/frame/XStatusListener.hpp>
5
#include <com/sun/star/frame/FeatureStateEvent.hpp>
6
#include <com/sun/star/frame/XDispatch.hpp>
6
#include <com/sun/star/frame/XDispatch.hpp>
7
7
8
#include <rtl/ustring.hxx>
8
#include <rtl/ustring.hxx>
9
#include <cppuhelper/implbase1.hxx>
9
#include <cppuhelper/implbase1.hxx>
10
10
11
struct hashObjectName_Impl
12
{
13
	size_t operator()(const ::rtl::OUString Str) const
14
	{
15
		return (size_t)Str.hashCode();
16
	}
17
};
18
19
struct eqObjectName_Impl
20
{
21
	sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const
22
	{
23
		return ( Str1 == Str2 );
24
	}
25
};
26
11
27
typedef std::vector < com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > > StatusListeners;
12
typedef std::vector < com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > > StatusListeners;
28
13
29
typedef std::hash_map
14
typedef std::hash_map < rtl::OUString,
30
<
15
                        StatusListeners,
31
	::rtl::OUString,
16
                        rtl::OUStringHash,
32
	StatusListeners,
17
                        std::equal_to< rtl::OUString > > ListenerMap;
33
	hashObjectName_Impl,
34
	eqObjectName_Impl
35
>
36
ListenerMap;
37
18
38
// For every frame there is *one* Dispatch object for all possible commands
19
// For every frame there is *one* Dispatch object for all possible commands
39
// this struct contains an array of listeners for every supported command
20
// this struct contains an array of listeners for every supported command
(-)a/odk/examples/cpp/complextoolbarcontrols/Makefile (+4 lines)
Lines 66-71 CXXFILES = \ Link Here
66
66
67
SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
67
SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
68
68
69
# Add OSL_DEBUG_LEVEL to compiler the flags (for OSL_TRACE et. al.)
70
ifeq "$(DEBUG)" "yes"
71
CC_FLAGS += -DOSL_DEBUG_LEVEL=2
72
endif
69
73
70
# Targets
74
# Targets
71
.PHONY: ALL
75
.PHONY: ALL
(-)a/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx (-9 / +7 lines)
Lines 25-35 Link Here
25
 *
25
 *
26
 ************************************************************************/
26
 ************************************************************************/
27
27
28
29
#ifndef _MyJob_HXX
30
#include "MyJob.h"
28
#include "MyJob.h"
31
#endif
29
32
#include <osl/diagnose.h>
33
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
30
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34
#include <com/sun/star/beans/NamedValue.hpp>
31
#include <com/sun/star/beans/NamedValue.hpp>
35
#include <com/sun/star/document/XEventBroadcaster.hpp>
32
#include <com/sun/star/document/XEventBroadcaster.hpp>
Lines 50-58 using com::sun::star::document::XEventBroadcaster; Link Here
50
Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
47
Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
51
	throw ( IllegalArgumentException, Exception, RuntimeException )
48
	throw ( IllegalArgumentException, Exception, RuntimeException )
52
{
49
{
53
	Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster") ), UNO_QUERY );
50
	Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(
51
        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.GlobalEventBroadcaster" ) ) ), UNO_QUERY );
54
	Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
52
	Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
55
		::rtl::OUString::createFromAscii("com.sun.star.comp.Office.MyListener" ) ), UNO_QUERY );
53
		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Office.MyListener" ) ) ), UNO_QUERY );
56
	if ( xBrd.is() )
54
	if ( xBrd.is() )
57
		xBrd->addEventListener( xLstner );
55
		xBrd->addEventListener( xLstner );
58
	return Any();
56
	return Any();
Lines 61-67 Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments ) Link Here
61
OUString MyJob_getImplementationName ()
59
OUString MyJob_getImplementationName ()
62
	throw (RuntimeException)
60
	throw (RuntimeException)
63
{
61
{
64
	return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Office.MyJob" ) );
62
	return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Office.MyJob" ) );
65
}
63
}
66
64
67
#define SERVICE_NAME "com.sun.star.task.Job"
65
#define SERVICE_NAME "com.sun.star.task.Job"
Lines 69-75 OUString MyJob_getImplementationName () Link Here
69
sal_Bool SAL_CALL MyJob_supportsService( const OUString& ServiceName )
67
sal_Bool SAL_CALL MyJob_supportsService( const OUString& ServiceName )
70
	throw (RuntimeException)
68
	throw (RuntimeException)
71
{
69
{
72
    return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
70
    return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SERVICE_NAME ) );
73
}
71
}
74
72
75
Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames(  )
73
Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames(  )
Lines 77-83 Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames( ) Link Here
77
{
75
{
78
	Sequence < OUString > aRet(1);
76
	Sequence < OUString > aRet(1);
79
    OUString* pArray = aRet.getArray();
77
    OUString* pArray = aRet.getArray();
80
    pArray[0] =  OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
78
    pArray[0] =  OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
81
    return aRet;
79
    return aRet;
82
}
80
}
83
81
(-)a/odk/examples/cpp/complextoolbarcontrols/MyJob.h (-73 lines)
Lines 1-150 Link Here
1
#ifndef _MyJob_HXX
1
#ifndef _MyJob_HXX
2
3
#define _MyJob_HXX
2
#define _MyJob_HXX
4
3
5
6
7
#ifndef _COM_SUN_STAR_TASK_XJOB_HPP_
8
9
#include <com/sun/star/task/XJob.hpp>
4
#include <com/sun/star/task/XJob.hpp>
10
11
#endif
12
13
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
14
15
#include <com/sun/star/lang/XServiceInfo.hpp>
5
#include <com/sun/star/lang/XServiceInfo.hpp>
16
17
#endif
18
19
#ifndef _CPPUHELPER_IMPLBASE2_HXX_
20
21
#include <cppuhelper/implbase2.hxx>
6
#include <cppuhelper/implbase2.hxx>
22
7
23
#endif
24
25
26
8
27
namespace com
9
namespace com
28
29
{
10
{
30
31
	namespace sun
11
	namespace sun
32
33
	{
12
	{
34
35
		namespace star
13
		namespace star
36
37
		{
14
		{
38
39
			namespace frame
15
			namespace frame
40
41
			{
16
			{
42
43
				class XModel;
17
				class XModel;
44
45
				class XFrame;
18
				class XFrame;
46
47
			}
19
			}
48
49
50
51
			namespace beans
20
			namespace beans
52
53
			{
21
			{
54
55
				struct NamedValue;
22
				struct NamedValue;
56
57
			}
23
			}
58
59
		}
24
		}
60
61
	}
25
	}
62
63
}
26
}
64
27
65
28
66
67
class MyJob : public cppu::WeakImplHelper2
29
class MyJob : public cppu::WeakImplHelper2
68
69
<
30
<
70
71
	com::sun::star::task::XJob,
31
	com::sun::star::task::XJob,
72
73
	com::sun::star::lang::XServiceInfo
32
	com::sun::star::lang::XServiceInfo
74
75
>
33
>
76
77
{
34
{
78
79
private:
35
private:
80
81
    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
36
    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
82
37
83
84
85
public:
38
public:
86
87
	MyJob( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
39
	MyJob( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
88
89
        : mxMSF( rxMSF ) {}
40
        : mxMSF( rxMSF ) {}
90
91
	virtual ~MyJob() {}
41
	virtual ~MyJob() {}
92
42
93
43
94
95
	// XJob
44
	// XJob
96
97
	virtual ::com::sun::star::uno::Any SAL_CALL execute(
45
	virtual ::com::sun::star::uno::Any SAL_CALL execute(
98
99
		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
46
		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
100
101
		throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
47
		throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
102
48
103
49
104
105
	// XServiceInfo
50
	// XServiceInfo
106
107
    virtual ::rtl::OUString SAL_CALL getImplementationName(  )
51
    virtual ::rtl::OUString SAL_CALL getImplementationName(  )
108
109
		throw (::com::sun::star::uno::RuntimeException);
52
		throw (::com::sun::star::uno::RuntimeException);
110
53
111
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
54
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
112
113
		throw (::com::sun::star::uno::RuntimeException);
55
		throw (::com::sun::star::uno::RuntimeException);
114
56
115
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
57
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
116
117
		throw (::com::sun::star::uno::RuntimeException);
58
		throw (::com::sun::star::uno::RuntimeException);
118
59
119
};
60
};
120
61
121
62
122
123
::rtl::OUString MyJob_getImplementationName()
63
::rtl::OUString MyJob_getImplementationName()
124
125
	throw ( ::com::sun::star::uno::RuntimeException );
64
	throw ( ::com::sun::star::uno::RuntimeException );
126
65
127
128
129
sal_Bool SAL_CALL MyJob_supportsService( const ::rtl::OUString& ServiceName )
66
sal_Bool SAL_CALL MyJob_supportsService( const ::rtl::OUString& ServiceName )
130
131
	throw ( ::com::sun::star::uno::RuntimeException );
67
	throw ( ::com::sun::star::uno::RuntimeException );
132
68
133
134
135
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyJob_getSupportedServiceNames(  )
69
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyJob_getSupportedServiceNames(  )
136
137
	throw ( ::com::sun::star::uno::RuntimeException );
70
	throw ( ::com::sun::star::uno::RuntimeException );
138
71
139
140
141
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
72
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
142
143
SAL_CALL MyJob_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
73
SAL_CALL MyJob_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
144
145
	throw ( ::com::sun::star::uno::Exception );
74
	throw ( ::com::sun::star::uno::Exception );
146
75
147
76
148
149
#endif
77
#endif
150
(-)a/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx (-34 / +20 lines)
Lines 34-55 Link Here
34
34
35
namespace css = ::com::sun::star;
35
namespace css = ::com::sun::star;
36
36
37
/*-----------------------------------------------------
37
38
	20.11.2003 11:31
39
-----------------------------------------------------*/
40
MyListener::MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
38
MyListener::MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
41
	: m_xSMGR(xSMGR)
39
	: m_xSMGR(xSMGR)
42
{}
40
{}
43
41
44
/*-----------------------------------------------------
45
	20.11.2003 11:32
46
-----------------------------------------------------*/
47
MyListener::~MyListener()
42
MyListener::~MyListener()
48
{}
43
{}
49
44
50
/*-----------------------------------------------------
45
51
    20.11.2003 12:04
52
-----------------------------------------------------*/
53
css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
46
css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
54
	throw (css::lang::IllegalArgumentException,
47
	throw (css::lang::IllegalArgumentException,
55
		   css::uno::Exception,
48
		   css::uno::Exception,
Lines 57-68 css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans: Link Here
57
{
50
{
58
    css::uno::Sequence< css::beans::NamedValue > lEnv;
51
    css::uno::Sequence< css::beans::NamedValue > lEnv;
59
52
60
          sal_Int32               i = 0;
53
    sal_Int32                     i = 0;
61
          sal_Int32               c = lArguments.getLength();
54
    sal_Int32                     c = lArguments.getLength();
62
    const css::beans::NamedValue* p = lArguments.getConstArray();
55
    const css::beans::NamedValue* p = lArguments.getConstArray();
63
    for (i=0; i<c; ++i)
56
    for (i=0; i<c; ++i)
64
	{
57
	{
65
        if (p[i].Name.equalsAscii("Environment"))
58
        if (p[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Environment" ) ) )
66
        {
59
        {
67
            p[i].Value >>= lEnv;
60
            p[i].Value >>= lEnv;
68
            break;
61
            break;
Lines 75-86 css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans: Link Here
75
    p = lEnv.getConstArray();
68
    p = lEnv.getConstArray();
76
    for (i=0; i<c; ++i)
69
    for (i=0; i<c; ++i)
77
    {
70
    {
78
        if (p[i].Name.equalsAscii("Model"))
71
        if (p[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Model" ) ) )
79
        {
72
        {
80
            p[i].Value >>= xModel;
73
            p[i].Value >>= xModel;
81
            break;
74
            break;
82
        }
75
        }
83
        if (p[i].Name.equalsAscii("Frame"))
76
        if (p[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Frame" ) ) )
84
        {
77
        {
85
			css::uno::Reference< css::frame::XController > xController;
78
			css::uno::Reference< css::frame::XController > xController;
86
			css::uno::Reference< css::frame::XFrame >      xFrame;
79
			css::uno::Reference< css::frame::XFrame >      xFrame;
Lines 97-107 css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans: Link Here
97
		return css::uno::Any();
90
		return css::uno::Any();
98
91
99
    css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
92
    css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
100
    sal_Bool bCalc   = xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument"));
93
    sal_Bool bCalc   = xInfo->supportsService(
94
        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) );
101
    sal_Bool bWriter = (
95
    sal_Bool bWriter = (
102
                         xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument"  )) &&
96
                         xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) ) &&
103
                        !xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.text.WebDocument"   )) &&
97
                        !xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) ) &&
104
                        !xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.text.GlobalDocument"))
98
                        !xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.GlobalDocument" ) ) )
105
                       );
99
                       );
106
100
107
    // Wir interessieren uns nur für Writer und Calc. Werden hier aber für
101
    // Wir interessieren uns nur für Writer und Calc. Werden hier aber für
Lines 124-164 css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans: Link Here
124
	return css::uno::Any();
118
	return css::uno::Any();
125
}
119
}
126
120
127
/*-----------------------------------------------------
121
128
    20.11.2003 12:13
129
-----------------------------------------------------*/
130
::rtl::OUString SAL_CALL MyListener::getImplementationName()
122
::rtl::OUString SAL_CALL MyListener::getImplementationName()
131
    throw (css::uno::RuntimeException)
123
    throw (css::uno::RuntimeException)
132
{
124
{
133
    return ::rtl::OUString::createFromAscii(MYLISTENER_IMPLEMENTATIONNAME);
125
    return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) );
134
}
126
}
135
127
136
/*-----------------------------------------------------
128
137
    20.11.2003 12:13
138
-----------------------------------------------------*/
139
css::uno::Sequence< ::rtl::OUString > SAL_CALL MyListener::getSupportedServiceNames()
129
css::uno::Sequence< ::rtl::OUString > SAL_CALL MyListener::getSupportedServiceNames()
140
    throw (css::uno::RuntimeException)
130
    throw (css::uno::RuntimeException)
141
{
131
{
142
    css::uno::Sequence< ::rtl::OUString > lNames(1);
132
    css::uno::Sequence< ::rtl::OUString > lNames(1);
143
    lNames[0] = ::rtl::OUString::createFromAscii(MYLISTENER_SERVICENAME);
133
    lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_SERVICENAME ) );
144
    return lNames;
134
    return lNames;
145
}
135
}
146
136
147
/*-----------------------------------------------------
137
148
    20.11.2003 12:14
149
-----------------------------------------------------*/
150
sal_Bool SAL_CALL MyListener::supportsService(const ::rtl::OUString& sServiceName)
138
sal_Bool SAL_CALL MyListener::supportsService(const ::rtl::OUString& sServiceName)
151
    throw (css::uno::RuntimeException)
139
    throw (css::uno::RuntimeException)
152
{
140
{
153
    return (
141
    return (
154
            sServiceName.equalsAscii(MYLISTENER_SERVICENAME) ||
142
            sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYLISTENER_SERVICENAME )) ||
155
            sServiceName.equalsAscii("com.sun.star.task.Job"    )
143
            sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.task.Job" ) )
156
           );
144
           );
157
}
145
}
158
146
159
/*-----------------------------------------------------
147
160
	20.11.2003 11:31
161
-----------------------------------------------------*/
162
css::uno::Reference< css::uno::XInterface > MyListener::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
148
css::uno::Reference< css::uno::XInterface > MyListener::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
163
{
149
{
164
	MyListener* pListener = new MyListener(xSMGR);
150
	MyListener* pListener = new MyListener(xSMGR);
(-)a/odk/examples/cpp/complextoolbarcontrols/MyListener.h (-3 / +1 lines)
Lines 1-7 Link Here
1
#ifndef _MyListener_HXX
1
#ifndef _MyListener_HXX
2
#define _MyListener_HXX
2
#define _MyListener_HXX
3
3
4
#include <com/sun/star/uno/Reference.h>
5
#include <com/sun/star/lang/XServiceInfo.hpp>
4
#include <com/sun/star/lang/XServiceInfo.hpp>
6
#include <com/sun/star/task/XJob.hpp>
5
#include <com/sun/star/task/XJob.hpp>
7
#include <com/sun/star/document/XEventListener.hpp>
6
#include <com/sun/star/document/XEventListener.hpp>
Lines 24-30 namespace css = ::com::sun::star; Link Here
24
 * @see WriterListener
23
 * @see WriterListener
25
 */
24
 */
26
class MyListener : public cppu::WeakImplHelper2< css::task::XJob         ,
25
class MyListener : public cppu::WeakImplHelper2< css::task::XJob         ,
27
                                                      css::lang::XServiceInfo >
26
                                                 css::lang::XServiceInfo >
28
{
27
{
29
    private:
28
    private:
30
        css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
29
        css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
Lines 59-65 class CalcListener : public cppu::WeakImplHelper1< css::document::XEventListener Link Here
59
    private:
58
    private:
60
        ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
59
        ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
61
60
62
63
    public:
61
    public:
64
        CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
62
        CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
65
            : mxMSF( rxMSF )
63
            : mxMSF( rxMSF )
(-)a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx (-151 / +135 lines)
Lines 25-75 Link Here
25
 *
25
 *
26
 ************************************************************************/
26
 ************************************************************************/
27
27
28
29
#include "ListenerHelper.h"
28
#include "ListenerHelper.h"
30
#include "MyProtocolHandler.h"
29
#include "MyProtocolHandler.h"
31
#include <com/sun/star/beans/PropertyValue.hpp>
30
32
#include <com/sun/star/frame/XFrame.hpp>
31
#include <com/sun/star/awt/MessageBoxButtons.hpp>
33
#include <com/sun/star/frame/XController.hpp>
32
#include <com/sun/star/awt/XMessageBoxFactory.hpp>
34
#include <com/sun/star/frame/DispatchDescriptor.hpp>
33
#include <com/sun/star/frame/ControlCommand.hpp>
35
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
34
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
36
#include <com/sun/star/text/XTextViewCursor.hpp>
37
#include <com/sun/star/text/XTextCursor.hpp>
38
#include <com/sun/star/text/XTextDocument.hpp>
39
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
35
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
40
#include <com/sun/star/frame/ControlCommand.hpp>
41
#include <com/sun/star/frame/ControlEvent.hpp>
42
#include <com/sun/star/frame/XModel.hpp>
43
#include <com/sun/star/frame/XControlNotificationListener.hpp>
44
#include <com/sun/star/beans/PropertyValue.hpp>
45
#include <com/sun/star/awt/XWindowPeer.hpp>
46
#include <com/sun/star/awt/WindowAttribute.hpp>
47
#include <com/sun/star/awt/XMessageBox.hpp>
48
#include <com/sun/star/frame/XComponentLoader.hpp>
49
#include <com/sun/star/view/XSelectionSupplier.hpp>
50
#include <com/sun/star/system/XSystemShellExecute.hpp>
51
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
36
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
52
#include <com/sun/star/frame/XStorable.hpp>
37
#include <com/sun/star/system/XSystemShellExecute.hpp>
53
#include <com/sun/star/container/XContainerQuery.hpp>
54
38
55
#include <osl/file.hxx>
56
39
57
using namespace com::sun::star::uno;
40
using namespace com::sun::star::awt;
58
using namespace com::sun::star::frame;
41
using namespace com::sun::star::frame;
59
using com::sun::star::lang::XMultiServiceFactory;
42
using namespace com::sun::star::system;
43
using namespace com::sun::star::uno;
44
45
using com::sun::star::beans::NamedValue;
60
using com::sun::star::beans::PropertyValue;
46
using com::sun::star::beans::PropertyValue;
61
using com::sun::star::util::URL;
47
using com::sun::star::lang::XMultiServiceFactory;
62
using com::sun::star::text::XTextViewCursorSupplier;
63
using com::sun::star::text::XTextViewCursor;
64
using com::sun::star::text::XTextCursor;
65
using com::sun::star::sheet::XSpreadsheetView;
48
using com::sun::star::sheet::XSpreadsheetView;
66
using com::sun::star::frame::XModel;
49
using com::sun::star::text::XTextViewCursorSupplier;
67
using com::sun::star::text::XTextRange;
50
using com::sun::star::util::URL;
68
using com::sun::star::text::XTextDocument;
69
using com::sun::star::beans::NamedValue;
70
using namespace com::sun::star::awt;
71
using com::sun::star::view::XSelectionSupplier;
72
using namespace com::sun::star::system;
73
51
74
ListenerHelper aListenerHelper;
52
ListenerHelper aListenerHelper;
75
53
Lines 77-106 void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rt Link Here
77
{
55
{
78
	if ( !mxToolkit.is() )
56
	if ( !mxToolkit.is() )
79
		mxToolkit = Reference< XToolkit > ( mxMSF->createInstance(
57
		mxToolkit = Reference< XToolkit > ( mxMSF->createInstance(
80
			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
58
			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
81
                                            "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
59
82
    if ( rFrame.is() && mxToolkit.is() )
60
    Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY );
61
    if ( rFrame.is() && xMsgBoxFactory.is() )
83
    {
62
    {
84
        // describe window properties.
63
        Reference< XMessageBox > xMsgBox = xMsgBoxFactory->createMessageBox(
85
        WindowDescriptor                aDescriptor;
64
            Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ),
86
        aDescriptor.Type              = WindowClass_MODALTOP;
65
            Rectangle(0,0,300,200),
87
        aDescriptor.WindowServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "infobox" ));
66
            rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "infobox" ) ),
88
        aDescriptor.ParentIndex       = -1;
67
            MessageBoxButtons::BUTTONS_OK,
89
        aDescriptor.Parent            = Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY );
68
            aTitle,
90
        aDescriptor.Bounds            = Rectangle(0,0,300,200);
69
            aMsgText );
91
        aDescriptor.WindowAttributes  = WindowAttribute::BORDER | WindowAttribute::MOVEABLE | WindowAttribute::CLOSEABLE;
70
92
71
        if ( xMsgBox.is() )
93
        Reference< XWindowPeer > xPeer = mxToolkit->createWindow( aDescriptor );
72
            xMsgBox->execute();
94
        if ( xPeer.is() )
95
        {
96
            Reference< XMessageBox > xMsgBox( xPeer, UNO_QUERY );
97
            if ( xMsgBox.is() )
98
            {
99
                xMsgBox->setCaptionText( aTitle );
100
                xMsgBox->setMessageText( aMsgText );
101
                xMsgBox->execute();
102
            }
103
        }
104
    }
73
    }
105
}
74
}
106
75
Lines 161-167 Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& aUR Link Here
161
		return 0;
130
		return 0;
162
131
163
	Reference < XController > xCtrl = mxFrame->getController();
132
	Reference < XController > xCtrl = mxFrame->getController();
164
	if ( xCtrl.is() && !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
133
	if ( xCtrl.is() && !aURL.Protocol.compareToAscii( 
134
        RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) )
165
	{
135
	{
166
		Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY );
136
		Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY );
167
		Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY );
137
		Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY );
Lines 169-181 Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& aUR Link Here
169
			// ohne ein entsprechendes Dokument funktioniert der Handler nicht
139
			// ohne ein entsprechendes Dokument funktioniert der Handler nicht
170
			return xRet;
140
			return xRet;
171
141
172
		if ( aURL.Path.equalsAscii("Command1" ) ||
142
		if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) ||
173
			 aURL.Path.equalsAscii("Command2" ) ||
143
			 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) ||
174
			 aURL.Path.equalsAscii("Command3" ) ||
144
			 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ToggleDropdownButtonCmd" ) ) ||
175
			 aURL.Path.equalsAscii("Command4" ) ||
145
			 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) ||
176
			 aURL.Path.equalsAscii("Command5" ) ||
146
			 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) ||
177
			 aURL.Path.equalsAscii("Command6" ) ||
147
			 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EditfieldCmd" ) ) ||
178
             aURL.Path.equalsAscii("Command7" ) )
148
             aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) )
179
		{
149
		{
180
			xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
150
			xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
181
			if ( !xRet.is() )
151
			if ( !xRet.is() )
Lines 205-219 Sequence < Reference< XDispatch > > SAL_CALL MyProtocolHandler::queryDispatches( Link Here
205
::rtl::OUString MyProtocolHandler_getImplementationName ()
175
::rtl::OUString MyProtocolHandler_getImplementationName ()
206
	throw (RuntimeException)
176
	throw (RuntimeException)
207
{
177
{
208
    return ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME);
178
    return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_IMPLEMENTATIONNAME ) );
209
}
179
}
210
180
211
sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
181
sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
212
	throw (RuntimeException)
182
	throw (RuntimeException)
213
{
183
{
214
    return (
184
    return (
215
            ServiceName.equalsAscii(MYPROTOCOLHANDLER_SERVICENAME  ) ||
185
            ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) ) ||
216
            ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler")
186
            ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.frame.ProtocolHandler" ) )
217
           );
187
           );
218
}
188
}
219
189
Lines 221-227 Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames( Link Here
221
	throw (RuntimeException)
191
	throw (RuntimeException)
222
{
192
{
223
	Sequence < ::rtl::OUString > aRet(1);
193
	Sequence < ::rtl::OUString > aRet(1);
224
    aRet[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME);
194
    aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) );
225
    return aRet;
195
    return aRet;
226
}
196
}
227
197
Lines 263-296 void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property Link Here
263
	 */
233
	 */
264
	Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
234
	Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
265
235
266
	if ( !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
236
	if ( !aURL.Protocol.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) )
267
	{
237
	{
268
		if ( !aURL.Path.compareToAscii("Command1" ) )
238
		if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) )
269
		{
239
		{
270
            // open the OpenOffice.org web page
240
            // open the OpenOffice.org web page
271
            ::rtl::OUString sURL(::rtl::OUString::createFromAscii("http://www.openoffice.org"));
241
            ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "http://www.openoffice.org" ) );
272
            Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
242
            Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
273
                ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), UNO_QUERY );
243
                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ), UNO_QUERY );
274
            if ( xSystemShellExecute.is() )
244
            if ( xSystemShellExecute.is() )
275
            {        
245
            {
276
                try
246
                try
277
                    
278
                {
247
                {
279
                    xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
248
                    xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
280
                }    
249
                }
281
                catch( Exception& rEx )
250
                catch( Exception& rEx )
282
                {
251
                {
283
                    (void)rEx;
252
                    (void)rEx;
284
                } 
253
                } 
285
            }
254
            }
286
        }
255
        }
287
		else if ( !aURL.Path.compareToAscii("Command2" ) )
256
		else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) )
288
		{
257
		{
289
            // remove the text if it's in our list
258
            // remove the text if it's in our list
290
            Sequence< NamedValue > aRemoveArgs( 1 );
259
            Sequence< NamedValue > aRemoveArgs( 1 );
291
            aRemoveArgs[0].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
260
            aRemoveArgs[0].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
292
            aRemoveArgs[0].Value <<= maComboBoxText;
261
            aRemoveArgs[0].Value <<= maComboBoxText;
293
            SendCommand( aURL, ::rtl::OUString::createFromAscii( "RemoveEntryText" ), aRemoveArgs, sal_True );
262
            SendCommand( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoveEntryText" ) ), aRemoveArgs, sal_True );
294
263
295
            // add the new text to the start of the list
264
            // add the new text to the start of the list
296
            Sequence< NamedValue > aInsertArgs( 2 );
265
            Sequence< NamedValue > aInsertArgs( 2 );
Lines 298-312 void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property Link Here
298
            aInsertArgs[0].Value <<= sal_Int32( 0 );
267
            aInsertArgs[0].Value <<= sal_Int32( 0 );
299
            aInsertArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
268
            aInsertArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
300
            aInsertArgs[1].Value <<= maComboBoxText;
269
            aInsertArgs[1].Value <<= maComboBoxText;
301
            SendCommand( aURL, ::rtl::OUString::createFromAscii( "InsertEntry" ), aInsertArgs, sal_True );
270
            SendCommand( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InsertEntry" ) ), aInsertArgs, sal_True );
302
        }
271
        }
303
		else if ( !aURL.Path.compareToAscii("Command3" ) )
272
		else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ToggleDropdownButtonCmd" ) ) )
304
		{
273
		{
305
            // Retrieve the text argument from the sequence property value
274
            // Retrieve the text argument from the sequence property value
306
            rtl::OUString aText;
275
            rtl::OUString aText;
307
            for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
276
            for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
308
            {
277
            {
309
                if ( lArgs[i].Name.equalsAsciiL( "Text", 4 ))
278
                if ( lArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) )
310
                {
279
                {
311
                    lArgs[i].Value >>= aText;
280
                    lArgs[i].Value >>= aText;
312
                    break;
281
                    break;
Lines 315-337 void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property Link Here
315
284
316
            // create new URL to address the combox box
285
            // create new URL to address the combox box
317
            URL aCmdURL;
286
            URL aCmdURL;
318
            aCmdURL.Path = rtl::OUString::createFromAscii( "Command2" );
287
            aCmdURL.Path = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ComboboxCmd" ) );
319
            aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" );
288
            aCmdURL.Protocol = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) );
320
            aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
289
            aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
321
            
290
322
            // set the selected item as text into the combobox
291
            // set the selected item as text into the combobox
323
            Sequence< NamedValue > aArgs( 1 );
292
            Sequence< NamedValue > aArgs( 1 );
324
            aArgs[0].Name = rtl::OUString::createFromAscii( "Text" );
293
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) );
325
            aArgs[0].Value <<= aText;
294
            aArgs[0].Value <<= aText;
326
            SendCommand( aCmdURL, ::rtl::OUString::createFromAscii( "SetText" ), aArgs, sal_True );
295
            SendCommand( aCmdURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetText" ) ), aArgs, sal_True );
327
		}
296
		}
328
		else if ( !aURL.Path.compareToAscii("Command4" ) )
297
		else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) )
329
		{
298
		{
330
            // Retrieve the text argument from the sequence property value
299
            // Retrieve the text argument from the sequence property value
331
            rtl::OUString aText;
300
            rtl::OUString aText;
332
            for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
301
            for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
333
            {
302
            {
334
                if ( lArgs[i].Name.equalsAsciiL( "Text", 4 ))
303
                if ( lArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) )
335
                {
304
                {
336
                    lArgs[i].Value >>= aText;
305
                    lArgs[i].Value >>= aText;
337
                    break;
306
                    break;
Lines 341-357 void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property Link Here
341
            // just enable this command
310
            // just enable this command
342
		    
311
		    
343
            // set enable flag according to selection
312
            // set enable flag according to selection
344
            if ( aText.equalsAscii( "Button Disabled" ))
313
            if ( aText.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Button Disabled" ) ))
345
                mbButtonEnabled = sal_False;
314
                mbButtonEnabled = sal_False;
346
            else
315
            else
347
                mbButtonEnabled = sal_True;
316
                mbButtonEnabled = sal_True;
348
317
349
            // create new URL to address the image button
318
            // create new URL to address the image button
350
            URL aCmdURL;
319
            URL aCmdURL;
351
            aCmdURL.Path = rtl::OUString::createFromAscii( "Command1" );
320
            aCmdURL.Path = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ImageButtonCmd" ) );
352
            aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" );
321
            aCmdURL.Protocol = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) );
353
            aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
322
            aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
354
            
323
355
            // create and initialize FeatureStateEvent with IsEnabled
324
            // create and initialize FeatureStateEvent with IsEnabled
356
            ::com::sun::star::frame::FeatureStateEvent aEvent;
325
            ::com::sun::star::frame::FeatureStateEvent aEvent;
357
			aEvent.FeatureURL = aCmdURL;
326
			aEvent.FeatureURL = aCmdURL;
Lines 359-380 void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property Link Here
359
			aEvent.IsEnabled = mbButtonEnabled;
328
			aEvent.IsEnabled = mbButtonEnabled;
360
			aEvent.Requery = sal_False;
329
			aEvent.Requery = sal_False;
361
			aEvent.State <<= Any();
330
			aEvent.State <<= Any();
362
            
331
363
            // Notify listener about new state
332
            // Notify listener about new state
364
            Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
333
            Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
365
            aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent ); 
334
            aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent ); 
366
        }
335
        }
367
        else if ( !aURL.Path.compareToAscii("Command5" ) )
336
        else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) )
368
        {
337
        {
369
        }
338
        }
339
        else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) )
340
        {
341
            // Retrieve the text argument from the sequence property value
342
            rtl::OUString aText;
343
            for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
344
            {
345
                if ( lArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) )
346
                {
347
                    lArgs[i].Value >>= aText;
348
                    break;
349
                }
350
            }
351
            OSL_TRACE( "Dropdownbox control - selected entry text : %s", 
352
                       rtl::OUStringToOString( aText, RTL_TEXTENCODING_UTF8 ).getStr() );
353
        }
370
	}
354
	}
371
}
355
}
372
356
373
void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
357
void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
374
{
358
{
375
	if ( aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
359
	if ( aURL.Protocol.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) )
376
	{
360
	{
377
		if ( aURL.Path.equalsAscii("Command1" ) )
361
		if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) )
378
        {
362
        {
379
			// just enable this command
363
			// just enable this command
380
		    ::com::sun::star::frame::FeatureStateEvent aEvent;
364
		    ::com::sun::star::frame::FeatureStateEvent aEvent;
Lines 385-391 void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener Link Here
385
			aEvent.State <<= Any();
369
			aEvent.State <<= Any();
386
			xControl->statusChanged( aEvent );
370
			xControl->statusChanged( aEvent );
387
        }
371
        }
388
        else if ( aURL.Path.equalsAscii("Command2" ) )
372
        else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) )
389
		{
373
		{
390
			// just enable this command
374
			// just enable this command
391
		    ::com::sun::star::frame::FeatureStateEvent aEvent;
375
		    ::com::sun::star::frame::FeatureStateEvent aEvent;
Lines 396-488 void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener Link Here
396
			aEvent.State <<= Any();
380
			aEvent.State <<= Any();
397
			xControl->statusChanged( aEvent );
381
			xControl->statusChanged( aEvent );
398
		}
382
		}
399
		else if ( aURL.Path.equalsAscii("Command3" ) )
383
		else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ToggleDropdownButtonCmd" ) ) )
400
		{
384
		{
401
            // A toggle dropdown box is normally used for a group of commands
385
            // A toggle dropdown box is normally used for a group of commands
402
            // where the user can select the last issued command easily.
386
            // where the user can select the last issued command easily.
403
            // E.g. a typical command group would be "Insert shape"
387
            // E.g. a typical command group would be "Insert shape"
404
            Sequence< NamedValue > aArgs( 1 );
388
            Sequence< NamedValue > aArgs( 1 );
405
            
389
406
            // send command to set context menu content
390
            // send command to set context menu content
407
            Sequence< rtl::OUString > aContextMenu( 3 );
391
            Sequence< rtl::OUString > aContextMenu( 3 );
408
            aContextMenu[0] = rtl::OUString::createFromAscii( "Command 1" );
392
            aContextMenu[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command 1" ) );
409
            aContextMenu[1] = rtl::OUString::createFromAscii( "Command 2" );
393
            aContextMenu[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command 2" ) );
410
            aContextMenu[2] = rtl::OUString::createFromAscii( "Command 3" );
394
            aContextMenu[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command 3" ) );
411
            
395
412
            aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
396
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) );
413
            aArgs[0].Value <<= aContextMenu;
397
            aArgs[0].Value <<= aContextMenu;
414
            SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
398
            SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetList" ) ), aArgs, sal_True );
415
            
399
416
            // send command to check item on pos=0
400
            // send command to check item on pos=0
417
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
401
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
418
            aArgs[0].Value <<= sal_Int32( 0 );            
402
            aArgs[0].Value <<= sal_Int32( 0 );
419
            SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True );
403
            SendCommandTo( xControl, aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckItemPos" ) ), aArgs, sal_True );
420
        }
404
        }
421
        else if ( aURL.Path.equalsAscii("Command4" ) )
405
        else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) )
422
        {
406
        {
423
            // A dropdown box is normally used for a group of dependent modes, where
407
            // A dropdown box is normally used for a group of dependent modes, where
424
            // the user can only select one. The modes cannot be combined.
408
            // the user can only select one. The modes cannot be combined.
425
            // E.g. a typical group would be left,right,center,block.
409
            // E.g. a typical group would be left,right,center,block.
426
            Sequence< NamedValue > aArgs( 1 );
410
            Sequence< NamedValue > aArgs( 1 );
427
            
411
428
            // send command to set context menu content
412
            // send command to set context menu content
429
            Sequence< rtl::OUString > aContextMenu( 2 );
413
            Sequence< rtl::OUString > aContextMenu( 2 );
430
            aContextMenu[0] = rtl::OUString::createFromAscii( "Button Enabled" );
414
            aContextMenu[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Button Enabled" ) );
431
            aContextMenu[1] = rtl::OUString::createFromAscii( "Button Disabled" );
415
            aContextMenu[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Button Disabled" ) );
432
            
416
433
            aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
417
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) );
434
            aArgs[0].Value <<= aContextMenu;
418
            aArgs[0].Value <<= aContextMenu;
435
            SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );            
419
            SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetList" ) ), aArgs, sal_True );            
436
420
437
            // set position according to enable/disable state of button
421
            // set position according to enable/disable state of button
438
            sal_Int32 nPos( mbButtonEnabled ? 0 : 1 );
422
            sal_Int32 nPos( mbButtonEnabled ? 0 : 1 );
439
            
423
440
            // send command to check item on pos=0
424
            // send command to check item on pos=0
441
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
425
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ) );
442
            aArgs[0].Value <<= nPos;
426
            aArgs[0].Value <<= nPos;
443
            SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True );
427
            SendCommandTo( xControl, aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckItemPos" ) ), aArgs, sal_True );
444
        }
428
        }
445
        else if ( aURL.Path.equalsAscii("Command5" ) )
429
        else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) )
446
        {
430
        {
447
            // A spin button
431
            // A spin button
448
            Sequence< NamedValue > aArgs( 5 );
432
            Sequence< NamedValue > aArgs( 5 );
449
            
433
450
            // send command to initialize spin button
434
            // send command to initialize spin button
451
            aArgs[0].Name = rtl::OUString::createFromAscii( "Value" );
435
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" ) );
452
            aArgs[0].Value <<= double( 0.0 );
436
            aArgs[0].Value <<= double( 0.0 );
453
            aArgs[1].Name = rtl::OUString::createFromAscii( "UpperLimit" );
437
            aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UpperLimit" ) );
454
            aArgs[1].Value <<= double( 10.0 );
438
            aArgs[1].Value <<= double( 10.0 );
455
            aArgs[2].Name = rtl::OUString::createFromAscii( "LowerLimit" );
439
            aArgs[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LowerLimit" ) );
456
            aArgs[2].Value <<= double( 0.0 );
440
            aArgs[2].Value <<= double( 0.0 );
457
            aArgs[3].Name = rtl::OUString::createFromAscii( "Step" );
441
            aArgs[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Step" ) );
458
            aArgs[3].Value <<= double( 0.1 );
442
            aArgs[3].Value <<= double( 0.1 );
459
            aArgs[4].Name = rtl::OUString::createFromAscii( "OutputFormat" );
443
            aArgs[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OutputFormat" ) );
460
            aArgs[4].Value <<= rtl::OUString::createFromAscii( "%.2f cm" );
444
            aArgs[4].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "%.2f cm" ) );
461
445
462
            SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetValues" ), aArgs, sal_True );
446
            SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetValues" ) ), aArgs, sal_True );
463
        }
447
        }
464
        else if ( aURL.Path.equalsAscii("Command7" ) )
448
        else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) )
465
        {
449
        {
466
            // A dropdown box is normally used for a group of commands
450
            // A dropdown box is normally used for a group of commands
467
            // where the user can select one of a defined set.
451
            // where the user can select one of a defined set.
468
            Sequence< NamedValue > aArgs( 1 );
452
            Sequence< NamedValue > aArgs( 1 );
469
            
453
470
            // send command to set context menu content
454
            // send command to set context menu content
471
            Sequence< rtl::OUString > aList( 10 );
455
            Sequence< rtl::OUString > aList( 10 );
472
            aList[0] = rtl::OUString::createFromAscii( "White" );
456
            aList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "White" ) );
473
            aList[1] = rtl::OUString::createFromAscii( "Black" );
457
            aList[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Black" ) );
474
            aList[2] = rtl::OUString::createFromAscii( "Red" );
458
            aList[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Red" ) );
475
            aList[3] = rtl::OUString::createFromAscii( "Blue" );
459
            aList[3] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) );
476
            aList[4] = rtl::OUString::createFromAscii( "Green" );
460
            aList[4] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Green" ) );
477
            aList[5] = rtl::OUString::createFromAscii( "Grey" );
461
            aList[5] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grey" ) );
478
            aList[6] = rtl::OUString::createFromAscii( "Yellow" );
462
            aList[6] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) );
479
            aList[7] = rtl::OUString::createFromAscii( "Orange" );
463
            aList[7] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Orange" ) );
480
            aList[8] = rtl::OUString::createFromAscii( "Brown" );
464
            aList[8] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) );
481
            aList[9] = rtl::OUString::createFromAscii( "Pink" );
465
            aList[9] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pink" ) );
482
            
466
483
            aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
467
            aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) );
484
            aArgs[0].Value <<= aList;
468
            aArgs[0].Value <<= aList;
485
            SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
469
            SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetList" ) ), aArgs, sal_True );
486
        }
470
        }
487
471
488
		aListenerHelper.AddListener( mxFrame, xControl, aURL.Path );
472
		aListenerHelper.AddListener( mxFrame, xControl, aURL.Path );
Lines 496-529 void SAL_CALL BaseDispatch::removeStatusListener( const Reference< XStatusListen Link Here
496
480
497
void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException)
481
void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException)
498
{
482
{
499
    if ( Event.aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:" ))
483
    if ( Event.aURL.Protocol.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) )
500
	{
484
	{
501
        if ( Event.aURL.Path.equalsAscii( "Command2" ))
485
        if ( Event.aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) )
502
        {
486
        {
503
            // We get notifications whenever the text inside the combobox has been changed.
487
            // We get notifications whenever the text inside the combobox has been changed.
504
            // We store the new text into a member.
488
            // We store the new text into a member.
505
            if ( Event.Event.equalsAscii( "TextChanged" ))
489
            if ( Event.Event.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "TextChanged" ) ) )
506
            {
490
            {
507
                rtl::OUString aNewText;
491
                rtl::OUString aNewText;
508
                sal_Bool      bHasText( sal_False );
492
                sal_Bool      bHasText( sal_False );
509
                for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ )
493
                for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ )
510
                {
494
                {
511
                    if ( Event.aInformation[i].Name.equalsAsciiL( "Text", 4 ))
495
                    if ( Event.aInformation[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) )
512
                    {
496
                    {
513
                        bHasText = Event.aInformation[i].Value >>= aNewText;
497
                        bHasText = Event.aInformation[i].Value >>= aNewText;
514
                        break;
498
                        break;
515
                    }
499
                    }
516
                }
500
                }
517
                
501
518
                if ( bHasText )
502
                if ( bHasText )
519
                    maComboBoxText = aNewText;
503
                    maComboBoxText = aNewText;
520
            }
504
            }
521
        }
505
        }
522
    }
506
    }
523
}
507
}
524
 
508
525
BaseDispatch::BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
509
BaseDispatch::BaseDispatch( const Reference< XMultiServiceFactory > &rxMSF,
526
        const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName )
510
        const Reference< XFrame >& xFrame, const rtl::OUString& rServiceName )
527
        : mxMSF( rxMSF )
511
        : mxMSF( rxMSF )
528
		, mxFrame( xFrame )
512
		, mxFrame( xFrame )
529
        , msDocService( rServiceName )
513
        , msDocService( rServiceName )
(-)a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h (-6 / +4 lines)
Lines 1-16 Link Here
1
#ifndef _MyProtocolHandler_HXX
1
#ifndef _MyProtocolHandler_HXX
2
#define _MyProtocolHandler_HXX
2
#define _MyProtocolHandler_HXX
3
3
4
#include <com/sun/star/awt/XToolkit.hpp>
5
#include <com/sun/star/beans/NamedValue.hpp>
4
#include <com/sun/star/lang/XInitialization.hpp>
6
#include <com/sun/star/lang/XInitialization.hpp>
7
#include <com/sun/star/lang/XServiceInfo.hpp>
5
#include <com/sun/star/frame/XDispatchProvider.hpp>
8
#include <com/sun/star/frame/XDispatchProvider.hpp>
6
#include <com/sun/star/frame/XControlNotificationListener.hpp>
9
#include <com/sun/star/frame/XControlNotificationListener.hpp>
7
#include <com/sun/star/lang/XServiceInfo.hpp>
8
#include <com/sun/star/beans/NamedValue.hpp>
9
#include <cppuhelper/implbase3.hxx>
10
#ifndef _CPPUHELPER_IMPLBASE2_HXX
11
#include <cppuhelper/implbase2.hxx>
10
#include <cppuhelper/implbase2.hxx>
12
#endif
11
#include <cppuhelper/implbase3.hxx>
13
#include <com/sun/star/awt/XToolkit.hpp>
14
12
15
#define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME   "vnd.demo.Impl.ProtocolHandler"
13
#define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME   "vnd.demo.Impl.ProtocolHandler"
16
#define MYPROTOCOLHANDLER_SERVICENAME          "vnd.demo.ProtocolHandler"
14
#define MYPROTOCOLHANDLER_SERVICENAME          "vnd.demo.ProtocolHandler"
(-)a/odk/examples/cpp/complextoolbarcontrols/exports.cxx (-42 / +39 lines)
Lines 25-57 Link Here
25
 *
25
 *
26
 ************************************************************************/
26
 ************************************************************************/
27
27
28
29
#include <stdio.h>
30
31
#include <osl/mutex.hxx>
32
#include <osl/thread.h>
33
#include <cppuhelper/factory.hxx>
28
#include <cppuhelper/factory.hxx>
34
#include <rtl/ustring.hxx>
35
#include <rtl/ustrbuf.hxx>
36
#include <sal/types.h>
37
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
38
29
39
#include "MyProtocolHandler.h"
30
#include "MyProtocolHandler.h"
40
#include "MyListener.h"
31
#include "MyListener.h"
41
32
42
namespace css = ::com::sun::star;
33
namespace css = ::com::sun::star;
43
34
44
// static void writeInfo(const css::uno::Reference< css::registry::XRegistryKey >& xRegistryKey       ,
35
#if 0
45
//                       const char*                                               pImplementationName,
36
static void writeInfo(const css::uno::Reference< css::registry::XRegistryKey >& xRegistryKey       ,
46
//                       const char*                                               pServiceName       )
37
                      const char*                                               pImplementationName,
47
// {
38
                      const char*                                               pServiceName       )
48
//     ::rtl::OUStringBuffer sKey(256);
39
{
49
// 	sKey.append     (::rtl::OUString::createFromAscii(pImplementationName));
40
    ::rtl::OUStringBuffer sKey(256);
50
//     sKey.appendAscii("/UNO/SERVICES/");
41
	sKey.append     (::rtl::OUString::createFromAscii(pImplementationName));
51
//     sKey.append     (::rtl::OUString::createFromAscii(pServiceName));
42
    sKey.appendAscii("/UNO/SERVICES/");
43
    sKey.append     (::rtl::OUString::createFromAscii(pServiceName));
52
44
53
//     xRegistryKey->createKey(sKey.makeStringAndClear());
45
    xRegistryKey->createKey(sKey.makeStringAndClear());
54
// }
46
}
47
#endif
55
48
56
extern "C"
49
extern "C"
57
{
50
{
Lines 62-91 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const Link Here
62
	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
55
	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
63
}
56
}
64
57
65
// This method not longer necessary since OOo 3.4 where the component registration was
58
#if 0
66
// was changed to passive component registration. For more details see
59
/**
67
// http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
60
 * This method not longer necessary since OOo 3.4 where the component registration was
61
 * was changed to passive component registration. For more details see
62
 * http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
63
 */
68
//==================================================================================================
64
//==================================================================================================
69
// SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* pServiceManager,
65
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* pServiceManager,
70
//                                                             void* pRegistryKey   )
66
                                                            void* pRegistryKey   )
71
// {
67
{
72
//     if (!pRegistryKey)
68
    if (!pRegistryKey)
73
//         return sal_False;
69
        return sal_False;
74
70
75
//     try
71
    try
76
//     {
72
    {
77
//         css::uno::Reference< css::registry::XRegistryKey > xKey(reinterpret_cast< css::registry::XRegistryKey* >(pRegistryKey), css::uno::UNO_QUERY);
73
        css::uno::Reference< css::registry::XRegistryKey > xKey(reinterpret_cast< css::registry::XRegistryKey* >(pRegistryKey), css::uno::UNO_QUERY);
78
74
79
//         writeInfo( xKey, MYLISTENER_IMPLEMENTATIONNAME       , MYLISTENER_SERVICENAME        );
75
        writeInfo( xKey, MYLISTENER_IMPLEMENTATIONNAME       , MYLISTENER_SERVICENAME        );
80
//         writeInfo( xKey, MYPROTOCOLHANDLER_IMPLEMENTATIONNAME, MYPROTOCOLHANDLER_SERVICENAME );
76
        writeInfo( xKey, MYPROTOCOLHANDLER_IMPLEMENTATIONNAME, MYPROTOCOLHANDLER_SERVICENAME );
81
77
82
//         return sal_True;
78
        return sal_True;
83
//     }
79
    }
84
//     catch(const css::registry::InvalidRegistryException&)
80
    catch(const css::registry::InvalidRegistryException&)
85
//         { OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); }
81
        { OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); }
86
82
87
//     return sal_False;
83
    return sal_False;
88
// }
84
}
85
#endif
89
86
90
//==================================================================================================
87
//==================================================================================================
91
SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplName      ,
88
SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplName      ,
Lines 99-115 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplNa Link Here
99
    css::uno::Reference< css::lang::XMultiServiceFactory >  xSMGR     (reinterpret_cast< css::lang::XMultiServiceFactory* >(pServiceManager), css::uno::UNO_QUERY);
96
    css::uno::Reference< css::lang::XMultiServiceFactory >  xSMGR     (reinterpret_cast< css::lang::XMultiServiceFactory* >(pServiceManager), css::uno::UNO_QUERY);
100
    ::rtl::OUString                                         sImplName = ::rtl::OUString::createFromAscii(pImplName);
97
    ::rtl::OUString                                         sImplName = ::rtl::OUString::createFromAscii(pImplName);
101
98
102
    if (sImplName.equalsAscii(MYLISTENER_IMPLEMENTATIONNAME))
99
    if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) ) )
103
	{
100
	{
104
        css::uno::Sequence< ::rtl::OUString > lNames(1);
101
        css::uno::Sequence< ::rtl::OUString > lNames(1);
105
        lNames[0] = ::rtl::OUString::createFromAscii(MYLISTENER_IMPLEMENTATIONNAME);
102
        lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) );
106
		xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyListener::st_createInstance, lNames);
103
		xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyListener::st_createInstance, lNames);
107
	}
104
	}
108
    else
105
    else
109
    if (sImplName.equalsAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME))
106
    if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYPROTOCOLHANDLER_IMPLEMENTATIONNAME ) ) )
110
	{
107
	{
111
        css::uno::Sequence< ::rtl::OUString > lNames(1);
108
        css::uno::Sequence< ::rtl::OUString > lNames(1);
112
        lNames[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME);
109
        lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) );
113
        xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyProtocolHandler_createInstance, lNames);
110
        xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyProtocolHandler_createInstance, lNames);
114
	}
111
	}
115
112

Return to issue 104788