[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - dbaccess/source include/unotools sfx2/source unotools/source
Maxim Monastirsky
momonasmon at gmail.com
Tue Jul 7 05:35:20 PDT 2015
dbaccess/source/ui/app/AppController.cxx | 2 -
include/unotools/historyoptions.hxx | 3 +-
sfx2/source/appl/newhelp.cxx | 2 -
sfx2/source/appl/sfxpicklist.cxx | 35 ++++++++++++++++++------------
unotools/source/config/historyoptions.cxx | 17 ++++++++------
5 files changed, 35 insertions(+), 24 deletions(-)
New commits:
commit 7c7836141b6f2e71b4c41227718b4b916f464f5a
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Tue Jun 30 20:30:33 2015 +0300
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.
Conflicts:
sfx2/source/appl/newhelp.cxx
sfx2/source/appl/sfxpicklist.cxx
Reviewed-on: https://gerrit.libreoffice.org/16659
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>
(cherry picked from commit d9c476bfbb4a8f1858c072d2fba33aa9e8e0ae92)
Change-Id: Ia7b1f3dbc9fbbc2ef1d87442c1dee25306f65826
Reviewed-on: https://gerrit.libreoffice.org/16765
Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
Tested-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 90d29b5..ff19b79 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -401,7 +401,7 @@ void SAL_CALL OApplicationController::disposing()
aFilter,
getStrippedDatabaseName(),
OUString(),
- OUString());
+ boost::none);
// add to recent document list
if ( aURL.GetProtocol() == INET_PROT_FILE )
diff --git a/include/unotools/historyoptions.hxx b/include/unotools/historyoptions.hxx
index e773a41..dce727f 100644
--- a/include/unotools/historyoptions.hxx
+++ b/include/unotools/historyoptions.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_UNOTOOLS_HISTORYOPTIONS_HXX
#define INCLUDED_UNOTOOLS_HISTORYOPTIONS_HXX
+#include <boost/optional.hpp>
#include <unotools/unotoolsdllapi.h>
#include <sal/types.h>
#include <osl/mutex.hxx>
@@ -94,7 +95,7 @@ public:
*/
void AppendItem(EHistoryType eHistory,
const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
- const OUString& sPassword, const OUString& sThumbnail);
+ const OUString& sPassword, const boost::optional<OUString>& sThumbnail);
/** Delete item from the specified list.
*/
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index baec605..aa4f574 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1147,7 +1147,7 @@ BookmarksBox_Impl::~BookmarksBox_Impl()
{
OUString aTitle = GetEntry(i);
OUString* pURL = reinterpret_cast<OUString*>(GetEntryData(i));
- aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, sEmpty, aTitle, sEmpty, sEmpty);
+ aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, sEmpty, aTitle, sEmpty, boost::none);
delete pURL;
}
}
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 0a6959f..f2d9a81 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -193,26 +193,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
- boost::shared_ptr<GDIMetaFile> pMetaFile = pDocSh->GetPreviewMetaFile();
- BitmapEx aResultBitmap;
- if (pMetaFile->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))
+ boost::shared_ptr<GDIMetaFile> pMetaFile = pDocSh->GetPreviewMetaFile();
+ BitmapEx aResultBitmap;
+ if (pMetaFile->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();
+ }
}
}
}
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx
index 7899c86..a5eee7e 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -86,7 +86,7 @@ public:
void AppendItem(EHistoryType eHistory,
const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
- const OUString& sPassword, const OUString& sThumbnail);
+ const OUString& sPassword, const boost::optional<OUString>& sThumbnail);
void DeleteItem(EHistoryType eHistory, const OUString& sURL);
@@ -346,7 +346,7 @@ Sequence< Sequence<PropertyValue> > SvtHistoryOptions_Impl::GetList(EHistoryType
void SvtHistoryOptions_Impl::AppendItem(EHistoryType eHistory,
const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
- const OUString& sPassword, const OUString& sThumbnail)
+ const OUString& sPassword, const boost::optional<OUString>& sThumbnail)
{
uno::Reference<container::XNameAccess> xListAccess(GetListAccess(eHistory));
if (!xListAccess.is())
@@ -371,9 +371,12 @@ void SvtHistoryOptions_Impl::AppendItem(EHistoryType eHistory,
// The item to be appended already exists
if (xItemList->hasByName(sURL))
{
- // update the thumbnail
- xItemList->getByName(sURL) >>= xSet;
- xSet->setPropertyValue(s_sThumbnail, uno::makeAny(sThumbnail));
+ if (sThumbnail)
+ {
+ // update the thumbnail
+ xItemList->getByName(sURL) >>= xSet;
+ xSet->setPropertyValue(s_sThumbnail, uno::makeAny(*sThumbnail));
+ }
for (sal_Int32 i=0; i<nLength; ++i)
{
@@ -460,7 +463,7 @@ void SvtHistoryOptions_Impl::AppendItem(EHistoryType eHistory,
xSet->setPropertyValue(s_sFilter, uno::makeAny(sFilter));
xSet->setPropertyValue(s_sTitle, uno::makeAny(sTitle));
xSet->setPropertyValue(s_sPassword, uno::makeAny(sPassword));
- xSet->setPropertyValue(s_sThumbnail, uno::makeAny(sThumbnail));
+ xSet->setPropertyValue(s_sThumbnail, uno::makeAny(sThumbnail.get_value_or(OUString())));
::comphelper::ConfigurationHelper::flush(m_xCfg);
}
@@ -599,7 +602,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions::GetList( EHistoryType e
void SvtHistoryOptions::AppendItem(EHistoryType eHistory,
const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
- const OUString& sPassword, const OUString& sThumbnail)
+ const OUString& sPassword, const boost::optional<OUString>& sThumbnail)
{
MutexGuard aGuard(theHistoryOptionsMutex::get());
More information about the Libreoffice-commits
mailing list