xref: /aoo4110/main/sfx2/source/inc/tplcomp.hxx (revision b1cdbd2c)
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 _TPLCOMP_HXX
25 #define _TPLCOMP_HXX
26 
27 #include <osl/mutex.hxx>
28 //ASDBG #ifndef _USR_UNO_HXX
29 //ASDBG #include <usr/uno.hxx>
30 //ASDBG #endif
31 //ASDBG #ifndef _USR_LSTCOMP_HXX
32 //ASDBG #include <usr/iterhlp.hxx>
33 //ASDBG #endif
34 //ASDBG #ifndef _USR_SERVICES_HXX
35 //ASDBG #include <usr/services.hxx>
36 //ASDBG #endif
37 #include <com/sun/star/chaos/XCommandExecutor.hpp>
38 #include <com/sun/star/chaos/XStatusCallback.hpp>
39 #include <com/sun/star/chaos/UnknownCommandException.hpp>
40 #include <com/sun/star/chaos/StatusCallbackEvent.hpp>
41 #include <com/sun/star/chaos/XURLContent.hpp>
42 #include <com/sun/star/chaos/XExplorerExchange.hpp>
43 #include <com/sun/star/beans/PropertyValues.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include <com/sun/star/beans/PropertyState.hpp>
47 #include <com/sun/star/beans/XPropertySetInfo.hpp>
48 #include <com/sun/star/beans/XMultiPropertySet.hpp>
49 #include <com/sun/star/beans/XFastPropertySet.hpp>
50 #include <com/sun/star/beans/XVetoableChangeListener.hpp>
51 #include <com/sun/star/beans/XPropertyState.hpp>
52 #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
53 #include <com/sun/star/beans/PropertyAttribute.hpp>
54 #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
55 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
56 #include <com/sun/star/beans/XPropertyAccess.hpp>
57 #include <com/sun/star/beans/XPropertyContainer.hpp>
58 #include <com/sun/star/beans/PropertyStateChangeEvent.hpp>
59 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
60 #include <com/sun/star/lang/XServiceInfo.hpp>
61 #include <cppuhelper/weak.hxx>
62 #include <cppuhelper/interfacecontainer.hxx>
63 
64 class CntAnchor;
65 
66 class TplAnchorListener;
67 
68 // -----------------
69 // - TplComponent -
70 // -----------------
71 
72 class TplComponent : public ::com::sun::star::chaos::XURLContent, public ::com::sun::star::chaos::XCommandExecutor,
73 					 public ::com::sun::star::beans::XPropertySet, public ::com::sun::star::chaos::XExplorerExchange,
74 					 public ::cppu::OWeakObject, public ::com::sun::star::lang::XServiceInfo
75 {
76 private:
77 
78 	void						HandleNewEvt( const ::rtl::OUString& rCommand,
79 											  const ::com::sun::star::uno::Any& rAny );
80 	void						CreatePopupMenu( ::com::sun::star::uno::Any& rAny ) const;
81 
82 protected:
83 
84 	::rtl::OUString						maURL;
85 	::rtl::OUString						maName;
86     ::osl::Mutex         aMutex;
87     ::cppu::OInterfaceContainerHelper maListeners;
88 	TplAnchorListener*			mpListener;
89 	short						mnOpenMode;
90 
91 public:
92 
93 	SFX_DECL_XINTERFACE_XTYPEPROVIDER_XSERVICEINFO
94 
95 								TplComponent();
96 								~TplComponent();
97 
98 	// interface  ::com::sun::star::ucb::XContent
getParent()99 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SAL_CALL		getParent() throw ( ::com::sun::star::uno::RuntimeException )
100 			{ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  aRef; return aRef; }
setParent(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & Parent)101 	virtual void	    SAL_CALL				setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & Parent ) throw ( ::com::sun::star::uno::RuntimeException )
102 			{}
103 
104 	// interface  ::com::sun::star::chaos::XURLContent
getURL()105 	virtual ::rtl::OUString	  SAL_CALL				getURL()  throw ( ::com::sun::star::uno::RuntimeException )
106 			{ return maURL; }
107 	virtual sal_Bool	   SAL_CALL				initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XURLContent > & aParent, const ::rtl::OUString& aURL ) throw ( ::com::sun::star::uno::RuntimeException );
108 
109 	// interface  ::com::sun::star::chaos::XCommandExecutor
110 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  SAL_CALL	 queryCommands()  throw ( ::com::sun::star::uno::RuntimeException );
cancel(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & rCommandId)111 	virtual void	   SAL_CALL				cancel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rCommandId ) throw ( ::com::sun::star::uno::RuntimeException )
112 			{}
113 	virtual void	   SAL_CALL				execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Any& rArgs,
114 										 const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XStatusCallback > & rCallback ) throw ( ::com::sun::star::uno::RuntimeException );
115 
116 	// interface  ::com::sun::star::beans::XPropertySet
117 	virtual	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL	 getPropertySetInfo()  throw ( ::com::sun::star::uno::RuntimeException );
118     virtual void      SAL_CALL	           setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::uno::RuntimeException );
119 	virtual ::com::sun::star::uno::Any	 SAL_CALL				getPropertyValue( const ::rtl::OUString& aPropertyName )  throw ( ::com::sun::star::uno::RuntimeException );
120 	virtual void	  SAL_CALL				addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
121                                                            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
122 	virtual void	  SAL_CALL				removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
123                                                               const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
124 	virtual void	  SAL_CALL				addVetoableChangeListener( const ::rtl::OUString& aPropertyName,
125                                                            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
126 	virtual void	  SAL_CALL				removeVetoableChangeListener( const ::rtl::OUString& aPropertyName,
127                                                               const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
128 	// interface  ::com::sun::star::chaos::XExplorerExchange
129 	virtual ::com::sun::star::uno::Any	   SAL_CALL				createDataObject( sal_uInt16& nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
130 	virtual sal_uInt16	  SAL_CALL				insertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
131 												  sal_uInt16 nUserAction,
132 												  sal_uInt16 nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
133 	virtual sal_Bool	  SAL_CALL				queryInsertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
134 													   sal_uInt16 nUserAction,
135 													   sal_uInt16 nSourceOptions,
136 													   sal_uInt16& nResultingAction,
137 													   sal_uInt16& nDefaultAction ) throw ( ::com::sun::star::uno::RuntimeException );
138 
139 
140 	// -------------------------------------------------------------
141 
142 	void						CreateNewChild( CntAnchor* pAnchor,
143 												const String& rTitle );
144 	void						RemoveChild( CntAnchor* pAnchor );
145 	void						StopListening( CntAnchor* pAnchor );
146 	void						HandleOpenEvt();
147 };
148 
149 // ------------------------
150 // - TplContentsComponent -
151 // ------------------------
152 
153 class TplContentsListener;
154 
155 class TplContentsComponent : public TplComponent
156 {
157 private:
158 	::com::sun::star::uno::Reference< ::com::sun::star::chaos::XURLContent > 				_xParent;
159 	TplContentsListener*		_pListener;
160 	SvDataObjectRef				_xObject;
161 	sal_uInt16						_nLayout;
162 
163 	void						HandleOpenEvt( const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XStatusCallback > & rJob,
164 											   const ::com::sun::star::chaos::StatusCallbackEvent& rEvt );
165 	void						HandleNewEvt( const ::rtl::OUString& rCommand,
166 											  const ::com::sun::star::uno::Any& rAny );
167 	void						HandleInitEvt();
168 
169 	void						CreateFileName( String& rName,
170 												String& rDirURL );
171 	void						CreateNewTpl( const String& rFilter,
172 											  const String& rParentDir,
173 											  const String& rFileName,
174 											  const String& rDocName );
175 protected:
176 
177 	void						CreatePopupMenu( ::com::sun::star::uno::Any& rAny ) const;
178 
179 public:
180 
181 	SFX_DECL_XINTERFACE_XTYPEPROVIDER_XSERVICEINFO
182 
183 								TplContentsComponent();
184 								~TplContentsComponent();
185 
186 	virtual sal_Bool   SAL_CALL				initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XURLContent > & aParent, const ::rtl::OUString& aURL ) throw ( ::com::sun::star::uno::RuntimeException );
187 
188 
189 	// interface  ::com::sun::star::chaos::XCommandExecutor
190 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  SAL_CALL	 queryCommands()  throw ( ::com::sun::star::uno::RuntimeException );
191 	virtual void		 SAL_CALL			execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Any& rArgs,
192 										 const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XStatusCallback > & rCallback ) throw ( ::com::sun::star::uno::RuntimeException );
193 
194 	// interface  ::com::sun::star::beans::XPropertySet
195 	virtual	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL	 getPropertySetInfo()  throw ( ::com::sun::star::uno::RuntimeException );
196 	virtual ::com::sun::star::uno::Any	  SAL_CALL				getPropertyValue( const ::rtl::OUString& aPropertyName )  throw ( ::com::sun::star::uno::RuntimeException );
197 	virtual void	   SAL_CALL				setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::uno::RuntimeException );
198 
199 	// interface  ::com::sun::star::chaos::XExplorerExchange
200 	virtual ::com::sun::star::uno::Any	    SAL_CALL				createDataObject( sal_uInt16& nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
201 	virtual sal_uInt16  SAL_CALL					insertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
202 												  sal_uInt16 nUserAction,
203 												  sal_uInt16 nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
204 	virtual sal_Bool    SAL_CALL					queryInsertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
205 													   sal_uInt16 nUserAction,
206 													   sal_uInt16 nSourceOptions,
207 													   sal_uInt16& nResultingAction,
208 													   sal_uInt16& nDefaultAction ) throw ( ::com::sun::star::uno::RuntimeException );
209 
210 	// -------------------------------------------------------------
211 
212 	void						CreateNewChild( CntAnchor* pAnchor );
213 	void						HandleDeleteEvt();
214 	void						SetURL( const ::rtl::OUString& rURL);
215 	void						SetName( const ::rtl::OUString& rNewName );
216 };
217 
218 
219 #endif
220 
221