LibreOffice Module forms (master) 1
Hidden.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "Hidden.hxx"
21#include <property.hxx>
22#include <services.hxx>
23#include <tools/debug.hxx>
26#include <com/sun/star/beans/PropertyAttribute.hpp>
27#include <com/sun/star/form/FormComponentType.hpp>
28
29
30namespace frm
31{
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::sdb;
34using namespace ::com::sun::star::sdbc;
35using namespace ::com::sun::star::beans;
36using namespace ::com::sun::star::container;
37using namespace ::com::sun::star::form;
38using namespace ::com::sun::star::awt;
39using namespace ::com::sun::star::io;
40using namespace ::com::sun::star::lang;
41using namespace ::com::sun::star::util;
42
43
44OHiddenModel::OHiddenModel(const Reference<XComponentContext>& _rxFactory)
45 :OControlModel(_rxFactory, OUString())
46{
47 m_nClassId = FormComponentType::HIDDENCONTROL;
48}
49
50
51OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
52 :OControlModel( _pOriginal, _rxFactory )
53{
54 m_sHiddenValue = _pOriginal->m_sHiddenValue;
55}
56
57
58OHiddenModel::~OHiddenModel( )
59{
60}
61
62
63css::uno::Reference< css::util::XCloneable > SAL_CALL OHiddenModel::createClone()
64{
65 rtl::Reference<OHiddenModel> pClone = new OHiddenModel(this, getContext());
66 pClone->clonedFrom(this);
67 return pClone;
68}
69
70
71void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
72{
73 switch (_nHandle)
74 {
75 case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
76 default:
77 OControlModel::getFastPropertyValue(_rValue, _nHandle);
78 }
79}
80
81
82void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue)
83{
84 switch (_nHandle)
85 {
87 DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
88 _rValue >>= m_sHiddenValue;
89 break;
90 default:
91 OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
92 }
93}
94
95
96sal_Bool OHiddenModel::convertFastPropertyValue(
97 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
98{
99 bool bModified(false);
100 switch (_nHandle)
101 {
103 bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
104 break;
105 default:
106 bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
107 break;
108 }
109 return bModified;
110}
111
112
113void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
114{
115 _rProps.realloc(4);
116 css::beans::Property* pProperties = _rProps.getArray();
117 *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT);
118 *pProperties++ = css::beans::Property(PROPERTY_HIDDEN_VALUE, PROPERTY_ID_HIDDEN_VALUE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
119 *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
120 *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND);
121 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
122}
123
124// XServiceInfo
125
126css::uno::Sequence<OUString> SAL_CALL OHiddenModel::getSupportedServiceNames()
127{
128 return css::uno::Sequence<OUString>{
131}
132
133
134OUString SAL_CALL OHiddenModel::getServiceName()
135{
136 return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility !
137}
138
139
140void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
141{
142 // Version
143 _rxOutStream->writeShort(0x0002);
144
145 // Value
146 _rxOutStream << m_sHiddenValue;
147
148 OControlModel::write(_rxOutStream);
149}
150
151
152void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream)
153{
154 // Version
155 sal_uInt16 nVersion = _rxInStream->readShort();
156
157 // Name
158 DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
159 switch (nVersion)
160 {
161 case 1 : { OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
162 case 2 : _rxInStream >> m_sHiddenValue; break;
163 default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue.clear();
164 }
165 OControlModel::read(_rxInStream);
166}
167
168}
169
170extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
171com_sun_star_form_OHiddenModel_get_implementation(css::uno::XComponentContext* component,
172 css::uno::Sequence<css::uno::Any> const &)
173{
174 return cppu::acquire(new frm::OHiddenModel(component));
175}
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OHiddenModel_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
Definition: Hidden.cxx:171
OHiddenModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
#define DBG_ASSERT(sCon, aError)
sal_Int16 nVersion
constexpr OUStringLiteral PROPERTY_NAME
Definition: frm_strings.hxx:28
constexpr OUStringLiteral PROPERTY_HIDDEN_VALUE
Definition: frm_strings.hxx:60
constexpr OUStringLiteral PROPERTY_CLASSID
Definition: frm_strings.hxx:30
constexpr OUStringLiteral PROPERTY_TAG
Definition: frm_strings.hxx:27
bool tryPropertyValue(Any &_rConvertedValue, Any &_rOldValue, const Any &_rValueToSet, const Any &_rCurrentValue, const Type &_rExpectedType)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
#define PROPERTY_ID_NAME
Definition: property.hxx:40
#define PROPERTY_ID_TAG
Definition: property.hxx:155
#define PROPERTY_ID_CLASSID
Definition: property.hxx:45
#define PROPERTY_ID_HIDDEN_VALUE
Definition: property.hxx:166
constexpr OUStringLiteral FRM_SUN_FORMCOMPONENT
Definition: services.hxx:188
constexpr OUStringLiteral FRM_COMPONENT_HIDDEN
Definition: services.hxx:83
constexpr OUStringLiteral FRM_SUN_COMPONENT_HIDDENCONTROL
Definition: services.hxx:129
constexpr OUStringLiteral FRM_COMPONENT_HIDDENCONTROL
Definition: services.hxx:84
unsigned char sal_Bool