xref: /aoo4110/main/sfx2/inc/sfx2/mailmodelapi.hxx (revision b1cdbd2c)
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 #ifndef INCLUDED_SFX_MAILMODEL_HXX
24 #define INCLUDED_SFX_MAILMODEL_HXX
25 
26 #include <vector>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/frame/XModel.hpp>
29 #include "tools/link.hxx"
30 #include <tools/string.hxx>
31 #include "sfx2/dllapi.h"
32 
33 // class SfxMailModel_Impl -----------------------------------------------
34 
35 class AddressList_Impl;
36 
37 class SFX2_DLLPUBLIC SfxMailModel
38 {
39 public:
40 	enum MailPriority
41 	{
42 		PRIO_HIGHEST,
43 		PRIO_HIGH,
44 		PRIO_NORMAL,
45 		PRIO_LOW,
46 		PRIO_LOWEST
47 	};
48 
49 	enum AddressRole
50 	{
51 		ROLE_TO,
52 		ROLE_CC,
53 		ROLE_BCC
54 	};
55 
56 	enum MailDocType
57 	{
58 		TYPE_SELF,
59 		TYPE_ASPDF
60 	};
61 
62 private:
63 	enum SaveResult
64 	{
65 		SAVE_SUCCESSFULL,
66 		SAVE_CANCELLED,
67 		SAVE_ERROR
68 	};
69 
70 	::std::vector< ::rtl::OUString > maAttachedDocuments;
71     AddressList_Impl*	mpToList;
72 	AddressList_Impl*	mpCcList;
73 	AddressList_Impl*	mpBccList;
74 	String				maFromAddress;
75 	String				maSubject;
76 	MailPriority		mePriority;
77 
78 	sal_Bool			mbLoadDone;
79 
80 	void				ClearList( AddressList_Impl* pList );
81 	void				MakeValueList( AddressList_Impl* pList, String& rValueList );
82     SaveResult			SaveDocumentAsFormat( const rtl::OUString& aSaveFileName,
83                                               const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xFrameOrModel,
84                                               const rtl::OUString& rType,
85                                               rtl::OUString& rFileNamePath );
86     SaveResult          ShowFilterOptionsDialog( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMGR,
87                                                  const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel,
88                                                  const ::rtl::OUString& rFilterName,
89                                                  const ::rtl::OUString& rType,
90                                                  bool bModified,
91                                                  sal_Int32& rNumArgs,
92                                                  ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
93 
94 	DECL_LINK( DoneHdl, void* );
95 
96 public:
97 	enum SendMailResult
98 	{
99 		SEND_MAIL_OK,
100 		SEND_MAIL_CANCELLED,
101 		SEND_MAIL_ERROR
102 	};
103 
104 	SfxMailModel();
105 	~SfxMailModel();
106 
107 	void				AddAddress( const String& rAddress, AddressRole eRole );
SetFromAddress(const String & rAddress)108 	void				SetFromAddress( const String& rAddress )	{ maFromAddress = rAddress; }
SetSubject(const String & rSubject)109 	void				SetSubject( const String& rSubject )		{ maSubject = rSubject; }
SetPriority(MailPriority ePrio)110 	void				SetPriority( MailPriority ePrio )			{ mePriority = ePrio; }
111 
112     /** attaches a document to the current attachment list, can be called more than once.
113 	*   at the moment there will be a dialog for export executed for every model which is going to be attached.
114 	*
115 	* \param sDocumentType
116 		The doc type to export. PDF will be at the moment only a direct export (no dialog).
117 	* \param xModel
118 		The current model to attach
119 	* \param sAttachmentTitle
120 		The title which will be used as attachment title
121 	* \return @see error code
122 	*/
123     SendMailResult      AttachDocument( const ::rtl::OUString& sDocumentType,
124                                         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xFrameOrModel,
125                                         const ::rtl::OUString& sAttachmentTitle );
126 
127     SendMailResult		SaveAndSend( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
128                                      const rtl::OUString& rType );
129     SendMailResult      Send( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame );
130 
131 	sal_Int32			GetCount() const;
132 	sal_Bool			IsEmpty() const;
133 };
134 
135 sal_Bool CreateFromAddress_Impl( String& rFrom );
136 
137 #endif // INCLUDED_SFX_MAILMODEL_HXX
138