bump product version to 4.1.6.2
[LibreOffice.git] / desktop / source / deployment / registry / help / dp_helpbackenddb.cxx
blob4d66fe4dd398ffef36309113603c1b676a3048d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
29 #include "dp_helpbackenddb.hxx"
32 using namespace ::com::sun::star::uno;
34 #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010"
35 #define NS_PREFIX "help"
36 #define ROOT_ELEMENT_NAME "help-backend-db"
37 #define KEY_ELEMENT_NAME "help"
39 namespace dp_registry {
40 namespace backend {
41 namespace help {
43 HelpBackendDb::HelpBackendDb(
44 Reference<XComponentContext> const & xContext,
45 OUString const & url):BackendDb(xContext, url)
50 OUString HelpBackendDb::getDbNSName()
52 return OUString(EXTENSION_REG_NS);
55 OUString HelpBackendDb::getNSPrefix()
57 return OUString(NS_PREFIX);
60 OUString HelpBackendDb::getRootElementName()
62 return OUString(ROOT_ELEMENT_NAME);
65 OUString HelpBackendDb::getKeyElementName()
67 return OUString(KEY_ELEMENT_NAME);
71 void HelpBackendDb::addEntry(OUString const & url, Data const & data)
73 try{
74 if (!activateEntry(url))
76 Reference<css::xml::dom::XNode> helpNode
77 = writeKeyElement(url);
79 writeSimpleElement("data-url", data.dataUrl, helpNode);
80 save();
83 catch ( const css::deployment::DeploymentException& )
85 throw;
87 catch(const css::uno::Exception &)
89 Any exc( ::cppu::getCaughtException() );
90 throw css::deployment::DeploymentException(
91 "Extension Manager: failed to write data entry in help backend db: " + m_urlDb, 0, exc);
96 ::boost::optional<HelpBackendDb::Data>
97 HelpBackendDb::getEntry(OUString const & url)
99 try
101 HelpBackendDb::Data retData;
102 Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
103 if (aNode.is())
105 retData.dataUrl = readSimpleElement("data-url", aNode);
107 else
109 return ::boost::optional<Data>();
111 return ::boost::optional<Data>(retData);
113 catch ( const css::deployment::DeploymentException& )
115 throw;
117 catch(const css::uno::Exception &)
119 Any exc( ::cppu::getCaughtException() );
120 throw css::deployment::DeploymentException(
121 "Extension Manager: failed to read data entry in help backend db: " + m_urlDb, 0, exc);
125 ::std::list<OUString> HelpBackendDb::getAllDataUrls()
127 return getOneChildFromAllEntries("data-url");
130 } // namespace help
131 } // namespace backend
132 } // namespace dp_registry
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */