summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-03-16 16:37:28 +0000
committerJörg Barfurth <jb@openoffice.org>2001-03-16 16:37:28 +0000
commit3b1871be12962fbb0e1bbc9941f2a97fdd34320e (patch)
tree7a89bd67a29abf96c0f61299538a60b05a9a05dd /configmgr
parent2c82e7461da09182d25b594b1c87e906d48f5d10 (diff)
Revised support for native type pseudo-templates; now includes the special case of localized values as sets
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/treemgr/template.cxx6
-rw-r--r--configmgr/source/treemgr/templateimpl.cxx63
-rw-r--r--configmgr/source/treemgr/templateimpl.hxx26
-rw-r--r--configmgr/source/xml/typeconverter.cxx63
4 files changed, 136 insertions, 22 deletions
diff --git a/configmgr/source/treemgr/template.cxx b/configmgr/source/treemgr/template.cxx
index a7fcb1d104c0..20512c8e5c12 100644
--- a/configmgr/source/treemgr/template.cxx
+++ b/configmgr/source/treemgr/template.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: template.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-03-12 14:59:05 $
+ * last change: $Author: jb $ $Date: 2001-03-16 17:35:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -160,7 +160,7 @@ TemplateHolder locate(Name const& aName, Name const& aModule, TemplateProvider c
TemplateHolder makeSimpleTemplate(UnoType const& aType, Attributes const& aAttrs, TemplateProvider const& aProvider)
{
- TemplateName aNames(aType);
+ TemplateName aNames(aType,false);
return TemplateImplHelper::makeTemplate( aNames, aProvider, aType, aAttrs);
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/templateimpl.cxx b/configmgr/source/treemgr/templateimpl.cxx
index 1d9bd01a626b..a163516ab179 100644
--- a/configmgr/source/treemgr/templateimpl.cxx
+++ b/configmgr/source/treemgr/templateimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templateimpl.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-03-12 14:59:05 $
+ * last change: $Author: jb $ $Date: 2001-03-16 17:35:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,8 @@
#include "treeprovider.hxx"
#include "apitypes.hxx"
+#include "strdecl.hxx"
+#include "typeconverter.hxx"
#include <vos/refernce.hxx>
#include <map>
@@ -76,17 +78,56 @@ namespace configmgr
Name TemplateName::makeSimpleTypeName(UnoType const& aType)
{
- OUString aTypeName = OUString(RTL_CONSTASCII_USTRINGPARAM("uno:")).concat(aType.getTypeName());
- return Name(aTypeName, Name::NoValidate());
+ OUString sTypeName = toTemplateName(aType);
+ return Name(sTypeName, Name::NoValidate());
}
//-----------------------------------------------------------------------------
-Name TemplateName::makeSimpleTypeModuleName()
+UnoType TemplateName::resolveSimpleTypeName(Name const& aName)
{
- OUString aModuleName = OUString(RTL_CONSTASCII_USTRINGPARAM("cfg:native-types"));
+ OUString sTypeName = aName.toString();
+ return parseTemplateName(sTypeName);
+}
+//-----------------------------------------------------------------------------
+
+Name TemplateName::makeNativeTypeModuleName()
+{
+ OUString aModuleName = TEMPLATE_MODULE_NATIVE_VALUE;
return Name(aModuleName, Name::NoValidate());
}
//-----------------------------------------------------------------------------
+Name TemplateName::makeLocalizedTypeModuleName()
+{
+ OUString aModuleName = TEMPLATE_MODULE_LOCALIZED_VALUE;
+ return Name(aModuleName, Name::NoValidate());
+}
+//-----------------------------------------------------------------------------
+bool TemplateName::isSimpleTypeName() const
+{
+ OUString aPrefix = TEMPLATE_MODULE_NATIVE_PREFIX;
+ if (aModule.toString().compareTo(aPrefix,aPrefix.getLength()) != 0)
+ return false;
+
+ OSL_ENSURE( aModule == makeNativeTypeModuleName() ||
+ aModule == makeLocalizedTypeModuleName(),
+ "ERROR: Invalid template module with native prefix found");
+
+ return true;
+}
+//-----------------------------------------------------------------------------
+
+UnoType TemplateName::resolveToSimpleType() const
+{
+ UnoType aType;
+ if ( isSimpleTypeName() )
+ {
+ aType = resolveSimpleTypeName( aName );
+ }
+ else
+ OSL_ENSURE(false, "TemplateName::resolveToSimpleType must be called only for simple type name pairs");
+ return aType;
+}
+//-----------------------------------------------------------------------------
#if 0
TemplateName TemplateName::parseTemplatePath(OUString const& sName)
{
@@ -322,7 +363,15 @@ TemplateHolder TemplateProvider_Impl::makeElementTemplateWithType(TemplateName c
if (it == m_aRepository.end() || !it->second->isInstanceTypeKnown())
{
UnoType aType;
- if (!detectElementType(aType,aSet))
+ if (aNames.isSimpleTypeName()) // native type found
+ {
+ aType = aNames.resolveToSimpleType();
+
+ if (aType == TemplateImplHelper::getNoTypeAvailable())
+ throw configuration::Exception("INTERNAL ERROR: Could not resolve native type");
+ }
+
+ else if (!detectElementType(aType,aSet))
{
std::auto_ptr<INode> pTemplateInstance;
if (m_pProvider)
diff --git a/configmgr/source/treemgr/templateimpl.hxx b/configmgr/source/treemgr/templateimpl.hxx
index 21870fe8e9d7..741dc052f2f2 100644
--- a/configmgr/source/treemgr/templateimpl.hxx
+++ b/configmgr/source/treemgr/templateimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templateimpl.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-03-12 14:59:05 $
+ * last change: $Author: jb $ $Date: 2001-03-16 17:35:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -101,9 +101,9 @@ namespace configmgr
, aModule()
{}
- TemplateName(UnoType const& aType)
+ TemplateName(UnoType const& aType, bool bLocalized)
: aName(makeSimpleTypeName(aType))
- , aModule(makeSimpleTypeModuleName())
+ , aModule(makeSimpleTypeModuleName(bLocalized))
{}
TemplateName(Name const& aName_)
@@ -136,10 +136,9 @@ namespace configmgr
return aName.isEmpty();
}
- bool isSimpleTypeName() const
- {
- return aModule == makeSimpleTypeModuleName();
- }
+ bool isSimpleTypeName() const;
+
+ UnoType resolveToSimpleType() const;
//-----------------------------------------------------------------
bool operator<(TemplateName const& aOther) const
@@ -152,9 +151,18 @@ namespace configmgr
//-----------------------------------------------------------------
static TemplateName parseTemplateNames(OUString const& sName, OUString const& sModule);
//-----------------------------------------------------------------
+ static UnoType resolveSimpleTypeName(Name const& aName);
+ //-----------------------------------------------------------------
static Name makeSimpleTypeName(UnoType const& aType);
//-----------------------------------------------------------------
- static Name makeSimpleTypeModuleName();
+ static Name makeNativeTypeModuleName();
+ //-----------------------------------------------------------------
+ static Name makeLocalizedTypeModuleName();
+ //-----------------------------------------------------------------
+ static Name makeSimpleTypeModuleName(bool bLocalized)
+ {
+ return bLocalized ? makeLocalizedTypeModuleName() : makeNativeTypeModuleName();
+ }
//-----------------------------------------------------------------
};
//-------------------------------------------------------------------------
diff --git a/configmgr/source/xml/typeconverter.cxx b/configmgr/source/xml/typeconverter.cxx
index d743dcdea75d..50eda8817ee0 100644
--- a/configmgr/source/xml/typeconverter.cxx
+++ b/configmgr/source/xml/typeconverter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: typeconverter.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: dg $ $Date: 2000-11-17 08:44:50 $
+ * last change: $Author: jb $ $Date: 2001-03-16 17:37:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -205,7 +205,6 @@ namespace configmgr
}
// *************************************************************************
-
namespace
{
@@ -382,4 +381,62 @@ namespace configmgr
}
+ // template names
+// *************************************************************************
+ ::rtl::OUString toTemplateName(const uno::Type& _rType)
+ {
+ bool bList;
+ uno::Type aBaseType = getBasicType(_rType,bList);
+ return toTemplateName(aBaseType.getTypeClass(), bList);
+ }
+
+ ::rtl::OUString toTemplateName(const uno::TypeClass& _rBasicType, bool bList)
+ {
+ return toTemplateName(toTypeName(_rBasicType), bList);
+ }
+
+// *************************************************************************
+ uno::Type parseTemplateName(::rtl::OUString const& sTypeName)
+ {
+ ::rtl::OUString sBasicTypeName;
+ bool bList;
+ parseTemplateName(sTypeName, sBasicTypeName,bList);
+ return toType(sTypeName,bList);
+ }
+
+ void parseTemplateName(::rtl::OUString const& sTypeName, uno::TypeClass& _rType, bool& bList)
+ {
+ ::rtl::OUString sBasicTypeName;
+ parseTemplateName(sTypeName, sBasicTypeName,bList);
+ _rType = toTypeClass(sTypeName);
+ }
+
+// *************************************************************************
+ ::rtl::OUString toTemplateName(const ::rtl::OUString& _rBasicTypeName, bool bList)
+ {
+ ::rtl::OUString sName = _rBasicTypeName;
+ if (bList)
+ sName += TEMPLATE_LIST_SUFFIX;
+ return sName;
+ }
+
+ void parseTemplateName(::rtl::OUString const& sTypeName, ::rtl::OUString& _rBasicName, bool& bList)
+ {
+ ::rtl::OUString const sSuffix = TEMPLATE_LIST_SUFFIX;
+
+ sal_Int32 nIndex = sTypeName.lastIndexOf(sSuffix);
+ if (nIndex >= 0 && nIndex + sSuffix.getLength() == sTypeName.getLength())
+ {
+ bList = true;
+ _rBasicName = sTypeName.copy(0,nIndex);
+ }
+ else
+ {
+ bList = false;
+ _rBasicName = sTypeName;
+ }
+
+ }
+// *************************************************************************
+
} // namespace configmgr