LCOV - code coverage report
Current view: top level - sc/source/filter/xml - XMLTableSourceContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 52 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 100 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                 :            : 
      29                 :            : #include "XMLTableSourceContext.hxx"
      30                 :            : #include "xmlimprt.hxx"
      31                 :            : #include "document.hxx"
      32                 :            : #include "xmlsubti.hxx"
      33                 :            : #include "tablink.hxx"
      34                 :            : #include <xmloff/xmltoken.hxx>
      35                 :            : #include <xmloff/xmlnmspe.hxx>
      36                 :            : #include <xmloff/nmspmap.hxx>
      37                 :            : #include <sax/tools/converter.hxx>
      38                 :            : #include <com/sun/star/sheet/XSheetLinkable.hpp>
      39                 :            : 
      40                 :            : using namespace com::sun::star;
      41                 :            : using namespace xmloff::token;
      42                 :            : 
      43                 :            : //------------------------------------------------------------------
      44                 :            : 
      45                 :          0 : ScXMLTableSourceContext::ScXMLTableSourceContext( ScXMLImport& rImport,
      46                 :            :                                       sal_uInt16 nPrfx,
      47                 :            :                                       const ::rtl::OUString& rLName,
      48                 :            :                                       const ::com::sun::star::uno::Reference<
      49                 :            :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
      50                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
      51                 :            :     sLink(),
      52                 :            :     sTableName(),
      53                 :            :     sFilterName(),
      54                 :            :     sFilterOptions(),
      55                 :            :     nRefresh(0),
      56                 :          0 :     nMode(sheet::SheetLinkMode_NORMAL)
      57                 :            : {
      58 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
                 [ #  # ]
      59         [ #  # ]:          0 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
      60                 :            :     {
      61 [ #  # ][ #  # ]:          0 :         const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
      62                 :          0 :         rtl::OUString aLocalName;
      63                 :          0 :         sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
      64         [ #  # ]:          0 :                                             sAttrName, &aLocalName ));
      65 [ #  # ][ #  # ]:          0 :         const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
      66         [ #  # ]:          0 :         if(nPrefix == XML_NAMESPACE_XLINK)
      67                 :            :         {
      68 [ #  # ][ #  # ]:          0 :             if (IsXMLToken(aLocalName, XML_HREF))
      69         [ #  # ]:          0 :                 sLink = GetScImport().GetAbsoluteReference(sValue);
      70                 :            :         }
      71         [ #  # ]:          0 :         else if (nPrefix == XML_NAMESPACE_TABLE)
      72                 :            :         {
      73 [ #  # ][ #  # ]:          0 :             if (IsXMLToken(aLocalName, XML_TABLE_NAME))
      74                 :          0 :                 sTableName = sValue;
      75 [ #  # ][ #  # ]:          0 :             else if (IsXMLToken(aLocalName, XML_FILTER_NAME))
      76                 :          0 :                 sFilterName = sValue;
      77 [ #  # ][ #  # ]:          0 :             else if (IsXMLToken(aLocalName, XML_FILTER_OPTIONS))
      78                 :          0 :                 sFilterOptions = sValue;
      79 [ #  # ][ #  # ]:          0 :             else if (IsXMLToken(aLocalName, XML_MODE))
      80                 :            :             {
      81 [ #  # ][ #  # ]:          0 :                 if (IsXMLToken(sValue, XML_COPY_RESULTS_ONLY))
      82                 :          0 :                     nMode = sheet::SheetLinkMode_VALUE;
      83                 :            :             }
      84 [ #  # ][ #  # ]:          0 :             else if (IsXMLToken(aLocalName, XML_REFRESH_DELAY))
      85                 :            :             {
      86                 :            :                 double fTime;
      87 [ #  # ][ #  # ]:          0 :                 if (::sax::Converter::convertDuration( fTime, sValue ))
      88                 :          0 :                     nRefresh = Max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
      89                 :            :             }
      90                 :            :         }
      91                 :          0 :     }
      92                 :          0 : }
      93                 :            : 
      94                 :          0 : ScXMLTableSourceContext::~ScXMLTableSourceContext()
      95                 :            : {
      96         [ #  # ]:          0 : }
      97                 :            : 
      98                 :          0 : SvXMLImportContext *ScXMLTableSourceContext::CreateChildContext( sal_uInt16 nPrefix,
      99                 :            :                                             const ::rtl::OUString& rLName,
     100                 :            :                                             const ::com::sun::star::uno::Reference<
     101                 :            :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
     102                 :            : {
     103         [ #  # ]:          0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
     104                 :            : }
     105                 :            : 
     106                 :          0 : void ScXMLTableSourceContext::EndElement()
     107                 :            : {
     108         [ #  # ]:          0 :     if (!sLink.isEmpty())
     109                 :            :     {
     110 [ #  # ][ #  # ]:          0 :         uno::Reference <sheet::XSheetLinkable> xLinkable (GetScImport().GetTables().GetCurrentXSheet(), uno::UNO_QUERY);
     111                 :          0 :         ScDocument* pDoc(GetScImport().GetDocument());
     112 [ #  # ][ #  # ]:          0 :         if (xLinkable.is() && pDoc)
                 [ #  # ]
     113                 :            :         {
     114         [ #  # ]:          0 :             ScXMLImport::MutexGuard aGuard(GetScImport());
     115   [ #  #  #  # ]:          0 :             if (pDoc->RenameTab( GetScImport().GetTables().GetCurrentSheet(),
     116                 :          0 :                 GetScImport().GetTables().GetCurrentSheetName(), false, sal_True))
     117                 :            :             {
     118 [ #  # ][ #  # ]:          0 :                 sLink = ScGlobal::GetAbsDocName( sLink, pDoc->GetDocumentShell() );
         [ #  # ][ #  # ]
                 [ #  # ]
     119         [ #  # ]:          0 :                 if (sFilterName.isEmpty())
     120         [ #  # ]:          0 :                     ScDocumentLoader::GetFilterName( sLink, sFilterName, sFilterOptions, false, false );
     121                 :            : 
     122                 :          0 :                 sal_uInt8 nLinkMode = SC_LINK_NONE;
     123         [ #  # ]:          0 :                 if ( nMode == sheet::SheetLinkMode_NORMAL )
     124                 :          0 :                     nLinkMode = SC_LINK_NORMAL;
     125         [ #  # ]:          0 :                 else if ( nMode == sheet::SheetLinkMode_VALUE )
     126                 :          0 :                     nLinkMode = SC_LINK_VALUE;
     127                 :            : 
     128                 :          0 :                 pDoc->SetLink( GetScImport().GetTables().GetCurrentSheet(),
     129                 :            :                     nLinkMode, sLink, sFilterName, sFilterOptions,
     130         [ #  # ]:          0 :                     sTableName, nRefresh );
     131         [ #  # ]:          0 :             }
     132                 :          0 :         }
     133                 :            :     }
     134                 :          0 : }
     135                 :            : 
     136                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10