xref: /core/include/unotools/historyoptions.hxx (revision cd35a509)
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 <config_options.h>
22 #include <unotools/unotoolsdllapi.h>
23 #include <rtl/ustring.hxx>
24 #include <vector>
25 #include <optional>
26 
27 /// You can use these enum values to specify right history if you call our interface methods.
28 enum class EHistoryType
29 {
30     PickList,
31     HelpBookmarks
32 };
33 
34 /** Collect information about history features.
35 
36     Interface methods to get and set value of config key "org.openoffice.Office.Common/History/..."
37 
38     key "PickList": The last used documents displayed in the file menu.
39     key "History":  The last opened documents general.
40 */
41 namespace SvtHistoryOptions
42 {
43 
44     /** Clear complete specified list.
45 
46         @param      eHistory select right history.
47     */
48     UNLESS_MERGELIBS_MORE(UNOTOOLS_DLLPUBLIC) void Clear(EHistoryType eHistory, const bool bClearPinnedItems = true);
49 
50     /** Return the complete specified history list.
51 
52         @param  eHistory select right history.
53         @return A list of history items is returned.
54     */
55     struct HistoryItem
56     {
57         OUString sURL;
58         OUString sFilter;
59         OUString sTitle;
60         OUString sThumbnail;
61         bool isReadOnly = false;
62         bool isPinned = false;
63     };
64     UNLESS_MERGELIBS_MORE(UNOTOOLS_DLLPUBLIC) std::vector< HistoryItem > GetList(EHistoryType eHistory);
65 
66     /** Append a new item to the specified list.
67 
68         The oldest entry is deleted automatically when the size reaches the maximum.
69 
70         @param eHistory    select right history.
71         @param sURL        URL to save in history
72         @param sFilter     filter name to save in history
73         @param sTitle      document title to save in history
74         @param sThumbnail  base64 encoded thumbnail of the item
75         @param oIsReadOnly item was opened editable or read-only
76     */
77     UNLESS_MERGELIBS_MORE(UNOTOOLS_DLLPUBLIC) void AppendItem(EHistoryType eHistory, const OUString& sURL,
78                                        const OUString& sFilter, const OUString& sTitle,
79                                        const std::optional<OUString>& sThumbnail,
80                                        std::optional<bool> oIsReadOnly);
81 
82     /** Delete item from the specified list.
83     */
84     UNLESS_MERGELIBS_MORE(UNOTOOLS_DLLPUBLIC) void DeleteItem(EHistoryType eHistory, const OUString& sURL,
85                                        const bool bClearPinned = true);
86 
87     // tdf#38742 - toggle pinned state of an item
88     UNLESS_MERGELIBS_MORE(UNOTOOLS_DLLPUBLIC) void TogglePinItem(EHistoryType eHistory, const OUString& sURL);
89 };
90 
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
92