libreoffice/framework/inc/classes/protocolhandlercache.hxx

152 lines
6.0 KiB
C++
Raw Normal View History

2010-10-27 13:11:31 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by: Armin Le Grand. #118558# Correcting OLE attributes of LO3.4 at load time by loading as OOo3.3, details see task. http://svn.apache.org/viewvc?view=revision&revision=1195906 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles http://svn.apache.org/viewvc?view=revision&revision=1293316 #119337# Solves the wrong get/setPropertyValue calls in SvxShapeText (and thus in SvxOle2Shape) http://svn.apache.org/viewvc?view=revision&revision=1344156 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117717#: remove wrong assertion http://svn.apache.org/viewvc?view=revision&revision=1172349 Patch contributed by Herbert Duerr goodbye Registration and License dialogs, don't let the door hit you http://svn.apache.org/viewvc?view=revision&revision=1172613 help gcc 4.6.0 on 32bit ubuntu 11.10" http://svn.apache.org/viewvc?view=revision&revision=1245357 Do not add targets for junit tests when junit is disabled. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1241508 Revert "sb140: #i117082# avoid unncessary static class data members commit 21d97438e2944861e26e4984195f959a0cce1e41. remove obsolete FreeBSD visibility special case. retain consolidated BSD bridge code, remove OS/2 pieces.
2012-11-12 17:21:24 +00:00
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2002-05-02 10:34:58 +00:00
#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_PROTOCOLHANDLERCACHE_HXX
#define INCLUDED_FRAMEWORK_INC_CLASSES_PROTOCOLHANDLERCACHE_HXX
2002-05-02 10:34:58 +00:00
#include <general.h>
#include <stdtypes.h>
#include <com/sun/star/util/URL.hpp>
#include <unotools/configitem.hxx>
#include <rtl/ustring.hxx>
#include <fwidllapi.h>
2002-05-02 10:34:58 +00:00
namespace framework{
#define PACKAGENAME_PROTOCOLHANDLER "Office.ProtocolHandler" /// name of our configuration package
2002-05-02 10:34:58 +00:00
#define CFG_PATH_SEPARATOR "/" /// separator for configuration paths
2002-05-02 10:34:58 +00:00
#define PROPERTY_PROTOCOLS "Protocols" /// properties of a protocol handler
2002-05-02 10:34:58 +00:00
/**
Programmer can register his own services to handle different protocols.
Don't forget: It doesn't mean "handling of documents" ... these services could handle protocols ...
e.g. "mailto:", "file://", ".java:"
2002-05-02 10:34:58 +00:00
This struct holds the information about one such registered protocol handler.
A list of handler objects is defined as ProtocolHandlerHash. see below
*/
struct FWI_DLLPUBLIC ProtocolHandler
2002-05-02 10:34:58 +00:00
{
/* member */
public:
/// the uno implementation name of this handler
OUString m_sUNOName;
2002-05-02 10:34:58 +00:00
/// list of URL pattern which defines the protocols which this handler is registered for
std::vector<OUString> m_lProtocols;
2002-05-02 10:34:58 +00:00
};
/**
This hash use registered pattern of all protocol handlers as keys and provide her
uno implementation names as value. Overloading of the index operator makes it possible
to search for a key by using a full qualified URL on list of all possible pattern keys.
*/
typedef std::unordered_map<OUString, OUString, OUStringHash> PatternHash;
2002-05-02 10:34:58 +00:00
/**
This hash holds protocol handler structs by her names.
*/
typedef std::unordered_map<OUString, ProtocolHandler, OUStringHash> HandlerHash;
2002-05-02 10:34:58 +00:00
/**
@short this hash makes it easy to find a protocol handler by using his uno implementation name.
@descr It holds two lists of information:
2002-05-02 10:34:58 +00:00
- first holds all handler by her uno implementation names and
can be used to get her other properties
- another one maps her registered pattern to her uno names to
perform search on such data
But this lists a static for all instances of this class. So it's possible to
create new objects without opening configuration twice and free memory automatically
2002-05-02 10:34:58 +00:00
if last object will gone.
@attention We implement a singleton concept - so we don't need any mutex member here.
2002-05-02 10:34:58 +00:00
Because to safe access on static member we must use a static global lock
here too.
@devstatus ready to use
@threadsafe yes
*/
class HandlerCFGAccess;
class FWI_DLLPUBLIC HandlerCache final
2002-05-02 10:34:58 +00:00
{
/* member */
private:
/// list of all registered handler registered by her uno implementation names
static HandlerHash* m_pHandler;
/// maps URL pattern to handler names
static PatternHash* m_pPattern;
/// informs about config updates
static HandlerCFGAccess* m_pConfig;
2002-05-02 10:34:58 +00:00
/// ref count to construct/destruct internal member lists on demand by using singleton mechanism
static sal_Int32 m_nRefCount;
/* interface */
public:
HandlerCache();
~HandlerCache();
2002-05-02 10:34:58 +00:00
bool search( const OUString& sURL, ProtocolHandler* pReturn ) const;
bool search( const css::util::URL& aURL, ProtocolHandler* pReturn ) const;
void takeOver(HandlerHash* pHandler, PatternHash* pPattern);
2002-05-02 10:34:58 +00:00
};
/**
@short implements configuration access for handler configuration
@descr We use the ConfigItem mechanism to read/write values from/to configuration.
We set a data container pointer for filling or reading ... this class use it temp.
After successfully calling of read(), we can use filled container directly or merge it with an existing one.
After successfully calling of write() all values of given data container are flushed to our configuration -
but current implementation doesn't support writing really.
2002-05-02 10:34:58 +00:00
@base ::utl::ConfigItem
base mechanism for configuration access
@devstatus ready to use
@threadsafe no
*/
class FWI_DLLPUBLIC HandlerCFGAccess : public ::utl::ConfigItem
2002-05-02 10:34:58 +00:00
{
private:
HandlerCache* m_pCache;
virtual void ImplCommit() override;
2002-05-02 10:34:58 +00:00
/* interface */
public:
HandlerCFGAccess( const OUString& sPackage );
2002-05-02 10:34:58 +00:00
void read ( HandlerHash** ppHandler ,
PatternHash** ppPattern );
void setCache(HandlerCache* pCache) {m_pCache = pCache;};
virtual void Notify(const css::uno::Sequence< OUString >& lPropertyNames) override;
2002-05-02 10:34:58 +00:00
};
} // namespace framework
#endif // INCLUDED_FRAMEWORK_INC_CLASSES_PROTOCOLHANDLERCACHE_HXX
2010-10-27 13:11:31 +01:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */