1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef INCLUDED_TDOC_URI_HXX
30 #define INCLUDED_TDOC_URI_HXX
32 #include "rtl/ustring.hxx"
36 //=========================================================================
38 #define TDOC_URL_SCHEME "vnd.sun.star.tdoc"
39 #define TDOC_URL_SCHEME_LENGTH 17
41 //=========================================================================
45 enum State
{ UNKNOWN
, INVALID
, VALID
};
47 mutable ::rtl::OUString m_aUri
;
48 mutable ::rtl::OUString m_aParentUri
;
49 mutable ::rtl::OUString m_aPath
;
50 mutable ::rtl::OUString m_aDocId
;
51 mutable ::rtl::OUString m_aInternalPath
;
52 mutable ::rtl::OUString m_aName
;
53 mutable ::rtl::OUString m_aDecodedName
;
54 mutable State m_eState
;
60 Uri() : m_eState( UNKNOWN
) {}
61 Uri( const ::rtl::OUString
& rUri
)
62 : m_aUri( rUri
), m_eState( UNKNOWN
) {}
64 bool operator== ( const Uri
& rOther
) const
65 { init(); return m_aUri
== rOther
.m_aUri
; }
67 bool operator!= ( const Uri
& rOther
) const
68 { return !operator==( rOther
); }
70 sal_Bool
isValid() const
71 { init(); return m_eState
== VALID
; }
73 const ::rtl::OUString
& getUri() const
74 { init(); return m_aUri
; }
76 inline void setUri( const ::rtl::OUString
& rUri
);
78 const ::rtl::OUString
& getParentUri() const
79 { init(); return m_aParentUri
; }
81 const ::rtl::OUString
& getPath() const
82 { init(); return m_aPath
; }
84 const ::rtl::OUString
& getDocumentId() const
85 { init(); return m_aDocId
; }
87 const ::rtl::OUString
& getInternalPath() const
88 { init(); return m_aInternalPath
; }
90 const ::rtl::OUString
& getName() const
91 { init(); return m_aName
; }
93 const ::rtl::OUString
& getDecodedName() const
94 { init(); return m_aDecodedName
; }
96 inline sal_Bool
isRoot() const;
98 inline sal_Bool
isDocument() const;
100 inline sal_Bool
isFolder() const;
103 inline void Uri::setUri( const ::rtl::OUString
& rUri
)
107 m_aParentUri
= m_aDocId
= m_aInternalPath
= m_aPath
= m_aName
108 = m_aDecodedName
= rtl::OUString();
111 inline sal_Bool
Uri::isRoot() const
114 return ( m_aPath
.getLength() == 1 );
117 inline sal_Bool
Uri::isDocument() const
120 return ( ( !m_aDocId
.isEmpty() ) /* not root */
121 && ( m_aPath
.copy( m_aDocId
.getLength() + 1 ).getLength() < 2 ) );
124 inline sal_Bool
Uri::isFolder() const
127 return ( m_aPath
.lastIndexOf( '/' ) == m_aPath
.getLength() - 1 );
130 } // namespace tdoc_ucp
132 #endif /* !INCLUDED_TDOC_URI_HXX */
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */