xref: /trunk/main/ucb/source/ucp/ext/ucpext_content.hxx (revision 6df1ea1f)
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 UCB_UCPEXT_CONTENT_HXX
25 #define UCB_UCPEXT_CONTENT_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/sdbc/XRow.hpp>
29 #include <com/sun/star/beans/PropertyValue.hpp>
30 /** === end UNO includes === **/
31 
32 #include <rtl/ref.hxx>
33 #include <ucbhelper/contenthelper.hxx>
34 
35 #include <list>
36 #include <boost/optional.hpp>
37 
38 //......................................................................................................................
39 namespace ucb { namespace ucp { namespace ext
40 {
41 //......................................................................................................................
42 
43     //==================================================================================================================
44     //= ExtensionContentType
45     //==================================================================================================================
46     enum ExtensionContentType
47     {
48         E_ROOT,
49         E_EXTENSION_ROOT,
50         E_EXTENSION_CONTENT,
51 
52         E_UNKNOWN
53     };
54 
55     //==================================================================================================================
56     //= ContentProvider
57     //==================================================================================================================
58     typedef ::ucbhelper::ContentImplHelper  Content_Base;
59     class Content : public Content_Base
60     {
61     public:
62 	    Content(
63             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
64             ::ucbhelper::ContentProviderImplHelper* pProvider,
65             const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier
66         );
67 
68 	    static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
69 	        getArtificialNodePropertyValues(
70                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
71                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties,
72                 const ::rtl::OUString& rTitle
73             );
74 
75 	    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
76             getPropertyValues(
77                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties,
78                 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv
79             );
80 
81         static ::rtl::OUString
82             encodeIdentifier( const ::rtl::OUString& i_rIdentifier );
83         static ::rtl::OUString
84             decodeIdentifier( const ::rtl::OUString& i_rIdentifier );
85 
86         virtual ::rtl::OUString getParentURL();
87 
getExtensionContentType() const88         ExtensionContentType getExtensionContentType() const { return m_eExtContentType; }
89 
90         /** retrieves the URL of the underlying physical content. Not to be called when getExtensionContentType()
91             returns E_ROOT.
92         */
93         ::rtl::OUString getPhysicalURL() const;
94 
95     protected:
96 	    virtual ~Content();
97 
98         // XServiceInfo
99         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
100         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
101 
102 	    // XContent
103         virtual rtl::OUString SAL_CALL getContentType() throw( com::sun::star::uno::RuntimeException );
104 
105 	    // XCommandProcessor
106         virtual com::sun::star::uno::Any SAL_CALL
107                 execute(
108                     const com::sun::star::ucb::Command& aCommand,
109 			        sal_Int32 CommandId,
110 			        const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment
111                 )
112                 throw   (   ::com::sun::star::uno::Exception
113                         ,   ::com::sun::star::ucb::CommandAbortedException
114                         ,   ::com::sun::star::uno::RuntimeException
115                         );
116 
117         virtual void SAL_CALL
118                 abort(
119                     sal_Int32 CommandId
120                 )
121                 throw   (   ::com::sun::star::uno::RuntimeException
122                         );
123 
124     private:
125 	    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > getProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& i_rEnv );
126         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::CommandInfo > getCommands( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& i_rEnv );
127 
128         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
129             setPropertyValues(
130                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues,
131                 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv
132             );
133 
134         static bool denotesRootContent( const ::rtl::OUString& i_rContentIdentifier );
135 
136         bool impl_isFolder();
137         void impl_determineContentType();
138 
139     private:
140         ExtensionContentType                    m_eExtContentType;
141         ::boost::optional< bool >               m_aIsFolder;
142         ::boost::optional< ::rtl::OUString >    m_aContentType;
143         ::rtl::OUString                         m_sExtensionId;
144         ::rtl::OUString                         m_sPathIntoExtension;
145     };
146 
147 //......................................................................................................................
148 } } }   // namespace ucb::ucp::ext
149 //......................................................................................................................
150 
151 #endif  // UCB_UCPEXT_CONTENT_HXX
152