1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SVTOOLS_RESTRICTEDPATHS_HXX 25 #define SVTOOLS_RESTRICTEDPATHS_HXX 26 27 #include <svl/urlfilter.hxx> 28 #include <svl/svldllapi.h> 29 #include <tools/string.hxx> 30 31 #include <vector> 32 33 namespace svt 34 { 35 class SVL_DLLPUBLIC RestrictedPaths : public IUrlFilter 36 { 37 private: 38 ::std::vector< String > m_aUnrestrictedURLs; 39 bool m_bFilterIsEnabled; 40 41 public: 42 RestrictedPaths(); 43 virtual ~RestrictedPaths(); 44 hasFilter() const45 inline bool hasFilter() const { return !m_aUnrestrictedURLs.empty(); } getFilter() const46 inline const ::std::vector< String >& getFilter() const { return m_aUnrestrictedURLs; } 47 enableFilter(bool _bEnable)48 inline void enableFilter( bool _bEnable ) { m_bFilterIsEnabled = _bEnable; } isFilterEnabled() const49 inline bool isFilterEnabled() const { return m_bFilterIsEnabled; } 50 51 public: 52 /** checks URL access permissions 53 54 <p>with the "restriction" feature we have in the file dialog, it's possible that 55 only certain URLs can be browsed. This method checks whether a given URL belongs 56 to this set of permitted URLs.</p> 57 58 <p>If no "access restriction" is effective, this method always returns <TRUE/>.</p> 59 */ 60 virtual bool isUrlAllowed( const String& _rURL ) const; 61 62 /** checks URL access permissions 63 64 <p>with the "restriction" feature we have in the file dialog, it's possible that 65 only certain URLs can be browsed. This method checks whether a given URL belongs 66 to this set of permitted URLs.</p> 67 68 <p>Default behavior allows access to parent folder of a restricted folder (but not to its siblings). 69 If allowParents is set to <FALSE/> parent folders will be treated as forbidden. 70 71 <p>If no "access restriction" is effective, this method always returns <TRUE/>.</p> 72 */ 73 bool isUrlAllowed( const String& _rURL, bool allowParents ) const; 74 }; 75 76 } // namespace svt 77 78 #endif // SVTOOLS_RESTRICTEDPATHS_HXX 79