1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_TDOC_URI_HXX
21 #define INCLUDED_TDOC_URI_HXX
23 #include "rtl/ustring.hxx"
27 //=========================================================================
29 #define TDOC_URL_SCHEME "vnd.sun.star.tdoc"
30 #define TDOC_URL_SCHEME_LENGTH 17
32 //=========================================================================
36 enum State
{ UNKNOWN
, INVALID
, VALID
};
38 mutable ::rtl::OUString m_aUri
;
39 mutable ::rtl::OUString m_aParentUri
;
40 mutable ::rtl::OUString m_aPath
;
41 mutable ::rtl::OUString m_aDocId
;
42 mutable ::rtl::OUString m_aInternalPath
;
43 mutable ::rtl::OUString m_aName
;
44 mutable ::rtl::OUString m_aDecodedName
;
45 mutable State m_eState
;
51 Uri() : m_eState( UNKNOWN
) {}
52 Uri( const ::rtl::OUString
& rUri
)
53 : m_aUri( rUri
), m_eState( UNKNOWN
) {}
55 bool operator== ( const Uri
& rOther
) const
56 { init(); return m_aUri
== rOther
.m_aUri
; }
58 bool operator!= ( const Uri
& rOther
) const
59 { return !operator==( rOther
); }
61 sal_Bool
isValid() const
62 { init(); return m_eState
== VALID
; }
64 const ::rtl::OUString
& getUri() const
65 { init(); return m_aUri
; }
67 inline void setUri( const ::rtl::OUString
& rUri
);
69 const ::rtl::OUString
& getParentUri() const
70 { init(); return m_aParentUri
; }
72 const ::rtl::OUString
& getPath() const
73 { init(); return m_aPath
; }
75 const ::rtl::OUString
& getDocumentId() const
76 { init(); return m_aDocId
; }
78 const ::rtl::OUString
& getInternalPath() const
79 { init(); return m_aInternalPath
; }
81 const ::rtl::OUString
& getName() const
82 { init(); return m_aName
; }
84 const ::rtl::OUString
& getDecodedName() const
85 { init(); return m_aDecodedName
; }
87 inline sal_Bool
isRoot() const;
89 inline sal_Bool
isDocument() const;
91 inline sal_Bool
isFolder() const;
94 inline void Uri::setUri( const ::rtl::OUString
& rUri
)
98 m_aParentUri
= m_aDocId
= m_aInternalPath
= m_aPath
= m_aName
99 = m_aDecodedName
= rtl::OUString();
102 inline sal_Bool
Uri::isRoot() const
105 return ( m_aPath
.getLength() == 1 );
108 inline sal_Bool
Uri::isDocument() const
111 return ( ( !m_aDocId
.isEmpty() ) /* not root */
112 && ( m_aPath
.copy( m_aDocId
.getLength() + 1 ).getLength() < 2 ) );
115 inline sal_Bool
Uri::isFolder() const
118 return ( m_aPath
.lastIndexOf( '/' ) == m_aPath
.getLength() - 1 );
121 } // namespace tdoc_ucp
123 #endif /* !INCLUDED_TDOC_URI_HXX */
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */