Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_uri.hxx
blob7bd8aa5951703ac3a8b34c0ca97f1e9cb996486e
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"
34 namespace tdoc_ucp {
36 //=========================================================================
38 #define TDOC_URL_SCHEME "vnd.sun.star.tdoc"
39 #define TDOC_URL_SCHEME_LENGTH 17
41 //=========================================================================
43 class Uri
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;
56 private:
57 void init() const;
59 public:
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 )
105 m_eState = UNKNOWN;
106 m_aUri = rUri;
107 m_aParentUri = m_aDocId = m_aInternalPath = m_aPath = m_aName
108 = m_aDecodedName = rtl::OUString();
111 inline sal_Bool Uri::isRoot() const
113 init();
114 return ( m_aPath.getLength() == 1 );
117 inline sal_Bool Uri::isDocument() const
119 init();
120 return ( ( !m_aDocId.isEmpty() ) /* not root */
121 && ( m_aPath.copy( m_aDocId.getLength() + 1 ).getLength() < 2 ) );
124 inline sal_Bool Uri::isFolder() const
126 init();
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: */