1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: configgroup.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_CONFIGGROUP_HXX_
32 #define CONFIGMGR_CONFIGGROUP_HXX_
34 #include "configexcept.hxx"
35 #include "noderef.hxx"
36 #include "configdefaultprovider.hxx"
38 namespace com
{ namespace sun
{ namespace star
{
39 namespace script
{ class XTypeConverter
; }
44 //-----------------------------------------------------------------------------
45 namespace configuration
47 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
53 /// helper for updating a <type>NodeRef</type> that refers to a Group
54 class GroupUpdateHelper
56 rtl::Reference
< Tree
> m_aTree
;
59 GroupUpdateHelper(rtl::Reference
< Tree
> const& aParentTree
, NodeRef
const& aGroupNode
);
60 ~GroupUpdateHelper() {}
62 void validateNode(ValueRef
const& aNode
) const;
63 void validateNode(NodeRef
const& aNode
) const;
65 rtl::Reference
< Tree
> const& tree() const { return m_aTree
; }
66 NodeRef
const& node() const { return m_aNode
; }
68 void implValidateTree(rtl::Reference
< Tree
> const& aTree
) const;
69 void implValidateNode(rtl::Reference
< Tree
> const& aTree
, NodeRef
const& aNode
) const;
70 void implValidateNode(rtl::Reference
< Tree
> const& aTree
, ValueRef
const& aNode
) const;
72 //-----------------------------------------------------------------------------
73 /// allows to update values of a simple type within a <type>NodeRef</type> that refers to a Group
76 GroupUpdateHelper m_aHelper
;
77 com::sun::star::uno::Reference
<com::sun::star::script::XTypeConverter
> m_xTypeConverter
;
79 GroupUpdater(rtl::Reference
< Tree
> const& aParentTree
, NodeRef
const& aGroupNode
, com::sun::star::uno::Reference
<com::sun::star::script::XTypeConverter
> const& xConverter
);
81 NodeChange
validateSetValue(ValueRef
const& aValueNode
, com::sun::star::uno::Any
const& newValue
);
84 com::sun::star::uno::Any
implValidateValue(rtl::Reference
< Tree
> const& aTree
, ValueRef
const& aNode
, com::sun::star::uno::Any
const& aValue
) const;
86 //-----------------------------------------------------------------------------
88 /// allows to reset to default value or state members of a <type>NodeRef</type> that refers to a Group
91 GroupUpdateHelper m_aHelper
;
92 DefaultProvider m_aDefaultProvider
;
95 GroupDefaulter(rtl::Reference
< Tree
> const& _aParentTree
, NodeRef
const& _aGroupNode
, DefaultProvider
const& _aProvider
);
97 bool hasDoneSet() const { return m_bHasDoneSet
; }
99 NodeChange
validateSetToDefaultValue(ValueRef
const& aValueNode
);
101 NodeChange
validateSetToDefaultState(NodeRef
const& aNode
);
103 NodeChanges
validateSetAllToDefault();
105 static bool isDataAvailable(rtl::Reference
< Tree
> const& _aParentTree
, NodeRef
const& _aGroupNode
);
106 static bool ensureDataAvailable(rtl::Reference
< Tree
> const& _aParentTree
, NodeRef
const& _aGroupNode
, DefaultProvider
const& _aSource
);
108 //-----------------------------------------------------------------------------
109 bool isPossibleValueType(com::sun::star::uno::Type
const& aValueType
);
110 //-----------------------------------------------------------------------------
111 bool convertCompatibleValue(com::sun::star::uno::Reference
<com::sun::star::script::XTypeConverter
> const& xConverter
, uno::Any
& rConverted
,
112 com::sun::star::uno::Any
const& rNewValue
, com::sun::star::uno::Type
const& rTargetType
);
113 //-----------------------------------------------------------------------------
117 #endif // CONFIGMGR_CONFIGGROUP_HXX_