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