Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchydata.hxx
blob9c93957fb1020b8c9ff80bb63c50426bf15bb17a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _HIERARCHYDATA_HXX
21 #define _HIERARCHYDATA_HXX
23 #include <rtl/ustring.hxx>
24 #include <osl/mutex.hxx>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
28 namespace com { namespace sun { namespace star {
29 namespace container {
30 class XHierarchicalNameAccess;
32 namespace util {
33 class XOfficeInstallationDirectories;
35 } } }
37 namespace hierarchy_ucp
40 //=========================================================================
42 class HierarchyEntryData
44 public:
45 enum Type { NONE, LINK, FOLDER };
47 HierarchyEntryData() : m_aType( NONE ) {}
48 HierarchyEntryData( const Type & rType ) : m_aType( rType ) {}
50 const rtl::OUString & getName() const { return m_aName; }
51 void setName( const rtl::OUString & rName ) { m_aName = rName; }
53 const rtl::OUString & getTitle() const { return m_aTitle; }
54 void setTitle( const rtl::OUString & rTitle ) { m_aTitle = rTitle; }
56 const rtl::OUString & getTargetURL() const { return m_aTargetURL; }
57 void setTargetURL( const rtl::OUString & rURL ) { m_aTargetURL = rURL; }
59 Type getType() const
60 { return ( m_aType != NONE ) ? m_aType
61 : m_aTargetURL.getLength()
62 ? LINK
63 : FOLDER; }
64 void setType( const Type & rType ) { m_aType = rType; }
66 private:
67 rtl::OUString m_aName; // Name (language independent)
68 rtl::OUString m_aTitle; // Title (language dependent)
69 rtl::OUString m_aTargetURL; // Target URL ( links only )
70 Type m_aType; // Type
73 //=========================================================================
75 class HierarchyContentProvider;
76 class HierarchyUri;
78 class HierarchyEntry
80 ::rtl::OUString m_aServiceSpecifier;
81 ::rtl::OUString m_aName;
82 ::rtl::OUString m_aPath;
83 ::osl::Mutex m_aMutex;
84 ::com::sun::star::uno::Reference<
85 ::com::sun::star::uno::XComponentContext > m_xContext;
86 ::com::sun::star::uno::Reference<
87 ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
88 ::com::sun::star::uno::Reference<
89 ::com::sun::star::container::XHierarchicalNameAccess >
90 m_xRootReadAccess;
91 ::com::sun::star::uno::Reference<
92 ::com::sun::star::util::XOfficeInstallationDirectories >
93 m_xOfficeInstDirs;
94 sal_Bool m_bTriedToGetRootReadAccess; // #82494#
96 private:
97 ::rtl::OUString createPathFromHierarchyURL( const HierarchyUri & rURI );
98 ::com::sun::star::uno::Reference<
99 ::com::sun::star::container::XHierarchicalNameAccess >
100 getRootReadAccess();
102 public:
103 HierarchyEntry( const ::com::sun::star::uno::Reference<
104 ::com::sun::star::uno::XComponentContext >& rxContext,
105 HierarchyContentProvider* pProvider,
106 const ::rtl::OUString& rURL );
108 sal_Bool hasData();
110 sal_Bool getData( HierarchyEntryData& rData );
112 sal_Bool setData( const HierarchyEntryData& rData, sal_Bool bCreate );
114 sal_Bool move( const ::rtl::OUString& rNewURL,
115 const HierarchyEntryData& rData );
117 sal_Bool remove();
119 // Iteration.
121 struct iterator_Impl;
123 class iterator
125 friend class HierarchyEntry;
127 iterator_Impl* m_pImpl;
129 public:
130 iterator();
131 ~iterator();
133 const HierarchyEntryData& operator*() const;
136 sal_Bool first( iterator& it );
137 sal_Bool next ( iterator& it );
140 } // namespace hierarchy_ucp
142 #endif /* !_HIERARCHYDATA_HXX */
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */