LCOV - code coverage report
Current view: top level - xmloff/source/forms - eventexport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 51 0.0 %
Date: 2014-11-03 Functions: 0 7 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 "eventexport.hxx"
      21             : #include <osl/diagnose.h>
      22             : #include "strings.hxx"
      23             : #include <tools/debug.hxx>
      24             : 
      25             : namespace xmloff
      26             : {
      27             : 
      28             :     using namespace ::com::sun::star::uno;
      29             :     using namespace ::com::sun::star::script;
      30             :     using namespace ::com::sun::star::container;
      31             :     using namespace ::com::sun::star::beans;
      32             :     using namespace ::com::sun::star::lang;
      33             : 
      34             :     //= OEventDescriptorMapper
      35           0 :     OEventDescriptorMapper::OEventDescriptorMapper(const Sequence< ScriptEventDescriptor >& _rEvents)
      36             :     {
      37           0 :         sal_Int32 nEvents = _rEvents.getLength();
      38             : 
      39             :         // translate the events
      40           0 :         const ScriptEventDescriptor* pEvents = _rEvents.getConstArray();
      41           0 :         OUString sName;
      42           0 :         OUString sLibrary, sLocalMacroName;
      43           0 :         for (sal_Int32 i=0; i<nEvents; ++i, ++pEvents)
      44             :         {
      45             :             // the name of the event is build from listener interface and listener method name
      46           0 :             sName = pEvents->ListenerType;
      47           0 :             sName += EVENT_NAME_SEPARATOR;
      48           0 :             sName += pEvents->EventMethod;
      49             : 
      50           0 :             Sequence< PropertyValue >& rMappedEvent = m_aMappedEvents[sName];
      51             : 
      52           0 :             sLocalMacroName = pEvents->ScriptCode;
      53           0 :             sLibrary = "";
      54           0 :             if (pEvents->ScriptType.equals(EVENT_STARBASIC))
      55             :             {   // for StarBasic, the library name is part of the ScriptCode
      56           0 :                 sal_Int32 nPrefixLen = sLocalMacroName.indexOf( ':' );
      57             :                 DBG_ASSERT( 0 <= nPrefixLen, "OEventDescriptorMapper::OEventDescriptorMapper: invalid script code prefix!" );
      58           0 :                 if ( 0 <= nPrefixLen )
      59             :                 {
      60             :                     // the export handler for StarBasic expects "StarOffice", not "application" for application modules ...
      61           0 :                     sLibrary = sLocalMacroName.copy( 0, nPrefixLen );
      62           0 :                     if (sLibrary.equals(EVENT_APPLICATION))
      63           0 :                         sLibrary = EVENT_STAROFFICE;
      64             : 
      65           0 :                     sLocalMacroName = sLocalMacroName.copy( nPrefixLen + 1 );
      66             :                 }
      67             :                 // tree property values to describe one event ...
      68           0 :                 rMappedEvent.realloc( sLibrary.isEmpty() ? 2 : 3 );
      69             : 
      70             :                 // ... the type
      71           0 :                 rMappedEvent[0] = PropertyValue(EVENT_TYPE, -1, makeAny(pEvents->ScriptType), PropertyState_DIRECT_VALUE);
      72             : 
      73             :                 // and the macro name
      74           0 :                 rMappedEvent[1] = PropertyValue(EVENT_LOCALMACRONAME, -1, makeAny(sLocalMacroName), PropertyState_DIRECT_VALUE);
      75             : 
      76             :                 // the library
      77           0 :                 if ( !sLibrary.isEmpty() )
      78           0 :                     rMappedEvent[2] = PropertyValue(EVENT_LIBRARY, -1, makeAny(sLibrary), PropertyState_DIRECT_VALUE);
      79             :             }
      80             :             else
      81             :             {
      82           0 :                 rMappedEvent.realloc( 2 );
      83           0 :                 rMappedEvent[0] = PropertyValue(EVENT_TYPE, -1, makeAny(pEvents->ScriptType), PropertyState_DIRECT_VALUE);
      84             :                 // and the macro name
      85           0 :                 rMappedEvent[1] = PropertyValue(EVENT_SCRIPTURL, -1, makeAny(pEvents->ScriptCode), PropertyState_DIRECT_VALUE);
      86             :             }
      87           0 :         }
      88           0 :     }
      89             : 
      90           0 :     void SAL_CALL OEventDescriptorMapper::replaceByName( const OUString&, const Any& ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
      91             :     {
      92             :         throw IllegalArgumentException(
      93           0 :             "replacing is not implemented for this wrapper class.", static_cast< ::cppu::OWeakObject* >(this), 1);
      94             :     }
      95             : 
      96           0 :     Any SAL_CALL OEventDescriptorMapper::getByName( const OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
      97             :     {
      98           0 :         MapString2PropertyValueSequence::const_iterator aPos = m_aMappedEvents.find(_rName);
      99           0 :         if (m_aMappedEvents.end() == aPos)
     100             :             throw NoSuchElementException(
     101           0 :                 OUString("There is no element named ") + _rName,
     102           0 :                 static_cast< ::cppu::OWeakObject* >(this));
     103             : 
     104           0 :         return makeAny(aPos->second);
     105             :     }
     106             : 
     107           0 :     Sequence< OUString > SAL_CALL OEventDescriptorMapper::getElementNames(  ) throw(RuntimeException, std::exception)
     108             :     {
     109           0 :         Sequence< OUString > aReturn(m_aMappedEvents.size());
     110           0 :         OUString* pReturn = aReturn.getArray();
     111           0 :         for (   MapString2PropertyValueSequence::const_iterator aCollect = m_aMappedEvents.begin();
     112           0 :                 aCollect != m_aMappedEvents.end();
     113             :                 ++aCollect, ++pReturn
     114             :             )
     115           0 :             *pReturn = aCollect->first;
     116             : 
     117           0 :         return aReturn;
     118             :     }
     119             : 
     120           0 :     sal_Bool SAL_CALL OEventDescriptorMapper::hasByName( const OUString& _rName ) throw(RuntimeException, std::exception)
     121             :     {
     122           0 :         MapString2PropertyValueSequence::const_iterator aPos = m_aMappedEvents.find(_rName);
     123           0 :         return m_aMappedEvents.end() != aPos;
     124             :     }
     125             : 
     126           0 :     Type SAL_CALL OEventDescriptorMapper::getElementType(  ) throw(RuntimeException, std::exception)
     127             :     {
     128           0 :         return ::cppu::UnoType<PropertyValue>::get();
     129             :     }
     130             : 
     131           0 :     sal_Bool SAL_CALL OEventDescriptorMapper::hasElements(  ) throw(RuntimeException, std::exception)
     132             :     {
     133           0 :         return !m_aMappedEvents.empty();
     134             :     }
     135             : 
     136             : }   // namespace xmloff
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10