Revert "tdf#158280 Replace usage of InputDialog with SvxNameDialog"
[LibreOffice.git] / sw / source / ui / inc / bookmark.hxx
blob1692e4654ce74463dfcc64c5a0f3d77ef18e1fe4
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 .
19 #pragma once
21 #include <sfx2/basedlgs.hxx>
22 #include <vcl/weld.hxx>
23 #include <IMark.hxx>
24 #include "condedit.hxx"
26 class SwWrtShell;
27 class SfxRequest;
29 class BookmarkTable
31 std::unique_ptr<weld::TreeView> m_xControl;
32 std::unique_ptr<weld::TreeIter> GetRowByBookmarkName(const OUString& sName);
34 public:
35 BookmarkTable(std::unique_ptr<weld::TreeView> xControl);
36 void InsertBookmark(SwWrtShell& rSh, sw::mark::MarkBase* pMark);
37 bool SelectByName(const OUString& sName);
38 sw::mark::MarkBase* GetBookmarkByName(const OUString& sName);
39 OUString GetNameProposal() const;
41 void unselect_all() { m_xControl->unselect_all(); }
42 bool has_focus() const { return m_xControl->has_focus(); }
43 std::unique_ptr<weld::TreeIter> get_selected() const;
44 void clear() { m_xControl->clear(); }
45 void select(const weld::TreeIter& rIter) { m_xControl->select(rIter); }
46 void remove_selection() { m_xControl->remove_selection(); }
47 OUString get_text(const weld::TreeIter& rIter) const { return m_xControl->get_text(rIter, 2); }
48 OUString get_id(const weld::TreeIter& rIter) const { return m_xControl->get_id(rIter); }
49 void set_sort_indicator(TriState eState, int nColumn = -1)
51 m_xControl->set_sort_indicator(eState, nColumn);
53 void selected_foreach(const std::function<bool(weld::TreeIter&)>& func)
55 m_xControl->selected_foreach(func);
58 void connect_changed(const Link<weld::TreeView&, void>& rLink)
60 m_xControl->connect_selection_changed(rLink);
62 void connect_row_activated(const Link<weld::TreeView&, bool>& rLink)
64 m_xControl->connect_row_activated(rLink);
66 void connect_column_clicked(const Link<int, void>& rLink)
68 m_xControl->connect_column_clicked(rLink);
70 void connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink,
71 const Link<const weld::TreeView::iter_string&, bool>& rEndLink)
73 m_xControl->connect_editing(rStartLink, rEndLink);
75 void set_column_editables(::std::vector<bool> const& rEditables)
77 m_xControl->set_column_editables(rEditables);
79 void start_editing(weld::TreeIter const& rIter) { m_xControl->start_editing(rIter); }
80 void make_sorted() { m_xControl->make_sorted(); }
81 bool get_sort_order() const { return m_xControl->get_sort_order(); }
82 void set_sort_order(bool bAscending) { m_xControl->set_sort_order(bAscending); }
83 int get_sort_column() const { return m_xControl->get_sort_column(); }
84 void set_sort_column(int nColumn) { m_xControl->set_sort_column(nColumn); }
86 static constexpr OUString aForbiddenChars = u"/\\@*?\",#"_ustr;
87 static const char s_cSeparator;
90 class SwInsertBookmarkDlg final : public SfxDialogController
92 SwWrtShell& m_rSh;
93 std::vector<std::pair<sw::mark::MarkBase*, OUString>> m_aTableBookmarks;
94 sal_Int32 m_nLastBookmarksCount;
95 bool m_bSorted;
96 bool m_bAreProtected;
98 std::unique_ptr<weld::Entry> m_xEditBox;
99 std::unique_ptr<weld::Button> m_xInsertBtn;
100 std::unique_ptr<weld::Button> m_xDeleteBtn;
101 std::unique_ptr<weld::Button> m_xGotoBtn;
102 std::unique_ptr<weld::Button> m_xEditTextBtn;
103 std::unique_ptr<weld::Button> m_xRenameBtn;
104 std::unique_ptr<weld::CheckButton> m_xHideCB;
105 std::unique_ptr<weld::Label> m_xConditionFT;
106 std::unique_ptr<ConditionEdit<weld::Entry>> m_xConditionED;
107 std::unique_ptr<BookmarkTable> m_xBookmarksBox;
108 std::unique_ptr<weld::Label> m_xForbiddenChars;
110 DECL_LINK(ModifyHdl, weld::Entry&, void);
111 DECL_LINK(InsertHdl, weld::Button&, void);
112 DECL_LINK(DeleteHdl, weld::Button&, void);
113 DECL_LINK(EditTextHdl, weld::Button&, void);
114 DECL_LINK(RenameHdl, weld::Button&, void);
115 DECL_LINK(GotoHdl, weld::Button&, void);
116 DECL_LINK(SelectionChangedHdl, weld::TreeView&, void);
117 DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
118 DECL_LINK(HeaderBarClick, int, void);
119 DECL_LINK(ChangeHideHdl, weld::Toggleable&, void);
120 DECL_LINK(EditingHdl, weld::TreeIter const&, bool);
121 DECL_LINK(EditedHdl, weld::TreeView::iter_string const&, bool);
123 // Fill table with bookmarks
124 void PopulateTable();
126 * Check if displayed bookmarks are up-to date, if not update them.
127 * @return True if no update was needed.
129 bool ValidateBookmarks();
130 bool HaveBookmarksChanged();
131 void GotoSelectedBookmark();
132 void SelectionChanged();
134 public:
135 SwInsertBookmarkDlg(weld::Window* pParent, SwWrtShell& rSh, OUString const* pSelected);
136 virtual ~SwInsertBookmarkDlg() override;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */