LibreOffice Module forms (master) 1
richtextimplcontrol.hxx
Go to the documentation of this file.
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#pragma once
20
22#include "richtextviewport.hxx"
23#include "richtextengine.hxx"
25#include <editeng/editdata.hxx>
26
27#include <map>
28
29class EditView;
30class EditStatus;
31namespace vcl { class Window; }
33
34namespace frm
35{
36
37
38 class ITextAttributeListener;
39 class ITextSelectionListener;
40 class RichTextViewPort;
41
43 {
44 typedef ::std::map< AttributeId, AttributeState > StateCache;
45 typedef ::std::map< AttributeId, ::rtl::Reference< AttributeHandler > > AttributeHandlerPool;
46 typedef ::std::map< AttributeId, ITextAttributeListener* > AttributeListenerPool;
47
51
53
59 std::unique_ptr<EditView> m_pView;
63
64 public:
65 struct GrantAccess { friend class RichTextControl; private: GrantAccess() { } };
66 EditView* getView( const GrantAccess& ) const { return m_pView.get(); }
67 RichTextEngine* getEngine( const GrantAccess& ) const { return m_pEngine; }
68 vcl::Window* getViewport( const GrantAccess& ) const { return m_pViewport; }
69
70 public:
71 RichTextControlImpl( Control* _pAntiImpl, RichTextEngine* _pEngine,
72 ITextAttributeListener* _pTextAttrListener, ITextSelectionListener* _pSelectionListener );
73 virtual ~RichTextControlImpl();
74
78 void updateAllAttributes( );
79
83 void updateAttribute( AttributeId _nAttribute );
84
86 void enableAttributeNotification( AttributeId _nAttributeId, ITextAttributeListener* _pListener );
87
89 void disableAttributeNotification( AttributeId _nAttributeId );
90
92 bool executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, AttributeId _nAttribute, const SfxPoolItem* _pArgument, SvtScriptType _nForScriptType );
93
95 AttributeState getAttributeState( AttributeId _nAttributeId ) const;
96
112
113 // gets the script type of the selection in our edit view (with fallback)
115
118 void layoutWindow();
119
122 void notifyStyleChanged();
123
126 void notifyZoomChanged();
127
130 void notifyInitShow();
131
132 // VCL "overrides"
133 void SetBackgroundColor( );
134 void SetBackgroundColor( const Color& _rColor );
135
136 void SetReadOnly( bool _bReadOnly );
137 bool IsReadOnly() const;
138
139 void SetHideInactiveSelection( bool _bHide );
140 bool GetHideInactiveSelection() const;
141
143 void Draw( OutputDevice* _pDev, const Point& _rPos, const Size& _rSize );
144
146 bool HandleCommand( const CommandEvent& _rEvent );
147
148 private:
149 // updates the cache with the state provided by the given attribute handler
150 void implUpdateAttribute( const AttributeHandlerPool::const_iterator& _pHandler );
151
152 // updates the cache with the given state, and calls listeners (if necessary)
153 void implCheckUpdateCache( AttributeId _nAttribute, const AttributeState& _rState );
154
155 // updates range and position of our scrollbars
156 void updateScrollbars();
157
158 // determines whether automatic (soft) line breaks are ON
160
162 void ensureScrollbars();
163
166
167 bool hasVScrollBar( ) const { return m_pVScroll != nullptr; }
168 bool hasHScrollBar( ) const { return m_pHScroll != nullptr; }
169
170 // IEngineStatusListener overridables
171 virtual void EditEngineStatusChanged( const EditStatus& _rStatus ) override;
172
173 private:
174 DECL_LINK( OnInvalidateAllAttributes, LinkParamNone*, void );
175 DECL_LINK( OnHScroll, weld::Scrollbar&, void );
176 DECL_LINK( OnVScroll, weld::Scrollbar&, void );
177 };
178
179
180} // namespace frm
181
182
183/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void updateAllAttributes()
updates the cache with the state of all attribute values from the given set, notifies the listener if...
VclPtr< RichTextViewPort > m_pViewport
void enableAttributeNotification(AttributeId _nAttributeId, ITextAttributeListener *_pListener)
enables the callback for a particular attribute
DECL_LINK(OnVScroll, weld::Scrollbar &, void)
virtual void EditEngineStatusChanged(const EditStatus &_rStatus) override
DECL_LINK(OnHScroll, weld::Scrollbar &, void)
void normalizeScriptDependentAttribute(SvxScriptSetItem &_rScriptSetItem)
normalizes the given item so that the state of script dependent attributes is correct considering the...
void implUpdateAttribute(const AttributeHandlerPool::const_iterator &_pHandler)
ITextSelectionListener * m_pSelectionListener
bool executeAttribute(const SfxItemSet &_rCurrentAttribs, SfxItemSet &_rNewAttribs, AttributeId _nAttribute, const SfxPoolItem *_pArgument, SvtScriptType _nForScriptType)
executes a toggle of the given attribute
void Draw(OutputDevice *_pDev, const Point &_rPos, const Size &_rSize)
draws the control onto a given output device
::std::map< AttributeId, AttributeState > StateCache
std::unique_ptr< EditView > m_pView
void updateAttribute(AttributeId _nAttribute)
updates the cache with the state of the attribute given by which id, notifies the listener if the sta...
void layoutWindow()
re-arranges the view and the scrollbars
ITextAttributeListener * m_pTextAttrListener
RichTextControlImpl(Control *_pAntiImpl, RichTextEngine *_pEngine, ITextAttributeListener *_pTextAttrListener, ITextSelectionListener *_pSelectionListener)
void implCheckUpdateCache(AttributeId _nAttribute, const AttributeState &_rState)
::std::map< AttributeId, ITextAttributeListener * > AttributeListenerPool
void SetReadOnly(bool _bReadOnly)
EditView * getView(const GrantAccess &) const
AttributeListenerPool m_aAttributeListeners
void ensureLineBreakSetting()
ensures that our "automatic line break" setting matches the current WinBits of the window
AttributeHandlerPool m_aAttributeHandlers
::std::map< AttributeId, ::rtl::Reference< AttributeHandler > > AttributeHandlerPool
void notifyZoomChanged()
to be called when the zoom of our window changed
AttributeState getAttributeState(AttributeId _nAttributeId) const
retrieves the state of the given attribute from the cache
RichTextEngine * getEngine(const GrantAccess &) const
VclPtr< ScrollAdaptor > m_pVScroll
SvtScriptType getSelectedScriptType() const
DECL_LINK(OnInvalidateAllAttributes, LinkParamNone *, void)
void SetHideInactiveSelection(bool _bHide)
void ensureScrollbars()
hides or shows our scrollbars, according to the current WinBits of the window
bool HandleCommand(const CommandEvent &_rEvent)
handles command events arrived at the anti-impl control
void notifyInitShow()
to be called when the StateChangedType::InitShow event arrives
void notifyStyleChanged()
to be called when the style of our window changed
void disableAttributeNotification(AttributeId _nAttributeId)
disables the change notifications for a particular attribute
vcl::Window * getViewport(const GrantAccess &) const
VclPtr< ScrollAdaptor > m_pHScroll
SvtScriptType
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
sal_Int32 AttributeId
the id of an attribute