1*46dbaceeSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*46dbaceeSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*46dbaceeSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*46dbaceeSAndrew Rist  * distributed with this work for additional information
6*46dbaceeSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*46dbaceeSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*46dbaceeSAndrew Rist  * "License"); you may not use this file except in compliance
9*46dbaceeSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*46dbaceeSAndrew Rist  *
11*46dbaceeSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*46dbaceeSAndrew Rist  *
13*46dbaceeSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*46dbaceeSAndrew Rist  * software distributed under the License is distributed on an
15*46dbaceeSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*46dbaceeSAndrew Rist  * KIND, either express or implied.  See the License for the
17*46dbaceeSAndrew Rist  * specific language governing permissions and limitations
18*46dbaceeSAndrew Rist  * under the License.
19*46dbaceeSAndrew Rist  *
20*46dbaceeSAndrew Rist  *************************************************************/
21*46dbaceeSAndrew Rist 
22*46dbaceeSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
25cdf0e10cSrcweir #define EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "eformshelper.hxx"
28cdf0e10cSrcweir #include "xsddatatypes.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir /** === begin UNO includes === **/
31cdf0e10cSrcweir #include <com/sun/star/xsd/XDataType.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir /** === end UNO includes === **/
34cdf0e10cSrcweir #include <rtl/ref.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //........................................................................
37cdf0e10cSrcweir namespace pcr
38cdf0e10cSrcweir {
39cdf0e10cSrcweir //........................................................................
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     class XSDDataType;
42cdf0e10cSrcweir 	//====================================================================
43cdf0e10cSrcweir 	//= XSDValidationHelper
44cdf0e10cSrcweir 	//====================================================================
45cdf0e10cSrcweir     class XSDValidationHelper : public EFormsHelper
46cdf0e10cSrcweir 	{
47cdf0e10cSrcweir     private:
48cdf0e10cSrcweir         bool    m_bInspectingFormattedField;
49cdf0e10cSrcweir     public:
isInspectingFormattedField() const50cdf0e10cSrcweir         bool    isInspectingFormattedField() const { return m_bInspectingFormattedField; }
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     public:
53cdf0e10cSrcweir         XSDValidationHelper(
54cdf0e10cSrcweir             ::osl::Mutex& _rMutex,
55cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxIntrospectee,
56cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
57cdf0e10cSrcweir         );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir         /** retrieves the names of all XForms models in the document the control lives in
60cdf0e10cSrcweir         */
61cdf0e10cSrcweir         void    getAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(());
62cdf0e10cSrcweir 
63cdf0e10cSrcweir         /** retrieves a particular data type given by name
64cdf0e10cSrcweir         */
65cdf0e10cSrcweir         ::rtl::Reference< XSDDataType >
66cdf0e10cSrcweir                 getDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(());
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         /** retrieves the DataType instance which the control model is currently validated against
69cdf0e10cSrcweir 
70cdf0e10cSrcweir             If there is a binding set at our control model, which at the same time acts as validator,
71cdf0e10cSrcweir             and if this validator is bound to an XDataType, then this data type is retrieved here.
72cdf0e10cSrcweir         */
73cdf0e10cSrcweir         ::rtl::Reference< XSDDataType >
74cdf0e10cSrcweir                 getValidatingDataType( ) const SAL_THROW(());
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         /** retrieves the name of the data type which the control model is currently validated against
77cdf0e10cSrcweir 
78cdf0e10cSrcweir             @seealso getValidatingDataType
79cdf0e10cSrcweir         */
80cdf0e10cSrcweir         ::rtl::OUString
81cdf0e10cSrcweir                 getValidatingDataTypeName( ) const SAL_THROW(());
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         /** binds the validator to a new data type
84cdf0e10cSrcweir 
85cdf0e10cSrcweir             To be called with an active binding only.
86cdf0e10cSrcweir         */
87cdf0e10cSrcweir         void    setValidatingDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(());
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         /** removes the data type given by name from the data type repository
90cdf0e10cSrcweir         */
91cdf0e10cSrcweir         bool    removeDataTypeFromRepository( const ::rtl::OUString& _rName ) const SAL_THROW(());
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         /** creates a new data type, which is a clone of an existing data type
94cdf0e10cSrcweir         */
95cdf0e10cSrcweir         bool    cloneDataType( const ::rtl::Reference< XSDDataType >& _pDataType, const ::rtl::OUString& _rNewName ) const SAL_THROW(());
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         /** retrieves the name of the basic data type which has the given class
98cdf0e10cSrcweir         */
99cdf0e10cSrcweir         ::rtl::OUString
100cdf0e10cSrcweir                 getBasicTypeNameForClass( sal_Int16 _eClass ) const SAL_THROW(());
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         /** copy a data type from one model to another
103cdf0e10cSrcweir 
104cdf0e10cSrcweir             If a data type with the given name already exists in the target model, then nothing
105cdf0e10cSrcweir             happens. In particular, the facets of the data type are not copied.
106cdf0e10cSrcweir         */
107cdf0e10cSrcweir         void    copyDataType( const ::rtl::OUString& _rFromModel, const ::rtl::OUString& _rToModel,
108cdf0e10cSrcweir                     const ::rtl::OUString& _rDataTypeName ) const SAL_THROW(());
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         /** finds (and sets) a default format for the formatted field we're inspecting,
111cdf0e10cSrcweir             according to the current data type the control value is evaluated against
112cdf0e10cSrcweir         */
113cdf0e10cSrcweir         void findDefaultFormatForIntrospectee() SAL_THROW(());
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     private:
116cdf0e10cSrcweir         /** retrieves the data type repository associated with the current model
117cdf0e10cSrcweir         */
118cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository >
119cdf0e10cSrcweir                 getDataTypeRepository() const SAL_THROW((::com::sun::star::uno::Exception));
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         /** retrieves the data type repository associated with any model
122cdf0e10cSrcweir         */
123cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository >
124cdf0e10cSrcweir                 getDataTypeRepository( const ::rtl::OUString& _rModelName ) const SAL_THROW((::com::sun::star::uno::Exception));
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         /** retrieves the data type object for the given name
127cdf0e10cSrcweir         */
128cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >
129cdf0e10cSrcweir             getDataType( const ::rtl::OUString& _rName ) const
130cdf0e10cSrcweir                 SAL_THROW((::com::sun::star::uno::Exception));
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         /** retrieves the name of the basic data type which has the given class, in the given repository
133cdf0e10cSrcweir         */
134cdf0e10cSrcweir         ::rtl::OUString
135cdf0e10cSrcweir                 getBasicTypeNameForClass(
136cdf0e10cSrcweir                     sal_Int16 _nClass,
137cdf0e10cSrcweir                     ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository > _rxRepository
138cdf0e10cSrcweir                 ) const SAL_THROW(());
139cdf0e10cSrcweir 	};
140cdf0e10cSrcweir 
141cdf0e10cSrcweir //........................................................................
142cdf0e10cSrcweir } // namespace pcr
143cdf0e10cSrcweir //........................................................................
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
146cdf0e10cSrcweir 
147