1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Grid.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "errorbroadcaster.hxx"
32 #include "FormComponent.hxx"
33 #include "formcontrolfont.hxx"
34 #include "InterfaceContainer.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/form/XGridColumnFactory.hpp>
38 #include <com/sun/star/form/XLoadable.hpp>
39 #include <com/sun/star/sdb/XRowSetSupplier.hpp>
40 #include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp>
41 #include <com/sun/star/view/XSelectionSupplier.hpp>
42 /** === end UNO includes === **/
44 #include <comphelper/proparrhlp.hxx>
45 #include <cppuhelper/implbase7.hxx>
46 #include <tools/link.hxx>
48 //.........................................................................
51 //.........................................................................
55 //==================================================================
57 //==================================================================
59 struct ColumnDescription
: public ElementDescription
62 OGridColumn
* pColumn
; // not owned by this instance! only to prevent duplicate XUnoTunnel usage
65 //==================================================================
67 //==================================================================
68 typedef ::cppu::ImplHelper7
< ::com::sun::star::awt::XControlModel
69 , ::com::sun::star::form::XGridColumnFactory
70 , ::com::sun::star::form::XReset
71 , ::com::sun::star::view::XSelectionSupplier
72 , ::com::sun::star::sdb::XSQLErrorListener
73 , ::com::sun::star::sdb::XRowSetSupplier
74 , ::com::sun::star::sdb::XRowSetChangeBroadcaster
75 > OGridControlModel_BASE
;
77 class OGridControlModel
:public OControlModel
78 ,public OInterfaceContainer
79 ,public OErrorBroadcaster
80 ,public FontControlModel
81 ,public OGridControlModel_BASE
83 ::cppu::OInterfaceContainerHelper m_aSelectListeners
,
85 m_aRowSetChangeListeners
;
88 ::com::sun::star::uno::Any m_aRowHeight
; // Zeilenhoehe
89 ::com::sun::star::uno::Any m_aTabStop
;
90 ::com::sun::star::uno::Any m_aBackgroundColor
;
91 ::com::sun::star::uno::Any m_aCursorColor
; // transient
92 ::com::sun::star::uno::Any m_aBorderColor
;
93 ::rtl::OUString m_aDefaultControl
;
94 ::rtl::OUString m_sHelpText
;
97 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xSelection
;
100 ::rtl::OUString m_sHelpURL
; // URL
102 sal_Int16 m_nWritingMode
;
103 sal_Int16 m_nContextWritingMode
;
104 sal_Bool m_bEnableVisible
: 1;
105 sal_Bool m_bEnable
: 1;
106 sal_Bool m_bNavigation
: 1;
107 sal_Bool m_bRecordMarker
: 1;
108 sal_Bool m_bPrintable
: 1;
109 sal_Bool m_bAlwaysShowCursor
: 1; // transient
110 sal_Bool m_bDisplaySynchron
: 1; // transient
117 DECLARE_DEFAULT_LEAF_XTOR( OGridControlModel
);
120 DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel
, OControlModel
);
121 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
124 virtual void SAL_CALL
setParent(const InterfaceRef
& Parent
) throw(::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
);
127 IMPLEMENTATION_NAME(OGridControlModel
);
128 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
131 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
134 virtual void SAL_CALL
disposing();
137 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& _rSource
) throw(::com::sun::star::uno::RuntimeException
);
140 virtual void SAL_CALL
reset() throw ( ::com::sun::star::uno::RuntimeException
);
141 virtual void SAL_CALL
addResetListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XResetListener
>& _rxListener
) throw ( ::com::sun::star::uno::RuntimeException
);
142 virtual void SAL_CALL
removeResetListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XResetListener
>& _rxListener
) throw ( ::com::sun::star::uno::RuntimeException
);
144 // XSelectionSupplier
145 virtual sal_Bool SAL_CALL
select(const ::com::sun::star::uno::Any
& aElement
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
146 virtual ::com::sun::star::uno::Any SAL_CALL
getSelection() throw(::com::sun::star::uno::RuntimeException
);
147 virtual void SAL_CALL
addSelectionChangeListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
148 virtual void SAL_CALL
removeSelectionChangeListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
150 // XGridColumnFactory
151 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
createColumn(const ::rtl::OUString
& ColumnType
) throw ( :: com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
152 virtual StringSequence SAL_CALL
getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException
);
155 virtual ::rtl::OUString SAL_CALL
getServiceName() throw ( ::com::sun::star::uno::RuntimeException
);
156 virtual void SAL_CALL
write(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
) throw ( ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
157 virtual void SAL_CALL
read(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
) throw ( ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
160 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
161 virtual sal_Bool SAL_CALL
convertFastPropertyValue(::com::sun::star::uno::Any
& rConvertedValue
, ::com::sun::star::uno::Any
& rOldValue
,
162 sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
)
163 throw(::com::sun::star::lang::IllegalArgumentException
);
164 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw ( ::com::sun::star::uno::Exception
);
167 virtual ::com::sun::star::uno::Any
getPropertyDefaultByHandle( sal_Int32 nHandle
) const;
170 virtual void SAL_CALL
errorOccured( const ::com::sun::star::sdb::SQLErrorEvent
& _rEvent
) throw (::com::sun::star::uno::RuntimeException
);
173 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
> SAL_CALL
getRowSet( ) throw (::com::sun::star::uno::RuntimeException
);
174 virtual void SAL_CALL
setRowSet( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& xDataSource
) throw (::com::sun::star::uno::RuntimeException
);
176 // XRowSetChangeBroadcaster
177 virtual void SAL_CALL
addRowSetChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XRowSetChangeListener
>& i_Listener
) throw (::com::sun::star::uno::RuntimeException
);
178 virtual void SAL_CALL
removeRowSetChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XRowSetChangeListener
>& i_Listener
) throw (::com::sun::star::uno::RuntimeException
);
180 // OControlModel's property handling
181 virtual void describeFixedProperties(
182 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rProps
185 // prevent method hiding
186 using OControlModel::disposing
;
187 using OControlModel::getFastPropertyValue
;
190 DECLARE_XCLONEABLE();
193 virtual void approveNewElement(
194 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxObject
,
195 ElementDescription
* _pElement
198 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> createColumn(sal_Int32 nTypeId
) const;
200 OGridColumn
* getColumnImplementation(const InterfaceRef
& _rxIFace
) const;
202 virtual ElementDescription
* createElementMetaData( );
205 virtual void implRemoved(const InterfaceRef
& _rxObject
);
206 virtual void implInserted( const ElementDescription
* _pElement
);
207 virtual void impl_replacedElement(
208 const ::com::sun::star::container::ContainerEvent
& _rEvent
,
209 ::osl::ClearableMutexGuard
& _rInstanceLock
212 void gotColumn(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxColumn
);
213 void lostColumn(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxColumn
);
215 void cloneColumns( const OGridControlModel
* _pOriginalContainer
);
218 //.........................................................................
220 //.........................................................................