xref: /aoo42x/main/sc/inc/targuno.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_TARGUNO_HXX
25 #define SC_TARGUNO_HXX
26 
27 #include <svl/lstner.hxx>
28 #include <tools/string.hxx>
29 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
30 #include <com/sun/star/lang/XServiceName.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/beans/PropertyValues.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/beans/PropertyState.hpp>
36 #include <com/sun/star/beans/XPropertySetInfo.hpp>
37 #include <com/sun/star/beans/XMultiPropertySet.hpp>
38 #include <com/sun/star/beans/XFastPropertySet.hpp>
39 #include <com/sun/star/beans/XVetoableChangeListener.hpp>
40 #include <com/sun/star/beans/XPropertyState.hpp>
41 #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
44 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
45 #include <com/sun/star/beans/XPropertyAccess.hpp>
46 #include <com/sun/star/beans/XPropertyContainer.hpp>
47 #include <com/sun/star/beans/PropertyStateChangeEvent.hpp>
48 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
49 #include <com/sun/star/container/XEnumerationAccess.hpp>
50 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
51 #include <com/sun/star/container/XNameAccess.hpp>
52 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
53 #include <com/sun/star/container/XEnumeration.hpp>
54 #include <com/sun/star/container/XElementAccess.hpp>
55 #include <com/sun/star/container/XIndexAccess.hpp>
56 #include <cppuhelper/implbase2.hxx>
57 #include <cppuhelper/implbase3.hxx>
58 
59 class ScDocShell;
60 
61 
62 #define SC_LINKTARGETTYPE_SHEET		0
63 #define SC_LINKTARGETTYPE_RANGENAME	1
64 #define SC_LINKTARGETTYPE_DBAREA	2
65 
66 #define SC_LINKTARGETTYPE_COUNT		3
67 
68 #define SCLINKTARGET_SERVICE		"com.sun.star.document.LinkTarget"
69 
70 
71 //!	Graphic / OleObject (need separate collections!)
72 
73 
74 class ScLinkTargetTypesObj : public ::cppu::WeakImplHelper2<
75 								::com::sun::star::container::XNameAccess,
76 								::com::sun::star::lang::XServiceInfo >,
77 							public SfxListener
78 {
79 private:
80 	ScDocShell*				pDocShell;
81 	String					aNames[SC_LINKTARGETTYPE_COUNT];
82 
83 public:
84 							ScLinkTargetTypesObj(ScDocShell* pDocSh);
85 	virtual					~ScLinkTargetTypesObj();
86 
87 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
88 
89 							// ::com::sun::star::container::XNameAccess
90 	virtual ::com::sun::star::uno::Any SAL_CALL		getByName(const ::rtl::OUString& aName)
91 								throw(	::com::sun::star::container::NoSuchElementException,
92 										::com::sun::star::lang::WrappedTargetException,
93 										::com::sun::star::uno::RuntimeException );
94 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL		getElementNames(void) throw( ::com::sun::star::uno::RuntimeException );
95 	virtual sal_Bool SAL_CALL			hasByName(const ::rtl::OUString& aName) throw( ::com::sun::star::uno::RuntimeException );
96 
97 							// ::com::sun::star::container::XElementAccess
98 	virtual ::com::sun::star::uno::Type SAL_CALL		getElementType(void) throw( ::com::sun::star::uno::RuntimeException );
99 	virtual sal_Bool SAL_CALL			hasElements(void) throw( ::com::sun::star::uno::RuntimeException );
100 
101 							// ::com::sun::star::lang::XServiceInfo
102 	virtual ::rtl::OUString SAL_CALL			getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
103 	virtual sal_Bool SAL_CALL			supportsService(const ::rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
104 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL		getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
105 };
106 
107 
108 class ScLinkTargetTypeObj : public ::cppu::WeakImplHelper3<
109 								::com::sun::star::beans::XPropertySet,
110 								::com::sun::star::document::XLinkTargetSupplier,
111 								::com::sun::star::lang::XServiceInfo >,
112 							public SfxListener
113 {
114 private:
115 	ScDocShell*				pDocShell;
116 	sal_uInt16				nType;
117 	String					aName;
118 
119 public:
120 							ScLinkTargetTypeObj(ScDocShell* pDocSh, sal_uInt16 nT);
121 	virtual					~ScLinkTargetTypeObj();
122 
123 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
124 
125 	static void				SetLinkTargetBitmap( ::com::sun::star::uno::Any& rRet, sal_uInt16 nType );
126 
127 							// ::com::sun::star::beans::XPropertySet
128 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL  getPropertySetInfo(void) throw( ::com::sun::star::uno::RuntimeException );
129 	virtual void SAL_CALL	setPropertyValue(const ::rtl::OUString& aPropertyName,
130 									const ::com::sun::star::uno::Any& aValue)
131 								throw(	::com::sun::star::beans::UnknownPropertyException,
132 										::com::sun::star::beans::PropertyVetoException,
133  										::com::sun::star::lang::IllegalArgumentException,
134 										::com::sun::star::lang::WrappedTargetException,
135 										::com::sun::star::uno::RuntimeException );
136 	virtual ::com::sun::star::uno::Any SAL_CALL		getPropertyValue(const ::rtl::OUString& PropertyName)
137 								throw(	::com::sun::star::beans::UnknownPropertyException,
138 										::com::sun::star::lang::WrappedTargetException,
139 										::com::sun::star::uno::RuntimeException );
140 	virtual void SAL_CALL			addPropertyChangeListener(const ::rtl::OUString& aPropertyName,
141 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & xListener)
142 								throw(	::com::sun::star::beans::UnknownPropertyException,
143 										::com::sun::star::lang::WrappedTargetException,
144 										::com::sun::star::uno::RuntimeException );
145 	virtual void SAL_CALL			removePropertyChangeListener(const ::rtl::OUString& aPropertyName,
146 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener)
147 								throw( 	::com::sun::star::beans::UnknownPropertyException,
148 										::com::sun::star::lang::WrappedTargetException,
149 										::com::sun::star::uno::RuntimeException );
150 	virtual void SAL_CALL			addVetoableChangeListener(const ::rtl::OUString& PropertyName,
151 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener)
152 								throw(	::com::sun::star::beans::UnknownPropertyException,
153 										::com::sun::star::lang::WrappedTargetException,
154 										::com::sun::star::uno::RuntimeException );
155 	virtual void SAL_CALL			removeVetoableChangeListener(const ::rtl::OUString& PropertyName,
156 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener)
157 								throw(	::com::sun::star::beans::UnknownPropertyException,
158 										::com::sun::star::lang::WrappedTargetException,
159 										::com::sun::star::uno::RuntimeException );
160 
161 							// ::com::sun::star::document::XLinkTargetSupplier
162 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL  getLinks(void) throw( ::com::sun::star::uno::RuntimeException );
163 
164 							// ::com::sun::star::lang::XServiceInfo
165 	virtual ::rtl::OUString SAL_CALL			getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
166 	virtual sal_Bool SAL_CALL			supportsService(const ::rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
167 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
168 };
169 
170 
171 class ScLinkTargetsObj : public ::cppu::WeakImplHelper2<
172 							::com::sun::star::container::XNameAccess,
173 							::com::sun::star::lang::XServiceInfo >
174 {
175 private:
176 	::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > 			xCollection;
177 
178 public:
179 							ScLinkTargetsObj( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & rColl );
180 	virtual					~ScLinkTargetsObj();
181 
182 							// ::com::sun::star::container::XNameAccess
183 	virtual ::com::sun::star::uno::Any SAL_CALL			getByName(const ::rtl::OUString& aName)
184 								throw(	::com::sun::star::container::NoSuchElementException,
185 										::com::sun::star::lang::WrappedTargetException,
186  										::com::sun::star::uno::RuntimeException );
187 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL		getElementNames(void) throw( ::com::sun::star::uno::RuntimeException );
188 	virtual sal_Bool SAL_CALL			hasByName(const ::rtl::OUString& aName) throw( ::com::sun::star::uno::RuntimeException );
189 
190 							// ::com::sun::star::container::XElementAccess
191 	virtual ::com::sun::star::uno::Type SAL_CALL		getElementType(void) throw( ::com::sun::star::uno::RuntimeException );
192 	virtual sal_Bool SAL_CALL			hasElements(void) throw( ::com::sun::star::uno::RuntimeException );
193 
194 							// ::com::sun::star::lang::XServiceInfo
195 	virtual ::rtl::OUString SAL_CALL			getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
196 	virtual sal_Bool SAL_CALL			supportsService(const ::rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
197 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL		getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
198 };
199 
200 
201 #endif
202 
203