tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / forms / source / component / Hidden.cxx
blob3891bbe9d31aa7e075719ac05440656e3d6acb52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "Hidden.hxx"
21 #include <property.hxx>
22 #include <services.hxx>
23 #include <tools/debug.hxx>
24 #include <comphelper/basicio.hxx>
25 #include <comphelper/property.hxx>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <com/sun/star/form/FormComponentType.hpp>
30 namespace frm
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::sdb;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::form;
37 using namespace ::com::sun::star::io;
38 using namespace ::com::sun::star::util;
41 OHiddenModel::OHiddenModel(const Reference<XComponentContext>& _rxFactory)
42 :OControlModel(_rxFactory, OUString())
44 m_nClassId = FormComponentType::HIDDENCONTROL;
48 OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
49 :OControlModel( _pOriginal, _rxFactory )
51 m_sHiddenValue = _pOriginal->m_sHiddenValue;
55 OHiddenModel::~OHiddenModel( )
60 css::uno::Reference< css::util::XCloneable > SAL_CALL OHiddenModel::createClone()
62 rtl::Reference<OHiddenModel> pClone = new OHiddenModel(this, getContext());
63 pClone->clonedFrom(this);
64 return pClone;
68 void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
70 switch (_nHandle)
72 case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
73 default:
74 OControlModel::getFastPropertyValue(_rValue, _nHandle);
79 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue)
81 switch (_nHandle)
83 case PROPERTY_ID_HIDDEN_VALUE :
84 DBG_ASSERT(_rValue.getValueTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
85 _rValue >>= m_sHiddenValue;
86 break;
87 default:
88 OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
93 sal_Bool OHiddenModel::convertFastPropertyValue(
94 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
96 bool bModified(false);
97 switch (_nHandle)
99 case PROPERTY_ID_HIDDEN_VALUE :
100 bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
101 break;
102 default:
103 bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
104 break;
106 return bModified;
110 void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
112 _rProps.realloc(4);
113 css::beans::Property* pProperties = _rProps.getArray();
114 *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT);
115 *pProperties++ = css::beans::Property(PROPERTY_HIDDEN_VALUE, PROPERTY_ID_HIDDEN_VALUE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
116 *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
117 *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
118 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
121 // XServiceInfo
123 css::uno::Sequence<OUString> SAL_CALL OHiddenModel::getSupportedServiceNames()
125 return css::uno::Sequence<OUString>{
126 FRM_SUN_COMPONENT_HIDDENCONTROL, FRM_SUN_FORMCOMPONENT,
127 FRM_COMPONENT_HIDDEN, FRM_COMPONENT_HIDDENCONTROL };
131 OUString SAL_CALL OHiddenModel::getServiceName()
133 return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility !
137 void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
139 // Version
140 _rxOutStream->writeShort(0x0002);
142 // Value
143 _rxOutStream << m_sHiddenValue;
145 OControlModel::write(_rxOutStream);
149 void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream)
151 // Version
152 sal_uInt16 nVersion = _rxInStream->readShort();
154 // Name
155 DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
156 switch (nVersion)
158 case 1 : { OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
159 case 2 : _rxInStream >> m_sHiddenValue; break;
160 default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue.clear();
162 OControlModel::read(_rxInStream);
167 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
168 com_sun_star_form_OHiddenModel_get_implementation(css::uno::XComponentContext* component,
169 css::uno::Sequence<css::uno::Any> const &)
171 return cppu::acquire(new frm::OHiddenModel(component));
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */