summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-04-19 14:13:33 +0000
committerJörg Barfurth <jb@openoffice.org>2001-04-19 14:13:33 +0000
commita52cdd53889d792f70ce656f11e4e0e336264734 (patch)
treecbb65f14e93b8d59f1aede2746e36d07ace9dea5 /configmgr
parent8db81bfd818c8917bfd0750b782adab0b6f90518 (diff)
#86095# Added Options to TemplateProvider (for localization support). Split off SpecialTemplateProvider for Admin sessions
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/inc/template.hxx43
-rw-r--r--configmgr/source/treemgr/template.cxx65
-rw-r--r--configmgr/source/treemgr/templateimpl.cxx88
-rw-r--r--configmgr/source/treemgr/templateimpl.hxx32
4 files changed, 130 insertions, 98 deletions
diff --git a/configmgr/source/inc/template.hxx b/configmgr/source/inc/template.hxx
index ad4087d07dda..13c8aeadecd6 100644
--- a/configmgr/source/inc/template.hxx
+++ b/configmgr/source/inc/template.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: template.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-03-12 14:58:00 $
+ * last change: $Author: jb $ $Date: 2001-04-19 15:13:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,6 +73,7 @@ namespace configmgr
//-----------------------------------------------------------------------------
class ITemplateProvider;
class ISubtree;
+ class OOptions;
//-----------------------------------------------------------------------------
namespace configuration
{
@@ -92,18 +93,36 @@ namespace configmgr
{
friend class SetElementFactory;
friend class TemplateImplHelper;
- vos::ORef<TemplateProvider_Impl> m_aImpl;
+
+ vos::ORef<TemplateProvider_Impl> m_aImpl;
public:
- TemplateProvider(); // creates an empty (invalid) template provider
- explicit
- TemplateProvider(ITemplateProvider& pProvider);
+ TemplateProvider(); // creates an empty (invalid) template instance provider
+ TemplateProvider(ITemplateProvider& rProvider, vos::ORef< OOptions > const& xOptions);
TemplateProvider(TemplateProvider const& aOther);
+ TemplateProvider& operator=(TemplateProvider const& aOther);
~TemplateProvider();
bool isValid() const { return !!m_aImpl.isValid(); }
};
//-----------------------------------------------------------------------------
+ struct SpecialTemplateProvider_Impl;
+ class SpecialTemplateProvider
+ {
+ friend class TemplateImplHelper;
+
+ vos::ORef<SpecialTemplateProvider_Impl> m_aImpl;
+ public:
+ explicit
+ SpecialTemplateProvider();
+ SpecialTemplateProvider(SpecialTemplateProvider const& aOther);
+ SpecialTemplateProvider& operator=(SpecialTemplateProvider const& aOther);
+ ~SpecialTemplateProvider();
+
+ bool isValid() const { return !!m_aImpl.isValid(); }
+ };
+//-----------------------------------------------------------------------------
+
class Template;
typedef vos::ORef<Template> TemplateHolder;
@@ -142,21 +161,13 @@ namespace configmgr
/// get the package name of the template
Name getModule() const { return m_aModule; }
- /// find the template for the given path (instance type may be unknown)
- // static TemplateHolder fromPath(OUString const& sName, TemplateProvider const& aProvider);
-
- /// find the template for the given path (instance type may be unknown)
- static TemplateHolder fromNames(OUString const& sName, OUString const& sModule, TemplateProvider const& aProvider);
-
friend class TemplateImplHelper;
};
/// make a template instance that matches the given (simple) type
- TemplateHolder makeSimpleTemplate(UnoType const& aType, Attributes const& aAttrs, TemplateProvider const& aProvider);
- /// make a template instance that matches the given path. Assume that it represents a (complex) tree structure.
- //TemplateHolder makeTreeTemplate(OUString const& sPath, TemplateProvider const& aProvider);
+ TemplateHolder makeSimpleTemplate(UnoType const& aType, Attributes const& aAttrs, SpecialTemplateProvider const& aProvider);
/// make a template instance that matches the given path. Assume that it represents a (complex) tree structure.
- TemplateHolder makeTreeTemplate(OUString const& sName, OUString const& sModule, TemplateProvider const& aProvider);
+ TemplateHolder makeTreeTemplate(OUString const& sName, OUString const& sModule, SpecialTemplateProvider const& aProvider);
/// make a template instance that matches the elements of the given set. Ensures that the element type is known
TemplateHolder makeSetElementTemplate(ISubtree const& aSet, TemplateProvider const& aProvider);
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/template.cxx b/configmgr/source/treemgr/template.cxx
index dbcb2e66276a..d49770bfcd75 100644
--- a/configmgr/source/treemgr/template.cxx
+++ b/configmgr/source/treemgr/template.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: template.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-04-03 16:28:40 $
+ * last change: $Author: jb $ $Date: 2001-04-19 15:13:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,14 +72,15 @@ namespace configmgr
// class TemplateProvider
//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
TemplateProvider::TemplateProvider()
: m_aImpl()
{
}
//-----------------------------------------------------------------------------
-TemplateProvider::TemplateProvider(ITemplateProvider& rProvider)
-: m_aImpl(new TemplateProvider_Impl(&rProvider))
+TemplateProvider::TemplateProvider(ITemplateProvider& rProvider, vos::ORef< OOptions > const& xOptions)
+: m_aImpl( new TemplateProvider_Impl(rProvider,xOptions) )
{
}
@@ -88,11 +89,46 @@ TemplateProvider::TemplateProvider(TemplateProvider const& aOther)
: m_aImpl(aOther.m_aImpl)
{
}
+
+//-----------------------------------------------------------------------------
+TemplateProvider& TemplateProvider::operator =(TemplateProvider const& aOther)
+{
+ m_aImpl = aOther.m_aImpl;
+ return *this;
+}
+
//-----------------------------------------------------------------------------
TemplateProvider::~TemplateProvider()
{
}
+//-----------------------------------------------------------------------------
+// class SpecialTemplateProvider
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+SpecialTemplateProvider::SpecialTemplateProvider()
+: m_aImpl( new SpecialTemplateProvider_Impl() )
+{
+}
+
+//-----------------------------------------------------------------------------
+SpecialTemplateProvider::SpecialTemplateProvider(SpecialTemplateProvider const& aOther)
+: m_aImpl(aOther.m_aImpl)
+{
+}
+
+//-----------------------------------------------------------------------------
+SpecialTemplateProvider& SpecialTemplateProvider::operator =(SpecialTemplateProvider const& aOther)
+{
+ m_aImpl = aOther.m_aImpl;
+ return *this;
+}
+
+//-----------------------------------------------------------------------------
+SpecialTemplateProvider::~SpecialTemplateProvider()
+{
+}
//-----------------------------------------------------------------------------
// class Template
@@ -137,30 +173,17 @@ RelativePath Template::getPath() const
}
//-----------------------------------------------------------------------------
-TemplateHolder Template::fromNames(OUString const& sName, OUString const& sModule, TemplateProvider const& aProvider)
-{
- TemplateName aNames( TemplateName::parseTemplateNames(sName,sModule) );
- return TemplateImplHelper::findTemplate(aNames, aProvider );
-}
-//-----------------------------------------------------------------------------
-TemplateHolder locate(Name const& aName, Name const& aModule, TemplateProvider const& aProvider)
-{
- TemplateName aNames(aName,aModule);
- return TemplateImplHelper::findTemplate(aNames, aProvider );
-}
-//-----------------------------------------------------------------------------
-
-TemplateHolder makeSimpleTemplate(UnoType const& aType, Attributes const& aAttrs, TemplateProvider const& aProvider)
+TemplateHolder makeSimpleTemplate(UnoType const& aType, Attributes const& aAttrs, SpecialTemplateProvider const& aProvider)
{
TemplateName aNames(aType,false);
- return TemplateImplHelper::makeTemplate( aNames, aProvider, aType, aAttrs);
+ return TemplateImplHelper::makeSpecialTemplate( aNames, aProvider, aType, aAttrs);
}
//-----------------------------------------------------------------------------
-TemplateHolder makeTreeTemplate(OUString const& sName, OUString const& sModule, TemplateProvider const& aProvider)
+TemplateHolder makeTreeTemplate(OUString const& sName, OUString const& sModule, SpecialTemplateProvider const& aProvider)
{
TemplateName aNames( TemplateName::parseTemplateNames(sName,sModule) );
- return TemplateImplHelper::makeTemplate( aNames,aProvider, TemplateImplHelper::getUnoInterfaceType(), Attributes());
+ return TemplateImplHelper::makeSpecialTemplate( aNames,aProvider, TemplateImplHelper::getUnoInterfaceType(), Attributes());
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/templateimpl.cxx b/configmgr/source/treemgr/templateimpl.cxx
index ae6ddbcec708..7a9dadee7fb3 100644
--- a/configmgr/source/treemgr/templateimpl.cxx
+++ b/configmgr/source/treemgr/templateimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templateimpl.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jb $ $Date: 2001-04-03 16:28:40 $
+ * last change: $Author: jb $ $Date: 2001-04-19 15:13:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,19 +143,7 @@ TemplateHolder TemplateImplHelper::createNew (TemplateName const& aNames,UnoType
}
//-----------------------------------------------------------------------------
-TemplateHolder TemplateImplHelper::findTemplate (TemplateName const& aNames, TemplateProvider const& aProvider)
-{
- OSL_ENSURE(aProvider.m_aImpl.isValid(), "Cannot find a template without a provider");
-
- if (aProvider.m_aImpl.isValid())
- return aProvider.m_aImpl->findTemplate(aNames);
-
- else
- return TemplateHolder(0);
-}
-//-----------------------------------------------------------------------------
-
-TemplateHolder TemplateImplHelper::makeTemplate (TemplateName const& aNames, TemplateProvider const& aProvider, UnoType const& aType, Attributes const& aAttrs)
+TemplateHolder TemplateImplHelper::makeSpecialTemplate (TemplateName const& aNames, SpecialTemplateProvider const& aProvider, UnoType const& aType, Attributes const& aAttrs)
{
OSL_ENSURE(aProvider.m_aImpl.isValid(), "Cannot find a template without a provider");
@@ -169,7 +157,7 @@ TemplateHolder TemplateImplHelper::makeTemplate (TemplateName const& aNames, Tem
TemplateHolder TemplateImplHelper::makeElementTemplateWithType(TemplateName const& aNames, TemplateProvider const& aProvider, ISubtree const& aSet)
{
- OSL_ENSURE(aProvider.m_aImpl.isValid(), "Cannot find a template without a provider");
+ OSL_ENSURE(aProvider.m_aImpl.isValid(), "ERROR: Cannot find a template without a provider");
if (aProvider.m_aImpl.isValid())
return aProvider.m_aImpl->makeElementTemplateWithType(aNames,aSet);
@@ -192,41 +180,16 @@ void TemplateImplHelper::assignActualType (Template& aTemplate,UnoType const& aT
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-// class TemplateProvider_Impl
+// class SpecialTemplateProvider_Impl
//-----------------------------------------------------------------------------
-TemplateProvider_Impl::TemplateProvider_Impl(ITemplateProvider* pProvider)
-: m_pProvider(pProvider)
-, m_aRepository()
+SpecialTemplateProvider_Impl::SpecialTemplateProvider_Impl()
+: m_aRepository()
{
}
//-----------------------------------------------------------------------------
-std::auto_ptr<INode> TemplateProvider_Impl::instantiate(TemplateHolder const& aTemplate)
-{
- std::auto_ptr<INode> pRet;
- if (m_pProvider && aTemplate.isValid())
- {
- pRet = m_pProvider->requestTemplateInstance(aTemplate->getName().toString(), aTemplate->getModule().toString(), NULL);
- }
- return pRet;
-}
-//-----------------------------------------------------------------------------
-
-TemplateHolder TemplateProvider_Impl::findTemplate (TemplateName const& aNames)
-{
- typedef TemplateRepository::value_type Entry;
-
- TemplateRepository::iterator it = m_aRepository.find(aNames);
- if (it == m_aRepository.end())
- it = m_aRepository.insert( Entry( aNames, TemplateImplHelper::createNew(aNames) ) ).first;
-
- return it->second;
-
-}
-//-----------------------------------------------------------------------------
-
-TemplateHolder TemplateProvider_Impl::makeTemplate (TemplateName const& aNames, UnoType const& aType, Attributes const& aAttrs)
+TemplateHolder SpecialTemplateProvider_Impl::makeTemplate (TemplateName const& aNames, UnoType const& aType, Attributes const& aAttrs)
{
typedef TemplateRepository::value_type Entry;
@@ -244,6 +207,29 @@ TemplateHolder TemplateProvider_Impl::makeTemplate (TemplateName const& aNames,
}
//-----------------------------------------------------------------------------
+// class TemplateProvider_Impl
+//-----------------------------------------------------------------------------
+
+TemplateProvider_Impl::TemplateProvider_Impl(ITemplateProvider& rProvider, vos::ORef< OOptions > const& xOptions)
+: m_rProvider(rProvider)
+, m_xOptions(xOptions)
+, m_aRepository()
+{
+}
+//-----------------------------------------------------------------------------
+
+std::auto_ptr<INode> TemplateProvider_Impl::instantiate(TemplateHolder const& aTemplate)
+{
+ std::auto_ptr<INode> pRet;
+ if (aTemplate.isValid())
+ {
+ pRet = m_rProvider.requestTemplateInstance(aTemplate->getName().toString(), aTemplate->getModule().toString(), m_xOptions);
+ }
+ return pRet;
+}
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
namespace
{
//-----------------------------------------------------------------------------
@@ -343,15 +329,13 @@ TemplateHolder TemplateProvider_Impl::makeElementTemplateWithType(TemplateName c
else if (!detectElementType(aType,aSet))
{
std::auto_ptr<INode> pTemplateInstance;
- if (m_pProvider)
- {
- OSL_ASSERT(aNames.aName.toString() == aSet.getElementTemplateName());
- OSL_ASSERT(aNames.aModule.toString() == aSet.getElementTemplateModule());
- OUString sPath = aNames.makePath().toString(); // could also be extracted from aSet
+ OSL_ASSERT(aNames.aName.toString() == aSet.getElementTemplateName());
+ OSL_ASSERT(aNames.aModule.toString() == aSet.getElementTemplateModule());
- pTemplateInstance = m_pProvider->requestTemplateInstance(aNames.aName.toString(), aNames.aModule.toString(), NULL);
- }
+ OUString sPath = aNames.makePath().toString(); // could also be extracted from aSet
+
+ pTemplateInstance = m_rProvider.requestTemplateInstance(aNames.aName.toString(), aNames.aModule.toString(), m_xOptions);
aType = detectNodeType(pTemplateInstance.get()); // throws if necessary
}
diff --git a/configmgr/source/treemgr/templateimpl.hxx b/configmgr/source/treemgr/templateimpl.hxx
index 741dc052f2f2..61504f509e4f 100644
--- a/configmgr/source/treemgr/templateimpl.hxx
+++ b/configmgr/source/treemgr/templateimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templateimpl.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-03-16 17:35:23 $
+ * last change: $Author: jb $ $Date: 2001-04-19 15:13:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,7 @@
#include "template.hxx"
#include "configpath.hxx"
+#include "options.hxx"
#include <vos/refernce.hxx>
#include <map>
@@ -192,8 +193,8 @@ namespace configmgr
static void assignActualType (Template& aTemplate,UnoType const& aType);
//-----------------------------------------------------------------
- static TemplateHolder findTemplate (TemplateName const& aNames, TemplateProvider const& aProvider);
- static TemplateHolder makeTemplate (TemplateName const& aNames, TemplateProvider const& aProvider, UnoType const& aType, Attributes const& aAttrs);
+ static TemplateHolder makeSpecialTemplate (TemplateName const& aNames, SpecialTemplateProvider const& aProvider, UnoType const& aType, Attributes const& aAttrs);
+
static TemplateHolder makeElementTemplateWithType(TemplateName const& aNames, TemplateProvider const& aProvider, ISubtree const& aSet);
//-----------------------------------------------------------------
@@ -211,21 +212,34 @@ namespace configmgr
//-------------------------------------------------------------------------
//---------------------------------------------------------------------
+ // class SpecialTemplateProvider_Impl
+ //---------------------------------------------------------------------
+
+ struct SpecialTemplateProvider_Impl : vos::OReference
+ {
+ SpecialTemplateProvider_Impl();
+
+ TemplateHolder makeTemplate (TemplateName const& aNames, UnoType const& aType, Attributes const& aAttrs);
+
+ private:
+ TemplateRepository m_aRepository;
+ };
+
+ //---------------------------------------------------------------------
// class TemplateProvider_Impl
//---------------------------------------------------------------------
struct TemplateProvider_Impl : vos::OReference
{
- TemplateProvider_Impl(ITemplateProvider* pProvider);
+ TemplateProvider_Impl(ITemplateProvider& rProvider, vos::ORef< OOptions > const& xOptions);
std::auto_ptr<INode> instantiate(TemplateHolder const& aTemplate);
- TemplateHolder findTemplate (TemplateName const& aNames);
- TemplateHolder makeTemplate (TemplateName const& aNames, UnoType const& aType, Attributes const& aAttrs);
TemplateHolder makeElementTemplateWithType(TemplateName const& aNames, ISubtree const& aSet);
-
private:
- ITemplateProvider* m_pProvider;
+ ITemplateProvider& m_rProvider;
+ vos::ORef< OOptions > m_xOptions;
+
TemplateRepository m_aRepository;
};