Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _HIERARCHYDATA_HXX
21 : #define _HIERARCHYDATA_HXX
22 :
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>
27 :
28 : namespace com { namespace sun { namespace star {
29 : namespace container {
30 : class XHierarchicalNameAccess;
31 : }
32 : namespace util {
33 : class XOfficeInstallationDirectories;
34 : }
35 : } } }
36 :
37 : namespace hierarchy_ucp
38 : {
39 :
40 :
41 :
42 0 : class HierarchyEntryData
43 : {
44 : public:
45 : enum Type { NONE, LINK, FOLDER };
46 :
47 0 : HierarchyEntryData() : m_aType( NONE ) {}
48 0 : HierarchyEntryData( const Type & rType ) : m_aType( rType ) {}
49 :
50 0 : const OUString & getName() const { return m_aName; }
51 0 : void setName( const OUString & rName ) { m_aName = rName; }
52 :
53 0 : const OUString & getTitle() const { return m_aTitle; }
54 0 : void setTitle( const OUString & rTitle ) { m_aTitle = rTitle; }
55 :
56 0 : const OUString & getTargetURL() const { return m_aTargetURL; }
57 0 : void setTargetURL( const OUString & rURL ) { m_aTargetURL = rURL; }
58 :
59 0 : Type getType() const
60 0 : { return ( m_aType != NONE ) ? m_aType
61 0 : : m_aTargetURL.getLength()
62 : ? LINK
63 0 : : FOLDER; }
64 0 : void setType( const Type & rType ) { m_aType = rType; }
65 :
66 : private:
67 : OUString m_aName; // Name (language independent)
68 : OUString m_aTitle; // Title (language dependent)
69 : OUString m_aTargetURL; // Target URL ( links only )
70 : Type m_aType; // Type
71 : };
72 :
73 :
74 :
75 : class HierarchyContentProvider;
76 : class HierarchyUri;
77 :
78 0 : class HierarchyEntry
79 : {
80 : OUString m_aServiceSpecifier;
81 : OUString m_aName;
82 : 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#
95 :
96 : private:
97 : OUString createPathFromHierarchyURL( const HierarchyUri & rURI );
98 : ::com::sun::star::uno::Reference<
99 : ::com::sun::star::container::XHierarchicalNameAccess >
100 : getRootReadAccess();
101 :
102 : public:
103 : HierarchyEntry( const ::com::sun::star::uno::Reference<
104 : ::com::sun::star::uno::XComponentContext >& rxContext,
105 : HierarchyContentProvider* pProvider,
106 : const OUString& rURL );
107 :
108 : sal_Bool hasData();
109 :
110 : sal_Bool getData( HierarchyEntryData& rData );
111 :
112 : sal_Bool setData( const HierarchyEntryData& rData, sal_Bool bCreate );
113 :
114 : sal_Bool move( const OUString& rNewURL,
115 : const HierarchyEntryData& rData );
116 :
117 : sal_Bool remove();
118 :
119 : // Iteration.
120 :
121 : struct iterator_Impl;
122 :
123 : class iterator
124 : {
125 : friend class HierarchyEntry;
126 :
127 : iterator_Impl* m_pImpl;
128 :
129 : public:
130 : iterator();
131 : ~iterator();
132 :
133 : const HierarchyEntryData& operator*() const;
134 : };
135 :
136 : sal_Bool first( iterator& it );
137 : sal_Bool next ( iterator& it );
138 : };
139 :
140 : } // namespace hierarchy_ucp
141 :
142 : #endif /* !_HIERARCHYDATA_HXX */
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|