xref: /trunk/main/ucbhelper/workben/myucp/myucp_content.hxx (revision 9d37da743abb7db0a497688391f6e55a19f27c44)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // @@@ Adjust multi-include-protection-ifdef.
25 #ifndef _MYUCP_CONTENT_HXX
26 #define _MYUCP_CONTENT_HXX
27 
28 #include <list>
29 
30 #include "rtl/ref.hxx"
31 #include "ucbhelper/contenthelper.hxx"
32 
33 namespace com { namespace sun { namespace star { namespace beans {
34     struct Property;
35     struct PropertyValue;
36 } } } }
37 
38 namespace com { namespace sun { namespace star { namespace sdbc {
39     class XRow;
40 } } } }
41 
42 namespace com { namespace sun { namespace star { namespace io {
43     class XInputStream;
44 } } } }
45 
46 // @@@ Adjust namespace name.
47 namespace myucp
48 {
49 
50 //=========================================================================
51 
52 // @@@ Adjust service name.
53 
54 // UNO service name for the content. Prefix with reversed company domain main.
55 #define MYUCP_CONTENT_SERVICE_NAME "com.sun.star.ucb.MyContent"
56 
57 //=========================================================================
58 
59 struct ContentProperties
60 {
61     ::rtl::OUString aTitle;         // Title
62     ::rtl::OUString aContentType;   // ContentType
63     sal_Bool        bIsDocument;    // IsDocument
64     sal_Bool        bIsFolder;      // IsFolder
65 
66     // @@@ Add other properties supported by your content.
67 
68     ContentProperties()
69     : bIsDocument( sal_True ), bIsFolder( sal_False ) {}
70 };
71 
72 //=========================================================================
73 
74 class Content : public ::ucbhelper::ContentImplHelper
75 {
76     ContentProperties m_aProps;
77 
78 private:
79     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
80     getProperties( const com::sun::star::uno::Reference<
81                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
82     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
83     getCommands( const com::sun::star::uno::Reference<
84                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
85     virtual ::rtl::OUString getParentURL();
86 
87     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
88     getPropertyValues( const ::com::sun::star::uno::Sequence<
89                         ::com::sun::star::beans::Property >& rProperties,
90                        const ::com::sun::star::uno::Reference<
91                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
92     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
93     setPropertyValues( const ::com::sun::star::uno::Sequence<
94                         ::com::sun::star::beans::PropertyValue >& rValues,
95                        const ::com::sun::star::uno::Reference<
96                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
97 
98 #define IMPLEMENT_COMMAND_OPEN
99 #define IMPLEMENT_COMMAND_INSERT
100 #define IMPLEMENT_COMMAND_DELETE
101 
102 #ifdef IMPLEMENT_COMMAND_INSERT
103     typedef rtl::Reference< Content > ContentRef;
104     typedef std::list< ContentRef > ContentRefList;
105     void queryChildren( ContentRefList& rChildren );
106 
107     // Command "insert"
108     void insert( const ::com::sun::star::uno::Reference<
109                  ::com::sun::star::io::XInputStream > & xInputStream,
110                  sal_Bool bReplaceExisting,
111                  const com::sun::star::uno::Reference<
112                  com::sun::star::ucb::XCommandEnvironment >& Environment );
113 #endif
114 
115 #ifdef IMPLEMENT_COMMAND_DELETE
116 
117     // Command "delete"
118     void destroy( sal_Bool bDeletePhysical );
119 #endif
120 
121 public:
122     Content( const ::com::sun::star::uno::Reference<
123                 ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
124              ::ucbhelper::ContentProviderImplHelper* pProvider,
125              const ::com::sun::star::uno::Reference<
126                 ::com::sun::star::ucb::XContentIdentifier >& Identifier );
127     virtual ~Content();
128 
129     // XInterface
130     XINTERFACE_DECL()
131 
132     // XTypeProvider
133     XTYPEPROVIDER_DECL()
134 
135     // XServiceInfo
136     virtual ::rtl::OUString SAL_CALL
137     getImplementationName();
138     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
139     getSupportedServiceNames();
140 
141     // XContent
142     virtual rtl::OUString SAL_CALL
143     getContentType();
144 
145     // XCommandProcessor
146     virtual com::sun::star::uno::Any SAL_CALL
147     execute( const com::sun::star::ucb::Command& aCommand,
148              sal_Int32 CommandId,
149              const com::sun::star::uno::Reference<
150                 com::sun::star::ucb::XCommandEnvironment >& Environment );
151     virtual void SAL_CALL
152     abort( sal_Int32 CommandId );
153 
154     //////////////////////////////////////////////////////////////////////
155     // Additional interfaces
156     //////////////////////////////////////////////////////////////////////
157 
158     // @@@ Add additional interfaces ( like com::sun::star::ucb::XContentCreator ).
159 
160     //////////////////////////////////////////////////////////////////////
161     // Non-interface methods.
162     //////////////////////////////////////////////////////////////////////
163 
164     // Called from resultset data supplier.
165     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
166     getPropertyValues( const ::com::sun::star::uno::Reference<
167                         ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
168                        const ::com::sun::star::uno::Sequence<
169                         ::com::sun::star::beans::Property >& rProperties,
170                        const ContentProperties& rData,
171                        const rtl::Reference<
172                         ::ucbhelper::ContentProviderImplHelper >& rProvider,
173                        const ::rtl::OUString& rContentId );
174 };
175 
176 }
177 
178 #endif
179