startcenter: fdo#72469: Thumbnails also for other file types than ODF.
Change-Id: If905b2f3e51adf7e64df9385ede74368acd11771
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 72fe127..8ef4d96 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -403,7 +403,8 @@
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 1706935..9308025 100644
--- a/include/sfx2/recentdocsview.hxx
+++ b/include/sfx2/recentdocsview.hxx
@@ -45,7 +45,7 @@
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 410e74b..eb9a621 100644
--- a/include/sfx2/recentdocsviewitem.hxx
+++ b/include/sfx2/recentdocsviewitem.hxx
@@ -16,7 +16,7 @@
{
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 d57eec1..1fdddf6 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 @@
@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 ec299ad..1382b89a 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 a1eed29..206d458 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1250,7 +1250,7 @@
{
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 eac8021..a06002d 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 @@
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 5f225bc..34ae603 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 @@
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 @@
OUString aURL;
OUString aTitle;
BitmapEx aThumbnail;
for ( int j = 0; j < rRecentEntry.getLength(); j++ )
{
@@ -167,11 +169,25 @@
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 d1947e9..8c64fb4 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 @@
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 404b409..c633d454 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -50,6 +50,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
}
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 @@
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 @@
//*****************************************************************************************************************
// 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