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

Generated by: LCOV version 1.10