LCOV - code coverage report
Current view: top level - dbaccess/source/filter/xml - xmlDatabase.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 46 58 79.3 %
Date: 2014-11-03 Functions: 6 6 100.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 "xmlDatabase.hxx"
      21             : #include "xmlfilter.hxx"
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <xmloff/xmlnmspe.hxx>
      24             : #include "xmlDataSource.hxx"
      25             : #include "xmlDocuments.hxx"
      26             : #include "xmlEnums.hxx"
      27             : #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
      28             : #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
      29             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      30             : #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
      31             : #include "xmlstrings.hrc"
      32             : #include <tools/debug.hxx>
      33             : #include <connectivity/dbtools.hxx>
      34             : 
      35             : namespace dbaxml
      36             : {
      37             :     using namespace ::com::sun::star::uno;
      38             :     using namespace ::com::sun::star::sdb;
      39             :     using namespace ::com::sun::star::sdbcx;
      40             :     using namespace ::com::sun::star::xml::sax;
      41             : 
      42          34 : OXMLDatabase::OXMLDatabase( ODBFilter& rImport,
      43             :                 sal_uInt16 nPrfx, const OUString& rLName ) :
      44          34 :     SvXMLImportContext( rImport, nPrfx, rLName )
      45             : {
      46             : 
      47          34 : }
      48             : 
      49          68 : OXMLDatabase::~OXMLDatabase()
      50             : {
      51             : 
      52          68 : }
      53             : 
      54          72 : SvXMLImportContext* OXMLDatabase::CreateChildContext(
      55             :         sal_uInt16 nPrefix,
      56             :         const OUString& rLocalName,
      57             :         const Reference< XAttributeList > & xAttrList )
      58             : {
      59          72 :     SvXMLImportContext *pContext = 0;
      60          72 :     const SvXMLTokenMap&    rTokenMap   = GetOwnImport().GetDatabaseElemTokenMap();
      61             : 
      62          72 :     switch( rTokenMap.Get( nPrefix, rLocalName ) )
      63             :     {
      64             :         case XML_TOK_DATASOURCE:
      65          34 :             GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
      66          34 :             pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource );
      67          34 :             break;
      68             :         case XML_TOK_FORMS:
      69             :             {
      70           0 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
      71           0 :                 Any aValue;
      72           0 :                 OUString sService;
      73           0 :                 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue);
      74           0 :                 aValue >>= sService;
      75           0 :                 if ( sService.isEmpty() )
      76             :                 {
      77           0 :                     Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
      78           0 :                     if ( xSup.is() )
      79           0 :                         pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
      80           0 :                 }
      81             :             }
      82           0 :             break;
      83             :         case XML_TOK_REPORTS:
      84             :             {
      85           6 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
      86           6 :                 Any aValue;
      87          12 :                 OUString sService;
      88           6 :                 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue);
      89           6 :                 aValue >>= sService;
      90           6 :                 if ( sService.isEmpty() )
      91             :                 {
      92           6 :                     Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
      93           6 :                     if ( xSup.is() )
      94           6 :                         pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
      95           6 :                 }
      96             :             }
      97           6 :             break;
      98             :         case XML_TOK_QUERIES:
      99             :             {
     100           6 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     101           6 :                 Any aValue;
     102          12 :                 OUString sService;
     103           6 :                 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue);
     104           6 :                 aValue >>= sService;
     105           6 :                 if ( sService.isEmpty() )
     106             :                 {
     107           6 :                     Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
     108           6 :                     if ( xSup.is() )
     109           6 :                         pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
     110           6 :                 }
     111             :             }
     112           6 :             break;
     113             :         case XML_TOK_TABLES:
     114             :         case XML_TOK_SCHEMA_DEFINITION:
     115             :             {
     116          26 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     117          26 :                 Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
     118          26 :                 if ( xSup.is() )
     119          26 :                     pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
     120             :             }
     121          26 :             break;
     122             :     }
     123             : 
     124          72 :     if( !pContext )
     125           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     126             : 
     127          72 :     return pContext;
     128             : }
     129             : 
     130         300 : ODBFilter& OXMLDatabase::GetOwnImport()
     131             : {
     132         300 :     return static_cast<ODBFilter&>(GetImport());
     133             : }
     134             : 
     135          34 : void OXMLDatabase::EndElement()
     136             : {
     137          34 :     GetOwnImport().setPropertyInfo();
     138          34 : }
     139             : 
     140             : } // namespace dbaxml
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10