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"
26 #include "rtl/ref.hxx"
27 #include "rtl/ustring.hxx"
31 #include "nodemap.hxx"
32 #include "setnode.hxx"
38 // Work around some compilers' failure to accept
39 // std::binder1st(std::ptr_fun(&Data::equalTemplateNames), ...):
40 class EqualTemplateNames
:
41 public std::unary_function
< OUString
const &, bool >
44 inline explicit EqualTemplateNames(OUString
const & shortName
):
45 shortName_(shortName
) {}
47 inline bool operator ()(OUString
const & longName
) const
48 { return Data::equalTemplateNames(shortName_
, longName
); }
51 OUString
const & shortName_
;
57 int layer
, OUString
const & defaultTemplateName
,
58 OUString
const & templateName
):
59 Node(layer
), defaultTemplateName_(defaultTemplateName
),
60 templateName_(templateName
), mandatory_(Data::NO_LAYER
)
63 rtl::Reference
< Node
> SetNode::clone(bool keepTemplateName
) const {
64 return new SetNode(*this, keepTemplateName
);
67 NodeMap
& SetNode::getMembers() {
71 OUString
SetNode::getTemplateName() const {
75 void SetNode::setMandatory(int layer
) {
79 int SetNode::getMandatory() const {
83 OUString
const & SetNode::getDefaultTemplateName() const {
84 return defaultTemplateName_
;
87 std::vector
< OUString
> & SetNode::getAdditionalTemplateNames() {
88 return additionalTemplateNames_
;
91 bool SetNode::isValidTemplate(OUString
const & templateName
) const {
92 return Data::equalTemplateNames(templateName
, defaultTemplateName_
) ||
94 additionalTemplateNames_
.begin(),
95 additionalTemplateNames_
.end(), EqualTemplateNames(templateName
)) !=
96 additionalTemplateNames_
.end());
99 SetNode::SetNode(SetNode
const & other
, bool keepTemplateName
):
100 Node(other
), defaultTemplateName_(other
.defaultTemplateName_
),
101 additionalTemplateNames_(other
.additionalTemplateNames_
),
102 mandatory_(other
.mandatory_
)
104 cloneNodeMap(other
.members_
, &members_
);
105 if (keepTemplateName
) {
106 templateName_
= other
.templateName_
;
110 SetNode::~SetNode() {}
112 Node::Kind
SetNode::kind() const {
116 void SetNode::clear() {
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */