10#include <com/sun/star/beans/XPropertySet.hpp>
11#include <com/sun/star/embed/ElementModes.hpp>
12#include <com/sun/star/embed/StorageFactory.hpp>
13#include <com/sun/star/frame/Desktop.hpp>
14#include <com/sun/star/util/URLTransformer.hpp>
21#include <officecfg/Office/Common.hxx>
35#include <bitmaps.hlst>
46bool IsDocEncrypted(
const OUString& rURL)
48 bool bIsEncrypted =
false;
53 auto xStorage(
xFactory->createInstanceWithArguments(
54 { uno::Any(rURL), uno::Any(embed::ElementModes::READ) }));
55 if (uno::Reference<beans::XPropertySet> xStorageProps{ xStorage, uno::UNO_QUERY })
59 xStorageProps->getPropertyValue(
"HasEncryptedEntries") >>= bIsEncrypted;
61 catch (uno::Exception&)
66 catch (
const uno::Exception&)
69 << rURL <<
"> is encrypted:");
75using Ext2IconMap = std::map<sfx2::ApplicationType, OUString>;
76BitmapEx Url2Icon(std::u16string_view rURL,
const Ext2IconMap& rExtToIcon,
const OUString& sDefault)
78 auto it = std::find_if(rExtToIcon.begin(), rExtToIcon.end(),
82 return BitmapEx(it != rExtToIcon.end() ? it->second : sDefault);
85BitmapEx getDefaultThumbnail(
const OUString& rURL)
87 static const Ext2IconMap BitmapForExtension
95 static const Ext2IconMap EncryptedBitmapForExtension
103 const std::map<sfx2::ApplicationType, OUString>& rWhichMap
104 = IsDocEncrypted(rURL) ? EncryptedBitmapForExtension : BitmapForExtension;
106 return Url2Icon(rURL, rWhichMap, SFX_FILE_THUMBNAIL_DEFAULT);
109BitmapEx getModuleOverlay(std::u16string_view rURL)
111 static const Ext2IconMap OverlayBitmapForExtension
119 return Url2Icon(rURL, OverlayBitmapForExtension, SFX_FILE_OVERLAY_DEFAULT);
124 const OUString &rTitle, std::u16string_view
const sThumbnailBase64,
125 sal_uInt16
const nId,
tools::Long const nThumbnailSize,
126 bool const isReadOnly,
bool const isPinned)
130 m_isReadOnly(isReadOnly),
131 m_bRemoveIconHighlighted(false),
132 m_aRemoveRecentBitmap(BMP_RECENTDOC_REMOVE),
133 m_aRemoveRecentBitmapHighlighted(BMP_RECENTDOC_REMOVE_HIGHLIGHTED)
135 OUString aTitle(rTitle);
143 if (aTitle.isEmpty())
149 if (officecfg::Office::Common::History::RecentDocsThumbnail::get())
151 if (!sThumbnailBase64.empty())
156 SvMemoryStream aStream(aDecoded.getArray(), aDecoded.getLength(), StreamMode::READ);
158 aThumbnail = aReader.
read();
164 =
BitmapEx(nThumbnailSize > 192 ? SFX_THUMBNAIL_BASE_256 : SFX_THUMBNAIL_BASE_192);
171 BitmapEx aExt(getDefaultThumbnail(rURL));
191 double ratio = double(nThumbnailSize) / double(std::max(nPaperHeight, nPaperWidth));
192 Size aThumbnailSize(std::round(nPaperWidth * ratio), std::round(nPaperHeight * ratio));
215 BitmapEx aModule = getModuleOverlay(rURL);
222 pVirDev->SetOutputSizePixel(aSize);
223 pVirDev->DrawBitmapEx(
Point(), aThumbnail);
227 aThumbnail = pVirDev->GetBitmapEx(
Point(), aSize);
263 return ::tools::Rectangle(
304 if (aPinPosRectangle.Contains(rMEvt.
GetPosPixel()))
326 uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext());
337 aArgsList.realloc(aArgsList.size()+1);
352 pLoadRecentFile->
aArgSeq = aArgsList;
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
bool CopyPixel(const tools::Rectangle &rRectDst, const tools::Rectangle &rRectSrc, const BitmapEx *pBmpExSrc)
const Size & GetSizePixel() const
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetProtocol GetProtocol() const
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const Point & GetPosPixel() const
static PaperInfo getSystemDefaultPaper()
tools::Long getWidth() const
tools::Long getHeight() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
BitmapEx m_aRemoveRecentBitmapHighlighted
virtual tools::Rectangle updateHighlight(bool bVisible, const Point &rPoint) override
Updates own highlight status based on the aPoint position.
BitmapEx m_aRemoveRecentBitmap
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUString &rURL, const OUString &rTitle, std::u16string_view sThumbnailBase64, sal_uInt16 nId, tools::Long nThumbnailSize, bool isReadOnly, bool isPinned)
tools::Rectangle getRemoveIconArea() const
Return area where is the icon to remove document from the recent documents.
virtual OUString getHelpText() const override
Text to be used for the tooltip.
bool m_bRemoveIconHighlighted
Is the icon that the user can click to remove the document from the recent documents highlighted?
void OpenDocument()
Called when the user clicks a document - it will open it.
virtual void Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor, const ThumbnailItemAttributes *pAttrs) override
sfx2::RecentDocsView & mrParentView
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static BitmapEx scaleImg(const BitmapEx &rImg, tools::Long width, tools::Long height)
bool isHighlighted() const
virtual tools::Rectangle updateHighlight(bool bVisible, const Point &rPoint)
Updates own highlight status based on the aPoint position.
BitmapEx maPinnedDocumentBitmap
const tools::Rectangle & getDrawArea() const
virtual void Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor, const ThumbnailItemAttributes *pAttrs)
virtual void Reload()
Updates information in the view; used only in RecentDocsView ATM.
static void decode(css::uno::Sequence< sal_Int8 > &aPass, std::u16string_view sBuffer)
void process(const primitive2d::Primitive2DContainer &rSource)
void PostLoadRecentUsedFile(LoadRecentFile *pLoadRecentFile)
static bool typeMatchesExtension(ApplicationType type, std::u16string_view rExt)
bool read(BitmapEx &rBitmap)
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XDispatch > xDispatch
Reference< XSingleServiceFactory > xFactory
Sequence< sal_Int8 > aSeq
void DeleteItem(EHistoryType eHistory, const OUString &sURL)
void TogglePinItem(EHistoryType eHistory, const OUString &sURL)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
rtl::Reference< BasePrimitive2D > Primitive2DReference
css::uno::Sequence< css::beans::PropertyValue > aArgSeq
css::uno::Reference< css::frame::XDispatch > xDispatch
css::util::URL aTargetURL
const int THUMBNAILVIEW_ITEM_CORNER