xref: /aoo41x/main/sfx2/source/inc/tplcomp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _TPLCOMP_HXX
29 #define _TPLCOMP_HXX
30 
31 #include <osl/mutex.hxx>
32 //ASDBG #ifndef _USR_UNO_HXX
33 //ASDBG #include <usr/uno.hxx>
34 //ASDBG #endif
35 //ASDBG #ifndef _USR_LSTCOMP_HXX
36 //ASDBG #include <usr/iterhlp.hxx>
37 //ASDBG #endif
38 //ASDBG #ifndef _USR_SERVICES_HXX
39 //ASDBG #include <usr/services.hxx>
40 //ASDBG #endif
41 #include <com/sun/star/chaos/XCommandExecutor.hpp>
42 #include <com/sun/star/chaos/XStatusCallback.hpp>
43 #include <com/sun/star/chaos/UnknownCommandException.hpp>
44 #include <com/sun/star/chaos/StatusCallbackEvent.hpp>
45 #include <com/sun/star/chaos/XURLContent.hpp>
46 #include <com/sun/star/chaos/XExplorerExchange.hpp>
47 #include <com/sun/star/beans/PropertyValues.hpp>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/beans/PropertyValue.hpp>
50 #include <com/sun/star/beans/PropertyState.hpp>
51 #include <com/sun/star/beans/XPropertySetInfo.hpp>
52 #include <com/sun/star/beans/XMultiPropertySet.hpp>
53 #include <com/sun/star/beans/XFastPropertySet.hpp>
54 #include <com/sun/star/beans/XVetoableChangeListener.hpp>
55 #include <com/sun/star/beans/XPropertyState.hpp>
56 #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
59 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
60 #include <com/sun/star/beans/XPropertyAccess.hpp>
61 #include <com/sun/star/beans/XPropertyContainer.hpp>
62 #include <com/sun/star/beans/PropertyStateChangeEvent.hpp>
63 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
64 #include <com/sun/star/lang/XServiceInfo.hpp>
65 #include <cppuhelper/weak.hxx>
66 #include <cppuhelper/interfacecontainer.hxx>
67 
68 class CntAnchor;
69 
70 class TplAnchorListener;
71 
72 // -----------------
73 // - TplComponent -
74 // -----------------
75 
76 class TplComponent : public ::com::sun::star::chaos::XURLContent, public ::com::sun::star::chaos::XCommandExecutor,
77 					 public ::com::sun::star::beans::XPropertySet, public ::com::sun::star::chaos::XExplorerExchange,
78 					 public ::cppu::OWeakObject, public ::com::sun::star::lang::XServiceInfo
79 {
80 private:
81 
82 	void						HandleNewEvt( const ::rtl::OUString& rCommand,
83 											  const ::com::sun::star::uno::Any& rAny );
84 	void						CreatePopupMenu( ::com::sun::star::uno::Any& rAny ) const;
85 
86 protected:
87 
88 	::rtl::OUString						maURL;
89 	::rtl::OUString						maName;
90     ::osl::Mutex         aMutex;
91     ::cppu::OInterfaceContainerHelper maListeners;
92 	TplAnchorListener*			mpListener;
93 	short						mnOpenMode;
94 
95 public:
96 
97 	SFX_DECL_XINTERFACE_XTYPEPROVIDER_XSERVICEINFO
98 
99 								TplComponent();
100 								~TplComponent();
101 
102 	// interface  ::com::sun::star::ucb::XContent
103 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SAL_CALL		getParent() throw ( ::com::sun::star::uno::RuntimeException )
104 			{ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  aRef; return aRef; }
105 	virtual void	    SAL_CALL				setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & Parent ) throw ( ::com::sun::star::uno::RuntimeException )
106 			{}
107 
108 	// interface  ::com::sun::star::chaos::XURLContent
109 	virtual ::rtl::OUString	  SAL_CALL				getURL()  throw ( ::com::sun::star::uno::RuntimeException )
110 			{ return maURL; }
111 	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 );
112 
113 	// interface  ::com::sun::star::chaos::XCommandExecutor
114 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  SAL_CALL	 queryCommands()  throw ( ::com::sun::star::uno::RuntimeException );
115 	virtual void	   SAL_CALL				cancel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rCommandId ) throw ( ::com::sun::star::uno::RuntimeException )
116 			{}
117 	virtual void	   SAL_CALL				execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Any& rArgs,
118 										 const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XStatusCallback > & rCallback ) throw ( ::com::sun::star::uno::RuntimeException );
119 
120 	// interface  ::com::sun::star::beans::XPropertySet
121 	virtual	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL	 getPropertySetInfo()  throw ( ::com::sun::star::uno::RuntimeException );
122     virtual void      SAL_CALL	           setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::uno::RuntimeException );
123 	virtual ::com::sun::star::uno::Any	 SAL_CALL				getPropertyValue( const ::rtl::OUString& aPropertyName )  throw ( ::com::sun::star::uno::RuntimeException );
124 	virtual void	  SAL_CALL				addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
125                                                            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
126 	virtual void	  SAL_CALL				removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
127                                                               const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
128 	virtual void	  SAL_CALL				addVetoableChangeListener( const ::rtl::OUString& aPropertyName,
129                                                            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
130 	virtual void	  SAL_CALL				removeVetoableChangeListener( const ::rtl::OUString& aPropertyName,
131                                                               const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener ) throw ( ::com::sun::star::uno::RuntimeException );
132 	// interface  ::com::sun::star::chaos::XExplorerExchange
133 	virtual ::com::sun::star::uno::Any	   SAL_CALL				createDataObject( sal_uInt16& nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
134 	virtual sal_uInt16	  SAL_CALL				insertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
135 												  sal_uInt16 nUserAction,
136 												  sal_uInt16 nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
137 	virtual sal_Bool	  SAL_CALL				queryInsertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
138 													   sal_uInt16 nUserAction,
139 													   sal_uInt16 nSourceOptions,
140 													   sal_uInt16& nResultingAction,
141 													   sal_uInt16& nDefaultAction ) throw ( ::com::sun::star::uno::RuntimeException );
142 
143 
144 	// -------------------------------------------------------------
145 
146 	void						CreateNewChild( CntAnchor* pAnchor,
147 												const String& rTitle );
148 	void						RemoveChild( CntAnchor* pAnchor );
149 	void						StopListening( CntAnchor* pAnchor );
150 	void						HandleOpenEvt();
151 };
152 
153 // ------------------------
154 // - TplContentsComponent -
155 // ------------------------
156 
157 class TplContentsListener;
158 
159 class TplContentsComponent : public TplComponent
160 {
161 private:
162 	::com::sun::star::uno::Reference< ::com::sun::star::chaos::XURLContent > 				_xParent;
163 	TplContentsListener*		_pListener;
164 	SvDataObjectRef				_xObject;
165 	sal_uInt16						_nLayout;
166 
167 	void						HandleOpenEvt( const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XStatusCallback > & rJob,
168 											   const ::com::sun::star::chaos::StatusCallbackEvent& rEvt );
169 	void						HandleNewEvt( const ::rtl::OUString& rCommand,
170 											  const ::com::sun::star::uno::Any& rAny );
171 	void						HandleInitEvt();
172 
173 	void						CreateFileName( String& rName,
174 												String& rDirURL );
175 	void						CreateNewTpl( const String& rFilter,
176 											  const String& rParentDir,
177 											  const String& rFileName,
178 											  const String& rDocName );
179 protected:
180 
181 	void						CreatePopupMenu( ::com::sun::star::uno::Any& rAny ) const;
182 
183 public:
184 
185 	SFX_DECL_XINTERFACE_XTYPEPROVIDER_XSERVICEINFO
186 
187 								TplContentsComponent();
188 								~TplContentsComponent();
189 
190 	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 );
191 
192 
193 	// interface  ::com::sun::star::chaos::XCommandExecutor
194 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  SAL_CALL	 queryCommands()  throw ( ::com::sun::star::uno::RuntimeException );
195 	virtual void		 SAL_CALL			execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Any& rArgs,
196 										 const ::com::sun::star::uno::Reference< ::com::sun::star::chaos::XStatusCallback > & rCallback ) throw ( ::com::sun::star::uno::RuntimeException );
197 
198 	// interface  ::com::sun::star::beans::XPropertySet
199 	virtual	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL	 getPropertySetInfo()  throw ( ::com::sun::star::uno::RuntimeException );
200 	virtual ::com::sun::star::uno::Any	  SAL_CALL				getPropertyValue( const ::rtl::OUString& aPropertyName )  throw ( ::com::sun::star::uno::RuntimeException );
201 	virtual void	   SAL_CALL				setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::uno::RuntimeException );
202 
203 	// interface  ::com::sun::star::chaos::XExplorerExchange
204 	virtual ::com::sun::star::uno::Any	    SAL_CALL				createDataObject( sal_uInt16& nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
205 	virtual sal_uInt16  SAL_CALL					insertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
206 												  sal_uInt16 nUserAction,
207 												  sal_uInt16 nSourceOptions ) throw ( ::com::sun::star::uno::RuntimeException );
208 	virtual sal_Bool    SAL_CALL					queryInsertDataObject( const ::com::sun::star::uno::Any& pSotDataObjectPtr,
209 													   sal_uInt16 nUserAction,
210 													   sal_uInt16 nSourceOptions,
211 													   sal_uInt16& nResultingAction,
212 													   sal_uInt16& nDefaultAction ) throw ( ::com::sun::star::uno::RuntimeException );
213 
214 	// -------------------------------------------------------------
215 
216 	void						CreateNewChild( CntAnchor* pAnchor );
217 	void						HandleDeleteEvt();
218 	void						SetURL( const ::rtl::OUString& rURL);
219 	void						SetName( const ::rtl::OUString& rNewName );
220 };
221 
222 
223 #endif
224 
225