summaryrefslogtreecommitdiff
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
parent56b404001ef83cc151727cc5a489dc493c6b65ec (diff)
startcenter: fdo#72469: Thumbnails also for other file types than ODF.
Change-Id: If905b2f3e51adf7e64df9385ede74368acd11771
-rw-r--r--dbaccess/source/ui/app/AppController.cxx3
-rw-r--r--include/sfx2/recentdocsview.hxx2
-rw-r--r--include/sfx2/recentdocsviewitem.hxx2
-rw-r--r--include/unotools/historyoptions.hxx9
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Histories.xcs5
-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
-rw-r--r--unotools/source/config/historyoptions.cxx78
10 files changed, 91 insertions, 70 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 72fe127a3e83..8ef4d96d1413 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -403,7 +403,8 @@ void SAL_CALL OApplicationController::disposing()
aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
aFilter,
getStrippedDatabaseName(),
- OUString() );
+ OUString(),
+ OUString());
// add to recent document list
if ( aURL.GetProtocol() == INET_PROT_FILE )
diff --git a/include/sfx2/recentdocsview.hxx b/include/sfx2/recentdocsview.hxx
index 1706935a5ac8..93080251be6d 100644
--- a/include/sfx2/recentdocsview.hxx
+++ b/include/sfx2/recentdocsview.hxx
@@ -45,7 +45,7 @@ public:
RecentDocsView( Window* pParent );
virtual ~RecentDocsView();
- void insertItem(const OUString &rURL, const OUString &rTitle, sal_uInt16 nId);
+ void insertItem(const OUString &rURL, const OUString &rTitle, const BitmapEx &rThumbnail, sal_uInt16 nId);
void loadRecentDocs();
void SetThumbnailSize(long thumbnailSize);
diff --git a/include/sfx2/recentdocsviewitem.hxx b/include/sfx2/recentdocsviewitem.hxx
index 410e74bea254..eb9a621769a5 100644
--- a/include/sfx2/recentdocsviewitem.hxx
+++ b/include/sfx2/recentdocsviewitem.hxx
@@ -16,7 +16,7 @@ class RecentDocsViewItem : public ThumbnailViewItem
{
public:
RecentDocsViewItem(ThumbnailView &rView, const OUString &rURL,
- const OUString &rTitle, sal_uInt16 nId);
+ const OUString &rTitle, const BitmapEx& rThumbnail, sal_uInt16 nId);
virtual void setEditTitle (bool edit, bool bChangeFocus = true);
/// Text to be used for the tooltip.
diff --git a/include/unotools/historyoptions.hxx b/include/unotools/historyoptions.hxx
index d57eec193c3c..1fdddf6dd54c 100644
--- a/include/unotools/historyoptions.hxx
+++ b/include/unotools/historyoptions.hxx
@@ -36,6 +36,7 @@
#define HISTORY_PROPERTYNAME_FILTER OUString("Filter")
#define HISTORY_PROPERTYNAME_TITLE OUString("Title")
#define HISTORY_PROPERTYNAME_PASSWORD OUString("Password")
+#define HISTORY_PROPERTYNAME_THUMBNAIL OUString("Thumbnail")
/*-************************************************************************************************************//**
@descr You can use these enum values to specify right history if you call ouer interface methods.
@@ -162,11 +163,9 @@ class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtHistoryOptions : public utl::detail:
@onerror -
*//*-*****************************************************************************************************/
- void AppendItem( EHistoryType eHistory ,
- const OUString& sURL ,
- const OUString& sFilter ,
- const OUString& sTitle ,
- const OUString& sPassword );
+ void AppendItem(EHistoryType eHistory,
+ const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
+ const OUString& sPassword, const OUString& sThumbnail);
private:
diff --git a/officecfg/registry/schema/org/openoffice/Office/Histories.xcs b/officecfg/registry/schema/org/openoffice/Office/Histories.xcs
index ec299adac958..1382b89a94ba 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Histories.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Histories.xcs
@@ -41,6 +41,11 @@
<desc>Contains an encoded password used to open the document.</desc>
</info>
</prop>
+ <prop oor:name="Thumbnail" oor:type="xs:string">
+ <info>
+ <desc>Contains a base64 encoded thumbnail of the document.</desc>
+ </info>
+ </prop>
</group>
<group oor:name="HistoryOrder">
<info>
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())
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx
index 404b409b5ad7..c633d4544a17 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -50,6 +50,7 @@ namespace {
static const ::sal_Int32 s_nOffsetFilter = 1;
static const ::sal_Int32 s_nOffsetTitle = 2;
static const ::sal_Int32 s_nOffsetPassword = 3;
+ static const ::sal_Int32 s_nOffsetThumbnail = 4;
const char s_sCommonHistory[] = "org.openoffice.Office.Common/History";
const char s_sHistories[] = "org.openoffice.Office.Histories/Histories";
@@ -65,36 +66,9 @@ namespace {
const char s_sFilter[] = "Filter";
const char s_sTitle[] = "Title";
const char s_sPassword[] = "Password";
+ const char s_sThumbnail[] = "Thumbnail";
}
-struct IMPL_THistoryItem
-{
- IMPL_THistoryItem()
- {
- }
-
- IMPL_THistoryItem( const OUString& sNewURL ,
- const OUString& sNewFilter ,
- const OUString& sNewTitle ,
- const OUString& sNewPassword )
- {
- sURL = sNewURL ;
- sFilter = sNewFilter ;
- sTitle = sNewTitle ;
- sPassword = sNewPassword ;
- }
-
- sal_Bool operator==( const OUString& sSearchedURL ) const
- {
- return( sURL == sSearchedURL );
- }
-
- OUString sURL ;
- OUString sFilter ;
- OUString sTitle ;
- OUString sPassword ;
-};
-
//*****************************************************************************************************************
// class SvtHistoryOptions_Impl
// redesigned
@@ -108,11 +82,9 @@ public:
sal_uInt32 GetSize( EHistoryType eHistory );
void Clear( EHistoryType eHistory );
Sequence< Sequence< PropertyValue > > GetList( EHistoryType eHistory );
- void AppendItem( EHistoryType eHistory ,
- const OUString& sURL ,
- const OUString& sFilter ,
- const OUString& sTitle ,
- const OUString& sPassword );
+ void AppendItem(EHistoryType eHistory,
+ const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
+ const OUString& sPassword, const OUString& sThumbnail);
private:
void impl_truncateList (EHistoryType eHistory, sal_uInt32 nSize);
@@ -339,7 +311,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT
impl_truncateList (eHistory, GetSize (eHistory));
Sequence< Sequence< PropertyValue > > seqReturn; // Set default return value.
- Sequence< PropertyValue > seqProperties( 4 );
+ Sequence< PropertyValue > seqProperties(5);
css::uno::Reference< css::container::XNameAccess > xListAccess;
css::uno::Reference< css::container::XNameAccess > xItemList;
@@ -350,6 +322,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT
seqProperties[s_nOffsetFilter ].Name = HISTORY_PROPERTYNAME_FILTER;
seqProperties[s_nOffsetTitle ].Name = HISTORY_PROPERTYNAME_TITLE;
seqProperties[s_nOffsetPassword ].Name = HISTORY_PROPERTYNAME_PASSWORD;
+ seqProperties[s_nOffsetThumbnail ].Name = HISTORY_PROPERTYNAME_THUMBNAIL;
try
{
@@ -401,6 +374,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT
xSet->getPropertyValue(OUString(s_sFilter)) >>= seqProperties[s_nOffsetFilter ].Value;
xSet->getPropertyValue(OUString(s_sTitle)) >>= seqProperties[s_nOffsetTitle ].Value;
xSet->getPropertyValue(OUString(s_sPassword)) >>= seqProperties[s_nOffsetPassword ].Value;
+ xSet->getPropertyValue(OUString(s_sThumbnail))>>= seqProperties[s_nOffsetThumbnail].Value;
aRet[nCount++] = seqProperties;
}
}
@@ -433,11 +407,9 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT
// public method
// implements a deque in XML
//*****************************************************************************************************************
-void SvtHistoryOptions_Impl::AppendItem( EHistoryType eHistory ,
- const OUString& sURL ,
- const OUString& sFilter ,
- const OUString& sTitle ,
- const OUString& sPassword )
+void SvtHistoryOptions_Impl::AppendItem(EHistoryType eHistory,
+ const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
+ const OUString& sPassword, const OUString& sThumbnail)
{
impl_truncateList (eHistory, GetSize (eHistory));
@@ -482,9 +454,16 @@ void SvtHistoryOptions_Impl::AppendItem( EHistoryType eHistory ,
sal_Int32 nLength = xOrderList->getElementNames().getLength();
OUString sHistoryItemRef(s_sHistoryItemRef);
- // The item to be appended is already existing!
+ // The item to be appended already exists
if (xItemList->hasByName(sURL))
{
+ if (!sThumbnail.isEmpty())
+ {
+ // update the thumbnail
+ xItemList->getByName(sURL) >>= xSet;
+ xSet->setPropertyValue(OUString(s_sThumbnail), css::uno::makeAny(sThumbnail));
+ }
+
for (sal_Int32 i=0; i<nLength; ++i)
{
OUString sTmp;
@@ -509,15 +488,13 @@ void SvtHistoryOptions_Impl::AppendItem( EHistoryType eHistory ,
}
xOrderList->getByName( OUString::number(0) ) >>= xSet;
xSet->setPropertyValue(sHistoryItemRef, css::uno::makeAny(sFind));
-
- ::comphelper::ConfigurationHelper::flush(m_xCfg);
break;
}
}
- }
- // The item to be appended is not existing!
- else
+ ::comphelper::ConfigurationHelper::flush(m_xCfg);
+ }
+ else // The item to be appended does not exist yet
{
css::uno::Reference< css::lang::XSingleServiceFactory > xFac;
css::uno::Reference< css::uno::XInterface > xInst;
@@ -574,6 +551,7 @@ void SvtHistoryOptions_Impl::AppendItem( EHistoryType eHistory ,
xSet->setPropertyValue(OUString(s_sFilter), css::uno::makeAny(sFilter));
xSet->setPropertyValue(OUString(s_sTitle), css::uno::makeAny(sTitle));
xSet->setPropertyValue(OUString(s_sPassword), css::uno::makeAny(sPassword));
+ xSet->setPropertyValue(OUString(s_sThumbnail), css::uno::makeAny(sThumbnail));
::comphelper::ConfigurationHelper::flush(m_xCfg);
}
@@ -658,14 +636,12 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions::GetList( EHistoryType e
//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
-void SvtHistoryOptions::AppendItem( EHistoryType eHistory ,
- const OUString& sURL ,
- const OUString& sFilter ,
- const OUString& sTitle ,
- const OUString& sPassword )
+void SvtHistoryOptions::AppendItem(EHistoryType eHistory,
+ const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
+ const OUString& sPassword, const OUString& sThumbnail)
{
MutexGuard aGuard( GetOwnStaticMutex() );
- m_pDataContainer->AppendItem( eHistory, sURL, sFilter, sTitle, sPassword );
+ m_pDataContainer->AppendItem(eHistory, sURL, sFilter, sTitle, sPassword, sThumbnail);
}
namespace