fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / shell / source / cmdmail / cmdmailmsg.cxx
blob287a73513450c48d3424421f2608b076fde558be
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "cmdmailmsg.hxx"
22 using com::sun::star::lang::IllegalArgumentException;
23 using com::sun::star::lang::WrappedTargetException;
24 using com::sun::star::container::NoSuchElementException;
25 using com::sun::star::container::XNameAccess;
26 using osl::MutexGuard;
28 using namespace cppu;
29 using namespace com::sun::star::uno;
32 void SAL_CALL CmdMailMsg::setBody( const OUString& aBody )
33 throw (RuntimeException, std::exception)
35 MutexGuard aGuard( m_aMutex );
36 m_aBody = aBody;
39 OUString SAL_CALL CmdMailMsg::getBody( )
40 throw (RuntimeException, std::exception)
42 MutexGuard aGuard( m_aMutex );
43 return m_aBody;
46 void SAL_CALL CmdMailMsg::setRecipient( const OUString& aRecipient )
47 throw (RuntimeException, std::exception)
49 MutexGuard aGuard( m_aMutex );
50 m_aRecipient = aRecipient;
53 OUString SAL_CALL CmdMailMsg::getRecipient( )
54 throw (RuntimeException, std::exception)
56 MutexGuard aGuard( m_aMutex );
57 return m_aRecipient;
60 void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient )
61 throw (RuntimeException, std::exception)
63 MutexGuard aGuard( m_aMutex );
64 m_CcRecipients = aCcRecipient;
67 Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient( )
68 throw (RuntimeException, std::exception)
70 MutexGuard aGuard( m_aMutex );
71 return m_CcRecipients;
74 void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient )
75 throw (RuntimeException, std::exception)
77 MutexGuard aGuard( m_aMutex );
78 m_BccRecipients = aBccRecipient;
81 Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient( )
82 throw (RuntimeException, std::exception)
84 MutexGuard aGuard( m_aMutex );
85 return m_BccRecipients;
88 void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator )
89 throw (RuntimeException, std::exception)
91 MutexGuard aGuard( m_aMutex );
92 m_aOriginator = aOriginator;
95 OUString SAL_CALL CmdMailMsg::getOriginator( )
96 throw (RuntimeException, std::exception)
98 MutexGuard aGuard( m_aMutex );
99 return m_aOriginator;
102 void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject )
103 throw (RuntimeException, std::exception)
105 MutexGuard aGuard( m_aMutex );
106 m_aSubject = aSubject;
109 OUString SAL_CALL CmdMailMsg::getSubject( )
110 throw (RuntimeException, std::exception)
112 MutexGuard aGuard( m_aMutex );
113 return m_aSubject;
116 void SAL_CALL CmdMailMsg::setAttachement( const Sequence< OUString >& aAttachment )
117 throw (IllegalArgumentException, RuntimeException, std::exception)
119 MutexGuard aGuard( m_aMutex );
120 m_Attachments = aAttachment;
123 Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( )
124 throw (RuntimeException, std::exception)
126 MutexGuard aGuard( m_aMutex );
127 return m_Attachments;
130 Any SAL_CALL CmdMailMsg::getByName( const OUString& aName )
131 throw (NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
133 MutexGuard aGuard( m_aMutex );
135 if( aName == "body" && !m_aBody.isEmpty() )
136 return makeAny( m_aBody );
138 if( aName == "from" && !m_aOriginator.isEmpty() )
139 return makeAny( m_aOriginator );
141 else if( aName == "to" && !m_aRecipient.isEmpty() )
142 return makeAny( m_aRecipient );
144 else if( aName == "cc" && m_CcRecipients.getLength() )
145 return makeAny( m_CcRecipients );
147 else if( aName == "bcc" && m_BccRecipients.getLength() )
148 return makeAny( m_BccRecipients );
150 else if( aName == "subject" && !m_aSubject.isEmpty() )
151 return makeAny( m_aSubject );
153 else if( aName == "attachment" && m_Attachments.getLength() )
154 return makeAny( m_Attachments );
156 throw NoSuchElementException("key not found: " + aName,
157 static_cast < XNameAccess * > (this) );
160 Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( )
161 throw (::com::sun::star::uno::RuntimeException, std::exception)
163 MutexGuard aGuard( m_aMutex );
165 sal_Int32 nItems = 0;
166 Sequence< OUString > aRet( 7 );
168 if( !m_aBody.isEmpty() )
169 aRet[nItems++] = "body";
171 if( !m_aOriginator.isEmpty() )
172 aRet[nItems++] = "from";
174 if( !m_aRecipient.isEmpty() )
175 aRet[nItems++] = "to";
177 if( m_CcRecipients.getLength() )
178 aRet[nItems++] = "cc";
180 if( m_BccRecipients.getLength() )
181 aRet[nItems++] = "bcc";
183 if( !m_aSubject.isEmpty() )
184 aRet[nItems++] = "subject";
186 if( m_Attachments.getLength() )
187 aRet[nItems++] = "attachment";
189 aRet.realloc( nItems );
190 return aRet;
193 sal_Bool SAL_CALL CmdMailMsg::hasByName( const OUString& aName )
194 throw (RuntimeException, std::exception)
196 MutexGuard aGuard( m_aMutex );
198 if( aName == "body" && !m_aBody.isEmpty() )
199 return sal_True;
201 if( aName == "from" && !m_aOriginator.isEmpty() )
202 return sal_True;
204 else if( aName == "to" && !m_aRecipient.isEmpty() )
205 return sal_True;
207 else if( aName == "cc" && m_CcRecipients.getLength() )
208 return sal_True;
210 else if( aName == "bcc" && m_BccRecipients.getLength() )
211 return sal_True;
213 else if( aName == "subject" && !m_aSubject.isEmpty() )
214 return sal_True;
216 else if( aName == "attachment" && m_Attachments.getLength() )
217 return sal_True;
219 return sal_False;
222 Type SAL_CALL CmdMailMsg::getElementType( )
223 throw (RuntimeException, std::exception)
225 // returning void for multi type container
226 return Type();
229 sal_Bool SAL_CALL CmdMailMsg::hasElements( )
230 throw (RuntimeException, std::exception)
232 return 0 != getElementNames().getLength();
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */