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: templateimpl.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_TEMPLATEIMPL_HXX_
32 #define CONFIGMGR_TEMPLATEIMPL_HXX_
34 #include "template.hxx"
35 #include "configpath.hxx"
36 #include "requestoptions.hxx"
37 #include <rtl/ustrbuf.hxx>
38 #include <rtl/ref.hxx>
39 #include <salhelper/simplereferenceobject.hxx>
40 #include "utility.hxx"
49 //-----------------------------------------------------------------------------
50 namespace data
{ class TreeSegment
; }
51 //-----------------------------------------------------------------------------
53 namespace configuration
55 //-----------------------------------------------------------------------------
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------
64 rtl::OUString aName
, aModule
;
66 //-----------------------------------------------------------------
72 TemplateName(rtl::OUString
const& aName_
)
77 TemplateName(rtl::OUString
const& aName_
, rtl::OUString
const& aModule_
)
82 //-----------------------------------------------------------------
84 /// compose the path where the template is located
85 rtl::OUString
makePathString() const
87 rtl::OUStringBuffer aBuffer
;
89 if (aModule
.getLength() != 0)
90 aBuffer
.append( this->aModule
).append(sal_Unicode('/'));
92 aBuffer
.append( this->aName
);
94 return aBuffer
.makeStringAndClear();
96 //-----------------------------------------------------------------
99 return aName
.getLength() == 0;
102 bool isSimpleTypeName() const;
104 com::sun::star::uno::Type
resolveToSimpleType() const;
105 //-----------------------------------------------------------------
107 bool operator<(TemplateName
const& aOther
) const
109 return (aModule
== aOther
.aModule
) ? (aName
< aOther
.aName
) : (aModule
< aOther
.aModule
);
112 //-----------------------------------------------------------------
113 static com::sun::star::uno::Type
resolveSimpleTypeName(rtl::OUString
const& aName
);
114 //-----------------------------------------------------------------
115 #if OSL_DEBUG_LEVEL > 0
116 static rtl::OUString
makeNativeTypeModuleName();
117 //-----------------------------------------------------------------
118 static rtl::OUString
makeLocalizedTypeModuleName();
120 //-----------------------------------------------------------------
122 //-------------------------------------------------------------------------
124 //---------------------------------------------------------------------
125 // class TemplateImplHelper
126 //---------------------------------------------------------------------
128 class TemplateImplHelper
131 //-----------------------------------------------------------------
133 static com::sun::star::uno::Type
getNoTypeAvailable()
135 return getVoidCppuType();
137 //-----------------------------------------------------------------
139 static void assignActualType (Template
& aTemplate
,com::sun::star::uno::Type
const& aType
);
140 //-----------------------------------------------------------------
142 static rtl::Reference
<Template
> makeElementTemplateWithType(TemplateName
const& aNames
, TemplateProvider
const& _aProvider
, sharable::SetNode
* set
);
143 //-----------------------------------------------------------------
145 static rtl::Reference
<Template
> createNew (TemplateName
const& aNames
,com::sun::star::uno::Type
const& aType
);
146 //-----------------------------------------------------------------
148 //-------------------------------------------------------------------------
150 typedef std::map
< TemplateName
, rtl::Reference
<Template
> > TemplateRepository
;
151 //-------------------------------------------------------------------------
153 //---------------------------------------------------------------------
154 // class TemplateProvider_Impl
155 //---------------------------------------------------------------------
157 struct TemplateProvider_Impl
: salhelper::SimpleReferenceObject
159 TemplateProvider_Impl(rtl::Reference
< TreeManager
> const & xProvider
, RequestOptions
const& aOptions
);
161 rtl::Reference
< data::TreeSegment
> instantiate(rtl::Reference
<Template
> const& aTemplate
);
163 rtl::Reference
<Template
> makeElementTemplateWithType(TemplateName
const& _aNames
, sharable::SetNode
* set
);
165 rtl::Reference
< TreeManager
> m_xProvider
;
166 RequestOptions m_aOptions
;
168 TemplateRepository m_aRepository
;
171 //-----------------------------------------------------------------------------
175 #endif // CONFIGMGR_TEMPLATEIMPL_HXX_