[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 2 commits - vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 22 08:11:13 UTC 2020
Rebased ref, commits from common ancestor:
commit 14e663ebff1db1bb6f7a97d8dcc0dafba9b48dad
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Apr 22 10:03:16 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Apr 22 10:03:16 2020 +0200
ImpGraphic: move filename handling from swapout to ImpSwapFile
Change-Id: I30930f61385e31e7754d6653ff2eecfea61ce4e1
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index f4da59cfcf40..9c5325ac528c 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -73,8 +73,8 @@ private:
OUString maOriginURL;
public:
- ImpSwapFile(INetURLObject const & aSwapURL, OUString const & rOriginURL)
- : maSwapURL(aSwapURL)
+ ImpSwapFile(INetURLObject const & rSwapURL, OUString const & rOriginURL)
+ : maSwapURL(rSwapURL)
, maOriginURL(rOriginURL)
{
}
@@ -84,8 +84,33 @@ public:
utl::UCBContentHelper::Kill(maSwapURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
}
- INetURLObject getSwapURL() { return maSwapURL; }
+ INetURLObject getSwapURL()
+ {
+ return maSwapURL;
+ }
+
+ OUString getSwapURLString()
+ {
+ return maSwapURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+ }
+
OUString const & getOriginURL() { return maOriginURL; }
+
+ std::unique_ptr<SvStream> openOutputStream()
+ {
+ OUString sSwapURL = getSwapURLString();
+ if (sSwapURL.isEmpty())
+ {
+ try
+ {
+ return utl::UcbStreamHelper::CreateStream(sSwapURL, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
+ }
+ catch (const css::uno::Exception&)
+ {
+ }
+ }
+ return std::unique_ptr<SvStream>();
+ }
};
ImpGraphic::ImpGraphic() :
@@ -1325,39 +1350,26 @@ bool ImpGraphic::swapOut()
utl::TempFile aTempFile;
const INetURLObject aTempFileURL(aTempFile.GetURL());
- OUString sTempFileURLString = aTempFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
- if (sTempFileURLString.isEmpty())
- return false;
- std::unique_ptr<SvStream> xOutputStream;
+ auto pSwapFile = std::make_shared<ImpSwapFile>(aTempFileURL, getOriginURL());
- try
- {
- xOutputStream = utl::UcbStreamHelper::CreateStream(sTempFileURLString, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
- }
- catch (const css::uno::Exception&)
- {
- }
+ std::unique_ptr<SvStream> xOutputStream = mpSwapFile->openOutputStream();
if (!xOutputStream)
return false;
+
xOutputStream->SetVersion(SOFFICE_FILEFORMAT_50);
xOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
bool bResult = swapOutToStream(xOutputStream.get());
- if (bResult)
- {
- mpSwapFile = std::make_shared<ImpSwapFile>(aTempFileURL, getOriginURL());
- }
- else
- {
- xOutputStream.reset();
- utl::UCBContentHelper::Kill(sTempFileURLString);
- }
+ xOutputStream.reset();
if (bResult)
+ {
+ mpSwapFile = pSwapFile;
vcl::graphic::Manager::get().swappedOut(this);
+ }
return bResult;
}
commit 8c22668c488ab72dbc9f42e8ed60a7fdb40a2c74
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Apr 20 22:29:04 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Apr 21 17:15:18 2020 +0200
ImpGraphic: clean-up and simplify swapOut()
Change-Id: I3e578c3172fcea341a218798843cd750971a5af1
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index f96aacc23b8d..f4da59cfcf40 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -73,7 +73,7 @@ private:
OUString maOriginURL;
public:
- ImpSwapFile(INetURLObject const & aSwapURL, OUString const & rOriginURL)
+ ImpSwapFile(INetURLObject const & aSwapURL, OUString const & rOriginURL)
: maSwapURL(aSwapURL)
, maOriginURL(rOriginURL)
{
@@ -1320,44 +1320,46 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
bool ImpGraphic::swapOut()
{
-
- if( isSwappedOut() )
+ if (isSwappedOut())
return false;
- ::utl::TempFile aTempFile;
- const INetURLObject aTmpURL( aTempFile.GetURL() );
+ utl::TempFile aTempFile;
+ const INetURLObject aTempFileURL(aTempFile.GetURL());
+ OUString sTempFileURLString = aTempFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
- if( aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ).isEmpty() )
+ if (sTempFileURLString.isEmpty())
return false;
+ std::unique_ptr<SvStream> xOutputStream;
- std::unique_ptr<SvStream> xOStm;
try
{
- xOStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
+ xOutputStream = utl::UcbStreamHelper::CreateStream(sTempFileURLString, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
}
- catch( const css::uno::Exception& )
+ catch (const css::uno::Exception&)
{
}
- if( !xOStm )
+
+ if (!xOutputStream)
return false;
+ xOutputStream->SetVersion(SOFFICE_FILEFORMAT_50);
+ xOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
- xOStm->SetVersion( SOFFICE_FILEFORMAT_50 );
- xOStm->SetCompressMode( SvStreamCompressFlags::NATIVE );
+ bool bResult = swapOutToStream(xOutputStream.get());
- bool bRet = swapOutToStream( xOStm.get() );
- if( bRet )
+ if (bResult)
{
- mpSwapFile = std::make_shared<ImpSwapFile>(aTmpURL, getOriginURL());
+ mpSwapFile = std::make_shared<ImpSwapFile>(aTempFileURL, getOriginURL());
}
else
{
- xOStm.reset();
- utl::UCBContentHelper::Kill(aTmpURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+ xOutputStream.reset();
+ utl::UCBContentHelper::Kill(sTempFileURLString);
}
- if (bRet)
+ if (bResult)
vcl::graphic::Manager::get().swappedOut(this);
- return bRet;
+
+ return bResult;
}
bool ImpGraphic::swapOutToStream(SvStream* xOStm)
More information about the Libreoffice-commits
mailing list