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