LCOV - code coverage report
Current view: top level - libreoffice/shell/source/cmdmail - cmdmailmsg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 95 0.0 %
Date: 2012-12-27 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <osl/diagnose.h>
      21             : #include "cmdmailmsg.hxx"
      22             : #include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
      23             : #include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
      24             : #include <com/sun/star/uno/Reference.hxx>
      25             : #include <com/sun/star/uno/RuntimeException.hpp>
      26             : 
      27             : //------------------------------------------------------------------------
      28             : // namespace directives
      29             : //------------------------------------------------------------------------
      30             : 
      31             : using com::sun::star::lang::IllegalArgumentException;
      32             : using com::sun::star::lang::WrappedTargetException;
      33             : using com::sun::star::container::NoSuchElementException;
      34             : using com::sun::star::container::XNameAccess;
      35             : using rtl::OUString;
      36             : using osl::MutexGuard;
      37             : 
      38             : using namespace cppu;
      39             : using namespace com::sun::star::uno;
      40             : 
      41             : 
      42             : //------------------------------------------------
      43             : 
      44           0 : void SAL_CALL CmdMailMsg::setRecipient( const ::rtl::OUString& aRecipient )
      45             :     throw (RuntimeException)
      46             : {
      47           0 :     MutexGuard aGuard( m_aMutex );
      48           0 :     m_aRecipient = aRecipient;
      49           0 : }
      50             : 
      51             : //------------------------------------------------
      52             : 
      53           0 : ::rtl::OUString SAL_CALL CmdMailMsg::getRecipient(  )
      54             :     throw (RuntimeException)
      55             : {
      56           0 :     MutexGuard aGuard( m_aMutex );
      57           0 :     return m_aRecipient;
      58             : }
      59             : 
      60             : //------------------------------------------------
      61             : 
      62           0 : void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient )
      63             :     throw (RuntimeException)
      64             : {
      65           0 :     MutexGuard aGuard( m_aMutex );
      66           0 :     m_CcRecipients = aCcRecipient;
      67           0 : }
      68             : 
      69             : //------------------------------------------------
      70             : 
      71           0 : Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient(  )
      72             :     throw (RuntimeException)
      73             : {
      74           0 :     MutexGuard aGuard( m_aMutex );
      75           0 :     return m_CcRecipients;
      76             : }
      77             : 
      78             : //------------------------------------------------
      79             : 
      80           0 : void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient )
      81             :     throw (RuntimeException)
      82             : {
      83           0 :     MutexGuard aGuard( m_aMutex );
      84           0 :     m_BccRecipients = aBccRecipient;
      85           0 : }
      86             : 
      87             : //------------------------------------------------
      88             : 
      89           0 : Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient(  )
      90             :     throw (RuntimeException)
      91             : {
      92           0 :     MutexGuard aGuard( m_aMutex );
      93           0 :     return m_BccRecipients;
      94             : }
      95             : 
      96             : //------------------------------------------------
      97             : 
      98           0 : void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator )
      99             :     throw (RuntimeException)
     100             : {
     101           0 :     MutexGuard aGuard( m_aMutex );
     102           0 :     m_aOriginator = aOriginator;
     103           0 : }
     104             : 
     105             : //------------------------------------------------
     106             : 
     107           0 : OUString SAL_CALL CmdMailMsg::getOriginator(  )
     108             :     throw (RuntimeException)
     109             : {
     110           0 :     MutexGuard aGuard( m_aMutex );
     111           0 :     return m_aOriginator;
     112             : }
     113             : 
     114             : //------------------------------------------------
     115             : 
     116           0 : void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject )
     117             :     throw (RuntimeException)
     118             : {
     119           0 :     MutexGuard aGuard( m_aMutex );
     120           0 :     m_aSubject = aSubject;
     121           0 : }
     122             : 
     123             : //------------------------------------------------
     124             : 
     125           0 : OUString SAL_CALL CmdMailMsg::getSubject(  )
     126             :     throw (RuntimeException)
     127             : {
     128           0 :     MutexGuard aGuard( m_aMutex );
     129           0 :     return m_aSubject;
     130             : }
     131             : 
     132             : //------------------------------------------------
     133             : 
     134           0 : void SAL_CALL CmdMailMsg::setAttachement( const Sequence< ::rtl::OUString >& aAttachment )
     135             :     throw (IllegalArgumentException, RuntimeException)
     136             : {
     137           0 :     MutexGuard aGuard( m_aMutex );
     138           0 :     m_Attachments = aAttachment;
     139           0 : }
     140             : 
     141             : //------------------------------------------------
     142             : 
     143           0 : Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement(  )
     144             :     throw (RuntimeException)
     145             : {
     146           0 :     MutexGuard aGuard( m_aMutex );
     147           0 :     return m_Attachments;
     148             : }
     149             : 
     150             : //------------------------------------------------
     151             : 
     152           0 : Any SAL_CALL CmdMailMsg::getByName( const OUString& aName )
     153             :     throw (NoSuchElementException, WrappedTargetException, RuntimeException)
     154             : {
     155           0 :     MutexGuard aGuard( m_aMutex );
     156             : 
     157           0 :     if( 0 == aName.compareToAscii( "from" ) &&  !m_aOriginator.isEmpty() )
     158           0 :         return makeAny( m_aOriginator );
     159             : 
     160           0 :     else if( 0 == aName.compareToAscii( "to" ) &&  !m_aRecipient.isEmpty() )
     161           0 :         return makeAny( m_aRecipient );
     162             : 
     163           0 :     else if( 0 == aName.compareToAscii( "cc" ) &&  m_CcRecipients.getLength() )
     164           0 :         return makeAny( m_CcRecipients );
     165             : 
     166           0 :     else if( 0 == aName.compareToAscii( "bcc" ) &&  m_BccRecipients.getLength() )
     167           0 :         return makeAny( m_BccRecipients );
     168             : 
     169           0 :     else if( 0 == aName.compareToAscii( "subject" ) &&  !m_aSubject.isEmpty() )
     170           0 :         return makeAny( m_aSubject );
     171             : 
     172           0 :     else if( 0 == aName.compareToAscii( "attachment" ) &&  m_Attachments.getLength() )
     173           0 :         return makeAny( m_Attachments );
     174             : 
     175           0 :    throw NoSuchElementException( OUString("key not found: ") + aName,
     176           0 :         static_cast < XNameAccess * > (this) );
     177             : }
     178             : 
     179             : //------------------------------------------------
     180             : 
     181           0 : Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames(  )
     182             :     throw (::com::sun::star::uno::RuntimeException)
     183             : {
     184           0 :     MutexGuard aGuard( m_aMutex );
     185             : 
     186           0 :     sal_Int32 nItems = 0;
     187           0 :     Sequence< OUString > aRet( 6 );
     188             : 
     189           0 :     if( !m_aOriginator.isEmpty() )
     190           0 :         aRet[nItems++] = OUString("from");
     191             : 
     192           0 :     if( !m_aRecipient.isEmpty() )
     193           0 :         aRet[nItems++] = OUString("to");
     194             : 
     195           0 :     if( m_CcRecipients.getLength() )
     196           0 :         aRet[nItems++] = OUString("cc");
     197             : 
     198           0 :     if( m_BccRecipients.getLength() )
     199           0 :         aRet[nItems++] = OUString("bcc");
     200             : 
     201           0 :     if( !m_aSubject.isEmpty() )
     202           0 :         aRet[nItems++] = OUString("subject");
     203             : 
     204           0 :     if( m_Attachments.getLength() )
     205           0 :         aRet[nItems++] = OUString("attachment");
     206             : 
     207           0 :     aRet.realloc( nItems );
     208           0 :     return aRet;
     209             : }
     210             : 
     211             : //------------------------------------------------
     212             : 
     213           0 :  sal_Bool SAL_CALL CmdMailMsg::hasByName( const ::rtl::OUString& aName )
     214             :     throw (RuntimeException)
     215             : {
     216           0 :     MutexGuard aGuard( m_aMutex );
     217             : 
     218           0 :     if( 0 == aName.compareToAscii( "from" ) &&  !m_aOriginator.isEmpty() )
     219           0 :         return sal_True;
     220             : 
     221           0 :     else if( 0 == aName.compareToAscii( "to" ) &&  !m_aRecipient.isEmpty() )
     222           0 :         return sal_True;
     223             : 
     224           0 :     else if( 0 == aName.compareToAscii( "cc" ) &&  m_CcRecipients.getLength() )
     225           0 :         return sal_True;
     226             : 
     227           0 :     else if( 0 == aName.compareToAscii( "bcc" ) &&  m_BccRecipients.getLength() )
     228           0 :         return sal_True;
     229             : 
     230           0 :     else if( 0 == aName.compareToAscii( "subject" ) &&  !m_aSubject.isEmpty() )
     231           0 :         return sal_True;
     232             : 
     233           0 :     else if( 0 == aName.compareToAscii( "attachment" ) &&  m_Attachments.getLength() )
     234           0 :         return sal_True;
     235             : 
     236           0 :     return sal_False;
     237             : }
     238             : 
     239             : //------------------------------------------------
     240             : 
     241           0 : Type SAL_CALL CmdMailMsg::getElementType(  )
     242             :     throw (RuntimeException)
     243             : {
     244             :     // returning void for multi type container
     245           0 :     return Type();
     246             : }
     247             : 
     248             : //------------------------------------------------
     249             : 
     250           0 : sal_Bool SAL_CALL CmdMailMsg::hasElements(  )
     251             :     throw (RuntimeException)
     252             : {
     253           0 :     return 0 != getElementNames().getLength();
     254             : }
     255             : 
     256             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10