xref: /AOO41X/main/ucb/source/ucp/hierarchy/hierarchyuri.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 _HIERARCHYURI_HXX
29 #define _HIERARCHYURI_HXX
30 
31 #include <rtl/ustring.hxx>
32 
33 namespace hierarchy_ucp {
34 
35 //=========================================================================
36 
37 #define HIERARCHY_URL_SCHEME          "vnd.sun.star.hier"
38 #define HIERARCHY_URL_SCHEME_LENGTH   17
39 
40 //=========================================================================
41 
42 class HierarchyUri
43 {
44 	mutable ::rtl::OUString m_aUri;
45 	mutable ::rtl::OUString m_aParentUri;
46     mutable ::rtl::OUString m_aService;
47 	mutable ::rtl::OUString m_aPath;
48 	mutable ::rtl::OUString m_aName;
49     mutable bool            m_bValid;
50 
51 private:
52 	void init() const;
53 
54 public:
55     HierarchyUri() : m_bValid( false ) {}
56     HierarchyUri( const ::rtl::OUString & rUri )
57     : m_aUri( rUri ), m_bValid( false ) {}
58 
59     sal_Bool isValid() const
60     { init(); return m_bValid; }
61 
62 	const ::rtl::OUString & getUri() const
63 	{ init(); return m_aUri; }
64 
65     void setUri( const ::rtl::OUString & rUri )
66     { m_aPath = ::rtl::OUString(); m_aUri = rUri; m_bValid = false; }
67 
68 	const ::rtl::OUString & getParentUri() const
69 	{ init(); return m_aParentUri; }
70 
71     const ::rtl::OUString & getService() const
72     { init(); return m_aService; }
73 
74 	const ::rtl::OUString & getPath() const
75 	{ init(); return m_aPath; }
76 
77 	const ::rtl::OUString & getName() const
78 	{ init(); return m_aName; }
79 
80     inline sal_Bool isRootFolder() const;
81 };
82 
83 inline sal_Bool HierarchyUri::isRootFolder() const
84 {
85     init();
86     return ( ( m_aPath.getLength() == 1 ) &&
87              ( m_aPath.getStr()[ 0 ] == sal_Unicode( '/' ) ) );
88 }
89 }
90 
91 #endif
92