LCOV - code coverage report
Current view: top level - libreoffice/desktop/source/deployment/registry/component - dp_compbackenddb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 34 0.0 %
Date: 2012-12-27 Functions: 0 7 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             : 
      21             : #include "rtl/string.h"
      22             : #include "rtl/bootstrap.hxx"
      23             : #include "cppuhelper/exc_hlp.hxx"
      24             : #include "com/sun/star/uno/XComponentContext.hpp"
      25             : #include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
      26             : #include "com/sun/star/xml/xpath/XXPathAPI.hpp"
      27             : #include "dp_misc.h"
      28             : 
      29             : #include "dp_compbackenddb.hxx"
      30             : 
      31             : 
      32             : using namespace ::com::sun::star::uno;
      33             : using ::rtl::OUString;
      34             : 
      35             : #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010"
      36             : #define NS_PREFIX "comp"
      37             : #define ROOT_ELEMENT_NAME "component-backend-db"
      38             : #define KEY_ELEMENT_NAME "component"
      39             : 
      40             : namespace dp_registry {
      41             : namespace backend {
      42             : namespace component {
      43             : 
      44           0 : ComponentBackendDb::ComponentBackendDb(
      45             :     Reference<XComponentContext> const &  xContext,
      46           0 :     ::rtl::OUString const & url):BackendDb(xContext, url)
      47             : {
      48             : 
      49           0 : }
      50             : 
      51           0 : OUString ComponentBackendDb::getDbNSName()
      52             : {
      53           0 :     return OUSTR(EXTENSION_REG_NS);
      54             : }
      55             : 
      56           0 : OUString ComponentBackendDb::getNSPrefix()
      57             : {
      58           0 :     return OUSTR(NS_PREFIX);
      59             : }
      60             : 
      61           0 : OUString ComponentBackendDb::getRootElementName()
      62             : {
      63           0 :     return OUSTR(ROOT_ELEMENT_NAME);
      64             : }
      65             : 
      66           0 : OUString ComponentBackendDb::getKeyElementName()
      67             : {
      68           0 :     return OUSTR(KEY_ELEMENT_NAME);
      69             : }
      70             : 
      71           0 : void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
      72             : {
      73             :     try{
      74           0 :         if (!activateEntry(url))
      75             :         {
      76           0 :             Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url);
      77             :             writeSimpleElement(OUSTR("java-type-library"),
      78             :                                OUString::valueOf((sal_Bool) data.javaTypeLibrary),
      79           0 :                                componentNode);
      80             : 
      81             :             writeSimpleList(
      82             :                 data.implementationNames,
      83             :                 OUSTR("implementation-names"),
      84             :                 OUSTR("name"),
      85           0 :                 componentNode);
      86             : 
      87             :             writeVectorOfPair(
      88             :                 data.singletons,
      89             :                 OUSTR("singletons"),
      90             :                 OUSTR("item"),
      91             :                 OUSTR("key"),
      92             :                 OUSTR("value"),
      93           0 :                 componentNode);
      94             : 
      95           0 :             save();
      96             :         }
      97             :     }
      98           0 :     catch(const css::uno::Exception &)
      99             :     {
     100           0 :         Any exc( ::cppu::getCaughtException() );
     101             :         throw css::deployment::DeploymentException(
     102             :             OUSTR("Extension Manager: failed to write data entry in backend db: ") +
     103           0 :             m_urlDb, 0, exc);
     104             :     }
     105           0 : }
     106             : 
     107           0 : ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url)
     108             : {
     109             :     try
     110             :     {
     111           0 :         ComponentBackendDb::Data retData;
     112           0 :         Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
     113           0 :         if (aNode.is())
     114             :         {
     115             :             bool bJava = readSimpleElement(OUSTR("java-type-library"), aNode)
     116           0 :                 .equals(OUSTR("true")) ? true : false;
     117           0 :             retData.javaTypeLibrary = bJava;
     118             : 
     119             :             retData.implementationNames =
     120             :                 readList(
     121             :                     aNode,
     122             :                     OUSTR("implementation-names"),
     123           0 :                     OUSTR("name"));
     124             : 
     125             :             retData.singletons =
     126             :                 readVectorOfPair(
     127             :                     aNode,
     128             :                     OUSTR("singletons"),
     129             :                     OUSTR("item"),
     130             :                     OUSTR("key"),
     131           0 :                     OUSTR("value"));
     132             :         }
     133           0 :         return retData;
     134             :     }
     135           0 :     catch(const css::uno::Exception &)
     136             :     {
     137           0 :         Any exc( ::cppu::getCaughtException() );
     138             :         throw css::deployment::DeploymentException(
     139             :             OUSTR("Extension Manager: failed to read data entry in backend db: ") +
     140           0 :             m_urlDb, 0, exc);
     141             :     }
     142             : }
     143             : 
     144             : 
     145             : } // namespace bundle
     146             : } // namespace backend
     147             : } // namespace dp_registry
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10