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 _PKGURI_HXX 25 #define _PKGURI_HXX 26 27 #include <rtl/ustring.hxx> 28 29 namespace package_ucp { 30 31 //========================================================================= 32 33 #define PACKAGE_URL_SCHEME "vnd.sun.star.pkg" 34 #define PACKAGE_ZIP_URL_SCHEME "vnd.sun.star.zip" 35 #define PACKAGE_URL_SCHEME_LENGTH 16 36 37 //========================================================================= 38 39 class PackageUri 40 { 41 mutable ::rtl::OUString m_aUri; 42 mutable ::rtl::OUString m_aParentUri; 43 mutable ::rtl::OUString m_aPackage; 44 mutable ::rtl::OUString m_aPath; 45 mutable ::rtl::OUString m_aName; 46 mutable ::rtl::OUString m_aParam; 47 mutable ::rtl::OUString m_aScheme; 48 mutable bool m_bValid; 49 50 private: 51 void init() const; 52 53 public: PackageUri()54 PackageUri() : m_bValid( false ) {} PackageUri(const::rtl::OUString & rPackageUri)55 PackageUri( const ::rtl::OUString & rPackageUri ) 56 : m_aUri( rPackageUri ), m_bValid( false ) {} 57 isValid() const58 sal_Bool isValid() const 59 { init(); return m_bValid; } 60 getUri() const61 const ::rtl::OUString & getUri() const 62 { init(); return m_aUri; } 63 setUri(const::rtl::OUString & rPackageUri)64 void setUri( const ::rtl::OUString & rPackageUri ) 65 { m_aPath = ::rtl::OUString(); m_aUri = rPackageUri; m_bValid = false; } 66 getParentUri() const67 const ::rtl::OUString & getParentUri() const 68 { init(); return m_aParentUri; } 69 getPackage() const70 const ::rtl::OUString & getPackage() const 71 { init(); return m_aPackage; } 72 getPath() const73 const ::rtl::OUString & getPath() const 74 { init(); return m_aPath; } 75 getName() const76 const ::rtl::OUString & getName() const 77 { init(); return m_aName; } 78 getParam() const79 const ::rtl::OUString & getParam() const 80 { init(); return m_aParam; } 81 getScheme() const82 const ::rtl::OUString & getScheme() const 83 { init(); return m_aScheme; } 84 85 inline sal_Bool isRootFolder() const; 86 }; 87 isRootFolder() const88inline sal_Bool PackageUri::isRootFolder() const 89 { 90 init(); 91 return ( ( m_aPath.getLength() == 1 ) && 92 ( m_aPath.getStr()[ 0 ] == sal_Unicode( '/' ) ) ); 93 } 94 95 } 96 97 #endif 98