26#include <rtl/ustring.hxx>
37#include <com/sun/star/accessibility/AccessibleEventId.hpp>
38#include <com/sun/star/embed/ElementModes.hpp>
39#include <com/sun/star/embed/StorageFactory.hpp>
40#include <com/sun/star/embed/XStorage.hpp>
63 uno::Reference<io::XInputStream> xIStream;
65 uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
68 uno::Reference<lang::XSingleServiceFactory> xStorageFactory = embed::StorageFactory::create(xContext);
70 uno::Sequence<uno::Any> aArgs{
uno::Any(msURL),
uno::Any(embed::ElementModes::READ) };
71 uno::Reference<embed::XStorage> xDocStorage (
72 xStorageFactory->createInstanceWithArguments(aArgs),
79 uno::Reference<embed::XStorage> xStorage (
80 xDocStorage->openStorageElement(
82 embed::ElementModes::READ));
85 uno::Reference<io::XStream> xThumbnailCopy (
86 xStorage->cloneStreamElement(
"thumbnail.png"));
87 if (xThumbnailCopy.is())
88 xIStream = xThumbnailCopy->getInputStream();
92 catch (
const uno::Exception&)
95 "caught exception while trying to access Thumbnail/thumbnail.png of " << msURL);
104 if ( ! xIStream.is())
106 uno::Reference<embed::XStorage> xStorage (
107 xDocStorage->openStorageElement(
"Thumbnail",
108 embed::ElementModes::READ));
111 uno::Reference<io::XStream> xThumbnailCopy (
112 xStorage->cloneStreamElement(
"thumbnail.png"));
113 if (xThumbnailCopy.is())
114 xIStream = xThumbnailCopy->getInputStream();
118 catch (
const uno::Exception&)
121 "caught exception while trying to access Thumbnails/thumbnail.png of " << msURL);
124 catch (
const uno::Exception&)
127 "caught exception while trying to access thumbnail of "
135 std::unique_ptr<SvStream> pStream (
138 aThumbnail = aReader.
read ();
148 : mnThumbnailHeight(0)
152 , mbSelectOnFocus(true)
154 , mxScrolledWindow(
std::move(xWindow))
155 , mxContextMenu(
std::move(xMenu))
163 css::uno::Reference< css::lang::XComponent> xComponent(
mxAccessible, css::uno::UNO_QUERY);
166 xComponent->dispose();
178 for (
size_t i = 0;
i < nItemCount;
i++)
196 for (
size_t i = 0;
i < nItemCount;
i++)
204 rHelpRect = rDrawArea;
217 size_t nSelStartPos = 0;
280 for (
size_t i = 0;
i <
n; ++
i )
295 css::uno::Any aOldAny, aNewAny;
348 nScrollRatio =
static_cast<float>(
mxScrolledWindow->vadjustment_get_value()) /
372 if (nVItemSpace == -1)
400 tools::Long y = nStartY - ((nFullSteps - 1) * nScrollRatio - nHiddenLines) * nItemHeightOffset;
414 bool bPinnedItems =
true;
415 size_t nCurCount = 0;
416 for (
size_t i = 0;
i < nItemCount;
i++ )
421 if (bPinnedItems && !pItem->
isPinned())
423 bPinnedItems =
false;
425 if ((nCurCount + 1) %
mnCols && nCurCount > nFirstItem)
433 if ((nCurCount >= nFirstItem) && (nCurCount < nLastItem))
439 css::uno::Any aOldAny, aNewAny;
453 if ( !((nCurCount+1) %
mnCols) )
467 css::uno::Any aOldAny, aNewAny;
525 const size_t nItemCount =
mItemList.size();
527 for (
size_t n = 0;
n < nItemCount; ++
n )
538 const size_t nItemCount =
mItemList.size();
540 for (
size_t n = 0;
n < nItemCount; ++
n )
544 if ( pItem->
isVisible() && !nVisiblePos-- )
567 CalculateItemPositions(
true);
568 if (IsReallyVisible() && IsUpdateMode())
574 bool bHandled =
true;
578 bool bFoundLast =
false;
589 bool bValidRange =
false;
591 size_t nNextPos = nLastPos;
595 if (aKeyCode.
IsShift() && bHasSelRange)
601 if (nLastPos == nSelPos)
616 nNextPos = nLastPos + 1;
628 nNextPos = nLastPos - 1;
645 nNextPos = nLastPos +
mnCols;
649 int curRow = nLastPos/
mnCols;
665 nNextPos = nLastPos -
mnCols;
678 bHandled = CustomWidgetController::KeyInput(rKEvt);
683 if (aKeyCode.
IsShift() && bValidRange)
685 std::pair<size_t,size_t> aRange;
688 if (nLastPos < nSelPos)
690 if (nNextPos > nLastPos)
692 if ( nNextPos > nSelPos)
693 aRange = std::make_pair(nLastPos,nNextPos);
695 aRange = std::make_pair(nLastPos,nNextPos-1);
698 aRange = std::make_pair(nNextPos,nLastPos-1);
700 else if (nLastPos == nSelPos)
702 if (nNextPos > nLastPos)
703 aRange = std::make_pair(nLastPos+1,nNextPos);
705 aRange = std::make_pair(nNextPos,nLastPos-1);
709 if (nNextPos > nLastPos)
710 aRange = std::make_pair(nLastPos+1,nNextPos);
713 if ( nNextPos < nSelPos)
714 aRange = std::make_pair(nNextPos,nLastPos);
716 aRange = std::make_pair(nNextPos+1,nLastPos);
720 for (
size_t i = aRange.first;
i <= aRange.second; ++
i)
756 if ( pItem->
mnId == nItemId )
780 return CustomWidgetController::MouseButtonDown( rMEvt );
789 return CustomWidgetController::MouseButtonDown( rMEvt );
810 std::pair<size_t,size_t> aNewRange;
812 aNewRange.second =
nPos;
814 if (aNewRange.first > aNewRange.second)
815 std::swap(aNewRange.first,aNewRange.second);
822 if (pCurItem->
isSelected() && (i < aNewRange.first || i > aNewRange.second))
837 int dir = nSelPos <
nPos ? 1 : -1;
838 size_t nCurPos = nSelPos + dir;
840 while (nCurPos !=
nPos)
883 CustomWidgetController::SetDrawingArea(pDrawingArea);
911 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
913 pProcessor->process(
aSeq);
916 for (
size_t i = 0;
i < nItemCount;
i++)
924 rRenderContext.
Pop();
933 for (
size_t i = 0,
n =
mItemList.size();
i <
n && nSelected == -1; ++
i)
939 if (nSelected == -1 && !
mItemList.empty())
957 CustomWidgetController::GetFocus();
962 CustomWidgetController::LoseFocus();
972 CustomWidgetController::Resize();
989 std::unique_ptr<ThumbnailViewItem> xKeepAliveViewItem;
994 if ((*it)->mnId == nItemId)
996 xKeepAliveViewItem = std::move(*it);
1004 ::std::advance( it,
nPos );
1006 if ((*it)->isSelected())
1008 (*it)->setSelection(
false);
1106 sal_uInt16 nNewLine =
static_cast<sal_uInt16
>(nItemPos /
mnCols);
1131 css::uno::Any aOldAny, aNewAny;
1132 aNewAny <<= css::uno::Reference(getXWeak( pItemAcc ));
1133 ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
1137 css::uno::Any aOldAny, aNewAny;
1153 for (std::unique_ptr<ThumbnailViewItem>&
p :
mItemList)
1155 if (
p->isSelected())
1157 p->setSelection(
false);
1183 bool bHasSelRange =
false;
1194 if (curSel == pItem)
1197 bHasSelRange =
true;
1208 css::uno::Any aOldAny, aNewAny;
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
basegfx::BColor getBColor() const
const vcl::KeyCode & GetKeyCode() const
bool IsLeaveWindow() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
const vcl::Font & GetFont() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetFieldColor() const
const Color & GetWindowTextColor() const
const Color & GetActiveColor() const
const Color & GetHighlightColor() const
const Color & GetHighlightTextColor() const
const Color & GetActiveTextColor() const
void FireAccessibleEvent(short nEventId, const css::uno::Any &rOldValue, const css::uno::Any &rNewValue)
bool HasAccessibleListeners() const
static ThumbnailViewAcc * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
void GetFocus()
Called by the corresponding ValueSet when it gets the focus.
void LoseFocus()
Called by the corresponding ValueSet when it loses the focus.
static ThumbnailViewItemAcc * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
virtual OUString getHelpText() const
bool isHighlighted() const
css::uno::Reference< css::accessibility::XAccessible > const & GetAccessible(bool bIsTransientChildrenDisabled)
void calculateItemsPosition(const tools::Long nThumbnailHeight, const tools::Long nPadding, sal_uInt32 nMaxTextLength, const ThumbnailItemAttributes *pAttrs)
virtual tools::Rectangle updateHighlight(bool bVisible, const Point &rPoint)
Updates own highlight status based on the aPoint position.
void setSelection(bool state)
const tools::Rectangle & getDrawArea() const
virtual void Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor, const ThumbnailItemAttributes *pAttrs)
void setDrawArea(const tools::Rectangle &area)
Class to display thumbnails with their names below their respective icons.
void updateItems(std::vector< std::unique_ptr< ThumbnailViewItem > > items)
tools::Long mnThumbnailHeight
virtual ~ThumbnailView() override
size_t GetItemPos(sal_uInt16 nItemId) const
void CalculateItemPositions(bool bScrollBarUsed=false)
void deselectItems()
deselect all current selected items.
Link< const ThumbnailViewItem *, void > maItemStateHdl
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
tools::Long mnDisplayHeight
sal_uInt16 GetItemId(size_t nPos) const
size_t ImplGetItem(const Point &rPoint) const
virtual bool KeyInput(const KeyEvent &rKEvt) override
virtual void Resize() override
const css::uno::Reference< css::accessibility::XAccessible > & getAccessible() const
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
virtual bool renameItem(ThumbnailViewItem *pItem, const OUString &sNewTitle)
bool ImplHasAccessibleListeners() const
Color maHighlightColor
Color of the highlight (background) of the hovered item.
virtual void OnItemDblClicked(ThumbnailViewItem *pItem)
void AppendItem(std::unique_ptr< ThumbnailViewItem > pItem)
ThumbnailValueItemList::iterator mpStartSelRange
sal_uInt16 ImplGetVisibleItemCount() const
tools::Long mnItemPadding
virtual bool MouseMove(const MouseEvent &rMEvt) override
double mfHighlightTransparence
Transparence of the highlight.
void RemoveItem(sal_uInt16 nItemId)
friend class ThumbnailViewAcc
bool IsItemSelected(sal_uInt16 nItemId) const
ThumbnailViewItem * ImplGetVisibleItem(sal_uInt16 nVisiblePos)
virtual OUString RequestHelp(tools::Rectangle &rRect) override
void filterItems(const std::function< bool(const ThumbnailViewItem *) > &func)
Color maHighlightTextColor
Color of the text for the highlighted item.
void setItemDimensions(tools::Long ItemWidth, tools::Long ThumbnailHeight, tools::Long DisplayHeight, int itemPadding)
ThumbnailView(std::unique_ptr< weld::ScrolledWindow > xWindow, std::unique_ptr< weld::Menu > xMenu)
virtual void LoseFocus() override
void DrawItem(ThumbnailViewItem const *pItem)
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
Color maTextColor
Text color.
css::uno::Reference< css::accessibility::XAccessible > mxAccessible
void ImplFireAccessibleEvent(short nEventId, const css::uno::Any &rOldValue, const css::uno::Any &rNewValue)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
virtual void GetFocus() override
void ShowTooltips(bool bShowTooltips)
void DrawMnemonics(bool bDrawMnemonics)
std::unique_ptr< ThumbnailItemAttributes > mpItemAttrs
std::function< bool(const ThumbnailViewItem *)> maFilterFunc
void setItemMaxTextLength(sal_uInt32 nLength)
Color maSelectHighlightTextColor
Color of the text of the selected and hovered item.
static BitmapEx readThumbnail(const OUString &msURL)
void SelectItem(sal_uInt16 nItemId)
Color maSelectHighlightColor
Color of the highlight (background) of the selected and hovered item.
std::vector< std::unique_ptr< ThumbnailViewItem > > mItemList
Color maFillColor
Background color of the thumbnail view widget.
ThumbnailValueItemList mFilteredItemList
Cache to store the filtered items.
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
void MakeItemVisible(sal_uInt16 nId)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
sal_uInt16 GetCode() const
bool read(BitmapEx &rBitmap)
virtual OutputDevice & get_ref_device()=0
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
#define LINK(Instance, Class, Member)
Sequence< sal_Int8 > aSeq
sal_uInt16 GetTransparentSelectionPercent()
rtl::Reference< BasePrimitive2D > Primitive2DReference
attribute::FontAttribute getFontAttributeFromVclFont(basegfx::B2DVector &o_rSize, const vcl::Font &rFont, bool bRTL, bool bBiDiStrong)
std::unique_ptr< BaseProcessor2D > createProcessor2DFromOutputDevice(OutputDevice &rTargetOutDev, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
IMPL_LINK_NOARG(ThumbnailView, ImplScrollHdl, weld::ScrolledWindow &, void)
#define THUMBNAILVIEW_ITEM_NOTFOUND