1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #ifndef SVX_SOURCE_FORM_XFM_ADDCONDITION_HXX
32 #include "xfm_addcondition.hxx"
33 #endif
34 
35 /** === begin UNO includes === **/
36 /** === end UNO includes === **/
37 #include <cppuhelper/typeprovider.hxx>
38 #include "datanavi.hxx"
39 #include <vcl/msgbox.hxx>
40 
41 //........................................................................
42 namespace svxform
43 {
44 //........................................................................
45 
46 #define PROPERTY_ID_BINDING             5724
47 #define PROPERTY_ID_FORM_MODEL          5725
48 #define PROPERTY_ID_FACET_NAME          5726
49 #define PROPERTY_ID_CONDITION_VALUE     5727
50 
51 	using namespace ::com::sun::star::uno;
52 	using namespace ::com::sun::star::lang;
53 	using namespace ::com::sun::star::beans;
54 	using namespace ::com::sun::star::xforms;
55 
56     //====================================================================
57 	//= OAddConditionDialog
58 	//====================================================================
59 	//--------------------------------------------------------------------
60     Reference< XInterface > SAL_CALL OAddConditionDialog_Create( const Reference< XMultiServiceFactory > & _rxORB )
61     {
62         return OAddConditionDialog::Create( _rxORB );
63     }
64 
65 	//--------------------------------------------------------------------
66     Sequence< ::rtl::OUString > SAL_CALL OAddConditionDialog_GetSupportedServiceNames()
67     {
68 	    ::comphelper::StringSequence aSupported( 1 );
69 	    aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xforms.ui.dialogs.AddCondition" ) );
70 	    return aSupported;
71     }
72 
73 	//--------------------------------------------------------------------
74     ::rtl::OUString SAL_CALL OAddConditionDialog_GetImplementationName()
75     {
76 	    return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.OAddConditionDialog" );
77     }
78 
79     //====================================================================
80 	//= OAddConditionDialog
81 	//====================================================================
82 	//--------------------------------------------------------------------
83     OAddConditionDialog::OAddConditionDialog( const Reference< XMultiServiceFactory >& _rxORB )
84 	    :OAddConditionDialogBase( _rxORB )
85     {
86 	    registerProperty(
87             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ),
88             PROPERTY_ID_BINDING,
89             PropertyAttribute::TRANSIENT,
90 		    &m_xBinding,
91             ::getCppuType( &m_xBinding )
92         );
93 
94 	    registerProperty(
95             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ),
96             PROPERTY_ID_FACET_NAME,
97             PropertyAttribute::TRANSIENT,
98 		    &m_sFacetName,
99             ::getCppuType( &m_sFacetName )
100         );
101 
102 	    registerProperty(
103             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ),
104             PROPERTY_ID_CONDITION_VALUE,
105             PropertyAttribute::TRANSIENT,
106 		    &m_sConditionValue,
107             ::getCppuType( &m_sConditionValue )
108         );
109 
110         registerProperty(
111             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ),
112             PROPERTY_ID_FORM_MODEL,
113             PropertyAttribute::TRANSIENT,
114 		    &m_xWorkModel,
115             ::getCppuType( &m_xWorkModel )
116         );
117     }
118 
119     //-------------------------------------------------------------------------
120     Sequence<sal_Int8> SAL_CALL OAddConditionDialog::getImplementationId(  ) throw(RuntimeException)
121     {
122         static ::cppu::OImplementationId * pId = 0;
123 	    if (! pId)
124 	    {
125             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
126 		    if (! pId)
127 		    {
128                 static ::cppu::OImplementationId aId;
129 			    pId = &aId;
130 		    }
131 	    }
132 	    return pId->getImplementationId();
133     }
134 
135     //-------------------------------------------------------------------------
136     Reference< XInterface > SAL_CALL OAddConditionDialog::Create( const Reference< XMultiServiceFactory >& _rxFactory )
137     {
138 	    return *( new OAddConditionDialog( _rxFactory ) );
139     }
140 
141     //-------------------------------------------------------------------------
142     ::rtl::OUString SAL_CALL OAddConditionDialog::getImplementationName() throw(RuntimeException)
143     {
144 	    return OAddConditionDialog_GetImplementationName();
145     }
146 
147     //-------------------------------------------------------------------------
148     Sequence< ::rtl::OUString > SAL_CALL OAddConditionDialog::getSupportedServiceNames() throw(RuntimeException)
149     {
150         return OAddConditionDialog_GetSupportedServiceNames();
151     }
152 
153     //-------------------------------------------------------------------------
154     Reference<XPropertySetInfo>  SAL_CALL OAddConditionDialog::getPropertySetInfo() throw(RuntimeException)
155     {
156 	    return createPropertySetInfo( getInfoHelper() );
157     }
158 
159     //-------------------------------------------------------------------------
160     ::cppu::IPropertyArrayHelper& OAddConditionDialog::getInfoHelper()
161     {
162 	    return *const_cast< OAddConditionDialog* >( this )->getArrayHelper();
163     }
164 
165     //------------------------------------------------------------------------------
166     ::cppu::IPropertyArrayHelper* OAddConditionDialog::createArrayHelper( ) const
167     {
168 	    Sequence< Property > aProperties;
169 	    describeProperties( aProperties );
170 	    return new ::cppu::OPropertyArrayHelper( aProperties );
171     }
172 
173     //------------------------------------------------------------------------------
174     Dialog*	OAddConditionDialog::createDialog(Window* _pParent)
175     {
176         if ( !m_xBinding.is() || !m_sFacetName.getLength() )
177             throw RuntimeException( ::rtl::OUString(), *this );
178 
179 		return new AddConditionDialog( _pParent, m_sFacetName, m_xBinding );
180     }
181 
182     //------------------------------------------------------------------------------
183     void OAddConditionDialog::executedDialog( sal_Int16 _nExecutionResult )
184     {
185         OAddConditionDialogBase::executedDialog( _nExecutionResult );
186         if ( _nExecutionResult == RET_OK )
187             m_sConditionValue = static_cast< AddConditionDialog* >( m_pDialog )->GetCondition();
188     }
189 
190 //........................................................................
191 } // namespace svxformv
192 //........................................................................
193 
194