Branch data Line data Source code
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 : :
20 : : #ifndef SVTOOLS_RESTRICTEDPATHS_HXX
21 : : #define SVTOOLS_RESTRICTEDPATHS_HXX
22 : :
23 : : #include <svl/urlfilter.hxx>
24 : : #include <svl/svldllapi.h>
25 : : #include <tools/string.hxx>
26 : :
27 : : #include <vector>
28 : :
29 : : namespace svt
30 : : {
31 : : class SVL_DLLPUBLIC RestrictedPaths : public IUrlFilter
32 : : {
33 : : private:
34 : : ::std::vector< String > m_aUnrestrictedURLs;
35 : : bool m_bFilterIsEnabled;
36 : :
37 : : public:
38 : : RestrictedPaths();
39 : : virtual ~RestrictedPaths();
40 : :
41 : : inline bool hasFilter() const { return !m_aUnrestrictedURLs.empty(); }
42 : 0 : inline const ::std::vector< String >& getFilter() const { return m_aUnrestrictedURLs; }
43 : :
44 : 0 : inline void enableFilter( bool _bEnable ) { m_bFilterIsEnabled = _bEnable; }
45 : : inline bool isFilterEnabled() const { return m_bFilterIsEnabled; }
46 : :
47 : : public:
48 : : /** checks URL access permissions
49 : :
50 : : <p>with the "restriction" feature we have in the file dialog, it's possible that
51 : : only certain URLs can be browsed. This method checks whether a given URL belongs
52 : : to this set of permitted URLs.</p>
53 : :
54 : : <p>If no "access restriction" is effective, this method always returns <TRUE/>.</p>
55 : : */
56 : : virtual bool isUrlAllowed( const String& _rURL ) const;
57 : :
58 : : /** checks URL access permissions
59 : :
60 : : <p>with the "restriction" feature we have in the file dialog, it's possible that
61 : : only certain URLs can be browsed. This method checks whether a given URL belongs
62 : : to this set of permitted URLs.</p>
63 : :
64 : : <p>Default behavior allows access to parent folder of a restricted folder (but not to its siblings).
65 : : If allowParents is set to <FALSE/> parent folders will be treated as forbidden.
66 : :
67 : : <p>If no "access restriction" is effective, this method always returns <TRUE/>.</p>
68 : : */
69 : : bool isUrlAllowed( const String& _rURL, bool allowParents ) const;
70 : : };
71 : :
72 : : } // namespace svt
73 : :
74 : : #endif // SVTOOLS_RESTRICTEDPATHS_HXX
75 : :
76 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|