LCOV - code coverage report
Current view: top level - dbaccess/source/filter/xml - xmlDatabase.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 46 58 79.3 %
Date: 2015-06-13 12:38:46 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          16 : OXMLDatabase::OXMLDatabase( ODBFilter& rImport,
      43             :                 sal_uInt16 nPrfx, const OUString& rLName ) :
      44          16 :     SvXMLImportContext( rImport, nPrfx, rLName )
      45             : {
      46             : 
      47          16 : }
      48             : 
      49          32 : OXMLDatabase::~OXMLDatabase()
      50             : {
      51             : 
      52          32 : }
      53             : 
      54          36 : SvXMLImportContext* OXMLDatabase::CreateChildContext(
      55             :         sal_uInt16 nPrefix,
      56             :         const OUString& rLocalName,
      57             :         const Reference< XAttributeList > & xAttrList )
      58             : {
      59          36 :     SvXMLImportContext *pContext = 0;
      60          36 :     const SvXMLTokenMap&    rTokenMap   = GetOwnImport().GetDatabaseElemTokenMap();
      61             : 
      62          36 :     switch( rTokenMap.Get( nPrefix, rLocalName ) )
      63             :     {
      64             :         case XML_TOK_DATASOURCE:
      65          16 :             GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
      66          16 :             pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource );
      67          16 :             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           4 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
      86           4 :                 Any aValue;
      87           8 :                 OUString sService;
      88           4 :                 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue);
      89           4 :                 aValue >>= sService;
      90           4 :                 if ( sService.isEmpty() )
      91             :                 {
      92           4 :                     Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
      93           4 :                     if ( xSup.is() )
      94           4 :                         pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
      95           4 :                 }
      96             :             }
      97           4 :             break;
      98             :         case XML_TOK_QUERIES:
      99             :             {
     100           4 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     101           4 :                 Any aValue;
     102           8 :                 OUString sService;
     103           4 :                 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue);
     104           4 :                 aValue >>= sService;
     105           4 :                 if ( sService.isEmpty() )
     106             :                 {
     107           4 :                     Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
     108           4 :                     if ( xSup.is() )
     109           4 :                         pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
     110           4 :                 }
     111             :             }
     112           4 :             break;
     113             :         case XML_TOK_TABLES:
     114             :         case XML_TOK_SCHEMA_DEFINITION:
     115             :             {
     116          12 :                 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     117          12 :                 Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
     118          12 :                 if ( xSup.is() )
     119          12 :                     pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
     120             :             }
     121          12 :             break;
     122             :     }
     123             : 
     124          36 :     if( !pContext )
     125           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     126             : 
     127          36 :     return pContext;
     128             : }
     129             : 
     130         152 : ODBFilter& OXMLDatabase::GetOwnImport()
     131             : {
     132         152 :     return static_cast<ODBFilter&>(GetImport());
     133             : }
     134             : 
     135          16 : void OXMLDatabase::EndElement()
     136             : {
     137          16 :     GetOwnImport().setPropertyInfo();
     138          16 : }
     139             : 
     140             : } // namespace dbaxml
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11