| 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 |
#pragma once |
| 21 |
|
| 22 |
#include <rtl/ustring.hxx> |
| 23 |
#include <com/sun/star/lang/XMultiServiceFactory.hpp> |
| 24 |
#include <com/sun/star/uno/XComponentContext.hpp> |
| 25 |
#include <mutex> |
| 26 |
|
| 27 |
namespace com::sun::star { |
| 28 |
namespace container { |
| 29 |
class XHierarchicalNameAccess; |
| 30 |
} |
| 31 |
namespace util { |
| 32 |
class XOfficeInstallationDirectories; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
namespace hierarchy_ucp |
| 37 |
{ |
| 38 |
|
| 39 |
|
| 40 |
class HierarchyEntryData |
| 41 |
{ |
| 42 |
public: |
| 43 |
enum Type { NONE, LINK, FOLDER }; |
| 44 |
|
| 45 |
HierarchyEntryData() : m_aType( NONE ) {} |
| 46 |
explicit HierarchyEntryData( const Type & rType ) : m_aType( rType ) {} |
| 47 |
|
| 48 |
const OUString & getName() const { return m_aName; } |
| 49 |
void setName( const OUString & rName ) { m_aName = rName; } |
| 50 |
|
| 51 |
const OUString & getTitle() const { return m_aTitle; } |
| 52 |
void setTitle( const OUString & rTitle ) { m_aTitle = rTitle; } |
| 53 |
|
| 54 |
const OUString & getTargetURL() const { return m_aTargetURL; } |
| 55 |
void setTargetURL( const OUString & rURL ) { m_aTargetURL = rURL; } |
| 56 |
|
| 57 |
Type getType() const |
| 58 |
{ return ( m_aType != NONE ) ? m_aType |
| 59 |
: m_aTargetURL.getLength() |
| 60 |
? LINK |
| 61 |
: FOLDER; } |
| 62 |
void setType( const Type & rType ) { m_aType = rType; } |
| 63 |
|
| 64 |
private: |
| 65 |
OUString m_aName; // Name (language independent) |
| 66 |
OUString m_aTitle; // Title (language dependent) |
| 67 |
OUString m_aTargetURL; // Target URL ( links only ) |
| 68 |
Type m_aType; // Type |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
class HierarchyContentProvider; |
| 73 |
class HierarchyUri; |
| 74 |
|
| 75 |
class HierarchyEntry |
| 76 |
{ |
| 77 |
OUString m_aServiceSpecifier; |
| 78 |
OUString m_aName; |
| 79 |
OUString m_aPath; |
| 80 |
std::mutex m_aMutex; |
| 81 |
css::uno::Reference< css::uno::XComponentContext > m_xContext; |
| 82 |
css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider; |
| 83 |
css::uno::Reference< css::container::XHierarchicalNameAccess > |
| 84 |
m_xRootReadAccess; |
| 85 |
css::uno::Reference< css::util::XOfficeInstallationDirectories > |
| 86 |
m_xOfficeInstDirs; |
| 87 |
bool m_bTriedToGetRootReadAccess; |
| 88 |
|
| 89 |
private: |
| 90 |
static OUString createPathFromHierarchyURL( const HierarchyUri & rURI ); |
| 91 |
css::uno::Reference< css::container::XHierarchicalNameAccess > |
| 92 |
getRootReadAccess(); |
| 93 |
|
| 94 |
public: |
| 95 |
HierarchyEntry( css::uno::Reference< css::uno::XComponentContext > xContext, |
| 96 |
HierarchyContentProvider* pProvider, |
| 97 |
const OUString& rURL ); |
| 98 |
|
| 99 |
bool hasData(); |
| 100 |
|
| 101 |
bool getData( HierarchyEntryData& rData ); |
| 102 |
|
| 103 |
bool setData( const HierarchyEntryData& rData ); |
| 104 |
|
| 105 |
bool move( const OUString& rNewURL, |
| 106 |
const HierarchyEntryData& rData ); |
| 107 |
|
| 108 |
bool remove(); |
| 109 |
|
| 110 |
// Iteration. |
| 111 |
|
| 112 |
class iterator |
| 113 |
{ |
| 114 |
friend class HierarchyEntry; |
| 115 |
|
| 116 |
public: |
| 117 |
iterator() : pos( -1 /* before first */ ) {}; |
| 118 |
|
| 119 |
const HierarchyEntryData& operator*(); |
| 120 |
private: |
| 121 |
HierarchyEntryData entry; |
| 122 |
css::uno::Reference< css::container::XHierarchicalNameAccess > dir; |
| 123 |
css::uno::Reference< css::util::XOfficeInstallationDirectories > officeDirs; |
| 124 |
css::uno::Sequence< OUString> names; |
| 125 |
sal_Int32 pos; |
| 126 |
}; |
| 127 |
|
| 128 |
bool first( iterator& it ); |
| 129 |
bool next ( iterator& it ); |
| 130 |
}; |
| 131 |
|
| 132 |
} // namespace hierarchy_ucp |
| 133 |
|
| 134 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |