xref: /aoo42x/main/ucb/source/ucp/package/pkguri.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _PKGURI_HXX
29 #define _PKGURI_HXX
30 
31 #include <rtl/ustring.hxx>
32 
33 namespace package_ucp {
34 
35 //=========================================================================
36 
37 #define PACKAGE_URL_SCHEME 			"vnd.sun.star.pkg"
38 #define PACKAGE_ZIP_URL_SCHEME		"vnd.sun.star.zip"
39 #define PACKAGE_URL_SCHEME_LENGTH	16
40 
41 //=========================================================================
42 
43 class PackageUri
44 {
45 	mutable ::rtl::OUString m_aUri;
46 	mutable ::rtl::OUString m_aParentUri;
47 	mutable ::rtl::OUString m_aPackage;
48 	mutable ::rtl::OUString m_aPath;
49 	mutable ::rtl::OUString m_aName;
50 	mutable ::rtl::OUString m_aParam;
51 	mutable ::rtl::OUString m_aScheme;
52     mutable bool            m_bValid;
53 
54 private:
55 	void init() const;
56 
57 public:
58     PackageUri() : m_bValid( false ) {}
59 	PackageUri( const ::rtl::OUString & rPackageUri )
60     : m_aUri( rPackageUri ), m_bValid( false ) {}
61 
62     sal_Bool isValid() const
63     { init(); return m_bValid; }
64 
65 	const ::rtl::OUString & getUri() const
66 	{ init(); return m_aUri; }
67 
68 	void setUri( const ::rtl::OUString & rPackageUri )
69     { m_aPath = ::rtl::OUString(); m_aUri = rPackageUri; m_bValid = false; }
70 
71 	const ::rtl::OUString & getParentUri() const
72 	{ init(); return m_aParentUri; }
73 
74 	const ::rtl::OUString & getPackage() const
75 	{ init(); return m_aPackage; }
76 
77 	const ::rtl::OUString & getPath() const
78 	{ init(); return m_aPath; }
79 
80 	const ::rtl::OUString & getName() const
81 	{ init(); return m_aName; }
82 
83 	const ::rtl::OUString & getParam() const
84 	{ init(); return m_aParam; }
85 
86 	const ::rtl::OUString & getScheme() const
87 	{ init(); return m_aScheme; }
88 
89     inline sal_Bool isRootFolder() const;
90 };
91 
92 inline sal_Bool PackageUri::isRootFolder() const
93 {
94     init();
95     return ( ( m_aPath.getLength() == 1 ) &&
96              ( m_aPath.getStr()[ 0 ] == sal_Unicode( '/' ) ) );
97 }
98 
99 }
100 
101 #endif
102