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 OFFAPI_COM_SUN_STAR_XFORMS_DATATYPEREPOSITORY_HXX
25 #define OFFAPI_COM_SUN_STAR_XFORMS_DATATYPEREPOSITORY_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/xforms/XDataTypeRepository.hpp>
29 /** === end UNO includes === **/
30 #include <cppuhelper/implbase1.hxx>
31 #include <rtl/ref.hxx>
32 
33 #include <map>
34 
35 //........................................................................
36 namespace xforms
37 {
38 //........................................................................
39 
40     class OXSDDataType;
41 	//====================================================================
42 	//= ODataTypeRepository
43 	//====================================================================
44     typedef ::cppu::WeakImplHelper1 <   ::com::sun::star::xforms::XDataTypeRepository
45                                     >   ODataTypeRepository_Base;
46     class ODataTypeRepository : public ODataTypeRepository_Base
47 	{
48     private:
49         typedef ::rtl::Reference< OXSDDataType >            DataType;
50         typedef ::std::map< ::rtl::OUString, DataType >     Repository;
51 
52         ::osl::Mutex                                        m_aMutex;
53         Repository                                          m_aRepository;
54 
55     public:
56         ODataTypeRepository( );
57 
58     protected:
59         ~ODataTypeRepository( );
60 
61         // XDataTypeRepository
62         virtual ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType > SAL_CALL getBasicDataType( sal_Int16 dataTypeClass ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
63         virtual ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType > SAL_CALL cloneDataType( const ::rtl::OUString& sourceName, const ::rtl::OUString& newName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
64         virtual void SAL_CALL revokeDataType( const ::rtl::OUString& typeName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::util::VetoException, ::com::sun::star::uno::RuntimeException);
65         virtual ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType > SAL_CALL getDataType( const ::rtl::OUString& typeName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
66 
67         // XEnumerationAccess (base of XDataTypeRepository)
68         virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(  ) throw (::com::sun::star::uno::RuntimeException);
69 
70         // XNameAccess (base of XDataTypeRepository)
71         virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
72         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException);
73         virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
74 
75         // XElementAccess (base of XEnumerationAccess and XNameAccess)
76         virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
77         virtual sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
78 
79     private:
80         ODataTypeRepository( const ODataTypeRepository& );              // never implemented
81         ODataTypeRepository& operator=( const ODataTypeRepository& );   // never implemented
82 
83     private:
84         /** locates the type with the given name in our repository, or throws an exception if there is no such type
85         */
86         Repository::iterator    implLocate( const ::rtl::OUString& _rName, bool _bAllowMiss = false ) SAL_THROW( ( ::com::sun::star::container::NoSuchElementException ) );
87     };
88 
89 //........................................................................
90 } // namespace xforms
91 //........................................................................
92 
93 #endif // OFFAPI_COM_SUN_STAR_XFORMS_DATATYPEREPOSITORY_HXX
94 
95