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

Generated by: LCOV version 1.10