LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / forms / source / component / Hidden.cxx
blob092eeb773fe432148a0e02b42afcf8638a5a155b
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/form/FormComponentType.hpp>
29 namespace frm
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::sdb;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::form;
37 using namespace ::com::sun::star::awt;
38 using namespace ::com::sun::star::io;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::util;
43 OHiddenModel::OHiddenModel(const Reference<XComponentContext>& _rxFactory)
44 :OControlModel(_rxFactory, OUString())
46 m_nClassId = FormComponentType::HIDDENCONTROL;
50 OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
51 :OControlModel( _pOriginal, _rxFactory )
53 m_sHiddenValue = _pOriginal->m_sHiddenValue;
57 OHiddenModel::~OHiddenModel( )
62 css::uno::Reference< css::util::XCloneable > SAL_CALL OHiddenModel::createClone()
64 rtl::Reference<OHiddenModel> pClone = new OHiddenModel(this, getContext());
65 pClone->clonedFrom(this);
66 return pClone;
70 void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
72 switch (_nHandle)
74 case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
75 default:
76 OControlModel::getFastPropertyValue(_rValue, _nHandle);
81 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue)
83 switch (_nHandle)
85 case PROPERTY_ID_HIDDEN_VALUE :
86 DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
87 _rValue >>= m_sHiddenValue;
88 break;
89 default:
90 OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
95 sal_Bool OHiddenModel::convertFastPropertyValue(
96 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
98 bool bModified(false);
99 switch (_nHandle)
101 case PROPERTY_ID_HIDDEN_VALUE :
102 bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
103 break;
104 default:
105 bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
106 break;
108 return bModified;
112 void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
114 _rProps.realloc(4);
115 css::beans::Property* pProperties = _rProps.getArray();
116 *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT);
117 *pProperties++ = css::beans::Property(PROPERTY_HIDDEN_VALUE, PROPERTY_ID_HIDDEN_VALUE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
118 *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
119 *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
120 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
123 // XServiceInfo
125 css::uno::Sequence<OUString> SAL_CALL OHiddenModel::getSupportedServiceNames()
127 return css::uno::Sequence<OUString>{
128 FRM_SUN_COMPONENT_HIDDENCONTROL, FRM_SUN_FORMCOMPONENT,
129 FRM_COMPONENT_HIDDEN, FRM_COMPONENT_HIDDENCONTROL };
133 OUString SAL_CALL OHiddenModel::getServiceName()
135 return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility !
139 void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
141 // Version
142 _rxOutStream->writeShort(0x0002);
144 // Value
145 _rxOutStream << m_sHiddenValue;
147 OControlModel::write(_rxOutStream);
151 void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream)
153 // Version
154 sal_uInt16 nVersion = _rxInStream->readShort();
156 // Name
157 DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
158 switch (nVersion)
160 case 1 : { OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
161 case 2 : _rxInStream >> m_sHiddenValue; break;
162 default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue.clear();
164 OControlModel::read(_rxInStream);
169 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
170 com_sun_star_form_OHiddenModel_get_implementation(css::uno::XComponentContext* component,
171 css::uno::Sequence<css::uno::Any> const &)
173 return cppu::acquire(new frm::OHiddenModel(component));
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */