xref: /trunk/main/ucb/source/ucp/ext/ucpext_content.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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(  );
100         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  );
101 
102         // XContent
103         virtual rtl::OUString SAL_CALL getContentType();
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 
113         virtual void SAL_CALL
114                 abort(
115                     sal_Int32 CommandId
116                 );
117 
118     private:
119         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 );
120         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 );
121 
122         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
123             setPropertyValues(
124                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues,
125                 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv
126             );
127 
128         static bool denotesRootContent( const ::rtl::OUString& i_rContentIdentifier );
129 
130         bool impl_isFolder();
131         void impl_determineContentType();
132 
133     private:
134         ExtensionContentType                    m_eExtContentType;
135         ::boost::optional< bool >               m_aIsFolder;
136         ::boost::optional< ::rtl::OUString >    m_aContentType;
137         ::rtl::OUString                         m_sExtensionId;
138         ::rtl::OUString                         m_sPathIntoExtension;
139     };
140 
141 //......................................................................................................................
142 } } }   // namespace ucb::ucp::ext
143 //......................................................................................................................
144 
145 #endif  // UCB_UCPEXT_CONTENT_HXX
146