LCOV - code coverage report
Current view: top level - sw/inc - accmap.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 3 66.7 %
Date: 2014-11-03 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             : class SwAccessibleParagraph;
      36             : 
      37             : class SwViewShell;
      38             : class Rectangle;
      39             : class SwFrm;
      40             : class SwTxtFrm;
      41             : class SwPageFrm;
      42             : class SwAccessibleContext;
      43             : class SwAccessibleContextMap_Impl;
      44             : class SwAccessibleEventList_Impl;
      45             : class SwAccessibleEventMap_Impl;
      46             : class SwShapeList_Impl;
      47             : class SdrObject;
      48             : namespace accessibility {
      49             :     class AccessibleShape;
      50             : }
      51             : class SwAccessibleShapeMap_Impl;
      52             : struct SwAccessibleEvent_Impl;
      53             : class SwAccessibleSelectedParas_Impl;
      54             : class SwRect;
      55             : class MapMode;
      56             : class SwAccPreviewData;
      57             : struct PreviewPage;
      58             : namespace vcl { class Window; }
      59             : 
      60             : // real states for events
      61             : #define ACC_STATE_EDITABLE 0x01
      62             : #define ACC_STATE_OPAQUE 0x02
      63             : 
      64             : // pseudo states for events
      65             : #define ACC_STATE_TEXT_ATTRIBUTE_CHANGED 0x0200
      66             : #define ACC_STATE_TEXT_SELECTION_CHANGED 0x0100
      67             : #define ACC_STATE_CARET 0x80
      68             : #define ACC_STATE_RELATION_FROM 0x40
      69             : #define ACC_STATE_RELATION_TO 0x20
      70             : 
      71             : #define ACC_STATE_RELATION_MASK 0x60
      72             : 
      73             : #define ACC_STATE_MASK 0x1F
      74             : 
      75             : typedef sal_uInt16 tAccessibleStates;
      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       22778 :     inline SwViewShell* GetShell() const
     166             :     {
     167       22778 :         return mpVSh;
     168             :     }
     169             :     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 SwTxtFrm& rTxtFrm );
     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( tAccessibleStates _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 _rTxtFrm
     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 SwTxtFrm& _rTxtFrm,
     233             :                                      const bool _bFrom );
     234             : 
     235             :     /** invalidation of text selection of a paragraph
     236             : 
     237             :         @author OD
     238             :     */
     239             :     void InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm );
     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.10