1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: myucp_content.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // @@@ Adjust multi-include-protection-ifdef.
32 #ifndef _MYUCP_CONTENT_HXX
33 #define _MYUCP_CONTENT_HXX
37 #include "rtl/ref.hxx"
38 #include "ucbhelper/contenthelper.hxx"
40 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{
45 namespace com
{ namespace sun
{ namespace star
{ namespace sdbc
{
49 namespace com
{ namespace sun
{ namespace star
{ namespace io
{
53 // @@@ Adjust namespace name.
57 //=========================================================================
59 // @@@ Adjust service name.
61 // UNO service name for the content. Prefix with reversed company domain main.
62 #define MYUCP_CONTENT_SERVICE_NAME "com.sun.star.ucb.MyContent"
64 //=========================================================================
66 struct ContentProperties
68 ::rtl::OUString aTitle
; // Title
69 ::rtl::OUString aContentType
; // ContentType
70 sal_Bool bIsDocument
; // IsDocument
71 sal_Bool bIsFolder
; // IsFolder
73 // @@@ Add other properties supported by your content.
76 : bIsDocument( sal_True
), bIsFolder( sal_False
) {}
79 //=========================================================================
81 class Content
: public ::ucbhelper::ContentImplHelper
83 ContentProperties m_aProps
;
86 virtual com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>
87 getProperties( const com::sun::star::uno::Reference
<
88 com::sun::star::ucb::XCommandEnvironment
> & xEnv
);
89 virtual com::sun::star::uno::Sequence
< com::sun::star::ucb::CommandInfo
>
90 getCommands( const com::sun::star::uno::Reference
<
91 com::sun::star::ucb::XCommandEnvironment
> & xEnv
);
92 virtual ::rtl::OUString
getParentURL();
94 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>
95 getPropertyValues( const ::com::sun::star::uno::Sequence
<
96 ::com::sun::star::beans::Property
>& rProperties
,
97 const ::com::sun::star::uno::Reference
<
98 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
99 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>
100 setPropertyValues( const ::com::sun::star::uno::Sequence
<
101 ::com::sun::star::beans::PropertyValue
>& rValues
,
102 const ::com::sun::star::uno::Reference
<
103 ::com::sun::star::ucb::XCommandEnvironment
>& xEnv
);
105 #define IMPLEMENT_COMMAND_OPEN
106 #define IMPLEMENT_COMMAND_INSERT
107 #define IMPLEMENT_COMMAND_DELETE
109 #ifdef IMPLEMENT_COMMAND_INSERT
110 typedef rtl::Reference
< Content
> ContentRef
;
111 typedef std::list
< ContentRef
> ContentRefList
;
112 void queryChildren( ContentRefList
& rChildren
);
115 void insert( const ::com::sun::star::uno::Reference
<
116 ::com::sun::star::io::XInputStream
> & xInputStream
,
117 sal_Bool bReplaceExisting
,
118 const com::sun::star::uno::Reference
<
119 com::sun::star::ucb::XCommandEnvironment
>& Environment
)
120 throw( ::com::sun::star::uno::Exception
);
123 #ifdef IMPLEMENT_COMMAND_DELETE
126 void destroy( sal_Bool bDeletePhysical
)
127 throw( ::com::sun::star::uno::Exception
);
131 Content( const ::com::sun::star::uno::Reference
<
132 ::com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
133 ::ucbhelper::ContentProviderImplHelper
* pProvider
,
134 const ::com::sun::star::uno::Reference
<
135 ::com::sun::star::ucb::XContentIdentifier
>& Identifier
);
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
);
153 virtual rtl::OUString SAL_CALL
155 throw( com::sun::star::uno::RuntimeException
);
158 virtual com::sun::star::uno::Any SAL_CALL
159 execute( const com::sun::star::ucb::Command
& aCommand
,
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
);
170 //////////////////////////////////////////////////////////////////////
171 // Additional interfaces
172 //////////////////////////////////////////////////////////////////////
174 // @@@ Add additional interfaces ( like com::sun::star::ucb::XContentCreator ).
176 //////////////////////////////////////////////////////////////////////
177 // Non-interface methods.
178 //////////////////////////////////////////////////////////////////////
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 ContentProperties
& rData
,
187 const rtl::Reference
<
188 ::ucbhelper::ContentProviderImplHelper
>& rProvider
,
189 const ::rtl::OUString
& rContentId
);