LibreOffice Module svx (master)  1
galbrws2.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_INC_GALBRWS2_HXX
21 #define INCLUDED_SVX_INC_GALBRWS2_HXX
22 
23 #include <vcl/transfer.hxx>
24 #include <svl/lstner.hxx>
25 #include <svx/galctrl.hxx>
26 #include <svtools/miscopt.hxx>
27 
28 #include <com/sun/star/frame/XDispatch.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/util/XURLTransformer.hpp>
31 
32 
34 {
39 };
40 
41 
43 {
45 };
46 
47 enum class GalleryItemFlags {
48  Title = 0x0002,
49  Path = 0x0004
50 };
51 namespace o3tl
52 {
53  template<> struct typed_flags<GalleryItemFlags> : is_typed_flags<GalleryItemFlags, 0x0006> {};
54 }
55 
56 
57 class Gallery;
58 class GalleryDragDrop;
59 class GalleryTheme;
60 class GalleryIconView;
61 class GalleryListView;
62 class GalleryPreview;
64 class Menu;
65 class SgaObject;
66 struct DispatchInfo;
67 
68 namespace svx::sidebar { class GalleryControl; }
69 
71 {
72  friend class GalleryBrowser;
74 
75 private:
76 
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;
91  sal_uInt32 mnCurActionPos;
94 
95  css::uno::Reference< css::uno::XComponentContext > m_xContext;
96  css::uno::Reference< css::util::XURLTransformer > m_xTransformer;
97 
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);
104 
105  // SfxListener
106  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
107 
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 );
117 
118 private:
119 
121 
122 public:
123 
124  static OUString GetItemText( const SgaObject& rObj, GalleryItemFlags nItemTextFlags );
125 
126 public:
127 
128  GalleryBrowser2(weld::Builder& rBuilder, Gallery* pGallery);
130 
131  void SelectTheme( const OUString& rThemeName );
132 
133  GalleryBrowserMode GetMode() const { return meMode; }
134  void SetMode( GalleryBrowserMode eMode );
135 
136  weld::Widget* GetViewWindow() const;
137 
138  void Travel( GalleryBrowserTravel eTravel );
139 
140  INetURLObject GetURL() const;
141  OUString GetFilterName() const;
142 
144  sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
145  bool StartDrag();
146  void TogglePreview();
147  void ShowContextMenu(const CommandEvent& rCEvt);
148  bool KeyInput(const KeyEvent& rEvt);
149  bool ViewBoxHasFocus() const;
150 
151  static css::uno::Reference< css::frame::XFrame > GetFrame();
152  const css::uno::Reference< css::util::XURLTransformer >& GetURLTransformer() const { return m_xTransformer; }
153 
154  void Execute(const OString &rIdent);
155  void DispatchAdd(const css::uno::Reference<css::frame::XDispatch> &rxDispatch,
156  const css::util::URL &rURL);
157 
158  DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, void*, void );
159 };
160 
162 {
163 private:
165 
166  virtual sal_Int8 AcceptDrop(const AcceptDropEvent& /*rEvt*/) override
167  {
168  return m_pParent->AcceptDrop(*this);
169  }
170 
171  virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
172  {
173  return m_pParent->ExecuteDrop(rEvt);
174  }
175 
176 public:
177  GalleryDragDrop(GalleryBrowser2* pParent, const css::uno::Reference<css::datatransfer::dnd::XDropTarget>& rDropTarget)
178  : DropTargetHelper(rDropTarget)
179  , m_pParent(pParent)
180  {
181  }
182 };
183 
184 #endif
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::CustomWeld > mxPreviewWin
Definition: galbrws2.hxx:84
void Execute(const OString &rIdent)
Definition: galbrws2.cxx:1097
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: galbrws2.hxx:95
static css::uno::Reference< css::frame::XFrame > GetFrame()
Definition: galbrws2.cxx:992
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: galbrws2.cxx:409
GalleryBrowserMode meMode
Definition: galbrws2.hxx:92
void SelectTheme(const OUString &rThemeName)
Definition: galbrws2.cxx:603
bool StartDrag()
Definition: galbrws2.cxx:473
signed char sal_Int8
void DispatchAdd(const css::uno::Reference< css::frame::XDispatch > &rxDispatch, const css::util::URL &rURL)
Definition: galbrws2.cxx:1005
static OUString GetItemText(const SgaObject &rObj, GalleryItemFlags nItemTextFlags)
Definition: galbrws2.cxx:1160
GalleryBrowserTravel
Definition: galbrws2.hxx:42
std::unique_ptr< weld::ToggleButton > mxIconButton
Definition: galbrws2.hxx:85
std::unique_ptr< weld::Label > mxInfoBar
Definition: galbrws2.hxx:87
std::unique_ptr< weld::CustomWeld > mxIconViewWin
Definition: galbrws2.hxx:80
void ImplUpdateSelection()
Definition: galbrws2.cxx:917
std::unique_ptr< weld::ToggleButton > mxListButton
Definition: galbrws2.hxx:86
std::unique_ptr< GalleryDragDrop > mxDragDropTargetHelper
Definition: galbrws2.hxx:82
friend class svx::sidebar::GalleryControl
Definition: galbrws2.hxx:73
GalleryBrowser2 * m_pParent
Definition: galbrws2.hxx:164
DECL_LINK(SelectObjectHdl, weld::TreeView &, void)
static GalleryBrowserMode meInitMode
Definition: galbrws2.hxx:120
sal_uInt32 mnCurActionPos
Definition: galbrws2.hxx:91
void UpdateRows(bool bVisibleOnly)
Definition: galbrws2.cxx:828
void Travel(GalleryBrowserTravel eTravel)
Definition: galbrws2.cxx:729
GalleryBrowserMode meLastMode
Definition: galbrws2.hxx:93
rtl::Reference< GalleryTransferable > m_xHelper
Definition: galbrws2.hxx:90
DECL_STATIC_LINK(GalleryBrowser2, AsyncDispatch_Impl, void *, void)
Size maPreviewSize
Definition: galbrws2.hxx:89
GalleryBrowser2(weld::Builder &rBuilder, Gallery *pGallery)
Definition: galbrws2.cxx:333
GalleryBrowserMode
Definition: galbrws2.hxx:33
VclPtr< VirtualDevice > mxDev
Definition: galbrws2.hxx:88
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &) override
Definition: galbrws2.hxx:166
OUString GetFilterName() const
Definition: galbrws2.cxx:1208
void ShowContextMenu(const CommandEvent &rCEvt)
Definition: galbrws2.cxx:492
const css::uno::Reference< css::util::XURLTransformer > & GetURLTransformer() const
Definition: galbrws2.hxx:152
GalleryBrowserMode GetMode() const
Definition: galbrws2.hxx:133
GalleryDragDrop(GalleryBrowser2 *pParent, const css::uno::Reference< css::datatransfer::dnd::XDropTarget > &rDropTarget)
Definition: galbrws2.hxx:177
friend class GalleryBrowser
Definition: galbrws2.hxx:72
void TogglePreview()
Definition: galbrws2.cxx:486
weld::Widget * GetViewWindow() const
Definition: galbrws2.cxx:712
GalleryTheme * mpCurTheme
Definition: galbrws2.hxx:78
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
Definition: galbrws2.cxx:454
sal_Int8 AcceptDrop(DropTargetHelper &rTarget)
Definition: galbrws2.cxx:429
std::unique_ptr< GalleryIconView > mxIconView
Definition: galbrws2.hxx:79
void ImplUpdateInfoBar()
Definition: galbrws2.cxx:910
sal_uInt32 ImplGetSelectedItemId(const Point *pSelPosPixel, Point &rSelPos)
Definition: galbrws2.cxx:925
void ImplSelectItemId(sal_uInt32 nItemId)
Definition: galbrws2.cxx:981
std::unique_ptr< weld::TreeView > mxListView
Definition: galbrws2.hxx:81
std::unique_ptr< GalleryPreview > mxPreview
Definition: galbrws2.hxx:83
INetURLObject GetURL() const
Definition: galbrws2.cxx:1198
bool KeyInput(const KeyEvent &rEvt)
Definition: galbrws2.cxx:524
void SetMode(GalleryBrowserMode eMode)
Definition: galbrws2.cxx:631
bool ViewBoxHasFocus() const
Definition: galbrws2.cxx:519
css::uno::Reference< css::util::XURLTransformer > m_xTransformer
Definition: galbrws2.hxx:96
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: galbrws2.hxx:171
GalleryItemFlags
Definition: galbrws2.hxx:47
Gallery * mpGallery
Definition: galbrws2.hxx:77
void ImplUpdateViews(sal_uInt16 nSelectionId)
Definition: galbrws2.cxx:778