xref: /aoo41x/main/ucb/source/ucp/odma/odma_content.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ODMA_CONTENT_HXX
29 #define ODMA_CONTENT_HXX
30 
31 #include <list>
32 #include <ucbhelper/contenthelper.hxx>
33 
34 namespace com { namespace sun { namespace star {
35 	namespace beans {
36 		struct Property;
37 		struct PropertyValue;
38 	}
39 	namespace sdbc {
40 		class XRow;
41 	}
42 	namespace io {
43 		class XInputStream;
44 	}
45 }}}
46 namespace ucbhelper
47 {
48 	class Content;
49 }
50 
51 
52 // @@@ Adjust namespace name.
53 namespace odma
54 {
55 
56 //=========================================================================
57 
58 // @@@ Adjust service name.
59 
60 // UNO service name for the content.
61 #define ODMA_CONTENT_SERVICE_NAME \
62 							"com.sun.star.ucb.OdmaContent"
63 
64 //=========================================================================
65 class ContentProvider;
66 class ContentProperties;
67 class Content : public ::ucbhelper::ContentImplHelper
68 {
69 	::rtl::Reference<ContentProperties>	m_aProps;
70 	ContentProvider*				    m_pProvider;
71 	::ucbhelper::Content*				m_pContent;
72 
73 private:
74 	virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
75 	getProperties( const com::sun::star::uno::Reference<
76 					com::sun::star::ucb::XCommandEnvironment > & xEnv );
77 	virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
78 	getCommands( const com::sun::star::uno::Reference<
79 					com::sun::star::ucb::XCommandEnvironment > & xEnv );
80     virtual ::rtl::OUString getParentURL();
81 
82 	::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
83 	getPropertyValues( const ::com::sun::star::uno::Sequence<
84                         ::com::sun::star::beans::Property >& rProperties,
85                        const ::com::sun::star::uno::Reference<
86 						::com::sun::star::ucb::XCommandEnvironment >& xEnv );
87     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
88     setPropertyValues( const ::com::sun::star::uno::Sequence<
89                         ::com::sun::star::beans::PropertyValue >& rValues,
90                        const ::com::sun::star::uno::Reference<
91                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
92 
93 	/** openDoc returns the file URL for the DOC ID
94 		@return the url of the temporary file
95 	*/
96 	::rtl::OUString openDoc();
97 
98 	/** changePropertyValue sets the property referenced by _sMemberValue to the new value
99 		@param	_rValue			the new value to set
100 		@param	_rnCurrentPos	the current position inside the Any sequence _rRet
101 		@param	_sMemberValue	the place where to set the property
102 		@param	_rnChanged		will be incremented when property changed
103 		@param	_rRet			collect the exceptions
104 		@param	_rChanges		contains the changes done
105 	*/
106 	void changePropertyValue(const ::com::sun::star::beans::PropertyValue& _rValue,
107 							 sal_Int32 _rnCurrentPos,
108 							 ::rtl::OUString& _rsMemberValue,
109 							 sal_Int32& _rnChanged,
110 							 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rRet,
111 							 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& _rChanges) throw (::com::sun::star::beans::IllegalTypeException);
112 
113 //    typedef rtl::Reference< Content > ContentRef;
114 //    typedef std::list< ContentRef > ContentRefList;
115 //    void queryChildren( ContentRefList& rChildren );
116 
117   // Command "insert"
118     void insert( const ::com::sun::star::uno::Reference<
119                     ::com::sun::star::io::XInputStream > & xInputStream,
120                  sal_Bool bReplaceExisting,
121                  const com::sun::star::uno::Reference<
122                     com::sun::star::ucb::XCommandEnvironment >& Environment )
123         throw( ::com::sun::star::uno::Exception );
124 
125 //  // Command "delete"
126 //	void destroy( sal_Bool bDeletePhysical )
127 //      throw( ::com::sun::star::uno::Exception );
128 
129 public:
130 	Content( const ::com::sun::star::uno::Reference<
131 				::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
132 				ContentProvider* pProvider,
133 			 const ::com::sun::star::uno::Reference<
134 				::com::sun::star::ucb::XContentIdentifier >& Identifier,
135 				const ::rtl::Reference<ContentProperties>& _rProps);
136 	virtual ~Content();
137 
138 	// XInterface
139 	XINTERFACE_DECL()
140 
141 	// XTypeProvider
142 	XTYPEPROVIDER_DECL()
143 
144     // XServiceInfo
145     virtual ::rtl::OUString SAL_CALL
146 	getImplementationName()
147 		throw( ::com::sun::star::uno::RuntimeException );
148     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
149 	getSupportedServiceNames()
150 		throw( ::com::sun::star::uno::RuntimeException );
151 
152 	// XContent
153     virtual rtl::OUString SAL_CALL
154 	getContentType()
155 		throw( com::sun::star::uno::RuntimeException );
156 
157 	// XCommandProcessor
158     virtual com::sun::star::uno::Any SAL_CALL
159 	execute( const com::sun::star::ucb::Command& aCommand,
160 			 sal_Int32 CommandId,
161 			 const com::sun::star::uno::Reference<
162 			 	com::sun::star::ucb::XCommandEnvironment >& Environment )
163     	throw( com::sun::star::uno::Exception,
164 			   com::sun::star::ucb::CommandAbortedException,
165 			   com::sun::star::uno::RuntimeException );
166     virtual void SAL_CALL
167 	abort( sal_Int32 CommandId )
168 		throw( com::sun::star::uno::RuntimeException );
169 
170 	//////////////////////////////////////////////////////////////////////
171 	// Additional interfaces
172 	//////////////////////////////////////////////////////////////////////
173 
174 	// @@@ Add additional interfaces ( like com::sun:.star::ucb::XContentCreator ).
175 
176 	//////////////////////////////////////////////////////////////////////
177 	// Non-interface methods.
178 	//////////////////////////////////////////////////////////////////////
179 
180 	// Called from resultset data supplier.
181 	static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
182 	getPropertyValues( const ::com::sun::star::uno::Reference<
183 						::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
184 					   const ::com::sun::star::uno::Sequence<
185 					   	::com::sun::star::beans::Property >& rProperties,
186 					   const ::rtl::Reference<ContentProperties>& rData,
187                        const ::rtl::Reference<
188 					   	::ucbhelper::ContentProviderImplHelper >&	rProvider,
189                        const ::rtl::OUString& rContentId );
190 
191 	ContentProvider* getContentProvider() const { return m_pProvider; }
192 };
193 
194 }
195 
196 #endif
197