1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
26 #include <svtools/miscopt.hxx>
28 #include <com/sun/star/frame/XDispatch.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
{
53 template<> struct typed_flags
<GalleryItemFlags
> : is_typed_flags
<GalleryItemFlags
, 0x0006> {};
58 class GalleryDragDrop
;
60 class GalleryIconView
;
61 class GalleryListView
;
63 class GalleryTransferable
;
68 namespace svx::sidebar
{ class GalleryControl
; }
70 class GalleryBrowser2
: public SfxListener
72 friend class GalleryBrowser
;
73 friend class svx::sidebar::GalleryControl
;
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 ScopedVclPtr
<VirtualDevice
> mxDev
;
90 rtl::Reference
<GalleryTransferable
> m_xHelper
;
91 sal_uInt32 mnCurActionPos
;
92 GalleryBrowserMode meMode
;
93 GalleryBrowserMode meLastMode
;
95 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
96 css::uno::Reference
< css::util::XURLTransformer
> m_xTransformer
;
98 void ImplUpdateViews( sal_uInt16 nSelectionId
);
99 void ImplUpdateInfoBar();
100 sal_uInt32
ImplGetSelectedItemId( const Point
* pSelPosPixel
, Point
& rSelPos
);
101 void ImplSelectItemId(sal_uInt32 nItemId
);
102 void ImplUpdateSelection();
103 void UpdateRows(bool bVisibleOnly
);
106 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
108 DECL_LINK( SelectObjectHdl
, weld::TreeView
&, void );
109 DECL_LINK( SelectObjectValueSetHdl
, ValueSet
*, void );
110 DECL_LINK( SelectTbxHdl
, weld::ToggleButton
&, void );
111 DECL_LINK( PopupMenuHdl
, const CommandEvent
&, bool );
112 DECL_LINK( KeyInputHdl
, const KeyEvent
&, bool );
113 DECL_LINK( RowActivatedHdl
, weld::TreeView
&, bool );
114 DECL_LINK( DragBeginHdl
, bool&, bool );
115 DECL_LINK( VisRowsScrolledHdl
, weld::TreeView
&, void );
116 DECL_LINK( SizeAllocHdl
, const Size
&, void );
120 static GalleryBrowserMode meInitMode
;
124 static OUString
GetItemText( const SgaObject
& rObj
, GalleryItemFlags nItemTextFlags
);
128 GalleryBrowser2(weld::Builder
& rBuilder
, Gallery
* pGallery
);
131 void SelectTheme( const OUString
& rThemeName
);
133 GalleryBrowserMode
GetMode() const { return meMode
; }
134 void SetMode( GalleryBrowserMode eMode
);
136 weld::Widget
* GetViewWindow() const;
138 void Travel( GalleryBrowserTravel eTravel
);
140 INetURLObject
GetURL() const;
141 OUString
GetFilterName() const;
143 sal_Int8
AcceptDrop( const DropTargetHelper
& rTarget
);
144 sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
146 void TogglePreview();
147 void ShowContextMenu(const CommandEvent
& rCEvt
);
148 bool KeyInput(const KeyEvent
& rEvt
);
149 bool ViewBoxHasFocus() const;
151 static css::uno::Reference
< css::frame::XFrame
> GetFrame();
152 const css::uno::Reference
< css::util::XURLTransformer
>& GetURLTransformer() const { return m_xTransformer
; }
154 void Execute(const OString
&rIdent
);
155 void DispatchAdd(const css::uno::Reference
<css::frame::XDispatch
> &rxDispatch
,
156 const css::util::URL
&rURL
);
158 DECL_STATIC_LINK( GalleryBrowser2
, AsyncDispatch_Impl
, void*, void );
161 class GalleryDragDrop
: public DropTargetHelper
164 GalleryBrowser2
* m_pParent
;
166 virtual sal_Int8
AcceptDrop(const AcceptDropEvent
& /*rEvt*/) override
168 return m_pParent
->AcceptDrop(*this);
171 virtual sal_Int8
ExecuteDrop(const ExecuteDropEvent
& rEvt
) override
173 return m_pParent
->ExecuteDrop(rEvt
);
177 GalleryDragDrop(GalleryBrowser2
* pParent
, const css::uno::Reference
<css::datatransfer::dnd::XDropTarget
>& rDropTarget
)
178 : DropTargetHelper(rDropTarget
)
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */