summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-26 19:02:37 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-28 13:50:46 +0200
commit772323b4a94e18794f9932f34297c26974e17c5a (patch)
treeeb6625d07aa53106ad5bc2e1daa3ef81e5bce24c /sfx2
parentb38de1f8f3712f0a632ff9b6fa10df2cf3ce268f (diff)
Reduce nesting / style in thumbnail creation routines
Change-Id: I733b677f4d4c7dfdf6fef531b43e1de36131f55d
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objstor.cxx83
1 files changed, 38 insertions, 45 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 6e8b659ff0a2..a79ea8c53585 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -3512,28 +3512,25 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( const uno::Reference< embed
return bResult;
}
-bool SfxObjectShell::GenerateAndStoreThumbnail( bool bEncrypted,
- bool bIsTemplate,
- const uno::Reference< embed::XStorage >& xStor )
+bool SfxObjectShell::GenerateAndStoreThumbnail(bool bEncrypted, bool bIsTemplate, const uno::Reference<embed::XStorage>& xStorage)
{
- bIsInGenerateThumbnail = true;//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
+ //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
+ bIsInGenerateThumbnail = true;
bool bResult = false;
- try {
- uno::Reference< embed::XStorage > xThumbnailStor =
- xStor->openStorageElement( OUString("Thumbnails"),
- embed::ElementModes::READWRITE );
- if ( xThumbnailStor.is() )
+ try
+ {
+ uno::Reference<embed::XStorage> xThumbnailStorage = xStorage->openStorageElement(OUString("Thumbnails"), embed::ElementModes::READWRITE);
+
+ if (xThumbnailStorage.is())
{
- uno::Reference< io::XStream > xStream = xThumbnailStor->openStreamElement(
- OUString("thumbnail.png"),
- embed::ElementModes::READWRITE );
+ uno::Reference<io::XStream> xStream = xThumbnailStorage->openStreamElement(OUString("thumbnail.png"), embed::ElementModes::READWRITE);
if (xStream.is() && WriteThumbnail(bEncrypted, bIsTemplate, xStream))
{
- uno::Reference< embed::XTransactedObject > xTransact( xThumbnailStor, uno::UNO_QUERY_THROW );
- xTransact->commit();
+ uno::Reference<embed::XTransactedObject> xTransactedObject(xThumbnailStorage, uno::UNO_QUERY_THROW);
+ xTransactedObject->commit();
bResult = true;
}
}
@@ -3542,49 +3539,45 @@ bool SfxObjectShell::GenerateAndStoreThumbnail( bool bEncrypted,
{
}
- bIsInGenerateThumbnail = false;//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
+ //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
+ bIsInGenerateThumbnail = false;
return bResult;
}
-bool SfxObjectShell::WriteThumbnail( bool bEncrypted,
- bool bIsTemplate,
- const uno::Reference< io::XStream >& xStream )
+bool SfxObjectShell::WriteThumbnail(bool bEncrypted, bool bIsTemplate, const uno::Reference<io::XStream>& xStream)
{
bool bResult = false;
- if ( xStream.is() )
+ if (!xStream.is())
+ return false;
+
+ try
{
- try {
- uno::Reference< io::XTruncate > xTruncate( xStream->getOutputStream(), uno::UNO_QUERY_THROW );
- xTruncate->truncate();
-
- uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
- if ( xSet.is() )
- xSet->setPropertyValue("MediaType",
- uno::makeAny( OUString("image/png") ) );
- if ( bEncrypted )
- {
- sal_uInt16 nResID = GraphicHelper::getThumbnailReplacementIDByFactoryName_Impl(
- OUString::createFromAscii( GetFactory().GetShortName() ),
- bIsTemplate );
- if ( nResID )
- bResult = GraphicHelper::getThumbnailReplacement_Impl(nResID, xStream);
- }
- else
+ uno::Reference<io::XTruncate> xTruncate(xStream->getOutputStream(), uno::UNO_QUERY_THROW);
+ xTruncate->truncate();
+
+ uno::Reference <beans::XPropertySet> xSet(xStream, uno::UNO_QUERY);
+ if (xSet.is())
+ xSet->setPropertyValue("MediaType", uno::makeAny(OUString("image/png")));
+ if (bEncrypted)
+ {
+ OUString sFactoryName = OUString::createFromAscii(GetFactory().GetShortName());
+ sal_uInt16 nResID = GraphicHelper::getThumbnailReplacementIDByFactoryName_Impl(sFactoryName, bIsTemplate);
+ if (nResID)
+ bResult = GraphicHelper::getThumbnailReplacement_Impl(nResID, xStream);
+ }
+ else
+ {
+ boost::shared_ptr<GDIMetaFile> pMetaFile = GetPreviewMetaFile(false);
+ if (pMetaFile)
{
- ::boost::shared_ptr<GDIMetaFile> pMetaFile =
- GetPreviewMetaFile( false );
- if ( pMetaFile )
- {
- bResult = GraphicHelper::getThumbnailFormatFromGDI_Impl(
- pMetaFile.get(), xStream);
- }
+ bResult = GraphicHelper::getThumbnailFormatFromGDI_Impl(pMetaFile.get(), xStream);
}
}
- catch( uno::Exception& )
- {}
}
+ catch(uno::Exception&)
+ {}
return bResult;
}