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 //------------------------------------------------------------------ 51 InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) 52 { 53 return *(new OHiddenModel(_rxFactory)); 54 } 55 56 //------------------------------------------------------------------ 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 //------------------------------------------------------------------ 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 //------------------------------------------------------------------------------ 75 OHiddenModel::~OHiddenModel( ) 76 { 77 DBG_CTOR( OHiddenModel, NULL ); 78 } 79 80 //------------------------------------------------------------------------------ 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 //------------------------------------------------------------------------------ 95 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) 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 //------------------------------------------------------------------------------ 109 sal_Bool OHiddenModel::convertFastPropertyValue( 110 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) 111 { 112 sal_Bool bModified(sal_False); 113 switch (_nHandle) 114 { 115 case PROPERTY_ID_HIDDEN_VALUE : 116 bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue); 117 break; 118 default: 119 bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue); 120 break; 121 } 122 return bModified; 123 } 124 125 //------------------------------------------------------------------------------ 126 void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const 127 { 128 BEGIN_DESCRIBE_BASE_PROPERTIES(4) 129 DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT); 130 DECL_PROP1(HIDDEN_VALUE, ::rtl::OUString, BOUND); 131 DECL_PROP1(NAME, ::rtl::OUString, BOUND); 132 DECL_PROP1(TAG, ::rtl::OUString, BOUND); 133 END_DESCRIBE_PROPERTIES(); 134 } 135 136 // XServiceInfo 137 //------------------------------------------------------------------------------ 138 StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() 139 { 140 StringSequence aSupported( 2 ); 141 aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL; 142 aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT; 143 return aSupported; 144 } 145 146 //------------------------------------------------------------------------------ 147 ::rtl::OUString SAL_CALL OHiddenModel::getServiceName() 148 { 149 return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility ! 150 } 151 152 //------------------------------------------------------------------------------ 153 void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream) 154 { 155 // Version 156 _rxOutStream->writeShort(0x0002); 157 158 // Wert 159 _rxOutStream << m_sHiddenValue; 160 161 OControlModel::write(_rxOutStream); 162 } 163 164 //------------------------------------------------------------------------------ 165 void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) 166 { 167 // Version 168 sal_uInt16 nVersion = _rxInStream->readShort(); 169 170 // Name 171 DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !"); 172 switch (nVersion) 173 { 174 case 1 : { ::rtl::OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break; 175 case 2 : _rxInStream >> m_sHiddenValue; break; 176 default : DBG_ERROR("OHiddenModel::read : unknown version !"); m_sHiddenValue = ::rtl::OUString(); 177 } 178 OControlModel::read(_rxInStream); 179 } 180 181 //......................................................................... 182 } 183 //......................................................................... 184