Kaydet (Commit) 12353c73 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

WIP: Experimental new binary type.rdb format

Add LegacyProvider to read the old format (requires a provider Manager, to
resolve singletons' bases, to decide whether they are interface- or service-
based).

Replace registry-based reg2bin with provider-based reg2unoidl.

Change-Id: I5865e62308cc2d9c5439211ac803d84e93aab656
üst 866ebf66
......@@ -52,7 +52,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
pdf2xml \
pdfunzip \
propex \
reg2bin \
reg2unoidl \
regsvrex \
rsc \
rscdep \
......
......@@ -35,7 +35,6 @@ ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,registry,\
StaticLibrary_registry_helper \
Executable_reg2bin \
Executable_regmerge \
Executable_regview \
Executable_regcompare \
......
This diff is collapsed.
......@@ -7,15 +7,16 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Executable_Executable,reg2bin))
$(eval $(call gb_Executable_Executable,reg2unoidl))
$(eval $(call gb_Executable_add_exception_objects,reg2bin, \
registry/tools/reg2bin \
$(eval $(call gb_Executable_add_exception_objects,reg2unoidl, \
unoidl/source/reg2unoidl \
))
$(eval $(call gb_Executable_use_libraries,reg2bin, \
reg \
$(eval $(call gb_Executable_use_libraries,reg2unoidl, \
sal \
salhelper \
unoidl \
))
# vim: set noet sw=4 ts=4:
......@@ -12,11 +12,13 @@ $(eval $(call gb_Library_Library,unoidl))
$(eval $(call gb_Library_add_defs,unoidl,-DLO_DLLIMPLEMENTATION_UNOIDL))
$(eval $(call gb_Library_add_exception_objects,unoidl, \
unoidl/source/legacyprovider \
unoidl/source/unoidl \
unoidl/source/unoidlprovider \
))
$(eval $(call gb_Library_use_libraries,unoidl, \
reg \
sal \
salhelper \
))
......
......@@ -10,6 +10,7 @@
$(eval $(call gb_Module_Module,unoidl))
$(eval $(call gb_Module_add_targets,unoidl, \
Executable_reg2unoidl \
Library_unoidl \
Package_inc \
))
......
......@@ -10,6 +10,7 @@
$(eval $(call gb_Package_Package,unoidl_inc,$(SRCDIR)/unoidl/inc/unoidl))
$(eval $(call gb_Package_add_file,unoidl_inc,inc/unoidl/detail/dllapi.hxx,detail/dllapi.hxx))
$(eval $(call gb_Package_add_file,unoidl_inc,inc/unoidl/legacyprovider.hxx,legacyprovider.hxx))
$(eval $(call gb_Package_add_file,unoidl_inc,inc/unoidl/unoidl.hxx,unoidl.hxx))
$(eval $(call gb_Package_add_file,unoidl_inc,inc/unoidl/unoidlprovider.hxx,unoidlprovider.hxx))
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_UNOIDL_LEGACYPROVIDER_HXX
#define INCLUDED_UNOIDL_LEGACYPROVIDER_HXX
#include "sal/config.h"
#include "registry/registry.hxx"
#include "rtl/ref.hxx"
#include "sal/types.h"
#include "unoidl/detail/dllapi.hxx"
#include "unoidl/unoidl.hxx"
namespace rtl { class OUString; }
namespace unoidl {
class LO_DLLPUBLIC_UNOIDL LegacyProvider: public Provider {
public:
// throws FileFormatException, NoSuchFileException:
LegacyProvider(
rtl::Reference< Manager > const & manager, rtl::OUString const & uri);
// throws FileFormatException:
virtual rtl::Reference< MapCursor > createRootCursor() const;
// throws FileFormatException:
virtual rtl::Reference< Entity > findEntity(rtl::OUString const & name)
const;
private:
virtual SAL_DLLPRIVATE ~LegacyProvider() throw ();
rtl::Reference< Manager > manager_;
mutable RegistryKey ucr_;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -601,15 +601,34 @@ public:
// throws FileFormatException:
virtual rtl::Reference< MapCursor > createRootCursor() const = 0;
// throws FileFormatException:
virtual rtl::Reference< Entity > findEntity(rtl::OUString const & name)
const = 0;
protected:
SAL_DLLPRIVATE Provider() {}
virtual SAL_DLLPRIVATE ~Provider() throw ();
};
class LO_DLLPUBLIC_UNOIDL Manager: public salhelper::SimpleReferenceObject {
public:
Manager() {}
void addProvider(rtl::Reference< Provider > const & provider);
// throws FileFormatException:
rtl::Reference< Entity > findEntity(rtl::OUString const & name) const;
private:
virtual SAL_DLLPRIVATE ~Manager() throw ();
std::vector< rtl::Reference< Provider > > providers_;
};
// throws FileFormatException, NoSuchFileException:
LO_DLLPUBLIC_UNOIDL rtl::Reference< Provider > loadProvider(
rtl::OUString const & uri);
rtl::Reference< Manager > const & manager, rtl::OUString const & uri);
}
......
......@@ -33,6 +33,10 @@ public:
// throws FileFormatException:
virtual rtl::Reference< MapCursor > createRootCursor() const;
// throws FileFormatException:
virtual rtl::Reference< Entity > findEntity(rtl::OUString const & name)
const;
// throws FileFormatException:
sal_uInt32 find(rtl::OUString const & name, bool * constant = 0) const;
......
un unoidl: sal salhelper NULL
un unoidl: registry sal salhelper NULL
un unoidl\prj nmake - all un_prj NULL
This diff is collapsed.
This diff is collapsed.
......@@ -13,6 +13,7 @@
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "unoidl/legacyprovider.hxx"
#include "unoidl/unoidl.hxx"
#include "unoidl/unoidlprovider.hxx"
......@@ -57,10 +58,41 @@ ServiceBasedSingletonEntity::~ServiceBasedSingletonEntity() throw () {}
Provider::~Provider() throw () {}
rtl::Reference< Provider > loadProvider(OUString const & uri) {
return new UnoidlProvider(uri);
rtl::Reference< Provider > loadProvider(
rtl::Reference< Manager > const & manager, OUString const & uri)
{
try {
return new UnoidlProvider(uri);
} catch (FileFormatException & e) {
SAL_INFO(
"unoidl",
"FileFormatException \"" << e.getDetail() << "\", retrying <" << uri
<< "> as legacy format");
return new LegacyProvider(manager, uri);
}
}
void Manager::addProvider(rtl::Reference< Provider > const & provider) {
assert(provider.is());
providers_.push_back(provider);
}
rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const {
//TODO: add caching
for (std::vector< rtl::Reference< Provider > >::const_iterator i(
providers_.begin());
i != providers_.end(); ++i)
{
rtl::Reference< Entity > ent((*i)->findEntity(name));
if (ent.is()) {
return ent;
}
}
return rtl::Reference< Entity >();
}
Manager::~Manager() throw () {}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1251,6 +1251,13 @@ rtl::Reference< MapCursor > UnoidlProvider::createRootCursor() const {
return new UnoidlCursor(file_, mapBegin_, mapSize_);
}
rtl::Reference< Entity > UnoidlProvider::findEntity(OUString const & name) const
{
bool cnst;
sal_uInt32 off = find(name, &cnst);
return off == 0 || cnst ? rtl::Reference< Entity >() : getEntity(off);
}
sal_uInt32 UnoidlProvider::find(OUString const & name, bool * constant) const {
detail::MapEntry const * mapBegin = mapBegin_;
sal_uInt32 mapSize = mapSize_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment