summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-06-30 20:30:33 +0300
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2015-07-07 07:27:47 -0500
commitab9132f4e2d3bf7c24dddba47b72b70c67d86374 (patch)
tree28830a9ff4cc2d009cb262a7a39d1d36158257da /sfx2
parent14b96e611d0618df6b8e85d394e8aa6350845cc4 (diff)
tdf#92431 Keep thumbnail for modified but unsaved doc
A regression of 1166966eb4112fdf332c656eae5082d82a3ec2f2. We need to consider 2 use-cases: 1. Protecting an existing document with a password (by overwriting the original file). In this case we don't want to generate a thumbnail from the now encrypted file, but we do want to erase the stored thumbnail and show a generic icon instead. 2. Closing a modified document without saving the changes. Here we don't want to generate a thumbnail either, because it may contain the unsaved changes, but either we don't want to replace the stored thumbnail, because most likely it correctly represents the last saved state of the document. Change-Id: Ia7b1f3dbc9fbbc2ef1d87442c1dee25306f65826 Reviewed-on: https://gerrit.libreoffice.org/16659 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com> (cherry picked from commit d9c476bfbb4a8f1858c072d2fba33aa9e8e0ae92) Signed-off-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/newhelp.cxx2
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx35
2 files changed, 22 insertions, 15 deletions
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 53d7614c8b9b..33b717d691dd 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1198,7 +1198,7 @@ void BookmarksBox_Impl::dispose()
{
OUString aTitle = GetEntry(i);
OUString* pURL = static_cast<OUString*>(GetEntryData(i));
- aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, sEmpty, aTitle, sEmpty, sEmpty);
+ aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, sEmpty, aTitle, sEmpty, boost::none);
delete pURL;
}
ListBox::dispose();
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 4ef292182a1b..0f3196df45cc 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -194,26 +194,33 @@ void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
aFilter = pFilter->GetFilterName();
// generate a thumbnail
- OUString aThumbnail;
+ boost::optional<OUString> aThumbnail;
// don't generate thumbnail when in headless mode, or on non-desktop (?)
#if HAVE_FEATURE_DESKTOP
- SFX_ITEMSET_ARG( pMed->GetItemSet(), pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, false );
-
- if (!pDocSh->IsModified() && !pEncryptionDataItem && !Application::IsHeadlessModeEnabled())
+ if (!pDocSh->IsModified() && !Application::IsHeadlessModeEnabled())
{
// not modified => the document matches what is in the shell
- std::shared_ptr<GDIMetaFile> xMetaFile = pDocSh->GetPreviewMetaFile();
- BitmapEx aResultBitmap;
- if (xMetaFile->CreateThumbnail(aResultBitmap))
+ SFX_ITEMSET_ARG( pMed->GetItemSet(), pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, false );
+ if ( pEncryptionDataItem )
+ {
+ // encrypted document, will show a generic document icon instead
+ aThumbnail = OUString();
+ }
+ else
{
- SvMemoryStream aStream(65535, 65535);
- vcl::PNGWriter aWriter(aResultBitmap);
- if (aWriter.Write(aStream))
+ std::shared_ptr<GDIMetaFile> xMetaFile = pDocSh->GetPreviewMetaFile();
+ BitmapEx aResultBitmap;
+ if (xMetaFile->CreateThumbnail(aResultBitmap))
{
- Sequence<sal_Int8> aSequence(static_cast<const sal_Int8*>(aStream.GetData()), aStream.Tell());
- OUStringBuffer aBuffer;
- ::sax::Converter::encodeBase64(aBuffer, aSequence);
- aThumbnail = aBuffer.makeStringAndClear();
+ SvMemoryStream aStream(65535, 65535);
+ vcl::PNGWriter aWriter(aResultBitmap);
+ if (aWriter.Write(aStream))
+ {
+ Sequence<sal_Int8> aSequence(static_cast<const sal_Int8*>(aStream.GetData()), aStream.Tell());
+ OUStringBuffer aBuffer;
+ ::sax::Converter::encodeBase64(aBuffer, aSequence);
+ aThumbnail = aBuffer.makeStringAndClear();
+ }
}
}
}