24#include <osl/diagnose.h>
26#include <editeng/editids.hrc>
38#define EMPTY_PAPER_SIZE 0x7FFFFFFF
45 :m_pAntiImpl ( _pAntiImpl )
46 ,m_pViewport ( nullptr )
47 ,m_pHScroll ( nullptr )
48 ,m_pVScroll ( nullptr )
49 ,m_pEngine ( _pEngine )
50 ,m_pTextAttrListener ( _pTextAttrListener )
51 ,m_pSelectionListener ( _pSelectionListener )
52 ,m_bHasEverBeenShown ( false )
54 OSL_ENSURE(
m_pAntiImpl,
"RichTextControlImpl::RichTextControlImpl: invalid window!" );
55 OSL_ENSURE(
m_pEngine,
"RichTextControlImpl::RichTextControlImpl: invalid edit engine! This will *definitely* crash!" );
74 nViewControlWord |= EVControlBits::AUTOSCROLL;
75 m_pView->SetControlWord( nViewControlWord );
98 if ( ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_WEIGHT) )
99 || ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_POSTURE) )
100 || ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_FONT) )
101 || ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_FONTHEIGHT) )
115 implCheckUpdateCache( _pHandler->first, _pHandler->second->getState( aNormalizedSet.GetItemSet() ) );
155 StateCache::const_iterator aCachedStatePos =
m_aLastKnownStates.find( _nAttributeId );
158 OSL_FAIL(
"RichTextControlImpl::getAttributeState: Don't ask for the state of an attribute which I never encountered!" );
161 return aCachedStatePos->second;
171 aHandlerPos->second->executeAttribute( _rCurrentAttribs, _rAttribs, _pArgument, _nForScriptType );
184 OSL_ENSURE( aHandler.is(),
"RichTextControlImpl::enableAttributeNotification: no handler available for this attribute!" );
185 if ( !aHandler.is() )
187 SAL_WARN_IF( _nAttributeId != aHandler->getAttributeId(),
"forms.richtext",
"RichTextControlImpl::enableAttributeNotification: suspicious handler!" );
217 _rScriptSetItem.GetItemSet().Put(
m_pView->GetAttribs(),
false );
220 WhichId nNormalizedWhichId = _rScriptSetItem.GetItemSet().GetPool()->GetWhich( _rScriptSetItem.Which() );
221 if ( pNormalizedItem )
223 _rScriptSetItem.GetItemSet().Put( pNormalizedItem->
CloneSetWhich(nNormalizedWhichId) );
226 _rScriptSetItem.GetItemSet().InvalidateItem( nNormalizedWhichId );
239 if ( aCachePos->second == _rState )
244 aCachePos->second = _rState;
250 aListenerPos->second->onAttributeStateChanged( _nAttribute );
261 if ( nScript == SvtScriptType::NONE )
270 if ( ( nStatusWord & EditStatusFlags::TEXTWIDTHCHANGED )
271 || ( nStatusWord & EditStatusFlags::TextHeightChanged )
280 bool bHScroll = bool( nStatusWord & EditStatusFlags::HSCROLL );
281 bool bVScroll = bool( nStatusWord & EditStatusFlags::VSCROLL );
307 updateAllAttributes();
312 auto nDiff = m_pView->GetVisArea().Left() - rScrollbar.adjustment_get_value();
313 m_pView->Scroll(nDiff, 0, ScrollRangeCheck::PaperWidthTextSize);
318 auto nDiff = m_pView->GetVisArea().Top() - rScrollbar.adjustment_get_value();
319 m_pView->Scroll(0, nDiff, ScrollRangeCheck::PaperWidthTextSize);
379 nScrollBarWidth =
m_pAntiImpl->CalcZoom( nScrollBarWidth );
380 nScrollBarHeight =
m_pAntiImpl->CalcZoom( nScrollBarHeight );
388 Size aViewportPlaygroundPixel( aPlaygroundSizePixel );
391 Size aViewportPlaygroundLogic(
m_pViewport->PixelToLogic( aViewportPlaygroundPixel ) );
394 Size aViewportSizePixel( aViewportPlaygroundPixel.
Width() - 2 * nOffset, aViewportPlaygroundPixel.
Height() - 2 * nOffset );
395 Size aViewportSizeLogic(
m_pViewport->PixelToLogic( aViewportSizePixel ) );
398 m_pViewport->SetPosSizePixel(
Point( nOffset, nOffset ), aViewportSizePixel );
428 m_pVScroll->SetPageSize( ::std::max( nFontHeight, aViewportPlaygroundLogic.
Height() - nFontHeight ) );
447 m_pHScroll->SetPageSize( ::std::max( nFontWidth, aViewportPlaygroundLogic.
Width() - nFontWidth ) );
515 m_pView->SetReadOnly( _bReadOnly );
538 if ( ( _rEvent.
GetCommand() == CommandEventId::Wheel )
539 || ( _rEvent.
GetCommand() == CommandEventId::StartAutoScroll )
540 || ( _rEvent.
GetCommand() == CommandEventId::AutoScroll )
564 Size aSize( _rSize );
565 if ( aOriginalMapMode.
GetMapUnit() == MapUnit::MapPixel )
567 aPos = _pDev->
PixelToLogic( _rPos, aNormalizedMapMode );
568 aSize = _pDev->
PixelToLogic( _rSize, aNormalizedMapMode );
596 lcl_inflate( aPlayground, -aOnePixel.
Width(), -aOnePixel.
Height() );
600 lcl_inflate( aPlayground, -aOnePixel.
Width(), -aOnePixel.
Height() );
601 lcl_inflate( aPlayground, -aOnePixel.
Width(), -aOnePixel.
Height() );
static const AllSettings & GetSettings()
CommandEventId GetCommand() const
OutputDevice * GetRefDevice() const
const Size & GetPaperSize() const
EditView * RemoveView(EditView *pEditView)
sal_uInt32 GetTextHeight() const
vcl::Font GetStandardFont(sal_Int32 nPara)
sal_uInt32 CalcTextWidth()
const SfxItemSet & GetEmptyItemSet() const
void Draw(OutputDevice &rOutDev, const tools::Rectangle &rOutRect)
void SetPaperSize(const Size &rSize)
void InsertView(EditView *pEditView, size_t nIndex=EE_APPEND)
EditStatusFlags GetStatusWord() const
void SetScaleY(const Fraction &rScaleY)
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Point & GetOrigin() const
const Fraction & GetScaleY() const
void SetScaleX(const Fraction &rScaleX)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawRect(const tools::Rectangle &rRect)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const MapMode & GetMapMode() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
SfxItemPool * GetPool() const
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_Int32 GetScrollBarSize() const
const SfxPoolItem * GetItemOfScript(SvtScriptType nScript) const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void onAttributeStateChanged(AttributeId _nAttributeId)=0
virtual void onSelectionChanged()=0
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
virtual void EditEngineStatusChanged(const EditStatus &_rStatus) override
RichTextEngine * m_pEngine
ESelection m_aLastKnownSelection
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)
bool hasHScrollBar() const
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
bool windowHasAutomaticLineBreak()
virtual ~RichTextControlImpl()
bool GetHideInactiveSelection() const
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
VclPtr< Control > m_pAntiImpl
ITextAttributeListener * m_pTextAttrListener
RichTextControlImpl(Control *_pAntiImpl, RichTextEngine *_pEngine, ITextAttributeListener *_pTextAttrListener, ITextSelectionListener *_pSelectionListener)
void implCheckUpdateCache(AttributeId _nAttribute, const AttributeState &_rState)
void SetReadOnly(bool _bReadOnly)
bool hasVScrollBar() const
AttributeListenerPool m_aAttributeListeners
void ensureLineBreakSetting()
ensures that our "automatic line break" setting matches the current WinBits of the window
AttributeHandlerPool m_aAttributeHandlers
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
VclPtr< ScrollAdaptor > m_pVScroll
SvtScriptType getSelectedScriptType() const
StateCache m_aLastKnownStates
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
void SetBackgroundColor()
VclPtr< ScrollAdaptor > m_pHScroll
void revokeEngineStatusListener(IEngineStatusListener const *_pListener)
void registerEngineStatusListener(IEngineStatusListener *_pListener)
const Size & GetFontSize() const
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
::rtl::Reference< AttributeHandler > getHandlerFor(AttributeId _nAttributeId, const SfxItemPool &_rEditEnginePool)
ListBox is a bit confusing / different from other form components, so here are a few notes:
sal_uInt16 WhichId
the "which id" of an item in an SfxItemSet
IMPL_LINK_NOARG(OButtonControl, OnClick, void *, void)
IMPL_LINK(OClickableImageBaseModel, OnImageImportDone, Graphic *, i_pGraphic, void)
sal_Int32 AttributeId
the id of an attribute
WinBits const WB_WORDBREAK