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