LCOV - code coverage report
Current view: top level - sc/source/core/data - sheetevents.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 54 5.6 %
Date: 2012-08-25 Functions: 1 10 10.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 42 4.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2008 by Sun Microsystems, Inc.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "sheetevents.hxx"
      30                 :            : #include <com/sun/star/script/vba/VBAEventId.hpp>
      31                 :            : // -----------------------------------------------------------------------
      32                 :            : 
      33                 :          0 : rtl::OUString ScSheetEvents::GetEventName(sal_Int32 nEvent)
      34                 :            : {
      35 [ #  # ][ #  # ]:          0 :     if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT)
      36                 :            :     {
      37                 :            :         OSL_FAIL("invalid event number");
      38                 :          0 :         return rtl::OUString();
      39                 :            :     }
      40                 :            : 
      41                 :            :     static const sal_Char* aEventNames[] =
      42                 :            :     {
      43                 :            :         "OnFocus",                  // SC_SHEETEVENT_FOCUS
      44                 :            :         "OnUnfocus",                // SC_SHEETEVENT_UNFOCUS
      45                 :            :         "OnSelect",                 // SC_SHEETEVENT_SELECT
      46                 :            :         "OnDoubleClick",            // SC_SHEETEVENT_DOUBLECLICK
      47                 :            :         "OnRightClick",             // SC_SHEETEVENT_RIGHTCLICK
      48                 :            :         "OnChange",                 // SC_SHEETEVENT_CHANGE
      49                 :            :         "OnCalculate"               // SC_SHEETEVENT_CALCULATE
      50                 :            :     };
      51                 :          0 :     return rtl::OUString::createFromAscii(aEventNames[nEvent]);
      52                 :            : }
      53                 :            : 
      54                 :         40 : sal_Int32 ScSheetEvents::GetVbaSheetEventId(sal_Int32 nEvent)
      55                 :            : {
      56                 :            :     using namespace ::com::sun::star::script::vba::VBAEventId;
      57 [ +  - ][ -  + ]:         40 :     if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT)
      58                 :            :     {
      59                 :            :         OSL_FAIL("invalid event number");
      60                 :          0 :         return NO_EVENT;
      61                 :            :     }
      62                 :            : 
      63                 :            :     static const sal_Int32 nVbaEventIds[] =
      64                 :            :     {
      65                 :            :         WORKSHEET_ACTIVATE,             // SC_SHEETEVENT_FOCUS
      66                 :            :         WORKSHEET_DEACTIVATE,           // SC_SHEETEVENT_UNFOCUS
      67                 :            :         WORKSHEET_SELECTIONCHANGE,      // SC_SHEETEVENT_SELECT
      68                 :            :         WORKSHEET_BEFOREDOUBLECLICK,    // SC_SHEETEVENT_DOUBLECLICK
      69                 :            :         WORKSHEET_BEFORERIGHTCLICK,     // SC_SHEETEVENT_RIGHTCLICK
      70                 :            :         WORKSHEET_CHANGE,               // SC_SHEETEVENT_CHANGE
      71                 :            :         WORKSHEET_CALCULATE             // SC_SHEETEVENT_CALCULATE
      72                 :            :     };
      73                 :         40 :     return nVbaEventIds[nEvent];
      74                 :            : }
      75                 :            : 
      76                 :          0 : sal_Int32 ScSheetEvents::GetVbaDocumentEventId(sal_Int32 nEvent)
      77                 :            : {
      78                 :            :     using namespace ::com::sun::star::script::vba::VBAEventId;
      79                 :          0 :     sal_Int32 nSheetEventId = GetVbaSheetEventId(nEvent);
      80         [ #  # ]:          0 :     return (nSheetEventId != NO_EVENT) ? (nSheetEventId + USERDEFINED_START) : NO_EVENT;
      81                 :            : }
      82                 :            : 
      83                 :            : // -----------------------------------------------------------------------
      84                 :            : 
      85                 :          0 : ScSheetEvents::ScSheetEvents() :
      86                 :          0 :     mpScriptNames(NULL)
      87                 :            : {
      88                 :          0 : }
      89                 :            : 
      90                 :          0 : ScSheetEvents::~ScSheetEvents()
      91                 :            : {
      92                 :          0 :     Clear();
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : void ScSheetEvents::Clear()
      96                 :            : {
      97         [ #  # ]:          0 :     if (mpScriptNames)
      98                 :            :     {
      99         [ #  # ]:          0 :         for (sal_Int32 nEvent=0; nEvent<SC_SHEETEVENT_COUNT; ++nEvent)
     100         [ #  # ]:          0 :             delete mpScriptNames[nEvent];
     101         [ #  # ]:          0 :         delete[] mpScriptNames;
     102                 :          0 :         mpScriptNames = NULL;
     103                 :            :     }
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : ScSheetEvents::ScSheetEvents(const ScSheetEvents& rOther) :
     107                 :          0 :     mpScriptNames(NULL)
     108                 :            : {
     109                 :          0 :     *this = rOther;
     110                 :          0 : }
     111                 :            : 
     112                 :          0 : const ScSheetEvents& ScSheetEvents::operator=(const ScSheetEvents& rOther)
     113                 :            : {
     114                 :          0 :     Clear();
     115         [ #  # ]:          0 :     if (rOther.mpScriptNames)
     116                 :            :     {
     117                 :          0 :         mpScriptNames = new rtl::OUString*[SC_SHEETEVENT_COUNT];
     118         [ #  # ]:          0 :         for (sal_Int32 nEvent=0; nEvent<SC_SHEETEVENT_COUNT; ++nEvent)
     119         [ #  # ]:          0 :             if (rOther.mpScriptNames[nEvent])
     120                 :          0 :                 mpScriptNames[nEvent] = new rtl::OUString(*rOther.mpScriptNames[nEvent]);
     121                 :            :             else
     122                 :          0 :                 mpScriptNames[nEvent] = NULL;
     123                 :            :     }
     124                 :          0 :     return *this;
     125                 :            : }
     126                 :            : 
     127                 :          0 : const rtl::OUString* ScSheetEvents::GetScript(sal_Int32 nEvent) const
     128                 :            : {
     129 [ #  # ][ #  # ]:          0 :     if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT)
     130                 :            :     {
     131                 :            :         OSL_FAIL("invalid event number");
     132                 :          0 :         return NULL;
     133                 :            :     }
     134                 :            : 
     135         [ #  # ]:          0 :     if (mpScriptNames)
     136                 :          0 :         return mpScriptNames[nEvent];
     137                 :          0 :     return NULL;
     138                 :            : }
     139                 :            : 
     140                 :          0 : void ScSheetEvents::SetScript(sal_Int32 nEvent, const rtl::OUString* pNew)
     141                 :            : {
     142 [ #  # ][ #  # ]:          0 :     if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT)
     143                 :            :     {
     144                 :            :         OSL_FAIL("invalid event number");
     145                 :          0 :         return;
     146                 :            :     }
     147                 :            : 
     148         [ #  # ]:          0 :     if (!mpScriptNames)
     149                 :            :     {
     150                 :          0 :         mpScriptNames = new rtl::OUString*[SC_SHEETEVENT_COUNT];
     151         [ #  # ]:          0 :         for (sal_Int32 nEventIdx=0; nEventIdx<SC_SHEETEVENT_COUNT; ++nEventIdx)
     152                 :          0 :             mpScriptNames[nEventIdx] = NULL;
     153                 :            :     }
     154         [ #  # ]:          0 :     delete mpScriptNames[nEvent];
     155         [ #  # ]:          0 :     if (pNew)
     156                 :          0 :         mpScriptNames[nEvent] = new rtl::OUString(*pNew);
     157                 :            :     else
     158                 :          0 :         mpScriptNames[nEvent] = NULL;
     159                 :            : }
     160                 :            : 
     161                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10