1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #include "precompiled_configmgr.hxx"
29 #include "sal/config.h"
35 #include "rtl/ref.hxx"
36 #include "rtl/ustring.hxx"
40 #include "nodemap.hxx"
41 #include "setnode.hxx"
47 // Work around some compilers' failure to accept
48 // std::binder1st(std::ptr_fun(&Data::equalTemplateNames), ...):
49 class EqualTemplateNames
:
50 public std::unary_function
< rtl::OUString
const &, bool >
53 inline explicit EqualTemplateNames(rtl::OUString
const & shortName
):
54 shortName_(shortName
) {}
56 inline bool operator ()(rtl::OUString
const & longName
) const
57 { return Data::equalTemplateNames(shortName_
, longName
); }
60 rtl::OUString
const & shortName_
;
66 int layer
, rtl::OUString
const & defaultTemplateName
,
67 rtl::OUString
const & templateName
):
68 Node(layer
), defaultTemplateName_(defaultTemplateName
),
69 templateName_(templateName
), mandatory_(Data::NO_LAYER
)
72 rtl::Reference
< Node
> SetNode::clone(bool keepTemplateName
) const {
73 return new SetNode(*this, keepTemplateName
);
76 NodeMap
& SetNode::getMembers() {
80 rtl::OUString
SetNode::getTemplateName() const {
84 void SetNode::setMandatory(int layer
) {
88 int SetNode::getMandatory() const {
92 rtl::OUString
const & SetNode::getDefaultTemplateName() const {
93 return defaultTemplateName_
;
96 std::vector
< rtl::OUString
> & SetNode::getAdditionalTemplateNames() {
97 return additionalTemplateNames_
;
100 bool SetNode::isValidTemplate(rtl::OUString
const & templateName
) const {
101 return Data::equalTemplateNames(templateName
, defaultTemplateName_
) ||
103 additionalTemplateNames_
.begin(),
104 additionalTemplateNames_
.end(), EqualTemplateNames(templateName
)) !=
105 additionalTemplateNames_
.end());
108 SetNode::SetNode(SetNode
const & other
, bool keepTemplateName
):
109 Node(other
), defaultTemplateName_(other
.defaultTemplateName_
),
110 additionalTemplateNames_(other
.additionalTemplateNames_
),
111 mandatory_(other
.mandatory_
)
113 cloneNodeMap(other
.members_
, &members_
);
114 if (keepTemplateName
) {
115 templateName_
= other
.templateName_
;
119 SetNode::~SetNode() {}
121 Node::Kind
SetNode::kind() const {
125 void SetNode::clear() {