Debian Codegraph @

shell/source/cmdmail/cmdmailmsg.cxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include "cmdmailmsg.hxx"
21
22 using com::sun::star::container::NoSuchElementException;
23 using com::sun::star::container::XNameAccess;
24
25 using namespace com::sun::star::uno;
26
27
28 void SAL_CALL CmdMailMsg::setBody( const OUString& aBody )
29 {
30 std::scoped_lock aGuard( m_aMutex );
31 m_aBody = aBody;
32 }
33
34 OUString SAL_CALL CmdMailMsg::getBody( )
35 {
36 std::scoped_lock aGuard( m_aMutex );
37 return m_aBody;
38 }
39
40 void SAL_CALL CmdMailMsg::setRecipient( const OUString& aRecipient )
41 {
42 std::scoped_lock aGuard( m_aMutex );
43 m_aRecipient = aRecipient;
44 }
45
46 OUString SAL_CALL CmdMailMsg::getRecipient( )
47 {
48 std::scoped_lock aGuard( m_aMutex );
49 return m_aRecipient;
50 }
51
52 void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient )
53 {
54 std::scoped_lock aGuard( m_aMutex );
55 m_CcRecipients = aCcRecipient;
56 }
57
58 Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient( )
59 {
60 std::scoped_lock aGuard( m_aMutex );
61 return m_CcRecipients;
62 }
63
64 void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient )
65 {
66 std::scoped_lock aGuard( m_aMutex );
67 m_BccRecipients = aBccRecipient;
68 }
69
70 Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient( )
71 {
72 std::scoped_lock aGuard( m_aMutex );
73 return m_BccRecipients;
74 }
75
76 void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator )
77 {
78 std::scoped_lock aGuard( m_aMutex );
79 m_aOriginator = aOriginator;
80 }
81
82 OUString SAL_CALL CmdMailMsg::getOriginator( )
83 {
84 std::scoped_lock aGuard( m_aMutex );
85 return m_aOriginator;
86 }
87
88 void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject )
89 {
90 std::scoped_lock aGuard( m_aMutex );
91 m_aSubject = aSubject;
92 }
93
94 OUString SAL_CALL CmdMailMsg::getSubject( )
95 {
96 std::scoped_lock aGuard( m_aMutex );
97 return m_aSubject;
98 }
99
100 void SAL_CALL CmdMailMsg::setAttachement( const Sequence< OUString >& aAttachment )
101 {
102 std::scoped_lock aGuard( m_aMutex );
103 m_Attachments = aAttachment;
104 }
105
106 Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( )
107 {
108 std::scoped_lock aGuard( m_aMutex );
109 return m_Attachments;
110 }
111
112 Any SAL_CALL CmdMailMsg::getByName( const OUString& aName )
113 {
114 std::scoped_lock aGuard( m_aMutex );
115
116 if( aName == "body" && !m_aBody.isEmpty() )
117 return Any( m_aBody );
118
119 if( aName == "from" && !m_aOriginator.isEmpty() )
120 return Any( m_aOriginator );
121
122 else if( aName == "to" && !m_aRecipient.isEmpty() )
123 return Any( m_aRecipient );
124
125 else if( aName == "cc" && m_CcRecipients.hasElements() )
126 return Any( m_CcRecipients );
127
128 else if( aName == "bcc" && m_BccRecipients.hasElements() )
129 return Any( m_BccRecipients );
130
131 else if( aName == "subject" && !m_aSubject.isEmpty() )
132 return Any( m_aSubject );
133
134 else if( aName == "attachment" && m_Attachments.hasElements() )
135 return Any( m_Attachments );
136
137 throw NoSuchElementException("key not found: " + aName,
138 static_cast < XNameAccess * > (this) );
139 }
140
141 Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( )
142 {
143 std::scoped_lock aGuard( m_aMutex );
144
145 sal_Int32 nItems = 0;
146 Sequence< OUString > aRet( 7 );
147 auto pRet = aRet.getArray();
148
149 if( !m_aBody.isEmpty() )
150 pRet[nItems++] = "body";
151
152 if( !m_aOriginator.isEmpty() )
153 pRet[nItems++] = "from";
154
155 if( !m_aRecipient.isEmpty() )
156 pRet[nItems++] = "to";
157
158 if( m_CcRecipients.hasElements() )
159 pRet[nItems++] = "cc";
160
161 if( m_BccRecipients.hasElements() )
162 pRet[nItems++] = "bcc";
163
164 if( !m_aSubject.isEmpty() )
165 pRet[nItems++] = "subject";
166
167 if( m_Attachments.hasElements() )
168 pRet[nItems++] = "attachment";
169
170 aRet.realloc( nItems );
171 return aRet;
172 }
173
174 sal_Bool SAL_CALL CmdMailMsg::hasByName( const OUString& aName )
175 {
176 std::scoped_lock aGuard( m_aMutex );
177
178 if( aName == "body" && !m_aBody.isEmpty() )
179 return true;
180
181 if( aName == "from" && !m_aOriginator.isEmpty() )
182 return true;
183
184 else if( aName == "to" && !m_aRecipient.isEmpty() )
185 return true;
186
187 else if( aName == "cc" && m_CcRecipients.hasElements() )
188 return true;
189
190 else if( aName == "bcc" && m_BccRecipients.hasElements() )
191 return true;
192
193 else if( aName == "subject" && !m_aSubject.isEmpty() )
194 return true;
195
196 else if( aName == "attachment" && m_Attachments.hasElements() )
197 return true;
198
199 return false;
200 }
201
202 Type SAL_CALL CmdMailMsg::getElementType( )
203 {
204 // returning void for multi type container
205 return Type();
206 }
207
208 sal_Bool SAL_CALL CmdMailMsg::hasElements( )
209 {
210 return getElementNames().hasElements();
211 }
212
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */