Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svl/inethist.hxx
Line
Count
Source
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 <svl/SfxBroadcaster.hxx>
22
#include <svl/hint.hxx>
23
#include <svl/svldllapi.h>
24
#include <tools/urlobj.hxx>
25
#include <memory>
26
27
class INetURLHistory_Impl;
28
class SVL_DLLPUBLIC INetURLHistory final : public SfxBroadcaster
29
{
30
    /** Representation.
31
    */
32
    std::unique_ptr<INetURLHistory_Impl> m_pImpl;
33
34
    /** Construction/Destruction.
35
    */
36
    SAL_DLLPRIVATE INetURLHistory();
37
    SAL_DLLPRIVATE virtual ~INetURLHistory() override;
38
39
    /** Implementation.
40
    */
41
    SAL_DLLPRIVATE static void NormalizeUrl_Impl (INetURLObject &rUrl);
42
43
    void PutUrl_Impl   (const INetURLObject &rUrl);
44
    bool QueryUrl_Impl (INetURLObject rUrl) const;
45
46
    /** Not implemented.
47
    */
48
    INetURLHistory (const INetURLHistory&) = delete;
49
    INetURLHistory& operator= (const INetURLHistory&) = delete;
50
51
public:
52
    /** GetOrCreate.
53
    */
54
    static INetURLHistory* GetOrCreate();
55
56
    /** QueryProtocol.
57
    */
58
    static bool QueryProtocol (INetProtocol eProto)
59
1.00M
    {
60
1.00M
        return ((eProto == INetProtocol::File ) ||
61
898k
                (eProto == INetProtocol::Ftp  ) ||
62
870k
                (eProto == INetProtocol::Http ) ||
63
829k
                (eProto == INetProtocol::Https)    );
64
1.00M
    }
65
66
    /** QueryUrl.
67
    */
68
    bool QueryUrl (const INetURLObject &rUrl) const
69
7.30k
    {
70
7.30k
        if (QueryProtocol (rUrl.GetProtocol()))
71
0
            return QueryUrl_Impl (rUrl);
72
7.30k
        else
73
7.30k
            return false;
74
7.30k
    }
75
76
    bool QueryUrl (std::u16string_view rUrl) const;
77
78
    /** PutUrl.
79
    */
80
    void PutUrl (const INetURLObject &rUrl)
81
0
    {
82
0
        if (QueryProtocol (rUrl.GetProtocol()))
83
0
            PutUrl_Impl (rUrl);
84
0
    }
85
};
86
87
// broadcasted from PutUrl().
88
class SVL_DLLPUBLIC INetURLHistoryHint final : public SfxHint
89
{
90
    const INetURLObject* pObj;
91
public:
92
0
    explicit INetURLHistoryHint( const INetURLObject* Object ) : SfxHint(SfxHintId::INetURLHistory), pObj(Object) {}
93
0
    const INetURLObject* GetObject() const { return pObj; }
94
};
95
96
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */