xref: /AOO41X/main/svx/source/form/xfm_addcondition.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #ifndef SVX_SOURCE_FORM_XFM_ADDCONDITION_HXX
28 #include "xfm_addcondition.hxx"
29 #endif
30 
31 /** === begin UNO includes === **/
32 /** === end UNO includes === **/
33 #include <cppuhelper/typeprovider.hxx>
34 #include "datanavi.hxx"
35 #include <vcl/msgbox.hxx>
36 
37 //........................................................................
38 namespace svxform
39 {
40 //........................................................................
41 
42 #define PROPERTY_ID_BINDING             5724
43 #define PROPERTY_ID_FORM_MODEL          5725
44 #define PROPERTY_ID_FACET_NAME          5726
45 #define PROPERTY_ID_CONDITION_VALUE     5727
46 
47     using namespace ::com::sun::star::uno;
48     using namespace ::com::sun::star::lang;
49     using namespace ::com::sun::star::beans;
50     using namespace ::com::sun::star::xforms;
51 
52     //====================================================================
53     //= OAddConditionDialog
54     //====================================================================
55     //--------------------------------------------------------------------
OAddConditionDialog_Create(const Reference<XMultiServiceFactory> & _rxORB)56     Reference< XInterface > SAL_CALL OAddConditionDialog_Create( const Reference< XMultiServiceFactory > & _rxORB )
57     {
58         return OAddConditionDialog::Create( _rxORB );
59     }
60 
61     //--------------------------------------------------------------------
OAddConditionDialog_GetSupportedServiceNames()62     Sequence< ::rtl::OUString > SAL_CALL OAddConditionDialog_GetSupportedServiceNames()
63     {
64         ::comphelper::StringSequence aSupported( 1 );
65         aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xforms.ui.dialogs.AddCondition" ) );
66         return aSupported;
67     }
68 
69     //--------------------------------------------------------------------
OAddConditionDialog_GetImplementationName()70     ::rtl::OUString SAL_CALL OAddConditionDialog_GetImplementationName()
71     {
72         return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.OAddConditionDialog" );
73     }
74 
75     //====================================================================
76     //= OAddConditionDialog
77     //====================================================================
78     //--------------------------------------------------------------------
OAddConditionDialog(const Reference<XMultiServiceFactory> & _rxORB)79     OAddConditionDialog::OAddConditionDialog( const Reference< XMultiServiceFactory >& _rxORB )
80         :OAddConditionDialogBase( _rxORB )
81     {
82         registerProperty(
83             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ),
84             PROPERTY_ID_BINDING,
85             PropertyAttribute::TRANSIENT,
86             &m_xBinding,
87             ::getCppuType( &m_xBinding )
88         );
89 
90         registerProperty(
91             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ),
92             PROPERTY_ID_FACET_NAME,
93             PropertyAttribute::TRANSIENT,
94             &m_sFacetName,
95             ::getCppuType( &m_sFacetName )
96         );
97 
98         registerProperty(
99             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ),
100             PROPERTY_ID_CONDITION_VALUE,
101             PropertyAttribute::TRANSIENT,
102             &m_sConditionValue,
103             ::getCppuType( &m_sConditionValue )
104         );
105 
106         registerProperty(
107             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ),
108             PROPERTY_ID_FORM_MODEL,
109             PropertyAttribute::TRANSIENT,
110             &m_xWorkModel,
111             ::getCppuType( &m_xWorkModel )
112         );
113     }
114 
115     //-------------------------------------------------------------------------
getImplementationId()116     Sequence<sal_Int8> SAL_CALL OAddConditionDialog::getImplementationId(  ) throw(RuntimeException)
117     {
118         static ::cppu::OImplementationId * pId = 0;
119         if (! pId)
120         {
121             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
122             if (! pId)
123             {
124                 static ::cppu::OImplementationId aId;
125                 pId = &aId;
126             }
127         }
128         return pId->getImplementationId();
129     }
130 
131     //-------------------------------------------------------------------------
Create(const Reference<XMultiServiceFactory> & _rxFactory)132     Reference< XInterface > SAL_CALL OAddConditionDialog::Create( const Reference< XMultiServiceFactory >& _rxFactory )
133     {
134         return *( new OAddConditionDialog( _rxFactory ) );
135     }
136 
137     //-------------------------------------------------------------------------
getImplementationName()138     ::rtl::OUString SAL_CALL OAddConditionDialog::getImplementationName() throw(RuntimeException)
139     {
140         return OAddConditionDialog_GetImplementationName();
141     }
142 
143     //-------------------------------------------------------------------------
getSupportedServiceNames()144     Sequence< ::rtl::OUString > SAL_CALL OAddConditionDialog::getSupportedServiceNames() throw(RuntimeException)
145     {
146         return OAddConditionDialog_GetSupportedServiceNames();
147     }
148 
149     //-------------------------------------------------------------------------
getPropertySetInfo()150     Reference<XPropertySetInfo>  SAL_CALL OAddConditionDialog::getPropertySetInfo() throw(RuntimeException)
151     {
152         return createPropertySetInfo( getInfoHelper() );
153     }
154 
155     //-------------------------------------------------------------------------
getInfoHelper()156     ::cppu::IPropertyArrayHelper& OAddConditionDialog::getInfoHelper()
157     {
158         return *const_cast< OAddConditionDialog* >( this )->getArrayHelper();
159     }
160 
161     //------------------------------------------------------------------------------
createArrayHelper() const162     ::cppu::IPropertyArrayHelper* OAddConditionDialog::createArrayHelper( ) const
163     {
164         Sequence< Property > aProperties;
165         describeProperties( aProperties );
166         return new ::cppu::OPropertyArrayHelper( aProperties );
167     }
168 
169     //------------------------------------------------------------------------------
createDialog(Window * _pParent)170     Dialog* OAddConditionDialog::createDialog(Window* _pParent)
171     {
172         if ( !m_xBinding.is() || !m_sFacetName.getLength() )
173             throw RuntimeException( ::rtl::OUString(), *this );
174 
175         return new AddConditionDialog( _pParent, m_sFacetName, m_xBinding );
176     }
177 
178     //------------------------------------------------------------------------------
executedDialog(sal_Int16 _nExecutionResult)179     void OAddConditionDialog::executedDialog( sal_Int16 _nExecutionResult )
180     {
181         OAddConditionDialogBase::executedDialog( _nExecutionResult );
182         if ( _nExecutionResult == RET_OK )
183             m_sConditionValue = static_cast< AddConditionDialog* >( m_pDialog )->GetCondition();
184     }
185 
186 //........................................................................
187 } // namespace svxformv
188 //........................................................................
189 
190