xref: /aoo41x/main/ucb/source/ucp/gio/gio_content.hxx (revision 6df1ea1f)
1*6df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6df1ea1fSAndrew Rist  * distributed with this work for additional information
6*6df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*6df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6df1ea1fSAndrew Rist  *
11*6df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6df1ea1fSAndrew Rist  *
13*6df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
15*6df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*6df1ea1fSAndrew Rist  * specific language governing permissions and limitations
18*6df1ea1fSAndrew Rist  * under the License.
19*6df1ea1fSAndrew Rist  *
20*6df1ea1fSAndrew Rist  *************************************************************/
21*6df1ea1fSAndrew Rist 
22*6df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef GIO_CONTENT_HXX
25cdf0e10cSrcweir #define GIO_CONTENT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
28cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
29cdf0e10cSrcweir #include <com/sun/star/ucb/ContentCreationException.hpp>
30cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
31cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp>
32cdf0e10cSrcweir #include <com/sun/star/ucb/XContentCreator.hpp>
33cdf0e10cSrcweir #include <ucbhelper/contenthelper.hxx>
34cdf0e10cSrcweir #include <gio/gio.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <list>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace com { namespace sun { namespace star {
39cdf0e10cSrcweir     namespace beans {
40cdf0e10cSrcweir         struct Property;
41cdf0e10cSrcweir         struct PropertyValue;
42cdf0e10cSrcweir     }
43cdf0e10cSrcweir     namespace sdbc {
44cdf0e10cSrcweir         class XRow;
45cdf0e10cSrcweir     }
46cdf0e10cSrcweir }}}
47cdf0e10cSrcweir namespace ucbhelper
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     class Content;
50cdf0e10cSrcweir }
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace gio
54cdf0e10cSrcweir {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #define GIO_CONTENT_SERVICE_NAME "com.sun.star.ucb.GIOContent"
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #define GIO_FILE_TYPE   "application/vnd.sun.staroffice.gio-file"
59cdf0e10cSrcweir #define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder"
60cdf0e10cSrcweir 
61cdf0e10cSrcweir com::sun::star::uno::Any convertToException(GError *pError,
62cdf0e10cSrcweir     const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext, bool bThrow=true);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir class ContentProvider;
65cdf0e10cSrcweir class ContentProperties;
66cdf0e10cSrcweir class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator
67cdf0e10cSrcweir {
68cdf0e10cSrcweir private:
69cdf0e10cSrcweir     ContentProvider  *m_pProvider;
70cdf0e10cSrcweir     GFile* mpFile;
71cdf0e10cSrcweir     GFileInfo *mpInfo;
72cdf0e10cSrcweir     bool mbTransient;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     GFileInfo *getGFileInfo(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv,
75cdf0e10cSrcweir         GError **ppError=NULL);
76cdf0e10cSrcweir     bool isFolder(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     com::sun::star::uno::Any mapGIOError( GError *error );
79cdf0e10cSrcweir     com::sun::star::uno::Any getBadArgExcept();
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
82cdf0e10cSrcweir         getPropertyValues(
83cdf0e10cSrcweir             const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties,
84cdf0e10cSrcweir             const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv );
85cdf0e10cSrcweir private:
86cdf0e10cSrcweir     typedef rtl::Reference< Content > ContentRef;
87cdf0e10cSrcweir     typedef std::list< ContentRef > ContentRefList;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     void queryChildren( ContentRefList& rChildren );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     bool doSetFileInfo ( GFileInfo *pNewInfo );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     com::sun::star::uno::Any open(const com::sun::star::ucb::OpenCommandArgument2 & rArg,
94cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
95cdf0e10cSrcweir             throw( com::sun::star::uno::Exception );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     void transfer( const com::sun::star::ucb::TransferInfo& rTransferInfo,
98cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
99cdf0e10cSrcweir             throw( com::sun::star::uno::Exception );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     void insert( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream > & xInputStream,
102cdf0e10cSrcweir         sal_Bool bReplaceExisting, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv )
103cdf0e10cSrcweir             throw( com::sun::star::uno::Exception );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     void destroy( sal_Bool bDeletePhysical ) throw( com::sun::star::uno::Exception );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     void copyData( com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xIn,
108cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOut );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     com::sun::star::uno::Sequence< com::sun::star::uno::Any >
111cdf0e10cSrcweir         setPropertyValues( const com::sun::star::uno::Sequence<
112cdf0e10cSrcweir             com::sun::star::beans::PropertyValue >& rValues,
113cdf0e10cSrcweir             const com::sun::star::uno::Reference<
114cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment >& xEnv );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     sal_Bool feedSink( com::sun::star::uno::Reference< com::sun::star::uno::XInterface> aSink,
117cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
120cdf0e10cSrcweir         createInputStream(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv )
121cdf0e10cSrcweir             throw( com::sun::star::uno::Exception );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     sal_Bool exchangeIdentity(const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >&  xNewId);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir public:
126cdf0e10cSrcweir     Content( const com::sun::star::uno::Reference<
127cdf0e10cSrcweir         com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider,
128cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier)
129cdf0e10cSrcweir             throw ( com::sun::star::ucb::ContentCreationException );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     Content( const com::sun::star::uno::Reference<
132cdf0e10cSrcweir         com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider,
133cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier,
134cdf0e10cSrcweir         sal_Bool bIsFolder)
135cdf0e10cSrcweir             throw ( com::sun::star::ucb::ContentCreationException );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     virtual ~Content();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo(
140cdf0e10cSrcweir         GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr,
141cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
142cdf0e10cSrcweir         const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
145cdf0e10cSrcweir         getProperties( const com::sun::star::uno::Reference<
146cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment > & xEnv );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
149cdf0e10cSrcweir         getCommands( const com::sun::star::uno::Reference<
150cdf0e10cSrcweir             com::sun::star::ucb::XCommandEnvironment > & xEnv );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     virtual ::rtl::OUString getParentURL();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     XINTERFACE_DECL()
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     XTYPEPROVIDER_DECL()
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL
159cdf0e10cSrcweir     getImplementationName()
160cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
163cdf0e10cSrcweir     getSupportedServiceNames()
164cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL
167cdf0e10cSrcweir     getContentType()
168cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
171cdf0e10cSrcweir         execute( const com::sun::star::ucb::Command& aCommand,
172cdf0e10cSrcweir         sal_Int32 CommandId,
173cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment )
174cdf0e10cSrcweir             throw( com::sun::star::uno::Exception, com::sun::star::ucb::CommandAbortedException, com::sun::star::uno::RuntimeException );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     virtual void SAL_CALL abort( sal_Int32 CommandId )
177cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
180cdf0e10cSrcweir         SAL_CALL queryCreatableContentsInfo()
181cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
182cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent >
183cdf0e10cSrcweir         SAL_CALL createNewContent( const com::sun::star::ucb::ContentInfo& Info )
184cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
187cdf0e10cSrcweir         queryCreatableContentsInfo(
188cdf0e10cSrcweir         const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv)
189cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     GFile* getGFile();
192cdf0e10cSrcweir };
193cdf0e10cSrcweir 
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir #endif
197