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 : #include "Columns.hxx"
20 : #include "findpos.hxx"
21 : #include "Grid.hxx"
22 : #include "property.hrc"
23 : #include "property.hxx"
24 : #include "services.hxx"
25 : #include <com/sun/star/form/FormComponentType.hpp>
26 : #include <com/sun/star/form/XForm.hpp>
27 : #include <com/sun/star/form/XLoadable.hpp>
28 : #include <com/sun/star/text/WritingMode2.hpp>
29 : #include <comphelper/basicio.hxx>
30 : #include <comphelper/container.hxx>
31 : #include <comphelper/processfactory.hxx>
32 : #include <cppuhelper/queryinterface.hxx>
33 : #include <toolkit/helper/vclunohelper.hxx>
34 : #include <vcl/svapp.hxx>
35 : using namespace ::com::sun::star::uno;
36 : namespace frm
37 : {
38 : using namespace ::com::sun::star;
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 : using namespace ::com::sun::star::view;
51 : namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
52 : const sal_uInt16 ROWHEIGHT = 0x0001;
53 : const sal_uInt16 FONTTYPE = 0x0002;
54 : const sal_uInt16 FONTSIZE = 0x0004;
55 : const sal_uInt16 FONTATTRIBS = 0x0008;
56 : const sal_uInt16 TABSTOP = 0x0010;
57 : const sal_uInt16 TEXTCOLOR = 0x0020;
58 : const sal_uInt16 FONTDESCRIPTOR = 0x0040;
59 : const sal_uInt16 RECORDMARKER = 0x0080;
60 : const sal_uInt16 BACKGROUNDCOLOR = 0x0100;
61 0 : InterfaceRef SAL_CALL OGridControlModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
62 : {
63 0 : return *(new OGridControlModel( comphelper::getComponentContext(_rxFactory) ));
64 : }
65 0 : OGridControlModel::OGridControlModel(const Reference<XComponentContext>& _rxFactory)
66 : :OControlModel(_rxFactory, OUString())
67 0 : ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL)))
68 : ,OErrorBroadcaster( OComponentHelper::rBHelper )
69 : ,FontControlModel( false )
70 : ,m_aSelectListeners(m_aMutex)
71 : ,m_aResetListeners(m_aMutex)
72 : ,m_aRowSetChangeListeners(m_aMutex)
73 : ,m_aDefaultControl( FRM_SUN_CONTROL_GRIDCONTROL )
74 : ,m_nBorder(1)
75 : ,m_nWritingMode( WritingMode2::CONTEXT )
76 : ,m_nContextWritingMode( WritingMode2::CONTEXT )
77 : ,m_bEnableVisible(sal_True)
78 : ,m_bEnable(sal_True)
79 : ,m_bNavigation(sal_True)
80 : ,m_bRecordMarker(sal_True)
81 : ,m_bPrintable(sal_True)
82 : ,m_bAlwaysShowCursor(sal_False)
83 0 : ,m_bDisplaySynchron(sal_True)
84 : {
85 0 : m_nClassId = FormComponentType::GRIDCONTROL;
86 0 : }
87 :
88 0 : OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const Reference< XComponentContext >& _rxFactory )
89 : :OControlModel( _pOriginal, _rxFactory )
90 0 : ,OInterfaceContainer( _rxFactory, m_aMutex, ::getCppuType( static_cast<Reference<XPropertySet>*>( NULL ) ) )
91 : ,OErrorBroadcaster( OComponentHelper::rBHelper )
92 : ,FontControlModel( _pOriginal )
93 : ,m_aSelectListeners( m_aMutex )
94 : ,m_aResetListeners( m_aMutex )
95 0 : ,m_aRowSetChangeListeners( m_aMutex )
96 : {
97 0 : m_aDefaultControl = _pOriginal->m_aDefaultControl;
98 0 : m_bEnable = _pOriginal->m_bEnable;
99 0 : m_bEnableVisible = _pOriginal->m_bEnableVisible;
100 0 : m_bNavigation = _pOriginal->m_bNavigation;
101 0 : m_nBorder = _pOriginal->m_nBorder;
102 0 : m_nWritingMode = _pOriginal->m_nWritingMode;
103 0 : m_nContextWritingMode = _pOriginal->m_nContextWritingMode;
104 0 : m_bRecordMarker = _pOriginal->m_bRecordMarker;
105 0 : m_bPrintable = _pOriginal->m_bPrintable;
106 0 : m_bAlwaysShowCursor = _pOriginal->m_bAlwaysShowCursor;
107 0 : m_bDisplaySynchron = _pOriginal->m_bDisplaySynchron;
108 : // clone the columns
109 0 : cloneColumns( _pOriginal );
110 : // TODO: clone the events?
111 0 : }
112 :
113 0 : OGridControlModel::~OGridControlModel()
114 : {
115 0 : if (!OComponentHelper::rBHelper.bDisposed)
116 : {
117 0 : acquire();
118 0 : dispose();
119 : }
120 0 : }
121 :
122 : // XCloneable
123 0 : Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException, std::exception)
124 : {
125 0 : OGridControlModel* pClone = new OGridControlModel( this, getContext() );
126 0 : osl_atomic_increment( &pClone->m_refCount );
127 0 : pClone->OControlModel::clonedFrom( this );
128 : // do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is
129 : // already done in the ctor
130 : //pClone->OInterfaceContainer::clonedFrom( *this );
131 0 : osl_atomic_decrement( &pClone->m_refCount );
132 0 : return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) );
133 : }
134 :
135 0 : void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer )
136 : {
137 : try
138 : {
139 0 : Reference< XCloneable > xColCloneable;
140 0 : const OInterfaceArray::const_iterator pColumnStart = _pOriginalContainer->m_aItems.begin();
141 0 : const OInterfaceArray::const_iterator pColumnEnd = _pOriginalContainer->m_aItems.end();
142 0 : for ( OInterfaceArray::const_iterator pColumn = pColumnStart; pColumn != pColumnEnd; ++pColumn )
143 : {
144 : // ask the col for a factory for the clone
145 0 : xColCloneable = xColCloneable.query( *pColumn );
146 : DBG_ASSERT( xColCloneable.is(), "OGridControlModel::cloneColumns: column is not cloneable!" );
147 0 : if ( xColCloneable.is() )
148 : {
149 : // create a clone of the column
150 0 : Reference< XCloneable > xColClone( xColCloneable->createClone() );
151 : DBG_ASSERT( xColClone.is(), "OGridControlModel::cloneColumns: invalid column clone!" );
152 0 : if ( xColClone.is() )
153 : {
154 : // insert this clone into our own container
155 0 : insertByIndex( pColumn - pColumnStart, xColClone->queryInterface( m_aElementType ) );
156 0 : }
157 : }
158 0 : }
159 : }
160 0 : catch( const Exception& )
161 : {
162 : OSL_FAIL( "OGridControlModel::cloneColumns: caught an exception while cloning the columns!" );
163 : }
164 0 : }
165 :
166 : // XServiceInfo
167 0 : StringSequence OGridControlModel::getSupportedServiceNames() throw(RuntimeException, std::exception)
168 : {
169 0 : StringSequence aSupported = OControlModel::getSupportedServiceNames();
170 0 : aSupported.realloc(aSupported.getLength() + 2);
171 0 : aSupported[aSupported.getLength()-2] = "com.sun.star.awt.UnoControlModel";
172 0 : aSupported[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GRIDCONTROL;
173 0 : return aSupported;
174 : }
175 0 : Any SAL_CALL OGridControlModel::queryAggregation( const Type& _rType ) throw (RuntimeException, std::exception)
176 : {
177 0 : Any aReturn = OGridControlModel_BASE::queryInterface(_rType);
178 0 : if ( !aReturn.hasValue() )
179 : {
180 0 : aReturn = OControlModel::queryAggregation( _rType );
181 0 : if ( !aReturn.hasValue() )
182 : {
183 0 : aReturn = OInterfaceContainer::queryInterface( _rType );
184 0 : if ( !aReturn.hasValue() )
185 0 : aReturn = OErrorBroadcaster::queryInterface( _rType );
186 : }
187 : }
188 0 : return aReturn;
189 : }
190 :
191 : // XSQLErrorListener
192 0 : void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) throw (RuntimeException, std::exception)
193 : {
194 : // forward the errors which happened to my columns to my own listeners
195 0 : onError( _rEvent );
196 0 : }
197 :
198 : // XRowSetSupplier
199 0 : Reference< XRowSet > SAL_CALL OGridControlModel::getRowSet( ) throw (RuntimeException, std::exception)
200 : {
201 0 : return Reference< XRowSet >( getParent(), UNO_QUERY );
202 : }
203 :
204 0 : void SAL_CALL OGridControlModel::setRowSet( const Reference< XRowSet >& /*_rxDataSource*/ ) throw (RuntimeException, std::exception)
205 : {
206 : OSL_FAIL( "OGridControlModel::setRowSet: not supported!" );
207 0 : }
208 :
209 0 : void SAL_CALL OGridControlModel::addRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException, std::exception)
210 : {
211 0 : if ( i_Listener.is() )
212 0 : m_aRowSetChangeListeners.addInterface( i_Listener );
213 0 : }
214 :
215 0 : void SAL_CALL OGridControlModel::removeRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException, std::exception)
216 : {
217 0 : m_aRowSetChangeListeners.removeInterface( i_Listener );
218 0 : }
219 :
220 : // XChild
221 0 : void SAL_CALL OGridControlModel::setParent( const InterfaceRef& i_Parent ) throw(NoSupportException, RuntimeException, std::exception)
222 : {
223 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
224 0 : if ( i_Parent == getParent() )
225 0 : return;
226 0 : OControlModel::setParent( i_Parent );
227 0 : EventObject aEvent( *this );
228 0 : aGuard.clear();
229 0 : m_aRowSetChangeListeners.notifyEach( &XRowSetChangeListener::onRowSetChanged, aEvent );
230 : }
231 0 : Sequence< Type > SAL_CALL OGridControlModel::getTypes( ) throw(RuntimeException, std::exception)
232 : {
233 : return concatSequences(
234 : concatSequences(
235 : OControlModel::getTypes(),
236 : OInterfaceContainer::getTypes(),
237 : OErrorBroadcaster::getTypes()
238 : ),
239 : OGridControlModel_BASE::getTypes()
240 0 : );
241 : }
242 :
243 : // OComponentHelper
244 0 : void OGridControlModel::disposing()
245 : {
246 0 : OControlModel::disposing();
247 0 : OErrorBroadcaster::disposing();
248 0 : OInterfaceContainer::disposing();
249 0 : setParent(NULL);
250 0 : EventObject aEvt(static_cast<XWeak*>(this));
251 0 : m_aSelectListeners.disposeAndClear(aEvt);
252 0 : m_aResetListeners.disposeAndClear(aEvt);
253 0 : m_aRowSetChangeListeners.disposeAndClear(aEvt);
254 0 : }
255 :
256 : // XEventListener
257 0 : void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeException, std::exception )
258 : {
259 0 : OControlModel::disposing( _rEvent );
260 0 : OInterfaceContainer::disposing( _rEvent );
261 0 : }
262 :
263 : // XSelectionSupplier
264 0 : sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalArgumentException, RuntimeException, std::exception)
265 : {
266 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
267 0 : Reference<XPropertySet> xSel;
268 0 : if (rElement.hasValue())
269 : {
270 0 : xSel.set(rElement, css::uno::UNO_QUERY);
271 0 : if (!xSel.is())
272 : {
273 0 : throw IllegalArgumentException();
274 : }
275 : }
276 0 : InterfaceRef xMe = static_cast<XWeak*>(this);
277 0 : if (xSel.is())
278 : {
279 0 : Reference<XChild> xAsChild(xSel, UNO_QUERY);
280 0 : if (!xAsChild.is() || (xAsChild->getParent() != xMe))
281 : {
282 0 : throw IllegalArgumentException();
283 0 : }
284 : }
285 0 : if ( xSel != m_xSelection )
286 : {
287 0 : m_xSelection = xSel;
288 0 : aGuard.clear();
289 0 : m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
290 0 : return sal_True;
291 : }
292 0 : return sal_False;
293 : }
294 0 : Any SAL_CALL OGridControlModel::getSelection() throw(RuntimeException, std::exception)
295 : {
296 0 : return makeAny(m_xSelection);
297 : }
298 :
299 0 : void OGridControlModel::addSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException, std::exception )
300 : {
301 0 : m_aSelectListeners.addInterface(_rxListener);
302 0 : }
303 :
304 0 : void OGridControlModel::removeSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException, std::exception )
305 : {
306 0 : m_aSelectListeners.removeInterface(_rxListener);
307 0 : }
308 :
309 : // XGridColumnFactory
310 0 : Reference<XPropertySet> SAL_CALL OGridControlModel::createColumn(const OUString& ColumnType) throw ( :: com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
311 : {
312 0 : SolarMutexGuard g;
313 0 : const Sequence< OUString >& rColumnTypes = frm::getColumnTypes();
314 0 : return createColumn( ::detail::findPos( ColumnType, rColumnTypes ) );
315 : }
316 0 : Reference<XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) const
317 : {
318 0 : Reference<XPropertySet> xReturn;
319 0 : switch (nTypeId)
320 : {
321 0 : case TYPE_CHECKBOX: xReturn = new CheckBoxColumn( getContext() ); break;
322 0 : case TYPE_COMBOBOX: xReturn = new ComboBoxColumn( getContext() ); break;
323 0 : case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn( getContext() ); break;
324 0 : case TYPE_DATEFIELD: xReturn = new DateFieldColumn( getContext() ); break;
325 0 : case TYPE_LISTBOX: xReturn = new ListBoxColumn( getContext() ); break;
326 0 : case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn( getContext() ); break;
327 0 : case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn( getContext() ); break;
328 0 : case TYPE_TEXTFIELD: xReturn = new TextFieldColumn( getContext() ); break;
329 0 : case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn( getContext() ); break;
330 0 : case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn( getContext() ); break;
331 : default:
332 : OSL_FAIL("OGridControlModel::createColumn: Unknown Column");
333 0 : break;
334 : }
335 0 : return xReturn;
336 : }
337 0 : StringSequence SAL_CALL OGridControlModel::getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
338 : {
339 0 : return frm::getColumnTypes();
340 : }
341 :
342 : // XReset
343 0 : void SAL_CALL OGridControlModel::reset() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
344 : {
345 0 : ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
346 0 : EventObject aEvt(static_cast<XWeak*>(this));
347 0 : sal_Bool bContinue = sal_True;
348 0 : while (aIter.hasMoreElements() && bContinue)
349 0 : bContinue =((XResetListener*)aIter.next())->approveReset(aEvt);
350 0 : if (bContinue)
351 : {
352 0 : _reset();
353 0 : m_aResetListeners.notifyEach( &XResetListener::resetted, aEvt );
354 0 : }
355 0 : }
356 0 : void SAL_CALL OGridControlModel::addResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException, std::exception)
357 : {
358 0 : m_aResetListeners.addInterface(_rxListener);
359 0 : }
360 0 : void SAL_CALL OGridControlModel::removeResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException, std::exception)
361 : {
362 0 : m_aResetListeners.removeInterface(_rxListener);
363 0 : }
364 0 : void OGridControlModel::_reset()
365 : {
366 0 : Reference<XReset> xReset;
367 0 : sal_Int32 nCount = getCount();
368 0 : for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
369 : {
370 0 : getByIndex( nIndex ) >>= xReset;
371 0 : if (xReset.is())
372 0 : xReset->reset();
373 0 : }
374 0 : }
375 :
376 : // XPropertySet
377 0 : void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const
378 : {
379 0 : BEGIN_DESCRIBE_BASE_PROPERTIES( 37 )
380 0 : DECL_PROP1(NAME, OUString, BOUND);
381 0 : DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
382 0 : DECL_PROP1(TAG, OUString, BOUND);
383 0 : DECL_PROP1(TABINDEX, sal_Int16, BOUND);
384 0 : DECL_PROP3(TABSTOP, sal_Bool, BOUND, MAYBEDEFAULT, MAYBEVOID);
385 0 : DECL_PROP2(HASNAVIGATION, sal_Bool, BOUND, MAYBEDEFAULT);
386 0 : DECL_PROP1(ENABLED, sal_Bool, BOUND);
387 0 : DECL_PROP2(ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT);
388 0 : DECL_PROP1(BORDER, sal_Int16, BOUND);
389 0 : DECL_PROP2(BORDERCOLOR, sal_Int16, BOUND, MAYBEVOID);
390 0 : DECL_PROP1(DEFAULTCONTROL, OUString, BOUND);
391 0 : DECL_PROP3(TEXTCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
392 0 : DECL_PROP3(BACKGROUNDCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
393 0 : DECL_PROP2(FONT, FontDescriptor, BOUND, MAYBEDEFAULT);
394 0 : DECL_PROP3(ROWHEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
395 0 : DECL_PROP1(HELPTEXT, OUString, BOUND);
396 0 : DECL_PROP1(FONT_NAME, OUString, MAYBEDEFAULT);
397 0 : DECL_PROP1(FONT_STYLENAME, OUString, MAYBEDEFAULT);
398 0 : DECL_PROP1(FONT_FAMILY, sal_Int16, MAYBEDEFAULT);
399 0 : DECL_PROP1(FONT_CHARSET, sal_Int16, MAYBEDEFAULT);
400 0 : DECL_PROP1(FONT_HEIGHT, float, MAYBEDEFAULT);
401 0 : DECL_PROP1(FONT_WEIGHT, float, MAYBEDEFAULT);
402 0 : DECL_PROP1(FONT_SLANT, sal_Int16, MAYBEDEFAULT);
403 0 : DECL_PROP1(FONT_UNDERLINE, sal_Int16, MAYBEDEFAULT);
404 0 : DECL_BOOL_PROP1(FONT_WORDLINEMODE, MAYBEDEFAULT);
405 0 : DECL_PROP3(TEXTLINECOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
406 0 : DECL_PROP2(FONTEMPHASISMARK, sal_Int16, BOUND, MAYBEDEFAULT);
407 0 : DECL_PROP2(FONTRELIEF, sal_Int16, BOUND, MAYBEDEFAULT);
408 0 : DECL_PROP1(FONT_STRIKEOUT, sal_Int16, MAYBEDEFAULT);
409 0 : DECL_PROP2(RECORDMARKER, sal_Bool, BOUND, MAYBEDEFAULT );
410 0 : DECL_PROP2(PRINTABLE, sal_Bool, BOUND, MAYBEDEFAULT );
411 0 : DECL_PROP4(CURSORCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID , TRANSIENT);
412 0 : DECL_PROP3(ALWAYSSHOWCURSOR, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT);
413 0 : DECL_PROP3(DISPLAYSYNCHRON, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT);
414 0 : DECL_PROP2(HELPURL, OUString, BOUND, MAYBEDEFAULT);
415 0 : DECL_PROP2(WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT);
416 0 : DECL_PROP3(CONTEXT_WRITING_MODE,sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT);
417 : END_DESCRIBE_PROPERTIES();
418 0 : }
419 0 : void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
420 : {
421 0 : switch (nHandle)
422 : {
423 : case PROPERTY_ID_CONTEXT_WRITING_MODE:
424 0 : rValue <<= m_nContextWritingMode;
425 0 : break;
426 : case PROPERTY_ID_WRITING_MODE:
427 0 : rValue <<= m_nWritingMode;
428 0 : break;
429 : case PROPERTY_ID_HELPTEXT:
430 0 : rValue <<= m_sHelpText;
431 0 : break;
432 : case PROPERTY_ID_HELPURL:
433 0 : rValue <<= m_sHelpURL;
434 0 : break;
435 : case PROPERTY_ID_DISPLAYSYNCHRON:
436 0 : setBOOL(rValue, m_bDisplaySynchron);
437 0 : break;
438 : case PROPERTY_ID_ALWAYSSHOWCURSOR:
439 0 : setBOOL(rValue, m_bAlwaysShowCursor);
440 0 : break;
441 : case PROPERTY_ID_CURSORCOLOR:
442 0 : rValue = m_aCursorColor;
443 0 : break;
444 : case PROPERTY_ID_PRINTABLE:
445 0 : setBOOL(rValue, m_bPrintable);
446 0 : break;
447 : case PROPERTY_ID_TABSTOP:
448 0 : rValue = m_aTabStop;
449 0 : break;
450 : case PROPERTY_ID_HASNAVIGATION:
451 0 : setBOOL(rValue, m_bNavigation);
452 0 : break;
453 : case PROPERTY_ID_RECORDMARKER:
454 0 : setBOOL(rValue, m_bRecordMarker);
455 0 : break;
456 : case PROPERTY_ID_ENABLED:
457 0 : setBOOL(rValue, m_bEnable);
458 0 : break;
459 : case PROPERTY_ID_ENABLEVISIBLE:
460 0 : setBOOL(rValue, m_bEnableVisible);
461 0 : break;
462 : case PROPERTY_ID_BORDER:
463 0 : rValue <<= (sal_Int16)m_nBorder;
464 0 : break;
465 : case PROPERTY_ID_BORDERCOLOR:
466 0 : rValue <<= m_aBorderColor;
467 0 : break;
468 : case PROPERTY_ID_DEFAULTCONTROL:
469 0 : rValue <<= m_aDefaultControl;
470 0 : break;
471 : case PROPERTY_ID_BACKGROUNDCOLOR:
472 0 : rValue = m_aBackgroundColor;
473 0 : break;
474 : case PROPERTY_ID_ROWHEIGHT:
475 0 : rValue = m_aRowHeight;
476 0 : break;
477 : default:
478 0 : if ( isFontRelatedProperty( nHandle ) )
479 0 : FontControlModel::getFastPropertyValue( rValue, nHandle );
480 : else
481 0 : OControlModel::getFastPropertyValue( rValue, nHandle );
482 : }
483 0 : }
484 0 : sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
485 : sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
486 : {
487 0 : sal_Bool bModified(sal_False);
488 0 : switch (nHandle)
489 : {
490 : case PROPERTY_ID_CONTEXT_WRITING_MODE:
491 0 : bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nContextWritingMode );
492 0 : break;
493 : case PROPERTY_ID_WRITING_MODE:
494 0 : bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nWritingMode );
495 0 : break;
496 : case PROPERTY_ID_HELPTEXT:
497 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpText);
498 0 : break;
499 : case PROPERTY_ID_HELPURL:
500 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpURL);
501 0 : break;
502 : case PROPERTY_ID_DISPLAYSYNCHRON:
503 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bDisplaySynchron);
504 0 : break;
505 : case PROPERTY_ID_ALWAYSSHOWCURSOR:
506 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAlwaysShowCursor);
507 0 : break;
508 : case PROPERTY_ID_CURSORCOLOR:
509 0 : if (!rValue.hasValue() || !m_aCursorColor.hasValue())
510 : {
511 0 : if (rValue.hasValue() && (TypeClass_LONG != rValue.getValueType().getTypeClass()))
512 : {
513 0 : throw IllegalArgumentException();
514 : }
515 0 : rOldValue = m_aCursorColor;
516 0 : rConvertedValue = rValue;
517 0 : bModified = (rOldValue.getValue() != rConvertedValue.getValue());
518 : }
519 : else
520 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getINT32(m_aCursorColor));
521 0 : break;
522 : case PROPERTY_ID_PRINTABLE:
523 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bPrintable);
524 0 : break;
525 : case PROPERTY_ID_TABSTOP:
526 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTabStop, ::getBooleanCppuType());
527 0 : break;
528 : case PROPERTY_ID_HASNAVIGATION:
529 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bNavigation);
530 0 : break;
531 : case PROPERTY_ID_RECORDMARKER:
532 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bRecordMarker);
533 0 : break;
534 : case PROPERTY_ID_ENABLED:
535 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnable);
536 0 : break;
537 : case PROPERTY_ID_ENABLEVISIBLE:
538 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnableVisible);
539 0 : break;
540 : case PROPERTY_ID_BORDER:
541 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nBorder);
542 0 : break;
543 : case PROPERTY_ID_BORDERCOLOR:
544 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBorderColor, ::getCppuType((const sal_Int32*)NULL));
545 0 : break;
546 : case PROPERTY_ID_DEFAULTCONTROL:
547 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultControl);
548 0 : break;
549 : case PROPERTY_ID_BACKGROUNDCOLOR:
550 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBackgroundColor, ::getCppuType((const sal_Int32*)NULL));
551 0 : break;
552 : case PROPERTY_ID_ROWHEIGHT:
553 : {
554 0 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aRowHeight, ::getCppuType((const sal_Int32*)NULL));
555 0 : sal_Int32 nNewVal( 0 );
556 0 : if ( ( rConvertedValue >>= nNewVal ) && ( nNewVal <= 0 ) )
557 : {
558 0 : rConvertedValue.clear();
559 0 : bModified = m_aRowHeight.hasValue();
560 : }
561 : }
562 0 : break;
563 : default:
564 0 : if ( isFontRelatedProperty( nHandle ) )
565 0 : bModified = FontControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
566 : else
567 0 : bModified = OControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue);
568 : }
569 0 : return bModified;
570 : }
571 0 : void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw ( ::com::sun::star::uno::Exception, std::exception)
572 : {
573 0 : switch (nHandle)
574 : {
575 : case PROPERTY_ID_CONTEXT_WRITING_MODE:
576 0 : rValue >>= m_nContextWritingMode;
577 0 : break;
578 : case PROPERTY_ID_WRITING_MODE:
579 0 : rValue >>= m_nWritingMode;
580 0 : break;
581 : case PROPERTY_ID_HELPTEXT:
582 0 : rValue >>= m_sHelpText;
583 0 : break;
584 : case PROPERTY_ID_HELPURL:
585 0 : rValue >>= m_sHelpURL;
586 0 : break;
587 : case PROPERTY_ID_DISPLAYSYNCHRON:
588 0 : m_bDisplaySynchron = getBOOL(rValue);
589 0 : break;
590 : case PROPERTY_ID_ALWAYSSHOWCURSOR:
591 0 : m_bAlwaysShowCursor = getBOOL(rValue);
592 0 : break;
593 : case PROPERTY_ID_CURSORCOLOR:
594 0 : m_aCursorColor = rValue;
595 0 : break;
596 : case PROPERTY_ID_PRINTABLE:
597 0 : m_bPrintable = getBOOL(rValue);
598 0 : break;
599 : case PROPERTY_ID_TABSTOP:
600 0 : m_aTabStop = rValue;
601 0 : break;
602 : case PROPERTY_ID_HASNAVIGATION:
603 0 : m_bNavigation = getBOOL(rValue);
604 0 : break;
605 : case PROPERTY_ID_ENABLED:
606 0 : m_bEnable = getBOOL(rValue);
607 0 : break;
608 : case PROPERTY_ID_ENABLEVISIBLE:
609 0 : m_bEnableVisible = getBOOL(rValue);
610 0 : break;
611 : case PROPERTY_ID_RECORDMARKER:
612 0 : m_bRecordMarker = getBOOL(rValue);
613 0 : break;
614 : case PROPERTY_ID_BORDER:
615 0 : rValue >>= m_nBorder;
616 0 : break;
617 : case PROPERTY_ID_BORDERCOLOR:
618 0 : m_aBorderColor = rValue;
619 0 : break;
620 : case PROPERTY_ID_DEFAULTCONTROL:
621 0 : rValue >>= m_aDefaultControl;
622 0 : break;
623 : case PROPERTY_ID_BACKGROUNDCOLOR:
624 0 : m_aBackgroundColor = rValue;
625 0 : break;
626 : case PROPERTY_ID_ROWHEIGHT:
627 0 : m_aRowHeight = rValue;
628 0 : break;
629 : default:
630 0 : if ( isFontRelatedProperty( nHandle ) )
631 : {
632 : FontControlModel::setFastPropertyValue_NoBroadcast_impl(
633 : *this, &OGridControlModel::setDependentFastPropertyValue,
634 0 : nHandle, rValue);
635 : }
636 : else
637 0 : OControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
638 : }
639 0 : }
640 :
641 : //XPropertyState
642 0 : Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
643 : {
644 0 : Any aReturn;
645 0 : switch (nHandle)
646 : {
647 : case PROPERTY_ID_CONTEXT_WRITING_MODE:
648 : case PROPERTY_ID_WRITING_MODE:
649 0 : aReturn <<= WritingMode2::CONTEXT;
650 0 : break;
651 : case PROPERTY_ID_DEFAULTCONTROL:
652 0 : aReturn <<= OUString( STARDIV_ONE_FORM_CONTROL_GRID );
653 0 : break;
654 : case PROPERTY_ID_PRINTABLE:
655 : case PROPERTY_ID_HASNAVIGATION:
656 : case PROPERTY_ID_RECORDMARKER:
657 : case PROPERTY_ID_DISPLAYSYNCHRON:
658 : case PROPERTY_ID_ENABLED:
659 : case PROPERTY_ID_ENABLEVISIBLE:
660 0 : aReturn = makeBoolAny(true);
661 0 : break;
662 : case PROPERTY_ID_ALWAYSSHOWCURSOR:
663 0 : aReturn = makeBoolAny(false);
664 0 : break;
665 : case PROPERTY_ID_HELPURL:
666 : case PROPERTY_ID_HELPTEXT:
667 0 : aReturn <<= OUString();
668 0 : break;
669 : case PROPERTY_ID_BORDER:
670 0 : aReturn <<= (sal_Int16)1;
671 0 : break;
672 : case PROPERTY_ID_BORDERCOLOR:
673 : case PROPERTY_ID_TABSTOP:
674 : case PROPERTY_ID_BACKGROUNDCOLOR:
675 : case PROPERTY_ID_ROWHEIGHT:
676 : case PROPERTY_ID_CURSORCOLOR:
677 : // void
678 0 : break;
679 : default:
680 0 : if ( isFontRelatedProperty( nHandle ) )
681 0 : aReturn = FontControlModel::getPropertyDefaultByHandle( nHandle );
682 : else
683 0 : aReturn = OControlModel::getPropertyDefaultByHandle(nHandle);
684 : }
685 0 : return aReturn;
686 : }
687 :
688 0 : OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const
689 : {
690 0 : OGridColumn* pImplementation = NULL;
691 0 : Reference< XUnoTunnel > xUnoTunnel( _rxIFace, UNO_QUERY );
692 0 : if ( xUnoTunnel.is() )
693 0 : pImplementation = reinterpret_cast<OGridColumn*>(xUnoTunnel->getSomething(OGridColumn::getUnoTunnelImplementationId()));
694 0 : return pImplementation;
695 : }
696 :
697 0 : void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn )
698 : {
699 0 : Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
700 0 : if ( xBroadcaster.is() )
701 0 : xBroadcaster->addSQLErrorListener( this );
702 0 : }
703 :
704 0 : void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn)
705 : {
706 0 : if ( m_xSelection == _rxColumn )
707 : { // the currently selected element was replaced
708 0 : m_xSelection.clear();
709 0 : EventObject aEvt( static_cast< XWeak* >( this ) );
710 0 : m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt );
711 : }
712 0 : Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
713 0 : if ( xBroadcaster.is() )
714 0 : xBroadcaster->removeSQLErrorListener( this );
715 0 : }
716 :
717 0 : void OGridControlModel::implRemoved(const InterfaceRef& _rxObject)
718 : {
719 0 : OInterfaceContainer::implRemoved(_rxObject);
720 0 : lostColumn(_rxObject);
721 0 : }
722 :
723 0 : void OGridControlModel::implInserted( const ElementDescription* _pElement )
724 : {
725 0 : OInterfaceContainer::implInserted( _pElement );
726 0 : gotColumn( _pElement->xInterface );
727 0 : }
728 :
729 0 : void OGridControlModel::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock )
730 : {
731 0 : Reference< XInterface > xOldColumn( _rEvent.ReplacedElement, UNO_QUERY );
732 0 : Reference< XInterface > xNewColumn( _rEvent.Element, UNO_QUERY );
733 0 : bool bNewSelection = ( xOldColumn == m_xSelection );
734 0 : lostColumn( xOldColumn );
735 0 : gotColumn( xNewColumn );
736 0 : if ( bNewSelection )
737 0 : m_xSelection.set( xNewColumn, UNO_QUERY );
738 0 : OInterfaceContainer::impl_replacedElement( _rEvent, _rInstanceLock );
739 : // < SYNCHRONIZED
740 0 : if ( bNewSelection )
741 : {
742 0 : m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
743 0 : }
744 0 : }
745 :
746 0 : ElementDescription* OGridControlModel::createElementMetaData( )
747 : {
748 0 : return new ColumnDescription;
749 : }
750 :
751 0 : void OGridControlModel::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement )
752 : {
753 0 : OGridColumn* pCol = getColumnImplementation( _rxObject );
754 0 : if ( !pCol )
755 0 : throw IllegalArgumentException();
756 0 : OInterfaceContainer::approveNewElement( _rxObject, _pElement );
757 : // if we're here, the object passed all tests
758 0 : if ( _pElement )
759 0 : static_cast< ColumnDescription* >( _pElement )->pColumn = pCol;
760 0 : }
761 :
762 : // XPersistObject
763 0 : OUString SAL_CALL OGridControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
764 : {
765 0 : return OUString(FRM_COMPONENT_GRID); // old (non-sun) name for compatibility!
766 : }
767 :
768 0 : void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
769 : {
770 0 : OControlModel::write(_rxOutStream);
771 0 : Reference<XMarkableStream> xMark(_rxOutStream, UNO_QUERY);
772 : // 1. Version
773 0 : _rxOutStream->writeShort(0x0008);
774 : // 2. Columns
775 0 : sal_Int32 nLen = getCount();
776 0 : _rxOutStream->writeLong(nLen);
777 : OGridColumn* pCol;
778 0 : for (sal_Int32 i = 0; i < nLen; i++)
779 : {
780 : // first the service name for the unerlying model
781 0 : pCol = getColumnImplementation(m_aItems[i]);
782 : DBG_ASSERT(pCol != NULL, "OGridControlModel::write : such items should never reach it into my container !");
783 0 : _rxOutStream << pCol->getModelName();
784 : // then the object itself
785 0 : sal_Int32 nMark = xMark->createMark();
786 0 : sal_Int32 nObjLen = 0;
787 0 : _rxOutStream->writeLong(nObjLen);
788 : // writing the column
789 0 : pCol->write(_rxOutStream);
790 : // determining the length
791 0 : nObjLen = xMark->offsetToMark(nMark) - 4;
792 0 : xMark->jumpToMark(nMark);
793 0 : _rxOutStream->writeLong(nObjLen);
794 0 : xMark->jumpToFurthest();
795 0 : xMark->deleteMark(nMark);
796 : }
797 : // 3. Events
798 0 : writeEvents(_rxOutStream);
799 : // 4. Attributes
800 : // Masking for all 'any' types
801 0 : sal_uInt16 nAnyMask = 0;
802 0 : if (m_aRowHeight.getValueType().getTypeClass() == TypeClass_LONG)
803 0 : nAnyMask |= ROWHEIGHT;
804 0 : if ( getFont() != getDefaultFont() )
805 0 : nAnyMask |= FONTATTRIBS | FONTSIZE | FONTTYPE | FONTDESCRIPTOR;
806 0 : if (m_aTabStop.getValueType().getTypeClass() == TypeClass_BOOLEAN)
807 0 : nAnyMask |= TABSTOP;
808 0 : if ( hasTextColor() )
809 0 : nAnyMask |= TEXTCOLOR;
810 0 : if (m_aBackgroundColor.getValueType().getTypeClass() == TypeClass_LONG)
811 0 : nAnyMask |= BACKGROUNDCOLOR;
812 0 : if (!m_bRecordMarker)
813 0 : nAnyMask |= RECORDMARKER;
814 0 : _rxOutStream->writeShort(nAnyMask);
815 0 : if (nAnyMask & ROWHEIGHT)
816 0 : _rxOutStream->writeLong(getINT32(m_aRowHeight));
817 : // old structures
818 0 : const FontDescriptor& aFont = getFont();
819 0 : if ( nAnyMask & FONTDESCRIPTOR )
820 : {
821 : // Attrib
822 0 : _rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWeight( aFont.Weight ) ) );
823 0 : _rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( aFont.Slant ) );
824 0 : _rxOutStream->writeShort( aFont.Underline );
825 0 : _rxOutStream->writeShort( aFont.Strikeout );
826 0 : _rxOutStream->writeShort( sal_Int16(aFont.Orientation * 10) );
827 0 : _rxOutStream->writeBoolean( aFont.Kerning );
828 0 : _rxOutStream->writeBoolean( aFont.WordLineMode );
829 : // Size
830 0 : _rxOutStream->writeLong( aFont.Width );
831 0 : _rxOutStream->writeLong( aFont.Height );
832 0 : _rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWidth( aFont.CharacterWidth ) ) );
833 : // Type
834 0 : _rxOutStream->writeUTF( aFont.Name );
835 0 : _rxOutStream->writeUTF( aFont.StyleName );
836 0 : _rxOutStream->writeShort( aFont.Family );
837 0 : _rxOutStream->writeShort( aFont.CharSet );
838 0 : _rxOutStream->writeShort( aFont.Pitch );
839 : }
840 0 : _rxOutStream << m_aDefaultControl;
841 0 : _rxOutStream->writeShort(m_nBorder);
842 0 : _rxOutStream->writeBoolean(m_bEnable);
843 0 : if (nAnyMask & TABSTOP)
844 0 : _rxOutStream->writeBoolean(getBOOL(m_aTabStop));
845 0 : _rxOutStream->writeBoolean(m_bNavigation);
846 0 : if (nAnyMask & TEXTCOLOR)
847 0 : _rxOutStream->writeLong( getTextColor() );
848 : // new since version 6
849 0 : _rxOutStream << m_sHelpText;
850 0 : if (nAnyMask & FONTDESCRIPTOR)
851 0 : _rxOutStream << getFont();
852 0 : if (nAnyMask & RECORDMARKER)
853 0 : _rxOutStream->writeBoolean(m_bRecordMarker);
854 : // new since version 7
855 0 : _rxOutStream->writeBoolean(m_bPrintable);
856 : // new since version 8
857 0 : if (nAnyMask & BACKGROUNDCOLOR)
858 0 : _rxOutStream->writeLong(getINT32(m_aBackgroundColor));
859 0 : }
860 :
861 0 : void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
862 : {
863 0 : SolarMutexGuard g;
864 0 : OControlModel::read(_rxInStream);
865 0 : Reference<XMarkableStream> xMark(_rxInStream, UNO_QUERY);
866 : // 1. version
867 0 : sal_Int16 nVersion = _rxInStream->readShort();
868 : // 2. reading the columns
869 0 : sal_Int32 nLen = _rxInStream->readLong();
870 0 : if (nLen)
871 : {
872 0 : for (sal_Int32 i = 0; i < nLen; i++)
873 : {
874 : // reading the model names
875 0 : OUString sModelName;
876 0 : _rxInStream >> sModelName;
877 0 : Reference<XPropertySet> xCol(createColumn(getColumnTypeByModelName(sModelName)));
878 : DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column type !");
879 0 : sal_Int32 nObjLen = _rxInStream->readLong();
880 0 : if (nObjLen)
881 : {
882 0 : sal_Int32 nMark = xMark->createMark();
883 0 : if (xCol.is())
884 : {
885 0 : OGridColumn* pCol = getColumnImplementation(xCol);
886 0 : pCol->read(_rxInStream);
887 : }
888 0 : xMark->jumpToMark(nMark);
889 0 : _rxInStream->skipBytes(nObjLen);
890 0 : xMark->deleteMark(nMark);
891 : }
892 0 : if ( xCol.is() )
893 0 : implInsert( i, xCol, sal_False, NULL, sal_False );
894 0 : }
895 : }
896 : // In the base implementation events are only read, elements in the container exist
897 : // but since before TF_ONE for the GridControl events were always written, so they
898 : // need to be read, too
899 0 : sal_Int32 nObjLen = _rxInStream->readLong();
900 0 : if (nObjLen)
901 : {
902 0 : sal_Int32 nMark = xMark->createMark();
903 0 : Reference<XPersistObject> xObj(m_xEventAttacher, UNO_QUERY);
904 0 : if (xObj.is())
905 0 : xObj->read(_rxInStream);
906 0 : xMark->jumpToMark(nMark);
907 0 : _rxInStream->skipBytes(nObjLen);
908 0 : xMark->deleteMark(nMark);
909 : }
910 : // reading the attachement
911 0 : for (sal_Int32 i = 0; i < nLen; i++)
912 : {
913 0 : InterfaceRef xIfc(m_aItems[i], UNO_QUERY);
914 0 : Reference<XPropertySet> xSet(xIfc, UNO_QUERY);
915 0 : Any aHelper;
916 0 : aHelper <<= xSet;
917 0 : m_xEventAttacher->attach( i, xIfc, aHelper );
918 0 : }
919 : // 4. reading the attributes
920 0 : if (nVersion == 1)
921 0 : return;
922 : // Masking for any
923 0 : sal_uInt16 nAnyMask = _rxInStream->readShort();
924 0 : if (nAnyMask & ROWHEIGHT)
925 : {
926 0 : sal_Int32 nValue = _rxInStream->readLong();
927 0 : m_aRowHeight <<= (sal_Int32)nValue;
928 : }
929 0 : FontDescriptor aFont( getFont() );
930 0 : if ( nAnyMask & FONTATTRIBS )
931 : {
932 0 : aFont.Weight = (float)VCLUnoHelper::ConvertFontWeight( _rxInStream->readShort() );
933 0 : aFont.Slant = (FontSlant)_rxInStream->readShort();
934 0 : aFont.Underline = _rxInStream->readShort();
935 0 : aFont.Strikeout = _rxInStream->readShort();
936 0 : aFont.Orientation = ( (float)_rxInStream->readShort() ) / 10;
937 0 : aFont.Kerning = _rxInStream->readBoolean();
938 0 : aFont.WordLineMode = _rxInStream->readBoolean();
939 : }
940 0 : if ( nAnyMask & FONTSIZE )
941 : {
942 0 : aFont.Width = (sal_Int16)_rxInStream->readLong();
943 0 : aFont.Height = (sal_Int16)_rxInStream->readLong();
944 0 : aFont.CharacterWidth = (float)VCLUnoHelper::ConvertFontWidth( _rxInStream->readShort() );
945 : }
946 0 : if ( nAnyMask & FONTTYPE )
947 : {
948 0 : aFont.Name = _rxInStream->readUTF();
949 0 : aFont.StyleName = _rxInStream->readUTF();
950 0 : aFont.Family = _rxInStream->readShort();
951 0 : aFont.CharSet = _rxInStream->readShort();
952 0 : aFont.Pitch = _rxInStream->readShort();
953 : }
954 0 : if ( nAnyMask & ( FONTATTRIBS | FONTSIZE | FONTTYPE ) )
955 0 : setFont( aFont );
956 : // Name
957 0 : _rxInStream >> m_aDefaultControl;
958 0 : m_nBorder = _rxInStream->readShort();
959 0 : m_bEnable = _rxInStream->readBoolean();
960 0 : if (nAnyMask & TABSTOP)
961 : {
962 0 : m_aTabStop = makeBoolAny(_rxInStream->readBoolean() != 0);
963 : }
964 0 : if (nVersion > 3)
965 0 : m_bNavigation = _rxInStream->readBoolean();
966 0 : if (nAnyMask & TEXTCOLOR)
967 : {
968 0 : sal_Int32 nValue = _rxInStream->readLong();
969 0 : setTextColor( (sal_Int32)nValue );
970 : }
971 : // new since version 6
972 0 : if (nVersion > 5)
973 0 : _rxInStream >> m_sHelpText;
974 0 : if (nAnyMask & FONTDESCRIPTOR)
975 : {
976 0 : FontDescriptor aUNOFont;
977 0 : _rxInStream >> aUNOFont;
978 0 : setFont( aFont );
979 : }
980 0 : if (nAnyMask & RECORDMARKER)
981 0 : m_bRecordMarker = _rxInStream->readBoolean();
982 : // new since version 7
983 0 : if (nVersion > 6)
984 0 : m_bPrintable = _rxInStream->readBoolean();
985 0 : if (nAnyMask & BACKGROUNDCOLOR)
986 : {
987 0 : sal_Int32 nValue = _rxInStream->readLong();
988 0 : m_aBackgroundColor <<= (sal_Int32)nValue;
989 0 : }
990 : }
991 : }
992 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|