1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "errorbroadcaster.hxx" 25 #include "FormComponent.hxx" 26 #include "formcontrolfont.hxx" 27 #include "InterfaceContainer.hxx" 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/form/XGridColumnFactory.hpp> 31 #include <com/sun/star/form/XLoadable.hpp> 32 #include <com/sun/star/sdb/XRowSetSupplier.hpp> 33 #include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp> 34 #include <com/sun/star/view/XSelectionSupplier.hpp> 35 /** === end UNO includes === **/ 36 37 #include <comphelper/proparrhlp.hxx> 38 #include <cppuhelper/implbase7.hxx> 39 #include <tools/link.hxx> 40 41 //......................................................................... 42 namespace frm 43 { 44 //......................................................................... 45 46 class OGridColumn; 47 48 //================================================================== 49 // ColumnDescription 50 //================================================================== 51 52 struct ColumnDescription : public ElementDescription 53 { 54 public: 55 OGridColumn* pColumn; // not owned by this instance! only to prevent duplicate XUnoTunnel usage 56 }; 57 58 //================================================================== 59 // OGridControlModel 60 //================================================================== 61 typedef ::cppu::ImplHelper7 < ::com::sun::star::awt::XControlModel 62 , ::com::sun::star::form::XGridColumnFactory 63 , ::com::sun::star::form::XReset 64 , ::com::sun::star::view::XSelectionSupplier 65 , ::com::sun::star::sdb::XSQLErrorListener 66 , ::com::sun::star::sdb::XRowSetSupplier 67 , ::com::sun::star::sdb::XRowSetChangeBroadcaster 68 > OGridControlModel_BASE; 69 70 class OGridControlModel :public OControlModel 71 ,public OInterfaceContainer 72 ,public OErrorBroadcaster 73 ,public FontControlModel 74 ,public OGridControlModel_BASE 75 { 76 ::cppu::OInterfaceContainerHelper m_aSelectListeners, 77 m_aResetListeners, 78 m_aRowSetChangeListeners; 79 80 // [properties] 81 ::com::sun::star::uno::Any m_aRowHeight; // Zeilenhoehe 82 ::com::sun::star::uno::Any m_aTabStop; 83 ::com::sun::star::uno::Any m_aBackgroundColor; 84 ::com::sun::star::uno::Any m_aCursorColor; // transient 85 ::com::sun::star::uno::Any m_aBorderColor; 86 ::rtl::OUString m_aDefaultControl; 87 ::rtl::OUString m_sHelpText; 88 // [properties] 89 90 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSelection; 91 92 // [properties] 93 ::rtl::OUString m_sHelpURL; // URL 94 sal_Int16 m_nBorder; 95 sal_Int16 m_nWritingMode; 96 sal_Int16 m_nContextWritingMode; 97 sal_Bool m_bEnableVisible : 1; 98 sal_Bool m_bEnable : 1; 99 sal_Bool m_bNavigation : 1; 100 sal_Bool m_bRecordMarker : 1; 101 sal_Bool m_bPrintable : 1; 102 sal_Bool m_bAlwaysShowCursor : 1; // transient 103 sal_Bool m_bDisplaySynchron : 1; // transient 104 // [properties] 105 106 protected: 107 void _reset(); 108 109 public: 110 DECLARE_DEFAULT_LEAF_XTOR( OGridControlModel ); 111 112 // UNO Anbindung 113 DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OControlModel); 114 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ); 115 116 // XChild 117 virtual void SAL_CALL setParent(const InterfaceRef& Parent); 118 119 // XServiceInfo 120 IMPLEMENTATION_NAME(OGridControlModel); 121 virtual StringSequence SAL_CALL getSupportedServiceNames(); 122 123 // XTypeProvider 124 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ); 125 126 // OComponentHelper 127 virtual void SAL_CALL disposing(); 128 129 // XEventListener 130 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource); 131 132 // XReset 133 virtual void SAL_CALL reset(); 134 virtual void SAL_CALL addResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener); 135 virtual void SAL_CALL removeResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener); 136 137 // XSelectionSupplier 138 virtual sal_Bool SAL_CALL select(const ::com::sun::star::uno::Any& aElement); 139 virtual ::com::sun::star::uno::Any SAL_CALL getSelection(); 140 virtual void SAL_CALL addSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener); 141 virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener); 142 143 // XGridColumnFactory 144 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> SAL_CALL createColumn(const ::rtl::OUString& ColumnType); 145 virtual StringSequence SAL_CALL getColumnTypes(); 146 147 // XPersistObject 148 virtual ::rtl::OUString SAL_CALL getServiceName(); 149 virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); 150 virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream); 151 152 // XPropertySet 153 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 154 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue, 155 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ); 156 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue); 157 158 // XPropertyState 159 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const; 160 161 // XSQLErrorListener 162 virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent ); 163 164 // XRowSetSupplier 165 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getRowSet( ); 166 virtual void SAL_CALL setRowSet( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xDataSource ); 167 168 // XRowSetChangeBroadcaster 169 virtual void SAL_CALL addRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ); 170 virtual void SAL_CALL removeRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ); 171 172 // OControlModel's property handling 173 virtual void describeFixedProperties( 174 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 175 ) const; 176 177 // prevent method hiding 178 using OControlModel::disposing; 179 using OControlModel::getFastPropertyValue; 180 181 protected: 182 DECLARE_XCLONEABLE(); 183 184 protected: 185 virtual void approveNewElement( 186 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject, 187 ElementDescription* _pElement 188 ); 189 190 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createColumn(sal_Int32 nTypeId) const; 191 192 OGridColumn* getColumnImplementation(const InterfaceRef& _rxIFace) const; 193 194 virtual ElementDescription* createElementMetaData( ); 195 196 protected: 197 virtual void implRemoved(const InterfaceRef& _rxObject); 198 virtual void implInserted( const ElementDescription* _pElement ); 199 virtual void impl_replacedElement( 200 const ::com::sun::star::container::ContainerEvent& _rEvent, 201 ::osl::ClearableMutexGuard& _rInstanceLock 202 ); 203 204 void gotColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); 205 void lostColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); 206 207 void cloneColumns( const OGridControlModel* _pOriginalContainer ); 208 }; 209 210 //......................................................................... 211 } // namespace frm 212 //......................................................................... 213