1*24acc546SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24acc546SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24acc546SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24acc546SAndrew Rist  * distributed with this work for additional information
6*24acc546SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24acc546SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24acc546SAndrew Rist  * "License"); you may not use this file except in compliance
9*24acc546SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24acc546SAndrew Rist  *
11*24acc546SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24acc546SAndrew Rist  *
13*24acc546SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24acc546SAndrew Rist  * software distributed under the License is distributed on an
15*24acc546SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24acc546SAndrew Rist  * KIND, either express or implied.  See the License for the
17*24acc546SAndrew Rist  * specific language governing permissions and limitations
18*24acc546SAndrew Rist  * under the License.
19*24acc546SAndrew Rist  *
20*24acc546SAndrew Rist  *************************************************************/
21*24acc546SAndrew Rist 
22*24acc546SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_forms.hxx"
26cdf0e10cSrcweir #include "richtextimplcontrol.hxx"
27cdf0e10cSrcweir #include "textattributelistener.hxx"
28cdf0e10cSrcweir #include "richtextengine.hxx"
29cdf0e10cSrcweir #include <editeng/editeng.hxx>
30cdf0e10cSrcweir #include <editeng/editview.hxx>
31cdf0e10cSrcweir #include <editeng/eeitem.hxx>
32cdf0e10cSrcweir #include <editeng/editstat.hxx>
33cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
34cdf0e10cSrcweir #include <svx/svxids.hrc>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <editeng/editobj.hxx>
39cdf0e10cSrcweir #include <svl/itempool.hxx>
40cdf0e10cSrcweir #include <svl/itemset.hxx>
41cdf0e10cSrcweir #include <tools/mapunit.hxx>
42cdf0e10cSrcweir #include <vcl/window.hxx>
43cdf0e10cSrcweir #include <vcl/svapp.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <memory>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #define EMPTY_PAPER_SIZE    0x7FFFFFFF
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //........................................................................
50cdf0e10cSrcweir namespace frm
51cdf0e10cSrcweir {
52cdf0e10cSrcweir //........................................................................
53cdf0e10cSrcweir     //====================================================================
54cdf0e10cSrcweir     //= RichTextControlImpl
55cdf0e10cSrcweir     //====================================================================
56cdf0e10cSrcweir     //--------------------------------------------------------------------
RichTextControlImpl(Control * _pAntiImpl,RichTextEngine * _pEngine,ITextAttributeListener * _pTextAttrListener,ITextSelectionListener * _pSelectionListener)57cdf0e10cSrcweir     RichTextControlImpl::RichTextControlImpl( Control* _pAntiImpl, RichTextEngine* _pEngine, ITextAttributeListener* _pTextAttrListener, ITextSelectionListener* _pSelectionListener )
58cdf0e10cSrcweir         :m_pAntiImpl            ( _pAntiImpl          )
59cdf0e10cSrcweir         ,m_pViewport            ( NULL                )
60cdf0e10cSrcweir         ,m_pHScroll             ( NULL                )
61cdf0e10cSrcweir         ,m_pVScroll             ( NULL                )
62cdf0e10cSrcweir         ,m_pScrollCorner        ( NULL                )
63cdf0e10cSrcweir         ,m_pEngine              ( _pEngine            )
64cdf0e10cSrcweir         ,m_pView                ( NULL                )
65cdf0e10cSrcweir         ,m_pTextAttrListener    ( _pTextAttrListener  )
66cdf0e10cSrcweir         ,m_pSelectionListener   ( _pSelectionListener )
67cdf0e10cSrcweir         ,m_bHasEverBeenShown    ( false               )
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir         OSL_ENSURE( m_pAntiImpl, "RichTextControlImpl::RichTextControlImpl: invalid window!" );
70cdf0e10cSrcweir         OSL_ENSURE( m_pEngine,   "RichTextControlImpl::RichTextControlImpl: invalid edit engine! This will *definately* crash!" );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         m_pViewport = new RichTextViewPort( m_pAntiImpl );
73cdf0e10cSrcweir         m_pViewport->setAttributeInvalidationHandler( LINK( this, RichTextControlImpl, OnInvalidateAllAttributes ) );
74cdf0e10cSrcweir         m_pViewport->Show();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         // ensure that both the window and the reference device have the same map unit
77cdf0e10cSrcweir         MapMode aRefDeviceMapMode( m_pEngine->GetRefDevice()->GetMapMode() );
78cdf0e10cSrcweir         m_pAntiImpl->SetMapMode( aRefDeviceMapMode );
79cdf0e10cSrcweir         m_pViewport->SetMapMode( aRefDeviceMapMode );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         m_pView = new EditView( m_pEngine, m_pViewport );
82cdf0e10cSrcweir         m_pEngine->InsertView( m_pView );
83cdf0e10cSrcweir         m_pViewport->setView( *m_pView );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         m_pEngine->registerEngineStatusListener( this );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         {
88cdf0e10cSrcweir             sal_uLong nViewControlWord = m_pView->GetControlWord();
89cdf0e10cSrcweir             nViewControlWord |= EV_CNTRL_AUTOSCROLL;
90cdf0e10cSrcweir             m_pView->SetControlWord( nViewControlWord );
91cdf0e10cSrcweir         }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         // ensure that it's initially scrolled to the upper left
94cdf0e10cSrcweir         m_pView->SetVisArea( Rectangle( Point( ), m_pViewport->GetOutputSize() ) );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         ensureScrollbars();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         m_pAntiImpl->SetBackground( Wallpaper( m_pAntiImpl->GetSettings().GetStyleSettings().GetFieldColor() ) );
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     //--------------------------------------------------------------------
~RichTextControlImpl()102cdf0e10cSrcweir     RichTextControlImpl::~RichTextControlImpl( )
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         m_pEngine->RemoveView( m_pView );
105cdf0e10cSrcweir         m_pEngine->revokeEngineStatusListener( this );
106cdf0e10cSrcweir         delete m_pView;
107cdf0e10cSrcweir         delete m_pViewport;
108cdf0e10cSrcweir         delete m_pHScroll;
109cdf0e10cSrcweir         delete m_pVScroll;
110cdf0e10cSrcweir         delete m_pScrollCorner;
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     //--------------------------------------------------------------------
implUpdateAttribute(AttributeHandlerPool::const_iterator _pHandler)114cdf0e10cSrcweir     void RichTextControlImpl::implUpdateAttribute( AttributeHandlerPool::const_iterator _pHandler )
115cdf0e10cSrcweir     {
116cdf0e10cSrcweir         if  (  ( _pHandler->first == SID_ATTR_CHAR_WEIGHT )
117cdf0e10cSrcweir             || ( _pHandler->first == SID_ATTR_CHAR_POSTURE )
118cdf0e10cSrcweir             || ( _pHandler->first == SID_ATTR_CHAR_FONT )
119cdf0e10cSrcweir             || ( _pHandler->first == SID_ATTR_CHAR_FONTHEIGHT )
120cdf0e10cSrcweir             )
121cdf0e10cSrcweir         {
122cdf0e10cSrcweir             // these are attributes whose value depends on the current script type.
123cdf0e10cSrcweir             // I.e., in real, there are *three* items in the ItemSet: One for each script
124cdf0e10cSrcweir             // type (Latin, Asian, Complex). However, if we have an observer who is interested
125cdf0e10cSrcweir             // in the state of this attribute, we have to kind of *merge* the three attributes
126cdf0e10cSrcweir             // to only one.
127cdf0e10cSrcweir             // This is usefull in case the observer is for instance a toolbox which contains only
128cdf0e10cSrcweir             // an, e.g., "bold" slot, and thus not interested in the particular script type of the
129cdf0e10cSrcweir             // current selection.
130cdf0e10cSrcweir             SvxScriptSetItem aNormalizedSet( (WhichId)_pHandler->first, *m_pView->GetAttribs().GetPool() );
131cdf0e10cSrcweir             normalizeScriptDependentAttribute( aNormalizedSet );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir             implCheckUpdateCache( _pHandler->first, _pHandler->second->getState( aNormalizedSet.GetItemSet() ) );
134cdf0e10cSrcweir         }
135cdf0e10cSrcweir         else
136cdf0e10cSrcweir             implCheckUpdateCache( _pHandler->first, _pHandler->second->getState( m_pView->GetAttribs() ) );
137cdf0e10cSrcweir     }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     //--------------------------------------------------------------------
updateAttribute(AttributeId _nAttribute)140cdf0e10cSrcweir     void RichTextControlImpl::updateAttribute( AttributeId _nAttribute )
141cdf0e10cSrcweir     {
142cdf0e10cSrcweir         AttributeHandlerPool::const_iterator pHandler = m_aAttributeHandlers.find( _nAttribute );
143cdf0e10cSrcweir         if ( pHandler != m_aAttributeHandlers.end() )
144cdf0e10cSrcweir             implUpdateAttribute( pHandler );
145cdf0e10cSrcweir     }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     //--------------------------------------------------------------------
updateAllAttributes()148cdf0e10cSrcweir     void RichTextControlImpl::updateAllAttributes( )
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         for (   AttributeHandlerPool::const_iterator pHandler = m_aAttributeHandlers.begin();
151cdf0e10cSrcweir                 pHandler != m_aAttributeHandlers.end();
152cdf0e10cSrcweir                 ++pHandler
153cdf0e10cSrcweir             )
154cdf0e10cSrcweir         {
155cdf0e10cSrcweir             implUpdateAttribute( pHandler );
156cdf0e10cSrcweir         }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         // notify changes of the selection, if necessary
159cdf0e10cSrcweir         if ( m_pSelectionListener && m_pView )
160cdf0e10cSrcweir         {
161cdf0e10cSrcweir             ESelection aCurrentSelection = m_pView->GetSelection();
162cdf0e10cSrcweir             if ( !aCurrentSelection.IsEqual( m_aLastKnownSelection ) )
163cdf0e10cSrcweir             {
164cdf0e10cSrcweir                 m_aLastKnownSelection = aCurrentSelection;
165cdf0e10cSrcweir                 m_pSelectionListener->onSelectionChanged( m_aLastKnownSelection );
166cdf0e10cSrcweir             }
167cdf0e10cSrcweir         }
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     //--------------------------------------------------------------------
getAttributeState(AttributeId _nAttributeId) const171cdf0e10cSrcweir     AttributeState RichTextControlImpl::getAttributeState( AttributeId _nAttributeId ) const
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         StateCache::const_iterator aCachedStatePos = m_aLastKnownStates.find( _nAttributeId );
174cdf0e10cSrcweir         if ( aCachedStatePos == m_aLastKnownStates.end() )
175cdf0e10cSrcweir         {
176cdf0e10cSrcweir             OSL_ENSURE( sal_False, "RichTextControlImpl::getAttributeState: Don't ask for the state of an attribute which I never encountered!" );
177cdf0e10cSrcweir             return AttributeState( eIndetermined );
178cdf0e10cSrcweir         }
179cdf0e10cSrcweir         return aCachedStatePos->second;
180cdf0e10cSrcweir     }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     //--------------------------------------------------------------------
executeAttribute(const SfxItemSet & _rCurrentAttribs,SfxItemSet & _rAttribs,AttributeId _nAttribute,const SfxPoolItem * _pArgument,ScriptType _nForScriptType)183cdf0e10cSrcweir     bool RichTextControlImpl::executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rAttribs, AttributeId _nAttribute, const SfxPoolItem* _pArgument, ScriptType _nForScriptType )
184cdf0e10cSrcweir     {
185cdf0e10cSrcweir         // let's see whether we have a handler for this attribute
186cdf0e10cSrcweir         AttributeHandlerPool::const_iterator aHandlerPos = m_aAttributeHandlers.find( _nAttribute );
187cdf0e10cSrcweir         if ( aHandlerPos != m_aAttributeHandlers.end() )
188cdf0e10cSrcweir         {
189cdf0e10cSrcweir             aHandlerPos->second->executeAttribute( _rCurrentAttribs, _rAttribs, _pArgument, _nForScriptType );
190cdf0e10cSrcweir             return true;
191cdf0e10cSrcweir         }
192cdf0e10cSrcweir         return false;
193cdf0e10cSrcweir     }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     //--------------------------------------------------------------------
enableAttributeNotification(AttributeId _nAttributeId,ITextAttributeListener * _pListener)196cdf0e10cSrcweir     void RichTextControlImpl::enableAttributeNotification( AttributeId _nAttributeId, ITextAttributeListener* _pListener )
197cdf0e10cSrcweir     {
198cdf0e10cSrcweir         AttributeHandlerPool::const_iterator aHandlerPos = m_aAttributeHandlers.find( _nAttributeId  );
199cdf0e10cSrcweir         if ( aHandlerPos == m_aAttributeHandlers.end() )
200cdf0e10cSrcweir         {
201cdf0e10cSrcweir             ::rtl::Reference< IAttributeHandler > aHandler = AttributeHandlerFactory::getHandlerFor( _nAttributeId, *m_pEngine->GetEmptyItemSet().GetPool() );
202cdf0e10cSrcweir             OSL_ENSURE( aHandler.is(), "RichTextControlImpl::enableAttributeNotification: no handler available for this attribute!" );
203cdf0e10cSrcweir             if ( !aHandler.is() )
204cdf0e10cSrcweir                 return;
205cdf0e10cSrcweir             OSL_POSTCOND( _nAttributeId == aHandler->getAttributeId(), "RichTextControlImpl::enableAttributeNotification: suspicious handler!" );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir             aHandlerPos = m_aAttributeHandlers.insert( AttributeHandlerPool::value_type( _nAttributeId , aHandler ) ).first;
208cdf0e10cSrcweir         }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         // remember the listener
211cdf0e10cSrcweir         if ( _pListener )
212cdf0e10cSrcweir             m_aAttributeListeners.insert( AttributeListenerPool::value_type( _nAttributeId, _pListener ) );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir         // update (and broadcast) the state of this attribute
215cdf0e10cSrcweir         updateAttribute( _nAttributeId );
216cdf0e10cSrcweir     }
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     //--------------------------------------------------------------------
disableAttributeNotification(AttributeId _nAttributeId)219cdf0e10cSrcweir     void RichTextControlImpl::disableAttributeNotification( AttributeId _nAttributeId )
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         // forget the handler for this attribute
222cdf0e10cSrcweir         AttributeHandlerPool::iterator aHandlerPos = m_aAttributeHandlers.find( _nAttributeId );
223cdf0e10cSrcweir         if ( aHandlerPos != m_aAttributeHandlers.end() )
224cdf0e10cSrcweir             m_aAttributeHandlers.erase( aHandlerPos );
225cdf0e10cSrcweir 
226cdf0e10cSrcweir         // as well as the listener
227cdf0e10cSrcweir         AttributeListenerPool::iterator aListenerPos = m_aAttributeListeners.find( _nAttributeId );
228cdf0e10cSrcweir         if ( aListenerPos != m_aAttributeListeners.end() )
229cdf0e10cSrcweir             m_aAttributeListeners.erase( aListenerPos );
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     //--------------------------------------------------------------------
normalizeScriptDependentAttribute(SvxScriptSetItem & _rScriptSetItem)233cdf0e10cSrcweir     void RichTextControlImpl::normalizeScriptDependentAttribute( SvxScriptSetItem& _rScriptSetItem )
234cdf0e10cSrcweir     {
235cdf0e10cSrcweir         _rScriptSetItem.GetItemSet().Put( m_pView->GetAttribs(), sal_False );
236cdf0e10cSrcweir         const SfxPoolItem* pNormalizedItem = _rScriptSetItem.GetItemOfScript( getSelectedScriptType() );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir         WhichId nNormalizedWhichId = _rScriptSetItem.GetItemSet().GetPool()->GetWhich( _rScriptSetItem.Which() );
239cdf0e10cSrcweir         if ( pNormalizedItem )
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             SfxPoolItem* pProperWhich = pNormalizedItem->Clone();
242cdf0e10cSrcweir             pProperWhich->SetWhich( nNormalizedWhichId );
243cdf0e10cSrcweir             _rScriptSetItem.GetItemSet().Put( *pProperWhich );
244cdf0e10cSrcweir             DELETEZ( pProperWhich );
245cdf0e10cSrcweir         }
246cdf0e10cSrcweir         else
247cdf0e10cSrcweir             _rScriptSetItem.GetItemSet().InvalidateItem( nNormalizedWhichId );
248cdf0e10cSrcweir     }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     //--------------------------------------------------------------------
implCheckUpdateCache(AttributeId _nAttribute,const AttributeState & _rState)251cdf0e10cSrcweir     void RichTextControlImpl::implCheckUpdateCache( AttributeId _nAttribute, const AttributeState& _rState )
252cdf0e10cSrcweir     {
253cdf0e10cSrcweir         StateCache::iterator aCachePos = m_aLastKnownStates.find( _nAttribute );
254cdf0e10cSrcweir         if ( aCachePos == m_aLastKnownStates.end() )
255cdf0e10cSrcweir         {   // nothing known about this attribute, yet
256cdf0e10cSrcweir             m_aLastKnownStates.insert( StateCache::value_type( _nAttribute, _rState ) );
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir         else
259cdf0e10cSrcweir         {
260cdf0e10cSrcweir             if ( aCachePos->second == _rState )
261cdf0e10cSrcweir             {
262cdf0e10cSrcweir                 // nothing to do
263cdf0e10cSrcweir                 return;
264cdf0e10cSrcweir             }
265cdf0e10cSrcweir             aCachePos->second = _rState;
266cdf0e10cSrcweir         }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         // is there a dedicated listener for this particular attribute?
269cdf0e10cSrcweir         AttributeListenerPool::const_iterator aListenerPos = m_aAttributeListeners.find( _nAttribute );
270cdf0e10cSrcweir         if ( aListenerPos != m_aAttributeListeners.end( ) )
271cdf0e10cSrcweir             aListenerPos->second->onAttributeStateChanged( _nAttribute, _rState );
272cdf0e10cSrcweir 
273cdf0e10cSrcweir         // call our global listener, if there is one
274cdf0e10cSrcweir         if ( m_pTextAttrListener )
275cdf0e10cSrcweir             m_pTextAttrListener->onAttributeStateChanged( _nAttribute, _rState );
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     //--------------------------------------------------------------------
getSelectedScriptType() const279cdf0e10cSrcweir     ScriptType RichTextControlImpl::getSelectedScriptType() const
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         ScriptType nScript = m_pView->GetSelectedScriptType();
282cdf0e10cSrcweir         if ( !nScript )
283cdf0e10cSrcweir             nScript = SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguage() );
284cdf0e10cSrcweir         return nScript;
285cdf0e10cSrcweir     }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     //--------------------------------------------------------------------
EditEngineStatusChanged(const EditStatus & _rStatus)288cdf0e10cSrcweir     void RichTextControlImpl::EditEngineStatusChanged( const EditStatus& _rStatus )
289cdf0e10cSrcweir     {
290cdf0e10cSrcweir         sal_uLong nStatusWord( _rStatus.GetStatusWord() );
291cdf0e10cSrcweir         if  (   ( nStatusWord & EE_STAT_TEXTWIDTHCHANGED )
292cdf0e10cSrcweir             ||  ( nStatusWord & EE_STAT_TEXTHEIGHTCHANGED )
293cdf0e10cSrcweir             )
294cdf0e10cSrcweir         {
295cdf0e10cSrcweir             if ( ( nStatusWord & EE_STAT_TEXTHEIGHTCHANGED ) && windowHasAutomaticLineBreak() )
296cdf0e10cSrcweir                 m_pEngine->SetPaperSize( Size( m_pEngine->GetPaperSize().Width(), m_pEngine->GetTextHeight() ) );
297cdf0e10cSrcweir 
298cdf0e10cSrcweir             updateScrollbars();
299cdf0e10cSrcweir         }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir         bool bHScroll = 0 != ( nStatusWord & EE_STAT_HSCROLL );
302cdf0e10cSrcweir         bool bVScroll = 0 != ( nStatusWord & EE_STAT_VSCROLL );
303cdf0e10cSrcweir 
304cdf0e10cSrcweir         // In case of *no* automatic line breaks, we also need to check for the *range* here.
305cdf0e10cSrcweir         // Normally, we would do this only after a EE_STAT_TEXTWIDTHCHANGED. However, due to a bug
306cdf0e10cSrcweir         // in the EditEngine (I believe so) this is not fired when the engine does not have
307cdf0e10cSrcweir         // the AutoPaperSize bits set.
308cdf0e10cSrcweir         // So in order to be properly notified, we would need the AutoPaperSize. But, with
309cdf0e10cSrcweir         // AutoPaperSize, other things do not work anymore: Either, when we set a MaxAutoPaperSize,
310cdf0e10cSrcweir         // then the view does automatic soft line breaks at the paper end - which we definately do
311cdf0e10cSrcweir         // want. Or, if we did not set a MaxAutoPaperSize, then the view does not automatically scroll
312cdf0e10cSrcweir         // anymore in horizontal direction.
313cdf0e10cSrcweir         // So this is some kind of lose-lose situation ... :(
314cdf0e10cSrcweir         if ( !windowHasAutomaticLineBreak() && bHScroll )
315cdf0e10cSrcweir         {
316cdf0e10cSrcweir             updateScrollbars();
317cdf0e10cSrcweir             return;
318cdf0e10cSrcweir         }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         if ( bHScroll && m_pHScroll )
321cdf0e10cSrcweir             m_pHScroll->SetThumbPos( m_pView->GetVisArea().Left() );
322cdf0e10cSrcweir         if ( bVScroll && m_pVScroll )
323cdf0e10cSrcweir             m_pVScroll->SetThumbPos( m_pView->GetVisArea().Top() );
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     //--------------------------------------------------------------------
327cdf0e10cSrcweir     IMPL_LINK( RichTextControlImpl, OnInvalidateAllAttributes, void*, /*_pNotInterestedIn*/ )
328cdf0e10cSrcweir     {
329cdf0e10cSrcweir         updateAllAttributes();
330cdf0e10cSrcweir         return 0L;
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     //--------------------------------------------------------------------
IMPL_LINK(RichTextControlImpl,OnHScroll,ScrollBar *,_pScrollbar)334cdf0e10cSrcweir     IMPL_LINK( RichTextControlImpl, OnHScroll, ScrollBar*, _pScrollbar )
335cdf0e10cSrcweir     {
336cdf0e10cSrcweir         m_pView->Scroll( -_pScrollbar->GetDelta(), 0, RGCHK_PAPERSZ1 );
337cdf0e10cSrcweir         return 0L;
338cdf0e10cSrcweir     }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     //--------------------------------------------------------------------
IMPL_LINK(RichTextControlImpl,OnVScroll,ScrollBar *,_pScrollbar)341cdf0e10cSrcweir     IMPL_LINK( RichTextControlImpl, OnVScroll, ScrollBar*, _pScrollbar )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir         m_pView->Scroll( 0, -_pScrollbar->GetDelta(), RGCHK_PAPERSZ1 );
344cdf0e10cSrcweir         return 0L;
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     //--------------------------------------------------------------------
ensureScrollbars()348cdf0e10cSrcweir     void RichTextControlImpl::ensureScrollbars()
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         bool bNeedVScroll = 0 != ( m_pAntiImpl->GetStyle() & WB_VSCROLL );
351cdf0e10cSrcweir         bool bNeedHScroll = 0 != ( m_pAntiImpl->GetStyle() & WB_HSCROLL );
352cdf0e10cSrcweir 
353cdf0e10cSrcweir         if ( ( bNeedVScroll == hasVScrollBar() ) && ( bNeedHScroll == hasHScrollBar( ) ) )
354cdf0e10cSrcweir             // nothing to do
355cdf0e10cSrcweir             return;
356cdf0e10cSrcweir 
357cdf0e10cSrcweir         // create or delete the scrollbars, as necessary
358cdf0e10cSrcweir         if ( !bNeedVScroll )
359cdf0e10cSrcweir         {
360cdf0e10cSrcweir             delete m_pVScroll;
361cdf0e10cSrcweir             m_pVScroll = NULL;
362cdf0e10cSrcweir         }
363cdf0e10cSrcweir         else
364cdf0e10cSrcweir         {
365cdf0e10cSrcweir             m_pVScroll = new ScrollBar( m_pAntiImpl, WB_VSCROLL | WB_DRAG | WB_REPEAT );
366cdf0e10cSrcweir             m_pVScroll->SetScrollHdl ( LINK( this, RichTextControlImpl, OnVScroll ) );
367cdf0e10cSrcweir             m_pVScroll->Show();
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         if ( !bNeedHScroll )
371cdf0e10cSrcweir         {
372cdf0e10cSrcweir             delete m_pHScroll;
373cdf0e10cSrcweir             m_pHScroll = NULL;
374cdf0e10cSrcweir         }
375cdf0e10cSrcweir         else
376cdf0e10cSrcweir         {
377cdf0e10cSrcweir             m_pHScroll = new ScrollBar( m_pAntiImpl, WB_HSCROLL | WB_DRAG | WB_REPEAT );
378cdf0e10cSrcweir             m_pHScroll->SetScrollHdl ( LINK( this, RichTextControlImpl, OnHScroll ) );
379cdf0e10cSrcweir             m_pHScroll->Show();
380cdf0e10cSrcweir         }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir         if ( m_pHScroll && m_pVScroll )
383cdf0e10cSrcweir         {
384cdf0e10cSrcweir             delete m_pScrollCorner;
385cdf0e10cSrcweir             m_pScrollCorner = new ScrollBarBox( m_pAntiImpl );
386cdf0e10cSrcweir             m_pScrollCorner->Show();
387cdf0e10cSrcweir         }
388cdf0e10cSrcweir         else
389cdf0e10cSrcweir         {
390cdf0e10cSrcweir             delete m_pScrollCorner;
391cdf0e10cSrcweir             m_pScrollCorner = NULL;
392cdf0e10cSrcweir         }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         layoutWindow();
395cdf0e10cSrcweir     }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     //--------------------------------------------------------------------
ensureLineBreakSetting()398cdf0e10cSrcweir     void RichTextControlImpl::ensureLineBreakSetting()
399cdf0e10cSrcweir     {
400cdf0e10cSrcweir         if ( !windowHasAutomaticLineBreak() )
401cdf0e10cSrcweir             m_pEngine->SetPaperSize( Size( EMPTY_PAPER_SIZE, EMPTY_PAPER_SIZE ) );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         layoutWindow();
404cdf0e10cSrcweir     }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     //--------------------------------------------------------------------
layoutWindow()407cdf0e10cSrcweir     void RichTextControlImpl::layoutWindow()
408cdf0e10cSrcweir     {
409cdf0e10cSrcweir         if ( !m_bHasEverBeenShown )
410cdf0e10cSrcweir             // no need to do anything. Especially, no need to set the paper size on the
411cdf0e10cSrcweir             // EditEngine to anything ....
412cdf0e10cSrcweir             return;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir         const StyleSettings& rStyleSettings = m_pAntiImpl->GetSettings().GetStyleSettings();
415cdf0e10cSrcweir 
416cdf0e10cSrcweir         long nScrollBarWidth = m_pVScroll ? rStyleSettings.GetScrollBarSize() : 0;
417cdf0e10cSrcweir         long nScrollBarHeight = m_pHScroll ? rStyleSettings.GetScrollBarSize() : 0;
418cdf0e10cSrcweir 
419cdf0e10cSrcweir         if ( m_pAntiImpl->IsZoom() )
420cdf0e10cSrcweir         {
421cdf0e10cSrcweir             nScrollBarWidth = m_pAntiImpl->CalcZoom( nScrollBarWidth );
422cdf0e10cSrcweir             nScrollBarHeight = m_pAntiImpl->CalcZoom( nScrollBarHeight );
423cdf0e10cSrcweir         }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir         // the overall size we can use
426cdf0e10cSrcweir         Size aPlaygroundSizePixel( m_pAntiImpl->GetOutputSizePixel() );
427cdf0e10cSrcweir 
428cdf0e10cSrcweir         // the size of the viewport - note that the viewport does *not* occupy all the place
429cdf0e10cSrcweir         // which is left when subtracting the scrollbar width/height
430cdf0e10cSrcweir         Size aViewportPlaygroundPixel( aPlaygroundSizePixel );
431cdf0e10cSrcweir         aViewportPlaygroundPixel.Width() = ::std::max( long( 10 ), long( aViewportPlaygroundPixel.Width() - nScrollBarWidth ) );
432cdf0e10cSrcweir         aViewportPlaygroundPixel.Height() = ::std::max( long( 10 ), long( aViewportPlaygroundPixel.Height() - nScrollBarHeight ) );
433cdf0e10cSrcweir         Size aViewportPlaygroundLogic( m_pViewport->PixelToLogic( aViewportPlaygroundPixel ) );
434cdf0e10cSrcweir 
435cdf0e10cSrcweir         const long nOffset = 2;
436cdf0e10cSrcweir         Size aViewportSizePixel( aViewportPlaygroundPixel.Width() - 2 * nOffset, aViewportPlaygroundPixel.Height() - 2 * nOffset );
437cdf0e10cSrcweir         Size aViewportSizeLogic( m_pViewport->PixelToLogic( aViewportSizePixel ) );
438cdf0e10cSrcweir 
439cdf0e10cSrcweir         // position the viewport
440cdf0e10cSrcweir         m_pViewport->SetPosSizePixel( Point( nOffset, nOffset ), aViewportSizePixel );
441cdf0e10cSrcweir         // position the scrollbars
442cdf0e10cSrcweir         if ( m_pVScroll )
443cdf0e10cSrcweir             m_pVScroll->SetPosSizePixel( Point( aViewportPlaygroundPixel.Width(), 0 ), Size( nScrollBarWidth, aViewportPlaygroundPixel.Height() ) );
444cdf0e10cSrcweir         if ( m_pHScroll )
445cdf0e10cSrcweir             m_pHScroll->SetPosSizePixel( Point( 0, aViewportPlaygroundPixel.Height() ), Size( aViewportPlaygroundPixel.Width(), nScrollBarHeight ) );
446cdf0e10cSrcweir         if ( m_pScrollCorner )
447cdf0e10cSrcweir             m_pScrollCorner->SetPosSizePixel( Point( aViewportPlaygroundPixel.Width(), aViewportPlaygroundPixel.Height() ), Size( nScrollBarWidth, nScrollBarHeight ) );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir         // paper size
450cdf0e10cSrcweir         if ( windowHasAutomaticLineBreak() )
451cdf0e10cSrcweir             m_pEngine->SetPaperSize( Size( aViewportSizeLogic.Width(), m_pEngine->GetTextHeight() ) );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir         // output area of the view
454cdf0e10cSrcweir         m_pView->SetOutputArea( Rectangle( Point( ), aViewportSizeLogic ) );
455cdf0e10cSrcweir         m_pView->SetVisArea( Rectangle( Point( ), aViewportSizeLogic ) );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir         if ( m_pVScroll )
458cdf0e10cSrcweir         {
459cdf0e10cSrcweir             m_pVScroll->SetVisibleSize( aViewportPlaygroundLogic.Height() );
460cdf0e10cSrcweir 
461cdf0e10cSrcweir             // the default height of a text line ....
462cdf0e10cSrcweir             long nFontHeight = m_pEngine->GetStandardFont(0).GetSize().Height();
463cdf0e10cSrcweir             // ... is the scroll size for the vertical scrollbar
464cdf0e10cSrcweir             m_pVScroll->SetLineSize( nFontHeight );
465cdf0e10cSrcweir             // the viewport width, minus one line, is the page scroll size
466cdf0e10cSrcweir             m_pVScroll->SetPageSize( ::std::max( nFontHeight, aViewportPlaygroundLogic.Height() - nFontHeight ) );
467cdf0e10cSrcweir         }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir         // the font width
470cdf0e10cSrcweir         if ( m_pHScroll )
471cdf0e10cSrcweir         {
472cdf0e10cSrcweir             m_pHScroll->SetVisibleSize( aViewportPlaygroundLogic.Width() );
473cdf0e10cSrcweir 
474cdf0e10cSrcweir             long nFontWidth = m_pEngine->GetStandardFont(0).GetSize().Width();
475cdf0e10cSrcweir             if ( !nFontWidth )
476cdf0e10cSrcweir             {
477cdf0e10cSrcweir                 m_pViewport->Push( PUSH_FONT );
478cdf0e10cSrcweir                 m_pViewport->SetFont( m_pEngine->GetStandardFont(0) );
479cdf0e10cSrcweir                 nFontWidth = m_pViewport->GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM( "x" ) ) );
480cdf0e10cSrcweir                 m_pViewport->Pop();
481cdf0e10cSrcweir             }
482cdf0e10cSrcweir             // ... is the scroll size for the horizontal scrollbar
483cdf0e10cSrcweir             m_pHScroll->SetLineSize( 5 * nFontWidth );
484cdf0e10cSrcweir             // the viewport height, minus one character, is the page scroll size
485cdf0e10cSrcweir             m_pHScroll->SetPageSize( ::std::max( nFontWidth, aViewportPlaygroundLogic.Width() - nFontWidth ) );
486cdf0e10cSrcweir         }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir         // update range and position of the scrollbars
489cdf0e10cSrcweir         updateScrollbars();
490cdf0e10cSrcweir     }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     //--------------------------------------------------------------------
updateScrollbars()493cdf0e10cSrcweir     void RichTextControlImpl::updateScrollbars()
494cdf0e10cSrcweir     {
495cdf0e10cSrcweir         if ( m_pVScroll )
496cdf0e10cSrcweir         {
497cdf0e10cSrcweir             long nOverallTextHeight = m_pEngine->GetTextHeight();
498cdf0e10cSrcweir             m_pVScroll->SetRange( Range( 0, nOverallTextHeight ) );
499cdf0e10cSrcweir             m_pVScroll->SetThumbPos( m_pView->GetVisArea().Top() );
500cdf0e10cSrcweir         }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         if ( m_pHScroll )
503cdf0e10cSrcweir         {
504cdf0e10cSrcweir             Size aPaperSize( m_pEngine->GetPaperSize() );
505cdf0e10cSrcweir             long nOverallTextWidth = ( aPaperSize.Width() == EMPTY_PAPER_SIZE ) ? m_pEngine->CalcTextWidth() : aPaperSize.Width();
506cdf0e10cSrcweir             m_pHScroll->SetRange( Range( 0, nOverallTextWidth ) );
507cdf0e10cSrcweir             m_pHScroll->SetThumbPos( m_pView->GetVisArea().Left() );
508cdf0e10cSrcweir         }
509cdf0e10cSrcweir     }
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     //--------------------------------------------------------------------
notifyInitShow()512cdf0e10cSrcweir     void RichTextControlImpl::notifyInitShow()
513cdf0e10cSrcweir     {
514cdf0e10cSrcweir         if ( !m_bHasEverBeenShown )
515cdf0e10cSrcweir         {
516cdf0e10cSrcweir             m_bHasEverBeenShown = true;
517cdf0e10cSrcweir             layoutWindow();
518cdf0e10cSrcweir         }
519cdf0e10cSrcweir     }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     //--------------------------------------------------------------------
notifyStyleChanged()522cdf0e10cSrcweir     void RichTextControlImpl::notifyStyleChanged()
523cdf0e10cSrcweir     {
524cdf0e10cSrcweir         ensureScrollbars();
525cdf0e10cSrcweir         ensureLineBreakSetting();
526cdf0e10cSrcweir     }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir     //--------------------------------------------------------------------
notifyZoomChanged()529cdf0e10cSrcweir     void RichTextControlImpl::notifyZoomChanged()
530cdf0e10cSrcweir     {
531cdf0e10cSrcweir         const Fraction& rZoom = m_pAntiImpl->GetZoom();
532cdf0e10cSrcweir 
533cdf0e10cSrcweir         MapMode aMapMode( m_pAntiImpl->GetMapMode() );
534cdf0e10cSrcweir         aMapMode.SetScaleX( rZoom );
535cdf0e10cSrcweir         aMapMode.SetScaleY( rZoom );
536cdf0e10cSrcweir         m_pAntiImpl->SetMapMode( aMapMode );
537cdf0e10cSrcweir 
538cdf0e10cSrcweir         m_pViewport->SetZoom( rZoom );
539cdf0e10cSrcweir         m_pViewport->SetMapMode( aMapMode );
540cdf0e10cSrcweir 
541cdf0e10cSrcweir         layoutWindow();
542cdf0e10cSrcweir     }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir     //--------------------------------------------------------------------
windowHasAutomaticLineBreak()545cdf0e10cSrcweir     bool RichTextControlImpl::windowHasAutomaticLineBreak()
546cdf0e10cSrcweir     {
547cdf0e10cSrcweir         return ( m_pAntiImpl->GetStyle() & WB_WORDBREAK ) != 0;
548cdf0e10cSrcweir     }
549cdf0e10cSrcweir 
550cdf0e10cSrcweir     //--------------------------------------------------------------------
SetReadOnly(bool _bReadOnly)551cdf0e10cSrcweir     void RichTextControlImpl::SetReadOnly( bool _bReadOnly )
552cdf0e10cSrcweir     {
553cdf0e10cSrcweir         m_pView->SetReadOnly( _bReadOnly );
554cdf0e10cSrcweir     }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir     //--------------------------------------------------------------------
IsReadOnly() const557cdf0e10cSrcweir     bool RichTextControlImpl::IsReadOnly() const
558cdf0e10cSrcweir     {
559cdf0e10cSrcweir         return m_pView->IsReadOnly( );
560cdf0e10cSrcweir     }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir     //--------------------------------------------------------------------
563cdf0e10cSrcweir     namespace
564cdf0e10cSrcweir     {
lcl_inflate(Rectangle & _rRect,long _nInflateX,long _nInflateY)565cdf0e10cSrcweir         static void lcl_inflate( Rectangle& _rRect, long _nInflateX, long _nInflateY )
566cdf0e10cSrcweir         {
567cdf0e10cSrcweir             _rRect.Left() -= _nInflateX;
568cdf0e10cSrcweir             _rRect.Right() += _nInflateX;
569cdf0e10cSrcweir             _rRect.Top() -= _nInflateY;
570cdf0e10cSrcweir             _rRect.Bottom() += _nInflateY;
571cdf0e10cSrcweir         }
572cdf0e10cSrcweir     }
573cdf0e10cSrcweir     //--------------------------------------------------------------------
HandleCommand(const CommandEvent & _rEvent)574cdf0e10cSrcweir     long RichTextControlImpl::HandleCommand( const CommandEvent& _rEvent )
575cdf0e10cSrcweir     {
576cdf0e10cSrcweir         if (  ( _rEvent.GetCommand() == COMMAND_WHEEL )
577cdf0e10cSrcweir            || ( _rEvent.GetCommand() == COMMAND_STARTAUTOSCROLL )
578cdf0e10cSrcweir            || ( _rEvent.GetCommand() == COMMAND_AUTOSCROLL )
579cdf0e10cSrcweir            )
580cdf0e10cSrcweir         {
581cdf0e10cSrcweir             m_pAntiImpl->HandleScrollCommand( _rEvent, m_pHScroll, m_pVScroll );
582cdf0e10cSrcweir             return 1;
583cdf0e10cSrcweir         }
584cdf0e10cSrcweir         return 0;
585cdf0e10cSrcweir     }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     //--------------------------------------------------------------------
Draw(OutputDevice * _pDev,const Point & _rPos,const Size & _rSize,sal_uLong)588cdf0e10cSrcweir     void RichTextControlImpl::Draw( OutputDevice* _pDev, const Point& _rPos, const Size& _rSize, sal_uLong /*_nFlags*/ )
589cdf0e10cSrcweir     {
590cdf0e10cSrcweir         // need to normalize the map mode of the device - every paint operation on any device needs
591cdf0e10cSrcweir         // to use the same map mode
592cdf0e10cSrcweir         _pDev->Push( PUSH_MAPMODE | PUSH_LINECOLOR | PUSH_FILLCOLOR );
593cdf0e10cSrcweir 
594cdf0e10cSrcweir         // enforce our "normalize map mode" on the device
595cdf0e10cSrcweir         MapMode aRefMapMode( m_pEngine->GetRefDevice()->GetMapMode() );
596cdf0e10cSrcweir         MapMode aOriginalMapMode( _pDev->GetMapMode() );
597cdf0e10cSrcweir         MapMode aNormalizedMapMode( aRefMapMode.GetMapUnit(), aRefMapMode.GetOrigin(), aOriginalMapMode.GetScaleX(), aOriginalMapMode.GetScaleY() );
598cdf0e10cSrcweir         _pDev->SetMapMode( aNormalizedMapMode );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir         // translate coordinates
601cdf0e10cSrcweir         Point aPos( _rPos );
602cdf0e10cSrcweir         Size aSize( _rSize );
603cdf0e10cSrcweir         if ( aOriginalMapMode.GetMapUnit() == MAP_PIXEL )
604cdf0e10cSrcweir         {
605cdf0e10cSrcweir             aPos = _pDev->PixelToLogic( _rPos, aNormalizedMapMode );
606cdf0e10cSrcweir             aSize = _pDev->PixelToLogic( _rSize, aNormalizedMapMode );
607cdf0e10cSrcweir         }
608cdf0e10cSrcweir         else
609cdf0e10cSrcweir         {
610cdf0e10cSrcweir             aPos = OutputDevice::LogicToLogic( _rPos, aOriginalMapMode, aNormalizedMapMode );
611cdf0e10cSrcweir             aSize = OutputDevice::LogicToLogic( _rSize, aOriginalMapMode, aNormalizedMapMode );
612cdf0e10cSrcweir         }
613cdf0e10cSrcweir 
614cdf0e10cSrcweir         Rectangle aPlayground( aPos, aSize );
615cdf0e10cSrcweir         Size aOnePixel( _pDev->PixelToLogic( Size( 1, 1 ) ) );
616cdf0e10cSrcweir         aPlayground.Right() -= aOnePixel.Width();
617cdf0e10cSrcweir         aPlayground.Bottom() -= aOnePixel.Height();
618cdf0e10cSrcweir 
619cdf0e10cSrcweir         // background
620cdf0e10cSrcweir         _pDev->SetLineColor();
621cdf0e10cSrcweir         _pDev->DrawRect( aPlayground );
622cdf0e10cSrcweir 
623cdf0e10cSrcweir         // do we need to draw a border?
624cdf0e10cSrcweir         bool bBorder = ( m_pAntiImpl->GetStyle() & WB_BORDER );
625cdf0e10cSrcweir         if ( bBorder )
626cdf0e10cSrcweir             _pDev->SetLineColor( m_pAntiImpl->GetSettings().GetStyleSettings().GetMonoColor() );
627cdf0e10cSrcweir         else
628cdf0e10cSrcweir             _pDev->SetLineColor();
629cdf0e10cSrcweir         _pDev->SetFillColor( m_pAntiImpl->GetBackground().GetColor() );
630cdf0e10cSrcweir         _pDev->DrawRect( aPlayground );
631cdf0e10cSrcweir 
632cdf0e10cSrcweir         if ( bBorder )
633cdf0e10cSrcweir             // don't draw the text over the border
634cdf0e10cSrcweir             lcl_inflate( aPlayground, -aOnePixel.Width(), -aOnePixel.Height() );
635cdf0e10cSrcweir 
636cdf0e10cSrcweir         // leave a space of one pixel between the "surroundings" of the control
637cdf0e10cSrcweir         // and the content
638cdf0e10cSrcweir         lcl_inflate( aPlayground, -aOnePixel.Width(), -aOnePixel.Height() );
639cdf0e10cSrcweir         lcl_inflate( aPlayground, -aOnePixel.Width(), -aOnePixel.Height() );
640cdf0e10cSrcweir 
641cdf0e10cSrcweir         // actually draw the content
642cdf0e10cSrcweir         m_pEngine->Draw( _pDev, aPlayground, Point(), sal_True );
643cdf0e10cSrcweir 
644cdf0e10cSrcweir         _pDev->Pop();
645cdf0e10cSrcweir     }
646cdf0e10cSrcweir 
647cdf0e10cSrcweir     //--------------------------------------------------------------------
SetBackgroundColor()648cdf0e10cSrcweir     void RichTextControlImpl::SetBackgroundColor( )
649cdf0e10cSrcweir     {
650cdf0e10cSrcweir         SetBackgroundColor( Application::GetSettings().GetStyleSettings().GetFieldColor() );
651cdf0e10cSrcweir     }
652cdf0e10cSrcweir 
653cdf0e10cSrcweir     //--------------------------------------------------------------------
SetBackgroundColor(const Color & _rColor)654cdf0e10cSrcweir     void RichTextControlImpl::SetBackgroundColor( const Color& _rColor )
655cdf0e10cSrcweir     {
656cdf0e10cSrcweir         Wallpaper aWallpaper( _rColor );
657cdf0e10cSrcweir         m_pAntiImpl->SetBackground( aWallpaper );
658cdf0e10cSrcweir         m_pViewport->SetBackground( aWallpaper );
659cdf0e10cSrcweir     }
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     //--------------------------------------------------------------------
SetHideInactiveSelection(bool _bHide)662cdf0e10cSrcweir     void RichTextControlImpl::SetHideInactiveSelection( bool _bHide )
663cdf0e10cSrcweir     {
664cdf0e10cSrcweir         m_pViewport->SetHideInactiveSelection( _bHide );
665cdf0e10cSrcweir     }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     //--------------------------------------------------------------------
GetHideInactiveSelection() const668cdf0e10cSrcweir     bool RichTextControlImpl::GetHideInactiveSelection() const
669cdf0e10cSrcweir     {
670cdf0e10cSrcweir         return m_pViewport->GetHideInactiveSelection( );
671cdf0e10cSrcweir     }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir //........................................................................
674cdf0e10cSrcweir }   // namespace frm
675cdf0e10cSrcweir //........................................................................
676cdf0e10cSrcweir 
677