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 
26 class SwWrtShell;
27 class SfxRequest;
28 
30 {
31  std::unique_ptr<weld::TreeView> m_xControl;
32  std::unique_ptr<weld::TreeIter> GetRowByBookmarkName(const OUString& sName);
33 public:
34  BookmarkTable(std::unique_ptr<weld::TreeView> xControl);
35  void InsertBookmark(sw::mark::IMark* pMark);
36  void 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_id(const weld::TreeIter& rIter) const { return m_xControl->get_id(rIter); }
47  void set_sort_indicator(TriState eState, int nColumn = -1) { m_xControl->set_sort_indicator(eState, nColumn); }
48  void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) { m_xControl->selected_foreach(func); }
49 
50  void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_changed(rLink); }
51  void connect_row_activated(const Link<weld::TreeView&, bool>& rLink) { m_xControl->connect_row_activated(rLink); }
52  void connect_column_clicked(const Link<int, void>& rLink) { m_xControl->connect_column_clicked(rLink); }
53  void make_sorted() { m_xControl->make_sorted(); }
54  bool get_sort_order() const { return m_xControl->get_sort_order(); }
55  void set_sort_order(bool bAscending) { m_xControl->set_sort_order(bAscending); }
56  int get_sort_column() const { return m_xControl->get_sort_column(); }
57  void set_sort_column(int nColumn) { m_xControl->set_sort_column(nColumn); }
58 
59  static constexpr OUStringLiteral aForbiddenChars = u"/\\@*?\",#";
60  static const char cSeparator;
61 };
62 
64 {
66  std::vector<std::pair<sw::mark::IMark*, OUString>> aTableBookmarks;
68  bool m_bSorted;
70 
71  std::unique_ptr<weld::Entry> m_xEditBox;
72  std::unique_ptr<weld::Button> m_xInsertBtn;
73  std::unique_ptr<weld::Button> m_xDeleteBtn;
74  std::unique_ptr<weld::Button> m_xGotoBtn;
75  std::unique_ptr<weld::Button> m_xRenameBtn;
76  std::unique_ptr<weld::CheckButton> m_xHideCB;
77  std::unique_ptr<weld::Label> m_xConditionFT;
78  std::unique_ptr<ConditionEdit> m_xConditionED;
79  std::unique_ptr<BookmarkTable> m_xBookmarksBox;
80  std::unique_ptr<weld::Label> m_xForbiddenChars;
81 
82  DECL_LINK(ModifyHdl, weld::Entry&, void);
83  DECL_LINK(InsertHdl, weld::Button&, void);
84  DECL_LINK(DeleteHdl, weld::Button&, void);
85  DECL_LINK(RenameHdl, weld::Button&, void);
86  DECL_LINK(GotoHdl, weld::Button&, void);
87  DECL_LINK(SelectionChangedHdl, weld::TreeView&, void);
88  DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
89  DECL_LINK(HeaderBarClick, int, void);
90  DECL_LINK(ChangeHideHdl, weld::Toggleable&, void);
91 
92  // Fill table with bookmarks
93  void PopulateTable();
98  bool ValidateBookmarks();
99  bool HaveBookmarksChanged();
100  void GotoSelectedBookmark();
101 
102 public:
104  virtual ~SwInsertBookmarkDlg() override;
105 };
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static constexpr OUStringLiteral aForbiddenChars
virtual ~SwInsertBookmarkDlg() override
std::unique_ptr< weld::TreeView > m_xControl
std::unique_ptr< weld::Button > m_xInsertBtn
std::unique_ptr< weld::Label > m_xConditionFT
bool has_focus() const
void set_sort_order(bool bAscending)
void selected_foreach(const std::function< bool(weld::TreeIter &)> &func)
void set_sort_column(int nColumn)
std::unique_ptr< weld::Label > m_xForbiddenChars
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
std::unique_ptr< weld::Button > m_xRenameBtn
std::unique_ptr< weld::CheckButton > m_xHideCB
std::unique_ptr< weld::TreeIter > GetRowByBookmarkName(const OUString &sName)
void connect_changed(const Link< weld::TreeView &, void > &rLink)
std::unique_ptr< ConditionEdit > m_xConditionED
SwInsertBookmarkDlg(weld::Window *pParent, SwWrtShell &rSh)
std::unique_ptr< weld::Button > m_xDeleteBtn
std::unique_ptr< BookmarkTable > m_xBookmarksBox
float u
int get_sort_column() const
static const char cSeparator
OUString GetNameProposal() const
void set_sort_indicator(TriState eState, int nColumn=-1)
bool get_sort_order() const
void select(const weld::TreeIter &rIter)
void SelectByName(const OUString &sName)
std::vector< std::pair< sw::mark::IMark *, OUString > > aTableBookmarks
void connect_column_clicked(const Link< int, void > &rLink)
BookmarkTable(std::unique_ptr< weld::TreeView > xControl)
void connect_row_activated(const Link< weld::TreeView &, bool > &rLink)
bool ValidateBookmarks()
Check if displayed bookmarks are up-to date, if not update them.
std::unique_ptr< weld::TreeIter > get_selected() const
DECL_LINK(ModifyHdl, weld::Entry &, void)
std::unique_ptr< weld::Entry > m_xEditBox
std::unique_ptr< weld::Button > m_xGotoBtn
sw::mark::IMark * GetBookmarkByName(const OUString &sName)
void InsertBookmark(sw::mark::IMark *pMark)
TriState
OUString get_id(const weld::TreeIter &rIter) const