xref: /AOO41X/main/ucb/source/ucp/odma/odma_content.hxx (revision 6df1ea1f75e32b7bdb9b43f28f6c06e1fbd0c5ce)
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 ODMA_CONTENT_HXX
25 #define ODMA_CONTENT_HXX
26 
27 #include <list>
28 #include <ucbhelper/contenthelper.hxx>
29 
30 namespace com { namespace sun { namespace star {
31     namespace beans {
32         struct Property;
33         struct PropertyValue;
34     }
35     namespace sdbc {
36         class XRow;
37     }
38     namespace io {
39         class XInputStream;
40     }
41 }}}
42 namespace ucbhelper
43 {
44     class Content;
45 }
46 
47 
48 // @@@ Adjust namespace name.
49 namespace odma
50 {
51 
52 //=========================================================================
53 
54 // @@@ Adjust service name.
55 
56 // UNO service name for the content.
57 #define ODMA_CONTENT_SERVICE_NAME \
58                             "com.sun.star.ucb.OdmaContent"
59 
60 //=========================================================================
61 class ContentProvider;
62 class ContentProperties;
63 class Content : public ::ucbhelper::ContentImplHelper
64 {
65     ::rtl::Reference<ContentProperties> m_aProps;
66     ContentProvider*                    m_pProvider;
67     ::ucbhelper::Content*               m_pContent;
68 
69 private:
70     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
71     getProperties( const com::sun::star::uno::Reference<
72                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
73     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
74     getCommands( const com::sun::star::uno::Reference<
75                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
76     virtual ::rtl::OUString getParentURL();
77 
78     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
79     getPropertyValues( const ::com::sun::star::uno::Sequence<
80                         ::com::sun::star::beans::Property >& rProperties,
81                        const ::com::sun::star::uno::Reference<
82                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
83     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
84     setPropertyValues( const ::com::sun::star::uno::Sequence<
85                         ::com::sun::star::beans::PropertyValue >& rValues,
86                        const ::com::sun::star::uno::Reference<
87                         ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
88 
89     /** openDoc returns the file URL for the DOC ID
90         @return the url of the temporary file
91     */
92     ::rtl::OUString openDoc();
93 
94     /** changePropertyValue sets the property referenced by _sMemberValue to the new value
95         @param  _rValue         the new value to set
96         @param  _rnCurrentPos   the current position inside the Any sequence _rRet
97         @param  _sMemberValue   the place where to set the property
98         @param  _rnChanged      will be incremented when property changed
99         @param  _rRet           collect the exceptions
100         @param  _rChanges       contains the changes done
101     */
102     void changePropertyValue(const ::com::sun::star::beans::PropertyValue& _rValue,
103                              sal_Int32 _rnCurrentPos,
104                              ::rtl::OUString& _rsMemberValue,
105                              sal_Int32& _rnChanged,
106                              ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rRet,
107                              ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& _rChanges) throw (::com::sun::star::beans::IllegalTypeException);
108 
109 //    typedef rtl::Reference< Content > ContentRef;
110 //    typedef std::list< ContentRef > ContentRefList;
111 //    void queryChildren( ContentRefList& rChildren );
112 
113   // Command "insert"
114     void insert( const ::com::sun::star::uno::Reference<
115                     ::com::sun::star::io::XInputStream > & xInputStream,
116                  sal_Bool bReplaceExisting,
117                  const com::sun::star::uno::Reference<
118                     com::sun::star::ucb::XCommandEnvironment >& Environment )
119         throw( ::com::sun::star::uno::Exception );
120 
121 //  // Command "delete"
122 //  void destroy( sal_Bool bDeletePhysical )
123 //      throw( ::com::sun::star::uno::Exception );
124 
125 public:
126     Content( const ::com::sun::star::uno::Reference<
127                 ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
128                 ContentProvider* pProvider,
129              const ::com::sun::star::uno::Reference<
130                 ::com::sun::star::ucb::XContentIdentifier >& Identifier,
131                 const ::rtl::Reference<ContentProperties>& _rProps);
132     virtual ~Content();
133 
134     // XInterface
135     XINTERFACE_DECL()
136 
137     // XTypeProvider
138     XTYPEPROVIDER_DECL()
139 
140     // XServiceInfo
141     virtual ::rtl::OUString SAL_CALL
142     getImplementationName()
143         throw( ::com::sun::star::uno::RuntimeException );
144     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
145     getSupportedServiceNames()
146         throw( ::com::sun::star::uno::RuntimeException );
147 
148     // XContent
149     virtual rtl::OUString SAL_CALL
150     getContentType()
151         throw( com::sun::star::uno::RuntimeException );
152 
153     // XCommandProcessor
154     virtual com::sun::star::uno::Any SAL_CALL
155     execute( const com::sun::star::ucb::Command& aCommand,
156              sal_Int32 CommandId,
157              const com::sun::star::uno::Reference<
158                 com::sun::star::ucb::XCommandEnvironment >& Environment )
159         throw( com::sun::star::uno::Exception,
160                com::sun::star::ucb::CommandAbortedException,
161                com::sun::star::uno::RuntimeException );
162     virtual void SAL_CALL
163     abort( sal_Int32 CommandId )
164         throw( com::sun::star::uno::RuntimeException );
165 
166     //////////////////////////////////////////////////////////////////////
167     // Additional interfaces
168     //////////////////////////////////////////////////////////////////////
169 
170     // @@@ Add additional interfaces ( like com::sun:.star::ucb::XContentCreator ).
171 
172     //////////////////////////////////////////////////////////////////////
173     // Non-interface methods.
174     //////////////////////////////////////////////////////////////////////
175 
176     // Called from resultset data supplier.
177     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
178     getPropertyValues( const ::com::sun::star::uno::Reference<
179                         ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
180                        const ::com::sun::star::uno::Sequence<
181                         ::com::sun::star::beans::Property >& rProperties,
182                        const ::rtl::Reference<ContentProperties>& rData,
183                        const ::rtl::Reference<
184                         ::ucbhelper::ContentProviderImplHelper >&   rProvider,
185                        const ::rtl::OUString& rContentId );
186 
getContentProvider() const187     ContentProvider* getContentProvider() const { return m_pProvider; }
188 };
189 
190 }
191 
192 #endif
193