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 #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX 24 #define FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX 25 26 #include "FormComponent.hxx" 27 #include "frm_module.hxx" 28 #include "formcontrolfont.hxx" 29 #include "richtextunowrapper.hxx" 30 #include <comphelper/propertycontainerhelper.hxx> 31 #include <comphelper/listenernotification.hxx> 32 33 /** === begin UNO includes === **/ 34 #include <com/sun/star/awt/XDevice.hpp> 35 #include <com/sun/star/util/XModifyBroadcaster.hpp> 36 /** === end UNO includes === **/ 37 #include <cppuhelper/implbase3.hxx> 38 #include <tools/link.hxx> 39 #include <memory> 40 41 class EditEngine; 42 //........................................................................ 43 namespace frm 44 { 45 //........................................................................ 46 47 class RichTextEngine; 48 //==================================================================== 49 //= ORichTextModel 50 //==================================================================== 51 typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XControlModel 52 , ::com::sun::star::lang::XUnoTunnel 53 , ::com::sun::star::util::XModifyBroadcaster 54 > ORichTextModel_BASE; 55 56 class ORichTextModel 57 :public OControlModel 58 ,public FontControlModel 59 ,public IEngineTextChangeListener 60 ,public ::comphelper::OPropertyContainerHelper 61 ,public ORichTextModel_BASE 62 { 63 private: 64 // <properties> 65 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > 66 m_xReferenceDevice; 67 ::com::sun::star::uno::Any m_aTabStop; 68 ::com::sun::star::uno::Any m_aBackgroundColor; 69 ::com::sun::star::uno::Any m_aBorderColor; 70 ::com::sun::star::uno::Any m_aVerticalAlignment; 71 ::rtl::OUString m_sDefaultControl; 72 ::rtl::OUString m_sHelpText; 73 ::rtl::OUString m_sHelpURL; 74 ::rtl::OUString m_sLastKnownEngineText; 75 sal_Int16 m_nLineEndFormat; 76 sal_Int16 m_nTextWritingMode; 77 sal_Int16 m_nContextWritingMode; 78 sal_Int16 m_nBorder; 79 sal_Bool m_bEnabled; 80 sal_Bool m_bEnableVisible; 81 sal_Bool m_bHardLineBreaks; 82 sal_Bool m_bHScroll; 83 sal_Bool m_bVScroll; 84 sal_Bool m_bReadonly; 85 sal_Bool m_bPrintable; 86 sal_Bool m_bReallyActAsRichText; // despite the class name, the RichTextControl later on 87 // will create "ordinary" text peers depending on this property 88 sal_Bool m_bHideInactiveSelection; 89 // </properties> 90 91 // <properties_for_awt_edit_compatibility> 92 ::com::sun::star::uno::Any m_aAlign; 93 sal_Int16 m_nEchoChar; 94 sal_Int16 m_nMaxTextLength; 95 sal_Bool m_bMultiLine; 96 // </properties_for_awt_edit_compatibility> 97 98 ::std::auto_ptr<RichTextEngine> 99 m_pEngine; 100 bool m_bSettingEngineText; 101 102 ::cppu::OInterfaceContainerHelper 103 m_aModifyListeners; 104 105 public: 106 static RichTextEngine* getEditEngine( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ); 107 108 protected: 109 DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel ); 110 111 // UNO 112 DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel ); 113 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); 114 115 // XServiceInfo 116 DECLARE_SERVICE_REGISTRATION( ORichTextModel ) 117 118 // XPersistObject 119 DECLARE_XPERSISTOBJECT() 120 121 // XTypeProvider 122 DECLARE_XTYPEPROVIDER() 123 124 // XCloneable 125 DECLARE_XCLONEABLE(); 126 127 // XUnoTunnel 128 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException); 129 130 // XModifyBroadcaster 131 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 132 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 133 134 // XPropertySet and friends 135 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 136 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue, 137 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 138 throw(::com::sun::star::lang::IllegalArgumentException); 139 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception); 140 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const; 141 142 // OControlModel's property handling 143 virtual void describeFixedProperties( 144 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 145 ) const; 146 virtual void describeAggregateProperties( 147 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps 148 ) const; 149 150 // prevent method hiding 151 using OControlModel::disposing; 152 using OControlModel::getFastPropertyValue; 153 154 // OComponentHelper 155 virtual void SAL_CALL disposing(); 156 157 // IEngineTextChangeListener 158 virtual void potentialTextChange( ); 159 160 private: 161 void implInit(); 162 void implDoAggregation(); 163 void implRegisterProperties(); 164 165 /** propagates a new text to the EditEngine 166 167 This method needs to lock the global solar mutex, so our own mutex must not 168 be locked when calling. 169 170 @precond 171 our mutex is not locked 172 */ 173 void impl_smlock_setEngineText( const ::rtl::OUString& _rText ); 174 175 DECL_LINK( OnEngineContentModified, void* ); 176 177 static ::com::sun::star::uno::Sequence< sal_Int8 > getEditEngineTunnelId(); 178 179 private: 180 ORichTextModel(); // never implemented 181 ORichTextModel( const ORichTextModel& ); // never implemented 182 ORichTextModel& operator=( const ORichTextModel& ); // never implemented 183 }; 184 185 //........................................................................ 186 } // namespace frm 187 //........................................................................ 188 189 #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX 190 191