LCOV - code coverage report
Current view: top level - forms/source/richtext - richtextimplcontrol.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 6 33.3 %
Date: 2015-06-13 12:38:46 Functions: 2 6 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTIMPLCONTROL_HXX
      20             : #define INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTIMPLCONTROL_HXX
      21             : 
      22             : #include "rtattributehandler.hxx"
      23             : #include "richtextviewport.hxx"
      24             : #include "richtextengine.hxx"
      25             : #include <vcl/scrbar.hxx>
      26             : #include <editeng/editdata.hxx>
      27             : 
      28             : #include <map>
      29             : 
      30             : class EditView;
      31             : class EditStatus;
      32             : namespace vcl { class Window; }
      33             : class SvxScriptSetItem;
      34             : 
      35             : namespace frm
      36             : {
      37             : 
      38             : 
      39             :     class ITextAttributeListener;
      40             :     class ITextSelectionListener;
      41             :     class RichTextViewPort;
      42             : 
      43             :     class RichTextControlImpl : public IEngineStatusListener
      44             :     {
      45             :         typedef ::std::map< AttributeId, AttributeState >                           StateCache;
      46             :         typedef ::std::map< AttributeId, ::rtl::Reference< IAttributeHandler > >    AttributeHandlerPool;
      47             :         typedef ::std::map< AttributeId, ITextAttributeListener* >                  AttributeListenerPool;
      48             : 
      49             :         StateCache              m_aLastKnownStates;
      50             :         AttributeHandlerPool    m_aAttributeHandlers;
      51             :         AttributeListenerPool   m_aAttributeListeners;
      52             : 
      53             :         ESelection              m_aLastKnownSelection;
      54             : 
      55             :         VclPtr<Control>                m_pAntiImpl;
      56             :         VclPtr<RichTextViewPort>       m_pViewport;
      57             :         VclPtr<ScrollBar>              m_pHScroll;
      58             :         VclPtr<ScrollBar>              m_pVScroll;
      59             :         VclPtr<ScrollBarBox>           m_pScrollCorner;
      60             :         RichTextEngine*         m_pEngine;
      61             :         EditView*               m_pView;
      62             :         ITextAttributeListener* m_pTextAttrListener;
      63             :         ITextSelectionListener* m_pSelectionListener;
      64             :         bool                    m_bHasEverBeenShown;
      65             : 
      66             :     public:
      67           0 :         struct GrantAccess { friend class RichTextControl; private: GrantAccess() { } };
      68           0 :         inline EditView*        getView( const GrantAccess& ) const     { return m_pView; }
      69           0 :         inline RichTextEngine*  getEngine( const GrantAccess& ) const   { return m_pEngine; }
      70           0 :         inline vcl::Window*          getViewport( const GrantAccess& ) const { return m_pViewport; }
      71             : 
      72             :     public:
      73             :         RichTextControlImpl( Control* _pAntiImpl, RichTextEngine* _pEngine,
      74             :             ITextAttributeListener* _pTextAttrListener, ITextSelectionListener* _pSelectionListener );
      75             :         virtual ~RichTextControlImpl();
      76             : 
      77             :         /** updates the cache with the state of all attribute values from the given set, notifies
      78             :             the listener if the state changed
      79             :         */
      80             :         void    updateAllAttributes( );
      81             : 
      82             :         /** updates the cache with the state of the attribute given by which id, notifies
      83             :             the listener if the state changed
      84             :         */
      85             :         void    updateAttribute( AttributeId _nAttribute );
      86             : 
      87             :         /// enables the callback for a particular attribute
      88             :         void    enableAttributeNotification( AttributeId _nAttributeId, ITextAttributeListener* _pListener = NULL );
      89             : 
      90             :         /// disables the change notifications for a particular attribute
      91             :         void    disableAttributeNotification( AttributeId _nAttributeId );
      92             : 
      93             :         /// executes a toggle of the given attribute
      94             :         bool    executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, AttributeId _nAttribute, const SfxPoolItem* _pArgument, SvtScriptType _nForScriptType );
      95             : 
      96             :         /// retrieves the state of the given attribute from the cache
      97             :         AttributeState  getAttributeState( AttributeId _nAttributeId ) const;
      98             : 
      99             :         /** normalizes the given item so that the state of script dependent attributes
     100             :             is correct considering the current script type
     101             : 
     102             :             There are some attributes which are script dependent, e.g. the CharPosture. This means
     103             :             that in real, there are 3 attributes for this, one for every possible script type (latin,
     104             :             asian, complex). However, to the out world, we behave as if there is only one attribute:
     105             :             E.g., if the outer world asks for the state of the "CharPosture" attribute, we return
     106             :             the state of either CharPostureLatin, CharPostureAsian, or CharPostureComplex, depending
     107             :             on the script type of the current selection. (In real, it may be more complex since
     108             :             the current selection may contain more than one script type.)
     109             : 
     110             :             This method normalizes a script dependent attribute, so that it's state takes into account
     111             :             the currently selected script type.
     112             :         */
     113             :         void        normalizeScriptDependentAttribute( SvxScriptSetItem& _rScriptSetItem );
     114             : 
     115             :         // gets the script type of the selection in our edit view (with fallback)
     116             :         SvtScriptType  getSelectedScriptType() const;
     117             : 
     118             :         /** re-arranges the view and the scrollbars
     119             :         */
     120             :         void    layoutWindow();
     121             : 
     122             :         /** to be called when the style of our window changed
     123             :         */
     124             :         void    notifyStyleChanged();
     125             : 
     126             :         /** to be called when the zoom of our window changed
     127             :         */
     128             :         void    notifyZoomChanged();
     129             : 
     130             :         /** to be called when the StateChangedType::InitShow event arrives
     131             :         */
     132             :         void    notifyInitShow();
     133             : 
     134             :         // VCL "overrides"
     135             :         void    SetBackgroundColor( );
     136             :         void    SetBackgroundColor( const Color& _rColor );
     137             : 
     138             :         void    SetReadOnly( bool _bReadOnly );
     139             :         bool    IsReadOnly() const;
     140             : 
     141             :         void    SetHideInactiveSelection( bool _bHide );
     142             :         bool    GetHideInactiveSelection() const;
     143             : 
     144             :         /// draws the control onto a given output device
     145             :         void    Draw( OutputDevice* _pDev, const Point& _rPos, const Size& _rSize, DrawFlags _nFlags );
     146             : 
     147             :         /// handles command events arrived at the anti-impl control
     148             :         long    HandleCommand( const CommandEvent& _rEvent );
     149             : 
     150             :     private:
     151             :         // updates the cache with the state provided by the given attribute handler
     152             :         void    implUpdateAttribute( AttributeHandlerPool::const_iterator _pHandler );
     153             : 
     154             :         // updates the cache with the given state, and calls listeners (if necessary)
     155             :         void    implCheckUpdateCache( AttributeId _nAttribute, const AttributeState& _rState );
     156             : 
     157             :         // updates range and position of our scrollbars
     158             :         void    updateScrollbars();
     159             : 
     160             :         // determines whether automatic (soft) line breaks are ON
     161             :         bool    windowHasAutomaticLineBreak();
     162             : 
     163             :         /// hides or shows our scrollbars, according to the current WinBits of the window
     164             :         void    ensureScrollbars();
     165             : 
     166             :         /// ensures that our "automatic line break" setting matches the current WinBits of the window
     167             :         void    ensureLineBreakSetting();
     168             : 
     169          64 :         inline  bool    hasVScrollBar( ) const { return m_pVScroll != nullptr; }
     170          54 :         inline  bool    hasHScrollBar( ) const { return m_pHScroll != nullptr; }
     171             : 
     172             :         // IEngineStatusListener overridables
     173             :         virtual void EditEngineStatusChanged( const EditStatus& _rStatus ) SAL_OVERRIDE;
     174             : 
     175             :     private:
     176             :         DECL_LINK( OnInvalidateAllAttributes, void* );
     177             :         DECL_LINK( OnHScroll, ScrollBar* );
     178             :         DECL_LINK( OnVScroll, ScrollBar* );
     179             :     };
     180             : 
     181             : 
     182             : } // namespace frm
     183             : 
     184             : 
     185             : #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTIMPLCONTROL_HXX
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11