cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / framework / configuration / GenericConfigurationChangeRequest.cxx
blobfa6d415034c8d5147980ca3c1db6bbbd8db648fb
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 .
20 #include <sal/config.h>
22 #include <string_view>
24 #include "GenericConfigurationChangeRequest.hxx"
26 #include <framework/FrameworkHelper.hxx>
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::drawing::framework;
32 namespace sd::framework {
34 GenericConfigurationChangeRequest::GenericConfigurationChangeRequest (
35 const Reference<XResourceId>& rxResourceId,
36 const Mode eMode)
37 : mxResourceId(rxResourceId),
38 meMode(eMode)
40 if ( ! rxResourceId.is() || rxResourceId->getResourceURL().isEmpty())
41 throw css::lang::IllegalArgumentException();
44 GenericConfigurationChangeRequest::~GenericConfigurationChangeRequest() noexcept
48 void SAL_CALL GenericConfigurationChangeRequest::execute (
49 const Reference<XConfiguration>& rxConfiguration)
51 if (!rxConfiguration.is())
52 return;
54 switch (meMode)
56 case Activation:
57 rxConfiguration->addResource(mxResourceId);
58 break;
60 case Deactivation:
61 rxConfiguration->removeResource(mxResourceId);
62 break;
66 OUString SAL_CALL GenericConfigurationChangeRequest::getName()
68 return OUString::Concat("GenericConfigurationChangeRequest ")
69 + (meMode==Activation
70 ? std::u16string_view(u"activate ") : std::u16string_view(u"deactivate "))
71 + FrameworkHelper::ResourceIdToString(mxResourceId);
74 void SAL_CALL GenericConfigurationChangeRequest::setName (const OUString&)
76 // Ignored.
79 } // end of namespace sd::framework
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */