LibreOffice Module shell (master) 1
cmdmailmsg.cxx
Go to the documentation of this file.
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
22using com::sun::star::container::NoSuchElementException;
23using com::sun::star::container::XNameAccess;
24
25using namespace cppu;
26using namespace com::sun::star::uno;
27
28
29void SAL_CALL CmdMailMsg::setBody( const OUString& aBody )
30{
31 std::scoped_lock aGuard( m_aMutex );
32 m_aBody = aBody;
33}
34
35OUString SAL_CALL CmdMailMsg::getBody( )
36{
37 std::scoped_lock aGuard( m_aMutex );
38 return m_aBody;
39}
40
41void SAL_CALL CmdMailMsg::setRecipient( const OUString& aRecipient )
42{
43 std::scoped_lock aGuard( m_aMutex );
44 m_aRecipient = aRecipient;
45}
46
47OUString SAL_CALL CmdMailMsg::getRecipient( )
48{
49 std::scoped_lock aGuard( m_aMutex );
50 return m_aRecipient;
51}
52
53void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient )
54{
55 std::scoped_lock aGuard( m_aMutex );
56 m_CcRecipients = aCcRecipient;
57}
58
60{
61 std::scoped_lock aGuard( m_aMutex );
62 return m_CcRecipients;
63}
64
65void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient )
66{
67 std::scoped_lock aGuard( m_aMutex );
68 m_BccRecipients = aBccRecipient;
69}
70
72{
73 std::scoped_lock aGuard( m_aMutex );
74 return m_BccRecipients;
75}
76
77void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator )
78{
79 std::scoped_lock aGuard( m_aMutex );
80 m_aOriginator = aOriginator;
81}
82
83OUString SAL_CALL CmdMailMsg::getOriginator( )
84{
85 std::scoped_lock aGuard( m_aMutex );
86 return m_aOriginator;
87}
88
89void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject )
90{
91 std::scoped_lock aGuard( m_aMutex );
92 m_aSubject = aSubject;
93}
94
95OUString SAL_CALL CmdMailMsg::getSubject( )
96{
97 std::scoped_lock aGuard( m_aMutex );
98 return m_aSubject;
99}
100
101void SAL_CALL CmdMailMsg::setAttachement( const Sequence< OUString >& aAttachment )
102{
103 std::scoped_lock aGuard( m_aMutex );
104 m_Attachments = aAttachment;
105}
106
108{
109 std::scoped_lock aGuard( m_aMutex );
110 return m_Attachments;
111}
112
113Any SAL_CALL CmdMailMsg::getByName( const OUString& aName )
114{
115 std::scoped_lock aGuard( m_aMutex );
116
117 if( aName == "body" && !m_aBody.isEmpty() )
118 return Any( m_aBody );
119
120 if( aName == "from" && !m_aOriginator.isEmpty() )
121 return Any( m_aOriginator );
122
123 else if( aName == "to" && !m_aRecipient.isEmpty() )
124 return Any( m_aRecipient );
125
126 else if( aName == "cc" && m_CcRecipients.hasElements() )
127 return Any( m_CcRecipients );
128
129 else if( aName == "bcc" && m_BccRecipients.hasElements() )
130 return Any( m_BccRecipients );
131
132 else if( aName == "subject" && !m_aSubject.isEmpty() )
133 return Any( m_aSubject );
134
135 else if( aName == "attachment" && m_Attachments.hasElements() )
136 return Any( m_Attachments );
137
138 throw NoSuchElementException("key not found: " + aName,
139 static_cast < XNameAccess * > (this) );
140}
141
143{
144 std::scoped_lock aGuard( m_aMutex );
145
146 sal_Int32 nItems = 0;
147 Sequence< OUString > aRet( 7 );
148 auto pRet = aRet.getArray();
149
150 if( !m_aBody.isEmpty() )
151 pRet[nItems++] = "body";
152
153 if( !m_aOriginator.isEmpty() )
154 pRet[nItems++] = "from";
155
156 if( !m_aRecipient.isEmpty() )
157 pRet[nItems++] = "to";
158
159 if( m_CcRecipients.hasElements() )
160 pRet[nItems++] = "cc";
161
162 if( m_BccRecipients.hasElements() )
163 pRet[nItems++] = "bcc";
164
165 if( !m_aSubject.isEmpty() )
166 pRet[nItems++] = "subject";
167
168 if( m_Attachments.hasElements() )
169 pRet[nItems++] = "attachment";
170
171 aRet.realloc( nItems );
172 return aRet;
173}
174
175 sal_Bool SAL_CALL CmdMailMsg::hasByName( const OUString& aName )
176{
177 std::scoped_lock aGuard( m_aMutex );
178
179 if( aName == "body" && !m_aBody.isEmpty() )
180 return true;
181
182 if( aName == "from" && !m_aOriginator.isEmpty() )
183 return true;
184
185 else if( aName == "to" && !m_aRecipient.isEmpty() )
186 return true;
187
188 else if( aName == "cc" && m_CcRecipients.hasElements() )
189 return true;
190
191 else if( aName == "bcc" && m_BccRecipients.hasElements() )
192 return true;
193
194 else if( aName == "subject" && !m_aSubject.isEmpty() )
195 return true;
196
197 else if( aName == "attachment" && m_Attachments.hasElements() )
198 return true;
199
200 return false;
201}
202
204{
205 // returning void for multi type container
206 return Type();
207}
208
210{
211 return getElementNames().hasElements();
212}
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< OUString > m_BccRecipients
Definition: cmdmailmsg.hxx:42
virtual void SAL_CALL setAttachement(const css::uno::Sequence< OUString > &aAttachement) override
Definition: cmdmailmsg.cxx:101
OUString m_aSubject
Definition: cmdmailmsg.hxx:40
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: cmdmailmsg.cxx:142
OUString m_aRecipient
Definition: cmdmailmsg.hxx:38
virtual css::uno::Sequence< OUString > SAL_CALL getAttachement() override
Definition: cmdmailmsg.cxx:107
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: cmdmailmsg.cxx:175
virtual OUString SAL_CALL getRecipient() override
Definition: cmdmailmsg.cxx:47
virtual void SAL_CALL setRecipient(const OUString &aRecipient) override
Definition: cmdmailmsg.cxx:41
virtual OUString SAL_CALL getBody() override
Definition: cmdmailmsg.cxx:35
OUString m_aBody
Definition: cmdmailmsg.hxx:37
OUString m_aOriginator
Definition: cmdmailmsg.hxx:39
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: cmdmailmsg.cxx:113
virtual sal_Bool SAL_CALL hasElements() override
Definition: cmdmailmsg.cxx:209
virtual void SAL_CALL setOriginator(const OUString &aOriginator) override
Definition: cmdmailmsg.cxx:77
virtual OUString SAL_CALL getSubject() override
Definition: cmdmailmsg.cxx:95
virtual void SAL_CALL setBody(const OUString &aBody) override
Definition: cmdmailmsg.cxx:29
virtual css::uno::Sequence< OUString > SAL_CALL getCcRecipient() override
Definition: cmdmailmsg.cxx:59
std::mutex m_aMutex
Definition: cmdmailmsg.hxx:45
css::uno::Sequence< OUString > m_Attachments
Definition: cmdmailmsg.hxx:43
virtual css::uno::Sequence< OUString > SAL_CALL getBccRecipient() override
Definition: cmdmailmsg.cxx:71
virtual void SAL_CALL setBccRecipient(const css::uno::Sequence< OUString > &aBccRecipient) override
Definition: cmdmailmsg.cxx:65
virtual css::uno::Type SAL_CALL getElementType() override
Definition: cmdmailmsg.cxx:203
virtual void SAL_CALL setSubject(const OUString &aSubject) override
Definition: cmdmailmsg.cxx:89
virtual OUString SAL_CALL getOriginator() override
Definition: cmdmailmsg.cxx:83
virtual void SAL_CALL setCcRecipient(const css::uno::Sequence< OUString > &aCcRecipient) override
Definition: cmdmailmsg.cxx:53
css::uno::Sequence< OUString > m_CcRecipients
Definition: cmdmailmsg.hxx:41
OUString aName
Type
unsigned char sal_Bool