tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / desktop / source / deployment / registry / component / dp_compbackenddb.cxx
blobfd9bb2c61bdd72b1fa1e1a20fa2b7c907ecc7d60
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 <cppuhelper/exc_hlp.hxx>
22 #include <com/sun/star/deployment/DeploymentException.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include "dp_compbackenddb.hxx"
28 using namespace ::com::sun::star::uno;
30 constexpr OUStringLiteral EXTENSION_REG_NS = u"http://openoffice.org/extensionmanager/component-registry/2010";
31 constexpr OUStringLiteral NS_PREFIX = u"comp";
32 constexpr OUStringLiteral ROOT_ELEMENT_NAME = u"component-backend-db";
33 constexpr OUStringLiteral KEY_ELEMENT_NAME = u"component";
35 namespace dp_registry::backend::component {
37 ComponentBackendDb::ComponentBackendDb(
38 Reference<XComponentContext> const & xContext,
39 OUString const & url):BackendDb(xContext, url)
44 OUString ComponentBackendDb::getDbNSName()
46 return EXTENSION_REG_NS;
49 OUString ComponentBackendDb::getNSPrefix()
51 return NS_PREFIX;
54 OUString ComponentBackendDb::getRootElementName()
56 return ROOT_ELEMENT_NAME;
59 OUString ComponentBackendDb::getKeyElementName()
61 return KEY_ELEMENT_NAME;
64 void ComponentBackendDb::addEntry(OUString const & url, Data const & data)
66 try{
67 if (!activateEntry(url))
69 Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url);
70 writeSimpleElement(u"java-type-library",
71 OUString::boolean(data.javaTypeLibrary),
72 componentNode);
74 writeSimpleList(
75 data.implementationNames,
76 u"implementation-names",
77 u"name",
78 componentNode);
80 writeVectorOfPair(
81 data.singletons,
82 u"singletons",
83 u"item",
84 u"key",
85 u"value",
86 componentNode);
88 save();
91 catch(const css::uno::Exception &)
93 Any exc( ::cppu::getCaughtException() );
94 throw css::deployment::DeploymentException(
95 "Extension Manager: failed to write data entry in backend db: " +
96 m_urlDb, nullptr, exc);
100 ComponentBackendDb::Data ComponentBackendDb::getEntry(std::u16string_view url)
104 ComponentBackendDb::Data retData;
105 Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
106 if (aNode.is())
108 bool bJava = readSimpleElement(u"java-type-library", aNode) == "true";
109 retData.javaTypeLibrary = bJava;
111 retData.implementationNames =
112 readList( aNode, u"implementation-names", u"name");
114 retData.singletons =
115 readVectorOfPair( aNode, u"singletons", u"item", u"key", u"value");
117 return retData;
119 catch(const css::uno::Exception &)
121 Any exc( ::cppu::getCaughtException() );
122 throw css::deployment::DeploymentException(
123 "Extension Manager: failed to read data entry in backend db: " +
124 m_urlDb, nullptr, exc);
129 } // namespace dp_registry::backend::component
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */