1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX 28 #define FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX 29 30 #include "FormComponent.hxx" 31 #include "frm_module.hxx" 32 #include "formcontrolfont.hxx" 33 #include "richtextunowrapper.hxx" 34 #include <comphelper/propertycontainerhelper.hxx> 35 #include <comphelper/listenernotification.hxx> 36 37 /** === begin UNO includes === **/ 38 #include <com/sun/star/awt/XDevice.hpp> 39 #include <com/sun/star/util/XModifyBroadcaster.hpp> 40 /** === end UNO includes === **/ 41 #include <cppuhelper/implbase3.hxx> 42 #include <tools/link.hxx> 43 #include <memory> 44 45 class EditEngine; 46 //........................................................................ 47 namespace frm 48 { 49 //........................................................................ 50 51 class RichTextEngine; 52 //==================================================================== 53 //= ORichTextModel 54 //==================================================================== 55 typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XControlModel 56 , ::com::sun::star::lang::XUnoTunnel 57 , ::com::sun::star::util::XModifyBroadcaster 58 > ORichTextModel_BASE; 59 60 class ORichTextModel 61 :public OControlModel 62 ,public FontControlModel 63 ,public IEngineTextChangeListener 64 ,public ::comphelper::OPropertyContainerHelper 65 ,public ORichTextModel_BASE 66 { 67 private: 68 // <properties> 69 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > 70 m_xReferenceDevice; 71 ::com::sun::star::uno::Any m_aTabStop; 72 ::com::sun::star::uno::Any m_aBackgroundColor; 73 ::com::sun::star::uno::Any m_aBorderColor; 74 ::com::sun::star::uno::Any m_aVerticalAlignment; 75 ::rtl::OUString m_sDefaultControl; 76 ::rtl::OUString m_sHelpText; 77 ::rtl::OUString m_sHelpURL; 78 ::rtl::OUString m_sLastKnownEngineText; 79 sal_Int16 m_nLineEndFormat; 80 sal_Int16 m_nTextWritingMode; 81 sal_Int16 m_nContextWritingMode; 82 sal_Int16 m_nBorder; 83 sal_Bool m_bEnabled; 84 sal_Bool m_bEnableVisible; 85 sal_Bool m_bHardLineBreaks; 86 sal_Bool m_bHScroll; 87 sal_Bool m_bVScroll; 88 sal_Bool m_bReadonly; 89 sal_Bool m_bPrintable; 90 sal_Bool m_bReallyActAsRichText; // despite the class name, the RichTextControl later on 91 // will create "ordinary" text peers depending on this property 92 sal_Bool m_bHideInactiveSelection; 93 // </properties> 94 95 // <properties_for_awt_edit_compatibility> 96 ::com::sun::star::uno::Any m_aAlign; 97 sal_Int16 m_nEchoChar; 98 sal_Int16 m_nMaxTextLength; 99 sal_Bool m_bMultiLine; 100 // </properties_for_awt_edit_compatibility> 101 102 ::std::auto_ptr<RichTextEngine> 103 m_pEngine; 104 bool m_bSettingEngineText; 105 106 ::cppu::OInterfaceContainerHelper 107 m_aModifyListeners; 108 109 public: 110 static RichTextEngine* getEditEngine( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ); 111 112 protected: 113 DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel ); 114 115 // UNO 116 DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel ); 117 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); 118 119 // XServiceInfo 120 DECLARE_SERVICE_REGISTRATION( ORichTextModel ) 121 122 // XPersistObject 123 DECLARE_XPERSISTOBJECT() 124 125 // XTypeProvider 126 DECLARE_XTYPEPROVIDER() 127 128 // XCloneable 129 DECLARE_XCLONEABLE(); 130 131 // XUnoTunnel 132 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException); 133 134 // XModifyBroadcaster 135 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 136 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 137 138 // XPropertySet and friends 139 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 140 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue, 141 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 142 throw(::com::sun::star::lang::IllegalArgumentException); 143 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception); 144 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const; 145 146 // OControlModel's property handling 147 virtual void describeFixedProperties( 148 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 149 ) const; 150 virtual void describeAggregateProperties( 151 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps 152 ) const; 153 154 // prevent method hiding 155 using OControlModel::disposing; 156 using OControlModel::getFastPropertyValue; 157 158 // OComponentHelper 159 virtual void SAL_CALL disposing(); 160 161 // IEngineTextChangeListener 162 virtual void potentialTextChange( ); 163 164 private: 165 void implInit(); 166 void implDoAggregation(); 167 void implRegisterProperties(); 168 169 /** propagates a new text to the EditEngine 170 171 This method needs to lock the global solar mutex, so our own mutex must not 172 be locked when calling. 173 174 @precond 175 our mutex is not locked 176 */ 177 void impl_smlock_setEngineText( const ::rtl::OUString& _rText ); 178 179 DECL_LINK( OnEngineContentModified, void* ); 180 181 static ::com::sun::star::uno::Sequence< sal_Int8 > getEditEngineTunnelId(); 182 183 private: 184 ORichTextModel(); // never implemented 185 ORichTextModel( const ORichTextModel& ); // never implemented 186 ORichTextModel& operator=( const ORichTextModel& ); // never implemented 187 }; 188 189 //........................................................................ 190 } // namespace frm 191 //........................................................................ 192 193 #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX 194 195