xref: /trunk/main/oox/inc/oox/xls/biffdetector.hxx (revision e3508121)
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 OOX_XLS_BIFFDETECTOR_HXX
25 #define OOX_XLS_BIFFDETECTOR_HXX
26 
27 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <cppuhelper/implbase2.hxx>
30 #include "oox/helper/storagebase.hxx"
31 #include "oox/xls/biffhelper.hxx"
32 
33 namespace com { namespace sun { namespace star {
34     namespace beans { struct PropertyValue; }
35     namespace uno { class XComponentContext; }
36 } } }
37 
38 namespace oox { class BinaryInputStream; }
39 
40 namespace oox {
41 namespace xls {
42 
43 // ============================================================================
44 
45 /** Detection service for BIFF streams or storages. */
46 class BiffDetector : public ::cppu::WeakImplHelper2<
47             ::com::sun::star::lang::XServiceInfo,
48             ::com::sun::star::document::XExtendedFilterDetection >
49 {
50 public:
51     explicit            BiffDetector(
52                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext )
53                             throw( ::com::sun::star::uno::RuntimeException );
54 
55     virtual             ~BiffDetector();
56 
57     /** Detects the BIFF version of the passed stream. */
58     static BiffType     detectStreamBiffVersion( BinaryInputStream& rInStream );
59 
60     /** Detects the BIFF version and workbook stream name of the passed storage. */
61     static BiffType     detectStorageBiffVersion(
62                             ::rtl::OUString& orWorkbookStreamName,
63                             const StorageRef& rxStorage );
64 
65     // com.sun.star.lang.XServiceInfo interface -------------------------------
66 
67     virtual ::rtl::OUString SAL_CALL
68                         getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
69 
70     virtual sal_Bool SAL_CALL
71                         supportsService( const ::rtl::OUString& rService )
72                             throw( ::com::sun::star::uno::RuntimeException );
73 
74     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
75                         getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
76 
77     // com.sun.star.document.XExtendedFilterDetect interface ------------------
78 
79     virtual ::rtl::OUString SAL_CALL
80                         detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& orDescriptor )
81                             throw( ::com::sun::star::uno::RuntimeException );
82 
83 private:
84     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
85                         mxContext;
86 };
87 
88 // ============================================================================
89 
90 } // namespace xls
91 } // namespace oox
92 
93 #endif
94