merge the formfield patch from ooo-build
[ooovba.git] / forms / source / component / Hidden.cxx
blobb3b4d0a5349151433c80fca35171af6a9db859ca
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Hidden.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_forms.hxx"
33 #include "Hidden.hxx"
34 #include "property.hxx"
35 #ifndef _FRM_PROPERTY_HRC_
36 #include "property.hrc"
37 #endif
38 #include "services.hxx"
39 #include <tools/debug.hxx>
40 #include <comphelper/basicio.hxx>
42 //.........................................................................
43 namespace frm
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::sdb;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::sdbcx;
49 using namespace ::com::sun::star::beans;
50 using namespace ::com::sun::star::container;
51 using namespace ::com::sun::star::form;
52 using namespace ::com::sun::star::awt;
53 using namespace ::com::sun::star::io;
54 using namespace ::com::sun::star::lang;
55 using namespace ::com::sun::star::util;
57 //------------------------------------------------------------------
58 InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
60 return *(new OHiddenModel(_rxFactory));
63 //------------------------------------------------------------------
64 DBG_NAME( OHiddenModel )
65 //------------------------------------------------------------------
66 OHiddenModel::OHiddenModel(const Reference<XMultiServiceFactory>& _rxFactory)
67 :OControlModel(_rxFactory, ::rtl::OUString())
69 DBG_CTOR( OHiddenModel, NULL );
70 m_nClassId = FormComponentType::HIDDENCONTROL;
73 //------------------------------------------------------------------
74 OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
75 :OControlModel( _pOriginal, _rxFactory )
77 DBG_CTOR( OHiddenModel, NULL );
78 m_sHiddenValue = _pOriginal->m_sHiddenValue;
81 //------------------------------------------------------------------------------
82 OHiddenModel::~OHiddenModel( )
84 DBG_CTOR( OHiddenModel, NULL );
87 //------------------------------------------------------------------------------
88 IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
90 //------------------------------------------------------------------------------
91 void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
93 switch (_nHandle)
95 case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
96 default:
97 OControlModel::getFastPropertyValue(_rValue, _nHandle);
101 //------------------------------------------------------------------------------
102 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception)
104 switch (_nHandle)
106 case PROPERTY_ID_HIDDEN_VALUE :
107 DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
108 _rValue >>= m_sHiddenValue;
109 break;
110 default:
111 OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
115 //------------------------------------------------------------------------------
116 sal_Bool OHiddenModel::convertFastPropertyValue(
117 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
118 throw (IllegalArgumentException)
120 sal_Bool bModified(sal_False);
121 switch (_nHandle)
123 case PROPERTY_ID_HIDDEN_VALUE :
124 bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
125 break;
126 default:
127 bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
128 break;
130 return bModified;
133 //------------------------------------------------------------------------------
134 void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
136 BEGIN_DESCRIBE_BASE_PROPERTIES(4)
137 DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
138 DECL_PROP1(HIDDEN_VALUE, ::rtl::OUString, BOUND);
139 DECL_PROP1(NAME, ::rtl::OUString, BOUND);
140 DECL_PROP1(TAG, ::rtl::OUString, BOUND);
141 END_DESCRIBE_PROPERTIES();
144 // XServiceInfo
145 //------------------------------------------------------------------------------
146 StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
148 StringSequence aSupported( 2 );
149 aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL;
150 aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT;
151 return aSupported;
154 //------------------------------------------------------------------------------
155 ::rtl::OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException)
157 return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility !
160 //------------------------------------------------------------------------------
161 void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
162 throw(IOException, RuntimeException)
164 // Version
165 _rxOutStream->writeShort(0x0002);
167 // Wert
168 _rxOutStream << m_sHiddenValue;
170 OControlModel::write(_rxOutStream);
173 //------------------------------------------------------------------------------
174 void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException)
176 // Version
177 UINT16 nVersion = _rxInStream->readShort();
179 // Name
180 DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
181 switch (nVersion)
183 case 1 : { ::rtl::OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
184 case 2 : _rxInStream >> m_sHiddenValue; break;
185 default : DBG_ERROR("OHiddenModel::read : unknown version !"); m_sHiddenValue = ::rtl::OUString();
187 OControlModel::read(_rxInStream);
190 //.........................................................................
192 //.........................................................................