Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / forms / source / richtext / richtextmodel.hxx
blobf3ed47408040cd1879f8e93aaa892da34aa34c4b
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 #ifndef INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX
20 #define INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX
22 #include "FormComponent.hxx"
23 #include "formcontrolfont.hxx"
24 #include "richtextunowrapper.hxx"
25 #include <comphelper/propertycontainerhelper.hxx>
26 #include <comphelper/listenernotification.hxx>
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>
34 class EditEngine;
36 namespace frm
40 class RichTextEngine;
42 //= ORichTextModel
44 typedef ::cppu::ImplHelper3 < css::awt::XControlModel
45 , css::lang::XUnoTunnel
46 , css::util::XModifyBroadcaster
47 > ORichTextModel_BASE;
49 class ORichTextModel
50 :public OControlModel
51 ,public FontControlModel
52 ,public IEngineTextChangeListener
53 ,public ::comphelper::OPropertyContainerHelper
54 ,public ORichTextModel_BASE
56 public:
57 DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel );
59 private:
60 // <properties>
61 css::uno::Reference< css::awt::XDevice >
62 m_xReferenceDevice;
63 css::uno::Any m_aTabStop;
64 css::uno::Any m_aBackgroundColor;
65 css::uno::Any m_aBorderColor;
66 css::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>
87 // <properties_for_awt_edit_compatibility>
88 css::uno::Any m_aAlign;
89 sal_Int16 m_nEchoChar;
90 sal_Int16 m_nMaxTextLength;
91 bool m_bMultiLine;
92 // </properties_for_awt_edit_compatibility>
94 ::std::unique_ptr<RichTextEngine>
95 m_pEngine;
96 bool m_bSettingEngineText;
98 ::comphelper::OInterfaceContainerHelper2
99 m_aModifyListeners;
101 public:
102 static RichTextEngine* getEditEngine( const css::uno::Reference< css::awt::XControlModel >& _rxModel );
104 private:
106 // UNO
107 DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel )
108 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) throw (css::uno::RuntimeException, std::exception) override;
110 // XServiceInfo
111 virtual OUString SAL_CALL getImplementationName() throw (::css::uno::RuntimeException, std::exception) override;
112 virtual ::css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (::css::uno::RuntimeException, std::exception) override;
114 // XPersistObject
115 DECLARE_XPERSISTOBJECT()
117 // XTypeProvider
118 DECLARE_XTYPEPROVIDER()
120 // XCloneable
121 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) override;
123 // XUnoTunnel
124 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw (css::uno::RuntimeException, std::exception) override;
126 // XModifyBroadcaster
127 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
128 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
130 // XPropertySet and friends
131 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override;
132 virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any& rConvertedValue, css::uno::Any& rOldValue,
133 sal_Int32 nHandle, const css::uno::Any& rValue )
134 throw(css::lang::IllegalArgumentException) override;
135 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any& rValue) throw ( css::uno::Exception, std::exception) override;
136 virtual css::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const override;
138 // OControlModel's property handling
139 virtual void describeFixedProperties(
140 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
141 ) const override;
142 virtual void describeAggregateProperties(
143 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
144 ) const override;
146 // prevent method hiding
147 using OControlModel::disposing;
148 using OControlModel::getFastPropertyValue;
150 // OComponentHelper
151 virtual void SAL_CALL disposing() override;
153 // IEngineTextChangeListener
154 virtual void potentialTextChange( ) override;
156 private:
157 void implInit();
158 void implDoAggregation();
159 void implRegisterProperties();
161 /** propagates a new text to the EditEngine
163 This method needs to lock the global solar mutex, so our own mutex must not
164 be locked when calling.
166 @precond
167 our mutex is not locked
169 void impl_smlock_setEngineText( const OUString& _rText );
171 DECL_LINK_TYPED( OnEngineContentModified, LinkParamNone*, void );
173 static css::uno::Sequence< sal_Int8 > getEditEngineTunnelId();
175 private:
176 ORichTextModel( const ORichTextModel& ) = delete;
177 ORichTextModel& operator=( const ORichTextModel& ) = delete;
181 } // namespace frm
184 #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTMODEL_HXX
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */