LibreOffice Module ucb (master)  1
hierarchycontent.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 #pragma once
21 
22 #include <vector>
23 #include <rtl/ref.hxx>
24 #include <com/sun/star/ucb/XContentCreator.hpp>
26 #include "hierarchydata.hxx"
27 #include "hierarchyprovider.hxx"
28 
29 namespace com::sun::star::beans {
30  struct Property;
31  struct PropertyValue;
32 }
33 
34 namespace com::sun::star::sdbc {
35  class XRow;
36 }
37 
38 namespace com::sun::star::ucb {
39  struct TransferInfo;
40 }
41 
42 namespace hierarchy_ucp
43 {
44 
45 
47 {
48 public:
50 
52  : m_aData( rType ),
54  ? OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
55  : OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
56 
58  : m_aData( rData ),
60  ? OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
61  : OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
62 
63  const OUString & getName() const { return m_aData.getName(); }
64  void setName( const OUString & rName ) { m_aData.setName( rName ); };
65 
66  const OUString & getTitle() const { return m_aData.getTitle(); }
67  void setTitle( const OUString & rTitle )
68  { m_aData.setTitle( rTitle ); };
69 
70  const OUString & getTargetURL() const
71  { return m_aData.getTargetURL(); }
72  void setTargetURL( const OUString & rURL )
73  { m_aData.setTargetURL( rURL ); };
74 
75  const OUString & getContentType() const { return m_aContentType; }
76 
77  bool getIsFolder() const
79 
80  bool getIsDocument() const { return !getIsFolder(); }
81 
82  css::uno::Sequence< css::ucb::ContentInfo >
84 
85  const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
86 
87 private:
89  OUString m_aContentType;
90 };
91 
92 
94 
96  public css::ucb::XContentCreator
97 {
99  enum ContentState { TRANSIENT, // created via CreateNewContent,
100  // but did not process "insert" yet
101  PERSISTENT, // processed "insert"
102  DEAD // processed "delete"
103  };
104 
111 
112 private:
114  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
115  HierarchyContentProvider* pProvider,
116  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
117  const HierarchyContentProperties& rProps );
119  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
120  HierarchyContentProvider* pProvider,
121  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
122  const css::ucb::ContentInfo& Info );
123 
124  virtual css::uno::Sequence< css::beans::Property >
125  getProperties( const css::uno::Reference<css::ucb::XCommandEnvironment > & xEnv ) override;
126  virtual css::uno::Sequence< css::ucb::CommandInfo >
127  getCommands( const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv ) override;
128  virtual OUString getParentURL() override;
129 
130  static bool hasData(
131  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
132  HierarchyContentProvider* pProvider,
133  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier );
134  bool hasData(
135  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier )
136  { return hasData( m_xContext, m_pProvider, Identifier ); }
137  static bool loadData(
138  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
139  HierarchyContentProvider* pProvider,
140  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
141  HierarchyContentProperties& rProps );
142  bool storeData();
143  void renameData( const css::uno::Reference< css::ucb::XContentIdentifier >& xOldId,
144  const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
145  bool removeData();
146 
147  void setKind( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier );
148 
149  bool isReadOnly();
150 
151  bool isFolder() const { return ( m_eKind > LINK ); }
152 
153  css::uno::Reference< css::ucb::XContentIdentifier >
154  makeNewIdentifier( const OUString& rTitle );
155 
157  typedef std::vector< HierarchyContentRef > HierarchyContentRefVector;
158  void queryChildren( HierarchyContentRefVector& rChildren );
159 
160  bool exchangeIdentity(
161  const css::uno::Reference< css::ucb::XContentIdentifier >& xNewId );
162 
163  css::uno::Reference< css::sdbc::XRow >
164  getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties );
166  css::uno::Sequence< css::uno::Any >
168  const css::uno::Sequence< css::beans::PropertyValue >& rValues,
169  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
170 
172  void insert( sal_Int32 nNameClashResolve,
173  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
174 
176  void destroy( bool bDeletePhysical,
177  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
178 
180  void transfer( const css::ucb::TransferInfo& rInfo,
181  const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
182 
183 public:
184  // Create existing content. Fail, if not already exists.
186  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
187  HierarchyContentProvider* pProvider,
188  const css::uno::Reference<
189  css::ucb::XContentIdentifier >& Identifier );
190 
191  // Create new content. Fail, if already exists.
193  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
194  HierarchyContentProvider* pProvider,
195  const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier,
196  const css::ucb::ContentInfo& Info );
197 
198  virtual ~HierarchyContent() override;
199 
200  // XInterface
201  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
202  virtual void SAL_CALL acquire()
203  noexcept override;
204  virtual void SAL_CALL release()
205  noexcept override;
206 
207  // XTypeProvider
208  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
209  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
210 
211  // XServiceInfo
212  virtual OUString SAL_CALL
213  getImplementationName() override;
214  virtual css::uno::Sequence< OUString > SAL_CALL
215  getSupportedServiceNames() override;
216 
217  // XContent
218  virtual OUString SAL_CALL
219  getContentType() override;
220  virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
221  getIdentifier() override;
222 
223  // XCommandProcessor
224  virtual css::uno::Any SAL_CALL
225  execute( const css::ucb::Command& aCommand,
226  sal_Int32 CommandId,
227  const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override;
228  virtual void SAL_CALL
229  abort( sal_Int32 CommandId ) override;
230 
231 
232  // Additional interfaces
233 
234 
235  // XContentCreator
236  virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL
237  queryCreatableContentsInfo() override;
238  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
239  createNewContent( const css::ucb::ContentInfo& Info ) override;
240 
241 
242  // Non-interface methods.
243 
244 
245  static css::uno::Reference< css::sdbc::XRow >
246  getPropertyValues( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
247  const css::uno::Sequence< css::beans::Property >& rProperties,
248  const HierarchyContentProperties& rData,
249  HierarchyContentProvider* pProvider,
250  const OUString& rContentId );
251 };
252 
253 } // namespace hierarchy_ucp
254 
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL abort(sal_Int32 CommandId) override
Type
void destroy(bool bDeletePhysical, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Sequence< css::uno::Any > setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &rValues, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
HierarchyContentProperties m_aProps
rtl::Reference< HierarchyContent > HierarchyContentRef
void queryChildren(HierarchyContentRefVector &rChildren)
void insert(sal_Int32 nNameClashResolve, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
bool getType(BSTR name, Type &type)
signed char sal_Int8
virtual void SAL_CALL acquire() noexcept override
std::vector< HierarchyContentRef > HierarchyContentRefVector
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier() override
HierarchyContentProperties(const HierarchyEntryData::Type &rType)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
#define HIERARCHY_LINK_CONTENT_TYPE
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createNewContent(const css::ucb::ContentInfo &Info) override
void transfer(const css::ucb::TransferInfo &rInfo, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
bool exchangeIdentity(const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
HierarchyContentProperties(const HierarchyEntryData &rData)
bool hasData(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
static bool loadData(const css::uno::Reference< css::uno::XComponentContext > &rxContext, HierarchyContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, HierarchyContentProperties &rProps)
const HierarchyEntryData & getHierarchyEntryData() const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
#define HIERARCHY_FOLDER_CONTENT_TYPE
virtual void SAL_CALL release() noexcept override
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties)
void setKind(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
void renameData(const css::uno::Reference< css::ucb::XContentIdentifier > &xOldId, const css::uno::Reference< css::ucb::XContentIdentifier > &xNewId)
void setTargetURL(const OUString &rURL)
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
const OUString & getName() const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString getParentURL() override
css::uno::Sequence< css::ucb::ContentInfo > getCreatableContentsInfo() const
HierarchyContent(const css::uno::Reference< css::uno::XComponentContext > &rxContext, HierarchyContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier, const HierarchyContentProperties &rProps)
virtual css::uno::Any SAL_CALL execute(const css::ucb::Command &aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment > &Environment) override
css::uno::Reference< css::ucb::XContentIdentifier > makeNewIdentifier(const OUString &rTitle)
virtual OUString SAL_CALL getContentType() override
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
virtual css::uno::Sequence< css::ucb::ContentInfo > SAL_CALL queryCreatableContentsInfo() override
virtual OUString SAL_CALL getImplementationName() override
static rtl::Reference< HierarchyContent > create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, HierarchyContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
HierarchyContentProvider * m_pProvider
void setTitle(const OUString &rTitle)
void setName(const OUString &rName)
static bool hasData(const css::uno::Reference< css::uno::XComponentContext > &rxContext, HierarchyContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
const OUString & getTargetURL() const
const OUString & getTitle() const