LibreOffice Module ucb (master)  1
hierarchydata.hxx
Go to the documentation of this file.
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 INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYDATA_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_HIERARCHY_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 #include <memory>
28 
29 namespace com { namespace sun { namespace star {
30  namespace container {
31  class XHierarchicalNameAccess;
32  }
33  namespace util {
34  class XOfficeInstallationDirectories;
35  }
36 } } }
37 
38 namespace hierarchy_ucp
39 {
40 
41 
43 {
44 public:
45  enum Type { NONE, LINK, FOLDER };
46 
48  explicit HierarchyEntryData( const Type & rType ) : m_aType( rType ) {}
49 
50  const OUString & getName() const { return m_aName; }
51  void setName( const OUString & rName ) { m_aName = rName; }
52 
53  const OUString & getTitle() const { return m_aTitle; }
54  void setTitle( const OUString & rTitle ) { m_aTitle = rTitle; }
55 
56  const OUString & getTargetURL() const { return m_aTargetURL; }
57  void setTargetURL( const OUString & rURL ) { m_aTargetURL = rURL; }
58 
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; }
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 
75 class HierarchyUri;
76 
78 {
80  OUString m_aName;
81  OUString m_aPath;
82  ::osl::Mutex m_aMutex;
83  css::uno::Reference< css::uno::XComponentContext > m_xContext;
84  css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider;
85  css::uno::Reference< css::container::XHierarchicalNameAccess >
87  css::uno::Reference< css::util::XOfficeInstallationDirectories >
90 
91 private:
92  static OUString createPathFromHierarchyURL( const HierarchyUri & rURI );
93  css::uno::Reference< css::container::XHierarchicalNameAccess >
95 
96 public:
97  HierarchyEntry( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
98  HierarchyContentProvider* pProvider,
99  const OUString& rURL );
100 
101  bool hasData();
102 
103  bool getData( HierarchyEntryData& rData );
104 
105  bool setData( const HierarchyEntryData& rData );
106 
107  bool move( const OUString& rNewURL,
108  const HierarchyEntryData& rData );
109 
110  bool remove();
111 
112  // Iteration.
113 
114  struct iterator_Impl;
115 
116  class iterator
117  {
118  friend class HierarchyEntry;
119 
120  std::unique_ptr<iterator_Impl> m_pImpl;
121 
122  public:
123  iterator();
124  ~iterator();
125 
126  const HierarchyEntryData& operator*() const;
127  };
128 
129  bool first( iterator const & it );
130  bool next ( iterator const & it );
131 };
132 
133 } // namespace hierarchy_ucp
134 
135 #endif // INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYDATA_HXX
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool setData(const HierarchyEntryData &rData)
bool next(iterator const &it)
void setType(const Type &rType)
bool first(iterator const &it)
css::uno::Reference< css::util::XOfficeInstallationDirectories > m_xOfficeInstDirs
const HierarchyEntryData & operator*() const
HierarchyEntry(const css::uno::Reference< css::uno::XComponentContext > &rxContext, HierarchyContentProvider *pProvider, const OUString &rURL)
bool getData(HierarchyEntryData &rData)
static OUString createPathFromHierarchyURL(const HierarchyUri &rURI)
css::uno::Reference< css::container::XHierarchicalNameAccess > m_xRootReadAccess
void setTargetURL(const OUString &rURL)
css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider
css::uno::Reference< css::container::XHierarchicalNameAccess > getRootReadAccess()
const OUString & getName() const
bool move(const OUString &rNewURL, const HierarchyEntryData &rData)
css::uno::Reference< css::uno::XComponentContext > m_xContext
std::unique_ptr< iterator_Impl > m_pImpl
void setTitle(const OUString &rTitle)
void setName(const OUString &rName)
HierarchyEntryData(const Type &rType)
const OUString & getTargetURL() const
const OUString & getTitle() const