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