xref: /aoo41x/main/forms/source/component/Hidden.cxx (revision 24acc546)
1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24acc546SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24acc546SAndrew Rist  * distributed with this work for additional information
6*24acc546SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24acc546SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist  * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24acc546SAndrew Rist  *
11*24acc546SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24acc546SAndrew Rist  *
13*24acc546SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist  * software distributed under the License is distributed on an
15*24acc546SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist  * KIND, either express or implied.  See the License for the
17*24acc546SAndrew Rist  * specific language governing permissions and limitations
18*24acc546SAndrew Rist  * under the License.
19*24acc546SAndrew Rist  *
20*24acc546SAndrew Rist  *************************************************************/
21*24acc546SAndrew Rist 
22*24acc546SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_forms.hxx"
26cdf0e10cSrcweir #include "Hidden.hxx"
27cdf0e10cSrcweir #include "property.hxx"
28cdf0e10cSrcweir #ifndef _FRM_PROPERTY_HRC_
29cdf0e10cSrcweir #include "property.hrc"
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include "services.hxx"
32cdf0e10cSrcweir #include <tools/debug.hxx>
33cdf0e10cSrcweir #include <comphelper/basicio.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //.........................................................................
36cdf0e10cSrcweir namespace frm
37cdf0e10cSrcweir {
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
40cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
41cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
42cdf0e10cSrcweir using namespace ::com::sun::star::beans;
43cdf0e10cSrcweir using namespace ::com::sun::star::container;
44cdf0e10cSrcweir using namespace ::com::sun::star::form;
45cdf0e10cSrcweir using namespace ::com::sun::star::awt;
46cdf0e10cSrcweir using namespace ::com::sun::star::io;
47cdf0e10cSrcweir using namespace ::com::sun::star::lang;
48cdf0e10cSrcweir using namespace ::com::sun::star::util;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //------------------------------------------------------------------
OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory> & _rxFactory)51cdf0e10cSrcweir InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	return *(new OHiddenModel(_rxFactory));
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //------------------------------------------------------------------
DBG_NAME(OHiddenModel)57cdf0e10cSrcweir DBG_NAME( OHiddenModel )
58cdf0e10cSrcweir //------------------------------------------------------------------
59cdf0e10cSrcweir OHiddenModel::OHiddenModel(const Reference<XMultiServiceFactory>& _rxFactory)
60cdf0e10cSrcweir 	:OControlModel(_rxFactory, ::rtl::OUString())
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	DBG_CTOR( OHiddenModel, NULL );
63cdf0e10cSrcweir 	m_nClassId = FormComponentType::HIDDENCONTROL;
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //------------------------------------------------------------------
OHiddenModel(const OHiddenModel * _pOriginal,const Reference<XMultiServiceFactory> & _rxFactory)67cdf0e10cSrcweir OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
68cdf0e10cSrcweir 	:OControlModel( _pOriginal, _rxFactory )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	DBG_CTOR( OHiddenModel, NULL );
71cdf0e10cSrcweir 	m_sHiddenValue = _pOriginal->m_sHiddenValue;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //------------------------------------------------------------------------------
~OHiddenModel()75cdf0e10cSrcweir OHiddenModel::~OHiddenModel( )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	DBG_CTOR( OHiddenModel, NULL );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPLEMENT_DEFAULT_CLONING(OHiddenModel)81cdf0e10cSrcweir IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //------------------------------------------------------------------------------
84cdf0e10cSrcweir void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	switch (_nHandle)
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir 		case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
89cdf0e10cSrcweir 		default:
90cdf0e10cSrcweir 			OControlModel::getFastPropertyValue(_rValue, _nHandle);
91cdf0e10cSrcweir 	}
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //------------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _rValue)95cdf0e10cSrcweir void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	switch (_nHandle)
98cdf0e10cSrcweir 	{
99cdf0e10cSrcweir 		case PROPERTY_ID_HIDDEN_VALUE :
100cdf0e10cSrcweir 			DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
101cdf0e10cSrcweir 			_rValue >>= m_sHiddenValue;
102cdf0e10cSrcweir 			break;
103cdf0e10cSrcweir 		default:
104cdf0e10cSrcweir 			OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
105cdf0e10cSrcweir 	}
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir //------------------------------------------------------------------------------
convertFastPropertyValue(Any & _rConvertedValue,Any & _rOldValue,sal_Int32 _nHandle,const Any & _rValue)109cdf0e10cSrcweir sal_Bool OHiddenModel::convertFastPropertyValue(
110cdf0e10cSrcweir 			Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
111cdf0e10cSrcweir 			throw (IllegalArgumentException)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	sal_Bool bModified(sal_False);
114cdf0e10cSrcweir 	switch (_nHandle)
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		case PROPERTY_ID_HIDDEN_VALUE :
117cdf0e10cSrcweir 			bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
118cdf0e10cSrcweir 			break;
119cdf0e10cSrcweir 		default:
120cdf0e10cSrcweir 			bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
121cdf0e10cSrcweir 			break;
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir 	return bModified;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir //------------------------------------------------------------------------------
describeFixedProperties(Sequence<Property> & _rProps) const127cdf0e10cSrcweir void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	BEGIN_DESCRIBE_BASE_PROPERTIES(4)
130cdf0e10cSrcweir 		DECL_PROP2(CLASSID,			sal_Int16,			READONLY, TRANSIENT);
131cdf0e10cSrcweir 		DECL_PROP1(HIDDEN_VALUE,	::rtl::OUString,	BOUND);
132cdf0e10cSrcweir 		DECL_PROP1(NAME,			::rtl::OUString,	BOUND);
133cdf0e10cSrcweir 		DECL_PROP1(TAG,				::rtl::OUString,	BOUND);
134cdf0e10cSrcweir 	END_DESCRIBE_PROPERTIES();
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // XServiceInfo
138cdf0e10cSrcweir //------------------------------------------------------------------------------
getSupportedServiceNames()139cdf0e10cSrcweir StringSequence SAL_CALL	OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	StringSequence aSupported( 2 );
142cdf0e10cSrcweir 	aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL;
143cdf0e10cSrcweir 	aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT;
144cdf0e10cSrcweir 	return aSupported;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir //------------------------------------------------------------------------------
getServiceName()148cdf0e10cSrcweir ::rtl::OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	return FRM_COMPONENT_HIDDEN;	// old (non-sun) name for compatibility !
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir //------------------------------------------------------------------------------
write(const Reference<XObjectOutputStream> & _rxOutStream)154cdf0e10cSrcweir void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
155cdf0e10cSrcweir 	throw(IOException, RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	// Version
158cdf0e10cSrcweir 	_rxOutStream->writeShort(0x0002);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	// Wert
161cdf0e10cSrcweir 	_rxOutStream << m_sHiddenValue;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	OControlModel::write(_rxOutStream);
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir //------------------------------------------------------------------------------
read(const Reference<XObjectInputStream> & _rxInStream)167cdf0e10cSrcweir void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	// Version
170cdf0e10cSrcweir 	sal_uInt16 nVersion = _rxInStream->readShort();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	// Name
173cdf0e10cSrcweir 	DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
174cdf0e10cSrcweir 	switch (nVersion)
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		case 1 : { ::rtl::OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
177cdf0e10cSrcweir 		case 2 : _rxInStream >> m_sHiddenValue; break;
178cdf0e10cSrcweir 		default : DBG_ERROR("OHiddenModel::read : unknown version !"); m_sHiddenValue = ::rtl::OUString();
179cdf0e10cSrcweir 	}
180cdf0e10cSrcweir 	OControlModel::read(_rxInStream);
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir //.........................................................................
184cdf0e10cSrcweir }
185cdf0e10cSrcweir //.........................................................................
186cdf0e10cSrcweir 
187