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