1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <rtl/ref.hxx>
25 #include <rtl/ustring.hxx>
30 #include "nodemap.hxx"
31 #include "setnode.hxx"
36 int layer
, OUString defaultTemplateName
,
37 OUString templateName
):
38 Node(layer
), defaultTemplateName_(std::move(defaultTemplateName
)),
39 templateName_(std::move(templateName
)), mandatory_(Data::NO_LAYER
)
42 rtl::Reference
< Node
> SetNode::clone(bool keepTemplateName
) const {
43 return new SetNode(*this, keepTemplateName
);
46 NodeMap
& SetNode::getMembers() {
50 OUString
SetNode::getTemplateName() const {
54 void SetNode::setMandatory(int layer
) {
58 int SetNode::getMandatory() const {
63 bool SetNode::isValidTemplate(OUString
const & templateName
) const {
64 return Data::equalTemplateNames(templateName
, defaultTemplateName_
) ||
66 additionalTemplateNames_
.begin(),
67 additionalTemplateNames_
.end(),
68 [&templateName
](OUString
const & longName
) { return Data::equalTemplateNames(templateName
, longName
); } );
71 SetNode::SetNode(SetNode
const & other
, bool keepTemplateName
):
72 Node(other
), defaultTemplateName_(other
.defaultTemplateName_
),
73 additionalTemplateNames_(other
.additionalTemplateNames_
),
74 mandatory_(other
.mandatory_
)
76 other
.members_
.cloneInto(&members_
);
77 if (keepTemplateName
) {
78 templateName_
= other
.templateName_
;
82 SetNode::~SetNode() {}
84 Node::Kind
SetNode::kind() const {
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */