xref: /aoo42x/main/sw/inc/unomailmerge.hxx (revision 1d2dbeb0)
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 _UNOMAILMERGE_HXX_
25 #define _UNOMAILMERGE_HXX_
26 
27 #include <functional>
28 #include <cppuhelper/implbase5.hxx> // WeakImplHelper4
29 #include <cppuhelper/interfacecontainer.hxx>    // OMultiTypeInterfaceContainerHelperVar
30 #include <unotools/configitem.hxx>  // !! needed for OMultiTypeInterfaceContainerHelperVar !!
31 
32 
33 #include <com/sun/star/task/XJob.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/lang/XComponent.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
38 #include <com/sun/star/text/XMailMergeBroadcaster.hpp>
39 #include <svl/itemprop.hxx>
40 #include <sfx2/objsh.hxx>
41 
42 #include <functional>
43 
44 namespace com { namespace sun { namespace star {
45 
46     namespace sdbc {
47         class XResultSet;
48         class XConnection;
49     }
50     namespace frame {
51         class XModel;
52     }
53     namespace lang {
54         class XMultiServiceFactory;
55     }
56     namespace text {
57         class XMailMergeListener;
58         struct MailMergeEvent;
59     }
60     namespace beans{
61         struct PropertyValue;
62     }
63 
64 }}}
65 
66 namespace rtl {
67     class OUString;
68 }
69 
70 ///////////////////////////////////////////////////////////////////////////
71 
72 // uses templates from <cppuhelper/interfacecontainer.h>
73 // and <unotools/configitem.hxx>
74 
75 // helper function call class
76 struct PropHashType_Impl
77 {
operator ()PropHashType_Impl78     size_t operator()(const sal_Int32 &s) const { return s; }
79 };
80 
81 typedef cppu::OMultiTypeInterfaceContainerHelperVar
82     <
83         sal_Int32,
84         PropHashType_Impl,
85         std::equal_to< sal_Int32 >
86     > OPropertyListenerContainerHelper;
87 
88 ////////////////////////////////////////////////////////////
89 
90 class SwXMailMerge :
91     public cppu::WeakImplHelper5
92     <
93         com::sun::star::task::XJob,
94         com::sun::star::beans::XPropertySet,
95         com::sun::star::text::XMailMergeBroadcaster,
96         com::sun::star::lang::XComponent,
97         com::sun::star::lang::XServiceInfo
98     >
99 {
100     cppu::OInterfaceContainerHelper     aEvtListeners;
101     cppu::OInterfaceContainerHelper     aMergeListeners;
102     OPropertyListenerContainerHelper    aPropListeners;
103 
104     //SfxItemPropertySet          aPropSet;
105     const SfxItemPropertySet*   pPropSet;
106 
107     SfxObjectShellRef xDocSh;   // the document
108 
109     String          aTmpFileName;
110 
111     // properties of mail merge service
112     com::sun::star::uno::Sequence< com::sun::star::uno::Any >           aSelection;
113     com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >  xResultSet;
114     com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > xConnection;
115     com::sun::star::uno::Reference< com::sun::star::frame::XModel >     xModel;
116     rtl::OUString   aDataSourceName;
117     rtl::OUString   aDataCommand;
118     rtl::OUString   aFilter;
119     rtl::OUString   aDocumentURL;
120     rtl::OUString   aOutputURL;
121     rtl::OUString   aFileNamePrefix;
122     sal_Int32       nDataCommandType;
123     sal_Int16       nOutputType;
124     sal_Bool        bEscapeProcessing;
125     sal_Bool        bSinglePrintJobs;
126     sal_Bool        bFileNameFromColumn;
127 
128 
129     ::rtl::OUString                                         sInServerPassword;
130     ::rtl::OUString                                         sOutServerPassword;
131     ::rtl::OUString                                         sSubject;
132     ::rtl::OUString                                         sAddressFromColumn;
133     ::rtl::OUString                                         sMailBody;
134     ::rtl::OUString                                         sAttachmentName;
135     ::rtl::OUString                                         sAttachmentFilter;
136     com::sun::star::uno::Sequence< ::rtl::OUString >        aCopiesTo;
137     com::sun::star::uno::Sequence< ::rtl::OUString >        aBlindCopiesTo;
138     sal_Bool                                                bSendAsHTML;
139     sal_Bool                                                bSendAsAttachment;
140 
141     com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aPrintSettings;
142 
143     sal_Bool                                                bSaveAsSingleFile;
144     ::rtl::OUString                                         sSaveFilter;
145     ::rtl::OUString                                         sSaveFilterOptions;
146     com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSaveFilterData;
147 
148 
149 
150     sal_Bool        bDisposing;
151 
152 
153     void    launchEvent( const com::sun::star::beans::PropertyChangeEvent &rEvt ) const;
154 
155     // disallow use of copy-constructor and assignment-operator for now
156     SwXMailMerge( const SwXMailMerge & );
157     SwXMailMerge & operator = ( const SwXMailMerge & );
158 protected:
159 	virtual ~SwXMailMerge();
160 public:
161     SwXMailMerge();
162 
163 
164     void LaunchMailMergeEvent( const com::sun::star::text::MailMergeEvent &rData ) const;
165 
166     // XJob
167     virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
168 
169     // XPropertySet
170     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
171     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
172     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
173     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
174     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
175     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
176     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
177 
178     // XMailMergeBroadcaster
179     virtual void SAL_CALL addMailMergeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XMailMergeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
180     virtual void SAL_CALL removeMailMergeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XMailMergeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
181 
182     // XComponent
183     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
184     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
185     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
186 
187     // XServiceInfo
188     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
189     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
190     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
191 };
192 
193 
194 extern com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
195 extern rtl::OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
196 extern com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( com::sun::star::uno::Exception );
197 
198 ////////////////////////////////////////////////////////////
199 
200 #endif
201 
202 
203