1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "property.hxx"
22 #include "property.hrc"
23 #include "services.hxx"
24 #include <tools/debug.hxx>
25 #include <comphelper/basicio.hxx>
26 #include <comphelper/processfactory.hxx>
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::sdbcx
;
35 using namespace ::com::sun::star::beans
;
36 using namespace ::com::sun::star::container
;
37 using namespace ::com::sun::star::form
;
38 using namespace ::com::sun::star::awt
;
39 using namespace ::com::sun::star::io
;
40 using namespace ::com::sun::star::lang
;
41 using namespace ::com::sun::star::util
;
44 OHiddenModel::OHiddenModel(const Reference
<XComponentContext
>& _rxFactory
)
45 :OControlModel(_rxFactory
, OUString())
47 m_nClassId
= FormComponentType::HIDDENCONTROL
;
51 OHiddenModel::OHiddenModel( const OHiddenModel
* _pOriginal
, const Reference
<XComponentContext
>& _rxFactory
)
52 :OControlModel( _pOriginal
, _rxFactory
)
54 m_sHiddenValue
= _pOriginal
->m_sHiddenValue
;
58 OHiddenModel::~OHiddenModel( )
63 IMPLEMENT_DEFAULT_CLONING( OHiddenModel
)
66 void OHiddenModel::getFastPropertyValue(Any
& _rValue
, sal_Int32 _nHandle
) const
70 case PROPERTY_ID_HIDDEN_VALUE
: _rValue
<<= m_sHiddenValue
; break;
72 OControlModel::getFastPropertyValue(_rValue
, _nHandle
);
77 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle
, const Any
& _rValue
) throw (com::sun::star::uno::Exception
, std::exception
)
81 case PROPERTY_ID_HIDDEN_VALUE
:
82 DBG_ASSERT(_rValue
.getValueType().getTypeClass() == TypeClass_STRING
, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
83 _rValue
>>= m_sHiddenValue
;
86 OControlModel::setFastPropertyValue_NoBroadcast(_nHandle
, _rValue
);
91 sal_Bool
OHiddenModel::convertFastPropertyValue(
92 Any
& _rConvertedValue
, Any
& _rOldValue
, sal_Int32 _nHandle
, const Any
& _rValue
)
93 throw (IllegalArgumentException
)
95 bool bModified(false);
98 case PROPERTY_ID_HIDDEN_VALUE
:
99 bModified
= tryPropertyValue(_rConvertedValue
, _rOldValue
, _rValue
, m_sHiddenValue
);
102 bModified
= OControlModel::convertFastPropertyValue(_rConvertedValue
, _rOldValue
, _nHandle
, _rValue
);
109 void OHiddenModel::describeFixedProperties( Sequence
< Property
>& _rProps
) const
111 BEGIN_DESCRIBE_BASE_PROPERTIES(4)
112 DECL_PROP2(CLASSID
, sal_Int16
, READONLY
, TRANSIENT
);
113 DECL_PROP1(HIDDEN_VALUE
, OUString
, BOUND
);
114 DECL_PROP1(NAME
, OUString
, BOUND
);
115 DECL_PROP1(TAG
, OUString
, BOUND
);
116 END_DESCRIBE_PROPERTIES();
121 StringSequence SAL_CALL
OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
123 return css::uno::Sequence
<OUString
>{
124 FRM_SUN_COMPONENT_HIDDENCONTROL
, FRM_SUN_FORMCOMPONENT
,
125 FRM_COMPONENT_HIDDEN
, FRM_COMPONENT_HIDDENCONTROL
};
129 OUString SAL_CALL
OHiddenModel::getServiceName() throw(RuntimeException
, std::exception
)
131 return OUString(FRM_COMPONENT_HIDDEN
); // old (non-sun) name for compatibility !
135 void SAL_CALL
OHiddenModel::write(const Reference
<XObjectOutputStream
>& _rxOutStream
)
136 throw(IOException
, RuntimeException
, std::exception
)
139 _rxOutStream
->writeShort(0x0002);
142 _rxOutStream
<< m_sHiddenValue
;
144 OControlModel::write(_rxOutStream
);
148 void SAL_CALL
OHiddenModel::read(const Reference
<XObjectInputStream
>& _rxInStream
) throw(IOException
, RuntimeException
, std::exception
)
151 sal_uInt16 nVersion
= _rxInStream
->readShort();
154 DBG_ASSERT(nVersion
!= 1, "OHiddenModel::read : this version is obsolete !");
157 case 1 : { OUString sDummy
; _rxInStream
>> sDummy
; _rxInStream
>> m_sHiddenValue
; } break;
158 case 2 : _rxInStream
>> m_sHiddenValue
; break;
159 default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue
.clear();
161 OControlModel::read(_rxInStream
);
166 extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface
* SAL_CALL
167 com_sun_star_form_OHiddenModel_get_implementation(::com::sun::star::uno::XComponentContext
* component
,
168 ::com::sun::star::uno::Sequence
<css::uno::Any
> const &)
170 return cppu::acquire(new frm::OHiddenModel(component
));
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */