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