LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbaname.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-08-25 Functions: 0 26 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 90 0.0 %

           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 2000, 2010 Oracle and/or its affiliates.
       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                 :            : #include <vbahelper/helperdecl.hxx>
      29                 :            : 
      30                 :            : #include <com/sun/star/table/XCellRange.hpp>
      31                 :            : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      32                 :            : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
      33                 :            : 
      34                 :            : #include "vbaname.hxx"
      35                 :            : #include "vbarange.hxx"
      36                 :            : #include "vbaglobals.hxx"
      37                 :            : #include <vector>
      38                 :            : #include <rangenam.hxx>
      39                 :            : #include <vcl/msgbox.hxx>
      40                 :            : #include "tabvwsh.hxx"
      41                 :            : #include "viewdata.hxx"
      42                 :            : 
      43                 :            : using namespace ::ooo::vba;
      44                 :            : using namespace ::com::sun::star;
      45                 :            : 
      46                 :          0 : ScVbaName::ScVbaName(const css::uno::Reference< ov::XHelperInterface >& xParent,
      47                 :            :             const css::uno::Reference< css::uno::XComponentContext >& xContext,
      48                 :            :             const css::uno::Reference< css::sheet::XNamedRange >& xName,
      49                 :            :             const css::uno::Reference< css::sheet::XNamedRanges >& xNames,
      50                 :            :             const css::uno::Reference< css::frame::XModel >& xModel ):
      51                 :            :             NameImpl_BASE(  xParent , xContext ),
      52                 :            :             mxModel( xModel ),
      53                 :            :             mxNamedRange( xName ),
      54                 :          0 :             mxNames( xNames )
      55                 :            : {
      56                 :          0 : }
      57                 :            : 
      58                 :          0 : ScVbaName::~ScVbaName()
      59                 :            : {
      60         [ #  # ]:          0 : }
      61                 :            : 
      62                 :            : css::uno::Reference< ov::excel::XWorksheet >
      63                 :          0 : ScVbaName::getWorkSheet() throw (css::uno::RuntimeException)
      64                 :            : {
      65 [ #  # ][ #  # ]:          0 :     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
      66 [ #  # ][ #  # ]:          0 :     return xApplication->getActiveSheet();
      67                 :            : }
      68                 :            : 
      69                 :            : ::rtl::OUString
      70                 :          0 : ScVbaName::getName() throw (css::uno::RuntimeException)
      71                 :            : {
      72         [ #  # ]:          0 :     String sName;
      73 [ #  # ][ #  # ]:          0 :     sName += UniString ( mxNamedRange->getName() );
         [ #  # ][ #  # ]
                 [ #  # ]
      74 [ #  # ][ #  # ]:          0 :     return ::rtl::OUString( sName );
      75                 :            : }
      76                 :            : 
      77                 :            : void
      78                 :          0 : ScVbaName::setName( const ::rtl::OUString & rName ) throw (css::uno::RuntimeException)
      79                 :            : {
      80                 :          0 :     mxNamedRange->setName( rName );
      81                 :          0 : }
      82                 :            : 
      83                 :            : ::rtl::OUString
      84                 :          0 : ScVbaName::getNameLocal() throw (css::uno::RuntimeException)
      85                 :            : {
      86                 :          0 :     return getName();
      87                 :            : }
      88                 :            : 
      89                 :            : void
      90                 :          0 : ScVbaName::setNameLocal( const ::rtl::OUString & rName ) throw (css::uno::RuntimeException)
      91                 :            : {
      92                 :          0 :     setName( rName );
      93                 :          0 : }
      94                 :            : 
      95                 :            : sal_Bool
      96                 :          0 : ScVbaName::getVisible() throw (css::uno::RuntimeException)
      97                 :            : {
      98                 :          0 :     return true;
      99                 :            : }
     100                 :            : 
     101                 :            : void
     102                 :          0 : ScVbaName::setVisible( sal_Bool /*bVisible*/ ) throw (css::uno::RuntimeException)
     103                 :            : {
     104                 :          0 : }
     105                 :            : 
     106                 :            : ::rtl::OUString
     107                 :          0 : ScVbaName::getValue() throw (css::uno::RuntimeException)
     108                 :            : {
     109                 :          0 :     return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
     110                 :            : }
     111                 :            : 
     112                 :            : ::rtl::OUString
     113                 :          0 : ScVbaName::getValue(const formula::FormulaGrammar::Grammar eGrammar) throw (css::uno::RuntimeException)
     114                 :            : {
     115 [ #  # ][ #  # ]:          0 :     rtl::OUString sValue = mxNamedRange->getContent();
     116         [ #  # ]:          0 :     ScDocShell* pDocShell = excel::getDocShell( mxModel );
     117         [ #  # ]:          0 :     ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
     118         [ #  # ]:          0 :     String aContent;
     119 [ #  # ][ #  # ]:          0 :     excel::CompileODFFormulaToExcel( pDoc, sValue, aContent, eGrammar );
                 [ #  # ]
     120         [ #  # ]:          0 :     if ( aContent.Len() > 0 )
     121                 :            :     {
     122         [ #  # ]:          0 :         sValue = aContent;
     123                 :            :     }
     124         [ #  # ]:          0 :     if ( sValue.indexOf('=') != 0 )
     125                 :            :     {
     126         [ #  # ]:          0 :         sValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")) + sValue;
     127                 :            :     }
     128         [ #  # ]:          0 :     return sValue;
     129                 :            : }
     130                 :            : 
     131                 :            : void
     132                 :          0 : ScVbaName::setValue( const ::rtl::OUString & rValue ) throw (css::uno::RuntimeException)
     133                 :            : {
     134                 :          0 :     ::rtl::OUString sValue = rValue;
     135         [ #  # ]:          0 :     ScDocShell* pDocShell = excel::getDocShell( mxModel );
     136         [ #  # ]:          0 :     ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
     137         [ #  # ]:          0 :     String aContent;
     138 [ #  # ][ #  # ]:          0 :     excel::CompileExcelFormulaToODF( pDoc, sValue, aContent );
                 [ #  # ]
     139         [ #  # ]:          0 :     if ( aContent.Len() > 0 )
     140                 :            :     {
     141         [ #  # ]:          0 :         sValue = aContent;
     142                 :            :     }
     143 [ #  # ][ #  # ]:          0 :     mxNamedRange->setContent( sValue );
                 [ #  # ]
     144                 :          0 : }
     145                 :            : 
     146                 :            : ::rtl::OUString
     147                 :          0 : ScVbaName::getRefersTo() throw (css::uno::RuntimeException)
     148                 :            : {
     149                 :          0 :     return getValue();
     150                 :            : }
     151                 :            : 
     152                 :            : void
     153                 :          0 : ScVbaName::setRefersTo( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
     154                 :            : {
     155                 :          0 :     setValue( rRefersTo );
     156                 :          0 : }
     157                 :            : 
     158                 :            : ::rtl::OUString
     159                 :          0 : ScVbaName::getRefersToLocal() throw (css::uno::RuntimeException)
     160                 :            : {
     161                 :          0 :     return getRefersTo();
     162                 :            : }
     163                 :            : 
     164                 :            : void
     165                 :          0 : ScVbaName::setRefersToLocal( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
     166                 :            : {
     167                 :          0 :     setRefersTo( rRefersTo );
     168                 :          0 : }
     169                 :            : 
     170                 :            : ::rtl::OUString
     171                 :          0 : ScVbaName::getRefersToR1C1() throw (css::uno::RuntimeException)
     172                 :            : {
     173                 :          0 :     return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
     174                 :            : }
     175                 :            : 
     176                 :            : void
     177                 :          0 : ScVbaName::setRefersToR1C1( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
     178                 :            : {
     179                 :          0 :     setRefersTo( rRefersTo );
     180                 :          0 : }
     181                 :            : 
     182                 :            : ::rtl::OUString
     183                 :          0 : ScVbaName::getRefersToR1C1Local() throw (css::uno::RuntimeException)
     184                 :            : {
     185                 :          0 :     return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
     186                 :            : }
     187                 :            : 
     188                 :            : void
     189                 :          0 : ScVbaName::setRefersToR1C1Local( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
     190                 :            : {
     191                 :          0 :     setRefersTo( rRefersTo );
     192                 :          0 : }
     193                 :            : 
     194                 :            : css::uno::Reference< ov::excel::XRange >
     195                 :          0 : ScVbaName::getRefersToRange() throw (css::uno::RuntimeException)
     196                 :            : {
     197                 :            :     uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName(
     198         [ #  # ]:          0 :         mxContext, mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
     199                 :          0 :     return xRange;
     200                 :            : }
     201                 :            : 
     202                 :            : void
     203                 :          0 : ScVbaName::setRefersToRange( const css::uno::Reference< ov::excel::XRange > /*rRange*/ ) throw (css::uno::RuntimeException)
     204                 :            : {
     205                 :          0 : }
     206                 :            : 
     207                 :            : void
     208                 :          0 : ScVbaName::Delete() throw (css::uno::RuntimeException)
     209                 :            : {
     210         [ #  # ]:          0 :     mxNames->removeByName( mxNamedRange->getName() );
     211                 :          0 : }
     212                 :            : 
     213                 :            : rtl::OUString
     214                 :          0 : ScVbaName::getServiceImplName()
     215                 :            : {
     216                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaName"));
     217                 :            : }
     218                 :            : 
     219                 :            : uno::Sequence< rtl::OUString >
     220                 :          0 : ScVbaName::getServiceNames()
     221                 :            : {
     222 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     223         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
     224                 :            :     {
     225                 :          0 :         aServiceNames.realloc( 1 );
     226         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Name" ) );
     227                 :            :     }
     228                 :          0 :     return aServiceNames;
     229                 :            : }
     230                 :            : 
     231                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10