Kaydet (Commit) 2d1c4141 authored tarafından Caolán McNamara's avatar Caolán McNamara

UnoStorageHolder is never ctored, follow logical consequences of that

üst ac1530a3
......@@ -78,7 +78,6 @@ $(eval $(call gb_Library_add_exception_objects,sot,\
sot/source/sdstor/storage \
sot/source/sdstor/storinfo \
sot/source/sdstor/ucbstorage \
sot/source/sdstor/unostorageholder \
))
# vim: set noet sw=4 ts=4:
......@@ -45,11 +45,6 @@
#include "sot/storinfo.hxx"
#include "sot/sotdllapi.h"
#include <list>
class UNOStorageHolder;
typedef ::std::list< UNOStorageHolder* > UNOStorageHolderList;
class Storage;
class StorageStream;
class StgIo;
......@@ -371,10 +366,6 @@ public:
sal_Bool GetProperty( const String& rName, ::com::sun::star::uno::Any& rValue );
sal_Bool GetProperty( const String& rEleName, const String& rName, ::com::sun::star::uno::Any& rValue );
// HACK to avoid incompatible build, can be done since this feature is only for development
// should be removed before release
UNOStorageHolderList* GetUNOStorageHolderList();
//#if _SOLAR__PRIVATE
UCBStorageElement_Impl* FindElement_Impl( const String& rName ) const;
sal_Bool CopyStorageElement_Impl( UCBStorageElement_Impl& rElement,
......
......@@ -232,8 +232,6 @@ public:
static sal_Bool IsOLEStorage( const String & rFileName );
static sal_Bool IsOLEStorage( SvStream* pStream );
void RemoveUNOStorageHolder( UNOStorageHolder* pHolder );
static SotStorage* OpenOLEStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage,
const String& rEleName, StreamMode = STREAM_STD_READWRITE );
static sal_Int32 GetFormatID( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
......
......@@ -50,8 +50,6 @@
#include <unotools/ucbhelper.hxx>
#include <comphelper/processfactory.hxx>
#include "unostorageholder.hxx"
using namespace ::com::sun::star;
/************** class SotStorageStream ***********************************/
......@@ -710,25 +708,6 @@ SotStorage::~SotStorage()
delete m_pStorStm;
}
/*************************************************************************
|* SotStorage::RemoveUNOStorageHolder()
|*
|* Beschreibung
*************************************************************************/
void SotStorage::RemoveUNOStorageHolder( UNOStorageHolder* pHolder )
{
UCBStorage* pStg = PTR_CAST( UCBStorage, m_pOwnStg );
if ( pStg )
{
pStg->GetUNOStorageHolderList()->remove( pHolder );
pHolder->release();
}
else
{
OSL_FAIL("Not implemented!");
}
}
/*************************************************************************
|* SotStorage::CreateMemoryStream()
|*
......
......@@ -73,8 +73,6 @@
#include <sot/formats.hxx>
#include "sot/clsids.hxx"
#include "unostorageholder.hxx"
#include <vector>
using namespace ::com::sun::star::lang;
......@@ -513,7 +511,6 @@ public:
sal_Bool m_bRepairPackage;
Reference< XProgressHandler > m_xProgressHandler;
UNOStorageHolderList* m_pUNOStorageHolderList;
UCBStorage_Impl( const ::ucbhelper::Content&, const String&, StreamMode, UCBStorage*, sal_Bool, sal_Bool, sal_Bool = sal_False, Reference< XProgressHandler > = Reference< XProgressHandler >() );
UCBStorage_Impl( const String&, StreamMode, UCBStorage*, sal_Bool, sal_Bool, sal_Bool = sal_False, Reference< XProgressHandler > = Reference< XProgressHandler >() );
UCBStorage_Impl( SvStream&, UCBStorage*, sal_Bool );
......@@ -1662,8 +1659,6 @@ UCBStorage_Impl::UCBStorage_Impl( const ::ucbhelper::Content& rContent, const St
, m_aClassId( SvGlobalName() )
, m_bRepairPackage( bIsRepair )
, m_xProgressHandler( xProgressHandler )
, m_pUNOStorageHolderList( NULL )
{
String aName( rName );
if( !aName.Len() )
......@@ -1697,7 +1692,6 @@ UCBStorage_Impl::UCBStorage_Impl( const String& rName, StreamMode nMode, UCBStor
, m_aClassId( SvGlobalName() )
, m_bRepairPackage( bIsRepair )
, m_xProgressHandler( xProgressHandler )
, m_pUNOStorageHolderList( NULL )
{
String aName( rName );
if( !aName.Len() )
......@@ -1748,7 +1742,6 @@ UCBStorage_Impl::UCBStorage_Impl( SvStream& rStream, UCBStorage* pStorage, sal_B
, m_nFormat( 0 )
, m_aClassId( SvGlobalName() )
, m_bRepairPackage( sal_False )
, m_pUNOStorageHolderList( NULL )
{
// opening in direct mode is too fuzzy because the data is transferred to the stream in the Commit() call,
// which will be called in the storages' dtor
......@@ -2176,21 +2169,6 @@ void UCBStorage_Impl::GetProps( sal_Int32& nProps, Sequence < Sequence < Propert
UCBStorage_Impl::~UCBStorage_Impl()
{
if ( m_pUNOStorageHolderList )
{
for ( UNOStorageHolderList::iterator aIter = m_pUNOStorageHolderList->begin();
aIter != m_pUNOStorageHolderList->end(); ++aIter )
if ( *aIter )
{
(*aIter)->InternalDispose();
(*aIter)->release();
(*aIter) = NULL;
}
m_pUNOStorageHolderList->clear();
DELETEZ( m_pUNOStorageHolderList );
}
// first delete elements!
for ( size_t i = 0, n = m_aChildrenList.size(); i < n; ++i )
delete m_aChildrenList[ i ];
......@@ -3512,12 +3490,4 @@ sal_Bool UCBStorage::GetProperty( const String& rEleName, const String& rName, :
return sal_False;
}
UNOStorageHolderList* UCBStorage::GetUNOStorageHolderList()
{
if ( !pImp->m_pUNOStorageHolderList )
pImp->m_pUNOStorageHolderList = new UNOStorageHolderList;
return pImp->m_pUNOStorageHolderList;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sot.hxx"
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
#include "unostorageholder.hxx"
#include "sot/storinfo.hxx"
using namespace ::com::sun::star;
UNOStorageHolder::UNOStorageHolder( SotStorage& aParentStorage,
SotStorage& aStorage,
uno::Reference< embed::XStorage > xStorage,
::utl::TempFile* pTempFile )
: m_pParentStorage( &aParentStorage )
, m_rSotStorage( &aStorage )
, m_xStorage( xStorage )
, m_pTempFile( pTempFile )
{
OSL_ENSURE( m_xStorage.is() && m_pTempFile, "Wrong initialization!\n" );
if ( !m_xStorage.is() || !m_pTempFile )
throw uno::RuntimeException();
uno::Reference< embed::XTransactionBroadcaster > xTrBroadcast( m_xStorage, uno::UNO_QUERY );
if ( !xTrBroadcast.is() )
throw uno::RuntimeException();
xTrBroadcast->addTransactionListener( (embed::XTransactionListener*)this );
}
void UNOStorageHolder::InternalDispose()
{
uno::Reference< embed::XTransactionBroadcaster > xTrBroadcast( m_xStorage, uno::UNO_QUERY );
if ( xTrBroadcast.is() )
xTrBroadcast->removeTransactionListener( (embed::XTransactionListener*)this );
uno::Reference< lang::XComponent > xComponent( m_xStorage, uno::UNO_QUERY );
if ( xComponent.is() )
xComponent->dispose();
m_xStorage = uno::Reference< embed::XStorage >();
if ( m_pParentStorage )
m_pParentStorage = NULL;
if ( m_pTempFile )
{
delete m_pTempFile;
m_pTempFile = NULL;
}
if ( m_rSotStorage.Is() )
m_rSotStorage = NULL;
}
String UNOStorageHolder::GetStorageName()
{
if ( m_rSotStorage.Is() )
return m_rSotStorage->GetName();
return String();
}
void SAL_CALL UNOStorageHolder::preCommit( const lang::EventObject& /*aEvent*/ )
throw ( uno::Exception,
uno::RuntimeException )
{
// do nothing
}
void SAL_CALL UNOStorageHolder::commited( const lang::EventObject& /*aEvent*/ )
throw ( uno::RuntimeException )
{
::utl::TempFile aTmpStorFile;
if ( !aTmpStorFile.GetURL().Len() )
throw uno::RuntimeException();
uno::Reference< lang::XSingleServiceFactory > xStorageFactory(
::comphelper::getProcessServiceFactory()->createInstance(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory")) ),
uno::UNO_QUERY );
OSL_ENSURE( xStorageFactory.is(), "Can't create storage factory!\n" );
if ( !xStorageFactory.is() )
throw uno::RuntimeException();
uno::Sequence< uno::Any > aArg( 2 );
aArg[0] <<= ::rtl::OUString( aTmpStorFile.GetURL() );
aArg[1] <<= embed::ElementModes::READWRITE;
uno::Reference< embed::XStorage > xTempStorage( xStorageFactory->createInstanceWithArguments( aArg ), uno::UNO_QUERY );
OSL_ENSURE( xTempStorage.is(), "Can't open storage!\n" );
if ( !xTempStorage.is() )
throw uno::RuntimeException();
m_xStorage->copyToStorage( xTempStorage );
uno::Reference< lang::XComponent > xComp( xTempStorage, uno::UNO_QUERY );
if ( !xComp.is() )
throw uno::RuntimeException();
xComp->dispose();
SotStorageRef rTempStorage = new SotStorage( sal_True, aTmpStorFile.GetURL(), STREAM_WRITE, STORAGE_TRANSACTED );
if ( !rTempStorage.Is() || rTempStorage->GetError() != ERRCODE_NONE )
throw uno::RuntimeException();
SvStorageInfoList aSubStorInfoList;
m_rSotStorage->FillInfoList( &aSubStorInfoList );
for ( sal_uInt32 nInd = 0; nInd < aSubStorInfoList.size(); nInd++ )
{
m_rSotStorage->Remove( aSubStorInfoList[nInd].GetName() );
if ( m_rSotStorage->GetError() )
{
m_rSotStorage->ResetError();
throw uno::RuntimeException();
}
}
rTempStorage->CopyTo( m_rSotStorage );
// CopyTo does not transport unknown media type
// just workaround it
uno::Any aMediaType;
if ( rTempStorage->GetProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")), aMediaType ) )
m_rSotStorage->SetProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")), aMediaType );
m_rSotStorage->Commit();
}
void SAL_CALL UNOStorageHolder::preRevert( const lang::EventObject& /*aEvent*/ )
throw ( uno::Exception,
uno::RuntimeException )
{
// do nothing
}
void SAL_CALL UNOStorageHolder::reverted( const lang::EventObject& /*aEvent*/ )
throw ( uno::RuntimeException )
{
// do nothing, since reverting of the duplicate storage just means
// not to copy changes done for it to the original storage
}
void SAL_CALL UNOStorageHolder::disposing( const lang::EventObject& /*Source*/ )
throw ( uno::RuntimeException )
{
if ( m_pTempFile )
{
delete m_pTempFile;
m_pTempFile = NULL;
}
if ( m_rSotStorage.Is() )
m_rSotStorage = NULL;
if ( m_pParentStorage )
{
SotStorage* pTmp = m_pParentStorage;
m_pParentStorage = NULL;
pTmp->RemoveUNOStorageHolder( this ); // this statement can lead to destruction of the holder
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _UNOSTORAGEHOLDER_HXX
#define _UNOSTORAGEHOLDER_HXX
#include <com/sun/star/embed/XTransactionListener.hpp>
#include <cppuhelper/implbase1.hxx>
#include <unotools/tempfile.hxx>
#include <sot/storage.hxx>
class SotStorage;
class UNOStorageHolder : public ::cppu::WeakImplHelper1<
::com::sun::star::embed::XTransactionListener >
{
SotStorage* m_pParentStorage; // parent storage
SotStorageRef m_rSotStorage; // original substorage
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xStorage; // duplicate storage
::utl::TempFile* m_pTempFile; // temporary file used by duplicate storage
public:
UNOStorageHolder( SotStorage& aParentStorage,
SotStorage& aStorage,
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > xStorage,
::utl::TempFile* pTempFile );
void InternalDispose();
String GetStorageName();
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetDuplicateStorage() { return m_xStorage; }
virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent )
throw ( ::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent )
throw ( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent )
throw ( ::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent )
throw ( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
throw ( ::com::sun::star::uno::RuntimeException );
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1552,8 +1552,6 @@ TransferableDataHelper::GetInterface(com::sun::star::datatransfer::DataFlavor co
TypeName::TypeName(char*, unsigned int, unsigned int, unsigned short, int, int)
UCBStorage::IsStorageFile(String const&)
UCBStream::UCBStream(com::sun::star::uno::Reference<com::sun::star::io::XOutputStream>&)
UNOStorageHolder::GetStorageName()
UNOStorageHolder::UNOStorageHolder(SotStorage&, SotStorage&, com::sun::star::uno::Reference<com::sun::star::embed::XStorage>, utl::TempFile*)
UShortCont::Sort()
UniqueIndex::Replace(unsigned long, void*)
UnoComboBoxControl::getActionListeners()
......
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