LCOV - code coverage report
Current view: top level - sw/inc - accmap.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 3 66.7 %
Date: 2015-06-13 12:38:46 Functions: 1 2 50.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 INCLUDED_SW_INC_ACCMAP_HXX
      20             : #define INCLUDED_SW_INC_ACCMAP_HXX
      21             : 
      22             : #include <cppuhelper/weakref.hxx>
      23             : #include <com/sun/star/accessibility/XAccessible.hpp>
      24             : #include <rtl/ref.hxx>
      25             : #include <osl/mutex.hxx>
      26             : #include <svx/IAccessibleViewForwarder.hxx>
      27             : #include <svx/IAccessibleParent.hxx>
      28             : #include <tools/fract.hxx>
      29             : 
      30             : #include <svx/AccessibleControlShape.hxx>
      31             : #include <svx/AccessibleShape.hxx>
      32             : #include "fesh.hxx"
      33             : #include <vector>
      34             : #include <set>
      35             : #include <o3tl/typed_flags_set.hxx>
      36             : 
      37             : class SwAccessibleParagraph;
      38             : class SwViewShell;
      39             : class Rectangle;
      40             : class SwFrm;
      41             : class SwTextFrm;
      42             : class SwPageFrm;
      43             : class SwAccessibleContext;
      44             : class SwAccessibleContextMap_Impl;
      45             : class SwAccessibleEventList_Impl;
      46             : class SwAccessibleEventMap_Impl;
      47             : class SwShapeList_Impl;
      48             : class SdrObject;
      49             : namespace accessibility { class AccessibleShape; }
      50             : class SwAccessibleShapeMap_Impl;
      51             : struct SwAccessibleEvent_Impl;
      52             : class SwAccessibleSelectedParas_Impl;
      53             : class SwRect;
      54             : class MapMode;
      55             : class SwAccPreviewData;
      56             : struct PreviewPage;
      57             : namespace vcl { class Window; }
      58             : 
      59             : enum class AccessibleStates
      60             : {
      61             :     NONE                   = 0x0000,
      62             :     // real states for events
      63             :     EDITABLE               = 0x0001,
      64             :     OPAQUE                 = 0x0002,
      65             :     // pseudo states for events
      66             :     TEXT_ATTRIBUTE_CHANGED = 0x0200,
      67             :     TEXT_SELECTION_CHANGED = 0x0100,
      68             :     CARET                  = 0x0080,
      69             :     RELATION_FROM          = 0x0040,
      70             :     RELATION_TO            = 0x0020,
      71             : };
      72             : namespace o3tl
      73             : {
      74             :     template<> struct typed_flags<AccessibleStates> : is_typed_flags<AccessibleStates, 0x3e3> {};
      75             : }
      76             : 
      77             : class SwAccessibleMap : public ::accessibility::IAccessibleViewForwarder,
      78             :                         public ::accessibility::IAccessibleParent
      79             : {
      80             :     mutable ::osl::Mutex maMutex;
      81             :     ::osl::Mutex maEventMutex;
      82             :     SwAccessibleContextMap_Impl *mpFrmMap;
      83             :     SwAccessibleShapeMap_Impl *mpShapeMap;
      84             :     SwShapeList_Impl *mpShapes;
      85             :     SwAccessibleEventList_Impl *mpEvents;
      86             :     SwAccessibleEventMap_Impl *mpEventMap;
      87             :     // #i27301 data structure to keep information about
      88             :     // accessible paragraph, which have a selection.
      89             :     SwAccessibleSelectedParas_Impl* mpSelectedParas;
      90             :     SwViewShell *mpVSh;
      91             :     /// for page preview: store preview data, VisArea, and mapping of
      92             :     /// preview-to-display coordinates
      93             :     SwAccPreviewData* mpPreview;
      94             : 
      95             :     ::com::sun::star::uno::WeakReference < ::com::sun::star::accessibility::XAccessible > mxCursorContext;
      96             : 
      97             :     sal_Int32 mnPara;
      98             : 
      99             :     bool mbShapeSelected;
     100             : 
     101             :     void FireEvent( const SwAccessibleEvent_Impl& rEvent );
     102             : 
     103             :     void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
     104             : 
     105             :     void InvalidateCursorPosition(
     106             :         const ::com::sun::star::uno::Reference<
     107             :             ::com::sun::star::accessibility::XAccessible>& rAcc );
     108             :     void DoInvalidateShapeSelection(bool bInvalidateFocusMode = false);
     109             : 
     110             :     void InvalidateShapeSelection();
     111             : 
     112             :     //mpSelectedFrmMap contains the old selected objects.
     113             :     SwAccessibleContextMap_Impl *mpSeletedFrmMap;
     114             :     //IvalidateShapeInParaSelection() method is responsible for the updating the selected states of the objects.
     115             :     void InvalidateShapeInParaSelection();
     116             : 
     117             :     void _InvalidateRelationSet( const SwFrm* pFrm, bool bFrom );
     118             : 
     119             :     ::com::sun::star::uno::Reference<
     120             :         ::com::sun::star::accessibility::XAccessible>
     121             :             _GetDocumentView( bool bPagePreview );
     122             : 
     123             :     /** method to build up a new data structure of the accessible paragraphs,
     124             :         which have a selection
     125             : 
     126             :         Important note: method has to used inside a mutual exclusive section
     127             : 
     128             :         @author OD
     129             :     */
     130             :     SwAccessibleSelectedParas_Impl* _BuildSelectedParas();
     131             : 
     132             : public:
     133             : 
     134             :     SwAccessibleMap( SwViewShell *pSh );
     135             :     virtual ~SwAccessibleMap();
     136             : 
     137             :     ::com::sun::star::uno::Reference<
     138             :         ::com::sun::star::accessibility::XAccessible> GetDocumentView();
     139             : 
     140             :     ::com::sun::star::uno::Reference<
     141             :         ::com::sun::star::accessibility::XAccessible> GetDocumentPreview(
     142             :                             const std::vector<PreviewPage*>& _rPreviewPages,
     143             :                             const Fraction&  _rScale,
     144             :                             const SwPageFrm* _pSelectedPageFrm,
     145             :                             const Size&      _rPreviewWinSize );
     146             : 
     147             :     ::rtl::Reference < SwAccessibleContext > GetContextImpl(
     148             :                                                  const SwFrm *pFrm,
     149             :                                                 bool bCreate = true );
     150             :     ::com::sun::star::uno::Reference<
     151             :         ::com::sun::star::accessibility::XAccessible> GetContext(
     152             :                                                  const SwFrm *pFrm,
     153             :                                                 bool bCreate = true );
     154             : 
     155             :     ::rtl::Reference < ::accessibility::AccessibleShape > GetContextImpl(
     156             :                                         const SdrObject *pObj,
     157             :                                         SwAccessibleContext *pParentImpl,
     158             :                                         bool bCreate = true );
     159             :     ::com::sun::star::uno::Reference<
     160             :         ::com::sun::star::accessibility::XAccessible> GetContext(
     161             :                                         const SdrObject *pObj,
     162             :                                         SwAccessibleContext *pParentImpl,
     163             :                                         bool bCreate = true );
     164             : 
     165       20256 :     inline SwViewShell* GetShell() const
     166             :     {
     167       20256 :         return mpVSh;
     168             :     }
     169             :     static bool IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh);
     170             :     void AddShapeContext(const SdrObject *pObj,
     171             :                              ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccShape);
     172             : 
     173             :     void AddGroupContext(const SdrObject *pParentObj,
     174             :                     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccParent);
     175             :     void RemoveGroupContext(const SdrObject *pParentObj, ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccParent);
     176             : 
     177             :     const SwRect& GetVisArea() const;
     178             : 
     179             :     /** get size of a dedicated preview page
     180             : 
     181             :         @author OD
     182             : 
     183             :         @param _nPreviewPageNum
     184             :         input parameter - physical page number of page visible in the page preview
     185             : 
     186             :         @return an object of class <Size>
     187             :     */
     188             :     Size GetPreviewPageSize( sal_uInt16 _nPreviewPageNum ) const;
     189             : 
     190             :     void RemoveContext( const SwFrm *pFrm );
     191             :     void RemoveContext( const SdrObject *pObj );
     192             : 
     193             :     // Dispose frame and its children if bRecursive is set
     194             :     void Dispose( const SwFrm* pFrm,
     195             :                   const SdrObject* pObj,
     196             :                   vcl::Window* pWindow,
     197             :                   bool bRecursive = false );
     198             : 
     199             :     void InvalidatePosOrSize( const SwFrm* pFrm,
     200             :                               const SdrObject* pObj,
     201             :                               vcl::Window* pWindow,
     202             :                               const SwRect& rOldFrm );
     203             : 
     204             :     void InvalidateContent( const SwFrm *pFrm );
     205             : 
     206             :     void InvalidateAttr( const SwTextFrm& rTextFrm );
     207             : 
     208             :     void InvalidateCursorPosition( const SwFrm *pFrm );
     209             :     void InvalidateFocus();
     210             :     void SetCursorContext(
     211             :         const ::rtl::Reference < SwAccessibleContext >& rCursorContext );
     212             : 
     213             :     // Invalidate state of whole tree. If an action is open, this call
     214             :     // is processed when the last action ends.
     215             :     void InvalidateStates( AccessibleStates _nStates,
     216             :                            const SwFrm* _pFrm = 0 );
     217             : 
     218             :     void InvalidateRelationSet( const SwFrm* pMaster, const SwFrm* pFollow );
     219             : 
     220             :     /** invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
     221             : 
     222             :         @author OD
     223             : 
     224             :         @param _rTextFrm
     225             :         input parameter - reference to paragraph, whose CONTENT_FLOWS_FROM/_TO
     226             :         has to be invalidated.
     227             : 
     228             :         @param _bFrom
     229             :         input parameter - boolean indicating, if relation CONTENT_FLOWS_FROM
     230             :         (value <true>) or CONTENT_FLOWS_TO (value <false>) has to be invalidated.
     231             :     */
     232             :     void InvalidateParaFlowRelation( const SwTextFrm& _rTextFrm,
     233             :                                      const bool _bFrom );
     234             : 
     235             :     /** invalidation of text selection of a paragraph
     236             : 
     237             :         @author OD
     238             :     */
     239             :     void InvalidateParaTextSelection( const SwTextFrm& _rTextFrm );
     240             : 
     241             :     /** invalidation of text selection of all paragraphs
     242             : 
     243             :         @author OD
     244             :     */
     245             :     void InvalidateTextSelectionOfAllParas();
     246             : 
     247             :     sal_Int32 GetChildIndex( const SwFrm& rParentFrm,
     248             :                              vcl::Window& rChild ) const;
     249             : 
     250             :     // update preview data (and fire events if necessary)
     251             :     void UpdatePreview( const std::vector<PreviewPage*>& _rPreviewPages,
     252             :                         const Fraction&  _rScale,
     253             :                         const SwPageFrm* _pSelectedPageFrm,
     254             :                         const Size&      _rPreviewWinSize );
     255             : 
     256             :     void InvalidatePreviewSelection( sal_uInt16 nSelPage );
     257             :     bool IsPageSelected( const SwPageFrm *pPageFrm ) const;
     258             : 
     259             :     void FireEvents();
     260             : 
     261             :     // IAccessibleViewForwarder
     262             : 
     263             :     virtual bool IsValid() const SAL_OVERRIDE;
     264             :     virtual Rectangle GetVisibleArea() const SAL_OVERRIDE;
     265             :     virtual Point LogicToPixel (const Point& rPoint) const SAL_OVERRIDE;
     266             :     virtual Size LogicToPixel (const Size& rSize) const SAL_OVERRIDE;
     267             :     virtual Point PixelToLogic (const Point& rPoint) const SAL_OVERRIDE;
     268             :     virtual Size PixelToLogic (const Size& rSize) const SAL_OVERRIDE;
     269             : 
     270             :     // IAccessibleParent
     271             :     virtual bool ReplaceChild (
     272             :         ::accessibility::AccessibleShape* pCurrentChild,
     273             :         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
     274             :         const long _nIndex,
     275             :         const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
     276             :     )   throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     277             :     virtual ::accessibility::AccessibleControlShape* GetAccControlShapeFromModel
     278             :         (::com::sun::star::beans::XPropertySet* pSet)
     279             :         throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     280             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >   GetAccessibleCaption (
     281             :         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape)
     282             :     throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     283             : 
     284             :     // additional Core/Pixel conversions for internal use; also works
     285             :     // for preview
     286             :     Point PixelToCore (const Point& rPoint) const;
     287             :     Rectangle CoreToPixel (const Rectangle& rRect) const;
     288             : 
     289             : private:
     290             :     /** get mapping mode for LogicToPixel and PixelToLogic conversions
     291             : 
     292             :         Replacement method <PreviewAdjust(..)> by new method <GetMapMode>.
     293             :         Method returns mapping mode of current output device and adjusts it,
     294             :         if the shell is in page/print preview.
     295             :         Necessary, because <PreviewAdjust(..)> changes mapping mode at current
     296             :         output device for mapping logic document positions to page preview window
     297             :         positions and vice versa and doesn't take care to recover its changes.
     298             : 
     299             :         @author OD
     300             : 
     301             :         @param _rPoint
     302             :         input parameter - constant reference to point to determine the mapping
     303             :         mode adjustments for page/print preview.
     304             : 
     305             :         @param _orMapMode
     306             :         output parameter - reference to the mapping mode, which is determined
     307             :         by the method
     308             :     */
     309             :     void GetMapMode( const Point& _rPoint,
     310             :                      MapMode&     _orMapMode ) const;
     311             : public:
     312             :     virtual bool IsDocumentSelAll() SAL_OVERRIDE;
     313             : 
     314             :     ::com::sun::star::uno::WeakReference < ::com::sun::star::accessibility::XAccessible >
     315           0 :         GetCursorContext() const { return mxCursorContext; }
     316             : 
     317             :     //Para Container for InvalidateCursorPosition
     318             :     typedef std::set< SwAccessibleParagraph* >  SET_PARA;
     319             :     SET_PARA m_setParaAdd;
     320             :     SET_PARA m_setParaRemove;
     321             : };
     322             : #endif
     323             : 
     324             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11