1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tdoc_uri.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_TDOC_URI_HXX
32 #define INCLUDED_TDOC_URI_HXX
34 #include "rtl/ustring.hxx"
38 //=========================================================================
40 #define TDOC_URL_SCHEME "vnd.sun.star.tdoc"
41 #define TDOC_URL_SCHEME_LENGTH 17
43 //=========================================================================
47 enum State
{ UNKNOWN
, INVALID
, VALID
};
49 mutable ::rtl::OUString m_aUri
;
50 mutable ::rtl::OUString m_aParentUri
;
51 mutable ::rtl::OUString m_aPath
;
52 mutable ::rtl::OUString m_aDocId
;
53 mutable ::rtl::OUString m_aInternalPath
;
54 mutable ::rtl::OUString m_aName
;
55 mutable ::rtl::OUString m_aDecodedName
;
56 mutable State m_eState
;
62 Uri() : m_eState( UNKNOWN
) {}
63 Uri( const ::rtl::OUString
& rUri
)
64 : m_aUri( rUri
), m_eState( UNKNOWN
) {}
66 bool operator== ( const Uri
& rOther
) const
67 { init(); return m_aUri
== rOther
.m_aUri
; }
69 bool operator!= ( const Uri
& rOther
) const
70 { return !operator==( rOther
); }
72 sal_Bool
isValid() const
73 { init(); return m_eState
== VALID
; }
75 const ::rtl::OUString
& getUri() const
76 { init(); return m_aUri
; }
78 inline void setUri( const ::rtl::OUString
& rUri
);
80 const ::rtl::OUString
& getParentUri() const
81 { init(); return m_aParentUri
; }
83 const ::rtl::OUString
& getPath() const
84 { init(); return m_aPath
; }
86 const ::rtl::OUString
& getDocumentId() const
87 { init(); return m_aDocId
; }
89 const ::rtl::OUString
& getInternalPath() const
90 { init(); return m_aInternalPath
; }
92 const ::rtl::OUString
& getName() const
93 { init(); return m_aName
; }
95 const ::rtl::OUString
& getDecodedName() const
96 { init(); return m_aDecodedName
; }
98 inline sal_Bool
isRoot() const;
100 inline sal_Bool
isDocument() const;
102 inline sal_Bool
isFolder() const;
105 inline void Uri::setUri( const ::rtl::OUString
& rUri
)
109 m_aParentUri
= m_aDocId
= m_aInternalPath
= m_aPath
= m_aName
110 = m_aDecodedName
= rtl::OUString();
113 inline sal_Bool
Uri::isRoot() const
116 return ( m_aPath
.getLength() == 1 );
119 inline sal_Bool
Uri::isDocument() const
122 return ( ( m_aDocId
.getLength() > 0 ) /* not root */
123 && ( m_aPath
.copy( m_aDocId
.getLength() + 1 ).getLength() < 2 ) );
126 inline sal_Bool
Uri::isFolder() const
129 return ( m_aPath
.lastIndexOf( '/' ) == m_aPath
.getLength() - 1 );
132 } // namespace tdoc_ucp
134 #endif /* !INCLUDED_TDOC_URI_HXX */