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 _HIERARCHYURI_HXX
25 #define _HIERARCHYURI_HXX
26 
27 #include <rtl/ustring.hxx>
28 
29 namespace hierarchy_ucp {
30 
31 //=========================================================================
32 
33 #define HIERARCHY_URL_SCHEME          "vnd.sun.star.hier"
34 #define HIERARCHY_URL_SCHEME_LENGTH   17
35 
36 //=========================================================================
37 
38 class HierarchyUri
39 {
40 	mutable ::rtl::OUString m_aUri;
41 	mutable ::rtl::OUString m_aParentUri;
42     mutable ::rtl::OUString m_aService;
43 	mutable ::rtl::OUString m_aPath;
44 	mutable ::rtl::OUString m_aName;
45     mutable bool            m_bValid;
46 
47 private:
48 	void init() const;
49 
50 public:
HierarchyUri()51     HierarchyUri() : m_bValid( false ) {}
HierarchyUri(const::rtl::OUString & rUri)52     HierarchyUri( const ::rtl::OUString & rUri )
53     : m_aUri( rUri ), m_bValid( false ) {}
54 
isValid() const55     sal_Bool isValid() const
56     { init(); return m_bValid; }
57 
getUri() const58 	const ::rtl::OUString & getUri() const
59 	{ init(); return m_aUri; }
60 
setUri(const::rtl::OUString & rUri)61     void setUri( const ::rtl::OUString & rUri )
62     { m_aPath = ::rtl::OUString(); m_aUri = rUri; m_bValid = false; }
63 
getParentUri() const64 	const ::rtl::OUString & getParentUri() const
65 	{ init(); return m_aParentUri; }
66 
getService() const67     const ::rtl::OUString & getService() const
68     { init(); return m_aService; }
69 
getPath() const70 	const ::rtl::OUString & getPath() const
71 	{ init(); return m_aPath; }
72 
getName() const73 	const ::rtl::OUString & getName() const
74 	{ init(); return m_aName; }
75 
76     inline sal_Bool isRootFolder() const;
77 };
78 
isRootFolder() const79 inline sal_Bool HierarchyUri::isRootFolder() const
80 {
81     init();
82     return ( ( m_aPath.getLength() == 1 ) &&
83              ( m_aPath.getStr()[ 0 ] == sal_Unicode( '/' ) ) );
84 }
85 }
86 
87 #endif
88