1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef _ACCMAP_HXX 28*cdf0e10cSrcweir #define _ACCMAP_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <cppuhelper/weakref.hxx> 31*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 32*cdf0e10cSrcweir #include <vos/ref.hxx> 33*cdf0e10cSrcweir #include <vos/mutex.hxx> 34*cdf0e10cSrcweir #include <svx/IAccessibleViewForwarder.hxx> 35*cdf0e10cSrcweir #include <svx/IAccessibleParent.hxx> 36*cdf0e10cSrcweir #include <tools/debug.hxx> 37*cdf0e10cSrcweir #include <tools/fract.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <vector> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir class ViewShell; 42*cdf0e10cSrcweir class Rectangle; 43*cdf0e10cSrcweir class SwFrm; 44*cdf0e10cSrcweir class SwTxtFrm; 45*cdf0e10cSrcweir class SwPageFrm; 46*cdf0e10cSrcweir class SwAccessibleContext; 47*cdf0e10cSrcweir class SwAccessibleContextMap_Impl; 48*cdf0e10cSrcweir class SwAccessibleEventList_Impl; 49*cdf0e10cSrcweir class SwAccessibleEventMap_Impl; 50*cdf0e10cSrcweir class SwShapeList_Impl; 51*cdf0e10cSrcweir class SdrObject; 52*cdf0e10cSrcweir namespace accessibility { 53*cdf0e10cSrcweir class AccessibleShape; 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir class SwAccessibleShapeMap_Impl; 56*cdf0e10cSrcweir struct SwAccessibleEvent_Impl; 57*cdf0e10cSrcweir class SwAccessibleSelectedParas_Impl; 58*cdf0e10cSrcweir class SwRect; 59*cdf0e10cSrcweir class MapMode; 60*cdf0e10cSrcweir class SwAccPreviewData; 61*cdf0e10cSrcweir struct PrevwPage; 62*cdf0e10cSrcweir class Window; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // real states for events 65*cdf0e10cSrcweir #define ACC_STATE_EDITABLE 0x01 66*cdf0e10cSrcweir #define ACC_STATE_OPAQUE 0x02 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // pseudo states for events 69*cdf0e10cSrcweir // --> OD 2009-01-07 #i88069# - pseudo state for event TEXT_ATTRIBUTE_CHANGED 70*cdf0e10cSrcweir #define ACC_STATE_TEXT_ATTRIBUTE_CHANGED 0x0200 71*cdf0e10cSrcweir // <-- 72*cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - pseudo state for event TEXT_SELECTION_CHANGED 73*cdf0e10cSrcweir #define ACC_STATE_TEXT_SELECTION_CHANGED 0x0100 74*cdf0e10cSrcweir // <-- 75*cdf0e10cSrcweir #define ACC_STATE_CARET 0x80 76*cdf0e10cSrcweir #define ACC_STATE_RELATION_FROM 0x40 77*cdf0e10cSrcweir #define ACC_STATE_RELATION_TO 0x20 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir #define ACC_STATE_RELATION_MASK 0x60 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir #define ACC_STATE_MASK 0x1F 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - introduce type definition of states 84*cdf0e10cSrcweir typedef sal_uInt16 tAccessibleStates; 85*cdf0e10cSrcweir // <-- 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir class SwAccessibleMap : public accessibility::IAccessibleViewForwarder, 88*cdf0e10cSrcweir public accessibility::IAccessibleParent 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir mutable ::vos::OMutex maMutex; 91*cdf0e10cSrcweir ::vos::OMutex maEventMutex; 92*cdf0e10cSrcweir SwAccessibleContextMap_Impl *mpFrmMap; 93*cdf0e10cSrcweir SwAccessibleShapeMap_Impl *mpShapeMap; 94*cdf0e10cSrcweir SwShapeList_Impl *mpShapes; 95*cdf0e10cSrcweir SwAccessibleEventList_Impl *mpEvents; 96*cdf0e10cSrcweir SwAccessibleEventMap_Impl *mpEventMap; 97*cdf0e10cSrcweir // --> OD 2005-12-13 #i27301# - data structure to keep information about 98*cdf0e10cSrcweir // accessible paragraph, which have a selection. 99*cdf0e10cSrcweir SwAccessibleSelectedParas_Impl* mpSelectedParas; 100*cdf0e10cSrcweir // <-- 101*cdf0e10cSrcweir ViewShell *mpVSh; 102*cdf0e10cSrcweir /// for page preview: store preview data, VisArea, and mapping of 103*cdf0e10cSrcweir /// preview-to-display coordinates 104*cdf0e10cSrcweir SwAccPreviewData* mpPreview; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir ::com::sun::star::uno::WeakReference < ::com::sun::star::accessibility::XAccessible > mxCursorContext; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir sal_Int32 mnPara; 109*cdf0e10cSrcweir sal_Int32 mnFootnote; 110*cdf0e10cSrcweir sal_Int32 mnEndnote; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir sal_Bool mbShapeSelected; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir void FireEvent( const SwAccessibleEvent_Impl& rEvent ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir void AppendEvent( const SwAccessibleEvent_Impl& rEvent ); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir void InvalidateCursorPosition( 120*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 121*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rAcc ); 122*cdf0e10cSrcweir void DoInvalidateShapeSelection(); 123*cdf0e10cSrcweir void DoInvalidateShapeFocus(); 124*cdf0e10cSrcweir void InvalidateShapeSelection(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir void _InvalidateRelationSet( const SwFrm* pFrm, sal_Bool bFrom ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 129*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> 130*cdf0e10cSrcweir _GetDocumentView( sal_Bool bPagePreview ); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir /** method to build up a new data structure of the accessible pararaphs, 133*cdf0e10cSrcweir which have a selection 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir OD 2005-12-13 #i27301# 136*cdf0e10cSrcweir Important note: method has to used inside a mutual exclusive section 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir @author OD 139*cdf0e10cSrcweir */ 140*cdf0e10cSrcweir SwAccessibleSelectedParas_Impl* _BuildSelectedParas(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir public: 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir SwAccessibleMap( ViewShell *pSh ); 145*cdf0e10cSrcweir ~SwAccessibleMap(); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 148*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> GetDocumentView(); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // OD 15.01.2003 #103492# - complete re-factoring of method due to new 151*cdf0e10cSrcweir // page/print preview functionality. 152*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 153*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> GetDocumentPreview( 154*cdf0e10cSrcweir const std::vector<PrevwPage*>& _rPrevwPages, 155*cdf0e10cSrcweir const Fraction& _rScale, 156*cdf0e10cSrcweir const SwPageFrm* _pSelectedPageFrm, 157*cdf0e10cSrcweir const Size& _rPrevwWinSize ); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir ::vos::ORef < SwAccessibleContext > GetContextImpl( 160*cdf0e10cSrcweir const SwFrm *pFrm, 161*cdf0e10cSrcweir sal_Bool bCreate = sal_True ); 162*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 163*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> GetContext( 164*cdf0e10cSrcweir const SwFrm *pFrm, 165*cdf0e10cSrcweir sal_Bool bCreate = sal_True ); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir ::vos::ORef < ::accessibility::AccessibleShape > GetContextImpl( 168*cdf0e10cSrcweir const SdrObject *pObj, 169*cdf0e10cSrcweir SwAccessibleContext *pParentImpl, 170*cdf0e10cSrcweir sal_Bool bCreate = sal_True ); 171*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 172*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> GetContext( 173*cdf0e10cSrcweir const SdrObject *pObj, 174*cdf0e10cSrcweir SwAccessibleContext *pParentImpl, 175*cdf0e10cSrcweir sal_Bool bCreate = sal_True ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir inline ViewShell* GetShell() const 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir return mpVSh; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir const SwRect& GetVisArea() const; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir /** get size of a dedicated preview page 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir OD 15.01.2003 #103492# 187*cdf0e10cSrcweir complete re-factoring of previous method due to new page/print preview 188*cdf0e10cSrcweir functionality. 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir @author OD 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir @param _nPrevwPageNum 193*cdf0e10cSrcweir input parameter - physical page number of page visible in the page preview 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir @return an object of class <Size> 196*cdf0e10cSrcweir */ 197*cdf0e10cSrcweir Size GetPreViewPageSize( sal_uInt16 _nPrevwPageNum ) const; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir void RemoveContext( const SwFrm *pFrm ); 200*cdf0e10cSrcweir void RemoveContext( const SdrObject *pObj ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // Dispose frame and its children if bRecursive is set 203*cdf0e10cSrcweir void Dispose( const SwFrm* pFrm, 204*cdf0e10cSrcweir const SdrObject* pObj, 205*cdf0e10cSrcweir Window* pWindow, 206*cdf0e10cSrcweir sal_Bool bRecursive = sal_False ); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir void InvalidatePosOrSize( const SwFrm* pFrm, 209*cdf0e10cSrcweir const SdrObject* pObj, 210*cdf0e10cSrcweir Window* pWindow, 211*cdf0e10cSrcweir const SwRect& rOldFrm ); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir void InvalidateContent( const SwFrm *pFrm ); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir // --> OD 2009-01-06 #i88069# 216*cdf0e10cSrcweir void InvalidateAttr( const SwTxtFrm& rTxtFrm ); 217*cdf0e10cSrcweir // <-- 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir void InvalidateCursorPosition( const SwFrm *pFrm ); 220*cdf0e10cSrcweir void InvalidateFocus(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir void SetCursorContext( 223*cdf0e10cSrcweir const ::vos::ORef < SwAccessibleContext >& rCursorContext ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir // Invalidate state of whole tree. If an action is open, this call 226*cdf0e10cSrcweir // is processed when the last action ends. 227*cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - use new type definition for <_nStates> 228*cdf0e10cSrcweir void InvalidateStates( tAccessibleStates _nStates, 229*cdf0e10cSrcweir const SwFrm* _pFrm = 0 ); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir void InvalidateRelationSet( const SwFrm* pMaster, const SwFrm* pFollow ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir /** invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir OD 2005-12-01 #i27138# 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir @author OD 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir @param _rTxtFrm 240*cdf0e10cSrcweir input parameter - reference to paragraph, whose CONTENT_FLOWS_FROM/_TO 241*cdf0e10cSrcweir has to be invalidated. 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir @param _bFrom 244*cdf0e10cSrcweir input parameter - boolean indicating, if relation CONTENT_FLOWS_FROM 245*cdf0e10cSrcweir (value <true>) or CONTENT_FLOWS_TO (value <false>) has to be invalidated. 246*cdf0e10cSrcweir */ 247*cdf0e10cSrcweir void InvalidateParaFlowRelation( const SwTxtFrm& _rTxtFrm, 248*cdf0e10cSrcweir const bool _bFrom ); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir /** invalidation of text selection of a paragraph 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir OD 2005-12-12 #i27301# 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir @author OD 255*cdf0e10cSrcweir */ 256*cdf0e10cSrcweir void InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir /** invalidation of text selection of all paragraphs 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir OD 2005-12-13 #i27301# 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir @author OD 263*cdf0e10cSrcweir */ 264*cdf0e10cSrcweir void InvalidateTextSelectionOfAllParas(); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir sal_Int32 GetChildIndex( const SwFrm& rParentFrm, 267*cdf0e10cSrcweir Window& rChild ) const; 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir // update preview data (and fire events if necessary) 270*cdf0e10cSrcweir // OD 15.01.2003 #103492# - complete re-factoring of method due to new 271*cdf0e10cSrcweir // page/print preview functionality. 272*cdf0e10cSrcweir void UpdatePreview( const std::vector<PrevwPage*>& _rPrevwPages, 273*cdf0e10cSrcweir const Fraction& _rScale, 274*cdf0e10cSrcweir const SwPageFrm* _pSelectedPageFrm, 275*cdf0e10cSrcweir const Size& _rPrevwWinSize ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir void InvalidatePreViewSelection( sal_uInt16 nSelPage ); 278*cdf0e10cSrcweir sal_Bool IsPageSelected( const SwPageFrm *pPageFrm ) const; 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir void FireEvents(); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir // IAccessibleViewForwarder 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir virtual sal_Bool IsValid() const; 286*cdf0e10cSrcweir virtual Rectangle GetVisibleArea() const; 287*cdf0e10cSrcweir virtual Point LogicToPixel (const Point& rPoint) const; 288*cdf0e10cSrcweir virtual Size LogicToPixel (const Size& rSize) const; 289*cdf0e10cSrcweir virtual Point PixelToLogic (const Point& rPoint) const; 290*cdf0e10cSrcweir virtual Size PixelToLogic (const Size& rSize) const; 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir // IAccessibleParent 293*cdf0e10cSrcweir virtual sal_Bool ReplaceChild ( 294*cdf0e10cSrcweir ::accessibility::AccessibleShape* pCurrentChild, 295*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape, 296*cdf0e10cSrcweir const long _nIndex, 297*cdf0e10cSrcweir const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo 298*cdf0e10cSrcweir ) throw (::com::sun::star::uno::RuntimeException); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir // additional Core/Pixel conversions for internal use; also works 301*cdf0e10cSrcweir // for preview 302*cdf0e10cSrcweir Point PixelToCore (const Point& rPoint) const; 303*cdf0e10cSrcweir Rectangle CoreToPixel (const Rectangle& rRect) const; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir private: 306*cdf0e10cSrcweir /** get mapping mode for LogicToPixel and PixelToLogic conversions 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir OD 15.01.2003 #103492# 309*cdf0e10cSrcweir Replacement method <PreviewAdjust(..)> by new method <GetMapMode>. 310*cdf0e10cSrcweir Method returns mapping mode of current output device and adjusts it, 311*cdf0e10cSrcweir if the shell is in page/print preview. 312*cdf0e10cSrcweir Necessary, because <PreviewAdjust(..)> changes mapping mode at current 313*cdf0e10cSrcweir output device for mapping logic document positions to page preview window 314*cdf0e10cSrcweir positions and vice versa and doesn't take care to recover its changes. 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir @author OD 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir @param _rPoint 319*cdf0e10cSrcweir input parameter - constant reference to point to determine the mapping 320*cdf0e10cSrcweir mode adjustments for page/print preview. 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir @param _orMapMode 323*cdf0e10cSrcweir output parameter - reference to the mapping mode, which is determined 324*cdf0e10cSrcweir by the method 325*cdf0e10cSrcweir */ 326*cdf0e10cSrcweir void GetMapMode( const Point& _rPoint, 327*cdf0e10cSrcweir MapMode& _orMapMode ) const; 328*cdf0e10cSrcweir }; 329*cdf0e10cSrcweir #endif 330