LibreOffice Module sw (master) 1
uibase/inc/bookmark.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#pragma once
20
21#include <sfx2/basedlgs.hxx>
22#include <vcl/weld.hxx>
23#include <IMark.hxx>
24#include "condedit.hxx"
25
26class SwWrtShell;
27class SfxRequest;
28
30{
31 std::unique_ptr<weld::TreeView> m_xControl;
32 std::unique_ptr<weld::TreeIter> GetRowByBookmarkName(const OUString& sName);
33public:
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;
39
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); }
50
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); }
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); }
63
64 static constexpr OUStringLiteral aForbiddenChars = u"/\\@*?\",#";
65 static const char s_cSeparator;
66};
67
69{
71 std::vector<std::pair<sw::mark::IMark*, OUString>> m_aTableBookmarks;
75
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;
87
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);
100
101 // Fill table with bookmarks
102 void PopulateTable();
107 bool ValidateBookmarks();
110 void SelectionChanged();
111
112public:
113 SwInsertBookmarkDlg(weld::Window* pParent, SwWrtShell& rSh, OUString const* pSelected);
114 virtual ~SwInsertBookmarkDlg() override;
115};
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString get_text(const weld::TreeIter &rIter) const
void connect_editing(const Link< const weld::TreeIter &, bool > &rStartLink, const Link< const weld::TreeView::iter_string &, bool > &rEndLink)
void InsertBookmark(SwWrtShell &rSh, sw::mark::IMark *pMark)
void set_sort_column(int nColumn)
int get_sort_column() const
OUString GetNameProposal() const
static constexpr OUStringLiteral aForbiddenChars
OUString get_id(const weld::TreeIter &rIter) const
void select(const weld::TreeIter &rIter)
bool SelectByName(const OUString &sName)
void connect_row_activated(const Link< weld::TreeView &, bool > &rLink)
void connect_changed(const Link< weld::TreeView &, void > &rLink)
static const char s_cSeparator
void connect_column_clicked(const Link< int, void > &rLink)
std::unique_ptr< weld::TreeIter > GetRowByBookmarkName(const OUString &sName)
bool get_sort_order() const
void set_sort_indicator(TriState eState, int nColumn=-1)
BookmarkTable(std::unique_ptr< weld::TreeView > xControl)
void set_column_editables(::std::vector< bool > const &rEditables)
void start_editing(weld::TreeIter const &rIter)
bool has_focus() const
sw::mark::IMark * GetBookmarkByName(const OUString &sName)
void set_sort_order(bool bAscending)
std::unique_ptr< weld::TreeIter > get_selected() const
void selected_foreach(const std::function< bool(weld::TreeIter &)> &func)
std::unique_ptr< weld::TreeView > m_xControl
std::unique_ptr< weld::Button > m_xEditTextBtn
DECL_LINK(EditedHdl, weld::TreeView::iter_string const &, bool)
std::unique_ptr< weld::Label > m_xForbiddenChars
std::vector< std::pair< sw::mark::IMark *, OUString > > m_aTableBookmarks
std::unique_ptr< weld::Button > m_xRenameBtn
DECL_LINK(DoubleClickHdl, weld::TreeView &, bool)
DECL_LINK(InsertHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xDeleteBtn
virtual ~SwInsertBookmarkDlg() override
DECL_LINK(ChangeHideHdl, weld::Toggleable &, void)
DECL_LINK(EditTextHdl, weld::Button &, void)
DECL_LINK(RenameHdl, weld::Button &, void)
std::unique_ptr< ConditionEdit > m_xConditionED
DECL_LINK(ModifyHdl, weld::Entry &, void)
SwInsertBookmarkDlg(weld::Window *pParent, SwWrtShell &rSh, OUString const *pSelected)
DECL_LINK(EditingHdl, weld::TreeIter const &, bool)
bool ValidateBookmarks()
Check if displayed bookmarks are up-to date, if not update them.
DECL_LINK(GotoHdl, weld::Button &, void)
DECL_LINK(SelectionChangedHdl, weld::TreeView &, void)
DECL_LINK(DeleteHdl, weld::Button &, void)
std::unique_ptr< weld::CheckButton > m_xHideCB
std::unique_ptr< weld::Button > m_xGotoBtn
std::unique_ptr< weld::Entry > m_xEditBox
DECL_LINK(HeaderBarClick, int, void)
std::unique_ptr< BookmarkTable > m_xBookmarksBox
std::unique_ptr< weld::Button > m_xInsertBtn
std::unique_ptr< weld::Label > m_xConditionFT
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
std::pair< const TreeIter &, OUString > iter_string
float u
TriState