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 .
21 #include <sfx2/basedlgs.hxx>
22 #include <vcl/weld.hxx>
24 #include "condedit.hxx"
31 std::unique_ptr
<weld::TreeView
> m_xControl
;
32 std::unique_ptr
<weld::TreeIter
> GetRowByBookmarkName(const OUString
& sName
);
34 BookmarkTable(std::unique_ptr
<weld::TreeView
> xControl
);
35 void InsertBookmark(SwWrtShell
& rSh
, sw::mark::IMark
* pMark
);
36 bool SelectByName(const OUString
& sName
);
37 sw::mark::IMark
* GetBookmarkByName(const OUString
& sName
);
38 OUString
GetNameProposal() const;
40 void unselect_all() { m_xControl
->unselect_all(); }
41 bool has_focus() const { return m_xControl
->has_focus(); }
42 std::unique_ptr
<weld::TreeIter
> get_selected() const;
43 void clear() { m_xControl
->clear(); }
44 void select(const weld::TreeIter
& rIter
) { m_xControl
->select(rIter
); }
45 void remove_selection() { m_xControl
->remove_selection(); }
46 OUString
get_text(const weld::TreeIter
& rIter
) const { return m_xControl
->get_text(rIter
, 2); }
47 OUString
get_id(const weld::TreeIter
& rIter
) const { return m_xControl
->get_id(rIter
); }
48 void set_sort_indicator(TriState eState
, int nColumn
= -1) { m_xControl
->set_sort_indicator(eState
, nColumn
); }
49 void selected_foreach(const std::function
<bool(weld::TreeIter
&)>& func
) { m_xControl
->selected_foreach(func
); }
51 void connect_changed(const Link
<weld::TreeView
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
52 void connect_row_activated(const Link
<weld::TreeView
&, bool>& rLink
) { m_xControl
->connect_row_activated(rLink
); }
53 void connect_column_clicked(const Link
<int, void>& rLink
) { m_xControl
->connect_column_clicked(rLink
); }
54 void connect_editing(const Link
<const weld::TreeIter
&, bool>& rStartLink
,
55 const Link
<const weld::TreeView::iter_string
&, bool>& rEndLink
) { m_xControl
->connect_editing(rStartLink
, rEndLink
); }
56 void set_column_editables(::std::vector
<bool> const& rEditables
) { m_xControl
->set_column_editables(rEditables
); }
57 void start_editing(weld::TreeIter
const& rIter
) { m_xControl
->start_editing(rIter
); }
58 void make_sorted() { m_xControl
->make_sorted(); }
59 bool get_sort_order() const { return m_xControl
->get_sort_order(); }
60 void set_sort_order(bool bAscending
) { m_xControl
->set_sort_order(bAscending
); }
61 int get_sort_column() const { return m_xControl
->get_sort_column(); }
62 void set_sort_column(int nColumn
) { m_xControl
->set_sort_column(nColumn
); }
64 static constexpr OUStringLiteral aForbiddenChars
= u
"/\\@*?\",#";
65 static const char s_cSeparator
;
68 class SwInsertBookmarkDlg final
: public SfxDialogController
71 std::vector
<std::pair
<sw::mark::IMark
*, OUString
>> m_aTableBookmarks
;
72 sal_Int32 m_nLastBookmarksCount
;
76 std::unique_ptr
<weld::Entry
> m_xEditBox
;
77 std::unique_ptr
<weld::Button
> m_xInsertBtn
;
78 std::unique_ptr
<weld::Button
> m_xDeleteBtn
;
79 std::unique_ptr
<weld::Button
> m_xGotoBtn
;
80 std::unique_ptr
<weld::Button
> m_xEditTextBtn
;
81 std::unique_ptr
<weld::Button
> m_xRenameBtn
;
82 std::unique_ptr
<weld::CheckButton
> m_xHideCB
;
83 std::unique_ptr
<weld::Label
> m_xConditionFT
;
84 std::unique_ptr
<ConditionEdit
> m_xConditionED
;
85 std::unique_ptr
<BookmarkTable
> m_xBookmarksBox
;
86 std::unique_ptr
<weld::Label
> m_xForbiddenChars
;
88 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
89 DECL_LINK(InsertHdl
, weld::Button
&, void);
90 DECL_LINK(DeleteHdl
, weld::Button
&, void);
91 DECL_LINK(EditTextHdl
, weld::Button
&, void);
92 DECL_LINK(RenameHdl
, weld::Button
&, void);
93 DECL_LINK(GotoHdl
, weld::Button
&, void);
94 DECL_LINK(SelectionChangedHdl
, weld::TreeView
&, void);
95 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
96 DECL_LINK(HeaderBarClick
, int, void);
97 DECL_LINK(ChangeHideHdl
, weld::Toggleable
&, void);
98 DECL_LINK(EditingHdl
, weld::TreeIter
const&, bool);
99 DECL_LINK(EditedHdl
, weld::TreeView::iter_string
const&, bool);
101 // Fill table with bookmarks
102 void PopulateTable();
104 * Check if displayed bookmarks are up-to date, if not update them.
105 * @return True if no update was needed.
107 bool ValidateBookmarks();
108 bool HaveBookmarksChanged();
109 void GotoSelectedBookmark();
110 void SelectionChanged();
113 SwInsertBookmarkDlg(weld::Window
* pParent
, SwWrtShell
& rSh
, OUString
const* pSelected
);
114 virtual ~SwInsertBookmarkDlg() override
;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */