Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "Hidden.hxx"
30 : : #include "property.hxx"
31 : : #include "property.hrc"
32 : : #include "services.hxx"
33 : : #include <tools/debug.hxx>
34 : : #include <comphelper/basicio.hxx>
35 : :
36 : : //.........................................................................
37 : : namespace frm
38 : : {
39 : : using namespace ::com::sun::star::uno;
40 : : using namespace ::com::sun::star::sdb;
41 : : using namespace ::com::sun::star::sdbc;
42 : : using namespace ::com::sun::star::sdbcx;
43 : : using namespace ::com::sun::star::beans;
44 : : using namespace ::com::sun::star::container;
45 : : using namespace ::com::sun::star::form;
46 : : using namespace ::com::sun::star::awt;
47 : : using namespace ::com::sun::star::io;
48 : : using namespace ::com::sun::star::lang;
49 : : using namespace ::com::sun::star::util;
50 : :
51 : : //------------------------------------------------------------------
52 : 7 : InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
53 : : {
54 [ + - ]: 7 : return *(new OHiddenModel(_rxFactory));
55 : : }
56 : :
57 : : //------------------------------------------------------------------
58 : : DBG_NAME( OHiddenModel )
59 : : //------------------------------------------------------------------
60 : 7 : OHiddenModel::OHiddenModel(const Reference<XMultiServiceFactory>& _rxFactory)
61 [ + - ]: 7 : :OControlModel(_rxFactory, ::rtl::OUString())
62 : : {
63 : : DBG_CTOR( OHiddenModel, NULL );
64 : 7 : m_nClassId = FormComponentType::HIDDENCONTROL;
65 : 7 : }
66 : :
67 : : //------------------------------------------------------------------
68 : 0 : OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
69 : 0 : :OControlModel( _pOriginal, _rxFactory )
70 : : {
71 : : DBG_CTOR( OHiddenModel, NULL );
72 : 0 : m_sHiddenValue = _pOriginal->m_sHiddenValue;
73 : 0 : }
74 : :
75 : : //------------------------------------------------------------------------------
76 : 7 : OHiddenModel::~OHiddenModel( )
77 : : {
78 : : DBG_CTOR( OHiddenModel, NULL );
79 [ - + ]: 14 : }
80 : :
81 : : //------------------------------------------------------------------------------
82 [ # # ][ # # ]: 0 : IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
83 : :
84 : : //------------------------------------------------------------------------------
85 : 80 : void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
86 : : {
87 [ + + ]: 80 : switch (_nHandle)
88 : : {
89 : 20 : case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
90 : : default:
91 : 60 : OControlModel::getFastPropertyValue(_rValue, _nHandle);
92 : : }
93 : 80 : }
94 : :
95 : : //------------------------------------------------------------------------------
96 : 36 : void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception)
97 : : {
98 [ + + ]: 36 : switch (_nHandle)
99 : : {
100 : : case PROPERTY_ID_HIDDEN_VALUE :
101 : : DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
102 : 8 : _rValue >>= m_sHiddenValue;
103 : 8 : break;
104 : : default:
105 : 28 : OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
106 : : }
107 : 36 : }
108 : :
109 : : //------------------------------------------------------------------------------
110 : 38 : sal_Bool OHiddenModel::convertFastPropertyValue(
111 : : Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
112 : : throw (IllegalArgumentException)
113 : : {
114 : 38 : sal_Bool bModified(sal_False);
115 [ + + ]: 38 : switch (_nHandle)
116 : : {
117 : : case PROPERTY_ID_HIDDEN_VALUE :
118 : 8 : bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
119 : 8 : break;
120 : : default:
121 : 30 : bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
122 : 28 : break;
123 : : }
124 : 36 : return bModified;
125 : : }
126 : :
127 : : //------------------------------------------------------------------------------
128 : 10 : void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
129 : : {
130 : 10 : BEGIN_DESCRIBE_BASE_PROPERTIES(4)
131 [ + - ][ + - ]: 10 : DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
132 [ + - ]: 10 : DECL_PROP1(HIDDEN_VALUE, ::rtl::OUString, BOUND);
133 [ + - ]: 10 : DECL_PROP1(NAME, ::rtl::OUString, BOUND);
134 [ + - ]: 10 : DECL_PROP1(TAG, ::rtl::OUString, BOUND);
135 : : END_DESCRIBE_PROPERTIES();
136 : 10 : }
137 : :
138 : : // XServiceInfo
139 : : //------------------------------------------------------------------------------
140 : 34 : StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
141 : : {
142 : 34 : StringSequence aSupported( 2 );
143 [ + - ][ + - ]: 34 : aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL;
144 [ + - ][ + - ]: 34 : aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT;
145 : 34 : return aSupported;
146 : : }
147 : :
148 : : //------------------------------------------------------------------------------
149 : 2 : ::rtl::OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException)
150 : : {
151 : 2 : return FRM_COMPONENT_HIDDEN; // old (non-sun) name for compatibility !
152 : : }
153 : :
154 : : //------------------------------------------------------------------------------
155 : 2 : void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
156 : : throw(IOException, RuntimeException)
157 : : {
158 : : // Version
159 : 2 : _rxOutStream->writeShort(0x0002);
160 : :
161 : : // Wert
162 : 2 : _rxOutStream << m_sHiddenValue;
163 : :
164 : 2 : OControlModel::write(_rxOutStream);
165 : 2 : }
166 : :
167 : : //------------------------------------------------------------------------------
168 : 2 : void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException)
169 : : {
170 : : // Version
171 : 2 : sal_uInt16 nVersion = _rxInStream->readShort();
172 : :
173 : : // Name
174 : : DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
175 [ - + - ]: 2 : switch (nVersion)
176 : : {
177 [ # # ][ # # ]: 0 : case 1 : { ::rtl::OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
178 : 2 : case 2 : _rxInStream >> m_sHiddenValue; break;
179 : 0 : default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue = ::rtl::OUString();
180 : : }
181 : 2 : OControlModel::read(_rxInStream);
182 : 2 : }
183 : :
184 : : //.........................................................................
185 : : }
186 : : //.........................................................................
187 : :
188 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|