Fix unit test failure when using Skia in debug builds
[LibreOffice.git] / svx / inc / galbrws2.hxx
blobd5ca8a50a041bac652bec39766bd9c135026f620
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_INC_GALBRWS2_HXX
21 #define INCLUDED_SVX_INC_GALBRWS2_HXX
23 #include <vcl/transfer.hxx>
24 #include <svl/lstner.hxx>
25 #include <svx/galctrl.hxx>
27 #include <com/sun/star/frame/XDispatch.hpp>
28 #include <com/sun/star/frame/XFrame.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/util/XURLTransformer.hpp>
33 enum GalleryBrowserMode
35 GALLERYBROWSERMODE_NONE = 0,
36 GALLERYBROWSERMODE_ICON = 1,
37 GALLERYBROWSERMODE_LIST = 2,
38 GALLERYBROWSERMODE_PREVIEW = 3
42 enum class GalleryBrowserTravel
44 First, Last, Previous, Next
47 enum class GalleryItemFlags {
48 Title = 0x0002,
49 Path = 0x0004
51 namespace o3tl
53 template<> struct typed_flags<GalleryItemFlags> : is_typed_flags<GalleryItemFlags, 0x0006> {};
57 class Gallery;
58 class GalleryDragDrop;
59 class GalleryTheme;
60 class GalleryIconView;
61 class GalleryListView;
62 class GalleryPreview;
63 class GalleryTransferable;
64 class Menu;
65 class SgaObject;
66 struct DispatchInfo;
68 namespace svx::sidebar { class GalleryControl; }
70 class GalleryBrowser2 final : public SfxListener
72 friend class GalleryBrowser;
73 friend class svx::sidebar::GalleryControl;
75 private:
77 Gallery* mpGallery;
78 GalleryTheme* mpCurTheme;
79 std::unique_ptr<GalleryIconView> mxIconView;
80 std::unique_ptr<weld::CustomWeld> mxIconViewWin;
81 std::unique_ptr<weld::TreeView> mxListView;
82 std::unique_ptr<GalleryDragDrop> mxDragDropTargetHelper;
83 std::unique_ptr<GalleryPreview> mxPreview;
84 std::unique_ptr<weld::CustomWeld> mxPreviewWin;
85 std::unique_ptr<weld::ToggleButton> mxIconButton;
86 std::unique_ptr<weld::ToggleButton> mxListButton;
87 std::unique_ptr<weld::Label> mxInfoBar;
88 Size maPreviewSize;
89 rtl::Reference<GalleryTransferable> m_xHelper;
90 sal_uInt32 mnCurActionPos;
91 GalleryBrowserMode meMode;
92 GalleryBrowserMode meLastMode;
94 css::uno::Reference< css::uno::XComponentContext > m_xContext;
95 css::uno::Reference< css::util::XURLTransformer > m_xTransformer;
97 void ImplUpdateViews( sal_uInt16 nSelectionId );
98 void ImplUpdateInfoBar();
99 sal_uInt32 ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos );
100 void ImplSelectItemId(sal_uInt32 nItemId);
101 void ImplUpdateSelection();
102 void UpdateRows(bool bVisibleOnly);
104 // SfxListener
105 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
107 DECL_LINK( SelectObjectHdl, weld::TreeView&, void );
108 DECL_LINK( SelectObjectValueSetHdl, ValueSet*, void );
109 DECL_LINK( SelectTbxHdl, weld::Toggleable&, void );
110 DECL_LINK( PopupMenuHdl, const CommandEvent&, bool );
111 DECL_LINK( KeyInputHdl, const KeyEvent&, bool );
112 DECL_LINK( RowActivatedHdl, weld::TreeView&, bool );
113 DECL_LINK( DragBeginHdl, bool&, bool );
114 DECL_LINK( VisRowsScrolledHdl, weld::TreeView&, void );
115 DECL_LINK( SizeAllocHdl, const Size&, void );
117 private:
119 static GalleryBrowserMode meInitMode;
121 public:
123 static OUString GetItemText( const SgaObject& rObj, GalleryItemFlags nItemTextFlags );
125 public:
127 GalleryBrowser2(weld::Builder& rBuilder, Gallery* pGallery);
128 ~GalleryBrowser2();
130 void SelectTheme( std::u16string_view rThemeName );
132 GalleryBrowserMode GetMode() const { return meMode; }
133 void SetMode( GalleryBrowserMode eMode );
135 weld::Widget* GetViewWindow() const;
137 void Travel( GalleryBrowserTravel eTravel );
139 INetURLObject GetURL() const;
140 OUString GetFilterName() const;
142 sal_Int8 AcceptDrop( const DropTargetHelper& rTarget );
143 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
144 bool StartDrag();
145 void TogglePreview();
146 bool ShowContextMenu(const CommandEvent& rCEvt);
147 bool KeyInput(const KeyEvent& rEvt);
148 bool ViewBoxHasFocus() const;
150 static css::uno::Reference< css::frame::XFrame > GetFrame();
151 const css::uno::Reference< css::util::XURLTransformer >& GetURLTransformer() const { return m_xTransformer; }
153 void Execute(std::u16string_view rIdent);
154 void DispatchAdd(const css::uno::Reference<css::frame::XDispatch> &rxDispatch,
155 const css::util::URL &rURL);
157 DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, void*, void );
160 class GalleryDragDrop final : public DropTargetHelper
162 private:
163 GalleryBrowser2* m_pParent;
165 virtual sal_Int8 AcceptDrop(const AcceptDropEvent& /*rEvt*/) override
167 return m_pParent->AcceptDrop(*this);
170 virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
172 return m_pParent->ExecuteDrop(rEvt);
175 public:
176 GalleryDragDrop(GalleryBrowser2* pParent, const css::uno::Reference<css::datatransfer::dnd::XDropTarget>& rDropTarget)
177 : DropTargetHelper(rDropTarget)
178 , m_pParent(pParent)
183 #endif
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */