tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / inc / galbrws1.hxx
blob4ec48c5154ff398d09eec2483041b0abc919250f
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 #pragma once
22 #include <svl/lstner.hxx>
23 #include <vcl/customweld.hxx>
24 #include <vcl/transfer.hxx>
25 #include <vcl/weld.hxx>
26 #include <svx/galmisc.hxx>
27 #include <svx/galctrl.hxx>
28 #include <unotools/charclass.hxx>
29 #include <vector>
30 #include <com/sun/star/util/XURLTransformer.hpp>
31 #include <com/sun/star/frame/XDispatch.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
35 class GalleryBrowser1;
37 class Gallery;
38 class GalleryThemeEntry;
39 class GalleryTheme;
40 class VclAbstractDialog;
41 struct ExchangeData;
42 class SfxItemSet;
43 class GalleryDragDrop;
44 class GalleryIconView;
45 class GalleryListView;
46 class GalleryPreview;
47 class SgaObject;
49 enum GalleryBrowserMode
51 GALLERYBROWSERMODE_NONE = 0,
52 GALLERYBROWSERMODE_ICON = 1,
53 GALLERYBROWSERMODE_LIST = 2,
54 GALLERYBROWSERMODE_PREVIEW = 3
57 enum class GalleryBrowserTravel
59 First,
60 Last,
61 Previous,
62 Next
65 enum class GalleryItemFlags
67 Title = 0x0002,
68 Path = 0x0004
70 namespace o3tl
72 template <> struct typed_flags<GalleryItemFlags> : is_typed_flags<GalleryItemFlags, 0x0006>
77 namespace svx::sidebar
79 class GalleryControl;
82 struct ThemeEntry
84 OUString maThemeName;
85 OUString maEntryTitle;
86 size_t mnIdInTheme;
88 ThemeEntry(const OUString& rThemeName, const OUString& rEntryTitle, size_t nId)
89 : maThemeName(rThemeName)
90 , maEntryTitle(rEntryTitle)
91 , mnIdInTheme(nId)
95 typedef ::std::vector<ThemeEntry> GalleryThemeEntries;
97 class GalleryBrowser1 final : public SfxListener
99 friend class GalleryBrowser;
100 friend class svx::sidebar::GalleryControl;
102 private:
103 std::unique_ptr<weld::Button> mxNewTheme;
104 std::unique_ptr<weld::TreeView> mxThemes;
105 std::unique_ptr<weld::Button> mxMoreGalleries;
106 Gallery* mpGallery;
107 std::unique_ptr<ExchangeData> mpExchangeData;
108 std::unique_ptr<SfxItemSet> mpThemePropsDlgItemSet;
110 OUString aImgNormal;
111 OUString aImgDefault;
112 OUString aImgReadOnly;
114 GalleryTheme* mpCurTheme;
115 std::unique_ptr<GalleryIconView> mxIconView;
116 std::unique_ptr<weld::CustomWeld> mxIconViewWin;
117 std::unique_ptr<weld::TreeView> mxListView;
118 std::unique_ptr<GalleryDragDrop> mxDragDropTargetHelper;
119 std::unique_ptr<GalleryPreview> mxPreview;
120 std::unique_ptr<weld::CustomWeld> mxPreviewWin;
121 std::unique_ptr<weld::ToggleButton> mxIconButton;
122 std::unique_ptr<weld::ToggleButton> mxListButton;
123 std::unique_ptr<weld::Entry> mxSearchField;
124 std::unique_ptr<weld::Label> mxInfoBar;
125 Size maPreviewSize;
126 rtl::Reference<GalleryTransferable> m_xHelper;
127 sal_uInt32 mnCurActionPos;
128 GalleryBrowserMode meMode;
129 GalleryBrowserMode meLastMode;
131 GalleryThemeEntries maAllThemeEntries;
132 GalleryThemeEntries maFoundThemeEntries;
134 css::uno::Reference<css::uno::XComponentContext> m_xContext;
135 css::uno::Reference<css::util::XURLTransformer> m_xTransformer;
137 CharClass m_aCharacterClassficator;
138 SfxListener maLocalListener;
140 void ImplInsertThemeEntry(const GalleryThemeEntry* pEntry);
141 static void ImplFillExchangeData(const GalleryTheme& rThm, ExchangeData& rData);
142 void ImplGetExecuteVector(std::vector<OUString>& o_aExec);
143 void ImplExecute(std::u16string_view rIdent);
144 void ImplGalleryThemeProperties(std::u16string_view rThemeName, bool bCreateNew);
145 void EndNewThemePropertiesDlgHdl(sal_Int32 nResult);
146 void EndThemePropertiesDlgHdl(sal_Int32 nResult);
147 void ImplEndGalleryThemeProperties(bool bCreateNew, sal_Int32 nResult);
149 void ImplUpdateViews(sal_uInt16 nSelectionId);
150 void ImplUpdateInfoBar();
151 sal_uInt32 ImplGetSelectedItemId(const Point* pSelPosPixel, Point& rSelPos);
152 void ImplSelectItemId(sal_uInt32 nItemId);
153 void ImplUpdateSelection();
154 void UpdateRows(bool bVisibleOnly);
155 void FillThemeEntries();
157 // SfxListener
158 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
160 DECL_LINK(ClickNewThemeHdl, weld::Button&, void);
161 DECL_LINK(SelectThemeHdl, weld::TreeView&, void);
162 DECL_LINK(PopupMenuHdl1, const CommandEvent&, bool);
163 DECL_LINK(KeyInputHdl1, const KeyEvent&, bool);
164 DECL_STATIC_LINK(GalleryBrowser1, OnMoreGalleriesClick, weld::Button&, void);
166 DECL_LINK(SelectObjectHdl, weld::TreeView&, void);
167 DECL_LINK(SelectObjectValueSetHdl, ValueSet*, void);
168 DECL_LINK(SelectTbxHdl, weld::Toggleable&, void);
169 DECL_LINK(PopupMenuHdl2, const CommandEvent&, bool);
170 DECL_LINK(KeyInputHdl2, const KeyEvent&, bool);
171 DECL_LINK(RowActivatedHdl, weld::TreeView&, bool);
172 DECL_LINK(DragBeginHdl, bool&, bool);
173 DECL_LINK(VisRowsScrolledHdl, weld::TreeView&, void);
174 DECL_LINK(SizeAllocHdl, const Size&, void);
175 DECL_LINK(SearchHdl, weld::Entry&, void);
177 static GalleryBrowserMode meInitMode;
179 public:
180 GalleryBrowser1(weld::Builder& rBuilder, Gallery* pGallery);
182 ~GalleryBrowser1();
184 void SelectTheme(sal_uInt16 nThemePos)
186 mxThemes->select(nThemePos);
187 SelectThemeHdl(*mxThemes);
189 OUString GetSelectedTheme() const { return mxThemes->get_selected_text(); }
191 static OUString GetItemText(const SgaObject& rObj, GalleryItemFlags nItemTextFlags);
193 public:
194 void SelectTheme(std::u16string_view rThemeName);
196 GalleryBrowserMode GetMode() const { return meMode; }
197 void SetMode(GalleryBrowserMode eMode);
199 weld::Widget* GetViewWindow() const;
201 void Travel(GalleryBrowserTravel eTravel);
203 INetURLObject GetURL() const;
204 OUString GetFilterName() const;
206 sal_Int8 AcceptDrop(const DropTargetHelper& rTarget);
207 sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt);
208 bool StartDrag();
209 void TogglePreview();
210 bool ShowContextMenu(const CommandEvent& rCEvt);
211 bool KeyInput(const KeyEvent& rEvt);
212 bool ViewBoxHasFocus() const;
214 static css::uno::Reference<css::frame::XFrame> GetFrame();
215 const css::uno::Reference<css::util::XURLTransformer>& GetURLTransformer() const
217 return m_xTransformer;
220 void Execute(std::u16string_view rIdent);
221 void DispatchAdd(const css::uno::Reference<css::frame::XDispatch>& rxDispatch,
222 const css::util::URL& rURL);
224 DECL_STATIC_LINK(GalleryBrowser1, AsyncDispatch_Impl, void*, void);
227 class GalleryDragDrop final : public DropTargetHelper
229 private:
230 GalleryBrowser1* m_pParent;
232 virtual sal_Int8 AcceptDrop(const AcceptDropEvent& /*rEvt*/) override
234 return m_pParent->AcceptDrop(*this);
237 virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
239 return m_pParent->ExecuteDrop(rEvt);
242 public:
243 GalleryDragDrop(GalleryBrowser1* pParent,
244 const css::uno::Reference<css::datatransfer::dnd::XDropTarget>& rDropTarget)
245 : DropTargetHelper(rDropTarget)
246 , m_pParent(pParent)
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */