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