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