LCOV - code coverage report
Current view: top level - desktop/source/deployment/registry/help - dp_helpbackenddb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 36 69.4 %
Date: 2012-08-25 Functions: 8 8 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 48 25.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                 :            : 
      30                 :            : #include "rtl/string.h"
      31                 :            : #include "rtl/bootstrap.hxx"
      32                 :            : #include "cppuhelper/exc_hlp.hxx"
      33                 :            : #include "com/sun/star/uno/XComponentContext.hpp"
      34                 :            : #include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
      35                 :            : #include "com/sun/star/xml/xpath/XXPathAPI.hpp"
      36                 :            : #include "dp_misc.h"
      37                 :            : 
      38                 :            : #include "dp_helpbackenddb.hxx"
      39                 :            : 
      40                 :            : 
      41                 :            : namespace css = ::com::sun::star;
      42                 :            : using namespace ::com::sun::star::uno;
      43                 :            : using ::rtl::OUString;
      44                 :            : 
      45                 :            : #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010"
      46                 :            : #define NS_PREFIX "help"
      47                 :            : #define ROOT_ELEMENT_NAME "help-backend-db"
      48                 :            : #define KEY_ELEMENT_NAME "help"
      49                 :            : 
      50                 :            : namespace dp_registry {
      51                 :            : namespace backend {
      52                 :            : namespace help {
      53                 :            : 
      54                 :        380 : HelpBackendDb::HelpBackendDb(
      55                 :            :     Reference<XComponentContext> const &  xContext,
      56                 :        380 :     ::rtl::OUString const & url):BackendDb(xContext, url)
      57                 :            : {
      58                 :            : 
      59                 :        380 : }
      60                 :            : 
      61                 :        692 : OUString HelpBackendDb::getDbNSName()
      62                 :            : {
      63                 :        692 :     return OUSTR(EXTENSION_REG_NS);
      64                 :            : }
      65                 :            : 
      66                 :       1938 : OUString HelpBackendDb::getNSPrefix()
      67                 :            : {
      68                 :       1938 :     return OUSTR(NS_PREFIX);
      69                 :            : }
      70                 :            : 
      71                 :        188 : OUString HelpBackendDb::getRootElementName()
      72                 :            : {
      73                 :        188 :     return OUSTR(ROOT_ELEMENT_NAME);
      74                 :            : }
      75                 :            : 
      76                 :       1200 : OUString HelpBackendDb::getKeyElementName()
      77                 :            : {
      78                 :       1200 :     return OUSTR(KEY_ELEMENT_NAME);
      79                 :            : }
      80                 :            : 
      81                 :            : 
      82                 :         62 : void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
      83                 :            : {
      84                 :            :     try{
      85 [ +  - ][ +  - ]:         62 :         if (!activateEntry(url))
      86                 :            :         {
      87                 :            :             Reference<css::xml::dom::XNode> helpNode
      88         [ +  - ]:         62 :                 = writeKeyElement(url);
      89                 :            : 
      90 [ +  - ][ +  - ]:         62 :             writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode);
      91         [ +  - ]:         62 :             save();
      92                 :            :         }
      93                 :            :     }
      94                 :          0 :     catch ( const css::deployment::DeploymentException& )
      95                 :            :     {
      96                 :          0 :         throw;
      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 help backend db: ") +
     103   [ #  #  #  #  :          0 :             m_urlDb, 0, exc);
                   #  # ]
     104                 :            :     }
     105                 :         62 : }
     106                 :            : 
     107                 :            : 
     108                 :            : ::boost::optional<HelpBackendDb::Data>
     109                 :        108 : HelpBackendDb::getEntry(::rtl::OUString const & url)
     110                 :            : {
     111                 :            :     try
     112                 :            :     {
     113                 :        108 :         HelpBackendDb::Data retData;
     114         [ +  - ]:        108 :         Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
     115         [ +  - ]:        108 :         if (aNode.is())
     116                 :            :         {
     117 [ +  - ][ +  - ]:        108 :             retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode);
     118                 :            :         }
     119                 :            :         else
     120                 :            :         {
     121         [ #  # ]:          0 :             return ::boost::optional<Data>();
     122                 :            :         }
     123         [ +  - ]:        108 :         return ::boost::optional<Data>(retData);
     124                 :            :     }
     125                 :          0 :     catch ( const css::deployment::DeploymentException& )
     126                 :            :     {
     127                 :          0 :         throw;
     128                 :            :     }
     129      [ #  #  # ]:          0 :     catch(const css::uno::Exception &)
     130                 :            :     {
     131         [ #  # ]:          0 :         Any exc( ::cppu::getCaughtException() );
     132                 :            :         throw css::deployment::DeploymentException(
     133                 :            :             OUSTR("Extension Manager: failed to read data entry in help backend db: ") +
     134   [ #  #  #  #  :          0 :             m_urlDb, 0, exc);
                   #  # ]
     135                 :            :     }
     136                 :            : }
     137                 :            : 
     138                 :        380 : ::std::list<OUString> HelpBackendDb::getAllDataUrls()
     139                 :            : {
     140         [ +  - ]:        380 :     return getOneChildFromAllEntries(OUString(RTL_CONSTASCII_USTRINGPARAM("data-url")));
     141                 :            : }
     142                 :            : 
     143                 :            : } // namespace help
     144                 :            : } // namespace backend
     145                 :            : } // namespace dp_registry
     146                 :            : 
     147                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10