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>
27 //.........................................................................
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::sdb
;
32 using namespace ::com::sun::star::sdbc
;
33 using namespace ::com::sun::star::sdbcx
;
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
;
42 //------------------------------------------------------------------
43 InterfaceRef SAL_CALL
OHiddenModel_CreateInstance(const Reference
<XMultiServiceFactory
>& _rxFactory
) throw (RuntimeException
)
45 return *(new OHiddenModel(_rxFactory
));
48 //------------------------------------------------------------------
49 DBG_NAME( OHiddenModel
)
50 //------------------------------------------------------------------
51 OHiddenModel::OHiddenModel(const Reference
<XMultiServiceFactory
>& _rxFactory
)
52 :OControlModel(_rxFactory
, OUString())
54 DBG_CTOR( OHiddenModel
, NULL
);
55 m_nClassId
= FormComponentType::HIDDENCONTROL
;
58 //------------------------------------------------------------------
59 OHiddenModel::OHiddenModel( const OHiddenModel
* _pOriginal
, const Reference
<XMultiServiceFactory
>& _rxFactory
)
60 :OControlModel( _pOriginal
, _rxFactory
)
62 DBG_CTOR( OHiddenModel
, NULL
);
63 m_sHiddenValue
= _pOriginal
->m_sHiddenValue
;
66 //------------------------------------------------------------------------------
67 OHiddenModel::~OHiddenModel( )
69 DBG_CTOR( OHiddenModel
, NULL
);
72 //------------------------------------------------------------------------------
73 IMPLEMENT_DEFAULT_CLONING( OHiddenModel
)
75 //------------------------------------------------------------------------------
76 void OHiddenModel::getFastPropertyValue(Any
& _rValue
, sal_Int32 _nHandle
) const
80 case PROPERTY_ID_HIDDEN_VALUE
: _rValue
<<= m_sHiddenValue
; break;
82 OControlModel::getFastPropertyValue(_rValue
, _nHandle
);
86 //------------------------------------------------------------------------------
87 void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle
, const Any
& _rValue
) throw (com::sun::star::uno::Exception
)
91 case PROPERTY_ID_HIDDEN_VALUE
:
92 DBG_ASSERT(_rValue
.getValueType().getTypeClass() == TypeClass_STRING
, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
93 _rValue
>>= m_sHiddenValue
;
96 OControlModel::setFastPropertyValue_NoBroadcast(_nHandle
, _rValue
);
100 //------------------------------------------------------------------------------
101 sal_Bool
OHiddenModel::convertFastPropertyValue(
102 Any
& _rConvertedValue
, Any
& _rOldValue
, sal_Int32 _nHandle
, const Any
& _rValue
)
103 throw (IllegalArgumentException
)
105 sal_Bool
bModified(sal_False
);
108 case PROPERTY_ID_HIDDEN_VALUE
:
109 bModified
= tryPropertyValue(_rConvertedValue
, _rOldValue
, _rValue
, m_sHiddenValue
);
112 bModified
= OControlModel::convertFastPropertyValue(_rConvertedValue
, _rOldValue
, _nHandle
, _rValue
);
118 //------------------------------------------------------------------------------
119 void OHiddenModel::describeFixedProperties( Sequence
< Property
>& _rProps
) const
121 BEGIN_DESCRIBE_BASE_PROPERTIES(4)
122 DECL_PROP2(CLASSID
, sal_Int16
, READONLY
, TRANSIENT
);
123 DECL_PROP1(HIDDEN_VALUE
, OUString
, BOUND
);
124 DECL_PROP1(NAME
, OUString
, BOUND
);
125 DECL_PROP1(TAG
, OUString
, BOUND
);
126 END_DESCRIBE_PROPERTIES();
130 //------------------------------------------------------------------------------
131 StringSequence SAL_CALL
OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
)
133 StringSequence
aSupported( 2 );
134 aSupported
[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL
;
135 aSupported
[ 1 ] = FRM_SUN_FORMCOMPONENT
;
139 //------------------------------------------------------------------------------
140 OUString SAL_CALL
OHiddenModel::getServiceName() throw(RuntimeException
)
142 return OUString(FRM_COMPONENT_HIDDEN
); // old (non-sun) name for compatibility !
145 //------------------------------------------------------------------------------
146 void SAL_CALL
OHiddenModel::write(const Reference
<XObjectOutputStream
>& _rxOutStream
)
147 throw(IOException
, RuntimeException
)
150 _rxOutStream
->writeShort(0x0002);
153 _rxOutStream
<< m_sHiddenValue
;
155 OControlModel::write(_rxOutStream
);
158 //------------------------------------------------------------------------------
159 void SAL_CALL
OHiddenModel::read(const Reference
<XObjectInputStream
>& _rxInStream
) throw(IOException
, RuntimeException
)
162 sal_uInt16 nVersion
= _rxInStream
->readShort();
165 DBG_ASSERT(nVersion
!= 1, "OHiddenModel::read : this version is obsolete !");
168 case 1 : { OUString sDummy
; _rxInStream
>> sDummy
; _rxInStream
>> m_sHiddenValue
; } break;
169 case 2 : _rxInStream
>> m_sHiddenValue
; break;
170 default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue
= OUString();
172 OControlModel::read(_rxInStream
);
175 //.........................................................................
177 //.........................................................................
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */