1*2d785d7eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2d785d7eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2d785d7eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2d785d7eSAndrew Rist  * distributed with this work for additional information
6*2d785d7eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2d785d7eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2d785d7eSAndrew Rist  * "License"); you may not use this file except in compliance
9*2d785d7eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2d785d7eSAndrew Rist  *
11*2d785d7eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2d785d7eSAndrew Rist  *
13*2d785d7eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2d785d7eSAndrew Rist  * software distributed under the License is distributed on an
15*2d785d7eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2d785d7eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2d785d7eSAndrew Rist  * specific language governing permissions and limitations
18*2d785d7eSAndrew Rist  * under the License.
19*2d785d7eSAndrew Rist  *
20*2d785d7eSAndrew Rist  *************************************************************/
21*2d785d7eSAndrew Rist 
22*2d785d7eSAndrew Rist 
23cdf0e10cSrcweir #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX
24cdf0e10cSrcweir #define FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "FormComponent.hxx"
27cdf0e10cSrcweir #include "frm_module.hxx"
28cdf0e10cSrcweir #include "formcontrolfont.hxx"
29cdf0e10cSrcweir #include "richtextunowrapper.hxx"
30cdf0e10cSrcweir #include <comphelper/propertycontainerhelper.hxx>
31cdf0e10cSrcweir #include <comphelper/listenernotification.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /** === begin UNO includes === **/
34cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp>
35cdf0e10cSrcweir #include <com/sun/star/util/XModifyBroadcaster.hpp>
36cdf0e10cSrcweir /** === end UNO includes === **/
37cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
38cdf0e10cSrcweir #include <tools/link.hxx>
39cdf0e10cSrcweir #include <memory>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class EditEngine;
42cdf0e10cSrcweir //........................................................................
43cdf0e10cSrcweir namespace frm
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //........................................................................
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     class RichTextEngine;
48cdf0e10cSrcweir     //====================================================================
49cdf0e10cSrcweir     //= ORichTextModel
50cdf0e10cSrcweir     //====================================================================
51cdf0e10cSrcweir     typedef ::cppu::ImplHelper3 <   ::com::sun::star::awt::XControlModel
52cdf0e10cSrcweir                                 ,   ::com::sun::star::lang::XUnoTunnel
53cdf0e10cSrcweir                                 ,   ::com::sun::star::util::XModifyBroadcaster
54cdf0e10cSrcweir                                 >   ORichTextModel_BASE;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     class ORichTextModel
57cdf0e10cSrcweir             :public OControlModel
58cdf0e10cSrcweir             ,public FontControlModel
59cdf0e10cSrcweir             ,public IEngineTextChangeListener
60cdf0e10cSrcweir             ,public ::comphelper::OPropertyContainerHelper
61cdf0e10cSrcweir             ,public ORichTextModel_BASE
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir     private:
64cdf0e10cSrcweir         // <properties>
65cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice >
66cdf0e10cSrcweir                                     m_xReferenceDevice;
67cdf0e10cSrcweir         ::com::sun::star::uno::Any  m_aTabStop;
68cdf0e10cSrcweir         ::com::sun::star::uno::Any  m_aBackgroundColor;
69cdf0e10cSrcweir         ::com::sun::star::uno::Any  m_aBorderColor;
70cdf0e10cSrcweir         ::com::sun::star::uno::Any  m_aVerticalAlignment;
71cdf0e10cSrcweir         ::rtl::OUString             m_sDefaultControl;
72cdf0e10cSrcweir         ::rtl::OUString             m_sHelpText;
73cdf0e10cSrcweir         ::rtl::OUString             m_sHelpURL;
74cdf0e10cSrcweir         ::rtl::OUString             m_sLastKnownEngineText;
75cdf0e10cSrcweir         sal_Int16                   m_nLineEndFormat;
76cdf0e10cSrcweir         sal_Int16                   m_nTextWritingMode;
77cdf0e10cSrcweir         sal_Int16                   m_nContextWritingMode;
78cdf0e10cSrcweir         sal_Int16                   m_nBorder;
79cdf0e10cSrcweir         sal_Bool                    m_bEnabled;
80cdf0e10cSrcweir         sal_Bool                    m_bEnableVisible;
81cdf0e10cSrcweir         sal_Bool                    m_bHardLineBreaks;
82cdf0e10cSrcweir         sal_Bool                    m_bHScroll;
83cdf0e10cSrcweir         sal_Bool                    m_bVScroll;
84cdf0e10cSrcweir         sal_Bool                    m_bReadonly;
85cdf0e10cSrcweir         sal_Bool                    m_bPrintable;
86cdf0e10cSrcweir         sal_Bool                    m_bReallyActAsRichText; // despite the class name, the RichTextControl later on
87cdf0e10cSrcweir                                                             // will create "ordinary" text peers depending on this property
88cdf0e10cSrcweir         sal_Bool                    m_bHideInactiveSelection;
89cdf0e10cSrcweir         // </properties>
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         // <properties_for_awt_edit_compatibility>
92cdf0e10cSrcweir         ::com::sun::star::uno::Any  m_aAlign;
93cdf0e10cSrcweir         sal_Int16                   m_nEchoChar;
94cdf0e10cSrcweir         sal_Int16                   m_nMaxTextLength;
95cdf0e10cSrcweir         sal_Bool                    m_bMultiLine;
96cdf0e10cSrcweir         // </properties_for_awt_edit_compatibility>
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         ::std::auto_ptr<RichTextEngine>
99cdf0e10cSrcweir                                     m_pEngine;
100cdf0e10cSrcweir         bool                        m_bSettingEngineText;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         ::cppu::OInterfaceContainerHelper
103cdf0e10cSrcweir                                     m_aModifyListeners;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     public:
106cdf0e10cSrcweir         static  RichTextEngine* getEditEngine( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     protected:
109cdf0e10cSrcweir         DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         // UNO
112cdf0e10cSrcweir         DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel );
113cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         // XServiceInfo
116cdf0e10cSrcweir         DECLARE_SERVICE_REGISTRATION( ORichTextModel )
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         // XPersistObject
119cdf0e10cSrcweir         DECLARE_XPERSISTOBJECT()
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         // XTypeProvider
122cdf0e10cSrcweir         DECLARE_XTYPEPROVIDER()
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         // XCloneable
125cdf0e10cSrcweir         DECLARE_XCLONEABLE();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         // XUnoTunnel
128cdf0e10cSrcweir         virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         // XModifyBroadcaster
131cdf0e10cSrcweir         virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
132cdf0e10cSrcweir         virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         // XPropertySet and friends
135cdf0e10cSrcweir         virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
136cdf0e10cSrcweir         virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
137cdf0e10cSrcweir                                             sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
138cdf0e10cSrcweir                                         throw(::com::sun::star::lang::IllegalArgumentException);
139cdf0e10cSrcweir         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
140cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         // OControlModel's property handling
143cdf0e10cSrcweir 	    virtual void describeFixedProperties(
144cdf0e10cSrcweir             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
145cdf0e10cSrcweir         ) const;
146cdf0e10cSrcweir         virtual void describeAggregateProperties(
147cdf0e10cSrcweir 		    ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
148cdf0e10cSrcweir         ) const;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         // prevent method hiding
151cdf0e10cSrcweir         using OControlModel::disposing;
152cdf0e10cSrcweir         using OControlModel::getFastPropertyValue;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         // OComponentHelper
155cdf0e10cSrcweir         virtual void SAL_CALL disposing();
156cdf0e10cSrcweir 
157cdf0e10cSrcweir         // IEngineTextChangeListener
158cdf0e10cSrcweir         virtual void potentialTextChange( );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     private:
161cdf0e10cSrcweir         void    implInit();
162cdf0e10cSrcweir         void    implDoAggregation();
163cdf0e10cSrcweir         void    implRegisterProperties();
164cdf0e10cSrcweir 
165cdf0e10cSrcweir         /** propagates a new text to the EditEngine
166cdf0e10cSrcweir 
167cdf0e10cSrcweir             This method needs to lock the global solar mutex, so our own mutex must not
168cdf0e10cSrcweir             be locked when calling.
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         @precond
171cdf0e10cSrcweir             our mutex is not locked
172cdf0e10cSrcweir         */
173cdf0e10cSrcweir         void    impl_smlock_setEngineText( const ::rtl::OUString& _rText );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir         DECL_LINK( OnEngineContentModified, void* );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir         static  ::com::sun::star::uno::Sequence< sal_Int8 > getEditEngineTunnelId();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     private:
180cdf0e10cSrcweir         ORichTextModel();                                   // never implemented
181cdf0e10cSrcweir         ORichTextModel( const ORichTextModel& );            // never implemented
182cdf0e10cSrcweir         ORichTextModel& operator=( const ORichTextModel& ); // never implemented
183cdf0e10cSrcweir     };
184cdf0e10cSrcweir 
185cdf0e10cSrcweir //........................................................................
186cdf0e10cSrcweir } // namespace frm
187cdf0e10cSrcweir //........................................................................
188cdf0e10cSrcweir 
189cdf0e10cSrcweir #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX
190cdf0e10cSrcweir 
191