1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "sal/config.h"
16 #include "registry/reader.hxx"
17 #include "registry/registry.hxx"
18 #include "registry/regtype.h"
19 #include "rtl/ref.hxx"
20 #include "rtl/ustring.hxx"
21 #include "sal/types.h"
22 #include "unoidl/legacyprovider.hxx"
23 #include "unoidl/unoidl.hxx"
29 std::vector
< OUString
> translateAnnotations(OUString
const & documentation
) {
30 std::vector
< OUString
> ans
;
31 if (documentation
.indexOf("@deprecated") != -1) {
32 //TODO: this check is somewhat crude
33 ans
.push_back("deprecated");
38 ConstantValue
translateConstantValue(
39 RegistryKey
& key
, RTConstValue
const & value
)
41 switch (value
.m_type
) {
43 return ConstantValue(static_cast< bool >(value
.m_value
.aBool
));
45 return ConstantValue(value
.m_value
.aByte
);
47 return ConstantValue(value
.m_value
.aShort
);
49 return ConstantValue(value
.m_value
.aUShort
);
51 return ConstantValue(value
.m_value
.aLong
);
53 return ConstantValue(value
.m_value
.aULong
);
55 return ConstantValue(value
.m_value
.aHyper
);
57 return ConstantValue(value
.m_value
.aUHyper
);
59 return ConstantValue(value
.m_value
.aFloat
);
61 return ConstantValue(value
.m_value
.aDouble
);
63 throw FileFormatException(
64 key
.getRegistryName(),
65 ("legacy format: unexpected type " + OUString::number(value
.m_type
)
66 + " of value of a field of constant group with key "
71 rtl::Reference
< Entity
> readEntity(
72 rtl::Reference
< Manager
> const & manager
, RegistryKey
& ucr
,
73 RegistryKey
& key
, OUString
const & path
, bool probe
);
75 class Cursor
: public MapCursor
{
78 rtl::Reference
< Manager
> const & manager
, RegistryKey
const & ucr
,
79 RegistryKey
const & key
);
82 virtual ~Cursor() throw () {}
84 virtual rtl::Reference
< Entity
> getNext(OUString
* name
);
86 rtl::Reference
< Manager
> manager_
;
90 RegistryKeyNames names_
;
95 rtl::Reference
< Manager
> const & manager
, RegistryKey
const & ucr
,
96 RegistryKey
const & key
):
97 manager_(manager
), ucr_(ucr
), key_(key
), index_(0)
100 prefix_
= key_
.getName();
101 if (!prefix_
.endsWith("/")) {
104 RegError e
= key_
.getKeyNames("", names_
);
105 if (e
!= REG_NO_ERROR
) {
106 throw FileFormatException(
107 key_
.getRegistryName(),
108 ("legacy format: cannot get sub-key names of " + key_
.getName()
109 + ": " + OUString::number(e
)));
114 rtl::Reference
< Entity
> Cursor::getNext(OUString
* name
) {
116 rtl::Reference
< Entity
> ent
;
117 if (index_
!= names_
.getLength()) {
118 OUString
path(names_
.getElement(index_
));
119 assert(path
.match(prefix_
));
120 *name
= path
.copy(prefix_
.getLength());
121 ent
= readEntity(manager_
, ucr_
, key_
, *name
, false);
128 class Module
: public ModuleEntity
{
131 rtl::Reference
< Manager
> const & manager
, RegistryKey
const & ucr
,
132 RegistryKey
const & key
):
133 manager_(manager
), ucr_(ucr
), key_(key
)
137 virtual ~Module() throw () {}
139 virtual std::vector
< OUString
> getMemberNames() const;
141 virtual rtl::Reference
< MapCursor
> createCursor() const
142 { return new Cursor(manager_
, ucr_
, key_
); }
144 rtl::Reference
< Manager
> manager_
;
146 mutable RegistryKey key_
;
149 std::vector
< OUString
> Module::getMemberNames() const {
150 RegistryKeyNames names
;
151 RegError e
= key_
.getKeyNames("", names
);
152 if (e
!= REG_NO_ERROR
) {
153 throw FileFormatException(
154 key_
.getRegistryName(),
155 ("legacy format: cannot get sub-key names of " + key_
.getName()
156 + ": " + OUString::number(e
)));
158 std::vector
< OUString
> ns
;
159 for (sal_uInt32 i
= 0; i
!= names
.getLength(); ++i
) {
160 ns
.push_back(names
.getElement(i
));
165 typereg::Reader
getReader(RegistryKey
& key
, std::vector
< char > * buffer
) {
169 RegError e
= key
.getValueInfo("", &type
, &size
);
170 if (e
!= REG_NO_ERROR
) {
171 throw FileFormatException(
172 key
.getRegistryName(),
173 ("legacy format: cannot get value info about key " + key
.getName()
174 + ": " + OUString::number(e
)));
176 if (type
!= RG_VALUETYPE_BINARY
) {
177 throw FileFormatException(
178 key
.getRegistryName(),
179 ("legacy format: unexpected value type " + OUString::number(type
)
180 + " of key " + key
.getName()));
183 /*TODO: || size > std::numeric_limits< std::vector< char >::size_type >::max() */)
185 throw FileFormatException(
186 key
.getRegistryName(),
187 ("legacy format: bad binary value size " + OUString::number(size
)
188 + " of key " + key
.getName()));
190 buffer
->resize(static_cast< std::vector
< char >::size_type
>(size
));
191 e
= key
.getValue("", &(*buffer
)[0]);
192 if (e
!= REG_NO_ERROR
) {
193 throw FileFormatException(
194 key
.getRegistryName(),
195 ("legacy format: cannot get binary value of key " + key
.getName()
196 + ": " + OUString::number(e
)));
198 typereg::Reader
reader(&(*buffer
)[0], size
, false, TYPEREG_VERSION_1
);
199 if (!reader
.isValid()) {
200 throw FileFormatException(
201 key
.getRegistryName(),
202 "legacy format: malformed binary value of key " + key
.getName());
207 rtl::Reference
< Entity
> readEntity(
208 rtl::Reference
< Manager
> const & manager
, RegistryKey
& ucr
,
209 RegistryKey
& key
, OUString
const & path
, bool probe
)
211 assert(manager
.is());
213 RegError e
= key
.openKey(path
, sub
);
217 case REG_KEY_NOT_EXISTS
:
219 return rtl::Reference
< Entity
>();
223 throw FileFormatException(
224 key
.getRegistryName(),
225 ("legacy format: cannot open sub-key " + path
+ " of "
226 + key
.getName() + ": " + OUString::number(e
)));
228 std::vector
< char > buf
;
229 typereg::Reader
reader(getReader(sub
, &buf
));
230 switch (reader
.getTypeClass()) {
231 case RT_TYPE_INTERFACE
:
233 std::vector
< AnnotatedReference
> mandBases
;
234 sal_uInt16 n
= reader
.getSuperTypeCount();
235 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
238 reader
.getSuperTypeName(j
).replace('/', '.'),
239 std::vector
< OUString
>()));
241 std::vector
< AnnotatedReference
> optBases
;
242 n
= reader
.getReferenceCount();
243 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
246 reader
.getReferenceTypeName(j
).replace('/', '.'),
247 translateAnnotations(
248 reader
.getReferenceDocumentation(j
))));
250 sal_uInt16 methodCount
= reader
.getMethodCount();
251 std::vector
< InterfaceTypeEntity::Attribute
> attrs
;
252 n
= reader
.getFieldCount(); // attributes
253 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
254 OUString
attrName(reader
.getFieldName(j
));
255 std::vector
< OUString
> getExcs
;
256 std::vector
< OUString
> setExcs
;
257 for (sal_uInt16 k
= 0; k
!= methodCount
; ++k
) {
258 if (reader
.getMethodName(k
) == attrName
) {
259 switch (reader
.getMethodFlags(k
)) {
260 case RT_MODE_ATTRIBUTE_GET
:
263 = reader
.getMethodExceptionCount(k
);
264 for (sal_uInt16 l
= 0; l
!= m
; ++l
) {
266 reader
.getMethodExceptionTypeName(k
, l
).
271 case RT_MODE_ATTRIBUTE_SET
:
274 = reader
.getMethodExceptionCount(k
);
275 for (sal_uInt16 l
= 0; l
!= m
; ++l
) {
277 reader
.getMethodExceptionTypeName(k
, l
).
283 throw FileFormatException(
284 key
.getRegistryName(),
285 ("legacy format: method and attribute with same"
287 + " in interface type with key "
292 RTFieldAccess flags
= reader
.getFieldFlags(j
);
294 InterfaceTypeEntity::Attribute(
295 attrName
, reader
.getFieldTypeName(j
).replace('/', '.'),
296 (flags
& RT_ACCESS_BOUND
) != 0,
297 (flags
& RT_ACCESS_READONLY
) != 0, getExcs
, setExcs
,
298 translateAnnotations(reader
.getFieldDocumentation(j
))));
300 std::vector
< InterfaceTypeEntity::Method
> meths
;
301 for (sal_uInt16 j
= 0; j
!= methodCount
; ++j
) {
302 RTMethodMode flags
= reader
.getMethodFlags(j
);
303 if (flags
!= RT_MODE_ATTRIBUTE_GET
304 && flags
!= RT_MODE_ATTRIBUTE_SET
)
306 std::vector
< InterfaceTypeEntity::Method::Parameter
>
308 sal_uInt16 m
= reader
.getMethodParameterCount(j
);
309 for (sal_uInt16 k
= 0; k
!= m
; ++k
) {
310 RTParamMode mode
= reader
.getMethodParameterFlags(j
, k
);
311 InterfaceTypeEntity::Method::Parameter::Direction dir
;
314 dir
= InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
;
317 dir
= InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT
;
320 dir
= InterfaceTypeEntity::Method::Parameter::DIRECTION_IN_OUT
;
323 throw FileFormatException(
324 key
.getRegistryName(),
325 ("legacy format: unexpected mode "
326 + OUString::number(mode
) + " of parameter "
327 + reader
.getMethodParameterName(j
, k
)
328 + " of method " + reader
.getMethodName(j
)
329 + " in interface type with key "
333 InterfaceTypeEntity::Method::Parameter(
334 reader
.getMethodParameterName(j
, k
),
335 (reader
.getMethodParameterTypeName(j
, k
).
339 std::vector
< OUString
> excs
;
340 m
= reader
.getMethodExceptionCount(j
);
341 for (sal_uInt16 k
= 0; k
!= m
; ++k
) {
343 reader
.getMethodExceptionTypeName(j
, k
).replace(
347 InterfaceTypeEntity::Method(
348 reader
.getMethodName(j
),
349 reader
.getMethodReturnTypeName(j
).replace('/', '.'),
351 translateAnnotations(
352 reader
.getMethodDocumentation(j
))));
355 return new InterfaceTypeEntity(
356 reader
.isPublished(), mandBases
, optBases
, attrs
, meths
,
357 translateAnnotations(reader
.getDocumentation()));
360 return new Module(manager
, ucr
, sub
);
363 sal_uInt32 n
= reader
.getReferenceCount();
366 switch (reader
.getSuperTypeCount()) {
370 base
= reader
.getSuperTypeName(0).replace('/', '.');
374 key
.getRegistryName(),
375 ("legacy format: unexpected number "
376 + OUString::number(reader
.getSuperTypeCount())
377 + " of super-types of plain struct type with key "
380 std::vector
< PlainStructTypeEntity::Member
> mems
;
381 n
= reader
.getFieldCount();
382 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
384 PlainStructTypeEntity::Member(
385 reader
.getFieldName(j
),
386 reader
.getFieldTypeName(j
).replace('/', '.'),
387 translateAnnotations(
388 reader
.getFieldDocumentation(j
))));
390 return new PlainStructTypeEntity(
391 reader
.isPublished(), base
, mems
,
392 translateAnnotations(reader
.getDocumentation()));
394 if (reader
.getSuperTypeCount() != 0) {
396 key
.getRegistryName(),
397 ("legacy format: unexpected number "
398 + OUString::number(reader
.getSuperTypeCount())
399 + " of super-types of polymorphic struct type template"
400 " with key " + sub
.getName()));
402 std::vector
< OUString
> params
;
403 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
405 reader
.getReferenceTypeName(j
).replace('/', '.'));
407 std::vector
< PolymorphicStructTypeTemplateEntity::Member
> mems
;
408 n
= reader
.getFieldCount();
409 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
411 PolymorphicStructTypeTemplateEntity::Member(
412 reader
.getFieldName(j
),
413 reader
.getFieldTypeName(j
).replace('/', '.'),
414 ((reader
.getFieldFlags(j
)
415 & RT_ACCESS_PARAMETERIZED_TYPE
)
417 translateAnnotations(
418 reader
.getFieldDocumentation(j
))));
420 return new PolymorphicStructTypeTemplateEntity(
421 reader
.isPublished(), params
, mems
,
422 translateAnnotations(reader
.getDocumentation()));
427 std::vector
< EnumTypeEntity::Member
> mems
;
428 sal_uInt16 n
= reader
.getFieldCount();
429 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
430 RTConstValue
v(reader
.getFieldValue(j
));
431 if (v
.m_type
!= RT_TYPE_INT32
) {
433 key
.getRegistryName(),
434 ("legacy format: unexpected type "
435 + OUString::number(v
.m_type
) + " of value of field "
436 + reader
.getFieldName(j
) + " of enum type with key "
440 EnumTypeEntity::Member(
441 reader
.getFieldName(j
), v
.m_value
.aLong
,
442 translateAnnotations(reader
.getFieldDocumentation(j
))));
445 return new EnumTypeEntity(
446 reader
.isPublished(), mems
,
447 translateAnnotations(reader
.getDocumentation()));
449 case RT_TYPE_EXCEPTION
:
452 switch (reader
.getSuperTypeCount()) {
456 base
= reader
.getSuperTypeName(0).replace('/', '.');
459 throw FileFormatException(
460 key
.getRegistryName(),
461 ("legacy format: unexpected number "
462 + OUString::number(reader
.getSuperTypeCount())
463 + " of super-types of exception type with key "
466 std::vector
< ExceptionTypeEntity::Member
> mems
;
467 sal_uInt16 n
= reader
.getFieldCount();
468 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
470 ExceptionTypeEntity::Member(
471 reader
.getFieldName(j
),
472 reader
.getFieldTypeName(j
).replace('/', '.'),
473 translateAnnotations(reader
.getFieldDocumentation(j
))));
475 return new ExceptionTypeEntity(
476 reader
.isPublished(), base
, mems
,
477 translateAnnotations(reader
.getDocumentation()));
479 case RT_TYPE_TYPEDEF
:
480 if (reader
.getSuperTypeCount() != 1) {
481 throw FileFormatException(
482 key
.getRegistryName(),
483 ("legacy format: unexpected number "
484 + OUString::number(reader
.getSuperTypeCount())
485 + " of super-types of typedef with key " + sub
.getName()));
487 return new TypedefEntity(
488 reader
.isPublished(), reader
.getSuperTypeName(0).replace('/', '.'),
489 translateAnnotations(reader
.getDocumentation()));
490 case RT_TYPE_SERVICE
:
491 switch (reader
.getSuperTypeCount()) {
494 std::vector
< AnnotatedReference
> mandServs
;
495 std::vector
< AnnotatedReference
> optServs
;
496 std::vector
< AnnotatedReference
> mandIfcs
;
497 std::vector
< AnnotatedReference
> optIfcs
;
498 sal_uInt16 n
= reader
.getReferenceCount();
499 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
500 AnnotatedReference
base(
501 reader
.getReferenceTypeName(j
).replace('/', '.'),
502 translateAnnotations(
503 reader
.getReferenceDocumentation(j
)));
504 switch (reader
.getReferenceSort(j
)) {
506 if ((reader
.getReferenceFlags(j
) & RT_ACCESS_OPTIONAL
)
509 mandServs
.push_back(base
);
511 optServs
.push_back(base
);
514 case RT_REF_SUPPORTS
:
515 if ((reader
.getReferenceFlags(j
) & RT_ACCESS_OPTIONAL
)
518 mandIfcs
.push_back(base
);
520 optIfcs
.push_back(base
);
524 throw FileFormatException(
525 key
.getRegistryName(),
526 ("legacy format: unexpected mode "
527 + OUString::number(reader
.getReferenceSort(j
))
528 + " of reference " + reader
.getReferenceTypeName(j
)
529 + " in service with key " + sub
.getName()));
532 std::vector
< AccumulationBasedServiceEntity::Property
> props
;
533 n
= reader
.getFieldCount();
534 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
535 RTFieldAccess acc
= reader
.getFieldFlags(j
);
537 if ((acc
& RT_ACCESS_READONLY
) != 0) {
538 attrs
|= AccumulationBasedServiceEntity::Property::
541 if ((acc
& RT_ACCESS_OPTIONAL
) != 0) {
542 attrs
|= AccumulationBasedServiceEntity::Property::
545 if ((acc
& RT_ACCESS_MAYBEVOID
) != 0) {
546 attrs
|= AccumulationBasedServiceEntity::Property::
547 ATTRIBUTE_MAYBE_VOID
;
549 if ((acc
& RT_ACCESS_BOUND
) != 0) {
550 attrs
|= AccumulationBasedServiceEntity::Property::
553 if ((acc
& RT_ACCESS_CONSTRAINED
) != 0) {
554 attrs
|= AccumulationBasedServiceEntity::Property::
555 ATTRIBUTE_CONSTRAINED
;
557 if ((acc
& RT_ACCESS_TRANSIENT
) != 0) {
558 attrs
|= AccumulationBasedServiceEntity::Property::
561 if ((acc
& RT_ACCESS_MAYBEAMBIGUOUS
) != 0) {
562 attrs
|= AccumulationBasedServiceEntity::Property::
563 ATTRIBUTE_MAYBE_AMBIGUOUS
;
565 if ((acc
& RT_ACCESS_MAYBEDEFAULT
) != 0) {
566 attrs
|= AccumulationBasedServiceEntity::Property::
567 ATTRIBUTE_MAYBE_DEFAULT
;
569 if ((acc
& RT_ACCESS_REMOVEABLE
) != 0) {
570 attrs
|= AccumulationBasedServiceEntity::Property::
574 AccumulationBasedServiceEntity::Property(
575 reader
.getFieldName(j
),
576 reader
.getFieldTypeName(j
).replace('/', '.'),
578 AccumulationBasedServiceEntity::Property::
580 translateAnnotations(
581 reader
.getFieldDocumentation(j
))));
583 return new AccumulationBasedServiceEntity(
584 reader
.isPublished(), mandServs
, optServs
, mandIfcs
,
586 translateAnnotations(reader
.getDocumentation()));
590 std::vector
< SingleInterfaceBasedServiceEntity::Constructor
>
592 sal_uInt16 n
= reader
.getMethodCount();
593 if (n
== 1 && reader
.getMethodFlags(0) == RT_MODE_TWOWAY
594 && reader
.getMethodName(0).isEmpty()
595 && reader
.getMethodReturnTypeName(0) == "void"
596 && reader
.getMethodParameterCount(0) == 0
597 && reader
.getMethodExceptionCount(0) == 0)
600 SingleInterfaceBasedServiceEntity::Constructor());
602 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
603 if (reader
.getMethodFlags(j
) != RT_MODE_TWOWAY
) {
604 throw FileFormatException(
605 key
.getRegistryName(),
606 ("legacy format: unexpected mode "
607 + OUString::number(reader
.getMethodFlags(j
))
608 + " of constructor " + reader
.getMethodName(j
)
609 + " in service with key " + sub
.getName()));
612 SingleInterfaceBasedServiceEntity::Constructor::
614 sal_uInt16 m
= reader
.getMethodParameterCount(j
);
615 for (sal_uInt16 k
= 0; k
!= m
; ++k
) {
617 = reader
.getMethodParameterFlags(j
, k
);
618 if ((mode
& ~RT_PARAM_REST
) != RT_PARAM_IN
) {
619 throw FileFormatException(
620 key
.getRegistryName(),
621 ("legacy format: unexpected mode "
622 + OUString::number(mode
)
624 + reader
.getMethodParameterName(j
, k
)
626 + reader
.getMethodName(j
)
627 + " in service with key "
630 if ((mode
& RT_PARAM_REST
) != 0
632 && ((reader
.getMethodParameterTypeName(
636 throw FileFormatException(
637 key
.getRegistryName(),
638 ("legacy format: bad rest parameter "
639 + reader
.getMethodParameterName(j
, k
)
641 + reader
.getMethodName(j
)
642 + " in service with key "
646 SingleInterfaceBasedServiceEntity::Constructor::
648 reader
.getMethodParameterName(j
, k
),
649 (reader
.getMethodParameterTypeName(j
, k
).
651 (mode
& RT_PARAM_REST
) != 0));
653 std::vector
< OUString
> excs
;
654 m
= reader
.getMethodExceptionCount(j
);
655 for (sal_uInt16 k
= 0; k
!= m
; ++k
) {
657 reader
.getMethodExceptionTypeName(j
, k
).replace(
661 SingleInterfaceBasedServiceEntity::Constructor(
662 reader
.getMethodName(j
), params
, excs
,
663 translateAnnotations(
664 reader
.getMethodDocumentation(j
))));
667 return new SingleInterfaceBasedServiceEntity(
668 reader
.isPublished(),
669 reader
.getSuperTypeName(0).replace('/', '.'), ctors
,
670 translateAnnotations(reader
.getDocumentation()));
673 throw FileFormatException(
674 key
.getRegistryName(),
675 ("legacy format: unexpected number "
676 + OUString::number(reader
.getSuperTypeCount())
677 + " of super-types of service with key " + sub
.getName()));
679 case RT_TYPE_SINGLETON
:
681 if (reader
.getSuperTypeCount() != 1) {
682 throw FileFormatException(
683 key
.getRegistryName(),
684 ("legacy format: unexpected number "
685 + OUString::number(reader
.getSuperTypeCount())
686 + " of super-types of singleton with key "
689 OUString
basePath(reader
.getSuperTypeName(0));
690 OUString
baseName(basePath
.replace('/', '.'));
692 rtl::Reference
< Entity
> base(manager
->findEntity(baseName
));
694 switch (base
->getSort()) {
695 case Entity::SORT_INTERFACE_TYPE
:
698 case Entity::SORT_ACCUMULATION_BASED_SERVICE
:
702 throw FileFormatException(
703 key
.getRegistryName(),
704 ("legacy format: unexpected sort "
705 + OUString::number(base
->getSort()) + " of base "
706 + baseName
+ " of singleton with key "
711 e
= ucr
.openKey(basePath
, key2
);
715 case REG_KEY_NOT_EXISTS
:
716 throw FileFormatException(
717 key
.getRegistryName(),
718 ("legacy format: unknown super-type " + basePath
719 + " of super-type with key " + sub
.getName()));
721 throw FileFormatException(
722 key
.getRegistryName(),
723 ("legacy format: cannot open ucr sub-key " + basePath
724 + ": " + OUString::number(e
)));
726 std::vector
< char > buf2
;
727 typereg::Reader
reader2(getReader(key2
, &buf2
));
728 switch (reader2
.getTypeClass()) {
729 case RT_TYPE_INTERFACE
:
732 case RT_TYPE_SERVICE
:
736 throw FileFormatException(
737 key
.getRegistryName(),
738 ("legacy format: unexpected type class "
739 + OUString::number(reader2
.getTypeClass())
740 + " of super-type with key " + key2
.getName()
741 + " of singleton with key " + sub
.getName()));
745 ? rtl::Reference
< Entity
>(
746 new InterfaceBasedSingletonEntity(
747 reader
.isPublished(), baseName
,
748 translateAnnotations(reader
.getDocumentation())))
749 : rtl::Reference
< Entity
>(
750 new ServiceBasedSingletonEntity(
751 reader
.isPublished(), baseName
,
752 translateAnnotations(reader
.getDocumentation())));
754 case RT_TYPE_CONSTANTS
:
756 std::vector
< ConstantGroupEntity::Member
> mems
;
757 sal_uInt16 n
= reader
.getFieldCount();
758 for (sal_uInt16 j
= 0; j
!= n
; ++j
) {
760 ConstantGroupEntity::Member(
761 reader
.getFieldName(j
),
762 translateConstantValue(sub
, reader
.getFieldValue(j
)),
763 translateAnnotations(reader
.getFieldDocumentation(j
))));
765 return new ConstantGroupEntity(
766 reader
.isPublished(), mems
,
767 translateAnnotations(reader
.getDocumentation()));
770 throw FileFormatException(
771 key
.getRegistryName(),
772 ("legacy format: unexpected type class "
773 + OUString::number(reader
.getTypeClass()) + " of key "
780 LegacyProvider::LegacyProvider(
781 rtl::Reference
< Manager
> const & manager
, OUString
const & uri
):
785 RegError e
= reg
.open(uri
, REG_READONLY
);
789 case REG_REGISTRY_NOT_EXISTS
:
790 throw NoSuchFileException(uri
);
792 throw FileFormatException(
793 uri
, "cannot open legacy file: " + OUString::number(e
));
796 e
= reg
.openRootKey(root
);
797 if (e
!= REG_NO_ERROR
) {
798 throw FileFormatException(
799 uri
, "legacy format: cannot open root key: " + OUString::number(e
));
801 e
= root
.openKey("UCR", ucr_
);
804 case REG_KEY_NOT_EXISTS
: // such effectively empty files exist in the wild
807 throw FileFormatException(
808 uri
, "legacy format: cannot open UCR key: " + OUString::number(e
));
812 rtl::Reference
< MapCursor
> LegacyProvider::createRootCursor() const {
813 return new Cursor(manager_
, ucr_
, ucr_
);
816 rtl::Reference
< Entity
> LegacyProvider::findEntity(OUString
const & name
)
819 return ucr_
.isValid()
820 ? readEntity(manager_
, ucr_
, ucr_
, name
.replace('.', '/'), true)
821 : rtl::Reference
< Entity
>();
824 LegacyProvider::~LegacyProvider() throw () {}
828 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */