xref: /trunk/main/sc/inc/targuno.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL      getElementNames(void);
92     virtual sal_Bool SAL_CALL           hasByName(const ::rtl::OUString& aName);
93 
94                             // ::com::sun::star::container::XElementAccess
95     virtual ::com::sun::star::uno::Type SAL_CALL        getElementType(void);
96     virtual sal_Bool SAL_CALL           hasElements(void);
97 
98                             // ::com::sun::star::lang::XServiceInfo
99     virtual ::rtl::OUString SAL_CALL            getImplementationName(void);
100     virtual sal_Bool SAL_CALL           supportsService(const ::rtl::OUString& ServiceName);
101     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL      getSupportedServiceNames(void);
102 };
103 
104 
105 class ScLinkTargetTypeObj : public ::cppu::WeakImplHelper3<
106                                 ::com::sun::star::beans::XPropertySet,
107                                 ::com::sun::star::document::XLinkTargetSupplier,
108                                 ::com::sun::star::lang::XServiceInfo >,
109                             public SfxListener
110 {
111 private:
112     ScDocShell*             pDocShell;
113     sal_uInt16              nType;
114     String                  aName;
115 
116 public:
117                             ScLinkTargetTypeObj(ScDocShell* pDocSh, sal_uInt16 nT);
118     virtual                 ~ScLinkTargetTypeObj();
119 
120     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
121 
122     static void             SetLinkTargetBitmap( ::com::sun::star::uno::Any& rRet, sal_uInt16 nType );
123 
124                             // ::com::sun::star::beans::XPropertySet
125     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL  getPropertySetInfo(void);
126     virtual void SAL_CALL   setPropertyValue(const ::rtl::OUString& aPropertyName,
127                                     const ::com::sun::star::uno::Any& aValue);
128     virtual ::com::sun::star::uno::Any SAL_CALL     getPropertyValue(const ::rtl::OUString& PropertyName);
129     virtual void SAL_CALL           addPropertyChangeListener(const ::rtl::OUString& aPropertyName,
130                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & xListener);
131     virtual void SAL_CALL           removePropertyChangeListener(const ::rtl::OUString& aPropertyName,
132                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener);
133     virtual void SAL_CALL           addVetoableChangeListener(const ::rtl::OUString& PropertyName,
134                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener);
135     virtual void SAL_CALL           removeVetoableChangeListener(const ::rtl::OUString& PropertyName,
136                                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener);
137 
138                             // ::com::sun::star::document::XLinkTargetSupplier
139     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL  getLinks(void);
140 
141                             // ::com::sun::star::lang::XServiceInfo
142     virtual ::rtl::OUString SAL_CALL            getImplementationName(void);
143     virtual sal_Bool SAL_CALL           supportsService(const ::rtl::OUString& ServiceName);
144     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames(void);
145 };
146 
147 
148 class ScLinkTargetsObj : public ::cppu::WeakImplHelper2<
149                             ::com::sun::star::container::XNameAccess,
150                             ::com::sun::star::lang::XServiceInfo >
151 {
152 private:
153     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >            xCollection;
154 
155 public:
156                             ScLinkTargetsObj( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & rColl );
157     virtual                 ~ScLinkTargetsObj();
158 
159                             // ::com::sun::star::container::XNameAccess
160     virtual ::com::sun::star::uno::Any SAL_CALL         getByName(const ::rtl::OUString& aName);
161     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL      getElementNames(void);
162     virtual sal_Bool SAL_CALL           hasByName(const ::rtl::OUString& aName);
163 
164                             // ::com::sun::star::container::XElementAccess
165     virtual ::com::sun::star::uno::Type SAL_CALL        getElementType(void);
166     virtual sal_Bool SAL_CALL           hasElements(void);
167 
168                             // ::com::sun::star::lang::XServiceInfo
169     virtual ::rtl::OUString SAL_CALL            getImplementationName(void);
170     virtual sal_Bool SAL_CALL           supportsService(const ::rtl::OUString& ServiceName);
171     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL      getSupportedServiceNames(void);
172 };
173 
174 
175 #endif
176