summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-22 09:30:33 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-22 13:14:18 +0000
commit988ac73e57b7e7f171fb2543de90a9afc2aa3289 (patch)
tree3412f8804f904f2507f96ffeb270428ef7a9e8f5
parentaf8c0696e56395d48f8d8d75a37ced1c58a5be17 (diff)
use std::unique_ptr
Change-Id: I11a58aa38f931c7912e2e5ac6df46f98e6bb681e Reviewed-on: https://gerrit.libreoffice.org/34539 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--package/source/xstor/xstorage.cxx255
-rw-r--r--package/source/xstor/xstorage.hxx7
-rw-r--r--sc/inc/funcuno.hxx7
-rw-r--r--sc/source/filter/inc/XclExpChangeTrack.hxx2
-rw-r--r--sc/source/filter/xcl97/XclExpChangeTrack.cxx21
-rw-r--r--sc/source/ui/inc/undoblk.hxx68
-rw-r--r--sc/source/ui/inc/undodat.hxx178
-rw-r--r--sc/source/ui/inc/undotab.hxx2
-rw-r--r--sc/source/ui/undo/undoblk.cxx60
-rw-r--r--sc/source/ui/undo/undoblk3.cxx114
-rw-r--r--sc/source/ui/undo/undodat.cxx545
-rw-r--r--sc/source/ui/undo/undotab.cxx56
-rw-r--r--sc/source/ui/unoobj/funcuno.cxx18
13 files changed, 589 insertions, 744 deletions
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 424f2c772b55..aa3007439d88 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -158,23 +158,15 @@ uno::Reference< io::XInputStream > GetSeekableTempCopy( const uno::Reference< io
return xTempIn;
}
-SotElement_Impl::SotElement_Impl( const OUString& rName, bool bStor, bool bNew )
-: m_aName( rName )
-, m_aOriginalName( rName )
-, m_bIsRemoved( false )
-, m_bIsInserted( bNew )
-, m_bIsStorage( bStor )
-, m_pStorage( nullptr )
-, m_pStream( nullptr )
+SotElement_Impl::SotElement_Impl(const OUString& rName, bool bStor, bool bNew)
+ : m_aName(rName)
+ , m_aOriginalName(rName)
+ , m_bIsRemoved(false)
+ , m_bIsInserted(bNew)
+ , m_bIsStorage(bStor)
{
}
-SotElement_Impl::~SotElement_Impl()
-{
- delete m_pStorage;
- delete m_pStream;
-}
-
// most of properties are holt by the storage but are not used
OStorage_Impl::OStorage_Impl( uno::Reference< io::XInputStream > const & xInputStream,
sal_Int32 nMode,
@@ -779,31 +771,31 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
SAL_WARN_IF( !xSubDest.is(), "package.xstor", "No destination substorage!" );
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
{
OpenSubStorage( pElement, embed::ElementModes::READ );
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
throw io::IOException( THROW_WHERE );
}
- pElement->m_pStorage->CopyToStorage( xSubDest, bDirect );
+ pElement->m_xStorage->CopyToStorage(xSubDest, bDirect);
}
else
{
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
{
OpenSubStream( pElement );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
throw io::IOException( THROW_WHERE );
}
- if ( !pElement->m_pStream->IsEncrypted() )
+ if (!pElement->m_xStream->IsEncrypted())
{
if ( bDirect )
{
// fill in the properties for the stream
uno::Sequence< beans::PropertyValue > aStrProps(0);
- uno::Sequence< beans::PropertyValue > aSrcPkgProps = pElement->m_pStream->GetStreamProperties();
+ uno::Sequence< beans::PropertyValue > aSrcPkgProps = pElement->m_xStream->GetStreamProperties();
sal_Int32 nNum = 0;
for ( int ind = 0; ind < aSrcPkgProps.getLength(); ind++ )
{
@@ -819,7 +811,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
{
aStrProps.realloc( ++nNum );
aStrProps[nNum-1].Name = "UseCommonStoragePasswordEncryption";
- aStrProps[nNum-1].Value <<= pElement->m_pStream->UsesCommonEncryption_Impl();
+ aStrProps[nNum-1].Value <<= pElement->m_xStream->UsesCommonEncryption_Impl();
}
else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
@@ -842,19 +834,19 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
uno::Reference< embed::XOptimizedStorage > xOptDest( xDest, uno::UNO_QUERY_THROW );
uno::Reference < io::XInputStream > xInputToInsert;
- if ( pElement->m_pStream->HasTempFile_Impl() || !pElement->m_pStream->m_xPackageStream.is() )
+ if (pElement->m_xStream->HasTempFile_Impl() || !pElement->m_xStream->m_xPackageStream.is())
{
- SAL_WARN_IF( !pElement->m_pStream->m_xPackageStream.is(), "package.xstor", "No package stream!" );
+ SAL_WARN_IF(!pElement->m_xStream->m_xPackageStream.is(), "package.xstor", "No package stream!");
// if the stream is modified - the temporary file must be used for insertion
- xInputToInsert = pElement->m_pStream->GetTempFileAsInputStream();
+ xInputToInsert = pElement->m_xStream->GetTempFileAsInputStream();
}
else
{
// for now get just nonseekable access to the stream
// TODO/LATER: the raw stream can be used
- xInputToInsert = pElement->m_pStream->m_xPackageStream->getDataStream();
+ xInputToInsert = pElement->m_xStream->m_xPackageStream->getDataStream();
}
if ( !xInputToInsert.is() )
@@ -869,7 +861,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
SAL_WARN_IF( !xSubStr.is(), "package.xstor", "No destination substream!" );
- pElement->m_pStream->CopyInternallyTo_Impl( xSubStr );
+ pElement->m_xStream->CopyInternallyTo_Impl(xSubStr);
}
}
else if ( m_nStorageType != embed::StorageFormats::PACKAGE )
@@ -877,8 +869,8 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
SAL_WARN( "package.xstor", "Encryption is only supported in package storage!" );
throw io::IOException( THROW_WHERE );
}
- else if ( pElement->m_pStream->HasCachedEncryptionData()
- && ( pElement->m_pStream->IsModified() || pElement->m_pStream->HasWriteOwner_Impl() ) )
+ else if ( pElement->m_xStream->HasCachedEncryptionData()
+ && ( pElement->m_xStream->IsModified() || pElement->m_xStream->HasWriteOwner_Impl() ) )
{
::comphelper::SequenceAsHashMap aCommonEncryptionData;
bool bHasCommonEncryptionData = false;
@@ -893,7 +885,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
AddLog( THROW_WHERE "No Encryption" );
}
- if ( bHasCommonEncryptionData && ::package::PackageEncryptionDatasEqual( pElement->m_pStream->GetCachedEncryptionData(), aCommonEncryptionData ) )
+ if (bHasCommonEncryptionData && ::package::PackageEncryptionDatasEqual(pElement->m_xStream->GetCachedEncryptionData(), aCommonEncryptionData))
{
// If the stream can be opened with the common storage password
// it must be stored with the common storage password as well
@@ -901,7 +893,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
xDest->openStreamElement( aName,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
- pElement->m_pStream->CopyInternallyTo_Impl( xDestStream );
+ pElement->m_xStream->CopyInternallyTo_Impl( xDestStream );
uno::Reference< beans::XPropertySet > xProps( xDestStream, uno::UNO_QUERY_THROW );
xProps->setPropertyValue(
@@ -915,10 +907,10 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
uno::Reference< io::XStream > xSubStr =
xDest2->openEncryptedStream( aName,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE,
- pElement->m_pStream->GetCachedEncryptionData().getAsConstNamedValueList() );
+ pElement->m_xStream->GetCachedEncryptionData().getAsConstNamedValueList() );
SAL_WARN_IF( !xSubStr.is(), "package.xstor", "No destination substream!" );
- pElement->m_pStream->CopyInternallyTo_Impl( xSubStr, pElement->m_pStream->GetCachedEncryptionData() );
+ pElement->m_xStream->CopyInternallyTo_Impl(xSubStr, pElement->m_xStream->GetCachedEncryptionData());
}
}
else
@@ -929,8 +921,8 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
// If the stream can be opened with the common storage password
// it must be stored with the common storage password as well
- uno::Reference< io::XStream > xOwnStream = pElement->m_pStream->GetStream( embed::ElementModes::READ,
- false );
+ uno::Reference< io::XStream > xOwnStream = pElement->m_xStream->GetStream(embed::ElementModes::READ,
+ false);
uno::Reference< io::XStream > xDestStream =
xDest->openStreamElement( aName,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
@@ -952,7 +944,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
// in the ODF1.2 package, so an invalid package could be produced if the stream
// is copied from ODF1.1 package, where it is allowed to have different StartKeys
uno::Reference< embed::XStorageRawAccess > xRawDest( xDest, uno::UNO_QUERY_THROW );
- uno::Reference< io::XInputStream > xRawInStream = pElement->m_pStream->GetRawInStream();
+ uno::Reference< io::XInputStream > xRawInStream = pElement->m_xStream->GetRawInStream();
xRawDest->insertRawEncrStreamElement( aName, xRawInStream );
}
}
@@ -1098,13 +1090,13 @@ void OStorage_Impl::Commit()
// following two steps are separated to allow easily implement transacted mode
// for streams if we need it in future.
// Only hierarchical access uses transacted streams currently
- if ( !(*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStream
- && !(*pElementIter)->m_pStream->IsTransacted() )
- (*pElementIter)->m_pStream->Commit();
+ if ( !(*pElementIter)->m_bIsStorage && (*pElementIter)->m_xStream
+ && !(*pElementIter)->m_xStream->IsTransacted() )
+ (*pElementIter)->m_xStream->Commit();
// if the storage was not open, there is no need to commit it ???
// the storage should be checked that it is committed
- if ( (*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStorage && (*pElementIter)->m_pStorage->m_bCommited )
+ if ((*pElementIter)->m_bIsStorage && (*pElementIter)->m_xStorage && (*pElementIter)->m_xStorage->m_bCommited)
{
// it's temporary PackageFolder should be inserted instead of current one
// also the new copy of PackageFolder should be used by the children storages
@@ -1113,9 +1105,9 @@ void OStorage_Impl::Commit()
if ( m_bCommited || m_bIsRoot )
xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
- (*pElementIter)->m_pStorage->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
+ (*pElementIter)->m_xStorage->InsertIntoPackageFolder((*pElementIter)->m_aName, xNewPackageFolder);
}
- else if ( !(*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStream && (*pElementIter)->m_pStream->m_bFlushed )
+ else if (!(*pElementIter)->m_bIsStorage && (*pElementIter)->m_xStream && (*pElementIter)->m_xStream->m_bFlushed)
{
if ( m_nStorageType == embed::StorageFormats::OFOPXML )
CommitStreamRelInfo( *pElementIter );
@@ -1124,7 +1116,7 @@ void OStorage_Impl::Commit()
if ( m_bCommited || m_bIsRoot )
xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
- (*pElementIter)->m_pStream->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
+ (*pElementIter)->m_xStream->InsertIntoPackageFolder((*pElementIter)->m_aName, xNewPackageFolder);
}
else if ( !m_bCommited && !m_bIsRoot )
{
@@ -1145,10 +1137,10 @@ void OStorage_Impl::Commit()
if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pElementIter)->m_bIsStorage )
{
- if ( !(*pElementIter)->m_pStream )
+ if (!(*pElementIter)->m_xStream)
{
OpenSubStream( *pElementIter );
- if ( !(*pElementIter)->m_pStream )
+ if (!(*pElementIter)->m_xStream)
throw uno::RuntimeException( THROW_WHERE );
}
@@ -1170,32 +1162,32 @@ void OStorage_Impl::Commit()
if ( (*pElementIter)->m_bIsStorage )
{
- if ( (*pElementIter)->m_pStorage->m_bCommited )
+ if ((*pElementIter)->m_xStorage->m_bCommited)
{
- OSL_ENSURE( (*pElementIter)->m_pStorage, "An inserted storage is incomplete!\n" );
- if ( !(*pElementIter)->m_pStorage )
+ OSL_ENSURE((*pElementIter)->m_xStorage, "An inserted storage is incomplete!\n");
+ if (!(*pElementIter)->m_xStorage)
throw uno::RuntimeException( THROW_WHERE );
- (*pElementIter)->m_pStorage->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
+ (*pElementIter)->m_xStorage->InsertIntoPackageFolder((*pElementIter)->m_aName, xNewPackageFolder);
(*pElementIter)->m_bIsInserted = false;
}
}
else
{
- OSL_ENSURE( (*pElementIter)->m_pStream, "An inserted stream is incomplete!\n" );
- if ( !(*pElementIter)->m_pStream )
+ OSL_ENSURE((*pElementIter)->m_xStream, "An inserted stream is incomplete!\n");
+ if (!(*pElementIter)->m_xStream)
throw uno::RuntimeException( THROW_WHERE );
- if ( !(*pElementIter)->m_pStream->IsTransacted() )
- (*pElementIter)->m_pStream->Commit();
+ if (!(*pElementIter)->m_xStream->IsTransacted())
+ (*pElementIter)->m_xStream->Commit();
- if ( (*pElementIter)->m_pStream->m_bFlushed )
+ if ((*pElementIter)->m_xStream->m_bFlushed)
{
if ( m_nStorageType == embed::StorageFormats::OFOPXML )
CommitStreamRelInfo( *pElementIter );
- (*pElementIter)->m_pStream->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
+ (*pElementIter)->m_xStream->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
(*pElementIter)->m_bIsInserted = false;
}
@@ -1372,7 +1364,7 @@ SotElement_Impl* OStorage_Impl::InsertStream( const OUString& aName, bool bEncr
// the mode is not needed for storage stream internal implementation
SotElement_Impl* pNewElement = InsertElement( aName, false );
- pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xContext, bEncr, m_nStorageType, true );
+ pNewElement->m_xStream.reset(new OWriteStream_Impl(this, xPackageSubStream, m_xPackage, m_xContext, bEncr, m_nStorageType, true));
m_aChildrenList.push_back( pNewElement );
m_bIsModified = true;
@@ -1409,9 +1401,9 @@ void OStorage_Impl::InsertRawStream( const OUString& aName, const uno::Reference
// the mode is not needed for storage stream internal implementation
SotElement_Impl* pNewElement = InsertElement( aName, false );
- pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xContext, true, m_nStorageType, false );
+ pNewElement->m_xStream.reset(new OWriteStream_Impl(this, xPackageSubStream, m_xPackage, m_xContext, true, m_nStorageType, false));
// the stream is inserted and must be treated as a committed one
- pNewElement->m_pStream->SetToBeCommited();
+ pNewElement->m_xStream->SetToBeCommited();
m_aChildrenList.push_back( pNewElement );
m_bIsModified = true;
@@ -1445,7 +1437,7 @@ SotElement_Impl* OStorage_Impl::InsertStorage( const OUString& aName, sal_Int32
{
SotElement_Impl* pNewElement = InsertElement( aName, true );
- pNewElement->m_pStorage = CreateNewStorageImpl( nStorageMode );
+ pNewElement->m_xStorage.reset(CreateNewStorageImpl(nStorageMode));
m_aChildrenList.push_back( pNewElement );
@@ -1497,7 +1489,7 @@ void OStorage_Impl::OpenSubStorage( SotElement_Impl* pElement, sal_Int32 nStorag
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
{
SAL_WARN_IF( pElement->m_bIsInserted, "package.xstor", "Inserted element must be created already!" );
@@ -1507,7 +1499,7 @@ void OStorage_Impl::OpenSubStorage( SotElement_Impl* pElement, sal_Int32 nStorag
throw container::NoSuchElementException( THROW_WHERE );
uno::Reference< container::XNameContainer > xPackageSubFolder( xTunnel, uno::UNO_QUERY_THROW );
- pElement->m_pStorage = new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType );
+ pElement->m_xStorage.reset(new OStorage_Impl(this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType));
}
}
@@ -1518,7 +1510,7 @@ void OStorage_Impl::OpenSubStream( SotElement_Impl* pElement )
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
{
SAL_WARN_IF( pElement->m_bIsInserted, "package.xstor", "Inserted element must be created already!" );
@@ -1530,7 +1522,7 @@ void OStorage_Impl::OpenSubStream( SotElement_Impl* pElement )
uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY_THROW );
// the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction
- pElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xContext, false, m_nStorageType, false, GetRelInfoStreamForName( pElement->m_aOriginalName ) );
+ pElement->m_xStream.reset(new OWriteStream_Impl(this, xPackageSubStream, m_xPackage, m_xContext, false, m_nStorageType, false, GetRelInfoStreamForName(pElement->m_aOriginalName)));
}
}
@@ -1562,8 +1554,8 @@ void OStorage_Impl::RemoveElement( SotElement_Impl* pElement )
if ( !pElement )
return;
- if ( (pElement->m_pStorage && ( pElement->m_pStorage->m_pAntiImpl || !pElement->m_pStorage->m_aReadOnlyWrapList.empty() ))
- || (pElement->m_pStream && ( pElement->m_pStream->m_pAntiImpl || !pElement->m_pStream->m_aInputStreamsList.empty() )) )
+ if ( (pElement->m_xStorage && ( pElement->m_xStorage->m_pAntiImpl || !pElement->m_xStorage->m_aReadOnlyWrapList.empty() ))
+ || (pElement->m_xStream && ( pElement->m_xStream->m_pAntiImpl || !pElement->m_xStream->m_aInputStreamsList.empty() )) )
throw io::IOException( THROW_WHERE ); // TODO: Access denied
if ( pElement->m_bIsInserted )
@@ -1582,17 +1574,8 @@ void OStorage_Impl::RemoveElement( SotElement_Impl* pElement )
void OStorage_Impl::ClearElement( SotElement_Impl* pElement )
{
- if ( pElement->m_pStorage )
- {
- delete pElement->m_pStorage;
- pElement->m_pStorage = nullptr;
- }
-
- if ( pElement->m_pStream )
- {
- delete pElement->m_pStream;
- pElement->m_pStream = nullptr;
- }
+ pElement->m_xStorage.reset();
+ pElement->m_xStream.reset();
}
void OStorage_Impl::CloneStreamElement( const OUString& aStreamName,
@@ -1609,10 +1592,10 @@ void OStorage_Impl::CloneStreamElement( const OUString& aStreamName,
else if ( pElement->m_bIsStorage )
throw io::IOException( THROW_WHERE );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
OpenSubStream( pElement );
- if ( pElement->m_pStream && pElement->m_pStream->m_xPackageStream.is() )
+ if (pElement->m_xStream && pElement->m_xStream->m_xPackageStream.is())
{
// the existence of m_pAntiImpl of the child is not interesting,
// the copy will be created internally
@@ -1623,10 +1606,10 @@ void OStorage_Impl::CloneStreamElement( const OUString& aStreamName,
// storage. The only problem is that some package streams can be accessed from outside
// at the same time (now solved by wrappers that remember own position).
- if ( bEncryptionDataProvided )
- pElement->m_pStream->GetCopyOfLastCommit( xTargetStream, aEncryptionData );
+ if (bEncryptionDataProvided)
+ pElement->m_xStream->GetCopyOfLastCommit(xTargetStream, aEncryptionData);
else
- pElement->m_pStream->GetCopyOfLastCommit( xTargetStream );
+ pElement->m_xStream->GetCopyOfLastCommit(xTargetStream);
}
else
throw io::IOException( THROW_WHERE ); // TODO: general_error
@@ -1657,18 +1640,18 @@ void OStorage_Impl::CreateRelStorage()
if ( !m_pRelStorElement )
{
m_pRelStorElement = new SotElement_Impl( "_rels", true, true );
- m_pRelStorElement->m_pStorage = CreateNewStorageImpl( embed::ElementModes::WRITE );
- if ( m_pRelStorElement->m_pStorage )
- m_pRelStorElement->m_pStorage->m_pParent = nullptr; // the relation storage is completely controlled by parent
+ m_pRelStorElement->m_xStorage.reset(CreateNewStorageImpl(embed::ElementModes::WRITE));
+ if (m_pRelStorElement->m_xStorage)
+ m_pRelStorElement->m_xStorage->m_pParent = nullptr; // the relation storage is completely controlled by parent
}
- if ( !m_pRelStorElement->m_pStorage )
+ if (!m_pRelStorElement->m_xStorage)
OpenSubStorage( m_pRelStorElement, embed::ElementModes::WRITE );
- if ( !m_pRelStorElement->m_pStorage )
+ if (!m_pRelStorElement->m_xStorage)
throw uno::RuntimeException( THROW_WHERE );
- OStorage* pResultStorage = new OStorage( m_pRelStorElement->m_pStorage, false );
+ OStorage* pResultStorage = new OStorage(m_pRelStorElement->m_xStorage.get(), false);
m_xRelStorage.set( static_cast<embed::XStorage*>(pResultStorage) );
}
}
@@ -1681,7 +1664,7 @@ void OStorage_Impl::CommitStreamRelInfo( SotElement_Impl* pStreamElement )
if ( !pStreamElement )
throw uno::RuntimeException( THROW_WHERE );
- if ( m_nStorageType == embed::StorageFormats::OFOPXML && pStreamElement->m_pStream )
+ if (m_nStorageType == embed::StorageFormats::OFOPXML && pStreamElement->m_xStream)
{
SAL_WARN_IF( pStreamElement->m_aName.isEmpty(), "package.xstor", "The name must not be empty!" );
@@ -1691,7 +1674,7 @@ void OStorage_Impl::CommitStreamRelInfo( SotElement_Impl* pStreamElement )
CreateRelStorage();
}
- pStreamElement->m_pStream->CommitStreamRelInfo( m_xRelStorage, pStreamElement->m_aOriginalName, pStreamElement->m_aName );
+ pStreamElement->m_xStream->CommitStreamRelInfo(m_xRelStorage, pStreamElement->m_aOriginalName, pStreamElement->m_aName);
}
}
@@ -1813,8 +1796,8 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain
m_pRelStorElement = nullptr;
m_xRelStorage.clear();
}
- else if ( m_pRelStorElement && m_pRelStorElement->m_pStorage && xNewPackageFolder.is() )
- m_pRelStorElement->m_pStorage->InsertIntoPackageFolder( aRelsStorName, xNewPackageFolder );
+ else if ( m_pRelStorElement && m_pRelStorElement->m_xStorage && xNewPackageFolder.is() )
+ m_pRelStorElement->m_xStorage->InsertIntoPackageFolder( aRelsStorName, xNewPackageFolder );
}
}
}
@@ -2081,10 +2064,10 @@ SotElement_Impl* OStorage::OpenStreamElement_Impl( const OUString& aStreamName,
SAL_WARN_IF( !pElement, "package.xstor", "In case element can not be created an exception must be thrown!" );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
m_pImpl->OpenSubStream( pElement );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
throw io::IOException( THROW_WHERE );
return pElement;
@@ -2335,9 +2318,9 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openStreamElement(
try
{
SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamName, nOpenMode, false );
- OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
+ OSL_ENSURE(pElement && pElement->m_xStream, "In case element can not be created an exception must be thrown!");
- xResult = pElement->m_pStream->GetStream( nOpenMode, false );
+ xResult = pElement->m_xStream->GetStream(nOpenMode, false);
SAL_WARN_IF( !xResult.is(), "package.xstor", "The method must throw exception instead of removing empty result!" );
if ( m_pData->m_bReadOnlyWrap )
@@ -2453,14 +2436,14 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement(
{
throw io::IOException( THROW_WHERE );
}
- else if ( pElement->m_pStorage )
+ else if (pElement->m_xStorage)
{
// storage has already been opened; it may be opened another time, if it the mode allows to do so
- if ( pElement->m_pStorage->m_pAntiImpl )
+ if (pElement->m_xStorage->m_pAntiImpl)
{
throw io::IOException( THROW_WHERE ); // TODO: access_denied
}
- else if ( !pElement->m_pStorage->m_aReadOnlyWrapList.empty()
+ else if ( !pElement->m_xStorage->m_aReadOnlyWrapList.empty()
&& ( nStorageMode & embed::ElementModes::WRITE ) )
{
throw io::IOException( THROW_WHERE ); // TODO: access_denied
@@ -2470,36 +2453,36 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement(
// in case parent storage allows writing the readonly mode of the child storage is
// virtual, that means that it is just enough to change the flag to let it be writable
// and since there is no AntiImpl nobody should be notified about it
- pElement->m_pStorage->m_nStorageMode = nStorageMode | embed::ElementModes::READ;
+ pElement->m_xStorage->m_nStorageMode = nStorageMode | embed::ElementModes::READ;
if ( ( nStorageMode & embed::ElementModes::TRUNCATE ) )
{
- for ( SotElementList_Impl::iterator pElementIter = pElement->m_pStorage->m_aChildrenList.begin();
- pElementIter != pElement->m_pStorage->m_aChildrenList.end(); )
- {
+ for ( SotElementList_Impl::iterator pElementIter = pElement->m_xStorage->m_aChildrenList.begin();
+ pElementIter != pElement->m_xStorage->m_aChildrenList.end(); )
+ {
SotElement_Impl* pElementToDel = (*pElementIter);
++pElementIter;
m_pImpl->RemoveElement( pElementToDel );
- }
+ }
}
}
}
- if ( !pElement->m_pStorage )
- m_pImpl->OpenSubStorage( pElement, nStorageMode );
+ if (!pElement->m_xStorage)
+ m_pImpl->OpenSubStorage(pElement, nStorageMode);
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
throw io::IOException( THROW_WHERE ); // TODO: general_error
bool bReadOnlyWrap = ( ( nStorageMode & embed::ElementModes::WRITE ) != embed::ElementModes::WRITE );
- OStorage* pResultStorage = new OStorage( pElement->m_pStorage, bReadOnlyWrap );
+ OStorage* pResultStorage = new OStorage(pElement->m_xStorage.get(), bReadOnlyWrap);
xResult.set( static_cast<embed::XStorage*>(pResultStorage) );
if ( bReadOnlyWrap )
{
// Before this call is done the object must be refcounted already
- pElement->m_pStorage->SetReadOnlyWrap( *pResultStorage );
+ pElement->m_xStorage->SetReadOnlyWrap(*pResultStorage);
// before the storage disposes the stream it must deregister itself as listener
uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY_THROW );
@@ -2721,16 +2704,16 @@ void SAL_CALL OStorage::copyStorageElementLastCommitTo(
throw io::IOException( THROW_WHERE );
}
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
m_pImpl->OpenSubStorage( pElement, nStorageMode );
uno::Reference< embed::XStorage > xResult;
- if ( pElement->m_pStorage )
+ if (pElement->m_xStorage)
{
// the existence of m_pAntiImpl of the child is not interesting,
// the copy will be created internally
- pElement->m_pStorage->CopyLastCommitTo( xTargetStorage );
+ pElement->m_xStorage->CopyLastCommitTo(xTargetStorage);
}
else
throw io::IOException( THROW_WHERE ); // TODO: general_error
@@ -3293,9 +3276,9 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream(
try
{
SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamName, nOpenMode, true );
- OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
+ OSL_ENSURE(pElement && pElement->m_xStream, "In case element can not be created an exception must be thrown!");
- xResult = pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, false );
+ xResult = pElement->m_xStream->GetStream(nOpenMode, aEncryptionData, false);
SAL_WARN_IF( !xResult.is(), "package.xstor", "The method must throw exception instead of removing empty result!" );
if ( m_pData->m_bReadOnlyWrap )
@@ -3470,14 +3453,14 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getPlainRawStreamElement(
if ( !pElement )
throw container::NoSuchElementException( THROW_WHERE );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
{
m_pImpl->OpenSubStream( pElement );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
throw io::IOException( THROW_WHERE );
}
- uno::Reference< io::XInputStream > xRawInStream = pElement->m_pStream->GetPlainRawInStream();
+ uno::Reference<io::XInputStream> xRawInStream = pElement->m_xStream->GetPlainRawInStream();
if ( !xRawInStream.is() )
throw io::IOException( THROW_WHERE );
@@ -3568,17 +3551,17 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getRawEncrStreamElement(
if ( !pElement )
throw container::NoSuchElementException( THROW_WHERE );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
{
m_pImpl->OpenSubStream( pElement );
- if ( !pElement->m_pStream )
+ if (!pElement->m_xStream)
throw io::IOException( THROW_WHERE );
}
- if ( !pElement->m_pStream->IsEncrypted() )
+ if (!pElement->m_xStream->IsEncrypted())
throw packages::NoEncryptionException( THROW_WHERE );
- uno::Reference< io::XInputStream > xRawInStream = pElement->m_pStream->GetRawInStream();
+ uno::Reference< io::XInputStream > xRawInStream = pElement->m_xStream->GetRawInStream();
if ( !xRawInStream.is() )
throw io::IOException( THROW_WHERE );
@@ -3815,10 +3798,10 @@ void SAL_CALL OStorage::revert()
for ( SotElementList_Impl::iterator pElementIter = m_pImpl->m_aChildrenList.begin();
pElementIter != m_pImpl->m_aChildrenList.end(); ++pElementIter )
{
- if ( ((*pElementIter)->m_pStorage
- && ( (*pElementIter)->m_pStorage->m_pAntiImpl || !(*pElementIter)->m_pStorage->m_aReadOnlyWrapList.empty() ))
- || ((*pElementIter)->m_pStream
- && ( (*pElementIter)->m_pStream->m_pAntiImpl || !(*pElementIter)->m_pStream->m_aInputStreamsList.empty()) ) )
+ if ( ((*pElementIter)->m_xStorage
+ && ( (*pElementIter)->m_xStorage->m_pAntiImpl || !(*pElementIter)->m_xStorage->m_aReadOnlyWrapList.empty() ))
+ || ((*pElementIter)->m_xStream
+ && ( (*pElementIter)->m_xStream->m_pAntiImpl || !(*pElementIter)->m_xStream->m_aInputStreamsList.empty()) ) )
throw io::IOException( THROW_WHERE ); // TODO: access denied
}
@@ -5165,9 +5148,9 @@ void SAL_CALL OStorage::insertStreamElementDirect(
throw container::ElementExistException( THROW_WHERE );
pElement = OpenStreamElement_Impl( aStreamName, embed::ElementModes::READWRITE, false );
- OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
+ OSL_ENSURE(pElement && pElement->m_xStream, "In case element can not be created an exception must be thrown!");
- pElement->m_pStream->InsertStreamDirectly( xInStream, aProps );
+ pElement->m_xStream->InsertStreamDirectly(xInStream, aProps);
}
catch( const embed::InvalidStorageException& rInvalidStorageException )
{
@@ -5472,14 +5455,14 @@ uno::Any SAL_CALL OStorage::getElementPropertyValue( const OUString& aElementNam
if ( !pElement->m_bIsStorage || m_pData->m_nStorageType != embed::StorageFormats::PACKAGE || aPropertyName != "MediaType" )
throw beans::PropertyVetoException( THROW_WHERE );
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
m_pImpl->OpenSubStorage( pElement, embed::ElementModes::READ );
- if ( !pElement->m_pStorage )
+ if (!pElement->m_xStorage)
throw io::IOException( THROW_WHERE ); // TODO: general_error
- pElement->m_pStorage->ReadContents();
- return uno::makeAny( pElement->m_pStorage->m_aMediaType );
+ pElement->m_xStorage->ReadContents();
+ return uno::makeAny(pElement->m_xStorage->m_aMediaType);
}
catch( const embed::InvalidStorageException& rInvalidStorageException )
{
@@ -5648,10 +5631,10 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openStreamEle
// the transacted version of the stream should be opened
SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, false );
- assert(pElement && pElement->m_pStream && "In case element can not be created an exception must be thrown!");
+ assert(pElement && pElement->m_xStream && "In case element can not be created an exception must be thrown!");
- xResult.set( pElement->m_pStream->GetStream( nOpenMode, true ),
- uno::UNO_QUERY_THROW );
+ xResult.set(pElement->m_xStream->GetStream(nOpenMode, true),
+ uno::UNO_QUERY_THROW);
}
catch ( const container::NoSuchElementException & )
{
@@ -5742,10 +5725,10 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
// the transacted version of the stream should be opened
SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, true );
- OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
+ OSL_ENSURE(pElement && pElement->m_xStream, "In case element can not be created an exception must be thrown!");
- xResult.set( pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, true ),
- uno::UNO_QUERY_THROW );
+ xResult.set(pElement->m_xStream->GetStream(nOpenMode, aEncryptionData, true),
+ uno::UNO_QUERY_THROW);
}
else
{
diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx
index 6bb5bc65919b..568caf3b90c2 100644
--- a/package/source/xstor/xstorage.hxx
+++ b/package/source/xstor/xstorage.hxx
@@ -85,12 +85,11 @@ struct SotElement_Impl
bool m_bIsInserted;
bool m_bIsStorage;
- OStorage_Impl* m_pStorage;
- OWriteStream_Impl* m_pStream;
+ std::unique_ptr<OStorage_Impl> m_xStorage;
+ std::unique_ptr<OWriteStream_Impl> m_xStream;
public:
- SotElement_Impl( const OUString& rName, bool bStor, bool bNew );
- ~SotElement_Impl();
+ SotElement_Impl(const OUString& rName, bool bStor, bool bNew);
};
typedef ::std::list< SotElement_Impl* > SotElementList_Impl;
diff --git a/sc/inc/funcuno.hxx b/sc/inc/funcuno.hxx
index ad32fb6d3e54..b7c87ff9da87 100644
--- a/sc/inc/funcuno.hxx
+++ b/sc/inc/funcuno.hxx
@@ -36,14 +36,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL
class ScTempDocCache
{
private:
- ScDocument* pDoc;
+ std::unique_ptr<ScDocument> xDoc;
bool bInUse;
public:
- ScTempDocCache();
- ~ScTempDocCache();
+ ScTempDocCache();
- ScDocument* GetDocument() const { return pDoc; }
+ ScDocument* GetDocument() const { return xDoc.get(); }
bool IsInUse() const { return bInUse; }
void SetInUse( bool bSet ) { bInUse = bSet; }
diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx
index 6f633dc53493..65d8dd4c0d62 100644
--- a/sc/source/filter/inc/XclExpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclExpChangeTrack.hxx
@@ -596,7 +596,7 @@ class XclExpChangeTrack : protected XclExpRoot
XclExpChTrTabIdBuffer* pTabIdBuffer;
TabIdBufferType maBuffers;
- ScDocument* pTempDoc; // empty document
+ std::unique_ptr<ScDocument> xTempDoc; // empty document
XclExpChTrHeader* pHeader; // header record for last GUID
sal_uInt8 aGUID[ 16 ]; // GUID for action info records
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index a9cce7fcc2d3..c959ab460e78 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -1408,7 +1408,6 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
XclExpRoot( rRoot ),
aActionStack(),
pTabIdBuffer( nullptr ),
- pTempDoc( nullptr ),
pHeader( nullptr ),
bValidGUID( false )
{
@@ -1528,8 +1527,6 @@ XclExpChangeTrack::~XclExpChangeTrack()
delete aActionStack.top();
aActionStack.pop();
}
-
- delete pTempDoc;
}
ScChangeTrack* XclExpChangeTrack::CreateTempChangeTrack()
@@ -1540,30 +1537,30 @@ ScChangeTrack* XclExpChangeTrack::CreateTempChangeTrack()
if( !pOrigChangeTrack )
return nullptr;
- assert(!pTempDoc);
+ assert(!xTempDoc);
// create empty document
- pTempDoc = new ScDocument;
+ xTempDoc.reset(new ScDocument);
// adjust table count
SCTAB nOrigCount = GetDoc().GetTableCount();
OUString sTabName;
for( sal_Int32 nIndex = 0; nIndex < nOrigCount; nIndex++ )
{
- pTempDoc->CreateValidTabName( sTabName );
- pTempDoc->InsertTab( SC_TAB_APPEND, sTabName );
+ xTempDoc->CreateValidTabName(sTabName);
+ xTempDoc->InsertTab(SC_TAB_APPEND, sTabName);
}
- OSL_ENSURE( nOrigCount == pTempDoc->GetTableCount(),
- "XclExpChangeTrack::CreateTempChangeTrack - table count mismatch" );
- if( nOrigCount != pTempDoc->GetTableCount() )
+ OSL_ENSURE(nOrigCount == xTempDoc->GetTableCount(),
+ "XclExpChangeTrack::CreateTempChangeTrack - table count mismatch");
+ if(nOrigCount != xTempDoc->GetTableCount())
return nullptr;
- return pOrigChangeTrack->Clone(pTempDoc);
+ return pOrigChangeTrack->Clone(xTempDoc.get());
}
void XclExpChangeTrack::PushActionRecord( const ScChangeAction& rAction )
{
XclExpChTrAction* pXclAction = nullptr;
- ScChangeTrack* pTempChangeTrack = pTempDoc->GetChangeTrack();
+ ScChangeTrack* pTempChangeTrack = xTempDoc->GetChangeTrack();
switch( rAction.GetType() )
{
case SC_CAT_CONTENT:
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 6dd755ff153a..4be768e47de1 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -439,7 +439,7 @@ public:
private:
ScCellMergeOption maOption;
bool mbMergeContents; // Merge contents in Redo().
- ScDocument* mpUndoDoc; // when data is merged
+ std::unique_ptr<ScDocument> mxUndoDoc; // when data is merged
SdrUndoAction* mpDrawUndo;
void DoChange( bool bUndo ) const;
@@ -592,10 +592,9 @@ private:
class ScUndoListNames: public ScBlockUndo
{
public:
- ScUndoListNames( ScDocShell* pNewDocShell,
- const ScRange& rRange,
- ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc );
- virtual ~ScUndoListNames() override;
+ ScUndoListNames(ScDocShell* pNewDocShell,
+ const ScRange& rRange,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc);
virtual void Undo() override;
virtual void Redo() override;
@@ -605,8 +604,8 @@ public:
virtual OUString GetComment() const override;
private:
- ScDocument* pUndoDoc;
- ScDocument* pRedoDoc;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScDocument> xRedoDoc;
void DoChange( ScDocument* pSrcDoc ) const;
};
@@ -687,9 +686,8 @@ private:
class ScUndoRefreshLink: public ScSimpleUndo
{
public:
- ScUndoRefreshLink( ScDocShell* pNewDocShell,
- ScDocument* pNewUndoDoc );
- virtual ~ScUndoRefreshLink() override;
+ ScUndoRefreshLink(ScDocShell* pNewDocShell,
+ ScDocument* pNewUndoDoc);
virtual void Undo() override;
virtual void Redo() override;
@@ -699,8 +697,8 @@ public:
virtual OUString GetComment() const override;
private:
- ScDocument* pUndoDoc;
- ScDocument* pRedoDoc;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScDocument> xRedoDoc;
};
class ScUndoEnterMatrix: public ScBlockUndo
@@ -784,18 +782,17 @@ private:
class ScUndoUpdateAreaLink : public ScSimpleUndo //! also change BlockUndo?
{
public:
- ScUndoUpdateAreaLink( ScDocShell* pShell,
- const OUString& rOldD,
- const OUString& rOldF, const OUString& rOldO,
- const OUString& rOldA, const ScRange& rOldR,
- sal_uLong nOldRD,
- const OUString& rNewD,
- const OUString& rNewF, const OUString& rNewO,
- const OUString& rNewA, const ScRange& rNewR,
- sal_uLong nNewRD,
- ScDocument* pUndo, ScDocument* pRedo,
- bool bDoInsert );
- virtual ~ScUndoUpdateAreaLink() override;
+ ScUndoUpdateAreaLink(ScDocShell* pShell,
+ const OUString& rOldD,
+ const OUString& rOldF, const OUString& rOldO,
+ const OUString& rOldA, const ScRange& rOldR,
+ sal_uLong nOldRD,
+ const OUString& rNewD,
+ const OUString& rNewF, const OUString& rNewO,
+ const OUString& rNewA, const ScRange& rNewR,
+ sal_uLong nNewRD,
+ ScDocument* pUndo, ScDocument* pRedo,
+ bool bDoInsert);
virtual void Undo() override;
virtual void Redo() override;
@@ -815,8 +812,8 @@ private:
OUString aNewOpt;
OUString aNewArea;
ScRange aNewRange;
- ScDocument* pUndoDoc;
- ScDocument* pRedoDoc;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScDocument> xRedoDoc;
sal_uLong nOldRefresh;
sal_uLong nNewRefresh;
bool bWithInsert;
@@ -937,12 +934,11 @@ private:
class ScUndoBorder: public ScBlockUndo
{
public:
- ScUndoBorder( ScDocShell* pNewDocShell,
- const ScRangeList& rRangeList,
- ScDocument* pNewUndoDoc,
- const SvxBoxItem& rNewOuter,
- const SvxBoxInfoItem& rNewInner );
- virtual ~ScUndoBorder() override;
+ ScUndoBorder(ScDocShell* pNewDocShell,
+ const ScRangeList& rRangeList,
+ ScDocument* pNewUndoDoc,
+ const SvxBoxItem& rNewOuter,
+ const SvxBoxInfoItem& rNewInner);
virtual void Undo() override;
virtual void Redo() override;
@@ -952,10 +948,10 @@ public:
virtual OUString GetComment() const override;
private:
- ScDocument* pUndoDoc;
- ScRangeList* pRanges;
- SvxBoxItem* pOuter;
- SvxBoxInfoItem* pInner;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScRangeList> xRanges;
+ std::unique_ptr<SvxBoxItem> xOuter;
+ std::unique_ptr<SvxBoxInfoItem> xInner;
};
#endif
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
index ae55159602ff..fdb6f3c27504 100644
--- a/sc/source/ui/inc/undodat.hxx
+++ b/sc/source/ui/inc/undodat.hxx
@@ -97,11 +97,10 @@ private:
class ScUndoOutlineLevel: public ScSimpleUndo
{
public:
- ScUndoOutlineLevel( ScDocShell* pNewDocShell,
- SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
- bool bNewColumns, sal_uInt16 nNewLevel );
- virtual ~ScUndoOutlineLevel() override;
+ ScUndoOutlineLevel(ScDocShell* pNewDocShell,
+ SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ bool bNewColumns, sal_uInt16 nNewLevel);
virtual void Undo() override;
virtual void Redo() override;
@@ -114,8 +113,8 @@ private:
SCCOLROW nStart;
SCCOLROW nEnd;
SCTAB nTab;
- ScDocument* pUndoDoc;
- ScOutlineTable* pUndoTable;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScOutlineTable> xUndoTable;
bool bColumns;
sal_uInt16 nLevel;
};
@@ -123,12 +122,11 @@ private:
class ScUndoOutlineBlock: public ScSimpleUndo
{
public:
- ScUndoOutlineBlock( ScDocShell* pNewDocShell,
- SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
- SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
- bool bNewShow );
- virtual ~ScUndoOutlineBlock() override;
+ ScUndoOutlineBlock(ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ bool bNewShow);
virtual void Undo() override;
virtual void Redo() override;
@@ -140,19 +138,18 @@ public:
private:
ScAddress aBlockStart;
ScAddress aBlockEnd;
- ScDocument* pUndoDoc;
- ScOutlineTable* pUndoTable;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScOutlineTable> xUndoTable;
bool bShow;
};
class ScUndoRemoveAllOutlines: public ScSimpleUndo
{
public:
- ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell,
- SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
- SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab );
- virtual ~ScUndoRemoveAllOutlines() override;
+ ScUndoRemoveAllOutlines(ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab);
virtual void Undo() override;
virtual void Redo() override;
@@ -164,18 +161,17 @@ public:
private:
ScAddress aBlockStart;
ScAddress aBlockEnd;
- ScDocument* pUndoDoc;
- ScOutlineTable* pUndoTable;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScOutlineTable> xUndoTable;
};
class ScUndoAutoOutline: public ScSimpleUndo
{
public:
- ScUndoAutoOutline( ScDocShell* pNewDocShell,
- SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
- SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab );
- virtual ~ScUndoAutoOutline() override;
+ ScUndoAutoOutline(ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab);
virtual void Undo() override;
virtual void Redo() override;
@@ -187,19 +183,17 @@ public:
private:
ScAddress aBlockStart;
ScAddress aBlockEnd;
- ScDocument* pUndoDoc;
- ScOutlineTable* pUndoTable;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScOutlineTable> xUndoTable;
};
class ScUndoSubTotals: public ScDBFuncUndo
{
public:
- ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab,
- const ScSubTotalParam& rNewParam, SCROW nNewEndY,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
-// ScDBData* pNewData,
- ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB );
- virtual ~ScUndoSubTotals() override;
+ ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScSubTotalParam& rNewParam, SCROW nNewEndY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB);
virtual void Undo() override;
virtual void Redo() override;
@@ -212,11 +206,10 @@ private:
SCTAB nTab;
ScSubTotalParam aParam; // The original passed parameter
SCROW nNewEndRow; // Size of result
- ScDocument* pUndoDoc;
- ScOutlineTable* pUndoTable;
-// ScDBData* pUndoDBData;
- ScRangeName* pUndoRange;
- ScDBCollection* pUndoDB;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScOutlineTable> xUndoTable;
+ std::unique_ptr<ScRangeName> xUndoRange;
+ std::unique_ptr<ScDBCollection> xUndoDB;
};
class ScUndoQuery: public ScDBFuncUndo
@@ -239,8 +232,8 @@ private:
SdrUndoAction* pDrawUndo;
SCTAB nTab;
ScQueryParam aQueryParam;
- ScDocument* pUndoDoc;
- ScDBCollection* pUndoDB; // due to source and target range
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScDBCollection> xUndoDB; // due to source and target range
ScRange aOldDest;
ScRange aAdvSource;
bool bIsAdvanced;
@@ -291,12 +284,11 @@ private:
class ScUndoImportData: public ScSimpleUndo
{
public:
- ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab,
- const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY,
- SCCOL nNewFormula,
- ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
- ScDBData* pNewUndoData, ScDBData* pNewRedoData );
- virtual ~ScUndoImportData() override;
+ ScUndoImportData(ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY,
+ SCCOL nNewFormula,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ ScDBData* pNewUndoData, ScDBData* pNewRedoData);
virtual void Undo() override;
virtual void Redo() override;
@@ -310,10 +302,10 @@ private:
ScImportParam aImportParam;
SCCOL nEndCol;
SCROW nEndRow;
- ScDocument* pUndoDoc;
- ScDocument* pRedoDoc;
- ScDBData* pUndoDBData;
- ScDBData* pRedoDBData;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScDocument> xRedoDoc;
+ std::unique_ptr<ScDBData> xUndoDBData;
+ std::unique_ptr<ScDBData> xRedoDBData;
SCCOL nFormulaCols;
bool bRedoFilled;
};
@@ -321,13 +313,12 @@ private:
class ScUndoRepeatDB: public ScSimpleUndo
{
public:
- ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
- SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
- SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
- ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB,
- const ScRange* pOldQ, const ScRange* pNewQ );
- virtual ~ScUndoRepeatDB() override;
+ ScUndoRepeatDB(ScDocShell* pNewDocShell, SCTAB nNewTab,
+ SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
+ SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB,
+ const ScRange* pOldQ, const ScRange* pNewQ);
virtual void Undo() override;
virtual void Redo() override;
@@ -341,10 +332,10 @@ private:
ScAddress aBlockEnd;
SCROW nNewEndRow;
ScAddress aCursorPos;
- ScDocument* pUndoDoc;
- ScOutlineTable* pUndoTable;
- ScRangeName* pUndoRange;
- ScDBCollection* pUndoDB;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScOutlineTable> xUndoTable;
+ std::unique_ptr<ScRangeName> xUndoRange;
+ std::unique_ptr<ScDBCollection> xUndoDB;
ScRange aOldQuery;
ScRange aNewQuery;
bool bQuerySize;
@@ -353,11 +344,10 @@ private:
class ScUndoDataPilot: public ScSimpleUndo
{
public:
- ScUndoDataPilot( ScDocShell* pNewDocShell,
- ScDocument* pOldDoc, ScDocument* pNewDoc,
- const ScDPObject* pOldObj, const ScDPObject* pNewObj,
- bool bMove );
- virtual ~ScUndoDataPilot() override;
+ ScUndoDataPilot(ScDocShell* pNewDocShell,
+ ScDocument* pOldDoc, ScDocument* pNewDoc,
+ const ScDPObject* pOldObj, const ScDPObject* pNewObj,
+ bool bMove);
virtual void Undo() override;
virtual void Redo() override;
@@ -367,22 +357,21 @@ public:
virtual OUString GetComment() const override;
private:
- ScDocument* pOldUndoDoc;
- ScDocument* pNewUndoDoc;
- ScDPObject* pOldDPObject;
- ScDPObject* pNewDPObject;
+ std::unique_ptr<ScDocument> xOldUndoDoc;
+ std::unique_ptr<ScDocument> xNewUndoDoc;
+ std::unique_ptr<ScDPObject> xOldDPObject;
+ std::unique_ptr<ScDPObject> xNewDPObject;
bool bAllowMove;
};
class ScUndoConsolidate: public ScSimpleUndo
{
public:
- ScUndoConsolidate( ScDocShell* pNewDocShell,
- const ScArea& rArea, const ScConsolidateParam& rPar,
- ScDocument* pNewUndoDoc, bool bReference,
- SCROW nInsCount, ScOutlineTable* pTab,
- ScDBData* pData );
- virtual ~ScUndoConsolidate() override;
+ ScUndoConsolidate(ScDocShell* pNewDocShell,
+ const ScArea& rArea, const ScConsolidateParam& rPar,
+ ScDocument* pNewUndoDoc, bool bReference,
+ SCROW nInsCount, ScOutlineTable* pTab,
+ ScDBData* pData);
virtual void Undo() override;
virtual void Redo() override;
@@ -393,12 +382,12 @@ public:
private:
ScArea aDestArea;
- ScDocument* pUndoDoc;
+ std::unique_ptr<ScDocument> xUndoDoc;
ScConsolidateParam aParam;
bool bInsRef;
SCSIZE nInsertCount;
- ScOutlineTable* pUndoTab;
- ScDBData* pUndoData;
+ std::unique_ptr<ScOutlineTable> xUndoTab;
+ std::unique_ptr<ScDBData> xUndoData;
};
class ScUndoChartData: public ScSimpleUndo
@@ -436,16 +425,13 @@ private:
class ScUndoDataForm: public ScBlockUndo
{
public:
- ScUndoDataForm( ScDocShell* pNewDocShell,
- SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
- SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- const ScMarkData& rMark,
- ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
- InsertDeleteFlags nNewFlags,
- ScRefUndoData* pRefData
- );
- virtual ~ScUndoDataForm() override;
-
+ ScUndoDataForm(ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ InsertDeleteFlags nNewFlags,
+ ScRefUndoData* pRefData);
virtual void Undo() override;
virtual void Redo() override;
virtual void Repeat(SfxRepeatTarget& rTarget) override;
@@ -454,12 +440,12 @@ public:
virtual OUString GetComment() const override;
private:
- std::unique_ptr<ScMarkData> mpMarkData;
- ScDocument* pUndoDoc;
- ScDocument* pRedoDoc;
+ std::unique_ptr<ScMarkData> mxMarkData;
+ std::unique_ptr<ScDocument> xUndoDoc;
+ std::unique_ptr<ScDocument> xRedoDoc;
InsertDeleteFlags nFlags;
- ScRefUndoData* pRefUndoData;
- ScRefUndoData* pRefRedoData;
+ std::unique_ptr<ScRefUndoData> xRefUndoData;
+ std::unique_ptr<ScRefUndoData> xRefRedoData;
sal_uLong nStartChangeAction;
sal_uLong nEndChangeAction;
bool bRedoFilled;
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index 214881479dce..662dd0358c1b 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -271,7 +271,7 @@ public:
private:
SCTAB nTab;
SCTAB nCount;
- ScDocument* pRedoDoc;
+ std::unique_ptr<ScDocument> xRedoDoc;
SdrUndoAction* pDrawUndo;
void DoChange() const;
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 3bbe625b206c..46b5d47fa3ee 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1432,20 +1432,14 @@ bool ScUndoDragDrop::CanRepeat(SfxRepeatTarget& /* rTarget */) const
return false; // not possible
}
-// Insert list containing range names
-// (Insert|Name|Insert =>[List])
-ScUndoListNames::ScUndoListNames( ScDocShell* pNewDocShell, const ScRange& rRange,
- ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc ) :
- ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ),
- pUndoDoc( pNewUndoDoc ),
- pRedoDoc( pNewRedoDoc )
-{
-}
-
-ScUndoListNames::~ScUndoListNames()
+// Insert list containing range names
+// (Insert|Name|Insert =>[List])
+ScUndoListNames::ScUndoListNames(ScDocShell* pNewDocShell, const ScRange& rRange,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc)
+ : ScBlockUndo(pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT)
+ , xUndoDoc(pNewUndoDoc)
+ , xRedoDoc(pNewRedoDoc)
{
- delete pUndoDoc;
- delete pRedoDoc;
}
OUString ScUndoListNames::GetComment() const
@@ -1469,14 +1463,14 @@ void ScUndoListNames::DoChange( ScDocument* pSrcDoc ) const
void ScUndoListNames::Undo()
{
BeginUndo();
- DoChange(pUndoDoc);
+ DoChange(xUndoDoc.get());
EndUndo();
}
void ScUndoListNames::Redo()
{
BeginRedo();
- DoChange(pRedoDoc);
+ DoChange(xRedoDoc.get());
EndRedo();
}
@@ -2258,23 +2252,15 @@ static ScRange lcl_TotalRange( const ScRangeList& rRanges )
return aTotal;
}
-ScUndoBorder::ScUndoBorder( ScDocShell* pNewDocShell,
- const ScRangeList& rRangeList, ScDocument* pNewUndoDoc,
- const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner ) :
- ScBlockUndo( pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE ),
- pUndoDoc( pNewUndoDoc )
-{
- pRanges = new ScRangeList(rRangeList);
- pOuter = new SvxBoxItem(rNewOuter);
- pInner = new SvxBoxInfoItem(rNewInner);
-}
-
-ScUndoBorder::~ScUndoBorder()
+ScUndoBorder::ScUndoBorder(ScDocShell* pNewDocShell,
+ const ScRangeList& rRangeList, ScDocument* pNewUndoDoc,
+ const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner)
+ : ScBlockUndo(pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE)
+ , xUndoDoc(pNewUndoDoc)
{
- delete pUndoDoc;
- delete pRanges;
- delete pOuter;
- delete pInner;
+ xRanges.reset(new ScRangeList(rRangeList));
+ xOuter.reset(new SvxBoxItem(rNewOuter));
+ xInner.reset(new SvxBoxInfoItem(rNewInner));
}
OUString ScUndoBorder::GetComment() const
@@ -2288,8 +2274,8 @@ void ScUndoBorder::Undo()
ScDocument& rDoc = pDocShell->GetDocument();
ScMarkData aMarkData;
- aMarkData.MarkFromRangeList( *pRanges, false );
- pUndoDoc->CopyToDocument(aBlockRange, InsertDeleteFlags::ATTRIB, true, rDoc, &aMarkData);
+ aMarkData.MarkFromRangeList(*xRanges, false);
+ xUndoDoc->CopyToDocument(aBlockRange, InsertDeleteFlags::ATTRIB, true, rDoc, &aMarkData);
pDocShell->PostPaint( aBlockRange, PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE );
EndUndo();
@@ -2300,20 +2286,20 @@ void ScUndoBorder::Redo()
BeginRedo();
ScDocument& rDoc = pDocShell->GetDocument(); // call function at docfunc
- size_t nCount = pRanges->size();
+ size_t nCount = xRanges->size();
for (size_t i = 0; i < nCount; ++i )
{
- ScRange aRange = *(*pRanges)[i];
+ ScRange aRange = *(*xRanges)[i];
SCTAB nTab = aRange.aStart.Tab();
ScMarkData aMark;
aMark.SetMarkArea( aRange );
aMark.SelectTable( nTab, true );
- rDoc.ApplySelectionFrame( aMark, pOuter, pInner );
+ rDoc.ApplySelectionFrame(aMark, xOuter.get(), xInner.get());
}
for (size_t i = 0; i < nCount; ++i)
- pDocShell->PostPaint( *(*pRanges)[i], PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE );
+ pDocShell->PostPaint( *(*xRanges)[i], PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE );
EndRedo();
}
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 5fe6c5ebd3b6..d5690e250baa 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -634,19 +634,18 @@ bool ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
-ScUndoMerge::ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
- bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo )
- : ScSimpleUndo( pNewDocShell ),
- maOption(rOption),
- mbMergeContents( bMergeContents ),
- mpUndoDoc( pUndoDoc ),
- mpDrawUndo( pDrawUndo )
+ScUndoMerge::ScUndoMerge(ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
+ bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo)
+ : ScSimpleUndo(pNewDocShell)
+ , maOption(rOption)
+ , mbMergeContents(bMergeContents)
+ , mxUndoDoc(pUndoDoc)
+ , mpDrawUndo(pDrawUndo)
{
}
ScUndoMerge::~ScUndoMerge()
{
- delete mpUndoDoc;
DeleteSdrUndoAction( mpDrawUndo );
}
@@ -697,7 +696,7 @@ void ScUndoMerge::DoChange( bool bUndo ) const
}
// undo -> copy back deleted contents
- if (bUndo && mpUndoDoc)
+ if (bUndo && mxUndoDoc)
{
// If there are note captions to be deleted during Undo they were
// kept or moved during the merge and copied to the Undo document
@@ -706,7 +705,7 @@ void ScUndoMerge::DoChange( bool bUndo ) const
// instead of deleting it.
rDoc.DeleteAreaTab( aRange,
InsertDeleteFlags::CONTENTS | InsertDeleteFlags::NOCAPTIONS | InsertDeleteFlags::FORGETCAPTIONS );
- mpUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL|InsertDeleteFlags::NOCAPTIONS, false, rDoc);
+ mxUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL|InsertDeleteFlags::NOCAPTIONS, false, rDoc);
}
// redo -> merge contents again
@@ -1364,18 +1363,11 @@ bool ScUndoRefConversion::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
-ScUndoRefreshLink::ScUndoRefreshLink( ScDocShell* pNewDocShell,
- ScDocument* pNewUndoDoc )
- : ScSimpleUndo( pNewDocShell ),
- pUndoDoc( pNewUndoDoc ),
- pRedoDoc( nullptr )
-{
-}
-
-ScUndoRefreshLink::~ScUndoRefreshLink()
+ScUndoRefreshLink::ScUndoRefreshLink(ScDocShell* pNewDocShell,
+ ScDocument* pNewUndoDoc)
+ : ScSimpleUndo(pNewDocShell)
+ , xUndoDoc(pNewUndoDoc)
{
- delete pUndoDoc;
- delete pRedoDoc;
}
OUString ScUndoRefreshLink::GetComment() const
@@ -1387,42 +1379,42 @@ void ScUndoRefreshLink::Undo()
{
BeginUndo();
- bool bMakeRedo = !pRedoDoc;
+ bool bMakeRedo = !xRedoDoc;
if (bMakeRedo)
- pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ xRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
bool bFirst = true;
ScDocument& rDoc = pDocShell->GetDocument();
SCTAB nCount = rDoc.GetTableCount();
for (SCTAB nTab=0; nTab<nCount; nTab++)
- if (pUndoDoc->HasTable(nTab))
+ if (xUndoDoc->HasTable(nTab))
{
ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
if (bMakeRedo)
{
if (bFirst)
- pRedoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
+ xRedoDoc->InitUndo(&rDoc, nTab, nTab, true, true);
else
- pRedoDoc->AddUndoTab( nTab, nTab, true, true );
+ xRedoDoc->AddUndoTab(nTab, nTab, true, true);
bFirst = false;
- rDoc.CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *pRedoDoc);
- pRedoDoc->SetLink( nTab,
- rDoc.GetLinkMode(nTab),
- rDoc.GetLinkDoc(nTab),
- rDoc.GetLinkFlt(nTab),
- rDoc.GetLinkOpt(nTab),
- rDoc.GetLinkTab(nTab),
- rDoc.GetLinkRefreshDelay(nTab) );
- pRedoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) );
+ rDoc.CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *xRedoDoc);
+ xRedoDoc->SetLink(nTab,
+ rDoc.GetLinkMode(nTab),
+ rDoc.GetLinkDoc(nTab),
+ rDoc.GetLinkFlt(nTab),
+ rDoc.GetLinkOpt(nTab),
+ rDoc.GetLinkTab(nTab),
+ rDoc.GetLinkRefreshDelay(nTab));
+ xRedoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) );
}
rDoc.DeleteAreaTab( aRange,InsertDeleteFlags::ALL );
- pUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc);
- rDoc.SetLink( nTab, pUndoDoc->GetLinkMode(nTab), pUndoDoc->GetLinkDoc(nTab),
- pUndoDoc->GetLinkFlt(nTab), pUndoDoc->GetLinkOpt(nTab),
- pUndoDoc->GetLinkTab(nTab),
- pUndoDoc->GetLinkRefreshDelay(nTab) );
- rDoc.SetTabBgColor( nTab, pUndoDoc->GetTabBgColor(nTab) );
+ xUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc);
+ rDoc.SetLink(nTab, xUndoDoc->GetLinkMode(nTab), xUndoDoc->GetLinkDoc(nTab),
+ xUndoDoc->GetLinkFlt(nTab), xUndoDoc->GetLinkOpt(nTab),
+ xUndoDoc->GetLinkTab(nTab),
+ xUndoDoc->GetLinkRefreshDelay(nTab) );
+ rDoc.SetTabBgColor(nTab, xUndoDoc->GetTabBgColor(nTab));
}
pDocShell->PostPaintGridAll();
@@ -1433,27 +1425,27 @@ void ScUndoRefreshLink::Undo()
void ScUndoRefreshLink::Redo()
{
- OSL_ENSURE(pRedoDoc, "No RedoDoc for ScUndoRefreshLink::Redo");
+ OSL_ENSURE(xRedoDoc, "No RedoDoc for ScUndoRefreshLink::Redo");
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
SCTAB nCount = rDoc.GetTableCount();
for (SCTAB nTab=0; nTab<nCount; nTab++)
- if (pRedoDoc->HasTable(nTab))
+ if (xRedoDoc->HasTable(nTab))
{
ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
rDoc.DeleteAreaTab( aRange, InsertDeleteFlags::ALL );
- pRedoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc);
- rDoc.SetLink( nTab,
- pRedoDoc->GetLinkMode(nTab),
- pRedoDoc->GetLinkDoc(nTab),
- pRedoDoc->GetLinkFlt(nTab),
- pRedoDoc->GetLinkOpt(nTab),
- pRedoDoc->GetLinkTab(nTab),
- pRedoDoc->GetLinkRefreshDelay(nTab) );
- rDoc.SetTabBgColor( nTab, pRedoDoc->GetTabBgColor(nTab) );
+ xRedoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc);
+ rDoc.SetLink(nTab,
+ xRedoDoc->GetLinkMode(nTab),
+ xRedoDoc->GetLinkDoc(nTab),
+ xRedoDoc->GetLinkFlt(nTab),
+ xRedoDoc->GetLinkOpt(nTab),
+ xRedoDoc->GetLinkTab(nTab),
+ xRedoDoc->GetLinkRefreshDelay(nTab) );
+ rDoc.SetTabBgColor(nTab, xRedoDoc->GetTabBgColor(nTab));
}
pDocShell->PostPaintGridAll();
@@ -1632,8 +1624,8 @@ ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell,
aNewOpt ( rNewO ),
aNewArea ( rNewA ),
aNewRange ( rNewR ),
- pUndoDoc ( pUndo ),
- pRedoDoc ( pRedo ),
+ xUndoDoc ( pUndo ),
+ xRedoDoc ( pRedo ),
nOldRefresh ( nOldRD ),
nNewRefresh ( nNewRD ),
bWithInsert ( bDoInsert )
@@ -1641,12 +1633,6 @@ ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell,
OSL_ENSURE( aOldRange.aStart == aNewRange.aStart, "AreaLink moved ?" );
}
-ScUndoUpdateAreaLink::~ScUndoUpdateAreaLink()
-{
- delete pUndoDoc;
- delete pRedoDoc;
-}
-
OUString ScUndoUpdateAreaLink::GetComment() const
{
return ScGlobal::GetRscString( STR_UNDO_UPDATELINK ); //! own text ??
@@ -1666,13 +1652,13 @@ void ScUndoUpdateAreaLink::DoChange( const bool bUndo ) const
{
rDoc.FitBlock( aNewRange, aOldRange );
rDoc.DeleteAreaTab( aOldRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pUndoDoc->UndoToDocument( aOldRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc );
+ xUndoDoc->UndoToDocument(aOldRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc);
}
else
{
ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
rDoc.DeleteAreaTab( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pUndoDoc->CopyToDocument( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc );
+ xUndoDoc->CopyToDocument(aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc);
}
}
else
@@ -1681,13 +1667,13 @@ void ScUndoUpdateAreaLink::DoChange( const bool bUndo ) const
{
rDoc.FitBlock( aOldRange, aNewRange );
rDoc.DeleteAreaTab( aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pRedoDoc->CopyToDocument( aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc );
+ xRedoDoc->CopyToDocument(aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc);
}
else
{
ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
rDoc.DeleteAreaTab( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pRedoDoc->CopyToDocument( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc );
+ xRedoDoc->CopyToDocument(aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc);
}
}
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index b6527a5faddd..372033807d84 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -222,22 +222,16 @@ bool ScUndoMakeOutline::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell* pNewDocShell,
SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
- bool bNewColumns, sal_uInt16 nNewLevel ) :
- ScSimpleUndo( pNewDocShell ),
- nStart( nNewStart ),
- nEnd( nNewEnd ),
- nTab( nNewTab ),
- pUndoDoc( pNewUndoDoc ),
- pUndoTable( pNewUndoTab ),
- bColumns( bNewColumns ),
- nLevel( nNewLevel )
-{
-}
-
-ScUndoOutlineLevel::~ScUndoOutlineLevel()
+ bool bNewColumns, sal_uInt16 nNewLevel )
+ : ScSimpleUndo(pNewDocShell)
+ , nStart(nNewStart)
+ , nEnd(nNewEnd)
+ , nTab(nNewTab)
+ , xUndoDoc(pNewUndoDoc)
+ , xUndoTable(pNewUndoTab)
+ , bColumns(bNewColumns)
+ , nLevel(nNewLevel)
{
- delete pUndoDoc;
- delete pUndoTable;
}
OUString ScUndoOutlineLevel::GetComment() const
@@ -254,15 +248,15 @@ void ScUndoOutlineLevel::Undo()
// Original Outline table
- rDoc.SetOutlineTable( nTab, pUndoTable );
+ rDoc.SetOutlineTable(nTab, xUndoTable.get());
// Original column/row status
if (bColumns)
- pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, nTab,
+ xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, nTab,
static_cast<SCCOL>(nEnd), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc);
else
- pUndoDoc->CopyToDocument(0, nStart, nTab, MAXCOL, nEnd, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, nStart, nTab, MAXCOL, nEnd, nTab, InsertDeleteFlags::NONE, false, rDoc);
rDoc.UpdatePageBreaks( nTab );
@@ -313,18 +307,12 @@ ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell* pNewDocShell,
ScSimpleUndo( pNewDocShell ),
aBlockStart( nStartX, nStartY, nStartZ ),
aBlockEnd( nEndX, nEndY, nEndZ ),
- pUndoDoc( pNewUndoDoc ),
- pUndoTable( pNewUndoTab ),
+ xUndoDoc(pNewUndoDoc),
+ xUndoTable(pNewUndoTab),
bShow( bNewShow )
{
}
-ScUndoOutlineBlock::~ScUndoOutlineBlock()
-{
- delete pUndoDoc;
- delete pUndoTable;
-}
-
OUString ScUndoOutlineBlock::GetComment() const
{ // "Show outline" "Hide outline"
return bShow ?
@@ -341,7 +329,7 @@ void ScUndoOutlineBlock::Undo()
SCTAB nTab = aBlockStart.Tab();
// Original Outline table
- rDoc.SetOutlineTable( nTab, pUndoTable );
+ rDoc.SetOutlineTable(nTab, xUndoTable.get());
// Original column/row status
SCCOLROW nStartCol = aBlockStart.Col();
@@ -352,15 +340,15 @@ void ScUndoOutlineBlock::Undo()
if (!bShow)
{ // Size of the hidden blocks
size_t nLevel;
- pUndoTable->GetColArray().FindTouchedLevel( nStartCol, nEndCol, nLevel );
- pUndoTable->GetColArray().ExtendBlock( nLevel, nStartCol, nEndCol );
- pUndoTable->GetRowArray().FindTouchedLevel( nStartRow, nEndRow, nLevel );
- pUndoTable->GetRowArray().ExtendBlock( nLevel, nStartRow, nEndRow );
+ xUndoTable->GetColArray().FindTouchedLevel(nStartCol, nEndCol, nLevel);
+ xUndoTable->GetColArray().ExtendBlock(nLevel, nStartCol, nEndCol);
+ xUndoTable->GetRowArray().FindTouchedLevel(nStartRow, nEndRow, nLevel);
+ xUndoTable->GetRowArray().ExtendBlock(nLevel, nStartRow, nEndRow);
}
- pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
+ xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc);
- pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
rDoc.UpdatePageBreaks( nTab );
@@ -408,22 +396,16 @@ bool ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
-ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell,
+ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines(ScDocShell* pNewDocShell,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
- ScSimpleUndo( pNewDocShell ),
- aBlockStart( nStartX, nStartY, nStartZ ),
- aBlockEnd( nEndX, nEndY, nEndZ ),
- pUndoDoc( pNewUndoDoc ),
- pUndoTable( pNewUndoTab )
-{
-}
-
-ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines()
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab)
+ : ScSimpleUndo(pNewDocShell)
+ , aBlockStart(nStartX, nStartY, nStartZ)
+ , aBlockEnd(nEndX, nEndY, nEndZ)
+ , xUndoDoc(pNewUndoDoc)
+ , xUndoTable(pNewUndoTab)
{
- delete pUndoDoc;
- delete pUndoTable;
}
OUString ScUndoRemoveAllOutlines::GetComment() const
@@ -440,7 +422,7 @@ void ScUndoRemoveAllOutlines::Undo()
SCTAB nTab = aBlockStart.Tab();
// Original Outline table
- rDoc.SetOutlineTable( nTab, pUndoTable );
+ rDoc.SetOutlineTable(nTab, xUndoTable.get());
// Original column/row status
SCCOL nStartCol = aBlockStart.Col();
@@ -448,8 +430,8 @@ void ScUndoRemoveAllOutlines::Undo()
SCROW nStartRow = aBlockStart.Row();
SCROW nEndRow = aBlockEnd.Row();
- pUndoDoc->CopyToDocument(nStartCol, 0, nTab, nEndCol, MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc);
- pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(nStartCol, 0, nTab, nEndCol, MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
rDoc.UpdatePageBreaks( nTab );
@@ -493,24 +475,18 @@ bool ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
-ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell* pNewDocShell,
- SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
- SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
- ScSimpleUndo( pNewDocShell ),
- aBlockStart( nStartX, nStartY, nStartZ ),
- aBlockEnd( nEndX, nEndY, nEndZ ),
- pUndoDoc( pNewUndoDoc ),
- pUndoTable( pNewUndoTab )
+ScUndoAutoOutline::ScUndoAutoOutline(ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab)
+ : ScSimpleUndo(pNewDocShell)
+ , aBlockStart(nStartX, nStartY, nStartZ)
+ , aBlockEnd(nEndX, nEndY, nEndZ)
+ , xUndoDoc(pNewUndoDoc)
+ , xUndoTable(pNewUndoTab)
{
}
-ScUndoAutoOutline::~ScUndoAutoOutline()
-{
- delete pUndoDoc;
- delete pUndoTable;
-}
-
OUString ScUndoAutoOutline::GetComment() const
{
return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE );
@@ -525,22 +501,22 @@ void ScUndoAutoOutline::Undo()
SCTAB nTab = aBlockStart.Tab();
// Original outline table
- rDoc.SetOutlineTable( nTab, pUndoTable );
+ rDoc.SetOutlineTable(nTab, xUndoTable.get());
// Original column/row status
- if (pUndoDoc && pUndoTable)
+ if (xUndoDoc && xUndoTable)
{
SCCOLROW nStartCol;
SCCOLROW nStartRow;
SCCOLROW nEndCol;
SCCOLROW nEndRow;
- pUndoTable->GetColArray().GetRange( nStartCol, nEndCol );
- pUndoTable->GetRowArray().GetRange( nStartRow, nEndRow );
+ xUndoTable->GetColArray().GetRange(nStartCol, nEndCol);
+ xUndoTable->GetRowArray().GetRange(nStartRow, nEndRow);
- pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
+ xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false,
rDoc);
- pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
pViewShell->UpdateScrollBars();
}
@@ -596,30 +572,22 @@ bool ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
-ScUndoSubTotals::ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab,
- const ScSubTotalParam& rNewParam, SCROW nNewEndY,
- ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
- ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ) :
- ScDBFuncUndo( pNewDocShell, ScRange( rNewParam.nCol1, rNewParam.nRow1, nNewTab,
- rNewParam.nCol2, rNewParam.nRow2, nNewTab ) ),
- nTab( nNewTab ),
- aParam( rNewParam ),
- nNewEndRow( nNewEndY ),
- pUndoDoc( pNewUndoDoc ),
- pUndoTable( pNewUndoTab ),
- pUndoRange( pNewUndoRange ),
- pUndoDB( pNewUndoDB )
+ScUndoSubTotals::ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScSubTotalParam& rNewParam, SCROW nNewEndY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB)
+ : ScDBFuncUndo(pNewDocShell, ScRange(rNewParam.nCol1, rNewParam.nRow1, nNewTab,
+ rNewParam.nCol2, rNewParam.nRow2, nNewTab))
+ , nTab(nNewTab)
+ , aParam(rNewParam)
+ , nNewEndRow(nNewEndY)
+ , xUndoDoc(pNewUndoDoc)
+ , xUndoTable(pNewUndoTab)
+ , xUndoRange(pNewUndoRange)
+ , xUndoDB(pNewUndoDB)
{
}
-ScUndoSubTotals::~ScUndoSubTotals()
-{
- delete pUndoDoc;
- delete pUndoTable;
- delete pUndoRange;
- delete pUndoDB;
-}
-
OUString ScUndoSubTotals::GetComment() const
{ // "Subtotals"
return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS );
@@ -642,22 +610,22 @@ void ScUndoSubTotals::Undo()
}
// Original Outline table
- rDoc.SetOutlineTable( nTab, pUndoTable );
+ rDoc.SetOutlineTable(nTab, xUndoTable.get());
// Original column/row status
- if (pUndoTable)
+ if (xUndoTable)
{
SCCOLROW nStartCol;
SCCOLROW nStartRow;
SCCOLROW nEndCol;
SCCOLROW nEndRow;
- pUndoTable->GetColArray().GetRange( nStartCol, nEndCol );
- pUndoTable->GetRowArray().GetRange( nStartRow, nEndRow );
+ xUndoTable->GetColArray().GetRange(nStartCol, nEndCol);
+ xUndoTable->GetRowArray().GetRange(nStartRow, nEndRow);
- pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
+ xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false,
rDoc);
- pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
pViewShell->UpdateScrollBars();
}
@@ -669,18 +637,18 @@ void ScUndoSubTotals::Undo()
rDoc.DeleteAreaTab( 0,aParam.nRow1+1, MAXCOL,aParam.nRow2, nTab, InsertDeleteFlags::ALL );
- pUndoDoc->CopyToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
- InsertDeleteFlags::NONE, false, rDoc ); // Flags
- pUndoDoc->UndoToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
- InsertDeleteFlags::ALL, false, rDoc );
+ xUndoDoc->CopyToDocument(0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
+ InsertDeleteFlags::NONE, false, rDoc); // Flags
+ xUndoDoc->UndoToDocument(0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
+ InsertDeleteFlags::ALL, false, rDoc);
ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
aParam.nCol2,aParam.nRow2,nTab );
- if (pUndoRange)
- rDoc.SetRangeName( new ScRangeName( *pUndoRange ) );
- if (pUndoDB)
- rDoc.SetDBCollection( new ScDBCollection( *pUndoDB ), true );
+ if (xUndoRange)
+ rDoc.SetRangeName(new ScRangeName(*xUndoRange));
+ if (xUndoDB)
+ rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true);
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
if ( nVisTab != nTab )
@@ -726,8 +694,8 @@ ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQuery
pDrawUndo( nullptr ),
nTab( nNewTab ),
aQueryParam( rParam ),
- pUndoDoc( pNewUndoDoc ),
- pUndoDB( pNewUndoDB ),
+ xUndoDoc( pNewUndoDoc ),
+ xUndoDB( pNewUndoDB ),
bIsAdvanced( false ),
bDestArea( false ),
bDoSize( bSize )
@@ -748,8 +716,6 @@ ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQuery
ScUndoQuery::~ScUndoQuery()
{
- delete pUndoDoc;
- delete pUndoDB;
DeleteSdrUndoAction( pDrawUndo );
}
@@ -800,24 +766,24 @@ void ScUndoQuery::Undo()
pViewShell->DoneBlockMode();
- pUndoDoc->CopyToDocument( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
- nDestEndCol, nDestEndRow, aQueryParam.nDestTab,
- InsertDeleteFlags::ALL, false, rDoc );
+ xUndoDoc->CopyToDocument(aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
+ nDestEndCol, nDestEndRow, aQueryParam.nDestTab,
+ InsertDeleteFlags::ALL, false, rDoc);
// Attributes are always copied (#49287#)
// rest of the old range
if ( bDestArea && !bDoSize )
{
rDoc.DeleteAreaTab( aOldDest, InsertDeleteFlags::ALL );
- pUndoDoc->CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, rDoc);
+ xUndoDoc->CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, rDoc);
}
}
else
- pUndoDoc->CopyToDocument(0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab,
+ xUndoDoc->CopyToDocument(0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab,
InsertDeleteFlags::NONE, false, rDoc);
- if (pUndoDB)
- rDoc.SetDBCollection( new ScDBCollection( *pUndoDB ), true );
+ if (xUndoDB)
+ rDoc.SetDBCollection(new ScDBCollection(*xUndoDB ), true);
if (!bCopy)
{
@@ -1042,24 +1008,16 @@ ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab,
aImportParam( rParam ),
nEndCol( nNewEndX ),
nEndRow( nNewEndY ),
- pUndoDoc( pNewUndoDoc ),
- pRedoDoc( pNewRedoDoc ),
- pUndoDBData( pNewUndoData ),
- pRedoDBData( pNewRedoData ),
+ xUndoDoc(pNewUndoDoc),
+ xRedoDoc(pNewRedoDoc),
+ xUndoDBData(pNewUndoData),
+ xRedoDBData(pNewRedoData),
nFormulaCols( nNewFormula ),
bRedoFilled( false )
{
// redo doc doesn't contain imported data (but everything else)
}
-ScUndoImportData::~ScUndoImportData()
-{
- delete pUndoDoc;
- delete pRedoDoc;
- delete pUndoDBData;
- delete pRedoDBData;
-}
-
OUString ScUndoImportData::GetComment() const
{
return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA );
@@ -1079,11 +1037,11 @@ void ScUndoImportData::Undo()
SCCOL nCol1, nCol2;
SCROW nRow1, nRow2;
ScDBData* pCurrentData = nullptr;
- if (pUndoDBData && pRedoDBData)
+ if (xUndoDBData && xRedoDBData)
{
- pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
- pCurrentData = ScUndoUtil::GetOldDBData( pRedoDBData, &rDoc, nTab,
- nCol1, nRow1, nCol2, nRow2 );
+ xRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ pCurrentData = ScUndoUtil::GetOldDBData(xRedoDBData.get(), &rDoc, nTab,
+ nCol1, nRow1, nCol2, nRow2);
if ( !bRedoFilled )
{
@@ -1096,22 +1054,22 @@ void ScUndoImportData::Undo()
for (SCCOL nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++)
{
rDoc.CopyToDocument(nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab,
- InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE, false, *pRedoDoc);
- rDoc.DeleteAreaTab(nCopyCol,nRow1, nCopyCol,nRow2, nTab, InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE);
+ InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE, false, *xRedoDoc);
+ rDoc.DeleteAreaTab(nCopyCol, nRow1, nCopyCol, nRow2, nTab, InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE);
}
rDoc.SetAutoCalc( bOldAutoCalc );
bRedoFilled = true;
}
}
- bool bMoveCells = pUndoDBData && pRedoDBData &&
- pRedoDBData->IsDoSize(); // the same in old and new
+ bool bMoveCells = xUndoDBData && xRedoDBData &&
+ xRedoDBData->IsDoSize(); // the same in old and new
if (bMoveCells)
{
// Undo: first delete the new data, then FitBlock backwards
ScRange aOld, aNew;
- pUndoDBData->GetArea( aOld );
- pRedoDBData->GetArea( aNew );
+ xUndoDBData->GetArea(aOld);
+ xRedoDBData->GetArea(aNew);
rDoc.DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
@@ -1124,15 +1082,15 @@ void ScUndoImportData::Undo()
rDoc.DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
nEndCol,nEndRow, nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pUndoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab,
+ xUndoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab,
nEndCol+nFormulaCols,nEndRow,nTab,
InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc);
if (pCurrentData)
{
- *pCurrentData = *pUndoDBData;
+ *pCurrentData = *xUndoDBData;
- pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ xUndoDBData->GetArea(nTable, nCol1, nRow1, nCol2, nRow2);
ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
}
@@ -1164,21 +1122,21 @@ void ScUndoImportData::Redo()
SCCOL nCol1, nCol2;
SCROW nRow1, nRow2;
ScDBData* pCurrentData = nullptr;
- if (pUndoDBData && pRedoDBData)
+ if (xUndoDBData && xRedoDBData)
{
- pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
- pCurrentData = ScUndoUtil::GetOldDBData( pUndoDBData, &rDoc, nTab,
- nCol1, nRow1, nCol2, nRow2 );
+ xUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ pCurrentData = ScUndoUtil::GetOldDBData(xUndoDBData.get(), &rDoc, nTab,
+ nCol1, nRow1, nCol2, nRow2);
}
- bool bMoveCells = pUndoDBData && pRedoDBData &&
- pRedoDBData->IsDoSize(); // the same in old and new
+ bool bMoveCells = xUndoDBData && xRedoDBData &&
+ xRedoDBData->IsDoSize(); // the same in old and new
if (bMoveCells)
{
// Redo: FitBlock, then delete data (needed for CopyToDocument)
ScRange aOld, aNew;
- pUndoDBData->GetArea( aOld );
- pRedoDBData->GetArea( aNew );
+ xUndoDBData->GetArea(aOld);
+ xRedoDBData->GetArea(aNew);
aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock also for formulas
aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
@@ -1187,21 +1145,21 @@ void ScUndoImportData::Redo()
rDoc.DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pRedoDoc->CopyToDocument(aNew, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); // including formulas
+ xRedoDoc->CopyToDocument(aNew, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); // including formulas
}
else
{
rDoc.DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
nEndCol,nEndRow, nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE );
- pRedoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab,
+ xRedoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab,
nEndCol,nEndRow,nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc);
}
if (pCurrentData)
{
- *pCurrentData = *pRedoDBData;
+ *pCurrentData = *xRedoDBData;
- pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ xRedoDBData->GetArea(nTable, nCol1, nRow1, nCol2, nRow2);
ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
}
@@ -1236,9 +1194,9 @@ void ScUndoImportData::Repeat(SfxRepeatTarget& rTarget)
bool ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const
{
- // Repeat only for import using a database range, then pUndoDBData is set
+ // Repeat only for import using a database range, then xUndoDBData is set
- if (pUndoDBData)
+ if (xUndoDBData)
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
else
return false; // Address book
@@ -1255,10 +1213,10 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
aBlockEnd( nEndX,nEndY,nNewTab ),
nNewEndRow( nResultEndRow ),
aCursorPos( nCurX,nCurY,nNewTab ),
- pUndoDoc( pNewUndoDoc ),
- pUndoTable( pNewUndoTab ),
- pUndoRange( pNewUndoRange ),
- pUndoDB( pNewUndoDB ),
+ xUndoDoc(pNewUndoDoc),
+ xUndoTable(pNewUndoTab),
+ xUndoRange(pNewUndoRange),
+ xUndoDB(pNewUndoDB),
bQuerySize( false )
{
if ( pOldQ && pNewQ )
@@ -1269,14 +1227,6 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
}
}
-ScUndoRepeatDB::~ScUndoRepeatDB()
-{
- delete pUndoDoc;
- delete pUndoTable;
- delete pUndoRange;
- delete pUndoDB;
-}
-
OUString ScUndoRepeatDB::GetComment() const
{
return ScGlobal::GetRscString( STR_UNDO_REPEATDB );
@@ -1330,22 +1280,22 @@ void ScUndoRepeatDB::Undo()
}
// Original Outline table
- rDoc.SetOutlineTable( nTab, pUndoTable );
+ rDoc.SetOutlineTable(nTab, xUndoTable.get());
// Original column/row status
- if (pUndoTable)
+ if (xUndoTable)
{
SCCOLROW nStartCol;
SCCOLROW nStartRow;
SCCOLROW nEndCol;
SCCOLROW nEndRow;
- pUndoTable->GetColArray().GetRange( nStartCol, nEndCol );
- pUndoTable->GetRowArray().GetRange( nStartRow, nEndRow );
+ xUndoTable->GetColArray().GetRange(nStartCol, nEndCol);
+ xUndoTable->GetRowArray().GetRange(nStartRow, nEndRow);
- pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
+ xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab,
static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false,
rDoc);
- pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc);
pViewShell->UpdateScrollBars();
}
@@ -1356,18 +1306,18 @@ void ScUndoRepeatDB::Undo()
rDoc.DeleteAreaTab( 0, aBlockStart.Row(),
MAXCOL, aBlockEnd.Row(), nTab, InsertDeleteFlags::ALL );
- pUndoDoc->CopyToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
+ xUndoDoc->CopyToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
InsertDeleteFlags::NONE, false, rDoc); // Flags
- pUndoDoc->UndoToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
+ xUndoDoc->UndoToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
InsertDeleteFlags::ALL, false, rDoc);
ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
aBlockEnd.Col(),aBlockEnd.Row(),nTab );
- if (pUndoRange)
- rDoc.SetRangeName( new ScRangeName( *pUndoRange ) );
- if (pUndoDB)
- rDoc.SetDBCollection( new ScDBCollection( *pUndoDB ), true );
+ if (xUndoRange)
+ rDoc.SetRangeName(new ScRangeName(*xUndoRange));
+ if (xUndoDB)
+ rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true);
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
if ( nVisTab != nTab )
@@ -1412,34 +1362,24 @@ bool ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoDataPilot::ScUndoDataPilot( ScDocShell* pNewDocShell,
ScDocument* pOldDoc, ScDocument* pNewDoc,
- const ScDPObject* pOldObj, const ScDPObject* pNewObj, bool bMove ) :
- ScSimpleUndo( pNewDocShell ),
- pOldUndoDoc( pOldDoc ),
- pNewUndoDoc( pNewDoc ),
- pOldDPObject( nullptr ),
- pNewDPObject( nullptr ),
- bAllowMove( bMove )
+ const ScDPObject* pOldObj, const ScDPObject* pNewObj, bool bMove )
+ : ScSimpleUndo(pNewDocShell)
+ , xOldUndoDoc(pOldDoc)
+ , xNewUndoDoc(pNewDoc)
+ , bAllowMove( bMove)
{
if (pOldObj)
- pOldDPObject = new ScDPObject( *pOldObj );
+ xOldDPObject.reset(new ScDPObject(*pOldObj));
if (pNewObj)
- pNewDPObject = new ScDPObject( *pNewObj );
-}
-
-ScUndoDataPilot::~ScUndoDataPilot()
-{
- delete pOldDPObject;
- delete pNewDPObject;
- delete pOldUndoDoc;
- delete pNewUndoDoc;
+ xNewDPObject.reset(new ScDPObject(*pNewObj));
}
OUString ScUndoDataPilot::GetComment() const
{
sal_uInt16 nIndex;
- if ( pOldUndoDoc && pNewUndoDoc )
+ if (xOldUndoDoc && xNewUndoDoc)
nIndex = STR_UNDO_PIVOT_MODIFY;
- else if ( pNewUndoDoc )
+ else if (xNewUndoDoc)
nIndex = STR_UNDO_PIVOT_NEW;
else
nIndex = STR_UNDO_PIVOT_DELETE;
@@ -1456,22 +1396,21 @@ void ScUndoDataPilot::Undo()
ScRange aOldRange;
ScRange aNewRange;
- if ( pNewDPObject && pNewUndoDoc )
+ if (xNewDPObject && xNewUndoDoc)
{
- aNewRange = pNewDPObject->GetOutRange();
+ aNewRange = xNewDPObject->GetOutRange();
rDoc.DeleteAreaTab( aNewRange, InsertDeleteFlags::ALL );
- pNewUndoDoc->CopyToDocument(aNewRange, InsertDeleteFlags::ALL, false, rDoc);
+ xNewUndoDoc->CopyToDocument(aNewRange, InsertDeleteFlags::ALL, false, rDoc);
}
- if ( pOldDPObject && pOldUndoDoc )
+ if (xOldDPObject && xOldUndoDoc)
{
- aOldRange = pOldDPObject->GetOutRange();
- rDoc.DeleteAreaTab( aOldRange, InsertDeleteFlags::ALL );
- pOldUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc);
+ aOldRange = xOldDPObject->GetOutRange();
+ rDoc.DeleteAreaTab(aOldRange, InsertDeleteFlags::ALL);
+ xOldUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc);
}
// update objects in collection
-
- if ( pNewDPObject )
+ if (xNewDPObject)
{
// find updated object
//! find by name!
@@ -1481,15 +1420,15 @@ void ScUndoDataPilot::Undo()
OSL_ENSURE(pDocObj, "DPObject not found");
if (pDocObj)
{
- if ( pOldDPObject )
+ if (xOldDPObject)
{
// restore old settings
- pOldDPObject->WriteSourceDataTo( *pDocObj );
- ScDPSaveData* pData = pOldDPObject->GetSaveData();
+ xOldDPObject->WriteSourceDataTo( *pDocObj );
+ ScDPSaveData* pData = xOldDPObject->GetSaveData();
if (pData)
pDocObj->SetSaveData(*pData);
- pDocObj->SetOutRange( pOldDPObject->GetOutRange() );
- pOldDPObject->WriteTempDataTo( *pDocObj );
+ pDocObj->SetOutRange(xOldDPObject->GetOutRange());
+ xOldDPObject->WriteTempDataTo( *pDocObj );
}
else
{
@@ -1498,11 +1437,11 @@ void ScUndoDataPilot::Undo()
}
}
}
- else if ( pOldDPObject )
+ else if (xOldDPObject)
{
// re-insert deleted object
- ScDPObject* pDestObj = new ScDPObject( *pOldDPObject );
+ ScDPObject* pDestObj = new ScDPObject(*xOldDPObject);
if ( !rDoc.GetDPCollection()->InsertNewTable(pDestObj) )
{
OSL_FAIL("cannot insert DPObject");
@@ -1510,10 +1449,10 @@ void ScUndoDataPilot::Undo()
}
}
- if (pNewUndoDoc)
- pDocShell->PostPaint( aNewRange, PaintPartFlags::Grid, SC_PF_LINES );
- if (pOldUndoDoc)
- pDocShell->PostPaint( aOldRange, PaintPartFlags::Grid, SC_PF_LINES );
+ if (xNewUndoDoc)
+ pDocShell->PostPaint(aNewRange, PaintPartFlags::Grid, SC_PF_LINES);
+ if (xOldUndoDoc)
+ pDocShell->PostPaint(aOldRange, PaintPartFlags::Grid, SC_PF_LINES);
pDocShell->PostDataChanged();
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
@@ -1522,10 +1461,10 @@ void ScUndoDataPilot::Undo()
//! set current sheet
}
- if (pNewDPObject)
+ if (xNewDPObject)
{
// notify API objects
- rDoc.BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) );
+ rDoc.BroadcastUno(ScDataPilotModifiedHint(xNewDPObject->GetName()));
}
EndUndo();
@@ -1541,19 +1480,19 @@ void ScUndoDataPilot::Redo()
ScDocument& rDoc = pDocShell->GetDocument();
ScDPObject* pSourceObj = nullptr;
- if ( pOldDPObject )
+ if (xOldDPObject)
{
// find object to modify
//! find by name!
- ScRange aOldRange = pOldDPObject->GetOutRange();
+ ScRange aOldRange = xOldDPObject->GetOutRange();
pSourceObj = rDoc.GetDPAtCursor(
aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aStart.Tab() );
OSL_ENSURE(pSourceObj, "DPObject not found");
}
ScDBDocFunc aFunc( *pDocShell );
- aFunc.DataPilotUpdate( pSourceObj, pNewDPObject, false, false, bAllowMove ); // no new undo action
+ aFunc.DataPilotUpdate(pSourceObj, xNewDPObject.get(), false, false, bAllowMove); // no new undo action
EndRedo();
}
@@ -1572,25 +1511,18 @@ bool ScUndoDataPilot::CanRepeat(SfxRepeatTarget& /* rTarget */) const
ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea,
const ScConsolidateParam& rPar, ScDocument* pNewUndoDoc,
bool bReference, SCROW nInsCount, ScOutlineTable* pTab,
- ScDBData* pData ) :
- ScSimpleUndo( pNewDocShell ),
- aDestArea( rArea ),
- pUndoDoc( pNewUndoDoc ),
- aParam( rPar ),
- bInsRef( bReference ),
- nInsertCount( nInsCount ),
- pUndoTab( pTab ),
- pUndoData( pData )
+ ScDBData* pData )
+ : ScSimpleUndo(pNewDocShell)
+ , aDestArea(rArea)
+ , xUndoDoc(pNewUndoDoc)
+ , aParam(rPar)
+ , bInsRef(bReference)
+ , nInsertCount(nInsCount)
+ , xUndoTab(pTab)
+ , xUndoData(pData)
{
}
-ScUndoConsolidate::~ScUndoConsolidate()
-{
- delete pUndoDoc;
- delete pUndoTab;
- delete pUndoData;
-}
-
OUString ScUndoConsolidate::GetComment() const
{
return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE );
@@ -1604,28 +1536,28 @@ void ScUndoConsolidate::Undo()
SCTAB nTab = aDestArea.nTab;
ScRange aOldRange;
- if (pUndoData)
- pUndoData->GetArea(aOldRange);
+ if (xUndoData)
+ xUndoData->GetArea(aOldRange);
if (bInsRef)
{
rDoc.DeleteRow( 0,nTab, MAXCOL,nTab, aDestArea.nRowStart, nInsertCount );
- rDoc.SetOutlineTable( nTab, pUndoTab );
+ rDoc.SetOutlineTable(nTab, xUndoTab.get());
// Row status
- pUndoDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, InsertDeleteFlags::NONE, false, rDoc);
+ xUndoDoc->CopyToDocument(0, 0, nTab, MAXCOL, MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc);
// Data and references
rDoc.DeleteAreaTab( 0,aDestArea.nRowStart, MAXCOL,aDestArea.nRowEnd, nTab, InsertDeleteFlags::ALL );
- pUndoDoc->UndoToDocument(0, aDestArea.nRowStart, nTab,
+ xUndoDoc->UndoToDocument(0, aDestArea.nRowStart, nTab,
MAXCOL, aDestArea.nRowEnd, nTab,
InsertDeleteFlags::ALL, false, rDoc);
// Original range
- if (pUndoData)
+ if (xUndoData)
{
rDoc.DeleteAreaTab(aOldRange, InsertDeleteFlags::ALL);
- pUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc);
+ xUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc);
}
pDocShell->PostPaint( 0,aDestArea.nRowStart,nTab, MAXCOL,MAXROW,nTab,
@@ -1635,20 +1567,20 @@ void ScUndoConsolidate::Undo()
{
rDoc.DeleteAreaTab( aDestArea.nColStart,aDestArea.nRowStart,
aDestArea.nColEnd,aDestArea.nRowEnd, nTab, InsertDeleteFlags::ALL );
- pUndoDoc->CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, nTab,
+ xUndoDoc->CopyToDocument(aDestArea.nColStart, aDestArea.nRowStart, nTab,
aDestArea.nColEnd, aDestArea.nRowEnd, nTab,
InsertDeleteFlags::ALL, false, rDoc);
// Original range
- if (pUndoData)
+ if (xUndoData)
{
rDoc.DeleteAreaTab(aOldRange, InsertDeleteFlags::ALL);
- pUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc);
+ xUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc);
}
SCCOL nEndX = aDestArea.nColEnd;
SCROW nEndY = aDestArea.nRowEnd;
- if ( pUndoData )
+ if (xUndoData)
{
if ( aOldRange.aEnd.Col() > nEndX )
nEndX = aOldRange.aEnd.Col();
@@ -1660,14 +1592,14 @@ void ScUndoConsolidate::Undo()
}
// Adjust Database range again
- if (pUndoData)
+ if (xUndoData)
{
ScDBCollection* pColl = rDoc.GetDBCollection();
if (pColl)
{
- ScDBData* pDocData = pColl->getNamedDBs().findByUpperName(pUndoData->GetUpperName());
+ ScDBData* pDocData = pColl->getNamedDBs().findByUpperName(xUndoData->GetUpperName());
if (pDocData)
- *pDocData = *pUndoData;
+ *pDocData = *xUndoData;
}
}
@@ -1788,70 +1720,61 @@ ScUndoDataForm::ScUndoDataForm( ScDocShell* pNewDocShell,
const ScMarkData& rMark,
ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
InsertDeleteFlags nNewFlags,
- ScRefUndoData* pRefData ) :
- ScBlockUndo( pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE ),
- mpMarkData(new ScMarkData(rMark)),
- pUndoDoc( pNewUndoDoc ),
- pRedoDoc( pNewRedoDoc ),
- nFlags( nNewFlags ),
- pRefUndoData( pRefData ),
- pRefRedoData( nullptr ),
- bRedoFilled( false )
-{
- // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting)
- // don't have to be changed and branched for 641.
- // They can be removed later.
-
- if (!mpMarkData->IsMarked()) // no cell marked:
- mpMarkData->SetMarkArea(aBlockRange); // mark paste block
-
- if ( pRefUndoData )
- pRefUndoData->DeleteUnchanged( &pDocShell->GetDocument() );
+ ScRefUndoData* pRefData )
+ : ScBlockUndo(pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE)
+ , mxMarkData(new ScMarkData(rMark))
+ , xUndoDoc(pNewUndoDoc)
+ , xRedoDoc(pNewRedoDoc)
+ , nFlags(nNewFlags)
+ , xRefUndoData(pRefData)
+ , bRedoFilled(false)
+{
+ // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting)
+ // don't have to be changed and branched for 641.
+ // They can be removed later.
- SetChangeTrack();
-}
+ if (!mxMarkData->IsMarked()) // no cell marked:
+ mxMarkData->SetMarkArea(aBlockRange); // mark paste block
-ScUndoDataForm::~ScUndoDataForm()
-{
- delete pUndoDoc;
- delete pRedoDoc;
- delete pRefUndoData;
- delete pRefRedoData;
+ if (xRefUndoData)
+ xRefUndoData->DeleteUnchanged(&pDocShell->GetDocument());
+
+ SetChangeTrack();
}
OUString ScUndoDataForm::GetComment() const
{
- return ScGlobal::GetRscString( STR_UNDO_PASTE );
+ return ScGlobal::GetRscString( STR_UNDO_PASTE );
}
void ScUndoDataForm::SetChangeTrack()
{
- ScChangeTrack* pChangeTrack = pDocShell->GetDocument().GetChangeTrack();
- if ( pChangeTrack && (nFlags & InsertDeleteFlags::CONTENTS) )
- pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
- nStartChangeAction, nEndChangeAction, SC_CACM_PASTE );
- else
- nStartChangeAction = nEndChangeAction = 0;
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument().GetChangeTrack();
+ if ( pChangeTrack && (nFlags & InsertDeleteFlags::CONTENTS) )
+ pChangeTrack->AppendContentRange(aBlockRange, xUndoDoc.get(),
+ nStartChangeAction, nEndChangeAction, SC_CACM_PASTE);
+ else
+ nStartChangeAction = nEndChangeAction = 0;
}
void ScUndoDataForm::Undo()
{
- BeginUndo();
- DoChange( true );
- ShowTable( aBlockRange );
- EndUndo();
- SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
+ BeginUndo();
+ DoChange( true );
+ ShowTable( aBlockRange );
+ EndUndo();
+ SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
}
void ScUndoDataForm::Redo()
{
- BeginRedo();
- ScDocument& rDoc = pDocShell->GetDocument();
- EnableDrawAdjust( &rDoc, false ); //! include in ScBlockUndo?
- DoChange( false );
- EnableDrawAdjust( &rDoc, true ); //! include in ScBlockUndo?
- EndRedo();
- SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
+ BeginRedo();
+ ScDocument& rDoc = pDocShell->GetDocument();
+ EnableDrawAdjust( &rDoc, false ); //! include in ScBlockUndo?
+ DoChange( false );
+ EnableDrawAdjust( &rDoc, true ); //! include in ScBlockUndo?
+ EndRedo();
+ SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
}
void ScUndoDataForm::Repeat(SfxRepeatTarget& /*rTarget*/)
@@ -1860,7 +1783,7 @@ void ScUndoDataForm::Repeat(SfxRepeatTarget& /*rTarget*/)
bool ScUndoDataForm::CanRepeat(SfxRepeatTarget& rTarget) const
{
- return (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr);
+ return (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr);
}
void ScUndoDataForm::DoChange( const bool bUndo )
@@ -1869,11 +1792,11 @@ void ScUndoDataForm::DoChange( const bool bUndo )
// RefUndoData for redo is created before first undo
// (with DeleteUnchanged after the DoUndo call)
- bool bCreateRedoData = ( bUndo && pRefUndoData && !pRefRedoData );
- if ( bCreateRedoData )
- pRefRedoData = new ScRefUndoData( &rDoc );
+ bool bCreateRedoData = (bUndo && xRefUndoData && !xRefRedoData);
+ if (bCreateRedoData)
+ xRefRedoData.reset(new ScRefUndoData(&rDoc));
- ScRefUndoData* pWorkRefData = bUndo ? pRefUndoData : pRefRedoData;
+ ScRefUndoData* pWorkRefData = bUndo ? xRefUndoData.get() : xRefRedoData.get();
// Always back-up either all or none of the content for Undo
InsertDeleteFlags nUndoFlags = InsertDeleteFlags::NONE;
@@ -1889,20 +1812,20 @@ void ScUndoDataForm::DoChange( const bool bUndo )
SCTAB nTabCount = rDoc.GetTableCount();
if ( bUndo && !bRedoFilled )
{
- if (!pRedoDoc)
+ if (!xRedoDoc)
{
bool bColInfo = ( aBlockRange.aStart.Row()==0 && aBlockRange.aEnd.Row()==MAXROW );
bool bRowInfo = ( aBlockRange.aStart.Col()==0 && aBlockRange.aEnd.Col()==MAXCOL );
- pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
- pRedoDoc->InitUndoSelected( &rDoc, *mpMarkData, bColInfo, bRowInfo );
+ xRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
+ xRedoDoc->InitUndoSelected(&rDoc, *mxMarkData, bColInfo, bRowInfo);
}
// read "redo" data from the document in the first undo
// all sheets - CopyToDocument skips those that don't exist in pRedoDoc
ScRange aCopyRange = aBlockRange;
aCopyRange.aStart.SetTab(0);
aCopyRange.aEnd.SetTab(nTabCount-1);
- rDoc.CopyToDocument(aCopyRange, InsertDeleteFlags::VALUE, false, *pRedoDoc);
+ rDoc.CopyToDocument(aCopyRange, InsertDeleteFlags::VALUE, false, *xRedoDoc);
bRedoFilled = true;
}
@@ -1911,7 +1834,7 @@ void ScUndoDataForm::DoChange( const bool bUndo )
for ( sal_uInt16 i=0; i <= ( aBlockRange.aEnd.Col() - aBlockRange.aStart.Col() ); i++ )
{
- OUString aOldString = pUndoDoc->GetString(
+ OUString aOldString = xUndoDoc->GetString(
aBlockRange.aStart.Col()+i, aBlockRange.aStart.Row(), aBlockRange.aStart.Tab());
rDoc.SetString( aBlockRange.aStart.Col()+i , aBlockRange.aStart.Row() , aBlockRange.aStart.Tab() , aOldString );
}
@@ -1923,8 +1846,8 @@ void ScUndoDataForm::DoChange( const bool bUndo )
bPaintAll = true;
}
- if ( bCreateRedoData && pRefRedoData )
- pRefRedoData->DeleteUnchanged( &rDoc );
+ if (bCreateRedoData && xRefRedoData)
+ xRefRedoData->DeleteUnchanged(&rDoc);
if ( bUndo )
{
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 5a4f873ea4a7..0e5416638173 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -858,20 +858,18 @@ bool ScUndoMakeScenario::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
-ScUndoImportTab::ScUndoImportTab( ScDocShell* pShell,
- SCTAB nNewTab, SCTAB nNewCount ) :
- ScSimpleUndo( pShell ),
- nTab( nNewTab ),
- nCount( nNewCount ),
- pRedoDoc( nullptr ),
- pDrawUndo( nullptr )
+ScUndoImportTab::ScUndoImportTab(ScDocShell* pShell,
+ SCTAB nNewTab, SCTAB nNewCount)
+ : ScSimpleUndo(pShell)
+ , nTab(nNewTab)
+ , nCount(nNewCount)
+ , pDrawUndo(nullptr)
{
pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
}
ScUndoImportTab::~ScUndoImportTab()
{
- delete pRedoDoc;
DeleteSdrUndoAction( pDrawUndo );
}
@@ -908,38 +906,38 @@ void ScUndoImportTab::Undo()
SCTAB i;
ScDocument& rDoc = pDocShell->GetDocument();
- bool bMakeRedo = !pRedoDoc;
+ bool bMakeRedo = !xRedoDoc;
if (bMakeRedo)
{
- pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
- pRedoDoc->InitUndo( &rDoc, nTab,nTab+nCount-1, true,true );
+ xRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
+ xRedoDoc->InitUndo(&rDoc, nTab,nTab+nCount-1, true, true);
OUString aOldName;
for (i=0; i<nCount; i++)
{
SCTAB nTabPos=nTab+i;
- rDoc.CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, *pRedoDoc);
+ rDoc.CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, *xRedoDoc);
rDoc.GetName( nTabPos, aOldName );
- pRedoDoc->RenameTab( nTabPos, aOldName, false );
- pRedoDoc->SetTabBgColor( nTabPos, rDoc.GetTabBgColor(nTabPos) );
+ xRedoDoc->RenameTab(nTabPos, aOldName, false);
+ xRedoDoc->SetTabBgColor(nTabPos, rDoc.GetTabBgColor(nTabPos));
if ( rDoc.IsScenario(nTabPos) )
{
- pRedoDoc->SetScenario(nTabPos, true );
+ xRedoDoc->SetScenario(nTabPos, true);
OUString aComment;
Color aColor;
ScScenarioFlags nScenFlags;
rDoc.GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
- pRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags );
+ xRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags);
bool bActive = rDoc.IsActiveScenario(nTabPos);
- pRedoDoc->SetActiveScenario(nTabPos, bActive );
+ xRedoDoc->SetActiveScenario(nTabPos, bActive);
bool bVisible = rDoc.IsVisible(nTabPos);
- pRedoDoc->SetVisible(nTabPos,bVisible );
+ xRedoDoc->SetVisible(nTabPos, bVisible);
}
if ( rDoc.IsTabProtected( nTabPos ) )
- pRedoDoc->SetTabProtection(nTabPos, rDoc.GetTabProtection(nTabPos));
+ xRedoDoc->SetTabProtection(nTabPos, rDoc.GetTabProtection(nTabPos));
}
}
@@ -956,7 +954,7 @@ void ScUndoImportTab::Undo()
void ScUndoImportTab::Redo()
{
- if (!pRedoDoc)
+ if (!xRedoDoc)
{
OSL_FAIL("Where is my Redo Document?");
return;
@@ -968,7 +966,7 @@ void ScUndoImportTab::Redo()
for (i=0; i<nCount; i++) // first insert all sheets (#63304#)
{
SCTAB nTabPos=nTab+i;
- pRedoDoc->GetName(nTabPos,aName);
+ xRedoDoc->GetName(nTabPos, aName);
bDrawIsInUndo = true;
rDoc.InsertTab(nTabPos,aName);
bDrawIsInUndo = false;
@@ -976,25 +974,25 @@ void ScUndoImportTab::Redo()
for (i=0; i<nCount; i++) // then copy into inserted sheets
{
SCTAB nTabPos=nTab+i;
- pRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, rDoc);
- rDoc.SetTabBgColor( nTabPos, pRedoDoc->GetTabBgColor(nTabPos) );
+ xRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, rDoc);
+ rDoc.SetTabBgColor(nTabPos, xRedoDoc->GetTabBgColor(nTabPos));
- if ( pRedoDoc->IsScenario(nTabPos) )
+ if (xRedoDoc->IsScenario(nTabPos))
{
rDoc.SetScenario(nTabPos, true );
OUString aComment;
Color aColor;
ScScenarioFlags nScenFlags;
- pRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
+ xRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
rDoc.SetScenarioData(nTabPos, aComment, aColor, nScenFlags );
- bool bActive = pRedoDoc->IsActiveScenario(nTabPos);
+ bool bActive = xRedoDoc->IsActiveScenario(nTabPos);
rDoc.SetActiveScenario(nTabPos, bActive );
- bool bVisible=pRedoDoc->IsVisible(nTabPos);
+ bool bVisible = xRedoDoc->IsVisible(nTabPos);
rDoc.SetVisible(nTabPos,bVisible );
}
- if ( pRedoDoc->IsTabProtected( nTabPos ) )
- rDoc.SetTabProtection(nTabPos, pRedoDoc->GetTabProtection(nTabPos));
+ if (xRedoDoc->IsTabProtected(nTabPos))
+ rDoc.SetTabProtection(nTabPos, xRedoDoc->GetTabProtection(nTabPos));
}
RedoSdrUndoAction( pDrawUndo ); // after the sheets are inserted
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index 1f90c52d0525..ce7e6d9e038a 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -109,29 +109,21 @@ ScDocument* ScTempDocSource::GetDocument()
return rCache.GetDocument();
}
-ScTempDocCache::ScTempDocCache() :
- pDoc( nullptr ),
- bInUse( false )
+ScTempDocCache::ScTempDocCache()
+ : bInUse(false)
{
}
-ScTempDocCache::~ScTempDocCache()
-{
- OSL_ENSURE( !bInUse, "ScTempDocCache dtor: bInUse" );
- delete pDoc;
-}
-
void ScTempDocCache::SetDocument( ScDocument* pNew )
{
- OSL_ENSURE( !pDoc, "ScTempDocCache::SetDocument: already set" );
- pDoc = pNew;
+ OSL_ENSURE(!xDoc, "ScTempDocCache::SetDocument: already set");
+ xDoc.reset(pNew);
}
void ScTempDocCache::Clear()
{
OSL_ENSURE( !bInUse, "ScTempDocCache::Clear: bInUse" );
- delete pDoc;
- pDoc = nullptr;
+ xDoc.reset();
}
// copy results from one document into another