xref: /aoo4110/main/ucb/source/ucp/gio/gio_content.hxx (revision b1cdbd2c)
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 #ifndef GIO_CONTENT_HXX
25 #define GIO_CONTENT_HXX
26 
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <com/sun/star/io/XOutputStream.hpp>
29 #include <com/sun/star/ucb/ContentCreationException.hpp>
30 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
31 #include <com/sun/star/ucb/TransferInfo.hpp>
32 #include <com/sun/star/ucb/XContentCreator.hpp>
33 #include <ucbhelper/contenthelper.hxx>
34 #include <gio/gio.h>
35 
36 #include <list>
37 
38 namespace com { namespace sun { namespace star {
39     namespace beans {
40         struct Property;
41         struct PropertyValue;
42     }
43     namespace sdbc {
44         class XRow;
45     }
46 }}}
47 namespace ucbhelper
48 {
49     class Content;
50 }
51 
52 
53 namespace gio
54 {
55 
56 #define GIO_CONTENT_SERVICE_NAME "com.sun.star.ucb.GIOContent"
57 
58 #define GIO_FILE_TYPE   "application/vnd.sun.staroffice.gio-file"
59 #define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder"
60 
61 com::sun::star::uno::Any convertToException(GError *pError,
62     const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext, bool bThrow=true);
63 
64 class ContentProvider;
65 class ContentProperties;
66 class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator
67 {
68 private:
69     ContentProvider  *m_pProvider;
70     GFile* mpFile;
71     GFileInfo *mpInfo;
72     bool mbTransient;
73 
74     GFileInfo *getGFileInfo(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv,
75         GError **ppError=NULL);
76     bool isFolder(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv);
77 
78     com::sun::star::uno::Any mapGIOError( GError *error );
79     com::sun::star::uno::Any getBadArgExcept();
80 
81     com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
82         getPropertyValues(
83             const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties,
84             const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv );
85 private:
86     typedef rtl::Reference< Content > ContentRef;
87     typedef std::list< ContentRef > ContentRefList;
88 
89     void queryChildren( ContentRefList& rChildren );
90 
91     bool doSetFileInfo ( GFileInfo *pNewInfo );
92 
93     com::sun::star::uno::Any open(const com::sun::star::ucb::OpenCommandArgument2 & rArg,
94         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
95             throw( com::sun::star::uno::Exception );
96 
97     void transfer( const com::sun::star::ucb::TransferInfo& rTransferInfo,
98         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
99             throw( com::sun::star::uno::Exception );
100 
101     void insert( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream > & xInputStream,
102         sal_Bool bReplaceExisting, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv )
103             throw( com::sun::star::uno::Exception );
104 
105     void destroy( sal_Bool bDeletePhysical ) throw( com::sun::star::uno::Exception );
106 
107     void copyData( com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xIn,
108         com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOut );
109 
110     com::sun::star::uno::Sequence< com::sun::star::uno::Any >
111         setPropertyValues( const com::sun::star::uno::Sequence<
112             com::sun::star::beans::PropertyValue >& rValues,
113             const com::sun::star::uno::Reference<
114             com::sun::star::ucb::XCommandEnvironment >& xEnv );
115 
116     sal_Bool feedSink( com::sun::star::uno::Reference< com::sun::star::uno::XInterface> aSink,
117         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv );
118 
119     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
120         createInputStream(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv )
121             throw( com::sun::star::uno::Exception );
122 
123     sal_Bool exchangeIdentity(const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >&  xNewId);
124 
125 public:
126     Content( const com::sun::star::uno::Reference<
127         com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider,
128         const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier)
129             throw ( com::sun::star::ucb::ContentCreationException );
130 
131     Content( const com::sun::star::uno::Reference<
132         com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider,
133         const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier,
134         sal_Bool bIsFolder)
135             throw ( com::sun::star::ucb::ContentCreationException );
136 
137     virtual ~Content();
138 
139     com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo(
140         GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr,
141         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
142         const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties);
143 
144     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
145         getProperties( const com::sun::star::uno::Reference<
146             com::sun::star::ucb::XCommandEnvironment > & xEnv );
147 
148     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
149         getCommands( const com::sun::star::uno::Reference<
150             com::sun::star::ucb::XCommandEnvironment > & xEnv );
151 
152     virtual ::rtl::OUString getParentURL();
153 
154     XINTERFACE_DECL()
155 
156     XTYPEPROVIDER_DECL()
157 
158     virtual ::rtl::OUString SAL_CALL
159     getImplementationName()
160             throw( com::sun::star::uno::RuntimeException );
161 
162     virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
163     getSupportedServiceNames()
164             throw( com::sun::star::uno::RuntimeException );
165 
166     virtual rtl::OUString SAL_CALL
167     getContentType()
168             throw( com::sun::star::uno::RuntimeException );
169 
170     virtual com::sun::star::uno::Any SAL_CALL
171         execute( const com::sun::star::ucb::Command& aCommand,
172         sal_Int32 CommandId,
173         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment )
174             throw( com::sun::star::uno::Exception, com::sun::star::ucb::CommandAbortedException, com::sun::star::uno::RuntimeException );
175 
176     virtual void SAL_CALL abort( sal_Int32 CommandId )
177             throw( com::sun::star::uno::RuntimeException );
178 
179     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
180         SAL_CALL queryCreatableContentsInfo()
181             throw( com::sun::star::uno::RuntimeException );
182     virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent >
183         SAL_CALL createNewContent( const com::sun::star::ucb::ContentInfo& Info )
184             throw( com::sun::star::uno::RuntimeException );
185 
186     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
187         queryCreatableContentsInfo(
188         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv)
189             throw( com::sun::star::uno::RuntimeException );
190 
191     GFile* getGFile();
192 };
193 
194 }
195 
196 #endif
197