tdf#164493 Update script change algorithm to always make progress
[LibreOffice.git] / forms / source / richtext / richtextmodel.hxx
blobcf0bae7db4356b5e1cbae4c94f85ce189504d6d4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <FormComponent.hxx>
22 #include <formcontrolfont.hxx>
23 #include "richtextunowrapper.hxx"
24 #include <comphelper/interfacecontainer3.hxx>
25 #include <comphelper/propertycontainerhelper.hxx>
27 #include <com/sun/star/awt/XDevice.hpp>
28 #include <com/sun/star/util/XModifyBroadcaster.hpp>
29 #include <cppuhelper/implbase3.hxx>
30 #include <tools/link.hxx>
31 #include <memory>
33 class EditEngine;
35 namespace frm
39 class RichTextEngine;
41 //= ORichTextModel
43 typedef ::cppu::ImplHelper3 < css::awt::XControlModel
44 , css::lang::XUnoTunnel
45 , css::util::XModifyBroadcaster
46 > ORichTextModel_BASE;
48 class ORichTextModel
49 :public OControlModel
50 ,public FontControlModel
51 ,public IEngineTextChangeListener
52 ,public ::comphelper::OPropertyContainerHelper
53 ,public ORichTextModel_BASE
55 public:
56 ORichTextModel(
57 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
59 ORichTextModel(
60 const ORichTextModel* _pOriginal,
61 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
63 virtual ~ORichTextModel() override;
65 private:
66 // <properties>
67 css::uno::Reference< css::awt::XDevice >
68 m_xReferenceDevice;
69 css::uno::Any m_aTabStop;
70 css::uno::Any m_aBackgroundColor;
71 css::uno::Any m_aBorderColor;
72 css::uno::Any m_aVerticalAlignment;
73 OUString m_sDefaultControl;
74 OUString m_sHelpText;
75 OUString m_sHelpURL;
76 OUString m_sLastKnownEngineText;
77 sal_Int16 m_nLineEndFormat;
78 sal_Int16 m_nTextWritingMode;
79 sal_Int16 m_nContextWritingMode;
80 sal_Int16 m_nBorder;
81 bool m_bEnabled;
82 bool m_bEnableVisible;
83 bool m_bHardLineBreaks;
84 bool m_bHScroll;
85 bool m_bVScroll;
86 bool m_bReadonly;
87 bool m_bPrintable;
88 bool m_bReallyActAsRichText; // despite the class name, the RichTextControl later on
89 // will create "ordinary" text peers depending on this property
90 bool m_bHideInactiveSelection;
91 // </properties>
93 // <properties_for_awt_edit_compatibility>
94 css::uno::Any m_aAlign;
95 sal_Int16 m_nEchoChar;
96 sal_Int16 m_nMaxTextLength;
97 bool m_bMultiLine;
98 // </properties_for_awt_edit_compatibility>
100 ::std::unique_ptr<RichTextEngine>
101 m_pEngine;
102 bool m_bSettingEngineText;
104 ::comphelper::OInterfaceContainerHelper3<css::util::XModifyListener>
105 m_aModifyListeners;
107 public:
108 static RichTextEngine* getEditEngine( const css::uno::Reference< css::awt::XControlModel >& _rxModel );
110 // UNO
111 DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel )
112 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
114 // XServiceInfo
115 virtual OUString SAL_CALL getImplementationName() override;
116 virtual ::css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
118 // XPersistObject
119 virtual OUString SAL_CALL getServiceName() override;
121 // XTypeProvider
122 DECLARE_XTYPEPROVIDER()
124 // XCloneable
125 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
127 // XUnoTunnel
128 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
129 static const css::uno::Sequence<sal_Int8> & getUnoTunnelId();
131 // XModifyBroadcaster
132 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
133 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
135 // XPropertySet and friends
136 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override;
137 virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any& rConvertedValue, css::uno::Any& rOldValue,
138 sal_Int32 nHandle, const css::uno::Any& rValue ) override;
139 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any& rValue) override;
140 virtual css::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const override;
142 // OControlModel's property handling
143 virtual void describeFixedProperties(
144 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
145 ) const override;
146 virtual void describeAggregateProperties(
147 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
148 ) const override;
150 // prevent method hiding
151 using OControlModel::disposing;
152 using OControlModel::getFastPropertyValue;
154 // OComponentHelper
155 virtual void SAL_CALL disposing() override;
157 // IEngineTextChangeListener
158 virtual void potentialTextChange( ) override;
160 private:
161 void implInit();
162 void implDoAggregation();
163 void implRegisterProperties();
165 /** propagates a new text to the EditEngine
167 This method needs to lock the global solar mutex, so our own mutex must not
168 be locked when calling.
170 @precond
171 our mutex is not locked
173 void impl_smlock_setEngineText( const OUString& _rText );
175 DECL_LINK( OnEngineContentModified, LinkParamNone*, void );
177 private:
178 ORichTextModel( const ORichTextModel& ) = delete;
179 ORichTextModel& operator=( const ORichTextModel& ) = delete;
183 } // namespace frm
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */