summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-02-04 00:33:14 +0100
committerJan Holesovsky <kendy@collabora.com>2014-02-04 09:11:29 +0100
commite2eda70f2746f08376d8cdf5e5360df217335aef (patch)
tree31051c577e388dc8f9730381e69e46a5735ae5cf /sfx2
parent56b404001ef83cc151727cc5a489dc493c6b65ec (diff)
startcenter: fdo#72469: Thumbnails also for other file types than ODF.
Change-Id: If905b2f3e51adf7e64df9385ede74368acd11771
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/newhelp.cxx2
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx28
-rw-r--r--sfx2/source/control/recentdocsview.cxx26
-rw-r--r--sfx2/source/control/recentdocsviewitem.cxx6
4 files changed, 51 insertions, 11 deletions
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index a1eed29606a5..206d45808e4e 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1250,7 +1250,7 @@ BookmarksBox_Impl::~BookmarksBox_Impl()
{
OUString aTitle = GetEntry(i);
OUString* pURL = (OUString*)(sal_uIntPtr)GetEntryData(i);
- aHistOpt.AppendItem( eHELPBOOKMARKS, OUString( *pURL ), sEmpty, OUString( aTitle ), sEmpty );
+ aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, sEmpty, aTitle, sEmpty, sEmpty);
delete pURL;
}
}
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index eac80211f7d0..a06002d5fd64 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -17,15 +17,17 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <unotools/historyoptions.hxx>
#include <unotools/useroptions.hxx>
#include <tools/urlobj.hxx>
#include <framework/menuconfiguration.hxx>
+#include <sax/tools/converter.hxx>
#include <svl/inethist.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/pngwrite.hxx>
#include <osl/file.hxx>
#include <unotools/localfilehelper.hxx>
#include <cppuhelper/implbase1.hxx>
@@ -188,12 +190,34 @@ void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
if ( pFilter )
aFilter = pFilter->GetFilterName();
+ // generate a thumbnail
+ OUString aThumbnail;
+ if (!pDocSh->IsModified())
+ {
+ // not modified => the document matches what is in the shell
+ boost::shared_ptr<GDIMetaFile> pMetaFile = pDocSh->GetPreviewMetaFile();
+ BitmapEx aResultBitmap;
+ if (pMetaFile->CreateThumbnail(aResultBitmap))
+ {
+ 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();
+ }
+ }
+ }
+
// add to svtool history options
SvtHistoryOptions().AppendItem( ePICKLIST,
aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
aFilter,
aTitle,
- OUString() );
+ OUString(),
+ aThumbnail);
if ( aURL.GetProtocol() == INET_PROT_FILE )
Application::AddToRecentDocumentList( aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx
index 5f225bccd249..34ae603bc238 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -17,14 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sax/tools/converter.hxx>
#include <sfx2/recentdocsview.hxx>
-#include <vcl/svapp.hxx>
#include <sfx2/templateabstractview.hxx>
#include <sfx2/app.hxx>
#include <sfx2/sfx.hrc>
#include <sfx2/sfxresid.hxx>
#include <unotools/historyoptions.hxx>
#include <vcl/builder.hxx>
+#include <vcl/pngread.hxx>
#include <vcl/svapp.hxx>
#include <tools/urlobj.hxx>
#include <com/sun/star/util/URLTransformer.hpp>
@@ -140,9 +141,9 @@ BitmapEx RecentDocsView::getDefaultThumbnail(const OUString &rURL)
return aImg;
}
-void RecentDocsView::insertItem(const OUString &rURL, const OUString &rTitle, sal_uInt16 nId)
+void RecentDocsView::insertItem(const OUString &rURL, const OUString &rTitle, const BitmapEx &rThumbnail, sal_uInt16 nId)
{
- RecentDocsViewItem *pChild = new RecentDocsViewItem(*this, rURL, rTitle, nId);
+ RecentDocsViewItem *pChild = new RecentDocsViewItem(*this, rURL, rTitle, rThumbnail, nId);
AppendItem(pChild);
}
@@ -158,6 +159,7 @@ void RecentDocsView::loadRecentDocs()
OUString aURL;
OUString aTitle;
+ BitmapEx aThumbnail;
for ( int j = 0; j < rRecentEntry.getLength(); j++ )
{
@@ -167,11 +169,25 @@ void RecentDocsView::loadRecentDocs()
a >>= aURL;
else if (rRecentEntry[j].Name == "Title")
a >>= aTitle;
+ else if (rRecentEntry[j].Name == "Thumbnail")
+ {
+ OUString aBase64;
+ a >>= aBase64;
+ if (!aBase64.isEmpty())
+ {
+ Sequence<sal_Int8> aDecoded;
+ sax::Converter::decodeBase64(aDecoded, aBase64);
+
+ SvMemoryStream aStream(aDecoded.getArray(), aDecoded.getLength(), STREAM_READ);
+ vcl::PNGReader aReader(aStream);
+ aThumbnail = aReader.Read();
+ }
+ }
}
- if( isAcceptedFile(aURL) )
+ if (isAcceptedFile(aURL))
{
- insertItem(aURL, aTitle, i+1);
+ insertItem(aURL, aTitle, aThumbnail, i+1);
}
}
diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx
index d1947e9a0b96..8c64fb4ddfd4 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -15,7 +15,7 @@
#include <tools/urlobj.hxx>
RecentDocsViewItem::RecentDocsViewItem(ThumbnailView &rView, const OUString &rURL,
- const OUString &rTitle, sal_uInt16 nId)
+ const OUString &rTitle, const BitmapEx &rThumbnail, sal_uInt16 nId)
: ThumbnailViewItem(rView, nId),
maURL(rURL)
{
@@ -33,8 +33,8 @@ RecentDocsViewItem::RecentDocsViewItem(ThumbnailView &rView, const OUString &rUR
if (aTitle.isEmpty())
aTitle = aURLObj.GetName(INetURLObject::DECODE_WITH_CHARSET);
- BitmapEx aThumbnail;
- if (aURLObj.GetProtocol() == INET_PROT_FILE)
+ BitmapEx aThumbnail(rThumbnail);
+ if (aThumbnail.IsEmpty() && aURLObj.GetProtocol() == INET_PROT_FILE)
aThumbnail = ThumbnailView::readThumbnail(rURL);
if (aThumbnail.IsEmpty())