xref: /aoo4110/main/forms/source/component/Hidden.cxx (revision b1cdbd2c)
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_forms.hxx"
26 #include "Hidden.hxx"
27 #include "property.hxx"
28 #ifndef _FRM_PROPERTY_HRC_
29 #include "property.hrc"
30 #endif
31 #include "services.hxx"
32 #include <tools/debug.hxx>
33 #include <comphelper/basicio.hxx>
34 
35 //.........................................................................
36 namespace frm
37 {
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::sdb;
40 using namespace ::com::sun::star::sdbc;
41 using namespace ::com::sun::star::sdbcx;
42 using namespace ::com::sun::star::beans;
43 using namespace ::com::sun::star::container;
44 using namespace ::com::sun::star::form;
45 using namespace ::com::sun::star::awt;
46 using namespace ::com::sun::star::io;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::util;
49 
50 //------------------------------------------------------------------
OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory> & _rxFactory)51 InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
52 {
53 	return *(new OHiddenModel(_rxFactory));
54 }
55 
56 //------------------------------------------------------------------
DBG_NAME(OHiddenModel)57 DBG_NAME( OHiddenModel )
58 //------------------------------------------------------------------
59 OHiddenModel::OHiddenModel(const Reference<XMultiServiceFactory>& _rxFactory)
60 	:OControlModel(_rxFactory, ::rtl::OUString())
61 {
62 	DBG_CTOR( OHiddenModel, NULL );
63 	m_nClassId = FormComponentType::HIDDENCONTROL;
64 }
65 
66 //------------------------------------------------------------------
OHiddenModel(const OHiddenModel * _pOriginal,const Reference<XMultiServiceFactory> & _rxFactory)67 OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
68 	:OControlModel( _pOriginal, _rxFactory )
69 {
70 	DBG_CTOR( OHiddenModel, NULL );
71 	m_sHiddenValue = _pOriginal->m_sHiddenValue;
72 }
73 
74 //------------------------------------------------------------------------------
~OHiddenModel()75 OHiddenModel::~OHiddenModel( )
76 {
77 	DBG_CTOR( OHiddenModel, NULL );
78 }
79 
80 //------------------------------------------------------------------------------
IMPLEMENT_DEFAULT_CLONING(OHiddenModel)81 IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
82 
83 //------------------------------------------------------------------------------
84 void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
85 {
86 	switch (_nHandle)
87 	{
88 		case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
89 		default:
90 			OControlModel::getFastPropertyValue(_rValue, _nHandle);
91 	}
92 }
93 
94 //------------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _rValue)95 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception)
96 {
97 	switch (_nHandle)
98 	{
99 		case PROPERTY_ID_HIDDEN_VALUE :
100 			DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
101 			_rValue >>= m_sHiddenValue;
102 			break;
103 		default:
104 			OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
105 	}
106 }
107 
108 //------------------------------------------------------------------------------
convertFastPropertyValue(Any & _rConvertedValue,Any & _rOldValue,sal_Int32 _nHandle,const Any & _rValue)109 sal_Bool OHiddenModel::convertFastPropertyValue(
110 			Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
111 			throw (IllegalArgumentException)
112 {
113 	sal_Bool bModified(sal_False);
114 	switch (_nHandle)
115 	{
116 		case PROPERTY_ID_HIDDEN_VALUE :
117 			bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
118 			break;
119 		default:
120 			bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
121 			break;
122 	}
123 	return bModified;
124 }
125 
126 //------------------------------------------------------------------------------
describeFixedProperties(Sequence<Property> & _rProps) const127 void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
128 {
129 	BEGIN_DESCRIBE_BASE_PROPERTIES(4)
130 		DECL_PROP2(CLASSID,			sal_Int16,			READONLY, TRANSIENT);
131 		DECL_PROP1(HIDDEN_VALUE,	::rtl::OUString,	BOUND);
132 		DECL_PROP1(NAME,			::rtl::OUString,	BOUND);
133 		DECL_PROP1(TAG,				::rtl::OUString,	BOUND);
134 	END_DESCRIBE_PROPERTIES();
135 }
136 
137 // XServiceInfo
138 //------------------------------------------------------------------------------
getSupportedServiceNames()139 StringSequence SAL_CALL	OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
140 {
141 	StringSequence aSupported( 2 );
142 	aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL;
143 	aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT;
144 	return aSupported;
145 }
146 
147 //------------------------------------------------------------------------------
getServiceName()148 ::rtl::OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException)
149 {
150 	return FRM_COMPONENT_HIDDEN;	// old (non-sun) name for compatibility !
151 }
152 
153 //------------------------------------------------------------------------------
write(const Reference<XObjectOutputStream> & _rxOutStream)154 void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
155 	throw(IOException, RuntimeException)
156 {
157 	// Version
158 	_rxOutStream->writeShort(0x0002);
159 
160 	// Wert
161 	_rxOutStream << m_sHiddenValue;
162 
163 	OControlModel::write(_rxOutStream);
164 }
165 
166 //------------------------------------------------------------------------------
read(const Reference<XObjectInputStream> & _rxInStream)167 void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException)
168 {
169 	// Version
170 	sal_uInt16 nVersion = _rxInStream->readShort();
171 
172 	// Name
173 	DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
174 	switch (nVersion)
175 	{
176 		case 1 : { ::rtl::OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
177 		case 2 : _rxInStream >> m_sHiddenValue; break;
178 		default : DBG_ERROR("OHiddenModel::read : unknown version !"); m_sHiddenValue = ::rtl::OUString();
179 	}
180 	OControlModel::read(_rxInStream);
181 }
182 
183 //.........................................................................
184 }
185 //.........................................................................
186 
187