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