move LifecycleProxy out of comphelper::OStorageHelper
... so it can be forward declared
This commit is contained in:
parent
c9a1a2acd5
commit
c2d3f170fb
3 changed files with 30 additions and 24 deletions
|
@ -25,8 +25,10 @@
|
||||||
* for a copy of the LGPLv3 License.
|
* for a copy of the LGPLv3 License.
|
||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#ifndef _COMPHELPER_STORAGEHELPER_HXX
|
#ifndef COMPHELPER_STORAGEHELPER_HXX
|
||||||
#define _COMPHELPER_STORAGEHELPER_HXX
|
#define COMPHELPER_STORAGEHELPER_HXX
|
||||||
|
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
#include <com/sun/star/uno/Sequence.hxx>
|
#include <com/sun/star/uno/Sequence.hxx>
|
||||||
#include <com/sun/star/uno/Reference.hxx>
|
#include <com/sun/star/uno/Reference.hxx>
|
||||||
|
@ -51,6 +53,20 @@
|
||||||
|
|
||||||
namespace comphelper {
|
namespace comphelper {
|
||||||
|
|
||||||
|
// Unfortunately - the impl.s of XStorage like to invalidate all
|
||||||
|
// their sub streams and storages when you release references, so
|
||||||
|
// it is necessary to keep references to all storages down the
|
||||||
|
// path - this is 'beautiful' (TM). So we need this ugly hack:
|
||||||
|
class COMPHELPER_DLLPUBLIC LifecycleProxy
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
public:
|
||||||
|
::boost::scoped_ptr<Impl> m_pBadness;
|
||||||
|
LifecycleProxy();
|
||||||
|
~LifecycleProxy();
|
||||||
|
};
|
||||||
|
|
||||||
class COMPHELPER_DLLPUBLIC OStorageHelper
|
class COMPHELPER_DLLPUBLIC OStorageHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -170,17 +186,6 @@ public:
|
||||||
|
|
||||||
// Methods to allow easy use of hierachical names inside storages
|
// Methods to allow easy use of hierachical names inside storages
|
||||||
|
|
||||||
// Unfortunately - the impl.s of XStorage like to invalidate all
|
|
||||||
// their sub streams and storages when you release references, so
|
|
||||||
// it is necessary to keep references to all storages down the
|
|
||||||
// path - this is 'beautiful' (TM). So we need this ugly hack:
|
|
||||||
class LifecycleProxyImpl;
|
|
||||||
class COMPHELPER_DLLPUBLIC LifecycleProxy {
|
|
||||||
public:
|
|
||||||
LifecycleProxyImpl *pBadness;
|
|
||||||
LifecycleProxy();
|
|
||||||
~LifecycleProxy();
|
|
||||||
};
|
|
||||||
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorageAtPath(
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorageAtPath(
|
||||||
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
|
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
|
||||||
const ::rtl::OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
|
const ::rtl::OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
|
||||||
|
|
|
@ -545,10 +545,11 @@ sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::r
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OStorageHelper::LifecycleProxyImpl : public std::vector< uno::Reference< embed::XStorage > > {};
|
class LifecycleProxy::Impl
|
||||||
OStorageHelper::LifecycleProxy::LifecycleProxy() :
|
: public std::vector< uno::Reference< embed::XStorage > > {};
|
||||||
pBadness( new OStorageHelper::LifecycleProxyImpl() ) { }
|
LifecycleProxy::LifecycleProxy()
|
||||||
OStorageHelper::LifecycleProxy::~LifecycleProxy() { delete pBadness; }
|
: m_pBadness( new Impl() ) { }
|
||||||
|
LifecycleProxy::~LifecycleProxy() { }
|
||||||
|
|
||||||
static void splitPath( std::vector<rtl::OUString> &rElems,
|
static void splitPath( std::vector<rtl::OUString> &rElems,
|
||||||
const ::rtl::OUString& rPath )
|
const ::rtl::OUString& rPath )
|
||||||
|
@ -560,14 +561,14 @@ static void splitPath( std::vector<rtl::OUString> &rElems,
|
||||||
static uno::Reference< embed::XStorage > LookupStorageAtPath(
|
static uno::Reference< embed::XStorage > LookupStorageAtPath(
|
||||||
const uno::Reference< embed::XStorage > &xParentStorage,
|
const uno::Reference< embed::XStorage > &xParentStorage,
|
||||||
std::vector<rtl::OUString> &rElems, sal_uInt32 nOpenMode,
|
std::vector<rtl::OUString> &rElems, sal_uInt32 nOpenMode,
|
||||||
OStorageHelper::LifecycleProxy &rNastiness )
|
LifecycleProxy &rNastiness )
|
||||||
{
|
{
|
||||||
uno::Reference< embed::XStorage > xStorage( xParentStorage );
|
uno::Reference< embed::XStorage > xStorage( xParentStorage );
|
||||||
rNastiness.pBadness->push_back( xStorage );
|
rNastiness.m_pBadness->push_back( xStorage );
|
||||||
for( size_t i = 0; i < rElems.size() && xStorage.is(); i++ )
|
for( size_t i = 0; i < rElems.size() && xStorage.is(); i++ )
|
||||||
{
|
{
|
||||||
xStorage = xStorage->openStorageElement( rElems[i], nOpenMode );
|
xStorage = xStorage->openStorageElement( rElems[i], nOpenMode );
|
||||||
rNastiness.pBadness->push_back( xStorage );
|
rNastiness.m_pBadness->push_back( xStorage );
|
||||||
}
|
}
|
||||||
return xStorage;
|
return xStorage;
|
||||||
}
|
}
|
||||||
|
@ -575,7 +576,7 @@ static uno::Reference< embed::XStorage > LookupStorageAtPath(
|
||||||
uno::Reference< embed::XStorage > OStorageHelper::GetStorageAtPath(
|
uno::Reference< embed::XStorage > OStorageHelper::GetStorageAtPath(
|
||||||
const uno::Reference< embed::XStorage > &xStorage,
|
const uno::Reference< embed::XStorage > &xStorage,
|
||||||
const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
|
const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
|
||||||
OStorageHelper::LifecycleProxy &rNastiness )
|
LifecycleProxy &rNastiness )
|
||||||
{
|
{
|
||||||
std::vector<rtl::OUString> aElems;
|
std::vector<rtl::OUString> aElems;
|
||||||
splitPath( aElems, rPath );
|
splitPath( aElems, rPath );
|
||||||
|
@ -585,7 +586,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageAtPath(
|
||||||
uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
|
uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
|
||||||
const uno::Reference< embed::XStorage > &xParentStorage,
|
const uno::Reference< embed::XStorage > &xParentStorage,
|
||||||
const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
|
const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
|
||||||
OStorageHelper::LifecycleProxy &rNastiness )
|
LifecycleProxy &rNastiness )
|
||||||
{
|
{
|
||||||
std::vector<rtl::OUString> aElems;
|
std::vector<rtl::OUString> aElems;
|
||||||
splitPath( aElems, rPath );
|
splitPath( aElems, rPath );
|
||||||
|
@ -601,7 +602,7 @@ uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
|
||||||
uno::Reference< io::XStream > OStorageHelper::GetStreamAtPackageURL(
|
uno::Reference< io::XStream > OStorageHelper::GetStreamAtPackageURL(
|
||||||
uno::Reference< embed::XStorage > const& xParentStorage,
|
uno::Reference< embed::XStorage > const& xParentStorage,
|
||||||
const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
|
const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
|
||||||
OStorageHelper::LifecycleProxy & rNastiness)
|
LifecycleProxy & rNastiness)
|
||||||
{
|
{
|
||||||
static char const s_PkgScheme[] = "vnd.sun.star.Package:";
|
static char const s_PkgScheme[] = "vnd.sun.star.Package:";
|
||||||
if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
|
if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
|
||||||
|
|
|
@ -403,7 +403,7 @@ bool SvxXMLXTableImport::load( const rtl::OUString &rPath,
|
||||||
uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY_THROW );
|
uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY_THROW );
|
||||||
|
|
||||||
xml::sax::InputSource aParserInput;
|
xml::sax::InputSource aParserInput;
|
||||||
comphelper::OStorageHelper::LifecycleProxy aNasty;
|
comphelper::LifecycleProxy aNasty;
|
||||||
|
|
||||||
if( !bUseStorage || !xStorage.is() )
|
if( !bUseStorage || !xStorage.is() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue