xref: /trunk/main/sc/inc/afmtuno.hxx (revision 9d37da743abb7db0a497688391f6e55a19f27c44)
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_AFMTUNO_HXX
25 #define SC_AFMTUNO_HXX
26 
27 #include <svl/lstner.hxx>
28 #include <svl/itemprop.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XContainer.hpp>
31 #include <com/sun/star/container/XIndexContainer.hpp>
32 #include <com/sun/star/container/XNameReplace.hpp>
33 #include <com/sun/star/container/XContainerListener.hpp>
34 #include <com/sun/star/container/XSet.hpp>
35 #include <com/sun/star/container/ContainerEvent.hpp>
36 #include <com/sun/star/container/XIndexReplace.hpp>
37 #include <com/sun/star/container/XNameContainer.hpp>
38 #include <com/sun/star/container/XNamed.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <cppuhelper/implbase2.hxx>
43 #include <cppuhelper/implbase4.hxx>
44 #include <cppuhelper/implbase6.hxx>
45 
46 class ScAutoFormatFieldObj;
47 class ScAutoFormatObj;
48 
49 
50 #define SC_AFMTOBJ_INVALID  USHRT_MAX
51 
52 
53 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
54     ScAutoFormatsObj_CreateInstance(
55         const ::com::sun::star::uno::Reference<
56             ::com::sun::star::lang::XMultiServiceFactory >& );
57 
58 
59 class ScAutoFormatsObj : public ::cppu::WeakImplHelper4<
60                             ::com::sun::star::container::XNameContainer,
61                             ::com::sun::star::container::XEnumerationAccess,
62                             ::com::sun::star::container::XIndexAccess,
63                             ::com::sun::star::lang::XServiceInfo >
64 {
65 private:
66     ScAutoFormatObj*        GetObjectByIndex_Impl(sal_uInt16 nIndex);
67     ScAutoFormatObj*        GetObjectByName_Impl(const ::rtl::OUString& aName);
68 
69 public:
70                             ScAutoFormatsObj();
71     virtual                 ~ScAutoFormatsObj();
72 
73     static ::rtl::OUString  getImplementationName_Static();
74     static ::com::sun::star::uno::Sequence< ::rtl::OUString> getSupportedServiceNames_Static();
75 
76                             // XNameContainer
77     virtual void SAL_CALL   insertByName( const ::rtl::OUString& aName,
78                                 const ::com::sun::star::uno::Any& aElement );
79     virtual void SAL_CALL   removeByName( const ::rtl::OUString& Name );
80 
81                             // XNameReplace
82     virtual void SAL_CALL   replaceByName( const ::rtl::OUString& aName,
83                                 const ::com::sun::star::uno::Any& aElement );
84 
85                             // XNameAccess
86     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName );
87     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames();
88     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName );
89 
90                             // XElementAccess
91     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
92     virtual sal_Bool SAL_CALL hasElements();
93 
94                             // XEnumerationAccess
95     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
96                             createEnumeration();
97 
98                             // XIndexAccess
99     virtual sal_Int32 SAL_CALL getCount();
100     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index );
101 
102                             // XServiceInfo
103     virtual ::rtl::OUString SAL_CALL getImplementationName();
104     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
105     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
106 };
107 
108 
109 class ScAutoFormatObj : public ::cppu::WeakImplHelper6<
110                             ::com::sun::star::container::XIndexAccess,
111                             ::com::sun::star::container::XEnumerationAccess,
112                             ::com::sun::star::container::XNamed,
113                             ::com::sun::star::beans::XPropertySet,
114                             ::com::sun::star::lang::XUnoTunnel,
115                             ::com::sun::star::lang::XServiceInfo >,
116                         public SfxListener
117 {
118 private:
119     SfxItemPropertySet      aPropSet;
120     sal_uInt16                  nFormatIndex;
121 
122     ScAutoFormatFieldObj*   GetObjectByIndex_Impl(sal_uInt16 nIndex);
123 
124 public:
125                             ScAutoFormatObj(sal_uInt16 nIndex);
126     virtual                 ~ScAutoFormatObj();
127 
128     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
129 
130                             // per getImplementation gerufen:
131     sal_Bool                IsInserted() const      { return nFormatIndex != SC_AFMTOBJ_INVALID; }
132     void                    InitFormat( sal_uInt16 nNewIndex );
133 
134                             // XIndexAccess
135     virtual sal_Int32 SAL_CALL getCount();
136     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index );
137 
138                             // XElementAccess
139     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
140     virtual sal_Bool SAL_CALL hasElements();
141 
142                             // XEnumerationAccess
143     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
144                             createEnumeration();
145 
146                             // XNamed
147     virtual ::rtl::OUString SAL_CALL getName();
148     virtual void SAL_CALL   setName( const ::rtl::OUString& aName );
149 
150                             // XPropertySet
151     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
152                             SAL_CALL getPropertySetInfo();
153     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
154                                     const ::com::sun::star::uno::Any& aValue );
155     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
156                                     const ::rtl::OUString& PropertyName );
157     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
158                                     const ::com::sun::star::uno::Reference<
159                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener );
160     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
161                                     const ::com::sun::star::uno::Reference<
162                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener );
163     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
164                                     const ::com::sun::star::uno::Reference<
165                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
166     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
167                                     const ::com::sun::star::uno::Reference<
168                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
169 
170                             // XServiceInfo
171     virtual ::rtl::OUString SAL_CALL getImplementationName();
172     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
173     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
174 
175                             // XUnoTunnel
176     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
177                                     sal_Int8 >& aIdentifier );
178 
179     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
180     static ScAutoFormatObj* getImplementation( const ::com::sun::star::uno::Reference<
181                                     ::com::sun::star::uno::XInterface> xObj );
182 };
183 
184 
185 class ScAutoFormatFieldObj : public ::cppu::WeakImplHelper2<
186                                 ::com::sun::star::beans::XPropertySet,
187                                 ::com::sun::star::lang::XServiceInfo >,
188                             public SfxListener
189 {
190 private:
191     SfxItemPropertySet      aPropSet;
192     sal_uInt16                  nFormatIndex;
193     sal_uInt16                  nFieldIndex;
194 
195 public:
196                             ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField);
197     virtual                 ~ScAutoFormatFieldObj();
198 
199     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
200 
201                             // XPropertySet
202     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
203                             SAL_CALL getPropertySetInfo();
204     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
205                                     const ::com::sun::star::uno::Any& aValue );
206     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
207                                     const ::rtl::OUString& PropertyName );
208     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
209                                     const ::com::sun::star::uno::Reference<
210                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener );
211     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
212                                     const ::com::sun::star::uno::Reference<
213                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener );
214     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
215                                     const ::com::sun::star::uno::Reference<
216                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
217     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
218                                     const ::com::sun::star::uno::Reference<
219                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener );
220 
221                             // XServiceInfo
222     virtual ::rtl::OUString SAL_CALL getImplementationName();
223     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
224     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
225 };
226 
227 
228 #endif
229