Line data Source code
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 "property.hrc"
23 : #include "services.hxx"
24 : #include <tools/debug.hxx>
25 : #include <comphelper/basicio.hxx>
26 : #include <comphelper/processfactory.hxx>
27 :
28 :
29 : namespace frm
30 : {
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;
42 :
43 :
44 0 : InterfaceRef SAL_CALL OHiddenModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
45 : {
46 0 : return *(new OHiddenModel( comphelper::getComponentContext(_rxFactory) ));
47 : }
48 :
49 :
50 :
51 0 : OHiddenModel::OHiddenModel(const Reference<XComponentContext>& _rxFactory)
52 0 : :OControlModel(_rxFactory, OUString())
53 : {
54 0 : m_nClassId = FormComponentType::HIDDENCONTROL;
55 0 : }
56 :
57 :
58 0 : OHiddenModel::OHiddenModel( const OHiddenModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
59 0 : :OControlModel( _pOriginal, _rxFactory )
60 : {
61 0 : m_sHiddenValue = _pOriginal->m_sHiddenValue;
62 0 : }
63 :
64 :
65 0 : OHiddenModel::~OHiddenModel( )
66 : {
67 0 : }
68 :
69 :
70 0 : IMPLEMENT_DEFAULT_CLONING( OHiddenModel )
71 :
72 :
73 0 : void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
74 : {
75 0 : switch (_nHandle)
76 : {
77 0 : case PROPERTY_ID_HIDDEN_VALUE : _rValue <<= m_sHiddenValue; break;
78 : default:
79 0 : OControlModel::getFastPropertyValue(_rValue, _nHandle);
80 : }
81 0 : }
82 :
83 :
84 0 : void OHiddenModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception, std::exception)
85 : {
86 0 : switch (_nHandle)
87 : {
88 : case PROPERTY_ID_HIDDEN_VALUE :
89 : DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING, "OHiddenModel::setFastPropertyValue_NoBroadcast : invalid type !" );
90 0 : _rValue >>= m_sHiddenValue;
91 0 : break;
92 : default:
93 0 : OControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
94 : }
95 0 : }
96 :
97 :
98 0 : sal_Bool OHiddenModel::convertFastPropertyValue(
99 : Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
100 : throw (IllegalArgumentException)
101 : {
102 0 : sal_Bool bModified(sal_False);
103 0 : switch (_nHandle)
104 : {
105 : case PROPERTY_ID_HIDDEN_VALUE :
106 0 : bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_sHiddenValue);
107 0 : break;
108 : default:
109 0 : bModified = OControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
110 0 : break;
111 : }
112 0 : return bModified;
113 : }
114 :
115 :
116 0 : void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const
117 : {
118 0 : BEGIN_DESCRIBE_BASE_PROPERTIES(4)
119 0 : DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
120 0 : DECL_PROP1(HIDDEN_VALUE, OUString, BOUND);
121 0 : DECL_PROP1(NAME, OUString, BOUND);
122 0 : DECL_PROP1(TAG, OUString, BOUND);
123 : END_DESCRIBE_PROPERTIES();
124 0 : }
125 :
126 : // XServiceInfo
127 :
128 0 : StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception)
129 : {
130 0 : StringSequence aSupported( 2 );
131 0 : aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL;
132 0 : aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT;
133 0 : return aSupported;
134 : }
135 :
136 :
137 0 : OUString SAL_CALL OHiddenModel::getServiceName() throw(RuntimeException, std::exception)
138 : {
139 0 : return OUString(FRM_COMPONENT_HIDDEN); // old (non-sun) name for compatibility !
140 : }
141 :
142 :
143 0 : void SAL_CALL OHiddenModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
144 : throw(IOException, RuntimeException, std::exception)
145 : {
146 : // Version
147 0 : _rxOutStream->writeShort(0x0002);
148 :
149 : // Wert
150 0 : _rxOutStream << m_sHiddenValue;
151 :
152 0 : OControlModel::write(_rxOutStream);
153 0 : }
154 :
155 :
156 0 : void SAL_CALL OHiddenModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException, std::exception)
157 : {
158 : // Version
159 0 : sal_uInt16 nVersion = _rxInStream->readShort();
160 :
161 : // Name
162 : DBG_ASSERT(nVersion != 1, "OHiddenModel::read : this version is obsolete !");
163 0 : switch (nVersion)
164 : {
165 0 : case 1 : { OUString sDummy; _rxInStream >> sDummy; _rxInStream >> m_sHiddenValue; } break;
166 0 : case 2 : _rxInStream >> m_sHiddenValue; break;
167 0 : default : OSL_FAIL("OHiddenModel::read : unknown version !"); m_sHiddenValue = OUString();
168 : }
169 0 : OControlModel::read(_rxInStream);
170 0 : }
171 :
172 :
173 : }
174 :
175 :
176 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|