diff options
author | Armin Le Grand <alg@apache.org> | 2013-11-27 16:25:40 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2013-11-27 16:25:40 +0000 |
commit | 812e2a8bf64274e47db572b8ca592f49b1263ad7 (patch) | |
tree | 404f9a7432e94c42a09bb76b33eb7d38186ccff6 /sw/source/core | |
parent | 9818d8d1c64bd93adfaacb8a2f824a9db1f4987d (diff) |
resync to trunk (after accessibility integration)
Diffstat (limited to 'sw/source/core')
138 files changed, 9320 insertions, 1859 deletions
diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index c70a5146e3b0..28a8bc1e2065 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -50,6 +50,14 @@ #include <limits.h> +//IAccessibility2 Implementation 2009----- +#include <ndtxt.hxx> +#include <editeng/brshitem.hxx> +#include <swatrset.hxx> +#include <frmatr.hxx> +#include "acctable.hxx" +//-----IAccessibility2 Implementation 2009 + using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; @@ -91,6 +99,10 @@ void SwAccessibleCell::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) DBG_ASSERT( pVSh, "no shell?" ); if( dynamic_cast< const SwCrsrShell* >(pVSh) ) rStateSet.AddState( AccessibleStateType::SELECTABLE ); + //IAccessibility2 Implementation 2009----- + //Solution:Add resizable state to table cell. + rStateSet.AddState( AccessibleStateType::RESIZABLE ); + //-----IAccessibility2 Implementation 2009 // SELECTED if( IsSelected() ) @@ -105,6 +117,7 @@ void SwAccessibleCell::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) SwAccessibleCell::SwAccessibleCell( SwAccessibleMap *pInitMap, const SwCellFrm *pCellFrm ) : SwAccessibleContext( pInitMap, AccessibleRole::TABLE_CELL, pCellFrm ) + , aSelectionHelper( *this ) , bIsSelected( sal_False ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -112,6 +125,13 @@ SwAccessibleCell::SwAccessibleCell( SwAccessibleMap *pInitMap, SetName( sBoxName ); bIsSelected = IsSelected(); + + //IAccessibility2 Implementation 2009----- + //Need not assign the pointer of accessible table object to m_pAccTable, + //for it already done in SwAccessibleCell::GetTable(); Former codes: + //m_pAccTable= GetTable(); + GetTable(); + //-----IAccessibility2 Implementation 2009 } sal_Bool SwAccessibleCell::_InvalidateMyCursorPos() @@ -132,9 +152,16 @@ sal_Bool SwAccessibleCell::_InvalidateMyCursorPos() } sal_Bool bChanged = bOld != bNew; + //IAccessibility2 Implementation 2009----- if( bChanged ) + { FireStateChangedEvent( AccessibleStateType::SELECTED, bNew ); - + if (m_pAccTable) + { + m_pAccTable->AddSelectionCell(this,bNew); + } + } + //-----IAccessibility2 Implementation 2009 return bChanged; } @@ -158,8 +185,10 @@ sal_Bool SwAccessibleCell::_InvalidateChildrenCursorPos( const SwFrm *pFrm ) { ASSERT( xAccImpl->GetFrm()->IsCellFrm(), "table child is not a cell frame" ) - bChanged |= static_cast< SwAccessibleCell *>( + //IAccessibility2 Implementation 2009----- + bChanged = static_cast< SwAccessibleCell *>( xAccImpl.getBodyPtr() )->_InvalidateMyCursorPos(); + //-----IAccessibility2 Implementation 2009 } else bChanged = sal_True; // If the context is not know we @@ -180,6 +209,22 @@ sal_Bool SwAccessibleCell::_InvalidateChildrenCursorPos( const SwFrm *pFrm ) void SwAccessibleCell::_InvalidateCursorPos() { + //IAccessibility2 Implementation 2009----- + if (IsSelected()) + { + const SwAccessibleChild aChild( GetChild( *(GetMap()), 0 ) ); + if( aChild.IsValid() && aChild.GetSwFrm() ) + { + ::vos::ORef < SwAccessibleContext > xChildImpl( GetMap()->GetContextImpl( aChild.GetSwFrm()) ); + if(xChildImpl.isValid()) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::STATE_CHANGED; + aEvent.NewValue<<=AccessibleStateType::FOCUSED; + xChildImpl->FireAccessibleEvent( aEvent ); + } + } + } const SwFrm *pParent = GetParent( SwAccessibleChild(GetFrm()), IsInPagePreview() ); ASSERT( pParent->IsTabFrm(), "parent is not a tab frame" ); @@ -189,6 +234,8 @@ void SwAccessibleCell::_InvalidateCursorPos() while( pTabFrm ) { + _InvalidateChildrenCursorPos( pTabFrm ); +/* sal_Bool bChanged = _InvalidateChildrenCursorPos( pTabFrm ); if( bChanged ) { @@ -201,9 +248,14 @@ void SwAccessibleCell::_InvalidateCursorPos() xAccImpl->FireAccessibleEvent( aEvent ); } } - +*/ pTabFrm = pTabFrm->GetFollow(); } + if (m_pAccTable) + { + m_pAccTable->FireSelectionEvent(); + } + //-----IAccessibility2 Implementation 2009 } sal_Bool SwAccessibleCell::HasCursor() @@ -274,6 +326,21 @@ void SwAccessibleCell::InvalidatePosOrSize( const SwRect& rOldBox ) uno::Any SwAccessibleCell::queryInterface( const uno::Type& rType ) throw( uno::RuntimeException ) { + //IAccessibility2 Implementation 2009----- + if (rType == ::getCppuType((const uno::Reference<XAccessibleExtendedAttributes>*)0)) + { + uno::Any aR; + aR <<= uno::Reference<XAccessibleExtendedAttributes>(this); + return aR; + } + + if (rType == ::getCppuType((const uno::Reference<XAccessibleSelection>*)0)) + { + uno::Any aR; + aR <<= uno::Reference<XAccessibleSelection>(this); + return aR; + } + //-----IAccessibility2 Implementation 2009 if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleValue > * >( 0 ) ) ) { uno::Reference<XAccessibleValue> xValue = this; @@ -327,7 +394,8 @@ SwFrmFmt* SwAccessibleCell::GetTblBoxFormat() const return pCellFrm->GetTabBox()->GetFrmFmt(); } - +//IAccessibility2 Implementation 2009----- +//Implement TableCell currentValue uno::Any SwAccessibleCell::getCurrentValue( ) throw( uno::RuntimeException ) { @@ -335,9 +403,33 @@ uno::Any SwAccessibleCell::getCurrentValue( ) CHECK_FOR_DEFUNC( XAccessibleValue ); uno::Any aAny; - aAny <<= GetTblBoxFormat()->GetTblBoxValue().GetValue(); + + const SwCellFrm* pCellFrm = static_cast<const SwCellFrm*>( GetFrm() ); + const SwStartNode *pSttNd = pCellFrm->GetTabBox()->GetSttNd(); + if( pSttNd ) + { + ::rtl::OUString strRet; + SwNodeIndex aCntntIdx( *pSttNd, 0 ); + SwCntntNode* pCNd=NULL; + for(int nIndex = 0 ; + 0 != ( pCNd = pSttNd->GetNodes().GoNext( &aCntntIdx ) ) && + aCntntIdx.GetIndex() < pSttNd->EndOfSectionIndex(); + ++nIndex ) + { + if(pCNd && pCNd->IsTxtNode()) + { + if (0 != nIndex) + { + strRet += ::rtl::OUString::createFromAscii(" "); + } + strRet +=((SwTxtNode*)pCNd)->GetTxt(); + } + } + aAny <<= strRet; + } return aAny; } +//-----IAccessibility2 Implementation 2009 sal_Bool SwAccessibleCell::setCurrentValue( const uno::Any& aNumber ) throw( uno::RuntimeException ) @@ -370,3 +462,133 @@ uno::Any SwAccessibleCell::getMinimumValue( ) aAny <<= -DBL_MAX; return aAny; } + +//IAccessibility2 Implementation 2009----- +::rtl::OUString ReplaceOneChar(::rtl::OUString oldOUString, ::rtl::OUString replacedChar, ::rtl::OUString replaceStr) +{ + int iReplace = -1; + iReplace = oldOUString.lastIndexOf(replacedChar); + if (iReplace > -1) + { + for(;iReplace>-1;) + { + oldOUString = oldOUString.replaceAt(iReplace,1, replaceStr); + iReplace=oldOUString.lastIndexOf(replacedChar,iReplace); + } + } + return oldOUString; +} +::rtl::OUString ReplaceFourChar(::rtl::OUString oldOUString) +{ + oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii("\\"),OUString::createFromAscii("\\\\")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii(";"),::rtl::OUString::createFromAscii("\\;")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii("="),::rtl::OUString::createFromAscii("\\=")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii(","),::rtl::OUString::createFromAscii("\\,")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii(":"),::rtl::OUString::createFromAscii("\\:")); + return oldOUString; +} + +::com::sun::star::uno::Any SAL_CALL SwAccessibleCell::getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any strRet; + SwFrmFmt *pFrmFmt = GetTblBoxFormat(); + DBG_ASSERT(pFrmFmt,"Must be Valid"); + + const SwTblBoxFormula& tbl_formula = pFrmFmt->GetTblBoxFormula(); + + ::rtl::OUString strFormula = ReplaceFourChar(tbl_formula.GetFormula()); + ::rtl::OUString strFor = ::rtl::OUString::createFromAscii("Formula:"); + strFor += strFormula; + strFor += ::rtl::OUString::createFromAscii(";") ; + strRet <<= strFor; + + return strRet; +} + +sal_Int32 SAL_CALL SwAccessibleCell::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ + const SvxBrushItem &rBack = GetFrm()->GetAttrSet()->GetBackground(); + sal_uInt32 crBack = rBack.GetColor().GetColor(); + + if (COL_AUTO == crBack) + { + uno::Reference<XAccessible> xAccDoc = getAccessibleParent(); + if (xAccDoc.is()) + { + uno::Reference<XAccessibleComponent> xCompoentDoc(xAccDoc, uno::UNO_QUERY); + if (xCompoentDoc.is()) + { + crBack = (sal_uInt32)xCompoentDoc->getBackground(); + } + } + } + return crBack; +} + +//===== XAccessibleSelection ============================================ +void SwAccessibleCell::selectAccessibleChild( + sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + aSelectionHelper.selectAccessibleChild(nChildIndex); +} + +sal_Bool SwAccessibleCell::isAccessibleChildSelected( + sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + return aSelectionHelper.isAccessibleChildSelected(nChildIndex); +} + +void SwAccessibleCell::clearAccessibleSelection( ) + throw ( uno::RuntimeException ) +{ + aSelectionHelper.clearAccessibleSelection(); +} + +void SwAccessibleCell::selectAllAccessibleChildren( ) + throw ( uno::RuntimeException ) +{ + aSelectionHelper.selectAllAccessibleChildren(); +} + +sal_Int32 SwAccessibleCell::getSelectedAccessibleChildCount( ) + throw ( uno::RuntimeException ) +{ + return aSelectionHelper.getSelectedAccessibleChildCount(); +} + +uno::Reference<XAccessible> SwAccessibleCell::getSelectedAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + return aSelectionHelper.getSelectedAccessibleChild(nSelectedChildIndex); +} + +void SwAccessibleCell::deselectAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + aSelectionHelper.deselectAccessibleChild(nSelectedChildIndex); +} + +SwAccessibleTable *SwAccessibleCell::GetTable() +{ + if (!m_pAccTable) + { + if (!xTableReference.is()) + { + xTableReference = getAccessibleParent(); + #ifdef OSL_DEBUG_LEVEL + uno::Reference<XAccessibleContext> xContextTable(xTableReference, uno::UNO_QUERY); + OSL_ASSERT(xContextTable.is() && xContextTable->getAccessibleRole() == AccessibleRole::TABLE); + #endif + //SwAccessibleTable aTable = *(static_cast<SwAccessibleTable *>(xTable.get())); + } + m_pAccTable = static_cast<SwAccessibleTable *>(xTableReference.get()); + } + return m_pAccTable; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/acccell.hxx b/sw/source/core/access/acccell.hxx index 130ae7c432d9..bc16a660a5a4 100644 --- a/sw/source/core/access/acccell.hxx +++ b/sw/source/core/access/acccell.hxx @@ -26,13 +26,27 @@ #include "acccontext.hxx" #include <com/sun/star/accessibility/XAccessibleValue.hpp> +//IAccessibility2 Implementation 2009----- +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XAccessibleExtendedAttributes_HPP_ +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> +#endif + +#ifndef _ACCSELECTIONHELPER_HXX_ +#include <accselectionhelper.hxx> +#endif +//-----IAccessibility2 Implementation 2009 + class SwCellFrm; +class SwAccessibleTable; class SwFrmFmt; class SwAccessibleCell : public SwAccessibleContext, - ::com::sun::star::accessibility::XAccessibleValue - + ::com::sun::star::accessibility::XAccessibleValue, + ::com::sun::star::accessibility::XAccessibleSelection, + public ::com::sun::star::accessibility::XAccessibleExtendedAttributes { + // Implementation for XAccessibleSelection interface + SwAccessibleSelectionHelper aSelectionHelper; sal_Bool bIsSelected; // protected by base class mutex sal_Bool IsSelected(); @@ -110,6 +124,11 @@ public: //===== XAccessibleValue ================================================ + //===== XAccessibleExtendedAttributes ================================================ + //IAccessibility2 Implementation 2009----- + ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + //-----IAccessibility2 Implementation 2009 private: SwFrmFmt* GetTblBoxFormat() const; @@ -126,6 +145,41 @@ public: virtual ::com::sun::star::uno::Any SAL_CALL getMinimumValue( ) throw (::com::sun::star::uno::RuntimeException); + //IAccessibility2 Implementation 2009----- + //===== XAccessibleComponent ============================================ + sal_Int32 SAL_CALL getBackground() + throw (::com::sun::star::uno::RuntimeException); + + //===== XAccessibleSelection ============================================ + virtual void SAL_CALL selectAccessibleChild( + sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL isAccessibleChildSelected( + sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL clearAccessibleSelection( ) + throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL selectAllAccessibleChildren( ) + throw ( ::com::sun::star::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) + throw ( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL deselectAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + SwAccessibleTable *GetTable(); + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTableReference; + SwAccessibleTable *m_pAccTable; + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index a4a0399747f7..df207e989350 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -60,6 +60,11 @@ #include <acccontext.hxx> #include <svx/AccessibleShape.hxx> #include <comphelper/accessibleeventnotifier.hxx> +//IAccessibility2 Implementation 2009----- +#ifndef _ACCPARA_HXX +#include "accpara.hxx" +#endif +//-----IAccessibility2 Implementation 2009 #include <PostItMgr.hxx> using namespace sw::access; @@ -215,8 +220,11 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" ); const SwFrm* pLower( rLower.GetSwFrm() ); ::vos::ORef< SwAccessibleContext > xAccImpl = - GetMap()->GetContextImpl( pLower, SCROLLED_OUT == eAction || - SCROLLED_IN == eAction ); + //IAccessibility2 Implementation 2009----- + //O is: GetMap()->GetContextImpl( pLower, SCROLLED_OUT == eAction || + // SCROLLED_IN == eAction ); + GetMap()->GetContextImpl( pLower, sal_True ); + //-----IAccessibility2 Implementation 2009 if( xAccImpl.isValid() ) { switch( eAction ) @@ -247,10 +255,15 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, ASSERT( !rLower.AlwaysIncludeAsChild(), "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" ); ::vos::ORef< ::accessibility::AccessibleShape > xAccImpl = + //IAccessibility2 Implementation 2009----- + //O is: GetMap()->GetContextImpl( rLower.GetSdrObject(), + // this, + // SCROLLED_OUT == eAction || + // SCROLLED_IN == eAction ); GetMap()->GetContextImpl( rLower.GetDrawObject(), this, - SCROLLED_OUT == eAction || - SCROLLED_IN == eAction ); + sal_True ); + //-----IAccessibility2 Implementation 2009 if( xAccImpl.isValid() ) { switch( eAction ) @@ -270,8 +283,11 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, xAccImpl->ViewForwarderChanged( ::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, GetMap() ); - DisposeShape( rLower.GetDrawObject(), - xAccImpl.getBodyPtr() ); + //IAccessibility2 Implementation 2009----- + //Remove + //DisposeShape( rLower.GetDrawObject(), + // xAccImpl.getBodyPtr() ); + //-----IAccessibility2 Implementation 2009 } break; case NONE: @@ -380,8 +396,11 @@ void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea ) // the child event. In this case no listener will exist. FireStateChangedEvent( AccessibleStateType::SHOWING, sal_False ); + //IAccessibility2 Implementation 2009----- + //Remove Dispose When scrolledout // We now dispose the frame - Dispose( sal_True ); + // Dispose( sal_True ); + //-----IAccessibility2 Implementation 2009 } // --> OD 2005-12-12 #i27301# - use new type definition for <_nStates> @@ -517,8 +536,14 @@ void SwAccessibleContext::GetStates( // EDITABLE if( bIsEditableState ) + //IAccessibility2 Implementation 2009----- + //Solution:Set editable state to graphic and other object when the document is editable + { rStateSet.AddState( AccessibleStateType::EDITABLE ); - + rStateSet.AddState( AccessibleStateType::RESIZABLE ); + rStateSet.AddState( AccessibleStateType::MOVEABLE ); + } + //-----IAccessibility2 Implementation 2009 // ENABLED rStateSet.AddState( AccessibleStateType::ENABLED ); @@ -554,6 +579,12 @@ SwAccessibleContext::SwAccessibleContext( SwAccessibleMap *pM, , nRole( nR ) , bDisposing( sal_False ) , bRegisteredAtAccessibleMap( true ) + //IAccessibility2 Implementation 2009----- + //Solution:Initialize the begin document load and IfAsynLoad to true + , bBeginDocumentLoad( sal_True ) + , isIfAsynLoad( sal_True ) + , bIsSeletedInDoc( sal_False) + //-----IAccessibility2 Implementation 2009 { InitStates(); DBG_MSG_CD( "constructed" ) @@ -581,6 +612,11 @@ sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleChildCount( void ) vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleContext ) + //IAccessibility2 Implementation 2009----- + //Solution:Notify the frame is a document + if( nRole == AccessibleRole::DOCUMENT ) + bIsAccDocUse = sal_True; + //-----IAccessibility2 Implementation 2009 return bDisposing ? 0 : GetChildCount( *(GetMap()) ); } @@ -593,6 +629,12 @@ uno::Reference< XAccessible> SAL_CALL CHECK_FOR_DEFUNC( XAccessibleContext ) + //IAccessibility2 Implementation 2009----- + //Solution:Notify the frame is a document + if( nRole == AccessibleRole::DOCUMENT ) + bIsAccDocUse = sal_True; + //-----IAccessibility2 Implementation 2009 + const SwAccessibleChild aChild( GetChild( *(GetMap()), nIndex ) ); if( !aChild.IsValid() ) { @@ -608,6 +650,26 @@ uno::Reference< XAccessible> SAL_CALL { ::vos::ORef < SwAccessibleContext > xChildImpl( GetMap()->GetContextImpl( aChild.GetSwFrm(), !bDisposing ) ); + //IAccessibility2 Implementation 2009----- + //Solution:Send out accessible event when begin load. + if( bBeginDocumentLoad && nRole == AccessibleRole::DOCUMENT ) + { + + FireStateChangedEvent( AccessibleStateType::FOCUSABLE,sal_True ); + FireStateChangedEvent( AccessibleStateType::BUSY,sal_True ); + if( !isIfAsynLoad ) + { + FireStateChangedEvent( AccessibleStateType::FOCUSED,sal_True ); + // IA2 CWS. MT: OFFSCREEN == !SHOWING, should stay consistent + // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_True ); + FireStateChangedEvent( AccessibleStateType::SHOWING,sal_True ); + FireStateChangedEvent( AccessibleStateType::BUSY,sal_False ); + // MT: OFFSCREEN again? + // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_False ); + } + bBeginDocumentLoad = sal_False; + } + //-----IAccessibility2 Implementation 2009 if( xChildImpl.isValid() ) { xChildImpl->SetParent( this ); @@ -717,6 +779,11 @@ uno::Reference<XAccessibleStateSet> SAL_CALL ::utl::AccessibleStateSetHelper *pStateSet = new ::utl::AccessibleStateSetHelper; + //IAccessibility2 Implementation 2009----- + if( bIsSeletedInDoc ) + pStateSet->AddState( AccessibleStateType::SELECTED ); + //-----IAccessibility2 Implementation 2009 + uno::Reference<XAccessibleStateSet> xStateSet( pStateSet ); GetStates( *pStateSet ); @@ -988,13 +1055,15 @@ uno::Any SAL_CALL SwAccessibleContext::getAccessibleKeyBinding() sal_Int32 SAL_CALL SwAccessibleContext::getForeground() throw (uno::RuntimeException) { - return 0; + //IAccessibility2 Implementation 2009----- + return COL_BLACK; + //-----IAccessibility2 Implementation 2009 } sal_Int32 SAL_CALL SwAccessibleContext::getBackground() throw (uno::RuntimeException) { - return 0xffffff; + return COL_WHITE; } @@ -1041,6 +1110,12 @@ void SwAccessibleContext::DisposeShape( const SdrObject *pObj, void SwAccessibleContext::ScrolledInShape( const SdrObject* , ::accessibility::AccessibleShape *pAccImpl ) { + //IAccessibility2 Implementation 2009----- + if(NULL == pAccImpl) + { + return ; + } + //-----IAccessibility2 Implementation 2009 AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::CHILD; uno::Reference< XAccessible > xAcc( pAccImpl ); @@ -1184,7 +1259,10 @@ void SwAccessibleContext::InvalidatePosOrSize( const SwRect& ) SwAccessibleChild( GetParent() ).IsVisibleChildrenOnly() ) { // The frame is now invisible -> dispose it - Dispose( sal_True ); + //IAccessibility2 Implementation 2009----- + //Remove + //Dispose( sal_True ); + //-----IAccessibility2 Implementation 2009 } else { @@ -1585,3 +1663,15 @@ void lcl_SwAccessibleContext_DbgMsg( SwAccessibleContext *pThisAcc, aStrm.Flush(); } #endif +//IAccessibility2 Implementation 2009----- +sal_Bool SwAccessibleContext::SetSelectedState(sal_Bool bSeleted) +{ + if(bIsSeletedInDoc != bSeleted) + { + bIsSeletedInDoc = bSeleted; + FireStateChangedEvent( AccessibleStateType::SELECTED, bSeleted ); + return sal_True; + } + return sal_False; +}; +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index e712973b7190..915a46e12627 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -98,6 +98,10 @@ private: // <-- void InitStates(); + //IAccessibility2 Implementation 2009----- + //Solution:Add a member to identify the firt time that document load + sal_Bool bBeginDocumentLoad; + //-----IAccessibility2 Implementation 2009 protected: void SetName( const ::rtl::OUString& rName ) { sName = rName; } @@ -105,7 +109,12 @@ protected: { return nRole; } - + //IAccessibility2 Implementation 2009----- + //Solution:Add a member to identify if the document is Asyn load. + sal_Bool isIfAsynLoad; + //This flag is used to mark the object's selected state. + sal_Bool bIsSeletedInDoc; + //-----IAccessibility2 Implementation 2009 void SetParent( SwAccessibleContext *pParent ); ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> GetWeakParent() const; @@ -172,6 +181,9 @@ protected: public: + //IAccessibility2 Implementation 2009----- + void SetMap(SwAccessibleMap *pM){pMap = pM;} + //-----IAccessibility2 Implementation 2009 void FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventObject& rEvent ); protected: @@ -415,12 +427,15 @@ public: { return Select( 0, pObj, bAdd ); } + //IAccessibility2 Implementation 2009----- + //This method is used to updated the selected state and fire the selected state changed event. + virtual sal_Bool SetSelectedState(sal_Bool bSeleted); + sal_Bool IsSeletedInDoc(){ return bIsSeletedInDoc; } + //-----IAccessibility2 Implementation 2009 static ::rtl::OUString GetResource( sal_uInt16 nResId, const ::rtl::OUString *pArg1 = 0, const ::rtl::OUString *pArg2 = 0 ); - - }; // some heaviliy used exception support diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index 83db96973a2d..fce090d5c4ac 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -45,6 +45,30 @@ #endif #include <pagefrm.hxx> +//IAccessibility2 Implementation 2009----- +#include <editeng/brshitem.hxx> +#include <swatrset.hxx> +#include <frmatr.hxx> +#include "unostyle.hxx" +#include "viewsh.hxx" +#include "docsh.hxx" +#include <crsrsh.hxx> +#include "fesh.hxx" +#include <fmtclds.hxx> +#include <flyfrm.hxx> +#include <colfrm.hxx> +#include <txtfrm.hxx> +#include <sectfrm.hxx> +#include <section.hxx> +#include <svx/unoapi.hxx> +#include <swmodule.hxx> +#include <svtools/colorcfg.hxx> + +#include <fmtanchr.hxx> +#include <viewimp.hxx> +#include <dview.hxx> +#include <dcontact.hxx> +//-----IAccessibility2 Implementation 2009 const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextDocumentView"; const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleDocumentView"; @@ -178,8 +202,17 @@ sal_Int32 SAL_CALL SwAccessibleDocumentBase::getAccessibleIndexInParent (void) for( sal_Int32 i=0; i < nCount; i++ ) { - if( xAcc->getAccessibleChild( i ) == xThis ) - return i; + //IAccessibility2 Implementation 2009----- + try + { + if( xAcc->getAccessibleChild( i ) == xThis ) + return i; + } + catch(::com::sun::star::lang::IndexOutOfBoundsException e) + { + return -1L; + } + //-----IAccessibility2 Implementation 2009 } return -1L; } @@ -190,20 +223,62 @@ OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleDescription (void) return GetResource( STR_ACCESS_DOC_DESC ); } +//IAccessibility2 Implementation 2009----- +OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleName (void) + throw (::com::sun::star::uno::RuntimeException) +{ + OUString sAccName = GetResource( STR_ACCESS_DOC_WORDPROCESSING ); + SwDoc *pDoc = GetShell()->GetDoc(); + if ( pDoc ) + { + OUString sFileName = pDoc->getDocAccTitle(); + if ( !sFileName.getLength() ) + { + SwDocShell* pDocSh = pDoc->GetDocShell(); + if ( pDocSh ) + { + sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME ); + } + } + OUString sReadOnly; + if(pDoc->getDocReadOnly()) + { + sReadOnly = GetResource( STR_ACCESS_DOC_WORDPROCESSING_READONLY ); + } + + if ( sFileName.getLength() ) + { + sAccName = sFileName + sReadOnly + OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sAccName; + } + } + + return sAccName; +} +//-----IAccessibility2 Implementation 2009 + awt::Rectangle SAL_CALL SwAccessibleDocumentBase::getBounds() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + //IAccessibility2 Implementation 2009----- + try + { + vos::OGuard aGuard(Application::GetSolarMutex()); - Window *pWin = GetWindow(); + Window *pWin = GetWindow(); - CHECK_FOR_WINDOW( XAccessibleComponent, pWin ) + CHECK_FOR_WINDOW( XAccessibleComponent, pWin ) - Rectangle aPixBounds( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ) ); - awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(), - aPixBounds.GetWidth(), aPixBounds.GetHeight() ); + Rectangle aPixBounds( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ) ); + awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(), + aPixBounds.GetWidth(), aPixBounds.GetHeight() ); - return aBox; + return aBox; + } + catch(::com::sun::star::lang::IndexOutOfBoundsException e) + { + return awt::Rectangle(); + } + //-----IAccessibility2 Implementation 2009 } @@ -303,6 +378,9 @@ void SwAccessibleDocument::GetStates( // MULTISELECTABLE rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE ); + //IAccessibility2 Implementation 2009----- + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + //-----IAccessibility2 Implementation 2009 } @@ -424,6 +502,24 @@ uno::Any SwAccessibleDocument::queryInterface( uno::Reference<XAccessibleSelection> aSelect = this; aRet <<= aSelect; } + //IAccessibility2 Implementation 2009----- + //Solution:Add XEventListener interface support. + else if ( (rType == ::getCppuType((uno::Reference<com::sun::star::document::XEventListener> *)NULL)) ) + { + uno::Reference<com::sun::star::document::XEventListener> aSelect = this; + aRet <<= aSelect; + } + else if ( rType == ::getCppuType((uno::Reference<XAccessibleExtendedAttributes> *)NULL) ) + { + uno::Reference<XAccessibleExtendedAttributes> aAttribute = this; + aRet <<= aAttribute; + } + else if(rType == ::getCppuType((uno::Reference<XAccessibleGetAccFlowTo> *)NULL) ) + { + uno::Reference<XAccessibleGetAccFlowTo> AccFlowTo = this; + aRet <<= AccFlowTo; + } + //-----IAccessibility2 Implementation 2009 else aRet = SwAccessibleContext::queryInterface( rType ); return aRet; @@ -436,11 +532,16 @@ uno::Sequence< uno::Type > SAL_CALL SwAccessibleDocument::getTypes() uno::Sequence< uno::Type > aTypes( SwAccessibleDocumentBase::getTypes() ); sal_Int32 nIndex = aTypes.getLength(); - aTypes.realloc( nIndex + 1 ); + //IAccessibility2 Implementation 2009----- + //Solution:Reset types memory alloc + //aTypes.realloc( nIndex + 1 ); + aTypes.realloc( nIndex + 2 ); uno::Type* pTypes = aTypes.getArray(); pTypes[nIndex] = ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) ); - + //Solution:Add XEventListener interface support. + pTypes[nIndex + 1 ] = ::getCppuType( static_cast< uno::Reference< com::sun::star::document::XEventListener > * >( 0 ) ); + //-----IAccessibility2 Implementation 2009 return aTypes; } @@ -510,3 +611,418 @@ void SwAccessibleDocument::deselectAccessibleChild( { maSelectionHelper.deselectAccessibleChild( nChildIndex ); } +//IAccessibility2 Implementation 2009----- +//Solution:Implement XEventListener interfaces +void SAL_CALL SwAccessibleDocument::notifyEvent( const ::com::sun::star::document::EventObject& Event ) + throw (::com::sun::star::uno::RuntimeException) +{ + if ( Event.EventName.equalsAscii( "FirstPageShows" ) ) + { + FireStateChangedEvent( AccessibleStateType::FOCUSED,sal_True ); + } + else if ( Event.EventName.equalsAscii( "LoadFinished" ) ) + { + // IA2 CWS. MT: OFFSCREEN == !SHOWING, should stay consistent + // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_True ); + // MT: LoadFinished => Why not SHOWING == TRUE? + FireStateChangedEvent( AccessibleStateType::SHOWING,sal_False ); + } + else if ( Event.EventName.equalsAscii( "FormatFinished" ) ) + { + FireStateChangedEvent( AccessibleStateType::BUSY,sal_False ); + // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_False ); + FireStateChangedEvent( AccessibleStateType::SHOWING,sal_True ); + } + else + { + isIfAsynLoad = sal_False; + } +} + +void SAL_CALL SwAccessibleDocument::disposing( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + uno::Any anyAtrribute; + SwDoc *pDoc = GetShell()->GetDoc(); + + if (!pDoc) + return anyAtrribute; + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( !pCrsrShell ) + return anyAtrribute; + + SwFEShell* pFEShell = dynamic_cast< SwFEShell* >(pCrsrShell); + rtl::OUString sAttrName; + rtl::OUString sValue; + sal_uInt16 nPage, nLogPage; + String sDisplay; + + if( pFEShell ) + { + pFEShell->GetPageNumber(-1,sal_True,nPage,nLogPage,sDisplay); + sAttrName = rtl::OUString::createFromAscii("page-name:"); + + + sValue = sAttrName + sDisplay ; + sAttrName = rtl::OUString::createFromAscii(";page-number:"); + sValue += sAttrName; + sValue += String::CreateFromInt32( nPage ) ; + sAttrName = rtl::OUString::createFromAscii(";total-pages:"); + sValue += sAttrName; + sValue += String::CreateFromInt32( pCrsrShell->GetPageCnt() ) ; + sValue += rtl::OUString::createFromAscii(";"); + + + sAttrName=rtl::OUString::createFromAscii("line-number:"); + + + + SwCntntFrm* pCurrFrm = pCrsrShell->GetCurrFrm(); + SwPageFrm* pCurrPage=((SwFrm*)pCurrFrm)->FindPageFrm(); + sal_uLong nLineNum = 0; + //IAccessibility2 Implementation 2009----- + SwTxtFrm* pTxtFrm = NULL; + SwTxtFrm* pCurrTxtFrm = NULL; + pTxtFrm = static_cast< SwTxtFrm* >(static_cast< SwPageFrm* > (pCurrPage)->ContainsCntnt()); + if (pCurrFrm->IsInFly())//such as, graphic,chart + { + SwFlyFrm *pFlyFrm = pCurrFrm->FindFlyFrm(); + const SwFmtAnchor& rAnchor = pFlyFrm->GetFmt()->GetAnchor(); + RndStdIds eAnchorId = rAnchor.GetAnchorId(); + if(eAnchorId == FLY_AS_CHAR) + { + const SwFrm *pSwFrm = pFlyFrm->GetAnchorFrm(); + if(pSwFrm->IsTxtFrm()) + pCurrTxtFrm = ((SwTxtFrm*)(pSwFrm)); + } + } + else + pCurrTxtFrm = static_cast< SwTxtFrm* >(pCurrFrm); + //check whether the text frame where the Graph/OLE/Frame anchored is in the Header/Footer + SwFrm* pFrm = pCurrTxtFrm; + while ( pFrm && !pFrm->IsHeaderFrm() && !pFrm->IsFooterFrm() ) + pFrm = pFrm->GetUpper(); + if ( pFrm ) + pCurrTxtFrm = NULL; + //check shape + if(pCrsrShell->Imp()->GetDrawView()) + { + const SdrObjectVector aSdrObjectVector(pCrsrShell->Imp()->GetDrawView()->getSelectedSdrObjectVectorFromSdrMarkView()); + + for(sal_uInt32 i(0); i < aSdrObjectVector.size(); ++i ) + { + SdrObject* pObj = aSdrObjectVector[i]; + + // replace formally used 'GetUserCall()' by new notify/listener mechanism + const SwDrawContact* pContact = static_cast< const SwDrawContact* >(findConnectionToSdrObject(pObj)); + + const SwFrmFmt* pFmt = pContact->GetFmt(); + const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); + if( FLY_AS_CHAR != rAnchor.GetAnchorId() ) + pCurrTxtFrm = NULL; + } + } + //calculate line number + if (pCurrTxtFrm && pTxtFrm) + { + if (!(pCurrTxtFrm->IsInTab() || pCurrTxtFrm->IsInFtn())) + { + while( pTxtFrm != pCurrTxtFrm ) + { + //check header/footer + pFrm = pTxtFrm; + while ( pFrm && !pFrm->IsHeaderFrm() && !pFrm->IsFooterFrm() ) + pFrm = pFrm->GetUpper(); + if ( pFrm ) + { + pTxtFrm = static_cast< SwTxtFrm*>(pTxtFrm->GetNextCntntFrm()); + continue; + } + if (!(pTxtFrm->IsInTab() || pTxtFrm->IsInFtn() || pTxtFrm->IsInFly())) + nLineNum += pTxtFrm->GetThisLines(); + pTxtFrm = static_cast< SwTxtFrm* >(pTxtFrm ->GetNextCntntFrm()); + } + SwPaM* pCaret = pCrsrShell->GetCrsr(); + if (!pCurrTxtFrm->IsEmpty() && pCaret) + { + sal_uInt16 nActPos = 0; + if (pCurrTxtFrm->IsTxtFrm()) + { + const SwPosition* pPoint = NULL; + if(pCurrTxtFrm->IsInFly()) + { + SwFlyFrm *pFlyFrm = pCurrTxtFrm->FindFlyFrm(); + const SwFmtAnchor& rAnchor = pFlyFrm->GetFmt()->GetAnchor(); + pPoint= rAnchor.GetCntntAnchor(); + } + else + pPoint = pCaret->GetPoint(); + nActPos = pPoint->nContent.GetIndex(); + nLineNum += pCurrTxtFrm->GetLineCount( nActPos ); + } + else//graphic, form, shape, etc. + { + SwPosition* pPoint = pCaret->GetPoint(); + Point aPt = pCrsrShell->_GetCrsr()->GetPtPos(); + if( pCrsrShell->GetLayout()->GetCrsrOfst( pPoint, aPt/*,* &eTmpState*/ ) ) + { + nActPos = pPoint->nContent.GetIndex(); + nLineNum += pCurrTxtFrm->GetLineCount( nActPos ); + } + } + } + else + ++nLineNum; + } + } + //-----IAccessibility2 Implementation 2009 + + sValue += sAttrName; + sValue += String::CreateFromInt32( nLineNum ) ; + + sValue += rtl::OUString::createFromAscii(";"); + + + SwFrm* pCurrCol=((SwFrm*)pCurrFrm)->FindColFrm(); + + sAttrName=rtl::OUString::createFromAscii("column-number:"); + sValue += sAttrName; + + sal_uInt16 nCurrCol = 1; + if(pCurrCol!=NULL) + { + //SwLayoutFrm* pParent = pCurrCol->GetUpper(); + SwFrm* pCurrPageCol=((SwFrm*)pCurrFrm)->FindColFrm(); + while(pCurrPageCol && pCurrPageCol->GetUpper() && pCurrPageCol->GetUpper()->IsPageFrm()) + { + pCurrPageCol = pCurrPageCol->GetUpper(); + } + + SwLayoutFrm* pParent = (SwLayoutFrm*)(pCurrPageCol->GetUpper()); + + if(pParent!=NULL) + { + SwFrm* pCol = pParent->Lower(); + while(pCol&&(pCol!=pCurrPageCol)) + { + pCol = pCol->GetNext(); + nCurrCol +=1; + } + } + } + sValue += String::CreateFromInt32( nCurrCol ) ; + sValue += rtl::OUString::createFromAscii(";"); + + sAttrName=rtl::OUString::createFromAscii("total-columns:"); + + const SwFmtCol &rFmtCol=pCurrPage->GetAttrSet()->GetCol(); + sal_uInt16 nColCount=rFmtCol.GetNumCols(); + nColCount = nColCount>0?nColCount:1; + sValue += sAttrName; + sValue += String::CreateFromInt32( nColCount ) ; + + sValue += rtl::OUString::createFromAscii(";"); + + if(pCurrFrm!=NULL) + { + SwSectionFrm* pCurrSctFrm=((SwFrm*)pCurrFrm)->FindSctFrm(); + if(pCurrSctFrm!=NULL && pCurrSctFrm->GetSection()!=NULL ) + { + sAttrName = rtl::OUString::createFromAscii("section-name:"); + + sValue += sAttrName; + String sectionName = pCurrSctFrm->GetSection()->GetSectionName(); + + sectionName.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" )); + sectionName.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ) ); + sectionName.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ) ); + sectionName.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ) ); + sectionName.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ) ); + + sValue += sectionName; + //sValue += pCurrSctFrm->GetSection()->GetName(); + + sValue += rtl::OUString::createFromAscii(";"); + + //section-columns-number + { + sAttrName=rtl::OUString::createFromAscii("section-columns-number:"); + + nCurrCol = 1; + + if(pCurrCol!=NULL) + { + SwLayoutFrm* pParent = pCurrCol->GetUpper(); + if(pParent!=NULL) + { + SwFrm* pCol = pParent->Lower(); + while(pCol&&(pCol!=pCurrCol)) + { + pCol = pCol->GetNext(); + nCurrCol +=1; + } + } + } + sValue += sAttrName; + sValue += String::CreateFromInt32( nCurrCol ) ; + sValue += rtl::OUString::createFromAscii(";"); + } + + //section-total-columns + { + sAttrName=rtl::OUString::createFromAscii("section-total-columns:"); + const SwFmtCol &rFmtSctCol=pCurrSctFrm->GetAttrSet()->GetCol(); + sal_uInt16 nSctColCount=rFmtSctCol.GetNumCols(); + nSctColCount = nSctColCount>0?nSctColCount:1; + sValue += sAttrName; + sValue += String::CreateFromInt32( nSctColCount ) ; + + sValue += rtl::OUString::createFromAscii(";"); + } + } + } + anyAtrribute <<= sValue; + } + return anyAtrribute; +} + +sal_Int32 SAL_CALL SwAccessibleDocument::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ + //IAccessibility2 Implementation 2009----- + vos::OGuard aGuard(Application::GetSolarMutex()); + return SW_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor; + //-----IAccessibility2 Implementation 2009 +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL SwAccessibleDocument::get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType) + throw ( ::com::sun::star::uno::RuntimeException ) +{ + const sal_Int32 FORSPELLCHECKFLOWTO = 1; + const sal_Int32 FORFINDREPLACEFLOWTO = 2; + SwAccessibleMap* pAccMap = GetMap(); + if ( !pAccMap ) + { + goto Rt; + } + + if ( nType == FORSPELLCHECKFLOWTO ) + { + uno::Reference< ::com::sun::star::drawing::XShape > xShape; + rAny >>= xShape; + if( xShape.is() ) + { + SdrObject* pObj = GetSdrObjectFromXShape(xShape); + if( pObj ) + { + uno::Reference<XAccessible> xAcc = pAccMap->GetContext(pObj, this, sal_False); + uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY ); + if ( xAccSelection.is() ) + { + try + { + if ( xAccSelection->getSelectedAccessibleChildCount() ) + { + uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 ); + if ( xSel.is() ) + { + uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() ); + if ( xSelContext.is() ) + { + //if in sw we find the selected paragraph here + if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) + { + uno::Sequence<uno::Any> aRet( 1 ); + aRet[0] = uno::makeAny( xSel ); + return aRet; + } + } + } + } + } + catch ( com::sun::star::lang::IndexOutOfBoundsException ) + { + //return empty sequence + goto Rt; + } + //end of try...catch + } + /*uno::Sequence< uno::Any > aRet(1); + aRet[0] = uno::makeAny( xAcc ); + return aRet;*/ + } + } + else + { + uno::Reference< XAccessible > xAcc = pAccMap->GetCursorContext(); + SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() ); + if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH ) + { + uno::Sequence< uno::Any > aRet(1); + aRet[0] = uno::makeAny( xAcc ); + return aRet; + } + } + } + else if ( nType == FORFINDREPLACEFLOWTO ) + { + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if ( pCrsrShell ) + { + SwPaM *_pStartCrsr = pCrsrShell->GetCrsr(), *__pStartCrsr = _pStartCrsr; + SwCntntNode* pPrevNode = NULL; + std::vector<SwFrm*> vFrmList; + do + { + if ( _pStartCrsr && _pStartCrsr->HasMark() ) + { + SwCntntNode* pCntntNode = _pStartCrsr->GetCntntNode(); + if ( pCntntNode == pPrevNode ) + { + continue; + } + SwFrm* pFrm = pCntntNode ? pCntntNode->getLayoutFrm( pCrsrShell->GetLayout() ) : NULL; + if ( pFrm ) + { + vFrmList.push_back( pFrm ); + } + + pPrevNode = pCntntNode; + } + } + + while( _pStartCrsr && ( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr) ); + + if ( vFrmList.size() ) + { + uno::Sequence< uno::Any > aRet(vFrmList.size()); + std::vector<SwFrm*>::iterator aIter = vFrmList.begin(); + for ( sal_Int32 nIndex = 0; aIter != vFrmList.end(); aIter++, nIndex++ ) + { + uno::Reference< XAccessible > xAcc = pAccMap->GetContext(*aIter, sal_False); + if ( xAcc.is() ) + { + SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() ); + if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH ) + { + aRet[nIndex] = uno::makeAny( xAcc ); + } + } + } + + return aRet; + } + } + } + +Rt: + uno::Sequence< uno::Any > aEmpty; + return aEmpty; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accdoc.hxx b/sw/source/core/access/accdoc.hxx index a8ae434256bf..24a0e75f7203 100644 --- a/sw/source/core/access/accdoc.hxx +++ b/sw/source/core/access/accdoc.hxx @@ -26,8 +26,19 @@ #include "acccontext.hxx" #endif #include <com/sun/star/accessibility/XAccessibleSelection.hpp> +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/document/XEventListener.hpp> #include <accselectionhelper.hxx> +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XAccessibleExtendedAttributes_HPP_ +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> +#endif + +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEGETACCFLOWTO_HPP_ +#include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp> +#endif +//-----IAccessibility2 Implementation 2009 + class VclSimpleEvent; /** @@ -81,6 +92,9 @@ public: /// Return this object's description. virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException); + //IAccessibility2 Implementation 2009----- + virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException); + //-----IAccessibility2 Implementation 2009 //===== XAccessibleComponent ============================================== virtual sal_Bool SAL_CALL containsPoint( @@ -111,7 +125,12 @@ public: * access to an accessible Writer document */ class SwAccessibleDocument : public SwAccessibleDocumentBase, - public com::sun::star::accessibility::XAccessibleSelection + public com::sun::star::accessibility::XAccessibleSelection, + //IAccessibility2 Implementation 2009----- + public com::sun::star::document::XEventListener, + public com::sun::star::accessibility::XAccessibleExtendedAttributes, + //-----IAccessibility2 Implementation 2009 + public com::sun::star::accessibility::XAccessibleGetAccFlowTo { // Implementation for XAccessibleSelection interface SwAccessibleSelectionHelper maSelectionHelper; @@ -129,6 +148,13 @@ public: SwAccessibleDocument( SwAccessibleMap* pInitMap ); DECL_LINK( WindowChildEventListener, VclSimpleEvent* ); + //IAccessibility2 Implementation 2009----- + //===== XEventListener==================================================== + virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Event ) + throw (::com::sun::star::uno::RuntimeException); + //-----IAccessibility2 Implementation 2009 //===== XServiceInfo ==================================================== @@ -199,10 +225,23 @@ public: throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); + //IAccessibility2 Implementation 2009----- + virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; //====== thread safe C++ interface ======================================== // The object is not visible an longer and should be destroyed virtual void Dispose( sal_Bool bRecursive = sal_False ); + + //===== XAccessibleComponent ============================================ + sal_Int32 SAL_CALL getBackground() + throw (::com::sun::star::uno::RuntimeException); + + //===== XAccessibleGetAccFlowTo ============================================ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType) + throw ( ::com::sun::star::uno::RuntimeException ); + //-----IAccessibility2 Implementation 2009 }; #endif diff --git a/sw/source/core/access/accembedded.cxx b/sw/source/core/access/accembedded.cxx index a3efadcd726a..48a123f1bcf7 100644 --- a/sw/source/core/access/accembedded.cxx +++ b/sw/source/core/access/accembedded.cxx @@ -31,6 +31,14 @@ #include <rtl/uuid.h> #include <flyfrm.hxx> #include "accembedded.hxx" +//IAccessibility2 Implementation 2009----- +#include "cntfrm.hxx" +#include "ndole.hxx" +#include <doc.hxx> +#include <docsh.hxx> +#include <../../ui/inc/wrtsh.hxx> +#include <../../ui/inc/view.hxx> +//-----IAccessibility2 Implementation 2009 using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -51,6 +59,34 @@ SwAccessibleEmbeddedObject::~SwAccessibleEmbeddedObject() { } +//IAccessibility2 Implementation 2009----- +//===== XInterface ========================================================== +com::sun::star::uno::Any SAL_CALL + SwAccessibleEmbeddedObject::queryInterface (const com::sun::star::uno::Type & rType) + throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aReturn = SwAccessibleNoTextFrame::queryInterface (rType); + if ( ! aReturn.hasValue()) + aReturn = ::cppu::queryInterface (rType, + static_cast< ::com::sun::star::accessibility::XAccessibleExtendedAttributes* >(this) ); + return aReturn; +} + +void SAL_CALL + SwAccessibleEmbeddedObject::acquire (void) + throw () +{ + SwAccessibleNoTextFrame::acquire (); +} + +void SAL_CALL + SwAccessibleEmbeddedObject::release (void) + throw () +{ + SwAccessibleNoTextFrame::release (); +} +//-----IAccessibility2 Implementation 2009 + OUString SAL_CALL SwAccessibleEmbeddedObject::getImplementationName() throw( uno::RuntimeException ) { @@ -91,3 +127,31 @@ uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleEmbeddedObject::getImplementation } return aId; } +//IAccessibility2 Implementation 2009----- +//===== XAccessibleExtendedAttributes ======================================================== +::com::sun::star::uno::Any SAL_CALL SwAccessibleEmbeddedObject::getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any strRet; + ::rtl::OUString style; + SwFlyFrm* pFFrm = getFlyFrm(); + + if( pFFrm ) + { + style = ::rtl::OUString::createFromAscii("style:"); + SwCntntFrm* pCFrm; + pCFrm = pFFrm->ContainsCntnt(); + if( pCFrm ) + { + SwCntntNode* pCNode = pCFrm->GetNode(); + if( pCNode ) + { + style += ((SwOLENode*)pCNode)->GetOLEObj().GetStyleString(); + } + } + style += ::rtl::OUString::createFromAscii(";"); + } + strRet <<= style; + return strRet; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accembedded.hxx b/sw/source/core/access/accembedded.hxx index f18ef2e1ec35..9347b16e1a58 100644 --- a/sw/source/core/access/accembedded.hxx +++ b/sw/source/core/access/accembedded.hxx @@ -24,7 +24,12 @@ #define _ACCEMBEDDED_HXX #include "accnotextframe.hxx" +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> +//-----IAccessibility2 Implementation 2009 class SwAccessibleEmbeddedObject : public SwAccessibleNoTextFrame + , public ::com::sun::star::accessibility::XAccessibleExtendedAttributes + { protected: @@ -36,6 +41,21 @@ public: SwAccessibleEmbeddedObject( SwAccessibleMap* pInitMap, const SwFlyFrm* pFlyFrm ); + //IAccessibility2 Implementation 2009----- + //===== XInterface ====================================================== + + virtual com::sun::star::uno::Any SAL_CALL + queryInterface (const com::sun::star::uno::Type & rType) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + acquire (void) + throw (); + + virtual void SAL_CALL + release (void) + throw (); + //-----IAccessibility2 Implementation 2009 //===== XServiceInfo ==================================================== /** Returns an identifier for the implementation of this object. @@ -59,6 +79,12 @@ public: //===== XTypeProvider ==================================================== virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + //IAccessibility2 Implementation 2009----- + // ====== XAccessibleExtendedAttributes ===================================== + virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/accfield.cxx b/sw/source/core/access/accfield.cxx new file mode 100644 index 000000000000..8aa79f29c497 --- /dev/null +++ b/sw/source/core/access/accfield.cxx @@ -0,0 +1,348 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#ifndef COMPHELPER_ACCESSIBLE_KEYBINDING_HELPER_HXX +#include <comphelper/accessiblekeybindinghelper.hxx> +#endif +#ifndef _SWURL_HXX //autogen +#include <swurl.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif +#ifndef _NDTXT_HXX +#include <ndtxt.hxx> +#endif +#ifndef _TXTINET_HXX +#include <txtinet.hxx> +#endif + +#ifndef _ACCPARA_HXX +#include <accpara.hxx> +#endif +#ifndef _ACCFIELD_HXX +#include <accfield.hxx> +#endif + +#include <comphelper/processfactory.hxx> + +#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ +#include <com/sun/star/frame/XDesktop.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +#include <com/sun/star/frame/XComponentLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XLINKTARGETSUPPLIER_HPP_ +#include <com/sun/star/document/XLinkTargetSupplier.hpp> +#endif +#ifndef COMPHELPER_ACCESSIBLE_EVENT_NOTIFIER +#include <comphelper/accessibleeventnotifier.hxx> +#endif + +//Add end + +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::accessibility; +// using namespace ::rtl; + +SwAccessibleField::SwAccessibleField( SwField *pSwFld,SwAccessibleParagraph *p,sal_Int16 nRole) : + m_xPara( p ),m_pSwField(pSwFld),m_nRole(nRole) +{ + m_nClientId=0; +} + +uno::Reference< XAccessibleContext > SAL_CALL + SwAccessibleField::getAccessibleContext( void ) + throw (::com::sun::star::uno::RuntimeException) +{ + uno::Reference < XAccessibleContext > xRet( this ); + return xRet; +} + +sal_Int32 SAL_CALL SwAccessibleField::getAccessibleChildCount( void ) + throw (::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return 0; +} + +uno::Reference< XAccessible> SAL_CALL + SwAccessibleField::getAccessibleChild( long ) + throw (::com::sun::star::uno::RuntimeException, + ::com::sun::star::lang::IndexOutOfBoundsException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return uno::Reference< XAccessible >(); +} + +uno::Reference< XAccessible> SAL_CALL SwAccessibleField::getAccessibleParent (void) + throw (::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + uno::Reference< XAccessible > xParent(static_cast<XAccessible*>(m_xPara.getBodyPtr()),UNO_QUERY); + return xParent; +} + +sal_Int32 SAL_CALL SwAccessibleField::getAccessibleIndexInParent (void) + throw (::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return 0; +} + +sal_Int16 SAL_CALL SwAccessibleField::getAccessibleRole (void) + throw (::com::sun::star::uno::RuntimeException) +{ + return m_nRole; +} + +rtl::OUString SAL_CALL SwAccessibleField::getAccessibleDescription (void) + throw (::com::sun::star::uno::RuntimeException) +{ + ASSERT( !this, "description needs to be overloaded" ); + //THROW_RUNTIME_EXCEPTION( XAccessibleContext, "internal error (method must be overloaded)" ); + return rtl::OUString(); +} + +rtl::OUString SAL_CALL SwAccessibleField::getAccessibleName (void) + throw (::com::sun::star::uno::RuntimeException) +{ + return rtl::OUString(); +} + +uno::Reference< XAccessibleRelationSet> SAL_CALL + SwAccessibleField::getAccessibleRelationSet (void) + throw (::com::sun::star::uno::RuntimeException) +{ + return NULL; +} + +uno::Reference<XAccessibleStateSet> SAL_CALL + SwAccessibleField::getAccessibleStateSet (void) + throw (::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return uno::Reference<XAccessibleStateSet>(); +} + +com::sun::star::lang::Locale SAL_CALL SwAccessibleField::getLocale (void) + throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + com::sun::star::lang::Locale aLoc( Application::GetSettings().GetLocale() ); + return aLoc; +} + +static sal_Bool lcl_PointInRectangle(const awt::Point & aPoint, + const awt::Rectangle & aRect) +{ + long nDiffX = aPoint.X - aRect.X; + long nDiffY = aPoint.Y - aRect.Y; + + return + nDiffX >= 0 && nDiffX < aRect.Width && nDiffY >= 0 && + nDiffY < aRect.Height; + +} + +sal_Bool SAL_CALL SwAccessibleField::containsPoint( + const ::com::sun::star::awt::Point& aPoint ) + throw (RuntimeException) +{ + awt::Rectangle aPixBounds = getBoundsImpl(sal_True); + aPixBounds.X = 0; + aPixBounds.Y = 0; + + return lcl_PointInRectangle(aPoint, aPixBounds); +} + +uno::Reference< XAccessible > SAL_CALL SwAccessibleField::getAccessibleAtPoint( + const awt::Point& aPoint ) + throw (RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + uno::Reference< XAccessible > xAcc; + awt::Rectangle rc = getBounds(); + if(aPoint.X >= rc.X && aPoint.X <= rc.X + rc.Width && + aPoint.Y >= rc.Y && aPoint.Y <= rc.Y + rc.Height ) + { + xAcc =this; + } + return xAcc; +} + + +/** + Get bounding box. + + There are two modes. + + - realative + + Return bounding box relative to parent if parent is no root + frame. Otherwise return the absolute bounding box. + + - absolute + + Return the absolute bounding box. + + @param bRelative + true: Use relative mode. + false: Use absolute mode. +*/ +awt::Rectangle SAL_CALL SwAccessibleField::getBoundsImpl( sal_Bool ) + throw (RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return awt::Rectangle(); +} + +awt::Rectangle SAL_CALL SwAccessibleField::getBounds() + throw (RuntimeException) +{ + return getBoundsImpl(sal_True); +} + +awt::Point SAL_CALL SwAccessibleField::getLocation() + throw (RuntimeException) +{ + awt::Rectangle aRect = getBoundsImpl(sal_True); + awt::Point aPoint(aRect.X, aRect.Y); + + return aPoint; +} + + +awt::Point SAL_CALL SwAccessibleField::getLocationOnScreen() + throw (RuntimeException) +{ + awt::Rectangle aRect = getBoundsImpl(sal_False); + //Point aPixPos = m_xPara->getLocationOnScreen(); + return awt::Point( aRect.X,aRect.Y);//aPixPos.X() + aRect.nLeft , aPixPos.Y() + + aRect.nRight ); +} + + +awt::Size SAL_CALL SwAccessibleField::getSize() + throw (RuntimeException) +{ + awt::Rectangle aRect = getBoundsImpl(sal_False); + awt::Size aSize( aRect.Width, aRect.Height ); + + return aSize; +} + +void SAL_CALL SwAccessibleField::grabFocus() + throw (RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return; +} + + +sal_Int32 SAL_CALL SwAccessibleField::getForeground() + throw (::com::sun::star::uno::RuntimeException) +{ + return 0; +} + +sal_Int32 SAL_CALL SwAccessibleField::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ + return 0xffffff; +} +::com::sun::star::uno::Any SAL_CALL SwAccessibleField::queryInterface( + const ::com::sun::star::uno::Type& rType ) + throw (::com::sun::star::uno::RuntimeException) +{ + Any aRet; + if ( rType == ::getCppuType((uno::Reference<XAccessibleContext> *)0) ) + { + Reference<XAccessibleContext> aAccContext = (XAccessibleContext *) this; // resolve ambiguity + aRet <<= aAccContext; + } + else if ( rType == ::getCppuType((Reference<XAccessibleComponent> *)0) ) + { + Reference<XAccessibleComponent> aAccEditComponent = this; + aRet <<= aAccEditComponent; + } + if (rType == ::getCppuType((Reference<XAccessibleEventBroadcaster> *)0)) + { + Reference<XAccessibleEventBroadcaster> aAccBroadcaster= this; + aRet <<= aAccBroadcaster; + } + return aRet; +} + +void SAL_CALL SwAccessibleField::acquire( ) throw () +{ +} +void SAL_CALL SwAccessibleField::release( ) throw () +{ +} + +void SAL_CALL SwAccessibleField::addEventListener( + const Reference< XAccessibleEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException) +{ + //DBG_MSG( "accessible event listener added" ) + + if (xListener.is()) + { + vos::OGuard aGuard(Application::GetSolarMutex()); + if (!m_nClientId) + m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); + comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); + } +} + +void SAL_CALL SwAccessibleField::removeEventListener( + const Reference< XAccessibleEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException) +{ + //DBG_MSG( "accessible event listener removed" ) + + if (xListener.is()) + { + vos::OGuard aGuard(Application::GetSolarMutex()); + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + comphelper::AccessibleEventNotifier::revokeClient( m_nClientId ); + m_nClientId = 0; + } + } +} diff --git a/sw/source/core/access/accfield.hxx b/sw/source/core/access/accfield.hxx new file mode 100644 index 000000000000..a206866ab23c --- /dev/null +++ b/sw/source/core/access/accfield.hxx @@ -0,0 +1,213 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +#ifndef _ACCFIELD_HXX +#define _ACCFIELD_HXX + +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_ +#include <com/sun/star/accessibility/XAccessible.hpp> +#endif +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECONTEXT_HPP_ +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#endif +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECOMPONENT_HPP_ +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#endif +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEEVENTBROADCASTER_HPP_ +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_ACCESSIBILITY_ILLEGALACCESSIBLECOMPONENTSTATEEXCEPTION_HDL_ +#include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_INDEXOUTOFBOUNDSEXCEPTION_HPP_ +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#endif +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEHYPERLINK_HPP_ +#include <com/sun/star/accessibility/XAccessibleHyperlink.hpp> +#endif +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEVALUE_HPP_ +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_ +#include <com/sun/star/uno/RuntimeException.hpp> +#endif +#ifndef _VOS_REF_HXX_ +#include <vos/ref.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include <cppuhelper/implbase4.hxx> +#endif +#ifndef _FMTINFMT_HXX //autogen +#include <fmtinfmt.hxx> +#endif + +class SwAccessibleParagraph; +class SwField; +class SwAccessibleField : + public ::cppu::WeakImplHelper4< + ::com::sun::star::accessibility::XAccessible, + ::com::sun::star::accessibility::XAccessibleContext, + ::com::sun::star::accessibility::XAccessibleComponent, + ::com::sun::star::accessibility::XAccessibleEventBroadcaster + > +{ + friend class SwAccessibleParagraph; + friend class SwAccessibleHyperTextData; + +protected: +// sal_uInt16 nHintPos; + ::vos::ORef< SwAccessibleParagraph > m_xPara; + SwField *m_pSwField; + + sal_uInt32 m_nClientId; // client id in the AccessibleEventNotifier queue + sal_Int16 m_nRole; // immutable outside constructor +// sal_Int32 nStartIdx; +// sal_Int32 nEndIdx; +public: + SwAccessibleField( SwField *pSwFld,SwAccessibleParagraph *p,sal_Int16); + + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + +// const SwTxtAttr *GetTxtAttr() const; +// void Invalidate(); + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& aType ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL acquire( ) throw () ; + virtual void SAL_CALL release( ) throw () ; + +public: + //===== XAccessible ===================================================== + + /// Return the XAccessibleContext. + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL + getAccessibleContext (void) throw (com::sun::star::uno::RuntimeException); + + //===== XAccessibleContext ============================================== + + /// Return the number of currently visible children. + virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return the specified child or NULL if index is invalid. + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL + getAccessibleChild (long nIndex) + throw (::com::sun::star::uno::RuntimeException, + ::com::sun::star::lang::IndexOutOfBoundsException); + + /// Return a reference to the parent. + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL + getAccessibleParent (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return this objects index among the parents children. + virtual sal_Int32 SAL_CALL + getAccessibleIndexInParent (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return this object's role. + virtual sal_Int16 SAL_CALL + getAccessibleRole (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return this object's description. + virtual ::rtl::OUString SAL_CALL + getAccessibleDescription (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return the object's current name. + virtual ::rtl::OUString SAL_CALL + getAccessibleName (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return NULL to indicate that an empty relation set. + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL + getAccessibleRelationSet (void) + throw (::com::sun::star::uno::RuntimeException); + + /// Return the set of current states. + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL + getAccessibleStateSet (void) + throw (::com::sun::star::uno::RuntimeException); + + /** Return the parents locale or throw exception if this object has no + parent yet/anymore. + */ + virtual ::com::sun::star::lang::Locale SAL_CALL + getLocale (void) + throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); + + //===== XAccessibleComponent ============================================ + virtual sal_Bool SAL_CALL containsPoint( + const ::com::sun::star::awt::Point& aPoint ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( + const ::com::sun::star::awt::Point& aPoint ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Point SAL_CALL getLocation() + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL grabFocus() + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getForeground() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackground() + throw (::com::sun::star::uno::RuntimeException); + + + virtual ::com::sun::star::awt::Rectangle SAL_CALL + getBoundsImpl(sal_Bool bRelative) + throw (::com::sun::star::uno::RuntimeException) ; + + +}; + +#endif + diff --git a/sw/source/core/access/accfootnote.cxx b/sw/source/core/access/accfootnote.cxx index 588bbb1c8161..95c2c09d9d75 100644 --- a/sw/source/core/access/accfootnote.cxx +++ b/sw/source/core/access/accfootnote.cxx @@ -55,7 +55,6 @@ const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccess SwAccessibleFootnote::SwAccessibleFootnote( SwAccessibleMap* pInitMap, sal_Bool bIsEndnote, - sal_Int32 nFootEndNote, const SwFtnFrm *pFtnFrm ) : SwAccessibleContext( pInitMap, bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE, @@ -65,7 +64,19 @@ SwAccessibleFootnote::SwAccessibleFootnote( sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME : STR_ACCESS_FOOTNOTE_NAME; - OUString sArg( OUString::valueOf( nFootEndNote ) ); + //IAccessibility2 Implementation 2009----- + //OUString sArg( OUString::valueOf( nFootEndNote ) ); + //old codes end + OUString sArg; + const SwTxtFtn *pTxtFtn = + static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr(); + if( pTxtFtn ) + { + const SwDoc *pDoc = GetShell()->GetDoc(); + sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc ); + } + //-----IAccessibility2 Implementation 2009 + SetName( GetResource( nResId, &sArg ) ); } diff --git a/sw/source/core/access/accfootnote.hxx b/sw/source/core/access/accfootnote.hxx index 9cec3b47ff2d..dadc3bcc7f05 100644 --- a/sw/source/core/access/accfootnote.hxx +++ b/sw/source/core/access/accfootnote.hxx @@ -41,7 +41,6 @@ public: SwAccessibleFootnote( SwAccessibleMap* pInitMap, sal_Bool bIsEndnote, - sal_Int32 nFootEndNote, const SwFtnFrm *pFtnFrm ); diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index 0099a63e9416..b9916a63d7fd 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -61,7 +61,9 @@ using namespace sw::access; { sal_Int32 nCount = 0; - const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap ); + // const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap ); + const SwAccessibleChildSList aVisList( pFrm->PaintArea(), *pFrm, rAccMap ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { @@ -163,7 +165,10 @@ using namespace sw::access; if( SwAccessibleChildMap::IsSortingRequired( rFrm ) ) { // We need a sorted list here - const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap ); + //IAccessibility2 Implementation 2009----- + // const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap ); + const SwAccessibleChildMap aVisMap( rFrm.PaintArea(), rFrm, rAccMap ); + //-----IAccessibility2 Implementation 2009 SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() ); while( aIter != aVisMap.end() && !bFound ) { @@ -189,7 +194,12 @@ using namespace sw::access; { // The unsorted list is sorted enough, because it return lower // frames in the correct order. - const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap ); + + //IAccessibility2 Implementation 2009----- + // const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap ); + const SwAccessibleChildSList aVisList( rFrm.PaintArea(), rFrm, rAccMap ); + //-----IAccessibility2 Implementation 2009 + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() && !bFound ) { @@ -425,7 +435,8 @@ SwAccessibleFrame::SwAccessibleFrame( const SwRect& rVisArea, sal_Bool bIsPagePreview ) : maVisArea( rVisArea ), mpFrm( pF ), - mbIsInPagePreview( bIsPagePreview ) + mbIsInPagePreview( bIsPagePreview ), + bIsAccDocUse( sal_False ) { } diff --git a/sw/source/core/access/accframe.hxx b/sw/source/core/access/accframe.hxx index 129caa2768c1..06ab5302d059 100644 --- a/sw/source/core/access/accframe.hxx +++ b/sw/source/core/access/accframe.hxx @@ -52,8 +52,9 @@ protected: static sal_Int32 GetChildCount( SwAccessibleMap& rAccMap, const SwRect& rVisArea, const SwFrm *pFrm, - sal_Bool bInPagePreview ); -private: + sal_Bool bInPagePreviewr ); + +// private: static sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap, const SwRect& rVisArea, const SwFrm& rFrm, @@ -105,6 +106,12 @@ protected: sal_Bool bIsPagePreview ); virtual ~SwAccessibleFrame(); + //IAccessibility2 Implementation 2009----- + // MT: Move to private area? + sal_Bool bIsAccDocUse; + //-----IAccessibility2 Implementation 2009 + + public: // Return the SwFrm this context is attached to. const SwFrm* GetFrm() const { return mpFrm; }; diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx index e2ce6ad6e89b..53b2b6600a58 100644 --- a/sw/source/core/access/accframebase.cxx +++ b/sw/source/core/access/accframebase.cxx @@ -42,6 +42,26 @@ #include "accmap.hxx" #include "accframebase.hxx" +//IAccessibility2 Implementation 2009----- +#ifndef _CRSRSH_HXX +#include <crsrsh.hxx> +#endif +#ifndef _FESH_HXX +#include "fesh.hxx" +#endif +#ifndef _TXTFRM_HXX +#include <txtfrm.hxx> +#endif +#ifndef _NDTXT_HXX +#include <ndtxt.hxx> +#endif +#ifndef _DCONTACT_HXX +#include <dcontact.hxx> +#endif +#ifndef _FMTANCHR_HXX +#include <fmtanchr.hxx> +#endif +//-----IAccessibility2 Implementation 2009 using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; @@ -94,6 +114,10 @@ void SwAccessibleFrameBase::GetStates( if( pWin && pWin->HasFocus() ) rStateSet.AddState( AccessibleStateType::FOCUSED ); } + //IAccessibility2 Implementation 2009----- + if( GetSelectedState() ) + rStateSet.AddState( AccessibleStateType::SELECTED ); + //-----IAccessibility2 Implementation 2009 } @@ -167,20 +191,26 @@ void SwAccessibleFrameBase::_InvalidateCursorPos() Window *pWin = GetWindow(); if( pWin && pWin->HasFocus() && bNewSelected ) FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected ); - FireStateChangedEvent( AccessibleStateType::SELECTED, bNewSelected ); + //IAccessibility2 Implementation 2009----- + //FireStateChangedEvent( AccessibleStateType::SELECTED, bNewSelected ); if( pWin && pWin->HasFocus() && !bNewSelected ) FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected ); - - uno::Reference< XAccessible > xParent( GetWeakParent() ); - if( xParent.is() ) + if(bNewSelected) { - SwAccessibleContext *pAcc = - static_cast <SwAccessibleContext *>( xParent.get() ); + uno::Reference< XAccessible > xParent( GetWeakParent() ); + if( xParent.is() ) + { + SwAccessibleContext *pAcc = + static_cast <SwAccessibleContext *>( xParent.get() ); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; - pAcc->FireAccessibleEvent( aEvent ); + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; + uno::Reference< XAccessible > xChild(this); + aEvent.NewValue <<= xChild; + pAcc->FireAccessibleEvent( aEvent ); + } } + //-----IAccessibility2 Implementation 2009 } } @@ -248,13 +278,13 @@ void SwAccessibleFrameBase::Modify( const SfxPoolItem* pOld, const SfxPoolItem * break; case RES_OBJECTDYING: // mba: it seems that this class intentionally does not call code in base class SwClient - if( GetRegisteredIn() == - static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) + if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) ) GetRegisteredInNonConst()->Remove( this ); break; case RES_FMT_CHG: - if( static_cast< const SwFmtChg * >(pNew)->pChangedFmt == GetRegisteredIn() && + if( pOld && + static_cast< const SwFmtChg * >(pNew)->pChangedFmt == GetRegisteredIn() && static_cast< const SwFmtChg * >(pOld)->pChangedFmt->IsFmtInDTOR() ) GetRegisteredInNonConst()->Remove( this ); break; @@ -274,3 +304,123 @@ void SwAccessibleFrameBase::Dispose( sal_Bool bRecursive ) SwAccessibleContext::Dispose( bRecursive ); } +//IAccessibility2 Implementation 2009----- +//Get the selection cursor of the document. +SwPaM* SwAccessibleFrameBase::GetCrsr() +{ + // get the cursor shell; if we don't have any, we don't have a + // cursor/selection either + SwPaM* pCrsr = NULL; + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL && !pCrsrShell->IsTableMode() ) + { + SwFEShell *pFESh = dynamic_cast< SwFEShell* >(pCrsrShell); + if( !pFESh || + !(pFESh->IsFrmSelected() || pFESh->IsObjSelected() > 0) ) + { + // get the selection, and test whether it affects our text node + pCrsr = pCrsrShell->GetCrsr( sal_False /* ??? */ ); + } + } + + return pCrsr; +} +//Return the selected state of the object. +//when the object's anchor are in the selection cursor, we should return true. +sal_Bool SwAccessibleFrameBase::GetSelectedState( ) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + //IAccessibility2 Implementation 2009----- + if(GetMap()->IsDocumentSelAll()) + { + return sal_True; + } + //-----IAccessibility2 Implementation 2009 + + // SELETED. + SwFlyFrm* pFlyFrm = getFlyFrm(); + const SwFrmFmt *pFrmFmt = pFlyFrm->GetFmt(); + const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor(); + const SwPosition *pPos = pAnchor.GetCntntAnchor(); + if( !pPos ) + return sal_False; + int pIndex = pPos->nContent.GetIndex(); + if( pPos->nNode.GetNode().GetTxtNode() ) + { + SwPaM* pCrsr = GetCrsr(); + if( pCrsr != NULL ) + { + const SwTxtNode* pNode = pPos->nNode.GetNode().GetTxtNode(); + sal_uLong nHere = pNode->GetIndex(); + + // iterate over ring + SwPaM* pRingStart = pCrsr; + do + { + // ignore, if no mark + if( pCrsr->HasMark() ) + { + // check whether nHere is 'inside' pCrsr + SwPosition* pStart = pCrsr->Start(); + sal_uLong nStartIndex = pStart->nNode.GetIndex(); + SwPosition* pEnd = pCrsr->End(); + sal_uLong nEndIndex = pEnd->nNode.GetIndex(); + if( ( nHere >= nStartIndex ) && (nHere <= nEndIndex) ) + { + if( pAnchor.GetAnchorId() == FLY_AS_CHAR ) + { + //IAccessibility2 Implementation 2009----- + if( (nHere == nStartIndex) && (pIndex >= pStart->nContent.GetIndex()) || (nHere > nStartIndex) ) + if( (nHere == nEndIndex) && (pIndex < pEnd->nContent.GetIndex()) || (nHere < nEndIndex) ) + return sal_True; + //-----IAccessibility2 Implementation 2009 + } + else if( pAnchor.GetAnchorId() == FLY_AT_PARA ) + { + if( ((nHere > nStartIndex) || pStart->nContent.GetIndex() ==0 ) + && (nHere < nEndIndex ) ) + return sal_True; + } + break; + } + // else: this PaM doesn't point to this paragraph + } + // else: this PaM is collapsed and doesn't select anything + + // next PaM in ring + pCrsr = static_cast<SwPaM*>( pCrsr->GetNext() ); + } + while( pCrsr != pRingStart ); + } + } + return sal_False; +} + +SwFlyFrm* SwAccessibleFrameBase::getFlyFrm() const +{ + SwFlyFrm* pFlyFrm = NULL; + + const SwFrm* pFrm = GetFrm(); + DBG_ASSERT( pFrm != NULL, "frame expected" ); + if( pFrm->IsFlyFrm() ) + { + pFlyFrm = static_cast<SwFlyFrm*>( const_cast<SwFrm*>( pFrm ) ); + } + + return pFlyFrm; +} + +sal_Bool SwAccessibleFrameBase::SetSelectedState( sal_Bool ) +{ + sal_Bool bParaSeleted = GetSelectedState() || IsSelected(); + + if(bIsSeletedInDoc != bParaSeleted) + { + bIsSeletedInDoc = bParaSeleted; + FireStateChangedEvent( AccessibleStateType::SELECTED, bParaSeleted ); + return sal_True; + } + return sal_False; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accframebase.hxx b/sw/source/core/access/accframebase.hxx index 14ae334065b2..6e2fd6f1bcef 100644 --- a/sw/source/core/access/accframebase.hxx +++ b/sw/source/core/access/accframebase.hxx @@ -23,6 +23,12 @@ #ifndef _ACCFRAMEBASE_HXX #define _ACCFRAMEBASE_HXX +//IAccessibility2 Implementation 2009----- +#ifndef _PAM_HXX +#include <pam.hxx> +#endif +//-----IAccessibility2 Implementation 2009 + #include <acccontext.hxx> #include <calbck.hxx> @@ -42,6 +48,11 @@ protected: // This drived class additionaly sets SELECTABLE(1), SELECTED(+), // FOCUSABLE(1) and FOCUSED(+) virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet ); + //IAccessibility2 Implementation 2009----- + SwFlyFrm* getFlyFrm() const; + sal_Bool GetSelectedState( ); + SwPaM* GetCrsr(); + //-----IAccessibility2 Implementation 2009 virtual void _InvalidateCursorPos(); virtual void _InvalidateFocus(); @@ -61,6 +72,8 @@ public: // The object is not visible an longer and should be destroyed virtual void Dispose( sal_Bool bRecursive = sal_False ); + virtual sal_Bool SetSelectedState( sal_Bool bSeleted ); + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index 53ca64a50c7b..913e6206093d 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -39,6 +39,10 @@ #include <frmfmt.hxx> #include <fmtanchr.hxx> #include <dcontact.hxx> +//IAccessibility2 Implementation 2009----- +#include <pam.hxx> +//-----IAccessibility2 Implementation 2009 + #include <vcl/window.hxx> #include <svx/svdlegacy.hxx> @@ -172,6 +176,25 @@ bool SwAccessibleChild::IsBoundAsChar() const return bRet; } +//IAccessibility2 Implementation 2009----- +sal_uInt32 SwAccessibleChild::GetAnchorPosition() const +{ + if( mpDrawObj ) + { + const SwFrmFmt *pFrmFmt = ::FindFrmFmt( mpDrawObj ); + if ( pFrmFmt ) + { + const SwPosition *pPos = pFrmFmt->GetAnchor().GetCntntAnchor(); + if ( pPos ) + { + return pPos->nContent.GetIndex(); + } + } + } + return 0; +} +//-----IAccessibility2 Implementation 2009 + SwAccessibleChild::SwAccessibleChild( const SwAccessibleChild& r ) : mpFrm( r.mpFrm ) , mpDrawObj( r.mpDrawObj ) diff --git a/sw/source/core/access/accfrmobj.hxx b/sw/source/core/access/accfrmobj.hxx index 60d41b3eb2d9..ff6012aa9c06 100644 --- a/sw/source/core/access/accfrmobj.hxx +++ b/sw/source/core/access/accfrmobj.hxx @@ -64,6 +64,10 @@ class SwAccessibleChild bool IsAccessible( sal_Bool bPagePreview ) const; bool IsBoundAsChar() const; + //IAccessibility2 Implementation 2009----- + sal_uInt32 GetAnchorPosition() const; + //-----IAccessibility2 Implementation 2009 + bool IsVisibleChildrenOnly() const; SwRect GetBox( const SwAccessibleMap& rAccMap ) const; SwRect GetBounds( const SwAccessibleMap& rAccMap ) const; diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx index 4fc284ae9fb2..c76df1453d1f 100644 --- a/sw/source/core/access/accfrmobjmap.cxx +++ b/sw/source/core/access/accfrmobjmap.cxx @@ -162,3 +162,97 @@ SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea, ( rFrm.IsTxtFrm() && rFrm.GetDrawObjs() ); } + +/* MT: The two insert methods had been introduced in the IA2 CWS (OOO310m11), but meanwhile we also have some in DEV300m80 (above) + Not sure if they have something which needs to be update in above methods. + Also, since there is no SwFrmOrObjMap CTOR anymore, the updated code in DEV300 might need some of the changes flagged with //IAccessibility2 Implementation 2009----- + +//IAccessibility2 Implementation 2009----- +::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert( + sal_uInt32 nOrd, Point nPos, const SwFrmOrObj& rLower ) +{ + SwFrmOrObjMapKey aKey( SwFrmOrObjMapKey::TEXT, nOrd, nPos ); + value_type aEntry( aKey, rLower ); + return _SwFrmOrObjMap::insert( aEntry ); +} + +::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert( + const SdrObject *pObj, const SwFrmOrObj& rLower, const SwDoc *pDoc , Point nPos) +{ + if( !bLayerIdsValid ) + { + nHellId = pDoc->GetHellId(); + nControlsId = pDoc->GetControlsId(); + bLayerIdsValid = sal_True; + } + + SdrLayerID nLayer = pObj->GetLayer(); + SwFrmOrObjMapKey::LayerId eLayerId = (nHellId == nLayer) + ? SwFrmOrObjMapKey::HELL + : ((nControlsId == nLayer) ? SwFrmOrObjMapKey::CONTROLS + : SwFrmOrObjMapKey::HEAVEN); + SwFrmOrObjMapKey aKey( eLayerId, pObj->GetOrdNum(), nPos ); + value_type aEntry( aKey, rLower ); + return _SwFrmOrObjMap::insert( aEntry ); +} +//-----IAccessibility2 Implementation 2009 + +SwFrmOrObjMap::SwFrmOrObjMap( + const SwRect& rVisArea, const SwFrm *pFrm ) : + bLayerIdsValid( sal_False ) +{ + SwFrmOrObj aFrm( pFrm ); + sal_Bool bVisibleOnly = aFrm.IsVisibleChildrenOnly(); + + sal_uInt32 nPos = 0; + SwFrmOrObj aLower( pFrm->GetLower() ); + while( aLower.GetSwFrm() ) + { + //IAccessibility2 Implementation 2009----- + if( !bVisibleOnly || aLower.GetBox().IsOver( rVisArea ) ) + insert( nPos++, aLower.GetBounds().Pos(), aLower ); + //-----IAccessibility2 Implementation 2009 + aLower = aLower.GetSwFrm()->GetNext(); + } + + if( pFrm->IsPageFrm() ) + { + ASSERT( bVisibleOnly, "page frame within tab frame???" ); + const SwPageFrm *pPgFrm = + static_cast< const SwPageFrm * >( pFrm ); + const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs(); + if( pObjs ) + { + const SwDoc *pDoc = pPgFrm->GetFmt()->GetDoc(); + for( sal_uInt16 i=0; i<pObjs->Count(); i++ ) + { + aLower = (*pObjs)[i]->GetDrawObj(); + //IAccessibility2 Implementation 2009----- + if( aLower.GetBox().IsOver( rVisArea ) ) + insert( aLower.GetSdrObject(), aLower, pDoc , aLower.GetBounds().Pos() ); + //-----IAccessibility2 Implementation 2009 + } + } + } + else if( pFrm->IsTxtFrm() ) + { + const SwDoc *pDoc = static_cast< const SwTxtFrm * >( pFrm )->GetNode() + ->GetDoc(); + const SwSortedObjs *pObjs = pFrm->GetDrawObjs(); + if( pObjs ) + { + for( sal_uInt16 i=0; i<pObjs->Count(); i++ ) + { + aLower = (*pObjs)[i]->GetDrawObj(); + //IAccessibility2 Implementation 2009----- + if( aLower.IsBoundAsChar() && + (!bVisibleOnly || aLower.GetBox().IsOver( rVisArea )) ) + insert( aLower.GetSdrObject(), aLower, pDoc , Point(aLower.GetAnchorPosition(),0) ); + //-----IAccessibility2 Implementation 2009 + } + } + } +} + +*/ + diff --git a/sw/source/core/access/accfrmobjmap.hxx b/sw/source/core/access/accfrmobjmap.hxx index d9df578277a7..fb05f9c8e117 100644 --- a/sw/source/core/access/accfrmobjmap.hxx +++ b/sw/source/core/access/accfrmobjmap.hxx @@ -26,6 +26,7 @@ #include <accfrmobj.hxx> #include <svx/svdtypes.hxx> +#include <tools/gen.hxx> #include <map> @@ -43,26 +44,59 @@ public: inline SwAccessibleChildMapKey() : eLayerId( INVALID ) , nOrdNum( 0 ) + , nPosNum( 0, 0 ) {} inline SwAccessibleChildMapKey( LayerId eId, sal_uInt32 nOrd ) : eLayerId( eId ) , nOrdNum( nOrd ) + , nPosNum( 0, 0 ) {} +//IAccessibility2 Implementation 2009----- + inline SwAccessibleChildMapKey( LayerId eId, sal_uInt32 nOrd, Point nPos ) + : eLayerId( eId ) + , nOrdNum( nOrd ) + , nPosNum( nPos ) + {} +//-----IAccessibility2 Implementation 2009 + inline bool operator()( const SwAccessibleChildMapKey& r1, const SwAccessibleChildMapKey& r2 ) const { - return (r1.eLayerId == r2.eLayerId) - ? (r1.nOrdNum < r2.nOrdNum) - : (r1.eLayerId < r2.eLayerId); +//IAccessibility2 Implementation 2009----- +// return (r1.eLayerId == r2.eLayerId) +// ? (r1.nOrdNum < r2.nOrdNum) +// : (r1.eLayerId < r2.eLayerId); + return (r1.eLayerId == r2.eLayerId) ? + ( (r1.nPosNum == r2.nPosNum) ?(r1.nOrdNum < r2.nOrdNum) : + (r1.nPosNum.getY() == r2.nPosNum.getY()? r1.nPosNum.getX() < r2.nPosNum.getX() : + r1.nPosNum.getY() < r2.nPosNum.getY()) ) : + (r1.eLayerId < r2.eLayerId); +//-----IAccessibility2 Implementation 2009 } + /* MT: Need to get this position parameter stuff in dev300 somehow... + //IAccessibility2 Implementation 2009----- + //This methods are used to insert an object to the map, adding a position parameter. + ::std::pair< iterator, bool > insert( sal_uInt32 nOrd, Point nPos, + const SwFrmOrObj& rLower ); + ::std::pair< iterator, bool > insert( const SdrObject *pObj, + const SwFrmOrObj& rLower, + const SwDoc *pDoc, + Point nPos); + //-----IAccessibility2 Implementation 2009 + */ + private: LayerId eLayerId; sal_uInt32 nOrdNum; + //IAccessibility2 Implementation 2009----- + Point nPosNum; + //-----IAccessibility2 Implementation 2009 + }; typedef ::std::map < SwAccessibleChildMapKey, sw::access::SwAccessibleChild, SwAccessibleChildMapKey > diff --git a/sw/source/core/access/accgraphic.cxx b/sw/source/core/access/accgraphic.cxx index 5b1e0f66857d..6b94077d4d75 100644 --- a/sw/source/core/access/accgraphic.cxx +++ b/sw/source/core/access/accgraphic.cxx @@ -33,6 +33,11 @@ #include "accgraphic.hxx" using namespace ::com::sun::star; +//IAccessibility2 Implementation 2009----- +#ifndef _FMTURL_HXX //autogen +#include <fmturl.hxx> +#endif +//-----IAccessibility2 Implementation 2009 using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; @@ -91,3 +96,15 @@ Sequence< sal_Int8 > SAL_CALL SwAccessibleGraphic::getImplementationId() } return aId; } +//IAccessibility2 Implementation 2009----- +// Return this object's role. +sal_Int16 SAL_CALL SwAccessibleGraphic::getAccessibleRole (void) + throw (::com::sun::star::uno::RuntimeException) +{ + SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() ); + + if(aURL.GetMap() ) + return AccessibleRole::IMAGE_MAP ; + return AccessibleRole::GRAPHIC ; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accgraphic.hxx b/sw/source/core/access/accgraphic.hxx index 379a95c274ee..af6391baa6f6 100644 --- a/sw/source/core/access/accgraphic.hxx +++ b/sw/source/core/access/accgraphic.hxx @@ -59,6 +59,10 @@ public: //===== XTypeProvider ==================================================== virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + //IAccessibility2 Implementation 2009----- + /// Return this object's role. + virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException); + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/accheaderfooter.cxx b/sw/source/core/access/accheaderfooter.cxx index c8a65f8d8bd0..5d6238f8a3e4 100644 --- a/sw/source/core/access/accheaderfooter.cxx +++ b/sw/source/core/access/accheaderfooter.cxx @@ -139,3 +139,20 @@ Sequence< sal_Int8 > SAL_CALL SwAccessibleHeaderFooter::getImplementationId() } return aId; } + +//IAccessibility2 Implementation 2009----- +sal_Int32 SAL_CALL SwAccessibleHeaderFooter::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ + Reference< XAccessible > xParent = getAccessibleParent(); + if (xParent.is()) + { + Reference< XAccessibleComponent > xAccContext (xParent,UNO_QUERY); + if(xAccContext.is()) + { + return xAccContext->getBackground(); + } + } + return SwAccessibleContext::getBackground(); +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accheaderfooter.hxx b/sw/source/core/access/accheaderfooter.hxx index 286639ca6474..e674bfd8ac8c 100644 --- a/sw/source/core/access/accheaderfooter.hxx +++ b/sw/source/core/access/accheaderfooter.hxx @@ -74,6 +74,11 @@ public: //===== XTypeProvider ==================================================== virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + //IAccessibility2 Implementation 2009----- + //===== XAccessibleComponent ============================================ + sal_Int32 SAL_CALL getBackground() + throw (::com::sun::star::uno::RuntimeException); + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/acchyperlink.cxx b/sw/source/core/access/acchyperlink.cxx index 872d73e4f9bc..7c6c3d3cea51 100644 --- a/sw/source/core/access/acchyperlink.cxx +++ b/sw/source/core/access/acchyperlink.cxx @@ -32,9 +32,23 @@ #include <accpara.hxx> #include <acchyperlink.hxx> +//IAccessibility2 Implementation 2009----- +#include <comphelper/processfactory.hxx> +#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ +#include <com/sun/star/frame/XDesktop.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +#include <com/sun/star/frame/XComponentLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XLINKTARGETSUPPLIER_HPP_ +#include <com/sun/star/document/XLinkTargetSupplier.hpp> +#endif +//-----IAccessibility2 Implementation 2009 + using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; +using ::com::sun::star::lang::IndexOutOfBoundsException; SwAccessibleHyperlink::SwAccessibleHyperlink( sal_uInt16 nHPos, SwAccessibleParagraph *p, sal_Int32 nStt, sal_Int32 nEnd ) : @@ -78,8 +92,12 @@ sal_Bool SAL_CALL SwAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) sal_Bool bRet = sal_False; + //IAccessibility2 Implementation 2009----- + if(nIndex != 0) + throw new IndexOutOfBoundsException; const SwTxtAttr *pTxtAttr = GetTxtAttr(); - if( pTxtAttr && 0 == nIndex ) + if( pTxtAttr /*&& 0 == nIndex*/ ) + //-----IAccessibility2 Implementation 2009 { const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt(); if( rINetFmt.GetValue().Len() ) @@ -111,23 +129,28 @@ OUString SAL_CALL SwAccessibleHyperlink::getAccessibleActionDescription( { OUString sDesc; + //IAccessibility2 Implementation 2009----- + if(nIndex != 0) + throw new IndexOutOfBoundsException; const SwTxtAttr *pTxtAttr = GetTxtAttr(); - if( pTxtAttr && 0 == nIndex ) + if( pTxtAttr /*&& 0 == nIndex*/ ) { const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt(); sDesc = OUString( rINetFmt.GetValue() ); } - + //-----IAccessibility2 Implementation 2009 return sDesc; } uno::Reference< XAccessibleKeyBinding > SAL_CALL - SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) + SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { uno::Reference< XAccessibleKeyBinding > xKeyBinding; - if( isValid() && 0==nIndex ) + //IAccessibility2 Implementation 2009----- + if( isValid() /*&& 0 == nIndex*/ ) + //-----IAccessibility2 Implementation 2009 { ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper(); @@ -146,17 +169,40 @@ uno::Reference< XAccessibleKeyBinding > SAL_CALL // XAccessibleHyperlink uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionAnchor( - sal_Int32 /*nIndex*/ ) + sal_Int32 nIndex) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { - return uno::Any(); + uno::Any aRet; + //IAccessibility2 Implementation 2009----- + if(nIndex != 0) + throw new IndexOutOfBoundsException; + //End Added. + ::rtl::OUString text = OUString( xPara->GetString() ); + ::rtl::OUString retText = text.copy(nStartIdx, nEndIdx - nStartIdx); + aRet <<= retText; + //-----IAccessibility2 Implementation 2009 + return aRet; } uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionObject( - sal_Int32 /*nIndex*/ ) + sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { - return uno::Any(); + //IAccessibility2 Implementation 2009----- + if(nIndex != 0) + throw new IndexOutOfBoundsException; + //End Added. + const SwTxtAttr *pTxtAttr = GetTxtAttr(); + ::rtl::OUString retText; + if( pTxtAttr /*&& 0 == nIndex*/ ) + { + const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt(); + retText = OUString( rINetFmt.GetValue() ); + } + uno::Any aRet; + aRet <<= retText; + return aRet; + //-----IAccessibility2 Implementation 2009 } sal_Int32 SAL_CALL SwAccessibleHyperlink::getStartIndex() @@ -175,7 +221,57 @@ sal_Bool SAL_CALL SwAccessibleHyperlink::isValid( ) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - return xPara.isValid(); + //IAccessibility2 Implementation 2009----- + // return xPara.isValid(); + if (xPara.isValid()) + { + const SwTxtAttr *pTxtAttr = GetTxtAttr(); + ::rtl::OUString sText; + if( pTxtAttr ) + { + const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt(); + sText = OUString( rINetFmt.GetValue() ); + ::rtl::OUString sToken = ::rtl::OUString::createFromAscii("#"); + sal_Int32 nPos = sText.indexOf(sToken); + if (nPos==0)//document link + { + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + if( ! xFactory.is() ) + return sal_False; + uno::Reference< com::sun::star::frame::XDesktop > xDesktop( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), + uno::UNO_QUERY ); + if( !xDesktop.is() ) + return sal_False; + uno::Reference< lang::XComponent > xComp; + xComp = xDesktop->getCurrentComponent(); + if( !xComp.is() ) + return sal_False; + uno::Reference< com::sun::star::document::XLinkTargetSupplier > xLTS(xComp, uno::UNO_QUERY); + if ( !xLTS.is()) + return sal_False; + + uno::Reference< ::com::sun::star::container::XNameAccess > xLinks = xLTS->getLinks(); + uno::Reference< ::com::sun::star::container::XNameAccess > xSubLinks; + const uno::Sequence< OUString > aNames( xLinks->getElementNames() ); + const sal_uLong nLinks = aNames.getLength(); + const OUString* pNames = aNames.getConstArray(); + + for( sal_uLong i = 0; i < nLinks; i++ ) + { + uno::Any aAny; + OUString aLink( *pNames++ ); + aAny = xLinks->getByName( aLink ); + aAny >>= xSubLinks; + if (xSubLinks->hasByName(sText.copy(1)) ) + return sal_True; + } + } + else//internet + return sal_True; + } + }//xpara valid + return sal_False; + //-----IAccessibility2 Implementation 2009 } void SwAccessibleHyperlink::Invalidate() diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 8be7f772f90d..8918bb598c59 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -34,6 +34,7 @@ #include <map> #include <list> +#include <vector> #include <accmap.hxx> #include <acccontext.hxx> #include <accdoc.hxx> @@ -60,11 +61,25 @@ #include <IDocumentDrawModelAccess.hxx> #include <svx/ShapeTypeHandler.hxx> #include <vcl/svapp.hxx> +//IAccessibility2 Implementation 2009----- +#ifndef _SVX_ACCESSIBILITY_SHAPE_TYPE_HANDLER_HXX +#include <svx/ShapeTypeHandler.hxx> +#endif +#ifndef _SVX_ACCESSIBILITY_SVX_SHAPE_TYPES_HXX +#include <svx/SvxShapeTypes.hxx> +#endif +#ifndef _SVDPAGE_HXX +#include <svx/svdpage.hxx> +#endif #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> #include <cppuhelper/implbase1.hxx> #include <pagepreviewlayout.hxx> +#include <dcontact.hxx> +#include <svx/unoapi.hxx> +#include <doc.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <dflyobj.hxx> @@ -280,7 +295,9 @@ SwAccessibleObjShape_Impl { const SdrObject *pObj = (*aIter).first; uno::Reference < XAccessible > xAcc( (*aIter).second ); - if( nSelShapes && pFESh->IsObjSelected( *pObj ) ) + //IAccessibility2 Implementation 2009----- + if( nSelShapes && pFESh &&pFESh->IsObjSelected( *pObj ) ) + //-----IAccessibility2 Implementation 2009 { // selected objects are inserted from the back --pSelShape; @@ -336,20 +353,31 @@ private: SwAccessibleEvent_Impl& operator==( const SwAccessibleEvent_Impl& ); public: + //IAccessibility2 Implementation 2009----- + const SwFrm* mpParentFrm; // The object that fires the event + sal_Bool IsNoXaccParentFrm() const + { + return CHILD_POS_CHANGED == meType && mpParentFrm != 0; + } + uno::WeakReference < XAccessible > GetxAcc() const { return mxAcc;} + //-----IAccessibility2 Implementation 2009 +public: SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, const SwAccessibleChild& rFrmOrObj ) : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ) + mnStates( 0 ), + mpParentFrm( 0 ) {} SwAccessibleEvent_Impl( EventType eT, const SwAccessibleChild& rFrmOrObj ) : maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ) + mnStates( 0 ), + mpParentFrm( 0 ) { ASSERT( SwAccessibleEvent_Impl::DISPOSE == meType, "wrong event constructor, DISPOSE only" ); @@ -357,7 +385,8 @@ public: SwAccessibleEvent_Impl( EventType eT ) : meType( eT ), - mnStates( 0 ) + mnStates( 0 ), + mpParentFrm( 0 ) { ASSERT( SwAccessibleEvent_Impl::SHAPE_SELECTION == meType, "wrong event constructor, SHAPE_SELECTION only" ); @@ -371,7 +400,8 @@ public: mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ) + mnStates( 0 ), + mpParentFrm( 0 ) { ASSERT( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType || SwAccessibleEvent_Impl::POS_CHANGED == meType, @@ -386,12 +416,28 @@ public: : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( _nStates ) + mnStates( _nStates ), + mpParentFrm( 0 ) { ASSERT( SwAccessibleEvent_Impl::CARET_OR_STATES == meType, "wrong event constructor, CARET_OR_STATES only" ); } + //IAccessibility2 Implementation 2009----- + SwAccessibleEvent_Impl( EventType eT, + const SwFrm *pParentFrm, + const SwAccessibleChild& rFrmOrObj, + const SwRect& rR ) : + maOldBox( rR ), + maFrmOrObj( rFrmOrObj ), + meType( eT ), + mnStates( 0 ), + mpParentFrm( pParentFrm ) + { + OSL_ENSURE( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType, + "wrong event constructor, CHILD_POS_CHANGED only" ); + } + //-----IAccessibility2 Implementation 2009 // <SetType(..)> only used in method <SwAccessibleMap::AppendEvent(..)> inline void SetType( EventType eT ) { @@ -495,8 +541,47 @@ public: { return mbFiring; } + //IAccessibility2 Implementation 2009----- + struct XAccisNULL + { + bool operator()(const SwAccessibleEvent_Impl& e) + { + return e.IsNoXaccParentFrm(); + } + }; + void MoveInvalidXAccToEnd(); + //-----IAccessibility2 Implementation 2009 }; +//IAccessibility2 Implementation 2009----- +void SwAccessibleEventList_Impl::MoveInvalidXAccToEnd() +{ + int nSize = size(); + if (nSize < 2 ) + { + return; + } + SwAccessibleEventList_Impl lstEvent; + iterator li = begin(); + for ( ;li != end();) + { + SwAccessibleEvent_Impl e = *li; + if (e.IsNoXaccParentFrm()) + { + iterator liNext = li; + ++liNext; + erase(li); + li = liNext; + lstEvent.insert(lstEvent.end(),e); + } + else + ++li; + } + OSL_ENSURE(size() + lstEvent.size() == nSize ,""); + insert(end(),lstEvent.begin(),lstEvent.end()); + OSL_ENSURE(size() == nSize ,""); +} +//-----IAccessibility2 Implementation 2009 //------------------------------------------------------------------------------ // The shape list is filled if an accessible shape is destroyed. It // simply keeps a reference to the accessible shape's XShape. These @@ -827,6 +912,25 @@ static sal_Bool AreInSameTable( const uno::Reference< XAccessible >& rAcc, void SwAccessibleMap::FireEvent( const SwAccessibleEvent_Impl& rEvent ) { ::vos::ORef < SwAccessibleContext > xAccImpl( rEvent.GetContext() ); + //IAccessibility2 Implementation 2009----- + if (!xAccImpl.isValid() && rEvent.mpParentFrm != 0 ) + { + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( rEvent.mpParentFrm ); + if( aIter != mpFrmMap->end() ) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if (xAcc.is()) + { + uno::Reference < XAccessibleContext > xContext(xAcc,uno::UNO_QUERY); + if (xContext.is() && xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + { + xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() ); + } + } + } + } + //-----IAccessibility2 Implementation 2009 if( SwAccessibleEvent_Impl::SHAPE_SELECTION == rEvent.GetType() ) { DoInvalidateShapeSelection(); @@ -1044,8 +1148,323 @@ void SwAccessibleMap::InvalidateShapeSelection() DoInvalidateShapeSelection(); } } +//IAccessibility2 Implementation 2009----- +//This method should implement the following functions: +//1.find the shape objects and set the selected state. +//2.find the Swframe objects and set the selected state. +//3.find the paragraph objects and set the selected state. +void SwAccessibleMap::InvalidateShapeInParaSelection() +{ + SwAccessibleObjShape_Impl *pShapes = 0; + SwAccessibleObjShape_Impl *pSelShape = 0; + size_t nShapes = 0; + + const ViewShell *pVSh = GetShell(); + const SwFEShell *pFESh = dynamic_cast< const SwFEShell* >(pVSh); + SwPaM* pCrsr = pFESh ? pFESh->GetCrsr( sal_False /* ??? */ ) : NULL;//IAccessibility2 Implementation 2009 + + //sal_uInt16 nSelShapes = pFESh ? pFESh->IsObjSelected() : 0; -void SwAccessibleMap::DoInvalidateShapeSelection() + { + vos::OGuard aGuard( maMutex ); + if( mpShapeMap ) + pShapes = mpShapeMap->Copy( nShapes, pFESh, &pSelShape ); + } + + sal_Bool bIsSelAll =IsDocumentSelAll(); + + if( mpShapeMap ) + { + //Checked for shapes. + _SwAccessibleShapeMap_Impl::const_iterator aIter = mpShapeMap->begin(); + _SwAccessibleShapeMap_Impl::const_iterator aEndIter = mpShapeMap->end(); + ::vos::ORef< SwAccessibleContext > xParentAccImpl; + + if( bIsSelAll) + { + while( aIter != aEndIter ) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if( xAcc.is() ) + (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->SetState( AccessibleStateType::SELECTED ); + + ++aIter; + } + } + else + { + while( aIter != aEndIter ) + { + sal_Bool bChanged = sal_False; + sal_Bool bMarked = sal_False; + SwAccessibleChild pFrm( (*aIter).first ); + + const SwFrmFmt *pFrmFmt = (*aIter).first ? ::FindFrmFmt( (*aIter).first ) : 0; + if( !pFrmFmt ) { ++aIter; continue; } + const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor(); + const SwPosition *pPos = pAnchor.GetCntntAnchor(); + + if(pAnchor.GetAnchorId() == FLY_AT_PAGE) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if(xAcc.is()) + (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED ); + + ++aIter; continue; + } + + if( !pPos ) { ++aIter; continue; } + if( pPos->nNode.GetNode().GetTxtNode() ) + { + int pIndex = pPos->nContent.GetIndex(); + SwPaM* pTmpCrsr = pCrsr; + if( pTmpCrsr != NULL ) + { + const SwTxtNode* pNode = pPos->nNode.GetNode().GetTxtNode(); + sal_uLong nHere = pNode->GetIndex(); + + do + { + // ignore, if no mark + if( pTmpCrsr->HasMark() ) + { + bMarked = sal_True; + // check whether nHere is 'inside' pCrsr + SwPosition* pStart = pTmpCrsr->Start(); + sal_uLong nStartIndex = pStart->nNode.GetIndex(); + SwPosition* pEnd = pTmpCrsr->End(); + sal_uLong nEndIndex = pEnd->nNode.GetIndex(); + if( ( nHere >= nStartIndex ) && (nHere <= nEndIndex) ) + { + if( pAnchor.GetAnchorId() == FLY_AS_CHAR ) + { + if( ( (nHere == nStartIndex) && (pIndex >= pStart->nContent.GetIndex()) || (nHere > nStartIndex) ) + &&( (nHere == nEndIndex) && (pIndex < pEnd->nContent.GetIndex()) || (nHere < nEndIndex) ) ) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if( xAcc.is() ) + bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->SetState( AccessibleStateType::SELECTED ); + } + else + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if( xAcc.is() ) + bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED ); + } + } + else if( pAnchor.GetAnchorId() == FLY_AT_PARA ) + { + if( ((nHere > nStartIndex) || pStart->nContent.GetIndex() ==0 ) + && (nHere < nEndIndex ) ) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if( xAcc.is() ) + bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->SetState( AccessibleStateType::SELECTED ); + } + else + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if(xAcc.is()) + bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED ); + } + } + } + } + // next PaM in ring + pTmpCrsr = static_cast<SwPaM*>( pTmpCrsr->GetNext() ); + } + while( pTmpCrsr != pCrsr ); + } + if( !bMarked ) + { + SwAccessibleObjShape_Impl *pShape = pShapes; + size_t nNumShapes = nShapes; + while( nNumShapes ) + { + if( pShape < pSelShape && (pShape->first==(*aIter).first) ) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + if(xAcc.is()) + bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED ); + } + --nNumShapes; + ++pShape; + } + } + } + ++aIter; + }//while( aIter != aEndIter ) + }//else + } + + //Checked for FlyFrm + SwAccessibleContextMap_Impl::iterator aIter = mpFrmMap->begin(); + while( aIter != mpFrmMap->end() ) + { + const SwFrm *pFrm = (*aIter).first; + if(pFrm->IsFlyFrm()) + { + sal_Bool bFrmChanged = sal_False; + uno::Reference < XAccessible > xAcc = (*aIter).second; + + if(xAcc.is()) + { + SwAccessibleFrameBase *pAccFrame = (static_cast< SwAccessibleFrameBase * >(xAcc.get())); + bFrmChanged = pAccFrame->SetSelectedState( sal_True ); + if (bFrmChanged) + { + const SwFlyFrm *pFlyFrm = static_cast< const SwFlyFrm * >( pFrm ); + const SwFrmFmt *pFrmFmt = pFlyFrm->GetFmt(); + if (pFrmFmt) + { + const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor(); + if( pAnchor.GetAnchorId() == FLY_AS_CHAR ) + { + uno::Reference< XAccessible > xAccParent = pAccFrame->getAccessibleParent(); + if (xAccParent.is()) + { + uno::Reference< XAccessibleContext > xAccContext = xAccParent->getAccessibleContext(); + if(xAccContext.is() && xAccContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + { + SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xAccContext.get()); + if(pAccFrame->IsSeletedInDoc()) + { + m_setParaAdd.insert(pAccPara); + } + else if(m_setParaAdd.count(pAccPara) == 0) + { + m_setParaRemove.insert(pAccPara); + } + } + } + } + } + } + } + } + ++aIter; + } + typedef std::vector< SwAccessibleContext* > VEC_PARA; + VEC_PARA vecAdd; + VEC_PARA vecRemove; + //Checked for Paras. + SwPaM* pTmpCrsr = pCrsr; + sal_Bool bMarkChanged = sal_False; + SwAccessibleContextMap_Impl mapTemp; + if( pTmpCrsr != NULL ) + { + do + { + if( pTmpCrsr->HasMark() ) + { + SwNodeIndex nStartIndex( pTmpCrsr->Start()->nNode ); + SwNodeIndex nEndIndex( pTmpCrsr->End()->nNode ); + while(nStartIndex <= nEndIndex) + { + SwFrm *pFrm = NULL; + if(nStartIndex.GetNode().IsCntntNode()) + { + SwCntntNode* pCNd = (SwCntntNode*)&(nStartIndex.GetNode()); + SwClientIter aClientIter( *pCNd ); + pFrm = dynamic_cast< SwFrm* >(aClientIter.SwClientIter_First()); + } + else if( nStartIndex.GetNode().IsTableNode() ) + { + SwTableNode * pTable= (SwTableNode *)&(nStartIndex.GetNode()); + SwFrmFmt* pFmt = const_cast<SwFrmFmt*>(pTable->GetTable().GetFrmFmt()); + SwClientIter aClientIter( *pFmt ); + pFrm = dynamic_cast< SwFrm* >(aClientIter.SwClientIter_First()); + } + + if( pFrm && mpFrmMap) + { + aIter = mpFrmMap->find( pFrm ); + if( aIter != mpFrmMap->end() ) + { + uno::Reference < XAccessible > xAcc = (*aIter).second; + sal_Bool isChanged = sal_False; + if( xAcc.is() ) + { + isChanged = (static_cast< SwAccessibleContext * >(xAcc.get()))->SetSelectedState( sal_True ); + } + if(!isChanged) + { + SwAccessibleContextMap_Impl::iterator aEraseIter = mpSeletedFrmMap->find( pFrm ); + if(aEraseIter != mpSeletedFrmMap->end()) + mpSeletedFrmMap->erase(aEraseIter); + } + else + { + bMarkChanged = sal_True; + vecAdd.push_back(static_cast< SwAccessibleContext * >(xAcc.get())); + } + + mapTemp.insert( SwAccessibleContextMap_Impl::value_type( pFrm, xAcc ) ); + } + } + nStartIndex++; + } + } + pTmpCrsr = static_cast<SwPaM*>( pTmpCrsr->GetNext() ); + } + while( pTmpCrsr != pCrsr ); + } + if( !mpSeletedFrmMap ) + mpSeletedFrmMap = new SwAccessibleContextMap_Impl; + if( !mpSeletedFrmMap->empty() ) + { + aIter = mpSeletedFrmMap->begin(); + while( aIter != mpSeletedFrmMap->end() ) + { + uno::Reference < XAccessible > xAcc = (*aIter).second; + if(xAcc.is()) + (static_cast< SwAccessibleContext * >(xAcc.get()))->SetSelectedState( sal_False ); + ++aIter; + vecRemove.push_back(static_cast< SwAccessibleContext * >(xAcc.get())); + } + bMarkChanged = sal_True; + mpSeletedFrmMap->clear(); + } + + if( !mapTemp.empty() ) + { + aIter = mapTemp.begin(); + while( aIter != mapTemp.end() ) + { + mpSeletedFrmMap->insert( SwAccessibleContextMap_Impl::value_type( (*aIter).first, (*aIter).second ) ); + ++aIter; + } + mapTemp.clear(); + } + if( bMarkChanged && mpFrmMap) + { + VEC_PARA::iterator vi = vecAdd.begin(); + for (; vi != vecAdd.end() ; ++vi) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; + SwAccessibleContext* pAccPara = *vi; + if (pAccPara) + { + pAccPara->FireAccessibleEvent( aEvent ); + } + } + vi = vecRemove.begin(); + for (; vi != vecRemove.end() ; ++vi) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; + SwAccessibleContext* pAccPara = *vi; + if (pAccPara) + { + pAccPara->FireAccessibleEvent( aEvent ); + } + } + } +} + +//Marge with DoInvalidateShapeFocus +void SwAccessibleMap::DoInvalidateShapeSelection(sal_Bool bInvalidateFocusMode /*=sal_False*/) { SwAccessibleObjShape_Impl *pShapes = 0; SwAccessibleObjShape_Impl *pSelShape = 0; @@ -1055,6 +1474,13 @@ void SwAccessibleMap::DoInvalidateShapeSelection() const SwFEShell *pFESh = dynamic_cast< const SwFEShell * >( pVSh ); sal_uInt32 nSelShapes = pFESh ? pFESh->GetNumberOfSelectedObjects() : 0; + + //when InvalidateFocus Call this function ,and the current selected shape count is not 1 , + //return + if (bInvalidateFocusMode && nSelShapes != 1) + { + return; + } { vos::OGuard aGuard( maMutex ); if( mpShapeMap ) @@ -1063,24 +1489,71 @@ void SwAccessibleMap::DoInvalidateShapeSelection() if( pShapes ) { - ::std::list< const SwFrm * > aParents; + typedef std::vector< ::vos::ORef < ::accessibility::AccessibleShape > > VEC_SHAPE; + VEC_SHAPE vecxShapeAdd; + VEC_SHAPE vecxShapeRemove; + int nCountSelectedShape=0; + Window *pWin = GetShell()->GetWin(); sal_Bool bFocused = pWin && pWin->HasFocus(); SwAccessibleObjShape_Impl *pShape = pShapes; + int nShapeCount = nShapes; + while( nShapeCount ) + { + //if( pShape->second.isValid() ) + if (pShape->second.isValid() && IsInSameLevel(pShape->first, pFESh)) + { + if( pShape < pSelShape ) + { + if(pShape->second->ResetState( AccessibleStateType::SELECTED )) + { + vecxShapeRemove.push_back(pShape->second); + } + pShape->second->ResetState( AccessibleStateType::FOCUSED ); + } + } + --nShapeCount; + ++pShape; + } + + VEC_SHAPE::iterator vi =vecxShapeRemove.begin(); + for (; vi != vecxShapeRemove.end(); ++vi) + { + ::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr()); + if (pAccShape) + { + pAccShape->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), uno::Any()); + } + } + + pShape = pShapes; while( nShapes ) { - if( pShape->second.isValid() ) + //if( pShape->second.isValid() ) + if (pShape->second.isValid() && IsInSameLevel(pShape->first, pFESh)) { - sal_Bool bChanged; + // IA2 - why? + // sal_Bool bChanged; if( pShape >= pSelShape ) { - bChanged = - pShape->second->SetState( AccessibleStateType::SELECTED ); + // IA2: first fire focus event + // bChanged = pShape->second->SetState( AccessibleStateType::SELECTED ); + + //first fire focus event if( bFocused && 1 == nSelShapes ) pShape->second->SetState( AccessibleStateType::FOCUSED ); else pShape->second->ResetState( AccessibleStateType::FOCUSED ); + + // IA2 CWS: + if(pShape->second->SetState( AccessibleStateType::SELECTED )) + { + vecxShapeAdd.push_back(pShape->second); + } + ++nCountSelectedShape; } + /* MT: This still was in DEV300m80, but was removed in IA2 CWS. + Someone needs to check what should happen here, see original diff CWS oo31ia2 vs. OOO310M11 else { bChanged = @@ -1094,47 +1567,97 @@ void SwAccessibleMap::DoInvalidateShapeSelection() GetShell()->IsPreView() ); aParents.push_back( pParent ); } + */ } --nShapes; ++pShape; } - if( aParents.size() > 0 ) + + const int SELECTION_WITH_NUM =10; + if (vecxShapeAdd.size() > SELECTION_WITH_NUM ) { - ::std::list< const SwFrm * >::const_iterator aIter = aParents.begin(); - ::std::list< const SwFrm * >::const_iterator aEndIter = aParents.end(); - while( aIter != aEndIter ) + uno::Reference< XAccessible > xDoc = GetDocumentView( ); + SwAccessibleContext * pCont = static_cast<SwAccessibleContext *>(xDoc.get()); + if (pCont) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; + pCont->FireAccessibleEvent(aEvent); + } + } + else + { + short nEventID = AccessibleEventId::SELECTION_CHANGED_ADD; + if (nCountSelectedShape <= 1 && vecxShapeAdd.size() == 1 ) + { + nEventID = AccessibleEventId::SELECTION_CHANGED; + } + vi = vecxShapeAdd.begin(); + for (; vi != vecxShapeAdd.end(); ++vi) { - ::vos::ORef< SwAccessibleContext > xParentAccImpl; + ::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr()); + if (pAccShape) { - vos::OGuard aGuard( maMutex ); - if( mpFrmMap ) + pAccShape->CommitChange(nEventID, uno::Any(), uno::Any()); + } + } + } + + vi = vecxShapeAdd.begin(); + for (; vi != vecxShapeAdd.end(); ++vi) + { + ::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr()); + if (pAccShape) + { + SdrObject *pObj = GetSdrObjectFromXShape(pAccShape->GetXShape()); + SwFrmFmt *pFrmFmt = pObj ? FindFrmFmt( pObj ) : NULL; + if (pFrmFmt) + { + const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor(); + if( pAnchor.GetAnchorId() == FLY_AS_CHAR ) { - SwAccessibleContextMap_Impl::const_iterator aMapIter = - mpFrmMap->find( *aIter ); - if( aMapIter != mpFrmMap->end() ) + uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent(); + if (xPara.is()) { - uno::Reference < XAccessible > xAcc( (*aMapIter).second ); - xParentAccImpl = - static_cast< SwAccessibleContext *>( xAcc.get() ); + uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext(); + if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + { + SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get()); + if (pAccPara) + { + m_setParaAdd.insert(pAccPara); + } + } } } } - if( xParentAccImpl.isValid() ) + } + } + vi = vecxShapeRemove.begin(); + for (; vi != vecxShapeRemove.end(); ++vi) + { + ::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr()); + if (pAccShape) + { + uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent(); + uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext(); + if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; - xParentAccImpl->FireAccessibleEvent( aEvent ); + SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get()); + if (m_setParaAdd.count(pAccPara) == 0 ) + { + m_setParaRemove.insert(pAccPara); + } } - - ++aIter; } } - delete[] pShapes; } } +//Marge with DoInvalidateShapeSelection +/* void SwAccessibleMap::DoInvalidateShapeFocus() { const ViewShell *pVSh = GetShell(); @@ -1177,7 +1700,8 @@ void SwAccessibleMap::DoInvalidateShapeFocus() delete[] pShapes; } } - +*/ +//-----IAccessibility2 Implementation 2009 SwAccessibleMap::SwAccessibleMap( ViewShell *pSh ) : mpFrmMap( 0 ), @@ -1193,7 +1717,8 @@ SwAccessibleMap::SwAccessibleMap( ViewShell *pSh ) : mnPara( 1 ), mnFootnote( 1 ), mnEndnote( 1 ), - mbShapeSelected( sal_False ) + mbShapeSelected( sal_False ), + mpSeletedFrmMap(NULL)//IAccessibility2 Implementation 2009 { pSh->GetLayout()->AddAccessibleShell(); } @@ -1214,10 +1739,28 @@ SwAccessibleMap::~SwAccessibleMap() } } + //IAccessibility2 Implementation 2009----- + if(xAcc.is()) + { SwAccessibleDocument *pAcc = static_cast< SwAccessibleDocument * >( xAcc.get() ); pAcc->Dispose( sal_True ); - + } + if( mpFrmMap ) + { + SwAccessibleContextMap_Impl::iterator aIter = mpFrmMap->begin(); + while( aIter != mpFrmMap->end() ) + { + uno::Reference < XAccessible > xTmp = (*aIter).second; + if( xTmp.is() ) + { + SwAccessibleContext *pTmp = static_cast< SwAccessibleContext * >( xTmp.get() ); + pTmp->SetMap(NULL); + } + ++aIter; + } + } + //-----IAccessibility2 Implementation 2009 { vos::OGuard aGuard( maMutex ); #ifdef DBG_UTIL @@ -1298,6 +1841,7 @@ SwAccessibleMap::~SwAccessibleMap() mpEvents = 0; } mpVSh->GetLayout()->RemoveAccessibleShell(); + delete mpSeletedFrmMap;//IAccessibility2 Implementation 2009 } uno::Reference< XAccessible > SwAccessibleMap::_GetDocumentView( @@ -1429,7 +1973,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, sal_Bool bIsEndnote = SwAccessibleFootnote::IsEndnote( pFtnFrm ); pAcc = new SwAccessibleFootnote( this, bIsEndnote, - (bIsEndnote ? mnEndnote++ : mnFootnote++), + /*(bIsEndnote ? mnEndnote++ : mnFootnote++),*/ pFtnFrm ); } break; @@ -1584,6 +2128,10 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( } // TODO: focus!!! } + //IAccessibility2 Implementation 2009----- + if (xAcc.is()) + AddGroupContext(pObj, xAcc); + //-----IAccessibility2 Implementation 2009 } } } @@ -1594,6 +2142,105 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( return xAcc; } +//IAccessibility2 Implementation 2009----- +sal_Bool SwAccessibleMap::IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh) +{ + if (pFESh && pObj) + return pFESh->IsObjSameLevelWithMarked(*pObj); + return sal_False; +} +void SwAccessibleMap::AddShapeContext(const SdrObject *pObj, uno::Reference < XAccessible > xAccShape) +{ + vos::OGuard aGuard( maMutex ); + + if( mpShapeMap ) + { + SwAccessibleShapeMap_Impl::value_type aEntry( pObj, xAccShape ); + mpShapeMap->insert( aEntry ); + } + +} + +//Added by yanjun for sym2_6407 +void SwAccessibleMap::RemoveGroupContext(const SdrObject *pParentObj, ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccParent) +{ + vos::OGuard aGuard( maMutex ); + if (mpShapeMap && pParentObj && pParentObj->getChildrenOfSdrObject() && xAccParent.is()) + { + uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext(); + if (xContext.is()) + { + for (sal_Int32 i = 0; i < xContext->getAccessibleChildCount(); ++i) + { + uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i); + if (xChild.is()) + { + uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext(); + if (xChildContext.is()) + { + if (xChildContext->getAccessibleRole() == AccessibleRole::SHAPE) + { + ::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get()); + uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape(); + if (xShape.is()) + { + SdrObject* pObj = GetSdrObjectFromXShape(xShape); + if (pObj) + RemoveContext(pObj); + } + } + } + } + } + } + } +} +//End + + +void SwAccessibleMap::AddGroupContext(const SdrObject *pParentObj, uno::Reference < XAccessible > xAccParent) +{ + vos::OGuard aGuard( maMutex ); + if( mpShapeMap ) + { + //here get all the sub list. + if (pParentObj->getChildrenOfSdrObject()) + { + if (xAccParent.is()) + { + uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext(); + if (xContext.is()) + { + sal_Int32 nChildren = xContext->getAccessibleChildCount(); + for(sal_Int32 i = 0; i<nChildren; i++) + { + uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i); + if (xChild.is()) + { + uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext(); + if (xChildContext.is()) + { + short nRole = xChildContext->getAccessibleRole(); + if (nRole == AccessibleRole::SHAPE) + { + ::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get()); + uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape(); + if (xShape.is()) + { + SdrObject* pObj = GetSdrObjectFromXShape(xShape); + AddShapeContext(pObj, xChild); + AddGroupContext(pObj,xChild); + } + } + } + } + } + } + } + } + } +} +//-----IAccessibility2 Implementation 2009 ::vos::ORef < ::accessibility::AccessibleShape > SwAccessibleMap::GetContextImpl( const SdrObject *pObj, @@ -1656,13 +2303,16 @@ void SwAccessibleMap::RemoveContext( const SdrObject *pObj ) mpShapeMap->find( pObj ); if( aIter != mpShapeMap->end() ) { + //IAccessible2 Implementation 2009 ---- + uno::Reference < XAccessible > xAcc( (*aIter).second ); mpShapeMap->erase( aIter ); - + RemoveGroupContext(pObj, xAcc); // The shape selection flag is not cleared, but one might do // so but has to make sure that the removed context is the one // that is selected. - if( mpShapeMap->empty() ) + if( mpShapeMap && mpShapeMap->empty() ) + //---- IAccessible2 Implementation 2009 { delete mpShapeMap; mpShapeMap = 0; @@ -1809,6 +2459,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, { ::vos::ORef< SwAccessibleContext > xAccImpl; ::vos::ORef< SwAccessibleContext > xParentAccImpl; + const SwFrm *pParent =NULL; //IAccessibility2 Implementation 2009 { vos::OGuard aGuard( maMutex ); @@ -1831,7 +2482,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, { // Otherwise we look if the parent is accessible. // If not, there is nothing to do. - const SwFrm *pParent = + pParent = //IAccessibility2 Implementation 2009 SwAccessibleFrame::GetParent( aFrmOrObj, GetShell()->IsPreView()); @@ -1881,7 +2532,54 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, rOldBox ); } } + //IAccessibility2 Implementation 2009----- + else if(pParent) + { +/* +For child graphic and it's parent paragraph,if split 2 graphic to 2 paragraph, +will delete one graphic swfrm and new create 1 graphic swfrm , +then the new paragraph and the new graphic SwFrm will add . +but when add graphic SwFrm ,the accessible of the new Paragraph is not created yet. +so the new graphic accessible 'parent is NULL, +so run here: save the parent's SwFrm not the accessible object parent, +*/ + sal_Bool bIsValidFrm = sal_False; + sal_Bool bIsTxtParent = sal_False; + if (aFrmOrObj.GetSwFrm()) + { + int nType = pFrm->GetType(); + if ( FRM_FLY == nType ) + { + bIsValidFrm =sal_True; + } + } + else if(pObj) + { + int nType = pParent->GetType(); + if (FRM_TXT == nType) + { + bIsTxtParent =sal_True; + } + } +// sal_Bool bIsVisibleChildrenOnly =aFrmOrObj.IsVisibleChildrenOnly() ; +// sal_Bool bIsBoundAsChar =aFrmOrObj.IsBoundAsChar() ;//bIsVisibleChildrenOnly && bIsBoundAsChar && + if((bIsValidFrm || bIsTxtParent) ) + { + if( GetShell()->ActionPend() ) + { + SwAccessibleEvent_Impl aEvent( + SwAccessibleEvent_Impl::CHILD_POS_CHANGED, + pParent, aFrmOrObj, rOldBox ); + AppendEvent( aEvent ); + } + else + { + OSL_ENSURE(false,""); + } + } + } } + //-----IAccessibility2 Implementation 2009 } void SwAccessibleMap::InvalidateContent( const SwFrm *pFrm ) @@ -2020,6 +2718,29 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrm *pFrm ) mpFrmMap->find( aFrmOrObj.GetSwFrm() ); if( aIter != mpFrmMap->end() ) xAcc = (*aIter).second; + //IAccessibility2 Implementation 2009----- + else + { + SwRect rcEmpty; + const SwTabFrm* pTabFrm = aFrmOrObj.GetSwFrm()->FindTabFrm(); + if (pTabFrm) + { + InvalidatePosOrSize(pTabFrm,0,0,rcEmpty); + } + else + { + InvalidatePosOrSize(aFrmOrObj.GetSwFrm(),0,0,rcEmpty); + } + + + aIter = + mpFrmMap->find( aFrmOrObj.GetSwFrm() ); + if( aIter != mpFrmMap->end() ) + { + xAcc = (*aIter).second; + } + } + //-----IAccessibility2 Implementation 2009 // For cells, some extra thoughts are necessary, // because invalidating the cursor for one cell @@ -2048,18 +2769,204 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrm *pFrm ) xAcc = GetContext( aFrmOrObj.GetSwFrm(), sal_True ); } } + //IAccessibility2 Implementation 2009----- + else if (bShapeSelected) + { + const SwFEShell *pFESh = pVSh ? static_cast< const SwFEShell * >( pVSh ) : NULL ; + if(pFESh) + { + SdrObject* pObj = pFESh->getSingleSelected(); + + if(pObj) + { + ::vos::ORef < ::accessibility::AccessibleShape > pAccShapeImpl = GetContextImpl(pObj,NULL,sal_False); + + if (!pAccShapeImpl.isValid()) + { + while(pObj && pObj->GetParentSdrObject()) + { + pObj = pObj->GetParentSdrObject(); + } + + if (pObj != NULL) + { + const SwFrm *pParent = SwAccessibleFrame::GetParent( SwAccessibleChild(pObj), GetShell()->IsPreView() ); + if( pParent ) + { + ::vos::ORef< SwAccessibleContext > xParentAccImpl = GetContextImpl(pParent,sal_False); + if (!xParentAccImpl.isValid()) + { + const SwTabFrm* pTabFrm = pParent->FindTabFrm(); + if (pTabFrm) + { + //The Table should not add in acc.because the "pParent" is not add to acc . + uno::Reference< XAccessible> xAccParentTab = GetContext(pTabFrm,sal_True);//Should Create. + + const SwFrm *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pTabFrm), GetShell()->IsPreView() ); + if (pParentRoot) + { + ::vos::ORef< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,sal_False); + if(xParentAccImplRoot.isValid()) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.NewValue <<= xAccParentTab; + xParentAccImplRoot->FireAccessibleEvent( aEvent ); + } + } + + //Get "pParent" acc again. + xParentAccImpl = GetContextImpl(pParent,sal_False); + } + else + { + //directly create this acc para . + xParentAccImpl = GetContextImpl(pParent,sal_True);//Should Create. + + const SwFrm *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pParent), GetShell()->IsPreView() ); + + ::vos::ORef< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,sal_False); + if(xParentAccImplRoot.isValid()) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.NewValue <<= uno::Reference< XAccessible>(xParentAccImpl.getBodyPtr()); + xParentAccImplRoot->FireAccessibleEvent( aEvent ); + } + } + } + if (xParentAccImpl.isValid()) + { + uno::Reference< XAccessible> xAccShape = + GetContext(pObj,xParentAccImpl.getBodyPtr(),sal_True); + + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.NewValue <<= xAccShape; + xParentAccImpl->FireAccessibleEvent( aEvent ); + } + } + } + } + } + } + } } + m_setParaAdd.clear(); + m_setParaRemove.clear(); if( xOldAcc.is() && xOldAcc != xAcc ) InvalidateCursorPosition( xOldAcc ); if( bOldShapeSelected || bShapeSelected ) InvalidateShapeSelection(); if( xAcc.is() ) InvalidateCursorPosition( xAcc ); + + InvalidateShapeInParaSelection(); + + SET_PARA::iterator si = m_setParaRemove.begin(); + for (; si != m_setParaRemove.end() ; ++si) + { + SwAccessibleParagraph* pAccPara = *si; + if(pAccPara && pAccPara->getSelectedAccessibleChildCount() == 0 && pAccPara->getSelectedText().getLength() == 0) + { + if(pAccPara->SetSelectedState(sal_False)) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; + pAccPara->FireAccessibleEvent( aEvent ); + } + } + } + si = m_setParaAdd.begin(); + for (; si != m_setParaAdd.end() ; ++si) + { + SwAccessibleParagraph* pAccPara = *si; + if(pAccPara && pAccPara->SetSelectedState(sal_True)) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; + pAccPara->FireAccessibleEvent( aEvent ); + } + } + //-----IAccessibility2 Implementation 2009 +} + +//IAccessibility2 Implementation 2009----- +//Notify the page change event to bridge. +void SwAccessibleMap::FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage) +{ + uno::Reference<XAccessible> xAcc = GetDocumentView( ); + if ( xAcc.is() ) + { + SwAccessibleDocumentBase *pAcc = + static_cast< SwAccessibleDocumentBase * >( xAcc.get() ); + if (pAcc) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::PAGE_CHANGED; + aEvent.OldValue <<= nOldPage; + aEvent.NewValue <<= nNewPage; + pAcc->FireAccessibleEvent( aEvent ); + } + } +} + +void SwAccessibleMap::FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection) +{ + uno::Reference<XAccessible> xAcc = GetDocumentView( ); + if ( xAcc.is() ) + { + SwAccessibleDocumentBase *pAcc = + static_cast< SwAccessibleDocumentBase * >( xAcc.get() ); + if (pAcc) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SECTION_CHANGED; + aEvent.OldValue <<= nOldSection; + aEvent.NewValue <<= nNewSection; + pAcc->FireAccessibleEvent( aEvent ); + + } + } } +void SwAccessibleMap::FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn) +{ + uno::Reference<XAccessible> xAcc = GetDocumentView( ); + if ( xAcc.is() ) + { + SwAccessibleDocumentBase *pAcc = + static_cast< SwAccessibleDocumentBase * >( xAcc.get() ); + if (pAcc) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::COLUMN_CHANGED; + aEvent.OldValue <<= nOldColumn; + aEvent.NewValue <<= nNewColumn; + pAcc->FireAccessibleEvent( aEvent ); + + } + } +} +//-----IAccessibility2 Implementation 2009 void SwAccessibleMap::InvalidateFocus() { + //IAccessibility2 Implementation 2009----- + if(GetShell()->IsPreView()) + { + uno::Reference<XAccessible> xAcc = _GetDocumentView( sal_True ); + if (xAcc.get()) + { + SwAccessiblePreview *pAccPreview = static_cast<SwAccessiblePreview *>(xAcc.get()); + if (pAccPreview) + { + pAccPreview->InvalidateFocus(); + return ; + } + } + } + //-----IAccessibility2 Implementation 2009 uno::Reference < XAccessible > xAcc; sal_Bool bShapeSelected; { @@ -2075,10 +2982,12 @@ void SwAccessibleMap::InvalidateFocus() static_cast< SwAccessibleContext *>( xAcc.get() ); pAccImpl->InvalidateFocus(); } - else if( bShapeSelected ) + //IAccessibility2 Implementation 2009----- + else { - DoInvalidateShapeFocus(); + DoInvalidateShapeSelection(sal_True); } + //-----IAccessibility2 Implementation 2009 } void SwAccessibleMap::SetCursorContext( @@ -2361,6 +3270,9 @@ void SwAccessibleMap::FireEvents() if( mpEvents ) { mpEvents->SetFiring(); + //IAccessibility2 Implementation 2009----- + mpEvents->MoveInvalidXAccToEnd(); + //-----IAccessibility2 Implementation 2009 SwAccessibleEventList_Impl::iterator aIter = mpEvents->begin(); while( aIter != mpEvents->end() ) { @@ -2551,6 +3463,94 @@ sal_Bool SwAccessibleMap::ReplaceChild ( return sal_True; } +//IAccessibility2 Implementation 2009----- +//Get the accessible control shape from the model object, here model object is with XPropertySet type +::accessibility::AccessibleControlShape * SwAccessibleMap::GetAccControlShapeFromModel(::com::sun::star::beans::XPropertySet* pSet) throw (::com::sun::star::uno::RuntimeException) +{ + if( mpShapeMap ) + { + SwAccessibleShapeMap_Impl::const_iterator aIter = mpShapeMap->begin(); + SwAccessibleShapeMap_Impl::const_iterator aEndIter = mpShapeMap->end(); + while( aIter != aEndIter) + { + uno::Reference < XAccessible > xAcc( (*aIter).second ); + ::accessibility::AccessibleShape *pAccShape = + static_cast < ::accessibility::AccessibleShape* >( xAcc.get() ); + if(pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == ::accessibility::DRAWING_CONTROL) + { + ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape); + if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet) + return pCtlAccShape; + } + ++aIter; + } + } + return NULL; +} + +::com::sun::star::uno::Reference< XAccessible > + SwAccessibleMap::GetAccessibleCaption (const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape) + throw (::com::sun::star::uno::RuntimeException) +{ + SdrObject* captionedObject = GetSdrObjectFromXShape(xShape); + + // replace formally used 'GetUserCall()' by new notify/listener mechanism + const SwDrawContact* pContact = static_cast< const SwDrawContact* >(findConnectionToSdrObject(captionedObject)); + + ASSERT( RES_DRAWFRMFMT == pContact->GetFmt()->Which(), + "fail" ); + if( !pContact ) + return 0; + + SwDrawFrmFmt *pCaptionedFmt = (SwDrawFrmFmt *)pContact->GetFmt(); + if( !pCaptionedFmt ) + return 0; + + SwFlyFrm* pFrm = NULL; + if (pCaptionedFmt->HasCaption()) + { + const SwFrmFmt *pCaptionFrmFmt = pCaptionedFmt->GetCaptionFmt(); + SwClientIter aIter (*(SwModify*)pCaptionFrmFmt); + pFrm = dynamic_cast< SwFlyFrm* >(aIter.SwClientIter_First()); + } + if (!pFrm) + return 0; + //SwFrmFmt* pFrm = pCaptionedFmt->GetCaptionFmt(); + uno::Reference < XAccessible > xAcc( GetContext((SwFrm*)pFrm,sal_True) ); + //Reference < XAccessibleShape > xAccShape( xAcc, UNO_QUERY ); + + uno::Reference< XAccessibleContext > xAccContext = xAcc->getAccessibleContext(); + if( xAccContext.is() ) + { //get the parent of caption frame, which is paragaph + uno::Reference< XAccessible > xAccParent = xAccContext->getAccessibleParent(); + if(xAccParent.is()) + { + //get the great parent of caption frame which is text frame. + uno::Reference< XAccessibleContext > xAccParentContext = xAccParent->getAccessibleContext(); + uno::Reference< XAccessible > xAccGreatParent = xAccParentContext->getAccessibleParent(); + if(xAccGreatParent.is()) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.NewValue <<= xAccParent; + ( static_cast< SwAccessibleContext * >(xAccGreatParent.get()) )->FireAccessibleEvent( aEvent ); + + } + + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.NewValue <<= xAcc; + ( static_cast< SwAccessibleContext * >(xAccParent.get()) )->FireAccessibleEvent( aEvent ); + } + } + + if(xAcc.get()) + return xAcc; + else + return NULL; + +} +//-----IAccessibility2 Implementation 2009 Point SwAccessibleMap::PixelToCore( const Point& rPoint ) const { Point aPoint; @@ -2876,3 +3876,10 @@ const SwRect& SwAccessibleMap::GetVisArea() const : GetShell()->VisArea(); } +//IAccessibility2 Implementation 2009----- +sal_Bool SwAccessibleMap::IsDocumentSelAll() +{ + return GetShell()->GetDoc()->IsPrepareSelAll(); +} +//-----IAccessibility2 Implementation 2009 + diff --git a/sw/source/core/access/accnotextframe.cxx b/sw/source/core/access/accnotextframe.cxx index f33498e9e06d..3c330dd17b0b 100644 --- a/sw/source/core/access/accnotextframe.cxx +++ b/sw/source/core/access/accnotextframe.cxx @@ -39,10 +39,20 @@ #include <hints.hxx> // <-- #include "accnotextframe.hxx" +//IAccessibility2 Implementation 2009----- +#include <fmturl.hxx> +#include <accnotexthyperlink.hxx> +#include <svtools/imap.hxx> +#include <unotools/accessiblerelationsethelper.hxx> +#include <com/sun/star/accessibility/AccessibleRelationType.hpp> +#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> +#include <doc.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; +using utl::AccessibleRelationSetHelper; +//-----IAccessibility2 Implementation 2009 const SwNoTxtNode *SwAccessibleNoTextFrame::GetNoTxtNode() const { @@ -52,7 +62,13 @@ const SwNoTxtNode *SwAccessibleNoTextFrame::GetNoTxtNode() const { const SwCntntFrm *pCntFrm = static_cast<const SwCntntFrm *>( pFlyFrm->Lower() ); - pNd = pCntFrm->GetNode()->GetNoTxtNode(); + //IAccessibility2 Implementation 2009----- + const SwCntntNode* pSwCntntNode = pCntFrm->GetNode(); + if(pSwCntntNode != NULL) + { + pNd = pSwCntntNode->GetNoTxtNode(); + } + //-----IAccessibility2 Implementation 2009 } return pNd; @@ -203,6 +219,12 @@ OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void) vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleContext ) + //IAccessibility2 Implementation 2009----- + // OUString longDesc; + // const SwFlyFrmFmt* pFlyFmt = GetShell()->GetDoc()->FindFlyByName( GetName(), 0); + // longDesc = OUString( pFlyFmt->GetLongDescription() ); + // return longDesc; MT: Do not return longDesc, which still is empty - why was the line above commented out? + //-----IAccessibility2 Implementation 2009 return msDesc; } @@ -224,6 +246,15 @@ uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aTyp aAny <<= xImage; return aAny; } + //IAccessibility2 Implementation 2009----- + else if ( aType == ::getCppuType((uno::Reference<XAccessibleHypertext> *)0) ) + { + uno::Reference<XAccessibleHypertext> aAccHypertext = this; + uno::Any aAny; + aAny <<= aAccHypertext; + return aAny; + } + //-----IAccessibility2 Implementation 2009 else return SwAccessibleContext::queryInterface( aType ); } @@ -269,3 +300,137 @@ sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageWidth( ) { return getSize().Width; } +//IAccessibility2 Implementation 2009----- +//===== XAccesibleText ================================================== +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException){return 0;} +sal_Bool SAL_CALL SwAccessibleNoTextFrame::setCaretPosition( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;} +sal_Unicode SAL_CALL SwAccessibleNoTextFrame::getCharacter( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;} +::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL SwAccessibleNoTextFrame::getCharacterAttributes( sal_Int32 , const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + uno::Sequence<beans::PropertyValue> aValues(0); + return aValues; +} +::com::sun::star::awt::Rectangle SAL_CALL SwAccessibleNoTextFrame::getCharacterBounds( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + return com::sun::star::awt::Rectangle(0, 0, 0, 0 ); +} +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException){return 0;} +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getIndexAtPoint( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException){return 0;} +::rtl::OUString SAL_CALL SwAccessibleNoTextFrame::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException){return OUString();} +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException){return 0;} +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException){return 0;} +sal_Bool SAL_CALL SwAccessibleNoTextFrame::setSelection( sal_Int32 , sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return sal_True;} +::rtl::OUString SAL_CALL SwAccessibleNoTextFrame::getText( ) throw (::com::sun::star::uno::RuntimeException){return OUString();} +::rtl::OUString SAL_CALL SwAccessibleNoTextFrame::getTextRange( sal_Int32 , sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return OUString();} +::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextAtIndex( sal_Int32 , sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::accessibility::TextSegment aResult; + return aResult; +} +::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBeforeIndex( sal_Int32, sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::accessibility::TextSegment aResult; + return aResult; +} +::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBehindIndex( sal_Int32 , sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::accessibility::TextSegment aResult; + return aResult; +} + +sal_Bool SAL_CALL SwAccessibleNoTextFrame::copyText( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return sal_True;} + + +// +// XAccessibleHyperText +// +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkCount() +throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + CHECK_FOR_DEFUNC( XAccessibleHypertext ); + + sal_Int32 nCount = 0; + SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() ); + + if(aURL.GetMap() || aURL.GetURL().Len()) + nCount = 1; + + return nCount; +} + +uno::Reference< XAccessibleHyperlink > SAL_CALL + SwAccessibleNoTextFrame::getHyperLink( sal_Int32 nLinkIndex ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + CHECK_FOR_DEFUNC( XAccessibleHypertext ); + + uno::Reference< XAccessibleHyperlink > xRet; + + SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() ); + + if( nLinkIndex > 0 ) + throw lang::IndexOutOfBoundsException(); + + if( aURL.GetMap() || aURL.GetURL().Len() ) + { + if ( !alink.is() ) + { + alink = new SwAccessibleNoTextHyperlink( this, GetFrm() ); + } + + return alink; + } + + return NULL; +} + +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkIndex( sal_Int32 ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + CHECK_FOR_DEFUNC( XAccessibleHypertext ); + + sal_Int32 nRet = 0; + + return nRet; +} + +AccessibleRelation SwAccessibleNoTextFrame::makeRelation( sal_Int16 nType, const SwFlyFrm* pFrm ) +{ + uno::Sequence<uno::Reference<XInterface> > aSequence(1); + aSequence[0] = GetMap()->GetContext( pFrm ); + return AccessibleRelation( nType, aSequence ); +} + + +uno::Reference<XAccessibleRelationSet> SAL_CALL SwAccessibleNoTextFrame::getAccessibleRelationSet( ) + throw ( uno::RuntimeException ) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + CHECK_FOR_DEFUNC( XAccessibleContext ); + + // get the caption frame, and insert label relations into helper + + AccessibleRelationSetHelper* pHelper = new AccessibleRelationSetHelper(); + + SwFlyFrm* pFlyFrm = getFlyFrm(); + DBG_ASSERT( pFlyFrm != NULL, "fly frame expected" ); + + SwFlyFrm* pCaptionFrm = NULL; + const SwFrmFmt* pFrm = pFlyFrm ->GetFmt()->GetCaptionFmt(); + if (pFrm) + { + SwClientIter aIter (*(SwModify*)pFrm); + pCaptionFrm = dynamic_cast< SwFlyFrm* >(aIter.SwClientIter_First()); + } + if(pCaptionFrm!=NULL) + { + pHelper->AddRelation( makeRelation( AccessibleRelationType::DESCRIBED_BY, pCaptionFrm ) ); + } + + return pHelper; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accnotextframe.hxx b/sw/source/core/access/accnotextframe.hxx index ebcb9c282245..6c7725c00af9 100644 --- a/sw/source/core/access/accnotextframe.hxx +++ b/sw/source/core/access/accnotextframe.hxx @@ -24,13 +24,30 @@ #define _ACCNOTEXTFRAME_HXX #include "accframebase.hxx" #include <com/sun/star/accessibility/XAccessibleImage.hpp> +//IAccessibility2 Implementation 2009----- +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEHYPERTEXT_HPP_ +#include <com/sun/star/accessibility/XAccessibleHypertext.hpp> +#endif + +namespace utl { class AccessibleRelationSetHelper; } +namespace com { namespace star { + namespace accessibility { struct AccessibleRelation; } +} } class SwFlyFrm; class SwNoTxtNode; +class SwAccessibleNoTextHyperlink; +//-----IAccessibility2 Implementation 2009 class SwAccessibleNoTextFrame : public SwAccessibleFrameBase, - public ::com::sun::star::accessibility::XAccessibleImage + public ::com::sun::star::accessibility::XAccessibleImage, + public ::com::sun::star::accessibility::XAccessibleHypertext//Added by yangzhh for HyperLink { + //IAccessibility2 Implementation 2009----- + friend class SwAccessibleNoTextHyperlink; + //HyperLinksMap alinksMap; + com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > alink; + //-----IAccessibility2 Implementation 2009 SwDepend aDepend; // --> OD 2009-07-14 #i73249# ::rtl::OUString msTitle; @@ -100,6 +117,51 @@ public: // The object is not visible an longer and should be destroyed virtual void Dispose( sal_Bool bRecursive = sal_False ); + + //IAccessibility2 Implementation 2009----- + virtual sal_Int32 SAL_CALL getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);//Shen Zhen Jie changed sal_Unicode to sal_uInt32 + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getIndexAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSelectedText( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getText( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + + //===== XAccessibleHypertext ============================================ + virtual sal_Int32 SAL_CALL getHyperLinkCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleHyperlink > + SAL_CALL getHyperLink( sal_Int32 nLinkIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getHyperLinkIndex( sal_Int32 nCharIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + SwAccessibleMap *GetAccessibleMap(){ return GetMap();} + +private: + com::sun::star::accessibility::AccessibleRelation makeRelation( + sal_Int16 nType, const SwFlyFrm* pFrm ); + +public: + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL + getAccessibleRelationSet (void) + throw (::com::sun::star::uno::RuntimeException); + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/accnotexthyperlink.cxx b/sw/source/core/access/accnotexthyperlink.cxx new file mode 100644 index 000000000000..4101ea51adc6 --- /dev/null +++ b/sw/source/core/access/accnotexthyperlink.cxx @@ -0,0 +1,232 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include <comphelper/accessiblekeybindinghelper.hxx> +#include <swurl.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <ndtxt.hxx> +#include <txtinet.hxx> +#include <frmfmt.hxx> + +#include <accnotexthyperlink.hxx> + +#include <fmturl.hxx> + +#include <svtools/imap.hxx> +#include <svtools/imapobj.hxx> + +#include <accmap.hxx> +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::accessibility; +//using namespace ::rtl; + +SwAccessibleNoTextHyperlink::SwAccessibleNoTextHyperlink( SwAccessibleNoTextFrame *p, const SwFrm *aFrm, sal_uInt16 nIndex) : + xFrame( p ), + mpFrm( aFrm ), + mnIndex(nIndex) +{ +} + +// XAccessibleAction +sal_Int32 SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionCount() + throw (RuntimeException) +{ + SwFmtURL aURL( GetFmt()->GetURL() ); + ImageMap* pMap = aURL.GetMap(); + if( pMap != NULL ) + { + return pMap->GetIMapObjectCount(); + }else if( aURL.GetURL().Len() ) + { + return 1; + } + + return 0; +} + +sal_Bool SAL_CALL SwAccessibleNoTextHyperlink::doAccessibleAction( sal_Int32 nIndex ) + throw (IndexOutOfBoundsException, RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + if(nIndex < 0 || nIndex >= getAccessibleActionCount()) + throw new IndexOutOfBoundsException; + + sal_Bool bRet = sal_False; + SwFmtURL aURL( GetFmt()->GetURL() ); + ImageMap* pMap = aURL.GetMap(); + if( pMap != NULL ) + { + IMapObject* pMapObj = pMap->GetIMapObject(nIndex); + if(pMapObj->GetURL().Len()) + { + ViewShell *pVSh = xFrame->GetShell(); + if( pVSh ) + { + LoadURL( pMapObj->GetURL(), pVSh, URLLOAD_NOFILTER, + &pMapObj->GetTarget() ); + bRet = sal_True; + } + } + } + else if( aURL.GetURL().Len() ) + { + ViewShell *pVSh = xFrame->GetShell(); + if( pVSh ) + { + LoadURL( aURL.GetURL(), pVSh, URLLOAD_NOFILTER, + &aURL.GetTargetFrameName() ); + bRet = sal_True; + } + } + + return bRet; +} + +rtl::OUString SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionDescription( + sal_Int32 nIndex ) + throw (IndexOutOfBoundsException, RuntimeException) +{ + rtl::OUString sDesc; + + if(nIndex < 0 || nIndex >= getAccessibleActionCount()) + throw new IndexOutOfBoundsException; + + SwFmtURL aURL( GetFmt()->GetURL() ); + ImageMap* pMap = aURL.GetMap(); + if( pMap != NULL ) + { + IMapObject* pMapObj = pMap->GetIMapObject(nIndex); + if(pMapObj->GetDesc().Len()) + sDesc = rtl::OUString( pMapObj->GetDesc() ); + else if(pMapObj->GetURL().Len()) + sDesc = rtl::OUString( pMapObj->GetURL() ); + } + else if( aURL.GetURL().Len() ) + sDesc = rtl::OUString( aURL.GetName() ); + //sDesc = rtl::OUString( aURL.GetName() ); + + return sDesc; +} + +Reference< XAccessibleKeyBinding > SAL_CALL + SwAccessibleNoTextHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) + throw (IndexOutOfBoundsException, RuntimeException) +{ + Reference< XAccessibleKeyBinding > xKeyBinding; + + if(nIndex < 0 || nIndex >= getAccessibleActionCount()) + throw new IndexOutOfBoundsException; + + bool bIsValid = sal_False; + SwFmtURL aURL( GetFmt()->GetURL() ); + ImageMap* pMap = aURL.GetMap(); + if( pMap != NULL ) + { + IMapObject* pMapObj = pMap->GetIMapObject(nIndex); + if(pMapObj->GetURL().Len()) + bIsValid = sal_True; + }else if( aURL.GetURL().Len() ) + bIsValid = sal_True; + + if(bIsValid) + { + ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = + new ::comphelper::OAccessibleKeyBindingHelper(); + xKeyBinding = pKeyBindingHelper; + + ::com::sun::star::awt::KeyStroke aKeyStroke; + aKeyStroke.Modifiers = 0; + aKeyStroke.KeyCode = KEY_RETURN; + aKeyStroke.KeyChar = 0; + aKeyStroke.KeyFunc = 0; + pKeyBindingHelper->AddKeyBinding( aKeyStroke ); + } + + return xKeyBinding; +} + +// XAccessibleHyperlink +Any SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionAnchor( + sal_Int32 nIndex ) + throw (IndexOutOfBoundsException, RuntimeException) +{ + if(nIndex < 0 || nIndex >= getAccessibleActionCount()) + throw new IndexOutOfBoundsException; + + Any aRet; + //SwFrm* pAnchor = ((SwFlyFrm*)mpFrm)->GetAnchor(); + Reference< XAccessible > xAnchor = xFrame->GetAccessibleMap()->GetContext(mpFrm, sal_True); + //SwAccessibleNoTextFrame* pFrame = xFrame.get(); + //Reference< XAccessible > xAnchor = (XAccessible*)pFrame; + aRet <<= xAnchor; + return aRet; +} + +Any SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionObject( + sal_Int32 nIndex ) + throw (IndexOutOfBoundsException, RuntimeException) +{ + if(nIndex < 0 || nIndex >= getAccessibleActionCount()) + throw new IndexOutOfBoundsException; + + SwFmtURL aURL( GetFmt()->GetURL() ); + ::rtl::OUString retText; + ImageMap* pMap = aURL.GetMap(); + if( pMap != NULL ) + { + IMapObject* pMapObj = pMap->GetIMapObject(nIndex); + if(pMapObj->GetURL().Len()) + retText = rtl::OUString( pMapObj->GetURL() ); + }else if( aURL.GetURL().Len() ) + retText = rtl::OUString( aURL.GetURL() ); + + Any aRet; + aRet <<= retText; + return aRet; +} + +sal_Int32 SAL_CALL SwAccessibleNoTextHyperlink::getStartIndex() + throw (RuntimeException) +{ + return 0; +} + +sal_Int32 SAL_CALL SwAccessibleNoTextHyperlink::getEndIndex() + throw (RuntimeException) +{ + return 0; +} + +sal_Bool SAL_CALL SwAccessibleNoTextHyperlink::isValid( ) + throw (::com::sun::star::uno::RuntimeException) +{ + SwFmtURL aURL( GetFmt()->GetURL() ); + + if( aURL.GetMap() || aURL.GetURL().Len() ) + return sal_True; + return sal_False; +} diff --git a/sw/source/core/access/accnotexthyperlink.hxx b/sw/source/core/access/accnotexthyperlink.hxx new file mode 100644 index 000000000000..29de85d79462 --- /dev/null +++ b/sw/source/core/access/accnotexthyperlink.hxx @@ -0,0 +1,93 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +#ifndef _ACCNOTEXTHYPERLINK_HXX +#define _ACCNOTEXTHYPERLINK_HXX + + +#include <com/sun/star/accessibility/XAccessibleHyperlink.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <vos/ref.hxx> +#include <cppuhelper/implbase1.hxx> +#include <fmtinfmt.hxx> +#include <frame.hxx> +#include <layfrm.hxx> + +#include "accnotextframe.hxx" +/* +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::accessibility; +using namespace ::rtl; +*/ +class SwAccessibleNoTextHyperlink : + public ::cppu::WeakImplHelper1< + ::com::sun::star::accessibility::XAccessibleHyperlink > +{ + friend class SwAccessibleNoTextFrame; + + ::vos::ORef< SwAccessibleNoTextFrame > xFrame; + const SwFrm *mpFrm; + sal_uInt16 mnIndex; + + SwFrmFmt *GetFmt() + { + return ((SwLayoutFrm*)mpFrm)->GetFmt(); + } +public: + + SwAccessibleNoTextHyperlink( SwAccessibleNoTextFrame *p, const SwFrm* aFrm, sal_uInt16 nIndex = 0xFFFF ); + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription( + sal_Int32 nIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL + getAccessibleActionKeyBinding( sal_Int32 nIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + // XAccessibleHyperlink + virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionAnchor( + sal_Int32 nIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionObject( + sal_Int32 nIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getStartIndex() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getEndIndex() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isValid( ) + throw (::com::sun::star::uno::RuntimeException); +}; + +#endif + diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index e5c0c8b68099..8c84b6578265 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -56,6 +56,15 @@ #include <sfx2/dispatch.hxx> // for ExecuteAtViewShell(...) #include <unotools/charclass.hxx> // for GetWordBoundary // for get/setCharacterAttribute(...) + +#include <reffld.hxx> +#include <docufld.hxx> +#include <expfld.hxx> +#include <flddat.hxx> +#include <fldui.hrc> +#include "../../ui/inc/fldmgr.hxx" +#include "fldbas.hxx" // SwField +#include <svl/svstdarr.hxx> #include <unocrsr.hxx> //#include <unoobj.hxx> #include <unoport.hxx> @@ -66,7 +75,31 @@ #include <acchypertextdata.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> +//IAccessibility2 Implementation 2009----- +#include <section.hxx> +#include <doctxm.hxx> #include <comphelper/accessibletexthelper.hxx> +#include <algorithm> +#include <docufld.hxx> +#include <txtfld.hxx> +#include <fmtfld.hxx> +#include <modcfg.hxx> +//#include "accnote.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> +#include "swmodule.hxx" +#include "redline.hxx" +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontStrikeout.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <wrong.hxx> +#include <editeng/brshitem.hxx> +#include <swatrset.hxx> +#include <frmatr.hxx> +#include <unosett.hxx> +#include <paratr.hxx> +#include <com/sun/star/container/XIndexReplace.hpp> +//-----IAccessibility2 Implementation 2009 +// --> OD 2006-07-12 #i63870# #include <unomap.hxx> #include <unoprnms.hxx> #include <com/sun/star/text/WritingMode2.hpp> @@ -86,6 +119,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; +using namespace ::com::sun::star::container; +using ::rtl::OUString; using beans::PropertyValue; using beans::XMultiPropertySet; @@ -148,6 +183,19 @@ sal_Int32 SwAccessibleParagraph::GetCaretPos() // same node? Then check whether it's also within 'our' part // of the paragraph sal_uInt16 nIndex = pPoint->nContent.GetIndex(); + //IAccessibility2 Implementation 2009----- + if(!GetPortionData().IsValidCorePosition( nIndex ) || + ( GetPortionData().IsZeroCorePositionData() && nIndex== 0) ) + { + const SwTxtFrm *pTxtFrm = dynamic_cast< const SwTxtFrm* >(GetFrm()); + bool bFormat = (pTxtFrm && pTxtFrm->HasPara()); + if(bFormat) + { + ClearPortionData(); + UpdatePortionData(); + } + } + //-----IAccessibility2 Implementation 2009 if( GetPortionData().IsValidCorePosition( nIndex ) ) { // Yes, it's us! @@ -391,6 +439,20 @@ void SwAccessibleParagraph::_InvalidateContent( sal_Bool bVisibleDataFired ) aEvent.OldValue, aEvent.NewValue ); FireAccessibleEvent( aEvent ); + //IAccessibility2 Implementation 2009----- + uno::Reference< XAccessible > xparent = getAccessibleParent(); + uno::Reference< XAccessibleContext > xAccContext(xparent,uno::UNO_QUERY); + if (xAccContext.is() && xAccContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) + { + SwAccessibleContext* pPara = static_cast< SwAccessibleContext* >(xparent.get()); + if(pPara) + { + AccessibleEventObject aParaEvent; + aParaEvent.EventId = AccessibleEventId::VALUE_CHANGED; + pPara->FireAccessibleEvent(aParaEvent); + } + } + //-----IAccessibility2 Implementation 2009 } else if( !bVisibleDataFired ) { @@ -398,6 +460,10 @@ void SwAccessibleParagraph::_InvalidateContent( sal_Bool bVisibleDataFired ) } sal_Bool bNewIsHeading = IsHeading(); + //IAccessibility2 Implementation 2009----- + //Get the real heading level, Heading1 ~ Heading10 + nHeadingLevel = GetRealHeadingLevel(); + //-----IAccessibility2 Implementation 2009 sal_Bool bOldIsHeading; { vos::OGuard aGuard( aMutex ); @@ -466,6 +532,20 @@ void SwAccessibleParagraph::_InvalidateCursorPos() if( pWin && pWin->HasFocus() && -1 == nNew ) FireStateChangedEvent( AccessibleStateType::FOCUSED, sal_False ); + //IAccessibility2 Implementation 2009----- + //To send TEXT_SELECTION_CHANGED event + sal_Int32 nStart=0; + sal_Int32 nEnd =0; + sal_Bool bCurSelection=GetSelection(nStart,nEnd); + if(m_bLastHasSelection || bCurSelection ) + { + aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED; + aEvent.OldValue <<= uno::Any(); + aEvent.NewValue <<= uno::Any(); + FireAccessibleEvent(aEvent); + } + m_bLastHasSelection =bCurSelection; + //-----IAccessibility2 Implementation 2009 } } @@ -498,20 +578,35 @@ SwAccessibleParagraph::SwAccessibleParagraph( , pHyperTextData( NULL ) , nOldCaretPos( -1 ) , bIsHeading( sal_False ) + //IAccessibility2 Implementation 2009----- + //Get the real heading level, Heading1 ~ Heading10 + , nHeadingLevel (-1) + //-----IAccessibility2 Implementation 2009 , aSelectionHelper( *this ) // --> OD 2010-02-19 #i108125# , mpParaChangeTrackInfo( new SwParaChangeTrackingInfo( rTxtFrm ) ) // <-- + //IAccessibility2 Implementation 2009----- + , m_bLastHasSelection(false) //To add TEXT_SELECTION_CHANGED event + //-----IAccessibility2 Implementation 2009 { vos::OGuard aGuard(Application::GetSolarMutex()); bIsHeading = IsHeading(); + //IAccessibility2 Implementation 2009----- + //Get the real heading level, Heading1 ~ Heading10 + nHeadingLevel = GetRealHeadingLevel(); + //-----IAccessibility2 Implementation 2009 // --> OD 2004-09-27 #117970# - set an empty accessibility name for paragraphs SetName( ::rtl::OUString() ); // <-- // If this object has the focus, then it is remembered by the map itself. - nOldCaretPos = GetCaretPos(); + //IAccessibility2 Implementation 2009----- + // not necessary to remember this pos here. Generally, the pos will be updated in invalidateXXX method, which may fire the + //Focus event based on the difference of new & old caret pos. + //nOldCaretPos = GetCaretPos(); + //-----IAccessibility2 Implementation 2009 } SwAccessibleParagraph::~SwAccessibleParagraph() @@ -635,7 +730,76 @@ sal_Bool SwAccessibleParagraph::IsValidRange( { return IsValidPosition(nBegin, nLength) && IsValidPosition(nEnd, nLength); } +//IAccessibility2 Implementation 2009----- +SwTOXSortTabBase* SwAccessibleParagraph::GetTOXSortTabBase() +{ + const SwTxtNode* pTxtNd = GetTxtNode(); + if( pTxtNd ) + { + const SwSectionNode * pSectNd = pTxtNd->FindSectionNode(); + if( pSectNd ) + { + const SwSection * pSect = &pSectNd->GetSection(); + SwTOXBaseSection *pTOXBaseSect = (SwTOXBaseSection *)pSect; + if( pSect->GetType() == TOX_CONTENT_SECTION ) + { + SwTOXSortTabBase* pSortBase = 0; + int nSize = pTOXBaseSect->GetTOXSortTabBases()->Count(); + + for(int nIndex = 0; nIndex<nSize; nIndex++ ) + { + pSortBase = (*(pTOXBaseSect->GetTOXSortTabBases()))[nIndex]; + if( pSortBase->pTOXNd == pTxtNd ) + break; + } + + if (pSortBase) + { + return pSortBase; + } + } + } + } + return NULL; +} + +short SwAccessibleParagraph::GetTOCLevel() +{ + SwTOXSortTabBase* pToxBase = GetTOXSortTabBase(); + if( pToxBase ) + { + const SwCntntNode* pNd = pToxBase->aTOXSources[0].pNd; + if( pNd ) + return pToxBase->GetLevel(); + else + return -1; + } + else + return -1; +} +//the function is to check whether the position is in a redline range. +const SwRedline* SwAccessibleParagraph::GetRedlineAtIndex( sal_Int32 ) +{ + const SwRedline* pRedline = NULL; + SwPaM* pCrSr = GetCursor( true ); + if ( pCrSr ) + { + SwPosition* pStart = pCrSr->Start(); + const SwTxtNode* pNode = GetTxtNode(); + if ( pNode ) + { + const SwDoc* pDoc = pNode->GetDoc(); + if ( pDoc ) + { + pRedline = pDoc->GetRedline( *pStart, NULL ); + } + } + } + + return pRedline; +} +//-----IAccessibility2 Implementation 2009 // // text boundaries @@ -647,6 +811,11 @@ sal_Bool SwAccessibleParagraph::GetCharBoundary( const ::rtl::OUString&, sal_Int32 nPos ) { + //IAccessibility2 Implementation 2009----- + if( GetPortionData().FillBoundaryIFDateField( rBound, nPos) ) + return sal_True; + //-----IAccessibility2 Implementation 2009 + rBound.startPos = nPos; rBound.endPos = nPos+1; return sal_True; @@ -673,6 +842,46 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( // (DICTIONARY_WORD includes punctuation, ANY_WORD doesn't.) const sal_uInt16 nWordType = i18n::WordType::ANY_WORD; +/* + // get word boundary, as the Break-Iterator sees fit. + sal_Unicode SpaceChar(' '); + if (rText.getCodePointAt(nPos) == SpaceChar) + { + int nStartPos = nPos; + int nEndPos = nPos+1; + while (nStartPos >= 0 && rText.getCodePointAt(nStartPos) == SpaceChar) + --nStartPos; + while (nEndPos < rText.getLength() && rText.getCodePointAt(nEndPos) == SpaceChar) + ++nEndPos; + //Get the previous word boundary + the followed space characters + if (nStartPos >= 0) + { + rBound = pBreakIt->xBreak->getWordBoundary( rText, nStartPos, aLocale, nWordType, sal_True ); + rBound.endPos += (nEndPos-nStartPos - 1); + } + //When the frontal characters are whitespace, return the all space characters directly. + else + { + rBound.startPos = 0; + rBound.endPos = nEndPos; + } + } + // add the " " into the word boundry + else + { + rBound = pBreakIt->xBreak->getWordBoundary(rText, nPos, aLocale, nWordType, sal_True ); + sal_Int32 nEndPos = rBound.endPos, nLength = rText.getLength(); + while ( nEndPos < nLength && rText.getCodePointAt(nEndPos) == SpaceChar ) + nEndPos++; + rBound.endPos = nEndPos; + } + //IAccessibility2 Implementation 2009----- + tabCharInWord( nPos, rBound); + if( GetPortionData().FillBoundaryIFDateField( rBound, rBound.startPos) ) + return sal_True; + //-----IAccessibility2 Implementation 2009 + return sal_True; // MT: So why do we need the return TRUE above??? +*/ // get word boundary, as the Break-Iterator sees fit. rBound = pBreakIt->GetBreakIter()->getWordBoundary( rText, nPos, aLocale, nWordType, sal_True ); @@ -693,9 +902,17 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( sal_Bool SwAccessibleParagraph::GetSentenceBoundary( i18n::Boundary& rBound, - const ::rtl::OUString&, + const ::rtl::OUString& rText, sal_Int32 nPos ) { + //IAccessibility2 Implementation 2009----- + const sal_Unicode* pStr = rText.getStr(); + if (pStr) + { + while( pStr[nPos] == sal_Unicode(' ') && nPos < rText.getLength()) + nPos++; + } + //-----IAccessibility2 Implementation 2009 GetPortionData().GetSentenceBoundary( rBound, nPos ); return sal_True; } @@ -809,11 +1026,80 @@ sal_Bool SwAccessibleParagraph::GetTextBoundary( break; case AccessibleTextType::LINE: - bRet = GetLineBoundary( rBound, rText, nPos ); + //IAccessibility2 Implementation 2009----- + //Solve the problem of returning wrong LINE and PARAGRAPH + if((nPos == rText.getLength()) && nPos > 0) + bRet = GetLineBoundary( rBound, rText, nPos - 1); + else + bRet = GetLineBoundary( rBound, rText, nPos ); + //-----IAccessibility2 Implementation 2009 break; case AccessibleTextType::ATTRIBUTE_RUN: bRet = GetAttributeBoundary( rBound, rText, nPos ); + //IAccessibility2 Implementation 2009----- + if(bRet) + { + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL && pCrsrShell->GetViewOptions() && pCrsrShell->GetViewOptions()->IsOnlineSpell()) + { + SwTxtNode* pTxtNode = const_cast<SwTxtNode*>( GetTxtNode() ); + if(pTxtNode) + { + const SwWrongList* pWrongList = pTxtNode->GetWrong(); + if( NULL != pWrongList ) + { + xub_StrLen nBegin = nPos; + xub_StrLen nLen = 1; + const xub_StrLen nNext = pWrongList->NextWrong(nBegin); + xub_StrLen nLast; + xub_StrLen nWrongPos = pWrongList->GetWrongPos( nBegin ); + if ( nWrongPos >= pWrongList->Count() || + ( nLast = pWrongList->Pos( nWrongPos ) ) >= nBegin ) + { + nLast = nWrongPos + ? pWrongList->Pos( --nWrongPos ) + : STRING_LEN; + } + if ( nBegin > pWrongList->GetBeginInv() && + ( nLast == STRING_LEN || nLast < pWrongList->GetEndInv() ) ) + { + nLast = nBegin > pWrongList->GetEndInv() + ? pWrongList->GetEndInv() + : nBegin; + } + else if ( nLast < STRING_LEN ) + { + nLast += pWrongList->Len( nWrongPos ); + } + // + sal_Bool bIn = pWrongList->InWrongWord(nBegin,nLen); // && !pTxtNode->IsSymbol(nBegin) ) + if(bIn) + { + rBound.startPos = max(nNext,(xub_StrLen)rBound.startPos); + rBound.endPos = min(xub_StrLen(nNext + nLen),(xub_StrLen)rBound.endPos); + } + else + { + if (STRING_LEN == nLast)//first + { + rBound.endPos = min(nNext,(xub_StrLen)rBound.endPos); + } + else if(STRING_LEN == nNext) + { + rBound.startPos = max(nLast,(xub_StrLen)rBound.startPos); + } + else + { + rBound.startPos = max(nLast,(xub_StrLen)rBound.startPos); + rBound.endPos = min(nNext,(xub_StrLen)rBound.endPos); + } + } + } + } + } + } + //-----IAccessibility2 Implementation 2009 break; case AccessibleTextType::GLYPH: @@ -1032,6 +1318,76 @@ uno::Sequence< ::rtl::OUString > SAL_CALL SwAccessibleParagraph::getSupportedSer return aRet; } +//IAccessibility2 Implementation 2009----- +uno::Sequence< ::rtl::OUString > getAttributeNames() +{ + static uno::Sequence< ::rtl::OUString >* pNames = NULL; + + if( pNames == NULL ) + { + // Add the font name to attribute list + uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 13 ); + + ::rtl::OUString* pStrings = pSeq->getArray(); + + // sorted list of strings + sal_Int32 i = 0; + +#define STR(x) pStrings[i++] = OUString::createFromAscii(x) + STR( GetPropName( UNO_NAME_CHAR_BACK_COLOR ).pName ); + STR( GetPropName( UNO_NAME_CHAR_COLOR ).pName ); + STR( GetPropName( UNO_NAME_CHAR_CONTOURED ).pName ); + STR( GetPropName( UNO_NAME_CHAR_EMPHASIS ).pName ); + STR( GetPropName( UNO_NAME_CHAR_ESCAPEMENT ).pName ); + STR( GetPropName( UNO_NAME_CHAR_FONT_NAME ).pName ); + STR( GetPropName( UNO_NAME_CHAR_HEIGHT ).pName ); + STR( GetPropName( UNO_NAME_CHAR_POSTURE ).pName ); + STR( GetPropName( UNO_NAME_CHAR_SHADOWED ).pName ); + STR( GetPropName( UNO_NAME_CHAR_STRIKEOUT ).pName ); + STR( GetPropName( UNO_NAME_CHAR_UNDERLINE ).pName ); + STR( GetPropName( UNO_NAME_CHAR_UNDERLINE_COLOR ).pName ); + STR( GetPropName( UNO_NAME_CHAR_WEIGHT ).pName ); +#undef STR + DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" ); + if( i != pSeq->getLength() ) + pSeq->realloc( i ); + pNames = pSeq; + } + return *pNames; +} + +uno::Sequence< ::rtl::OUString > getSupplementalAttributeNames() +{ + static uno::Sequence< ::rtl::OUString >* pNames = NULL; + + if( pNames == NULL ) + { + uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 9 ); + + ::rtl::OUString* pStrings = pSeq->getArray(); + + // sorted list of strings + sal_Int32 i = 0; + +#define STR(x) pStrings[i++] = OUString::createFromAscii(x) + STR( GetPropName( UNO_NAME_NUMBERING_LEVEL ).pName ); + STR( GetPropName( UNO_NAME_NUMBERING_RULES ).pName ); + STR( GetPropName( UNO_NAME_PARA_ADJUST ).pName ); + STR( GetPropName( UNO_NAME_PARA_BOTTOM_MARGIN ).pName ); + STR( GetPropName( UNO_NAME_PARA_FIRST_LINE_INDENT ).pName ); + STR( GetPropName( UNO_NAME_PARA_LEFT_MARGIN ).pName ); + STR( GetPropName( UNO_NAME_PARA_LINE_SPACING ).pName ); + STR( GetPropName( UNO_NAME_PARA_RIGHT_MARGIN ).pName ); + STR( GetPropName( UNO_NAME_TABSTOPS ).pName ); +#undef STR + DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" ); + if( i != pSeq->getLength() ) + pSeq->realloc( i ); + pNames = pSeq; + } + return *pNames; +} +//-----IAccessibility2 Implementation 2009 // //===== XInterface ======================================================= // @@ -1082,6 +1438,19 @@ uno::Any SwAccessibleParagraph::queryInterface( const uno::Type& rType ) aRet <<= aAccMultiLineText; } // <-- + //IAccessibility2 Implementation 2009----- + //MSAA Extension Implementation in app module + else if ( rType == ::getCppuType((uno::Reference<XAccessibleTextSelection> *)NULL) ) + { + uno::Reference< com::sun::star::accessibility::XAccessibleTextSelection > aTextExtension = this; + aRet <<= aTextExtension; + } + else if ( rType == ::getCppuType((uno::Reference<XAccessibleExtendedAttributes> *)NULL) ) + { + uno::Reference<XAccessibleExtendedAttributes> xAttr = this; + aRet <<= xAttr; + } + //-----IAccessibility2 Implementation 2009 else { aRet = SwAccessibleContext::queryInterface(rType); @@ -1206,6 +1575,270 @@ sal_Unicode SwAccessibleParagraph::getCharacter( sal_Int32 nIndex ) throw lang::IndexOutOfBoundsException(); } +//IAccessibility2 Implementation 2009----- +com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > SwAccessibleParagraph::GetCurrentTabStop( sal_Int32 nIndex ) +{ +vos::OGuard aGuard(Application::GetSolarMutex()); + CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); + + + + /* #i12332# The position after the string needs special treatment. + IsValidChar -> IsValidPosition + */ + if( ! (IsValidPosition( nIndex, GetString().getLength() ) ) ) + throw lang::IndexOutOfBoundsException(); + + /* #i12332# */ + sal_Bool bBehindText = sal_False; + if ( nIndex == GetString().getLength() ) + bBehindText = sal_True; + + // get model position & prepare GetCharRect() arguments + SwCrsrMoveState aMoveState; + aMoveState.bRealHeight = sal_True; + aMoveState.bRealWidth = sal_True; + SwSpecialPos aSpecialPos; + SwTxtNode* pNode = const_cast<SwTxtNode*>( GetTxtNode() ); + + sal_uInt16 nPos = 0; + + /* #i12332# FillSpecialPos does not accept nIndex == + GetString().getLength(). In that case nPos is set to the + length of the string in the core. This way GetCharRect + returns the rectangle for a cursor at the end of the + paragraph. */ + if (bBehindText) + { + nPos = pNode->GetTxt().Len(); + } + else + nPos = GetPortionData().FillSpecialPos + (nIndex, aSpecialPos, aMoveState.pSpecialPos ); + + // call GetCharRect + SwRect aCoreRect; + SwIndex aIndex( pNode, nPos ); + SwPosition aPosition( *pNode, aIndex ); + GetFrm()->GetCharRect( aCoreRect, aPosition, &aMoveState ); + + // already get the caret postion + + //IAccessibility2 Implementation 2009----- + /*SwFrm* pTFrm = const_cast<SwFrm*>(GetFrm()); + com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > tabs = + pTFrm->GetTabStopInfo(aCoreRect.Left());*/ + + com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > tabs; + const xub_StrLen nStrLen = GetTxtNode()->GetTxt().Len(); + if( nStrLen > 0 ) + { + SwFrm* pTFrm = const_cast<SwFrm*>(GetFrm()); + tabs = pTFrm->GetTabStopInfo(aCoreRect.Left()); + } + //-----IAccessibility2 Implementation 2009 + + if( tabs.hasElements() ) + { + // translate core coordinates into accessibility coordinates + Window *pWin = GetWindow(); + CHECK_FOR_WINDOW( XAccessibleComponent, pWin ); + + SwRect aTmpRect(0, 0, tabs[0].Position, 0); + + Rectangle aScreenRect( GetMap()->CoreToPixel( aTmpRect.SVRect() )); + SwRect aFrmLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root + + Point aFrmPixPos( GetMap()->CoreToPixel( aFrmLogBounds.SVRect() ).TopLeft() ); + aScreenRect.Move( -aFrmPixPos.X(), -aFrmPixPos.Y() ); + + tabs[0].Position = aScreenRect.GetWidth(); + } + + return tabs; +} + +struct IndexCompare +{ + const PropertyValue* pValues; + IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {} + bool operator() ( const sal_Int32& a, const sal_Int32& b ) const + { + return (pValues[a].Name < pValues[b].Name) ? true : false; + } +}; +//-----IAccessibility2 Implementation 2009 + +String SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) +{ + String strTypeName; + SwFldMgr aMgr; + SwTxtFld* pTxtFld = NULL; + SwTxtNode* pTxtNd = const_cast<SwTxtNode*>( GetTxtNode() ); + SwIndex fldIndex( pTxtNd, nIndex ); + sal_Int32 nFldIndex = GetPortionData().GetFieldIndex(nIndex); + if (nFldIndex >= 0) + { + const SwpHints* pSwpHints = GetTxtNode()->GetpSwpHints(); + if (pSwpHints) + { + const sal_uInt16 nSize = pSwpHints ? pSwpHints->Count() : 0; + for( sal_uInt16 i = 0; i < nSize; ++i ) + { + const SwTxtAttr* pHt = (*pSwpHints)[i]; + if (pHt->Which() == RES_TXTATR_FIELD && (nFldIndex-- == 0)) + { + pTxtFld = (SwTxtFld *)pHt; + break; + } + else if (pHt->Which() == RES_TXTATR_REFMARK && (nFldIndex-- == 0)) + strTypeName = String(OUString(RTL_CONSTASCII_USTRINGPARAM("set reference"))); + } + } + } + if (pTxtFld) + { + const SwField* pField = (pTxtFld->GetFmtFld()).GetField(); + if (pField) + { + strTypeName = pField->GetTyp()->GetTypeStr(pField->GetTypeId()); + sal_uInt16 nWhich = pField->GetTyp()->Which(); + rtl::OUString sEntry; + sal_Int32 subType = 0; + switch (nWhich) + { + case RES_DOCSTATFLD: + subType = ((SwDocStatField*)pField)->GetSubType(); + break; + case RES_GETREFFLD: + { + sal_uInt16 nSub = pField->GetSubType(); + switch( nSub ) + { + case REF_BOOKMARK: + { + const SwGetRefField* pRefFld = dynamic_cast<const SwGetRefField*>(pField); + if ( pRefFld && pRefFld->IsRefToHeadingCrossRefBookmark() ) + sEntry = OUString(RTL_CONSTASCII_USTRINGPARAM("Headings")); + else if ( pRefFld && pRefFld->IsRefToNumItemCrossRefBookmark() ) + sEntry = OUString(RTL_CONSTASCII_USTRINGPARAM("Numbered Paragraphs")); + else + sEntry = OUString(RTL_CONSTASCII_USTRINGPARAM("Bookmarks")); + } + break; + case REF_FOOTNOTE: + sEntry = OUString(RTL_CONSTASCII_USTRINGPARAM("Footnotes")); + break; + case REF_ENDNOTE: + sEntry = OUString(RTL_CONSTASCII_USTRINGPARAM("Endnotes")); + break; + case REF_SETREFATTR: + sEntry = OUString(RTL_CONSTASCII_USTRINGPARAM("Insert Reference")); + break; + case REF_SEQUENCEFLD: + sEntry = ((SwGetRefField*)pField)->GetSetRefName(); + break; + } + //Get format string + strTypeName = sEntry; + // <pField->GetFormat() >= 0> is always true as <pField->GetFormat()> is unsigned +// if (pField->GetFormat() >= 0) + { + sEntry = aMgr.GetFormatStr( pField->GetTypeId(), pField->GetFormat() ); + if (sEntry.getLength() > 0) + { + strTypeName.AppendAscii("-"); + strTypeName += String(sEntry); + } + } + } + break; + case RES_DATETIMEFLD: + subType = ((SwDateTimeField*)pField)->GetSubType(); + break; + case RES_JUMPEDITFLD: + { + sal_uInt16 nFormat= pField->GetFormat(); + sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), sal_False); + if (nFormat < nSize) + { + sEntry = aMgr.GetFormatStr(pField->GetTypeId(), nFormat); + if (sEntry.getLength() > 0) + { + strTypeName.AppendAscii("-"); + strTypeName += String(sEntry); + } + } + } + break; + case RES_EXTUSERFLD: + subType = ((SwExtUserField*)pField)->GetSubType(); + break; + case RES_HIDDENTXTFLD: + case RES_SETEXPFLD: + { + sEntry = pField->GetTyp()->GetName(); + if (sEntry.getLength() > 0) + { + strTypeName.AppendAscii("-"); + strTypeName += String(sEntry); + } + } + break; + case RES_DOCINFOFLD: + subType = pField->GetSubType(); + subType &= 0x00ff; + break; + case RES_REFPAGESETFLD: + { + SwRefPageSetField* pRPld = (SwRefPageSetField*)pField; + sal_Bool bOn = pRPld->IsOn(); + strTypeName.AppendAscii("-"); + if (bOn) + strTypeName += String(OUString(RTL_CONSTASCII_USTRINGPARAM("on"))); + else + strTypeName += String(OUString(RTL_CONSTASCII_USTRINGPARAM("off"))); + } + break; + case RES_AUTHORFLD: + { + strTypeName.AppendAscii("-"); + strTypeName += aMgr.GetFormatStr(pField->GetTypeId(), pField->GetFormat() & 0xff); + } + break; + } + if (subType > 0 || (subType == 0 && (nWhich == RES_DOCINFOFLD || nWhich == RES_EXTUSERFLD || nWhich == RES_DOCSTATFLD))) + { + SvStringsDtor aLst; + aMgr.GetSubTypes(pField->GetTypeId(), aLst); + if (subType < aLst.Count()) + sEntry = *aLst[subType]; + if (sEntry.getLength() > 0) + { + if (nWhich == RES_DOCINFOFLD) + { + strTypeName = String(sEntry); + sal_uInt32 nSize = aMgr.GetFormatCount(pField->GetTypeId(), sal_False); + sal_uInt16 nExSub = pField->GetSubType() & 0xff00; + if (nSize > 0 && nExSub > 0) + { + //Get extra subtype string + strTypeName.AppendAscii("-"); + sEntry = aMgr.GetFormatStr(pField->GetTypeId(), nExSub/0x0100-1); + strTypeName += String(sEntry); + } + } + else + { + strTypeName.AppendAscii("-"); + strTypeName += String(sEntry); + } + } + } + } + } + return strTypeName; +} // --> OD 2006-07-20 #i63870# // re-implement method on behalf of methods <_getDefaultAttributesImpl(..)> and // <_getRunAttributesImpl(..)> @@ -1220,16 +1853,24 @@ uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( const ::rtl::OUString& rText = GetString(); - if( ! IsValidChar( nIndex, rText.getLength() ) ) + if( ! IsValidChar( nIndex, rText.getLength()+1 ) )//IAccessibility2 Implementation 2009 throw lang::IndexOutOfBoundsException(); + //IAccessibility2 Implementation 2009----- + bool bSupplementalMode = false; + uno::Sequence< ::rtl::OUString > aNames = aRequestedAttributes; + if (aNames.getLength() == 0) + { + bSupplementalMode = true; + aNames = getAttributeNames(); + } // retrieve default character attributes tAccParaPropValMap aDefAttrSeq; - _getDefaultAttributesImpl( aRequestedAttributes, aDefAttrSeq, true ); + _getDefaultAttributesImpl( aNames, aDefAttrSeq, true ); // retrieved run character attributes tAccParaPropValMap aRunAttrSeq; - _getRunAttributesImpl( nIndex, aRequestedAttributes, aRunAttrSeq ); + _getRunAttributesImpl( nIndex, aNames, aRunAttrSeq ); // merge default and run attributes uno::Sequence< PropertyValue > aValues( aDefAttrSeq.size() ); @@ -1251,6 +1892,70 @@ uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( } ++i; } + if( bSupplementalMode ) + { + uno::Sequence< ::rtl::OUString > aSupplementalNames = aRequestedAttributes; + if (aSupplementalNames.getLength() == 0) + aSupplementalNames = getSupplementalAttributeNames(); + + tAccParaPropValMap aSupplementalAttrSeq; + _getSupplementalAttributesImpl( nIndex, aSupplementalNames, aSupplementalAttrSeq ); + + aValues.realloc( aValues.getLength() + aSupplementalAttrSeq.size() ); + pValues = aValues.getArray(); + + for ( tAccParaPropValMap::const_iterator aSupplementalIter = aSupplementalAttrSeq.begin(); + aSupplementalIter != aSupplementalAttrSeq.end(); + ++aSupplementalIter ) + { + pValues[i] = aSupplementalIter->second; + ++i; + } + + _correctValues( nIndex, aValues ); + + aValues.realloc( aValues.getLength() + 1 ); + + pValues = aValues.getArray(); + + const SwTxtNode* pTxtNode( GetTxtNode() ); + PropertyValue& rValue = pValues[aValues.getLength() - 1 ]; + rValue.Name = OUString::createFromAscii("NumberingPrefix"); + OUString sNumBullet = pTxtNode->GetNumString(); + rValue.Value <<= sNumBullet; + rValue.Handle = -1; + rValue.State = PropertyState_DIRECT_VALUE; + + String strTypeName = GetFieldTypeNameAtIndex(nIndex); + if (strTypeName.Len() > 0) + { + aValues.realloc( aValues.getLength() + 1 ); + pValues = aValues.getArray(); + rValue = pValues[aValues.getLength() - 1]; + rValue.Name = OUString::createFromAscii("FieldType"); + rValue.Value <<= rtl::OUString(strTypeName.ToLowerAscii()); + rValue.Handle = -1; + rValue.State = PropertyState_DIRECT_VALUE; + } + + //sort property values + // build sorted index array + sal_Int32 nLength = aValues.getLength(); + const PropertyValue* pPairs = aValues.getConstArray(); + sal_Int32* pIndices = new sal_Int32[nLength]; + for( i = 0; i < nLength; i++ ) + pIndices[i] = i; + sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); + // create sorted sequences accoring to index array + uno::Sequence<PropertyValue> aNewValues( nLength ); + PropertyValue* pNewValues = aNewValues.getArray(); + for( i = 0; i < nLength; i++ ) + { + pNewValues[i] = pPairs[pIndices[i]]; + } + delete[] pIndices; + return aNewValues; + } // // create a (dummy) text portion for the sole purpose of calling // // getPropertyValues on it @@ -1669,6 +2374,308 @@ uno::Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes( return aValues; } // <-- +// IAccessibility2 Implementation 2009---- +void SwAccessibleParagraph::_getSupplementalAttributesImpl( + const sal_Int32, + const uno::Sequence< ::rtl::OUString >& aRequestedAttributes, + tAccParaPropValMap& rSupplementalAttrSeq ) +{ + const SwTxtNode* pTxtNode( GetTxtNode() ); + ::boost::scoped_ptr<SfxItemSet> pSet; + pSet.reset( new SfxItemSet( const_cast<SwAttrPool&>(pTxtNode->GetDoc()->GetAttrPool()), + RES_PARATR_ADJUST, RES_PARATR_ADJUST, + RES_PARATR_TABSTOP, RES_PARATR_TABSTOP, + RES_PARATR_LINESPACING, RES_PARATR_LINESPACING, + RES_UL_SPACE, RES_UL_SPACE, + RES_LR_SPACE, RES_LR_SPACE, + RES_PARATR_NUMRULE, RES_PARATR_NUMRULE, + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, + 0 ) ); + + if ( pTxtNode->HasBullet() || pTxtNode->HasNumber() ) + { + pSet->Put( pTxtNode->GetAttr(RES_PARATR_LIST_LEVEL, RES_PARATR_LIST_LEVEL) ); + } + pSet->Put( pTxtNode->SwCntntNode::GetAttr(RES_UL_SPACE) ); + pSet->Put( pTxtNode->SwCntntNode::GetAttr(RES_LR_SPACE) ); + pSet->Put( pTxtNode->SwCntntNode::GetAttr(RES_PARATR_ADJUST) ); + + tAccParaPropValMap aSupplementalAttrSeq; + { +// const SfxItemPropertySet& rPropSet = +// aSwMapProvider.GetPropertyMap( PROPERTY_MAP_ACCESSIBILITY_TEXT_ATTRIBUTE ); +// const SfxItemPropertyMap* pPropMap( rPropSet.getPropertyMap() ); + const SfxItemPropertyMapEntry* pPropMap( + aSwMapProvider.GetPropertyMapEntries( PROPERTY_MAP_ACCESSIBILITY_TEXT_ATTRIBUTE ) ); + while ( pPropMap->pName ) + { + const SfxPoolItem* pItem = pSet->GetItem( pPropMap->nWID ); + if ( pItem ) + { + uno::Any aVal; + pItem->QueryValue( aVal, pPropMap->nMemberId ); + + PropertyValue rPropVal; + rPropVal.Name = OUString::createFromAscii( pPropMap->pName ); + rPropVal.Value = aVal; + rPropVal.Handle = -1; + rPropVal.State = beans::PropertyState_DEFAULT_VALUE; + + aSupplementalAttrSeq[rPropVal.Name] = rPropVal; + } + + ++pPropMap; + } + } + + const OUString* pSupplementalAttrs = aRequestedAttributes.getConstArray(); + const sal_Int32 nSupplementalLength = aRequestedAttributes.getLength(); + + for( sal_Int32 index = 0; index < nSupplementalLength; ++index ) + { + tAccParaPropValMap::const_iterator const aIter = aSupplementalAttrSeq.find( pSupplementalAttrs[index] ); + if ( aIter != aSupplementalAttrSeq.end() ) + { + rSupplementalAttrSeq[ aIter->first ] = aIter->second; + } + } +} + +void SwAccessibleParagraph::_correctValues( const sal_Int32 nIndex, + uno::Sequence< PropertyValue >& rValues) +{ + PropertyValue ChangeAttr, ChangeAttrColor; + + const SwRedline* pRedline = GetRedlineAtIndex( nIndex ); + if ( pRedline ) + { + + const SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig(); + AuthorCharAttr aChangeAttr; + if ( pOpt ) + { + switch( pRedline->GetType()) + { + case nsRedlineType_t::REDLINE_INSERT: + aChangeAttr = pOpt->GetInsertAuthorAttr(); + break; + case nsRedlineType_t::REDLINE_DELETE: + aChangeAttr = pOpt->GetDeletedAuthorAttr(); + break; + case nsRedlineType_t::REDLINE_FORMAT: + aChangeAttr = pOpt->GetFormatAuthorAttr(); + break; + } + } + switch( aChangeAttr.nItemId ) + { + case SID_ATTR_CHAR_WEIGHT: + ChangeAttr.Name = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_WEIGHT).pName ); + ChangeAttr.Value <<= awt::FontWeight::BOLD; + break; + case SID_ATTR_CHAR_POSTURE: + ChangeAttr.Name = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_POSTURE).pName ); + ChangeAttr.Value <<= awt::FontSlant_ITALIC; //char posture + break; + case SID_ATTR_CHAR_STRIKEOUT: + ChangeAttr.Name = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_STRIKEOUT).pName ); + ChangeAttr.Value <<= awt::FontStrikeout::SINGLE; //char strikeout + break; + case SID_ATTR_CHAR_UNDERLINE: + ChangeAttr.Name = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_UNDERLINE).pName ); + ChangeAttr.Value <<= aChangeAttr.nAttr; //underline line + break; + } + if( aChangeAttr.nColor != COL_NONE ) + { + if( aChangeAttr.nItemId == SID_ATTR_BRUSH ) + { + ChangeAttrColor.Name = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_BACK_COLOR).pName ); + if( aChangeAttr.nColor == COL_TRANSPARENT )//char backcolor + ChangeAttrColor.Value <<= COL_BLUE; + else + ChangeAttrColor.Value <<= aChangeAttr.nColor; + } + else + { + ChangeAttrColor.Name = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_COLOR ).pName ); + if( aChangeAttr.nColor == COL_TRANSPARENT )//char color + ChangeAttrColor.Value <<= COL_BLUE; + else + ChangeAttrColor.Value <<= aChangeAttr.nColor; + } + } + } + + PropertyValue* pValues = rValues.getArray(); + + const SwTxtNode* pTxtNode( GetTxtNode() ); + + sal_Int32 nValues = rValues.getLength(); + for (sal_Int32 i = 0; i < nValues; ++i) + { + PropertyValue& rValue = pValues[i]; + + if (rValue.Name.compareTo( ChangeAttr.Name )==0) + { + rValue.Value = ChangeAttr.Value; + continue; + } + + if (rValue.Name.compareTo( ChangeAttrColor.Name )==0) + { + rValue.Value = ChangeAttr.Value; + continue; + } + + //back color + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_BACK_COLOR ).pName ) )==0) + { + uno::Any &anyChar = rValue.Value; + sal_uInt32 crBack = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved)); + if (COL_AUTO == crBack) + { + uno::Reference<XAccessibleComponent> xComponent(this); + if (xComponent.is()) + { + crBack = (sal_uInt32)xComponent->getBackground(); + } + rValue.Value <<= crBack; + } + continue; + } + + //char color + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_COLOR ).pName ) )==0) + { + if( GetPortionData().IsInGrayPortion( nIndex ) ) + rValue.Value <<= SwViewOption::GetFieldShadingsColor().GetColor(); + uno::Any &anyChar = rValue.Value; + sal_uInt32 crChar = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved)); + + if( COL_AUTO == crChar ) + { + uno::Reference<XAccessibleComponent> xComponent(this); + if (xComponent.is()) + { + Color cr(xComponent->getBackground()); + crChar = cr.IsDark() ? COL_WHITE : COL_BLACK; + rValue.Value <<= crChar; + } + } + continue; + } + + // UnderLine + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_UNDERLINE ).pName ) )==0) + { + //misspelled word + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL && pCrsrShell->GetViewOptions() && pCrsrShell->GetViewOptions()->IsOnlineSpell()) + { + const SwWrongList* pWrongList = pTxtNode->GetWrong(); + if( NULL != pWrongList ) + { + xub_StrLen nBegin = nIndex; + xub_StrLen nLen = 1; + if( pWrongList->InWrongWord(nBegin,nLen) && !pTxtNode->IsSymbol(nBegin) ) + { + rValue.Value <<= (sal_uInt16)UNDERLINE_WAVE; + } + } + } + continue; + } + + // UnderLineColor + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_UNDERLINE_COLOR ).pName ) )==0) + { + //misspelled word + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL && pCrsrShell->GetViewOptions() && pCrsrShell->GetViewOptions()->IsOnlineSpell()) + { + const SwWrongList* pWrongList = pTxtNode->GetWrong(); + if( NULL != pWrongList ) + { + xub_StrLen nBegin = nIndex; + xub_StrLen nLen = 1; + if( pWrongList->InWrongWord(nBegin,nLen) && !pTxtNode->IsSymbol(nBegin) ) + { + rValue.Value <<= (sal_Int32)0x00ff0000; + continue; + } + } + } + + uno::Any &anyChar = rValue.Value; + sal_uInt32 crUnderline = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved)); + if ( COL_AUTO == crUnderline ) + { + uno::Reference<XAccessibleComponent> xComponent(this); + if (xComponent.is()) + { + Color cr(xComponent->getBackground()); + crUnderline = cr.IsDark() ? COL_WHITE : COL_BLACK; + rValue.Value <<= crUnderline; + } + } + + continue; + } + + //tab stop + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_TABSTOPS ).pName ) )==0) + { + com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > tabs = GetCurrentTabStop( nIndex ); + if( !tabs.hasElements() ) + { + tabs.realloc(1); + ::com::sun::star::style::TabStop ts; + com::sun::star::awt::Rectangle rc0 = getCharacterBounds(0); + com::sun::star::awt::Rectangle rc1 = getCharacterBounds(nIndex); + if( rc1.X - rc0.X >= 48 ) + ts.Position = (rc1.X - rc0.X) - (rc1.X - rc0.X - 48)% 47 + 47; + else + ts.Position = 48; + ts.DecimalChar = ' '; + ts.FillChar = ' '; + ts.Alignment = ::com::sun::star::style::TabAlign_LEFT; + tabs[0] = ts; + } + rValue.Value <<= tabs; + continue; + } + + //number bullet + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_NUMBERING_RULES ).pName ) )==0) + { + if ( pTxtNode->HasBullet() || pTxtNode->HasNumber() ) + { + uno::Any aVal; + SwNumRule* pNumRule = pTxtNode->GetNumRule(); + if (pNumRule) + { + uno::Reference< container::XIndexReplace > xNum = new SwXNumberingRules(*pNumRule); + aVal.setValue(&xNum, ::getCppuType((const uno::Reference< container::XIndexReplace >*)0)); + } + rValue.Value <<= aVal; + } + continue; + } + + //footnote & endnote + if (rValue.Name.compareTo(::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_ESCAPEMENT ).pName ) )==0) + { + if ( GetPortionData().IsIndexInFootnode(nIndex) ) + { + const OUString sEscapmentName = OUString::createFromAscii( GetPropName( UNO_NAME_CHAR_ESCAPEMENT ).pName ); + rValue.Value <<= (sal_Int32)101; + } + continue; + } + } +} +//-----IAccessibility2 Implementation 2009 awt::Rectangle SwAccessibleParagraph::getCharacterBounds( sal_Int32 nIndex ) @@ -1971,6 +2978,12 @@ sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 n /*accessibility::*/TextSegment aResult; aResult.SegmentStart = -1; aResult.SegmentEnd = -1; + //IAccessibility2 Implementation 2009----- + //If nIndex = 0, then nobefore text so return -1 directly. + if( nIndex == 0 ) + return aResult; + //Tab will be return when call WORDTYPE + //-----IAccessibility2 Implementation 2009 // get starting pos i18n::Boundary aBound; @@ -1985,22 +2998,47 @@ sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 n } // now skip to previous word - sal_Bool bWord = sal_False; - while( !bWord ) + //IAccessibility2 Implementation 2009----- + if (nTextType==2 || nTextType == 3) { - nIndex = min( nIndex, aBound.startPos ) - 1; - if( nIndex >= 0 ) - bWord = GetTextBoundary( aBound, rText, nIndex, nTextType ); - else - break; // exit if beginning of string is reached + i18n::Boundary preBound = aBound; + while(preBound.startPos==aBound.startPos && nIndex > 0) + { + nIndex = min( nIndex, preBound.startPos ) - 1; + if( nIndex < 0 ) break; + GetTextBoundary( preBound, rText, nIndex, nTextType ); + } + //if (nIndex>0) + if (nIndex>=0) + //Tab will be return when call WORDTYPE + { + aResult.SegmentText = rText.copy( preBound.startPos, preBound.endPos - preBound.startPos ); + aResult.SegmentStart = preBound.startPos; + aResult.SegmentEnd = preBound.endPos; + } } - - if ( bWord ) + else { - aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos ); - aResult.SegmentStart = aBound.startPos; - aResult.SegmentEnd = aBound.endPos; - }; + sal_Bool bWord = sal_False; + while( !bWord ) + { + nIndex = min( nIndex, aBound.startPos ) - 1; + if( nIndex >= 0 ) + { + bWord = GetTextBoundary( aBound, rText, nIndex, nTextType ); + } + else + break; // exit if beginning of string is reached + } + + if (bWord && nIndex<rText.getLength()) + { + aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos ); + aResult.SegmentStart = aBound.startPos; + aResult.SegmentEnd = aBound.endPos; + } + } + //-----IAccessibility2 Implementation 2009 return aResult; } @@ -2041,6 +3079,66 @@ sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 n aResult.SegmentStart = aBound.startPos; aResult.SegmentEnd = aBound.endPos; } + +/* + //IAccessibility2 Implementation 2009----- + sal_Bool bWord = sal_False; + bWord = GetTextBoundary( aBound, rText, nIndex, nTextType ); + + if (nTextType==2) + { + Boundary nexBound=aBound; + + // real current word + if( nIndex <= aBound.endPos && nIndex >= aBound.startPos ) + { + while(nexBound.endPos==aBound.endPos&&nIndex<rText.getLength()) + { + // nIndex = max( (sal_Int32)(nIndex), nexBound.endPos) + 1; + nIndex = max( (sal_Int32)(nIndex), nexBound.endPos) ; + const sal_Unicode* pStr = rText.getStr(); + if (pStr) + { + if( pStr[nIndex] == sal_Unicode(' ') ) + nIndex++; + } + if( nIndex < rText.getLength() ) + { + bWord = GetTextBoundary( nexBound, rText, nIndex, nTextType ); + } + } + } + + if (bWord && nIndex<rText.getLength()) + { + aResult.SegmentText = rText.copy( nexBound.startPos, nexBound.endPos - nexBound.startPos ); + aResult.SegmentStart = nexBound.startPos; + aResult.SegmentEnd = nexBound.endPos; + } + + } + else + { + bWord = sal_False; + while( !bWord ) + { + nIndex = max( (sal_Int32)(nIndex+1), aBound.endPos ); + if( nIndex < rText.getLength() ) + { + bWord = GetTextBoundary( aBound, rText, nIndex, nTextType ); + } + else + break; // exit if end of string is reached + } + if (bWord && nIndex<rText.getLength()) + { + aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos ); + aResult.SegmentStart = aBound.startPos; + aResult.SegmentEnd = aBound.endPos; + } + } + //-----IAccessibility2 Implementation 2009 +*/ return aResult; } @@ -2153,16 +3251,6 @@ sal_Bool SwAccessibleParagraph::replaceText( throw lang::IndexOutOfBoundsException(); } -struct IndexCompare -{ - const PropertyValue* pValues; - IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {} - bool operator() ( const sal_Int32& a, const sal_Int32& b ) const - { - return (pValues[a].Name < pValues[b].Name) ? true : false; - } -}; - sal_Bool SwAccessibleParagraph::setAttributes( sal_Int32 nStartIndex, @@ -2368,6 +3456,16 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkCount() nCount++; } + //IAccessibility2 Implementation 2009----- + /* Can't fin the function "GetTOCFirstWordEndIndex" declaration in sym2.0 (Added by yanjun) + if( GetTOXSortTabBase() ) + { + SwTxtNode* pNode = const_cast<SwTxtNode*>(GetTxtNode()); + if(pNode && pNode->GetTOCFirstWordEndIndex() > 0) + nCount++; + } + */ + //-----IAccessibility2 Implementation 2009 return nCount; } @@ -2382,8 +3480,163 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL // --> OD 2007-06-27 #i77108# - provide hyperlinks also in editable documents. // if( !IsEditableState() ) - // <-- + const SwTxtFrm *pTxtFrm = static_cast<const SwTxtFrm*>( GetFrm() ); + SwHyperlinkIter_Impl aHIter( pTxtFrm ); + //SwAccessibleAutoRecognizerHelper_Impl aARHelper( pTxtFrm ); + sal_Int32 nARCount = 0; + sal_Int32 nARIndex = 0; + sal_Int32 nTIndex = -1; + sal_Int32 nTOCEndIndex = -1; + SwTxtNode* pNode = NULL; + SwTOXSortTabBase* pTBase = GetTOXSortTabBase(); + if( pTBase ) + { + pNode = const_cast<SwTxtNode*>(GetTxtNode()); + } + nTOCEndIndex = -1; + //if(pNode) + // nTOCEndIndex = pNode->GetTOCFirstWordEndIndex(); + SwTxtAttr* pHt = (SwTxtAttr*)(aHIter.next()); + while( (nLinkIndex < getHyperLinkCount()) && nTIndex < nLinkIndex) { + // no candidates, exit + //if( (!pHt) && (nARIndex >= nARCount) && nTOCEndIndex <= 0) + // break; + + sal_Int32 nHStt = -1; + sal_Int32 nAStt = -1; + sal_Bool bH = sal_False; + sal_Bool bA = sal_False; + + + if( pHt ) + nHStt = *pHt->GetStart(); + if( nARIndex < nARCount ) + { + /* + sal_Int32 nAEnd; + aARHelper.getPosition( nARIndex, nAStt, nAEnd ); + */ + } + sal_Bool bTOC = sal_False; + // Inside TOC & get the first link + if( pTBase && nTIndex == -1 ) + { + nTIndex++; + bTOC = sal_True; + } + else + { + if( nHStt >=0 && nAStt >=0 ) + { // both hyperlink and smart tag available + nTIndex++; + if( nHStt <= nAStt ) + bH = sal_True; + else + bA = sal_True; + } + else if( nHStt >= 0 ) + { // only hyperlink available + nTIndex++; + bH = sal_True; + } + else if( nAStt >= 0 ) + { // only smart tag available + nTIndex++; + bA = sal_True; + } + } + + if( nTIndex == nLinkIndex ) + { // found + if( bH ) + { // it's a hyperlink + if( pHt ) + { +// const SwField* pFFld = pHt->GetFld().GetFld(); + { + if( !pHyperTextData ) + pHyperTextData = new SwAccessibleHyperTextData; + SwAccessibleHyperTextData::iterator aIter = + pHyperTextData ->find( pHt ); + if( aIter != pHyperTextData->end() ) + { + xRet = (*aIter).second; + } + if( !xRet.is() ) + { + { + const sal_Int32 nTmpHStt= GetPortionData().GetAccessiblePosition( + max( aHIter.startIdx(), *pHt->GetStart() ) ); + const sal_Int32 nTmpHEnd= GetPortionData().GetAccessiblePosition( + min( aHIter.endIdx(), *pHt->GetAnyEnd() ) ); + xRet = new SwAccessibleHyperlink( aHIter.getCurrHintPos(), + this, nTmpHStt, nTmpHEnd ); + } + if( aIter != pHyperTextData->end() ) + { + (*aIter).second = xRet; + } + else + { + SwAccessibleHyperTextData::value_type aEntry( pHt, xRet ); + pHyperTextData->insert( aEntry ); + } + } + } + } + } + else if( bTOC ) + { + //xRet = new SwAccessibleTOCLink( this ); + } + else if( bA ) + { + /* + // it's a smart tag + if( !pAutoRecognizerData ) + pAutoRecognizerData = new SwAccessibleAutoRecognizerData; + SwAccessibleAutoRecognizerData::iterator aIter = + pAutoRecognizerData ->find( nARIndex ); + if( aIter != pAutoRecognizerData->end() ) + { + xRet = (*aIter).second; + } + if( !xRet.is() ) + { + sal_Int32 nAStt = 0; + sal_Int32 nAEnd = 0; + //aARHelper.getPosition( nARIndex, nAStt, nAEnd ); + xRet = new SwAccessibleAutoRecognizer( this, nAStt, nAEnd ); + if( aIter != pAutoRecognizerData->end() ) + { + (*aIter).second = xRet; + } + else + { + SwAccessibleAutoRecognizerData::value_type aEntry( nARIndex, xRet ); + pAutoRecognizerData->insert( aEntry ); + } + } + */ + } + break; + } + + // iterate next + if( bH ) + // iterate next hyperlink + pHt = (SwTxtAttr*)(aHIter.next()); + else if( bA ) + // iterate next smart tag + nARIndex++; + else if(bTOC) + continue; + else + // no candidate, exit + break; + } + /* const SwTxtFrm *pTxtFrm = static_cast<const SwTxtFrm*>( GetFrm() ); SwHyperlinkIter_Impl aHIter( pTxtFrm ); while( nLinkIndex-- ) @@ -2420,7 +3673,7 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL } } } - + */ if( !xRet.is() ) throw lang::IndexOutOfBoundsException(); @@ -2459,10 +3712,23 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharInde if( pHt ) nRet = nPos; - } + //IAccessibility2 Implementation 2009----- + /* Added by yanjun for acc miagration + if( nRet == -1 && GetTOXSortTabBase() ) + { + SwTxtNode* pNode = const_cast<SwTxtNode*>(GetTxtNode()); + if( nCharIndex >= 0 && nCharIndex < pNode->GetTOCFirstWordEndIndex()) + nRet = 0; + } + */ - return nRet; + if (nRet == -1) + throw lang::IndexOutOfBoundsException(); + else + return nRet; + //return nRet; + //-----IAccessibility2 Implementation 2009 } // --> OD 2008-05-26 #i71360# @@ -2491,6 +3757,203 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getTextMarkupCount( sal_Int32 nTextMar return pTextMarkupHelper->getTextMarkupCount( nTextMarkupType ); } +//IAccessibility2 Implementation 2009----- +//MSAA Extension Implementation in app module +sal_Bool SAL_CALL SwAccessibleParagraph::scrollToPosition( const ::com::sun::star::awt::Point&, sal_Bool ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +{ + return sal_False; +} + +sal_Int32 SAL_CALL SwAccessibleParagraph::getSelectedPortionCount( ) + throw (::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nSeleted = 0; + SwPaM* pCrsr = GetCursor( true ); + if( pCrsr != NULL ) + { + // get SwPosition for my node + const SwTxtNode* pNode = GetTxtNode(); + sal_uLong nHere = pNode->GetIndex(); + + // iterate over ring + SwPaM* pRingStart = pCrsr; + do + { + // ignore, if no mark + if( pCrsr->HasMark() ) + { + // check whether nHere is 'inside' pCrsr + SwPosition* pStart = pCrsr->Start(); + sal_uLong nStartIndex = pStart->nNode.GetIndex(); + SwPosition* pEnd = pCrsr->End(); + sal_uLong nEndIndex = pEnd->nNode.GetIndex(); + if( ( nHere >= nStartIndex ) && + ( nHere <= nEndIndex ) ) + { + nSeleted++; + } + // else: this PaM doesn't point to this paragraph + } + // else: this PaM is collapsed and doesn't select anything + + // next PaM in ring + pCrsr = static_cast<SwPaM*>( pCrsr->GetNext() ); + } + while( pCrsr != pRingStart ); + } + return nSeleted; + +} + +sal_Int32 SAL_CALL SwAccessibleParagraph::getSeletedPositionStart( sal_Int32 nSelectedPortionIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); + + sal_Int32 nStart, nEnd; + /*sal_Bool bSelected = */GetSelectionAtIndex(nSelectedPortionIndex, nStart, nEnd ); + return nStart; +} + +sal_Int32 SAL_CALL SwAccessibleParagraph::getSeletedPositionEnd( sal_Int32 nSelectedPortionIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); + + sal_Int32 nStart, nEnd; + /*sal_Bool bSelected = */GetSelectionAtIndex(nSelectedPortionIndex, nStart, nEnd ); + return nEnd; +} + +sal_Bool SAL_CALL SwAccessibleParagraph::removeSelection( sal_Int32 selectionIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + if(selectionIndex < 0) return sal_False; + + sal_Bool bRet = sal_False; + sal_Int32 nSelected = selectionIndex; + + // get the selection, and test whether it affects our text node + SwPaM* pCrsr = GetCursor( true ); +// SwPaM* pFirst = pCrsr; + SwPaM* pPrev = pCrsr; + + if( pCrsr != NULL ) + { + // get SwPosition for my node + const SwTxtNode* pNode = GetTxtNode(); + sal_uLong nHere = pNode->GetIndex(); + + // iterate over ring + SwPaM* pRingStart = pCrsr; + do + { + // ignore, if no mark + if( pCrsr->HasMark() ) + { + // check whether nHere is 'inside' pCrsr + SwPosition* pStart = pCrsr->Start(); + sal_uLong nStartIndex = pStart->nNode.GetIndex(); + SwPosition* pEnd = pCrsr->End(); + sal_uLong nEndIndex = pEnd->nNode.GetIndex(); + if( ( nHere >= nStartIndex ) && + ( nHere <= nEndIndex ) ) + { + if( nSelected == 0 ) + { + pCrsr->MoveTo((Ring*)0); + delete pCrsr; + bRet = sal_True; + } + else + { + nSelected--; + } + } + } + // else: this PaM is collapsed and doesn't select anything + pPrev = pCrsr; + pCrsr = static_cast<SwPaM*>( pCrsr->GetNext() ); + } + while( !bRet && (pCrsr != pRingStart) ); + } + return sal_True; +} + +sal_Int32 SAL_CALL SwAccessibleParagraph::addSelection( sal_Int32, sal_Int32 startOffset, sal_Int32 endOffset) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); + + // parameter checking + sal_Int32 nLength = GetString().getLength(); + if ( ! IsValidRange( startOffset, endOffset, nLength ) ) + { + throw lang::IndexOutOfBoundsException(); + } + + sal_Int32 nSelectedCount = getSelectedPortionCount(); + for ( sal_Int32 i = nSelectedCount ; i >= 0 ; i--) + { + sal_Int32 nStart, nEnd; + sal_Bool bSelected = GetSelectionAtIndex(i, nStart, nEnd ); + if(bSelected) + { + if(nStart <= nEnd ) + { + if (( startOffset>=nStart && startOffset <=nEnd ) || //startOffset in a selection + ( endOffset>=nStart && endOffset <=nEnd ) || //endOffset in a selection + ( startOffset <= nStart && endOffset >=nEnd) || //start and end include the old selection + ( startOffset >= nStart && endOffset <=nEnd) ) + { + removeSelection(i); + } + + } + else + { + if (( startOffset>=nEnd && startOffset <=nStart ) || //startOffset in a selection + ( endOffset>=nEnd && endOffset <=nStart ) || //endOffset in a selection + ( startOffset <= nStart && endOffset >=nEnd) || //start and end include the old selection + ( startOffset >= nStart && endOffset <=nEnd) ) + + { + removeSelection(i); + } + } + } + + } + + sal_Bool bRet = sal_False; + + // get cursor shell + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL ) + { + // create pam for selection + pCrsrShell->StartAction(); +// SwTxtNode* pNode = const_cast<SwTxtNode*>( GetTxtNode() ); + SwPaM* aPaM = pCrsrShell->CreateCrsr(); + aPaM->SetMark(); + aPaM->GetPoint()->nContent = GetPortionData().GetModelPosition(startOffset); + aPaM->GetMark()->nContent = GetPortionData().GetModelPosition(endOffset); + //pCrsrShell->ShowCrsr(); + pCrsrShell->EndAction(); + // set PaM at cursor shell + //bRet = Select( aPaM ); + } + + return bRet; +} +//-----IAccessibility2 Implementation 2009 /*accessibility::*/TextSegment SAL_CALL SwAccessibleParagraph::getTextMarkup( sal_Int32 nTextMarkupIndex, @@ -2672,3 +4135,267 @@ void SwAccessibleParagraph::Modify( const SfxPoolItem* pOld, const SfxPoolItem* CheckRegistration( pOld, pNew ); } // <-- + +//IAccessibility2 Implementation 2009----- +sal_Bool SwAccessibleParagraph::GetSelectionAtIndex( + sal_Int32& nIndex, sal_Int32& nStart, sal_Int32& nEnd) +{ + if(nIndex < 0) return sal_False; + + + sal_Bool bRet = sal_False; + nStart = -1; + nEnd = -1; + sal_Int32 nSelected = nIndex; + + // get the selection, and test whether it affects our text node + SwPaM* pCrsr = GetCursor( true ); + if( pCrsr != NULL ) + { + // get SwPosition for my node + const SwTxtNode* pNode = GetTxtNode(); + sal_uLong nHere = pNode->GetIndex(); + + // iterate over ring + SwPaM* pRingStart = pCrsr; + do + { + // ignore, if no mark + if( pCrsr->HasMark() ) + { + // check whether nHere is 'inside' pCrsr + SwPosition* pStart = pCrsr->Start(); + sal_uLong nStartIndex = pStart->nNode.GetIndex(); + SwPosition* pEnd = pCrsr->End(); + sal_uLong nEndIndex = pEnd->nNode.GetIndex(); + if( ( nHere >= nStartIndex ) && + ( nHere <= nEndIndex ) ) + { + if( nSelected == 0 ) + { + // translate start and end positions + + // start position + sal_Int32 nLocalStart = -1; + if( nHere > nStartIndex ) + { + // selection starts in previous node: + // then our local selection starts with the paragraph + nLocalStart = 0; + } + else + { + DBG_ASSERT( nHere == nStartIndex, + "miscalculated index" ); + + // selection starts in this node: + // then check whether it's before or inside our part of + // the paragraph, and if so, get the proper position + sal_uInt16 nCoreStart = pStart->nContent.GetIndex(); + if( nCoreStart < + GetPortionData().GetFirstValidCorePosition() ) + { + nLocalStart = 0; + } + else if( nCoreStart <= + GetPortionData().GetLastValidCorePosition() ) + { + DBG_ASSERT( + GetPortionData().IsValidCorePosition( + nCoreStart ), + "problem determining valid core position" ); + + nLocalStart = + GetPortionData().GetAccessiblePosition( + nCoreStart ); + } + } + + // end position + sal_Int32 nLocalEnd = -1; + if( nHere < nEndIndex ) + { + // selection ends in following node: + // then our local selection extends to the end + nLocalEnd = GetPortionData().GetAccessibleString(). + getLength(); + } + else + { + DBG_ASSERT( nHere == nStartIndex, + "miscalculated index" ); + + // selection ends in this node: then select everything + // before our part of the node + sal_uInt16 nCoreEnd = pEnd->nContent.GetIndex(); + if( nCoreEnd > + GetPortionData().GetLastValidCorePosition() ) + { + // selection extends beyond out part of this para + nLocalEnd = GetPortionData().GetAccessibleString(). + getLength(); + } + else if( nCoreEnd >= + GetPortionData().GetFirstValidCorePosition() ) + { + // selection is inside our part of this para + DBG_ASSERT( + GetPortionData().IsValidCorePosition( + nCoreEnd ), + "problem determining valid core position" ); + + nLocalEnd = GetPortionData().GetAccessiblePosition( + nCoreEnd ); + } + } + + if( ( nLocalStart != -1 ) && ( nLocalEnd != -1 ) ) + { + nStart = nLocalStart; + nEnd = nLocalEnd; + bRet = sal_True; + } + } // if hit the index + else + { + nSelected--; + } + } + // else: this PaM doesn't point to this paragraph + } + // else: this PaM is collapsed and doesn't select anything + + // next PaM in ring + pCrsr = static_cast<SwPaM*>( pCrsr->GetNext() ); + } + while( !bRet && (pCrsr != pRingStart) ); + } + // else: nocursor -> no selection + + if( bRet ) + { + sal_Int32 nCaretPos = GetCaretPos(); + if( nStart == nCaretPos ) + { + sal_Int32 tmp = nStart; + nStart = nEnd; + nEnd = tmp; + } + } + return bRet; +} + +sal_Int16 SAL_CALL SwAccessibleParagraph::getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException) +{ + //Get the real heading level, Heading1 ~ Heading10 + if (nHeadingLevel > 0) + { + return AccessibleRole::HEADING; + } + else + { + return AccessibleRole::PARAGRAPH; + } +} + +// End Add + + +/* This funcion is already defined in accpara.cxx(Added by yanjun) +sal_Int32 SAL_CALL SwAccessibleParagraph::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ +// Test Code +// Sequence<OUString> seNames(1); +// OUString* pStrings = seNames.getArray(); +// pStrings[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackColor")); +// +// Sequence<Any> aAnys(1); +// Reference<XMultiPropertySet> xPortion = CreateUnoPortion( 0, 0 ); +// aAnys = xPortion->getPropertyValues( seNames ); +// const Any* pAnys = aAnys.getConstArray(); +// +// sal_uInt32 crColorT=0; +// pAnys[0] >>= crColorT; +// End Test Code + + const SvxBrushItem &rBack = GetFrm()->GetAttrSet()->GetBackground(); + sal_uInt32 crBack = rBack.GetColor().GetColor(); + + if (COL_AUTO == crBack) + { + Reference<XAccessible> xAccDoc = getAccessibleParent(); + if (xAccDoc.is()) + { + Reference<XAccessibleComponent> xCompoentDoc(xAccDoc,UNO_QUERY); + if (xCompoentDoc.is()) + { + crBack = (sal_uInt32)xCompoentDoc->getBackground(); + } + } + } + return crBack; +} +*/ + +//Get the real heading level, Heading1 ~ Heading10 +sal_Int32 SwAccessibleParagraph::GetRealHeadingLevel() +{ + uno::Reference< ::com::sun::star::beans::XPropertySet > xPortion = CreateUnoPortion( 0, 0 ); + ::rtl::OUString pString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")); + uno::Any styleAny = xPortion->getPropertyValue( pString ); + ::rtl::OUString sValue; + if (styleAny >>= sValue) + { + //Modified by yanjun for acc migration + sal_Int32 length = sValue.getLength/*GetCharCount*/(); + if (length == 9 || length == 10) + { + ::rtl::OUString headStr = sValue.copy(0, 7); + if (headStr.equals(::rtl::OUString::createFromAscii("Heading"))) + { + ::rtl::OUString intStr = sValue.copy(8); + sal_Int32 headingLevel = intStr.toInt32(10); + return headingLevel; + } + } + } + return -1; +} + +uno::Any SAL_CALL SwAccessibleParagraph::getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + uno::Any Ret; + ::rtl::OUString strHeading(::rtl::OUString::createFromAscii("heading-level:")); + if( nHeadingLevel >= 0 ) + strHeading += OUString::valueOf(nHeadingLevel, 10); + strHeading += OUString::createFromAscii(";"); + + Ret <<= strHeading; + + return Ret; +} + +//Tab will be return when call WORDTYPE +sal_Bool SwAccessibleParagraph::tabCharInWord( sal_Int32 nIndex, i18n::Boundary& aBound) +{ + sal_Bool bFind = sal_False; + if( aBound.startPos != nIndex) + { + OUString tabStr; + if(aBound.startPos>nIndex) + tabStr = GetString().copy(nIndex,(aBound.startPos - nIndex) ); + + sal_Unicode tabChar('\t'); + sal_Int32 tabIndex = tabStr.indexOf(tabChar); + if( tabIndex > -1 ) + { + aBound.startPos = nIndex + tabIndex ; + aBound.endPos = aBound.startPos + 1; + bFind = sal_True; + } + } + return bFind; +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index 782ecfbefe5a..1de219d9e2bf 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -29,6 +29,11 @@ #include <com/sun/star/accessibility/XAccessibleHypertext.hpp> #include <com/sun/star/accessibility/XAccessibleTextMarkup.hpp> #include <com/sun/star/accessibility/XAccessibleMultiLineText.hpp> +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/accessibility/XAccessibleTextSelection.hpp> +#include <txmsrt.hxx> +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> +//-----IAccessibility2 Implementation 2009 #include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp> #include <hash_map> #include <accselectionhelper.hxx> @@ -36,11 +41,13 @@ #include <calbck.hxx> // <-- +class SwField; class SwTxtFrm; class SwTxtNode; class SwPaM; class SwAccessiblePortionData; class SwAccessibleHyperTextData; +class SwRedline; //IAccessibility2 Implementation 2009 class SwXTextPortion; // --> OD 2010-02-19 #i108125# class SwParaChangeTrackingInfo; @@ -50,6 +57,7 @@ namespace rtl { class OUString; } namespace com { namespace sun { namespace star { namespace i18n { struct Boundary; } namespace accessibility { class XAccessibleHyperlink; } + namespace style { class TabStop; } } } } typedef ::std::hash_map< ::rtl::OUString, @@ -67,7 +75,11 @@ class SwAccessibleParagraph : public com::sun::star::accessibility::XAccessibleHypertext, public com::sun::star::accessibility::XAccessibleTextMarkup, public com::sun::star::accessibility::XAccessibleMultiLineText, - public ::com::sun::star::accessibility::XAccessibleTextAttributes + public ::com::sun::star::accessibility::XAccessibleTextAttributes, + //IAccessibility2 Implementation 2009----- + public com::sun::star::accessibility::XAccessibleTextSelection, + public com::sun::star::accessibility::XAccessibleExtendedAttributes + //-----IAccessibility2 Implementation 2009 { friend class SwAccessibleHyperlink; @@ -86,6 +98,9 @@ class SwAccessibleParagraph : // mutex) sal_Bool bIsHeading; // protected by base classes mutex + //IAccessibility2 Implementation 2009----- + sal_Int32 nHeadingLevel; + //-----IAccessibility2 Implementation 2009 // implementation for XAccessibleSelection SwAccessibleSelectionHelper aSelectionHelper; @@ -144,6 +159,10 @@ class SwAccessibleParagraph : } } + //IAccessibility2 Implementation 2009----- + const SwRedline* GetRedlineAtIndex( sal_Int32 nPos ); + String GetFieldTypeNameAtIndex(sal_Int32 nIndex); + //-----IAccessibility2 Implementation 2009 // --> OD 2006-07-13 #i63870# void _getDefaultAttributesImpl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes, @@ -154,9 +173,22 @@ class SwAccessibleParagraph : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes, tAccParaPropValMap& rRunAttrSeq ); // <-- + // IAccessibility2 Implementation 2009---- + void _getSupplementalAttributesImpl( + const sal_Int32 nIndex, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes, + tAccParaPropValMap& rSupplementalAttrSeq ); -public: + void _correctValues( + const sal_Int32 nIndex, + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues ); + // ----IAccessibility2 Implementation 2009 +public: + //IAccessibility2 Implementation 2009----- + SwTOXSortTabBase* GetTOXSortTabBase(); + short GetTOCLevel(); + //-----IAccessibility2 Implementation 2009 sal_Bool IsHeading() const; protected: @@ -241,6 +273,15 @@ public: virtual sal_Bool HasCursor(); // required by map to remember that object + //IAccessibility2 Implementation 2009----- + com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > GetCurrentTabStop( sal_Int32 nIndex ); + virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException); + //-----IAccessibility2 Implementation 2009 + // --> OD 2010-02-19 #i108125# + // MT: Solved merge conflict - seems this was removed between 101 and 103? + // virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew); + // <-- + //===== XAccessibleContext ============================================== /// Return this object's description. @@ -406,7 +447,29 @@ public: ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); // <-- - + //IAccessibility2 Implementation 2009----- + //====== XAccessibleTextSelection ====================================== + virtual sal_Bool SAL_CALL scrollToPosition( const ::com::sun::star::awt::Point& aPoint, sal_Bool isLeftTop ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSelectedPortionCount( ) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSeletedPositionStart( sal_Int32 nSelectedPortionIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSeletedPositionEnd( sal_Int32 nSelectedPortionIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL removeSelection( sal_Int32 selectionIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL addSelection( sal_Int32 selectionIndex, sal_Int32 startOffset, sal_Int32 endOffset) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + //===== XAccessibleExtendedAttributes ============================================== + virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + sal_Bool GetSelectionAtIndex(sal_Int32& nIndex, sal_Int32& nStart, sal_Int32& nEnd); + sal_Int32 GetRealHeadingLevel(); + //===== XAccessibleComponent ============================================ + sal_Bool m_bLastHasSelection; + sal_Bool tabCharInWord(sal_Int32 nIndex, com::sun::star::i18n::Boundary& aBound); + //-----IAccessibility2 Implementation 2009 // --> OD 2008-05-29 #i89175# //===== XAccessibleMultiLineText ======================================== virtual sal_Int32 SAL_CALL getLineNumberAtIndex( sal_Int32 nIndex ) diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx index 2d50e6f0d08a..64d6daba5cae 100644 --- a/sw/source/core/access/accportions.cxx +++ b/sw/source/core/access/accportions.cxx @@ -64,6 +64,10 @@ using namespace ::com::sun::star; +//IAccessibility2 Implementation 2009----- +//#include "accnote.hxx" +//-----IAccessibility2 Implementation 2009 + using rtl::OUString; using rtl::OUStringBuffer; using i18n::Boundary; @@ -140,6 +144,13 @@ void SwAccessiblePortionData::Text(sal_uInt16 nLength, sal_uInt16 nType) bLastIsSpecial = sal_False; } +//IAccessibility2 Implementation 2009----- +void SwAccessiblePortionData::SetAttrFieldType( sal_uInt16 nAttrFldType ) +{ + aAttrFieldType.push_back(nAttrFldType); + return; +} +//-----IAccessibility2 Implementation 2009 void SwAccessiblePortionData::Special( sal_uInt16 nLength, const String& rText, sal_uInt16 nType) @@ -156,11 +167,46 @@ void SwAccessiblePortionData::Special( switch( nType ) { case POR_POSTITS: - case POR_FLYCNT: - case POR_GRFNUM: + //IAccessibility2 Implementation 2009----- sDisplay = String(sal_Unicode(0xfffc)); break; + case POR_FLYCNT: + sDisplay = String(sal_Unicode(0xfffc)); + break; + case POR_GRFNUM: + case POR_BULLET: + break; + case POR_FLD: + //Added by yanjun for 6854 + case POR_HIDDEN: + case POR_COMBINED: + case POR_ISOREF: + //End + { + //When the filed content is empty, input a special character. + if (rText.Len() == 0) + sDisplay = String(sal_Unicode(0xfffc)); + else + sDisplay = rText; + aFieldPosition.push_back(aBuffer.getLength()); + aFieldPosition.push_back(aBuffer.getLength() + rText.Len()); + break; + } + case POR_FTNNUM: + { + break; + } + case POR_FTN: + { + sDisplay = rText; + sal_Int32 nStart=aBuffer.getLength(); + sal_Int32 nEnd=nStart + rText.Len(); + m_vecPairPos.push_back(std::make_pair(nStart,nEnd)); + break; + } + //-----IAccessibility2 Implementation 2009 + break; case POR_NUMBER: { OUStringBuffer aTmpBuffer( rText.Len() + 1 ); @@ -280,6 +326,7 @@ sal_Bool SwAccessiblePortionData::IsGrayPortionType( sal_uInt16 nType ) const case POR_NUMBER: case POR_FLD: case POR_URL: + case POR_INPUTFLD: case POR_ISOTOX: case POR_TOX: case POR_HIDDEN: @@ -675,6 +722,37 @@ sal_uInt16 SwAccessiblePortionData::FillSpecialPos( return static_cast<sal_uInt16>( nModelPos ); } +//IAccessibility2 Implementation 2009----- +sal_uInt16 SwAccessiblePortionData::GetAttrFldType( sal_Int32 nPos ) +{ + if( aFieldPosition.size() < 2 ) return sal_False; + sal_Int32 nFieldIndex = 0; + for( size_t i = 0; i < aFieldPosition.size() - 1; i += 2 ) + { + if( nPos < aFieldPosition[ i + 1 ] && nPos >= aFieldPosition[ i ] ) + { + return aAttrFieldType[nFieldIndex]; + } + nFieldIndex++ ; + } + return 0; +} + +sal_Bool SwAccessiblePortionData::FillBoundaryIFDateField( com::sun::star::i18n::Boundary& rBound, const sal_Int32 nPos ) +{ + if( aFieldPosition.size() < 2 ) return sal_False; + for( size_t i = 0; i < aFieldPosition.size() - 1; i += 2 ) + { + if( nPos < aFieldPosition[ i + 1 ] && nPos >= aFieldPosition[ i ] ) + { + rBound.startPos = aFieldPosition[i]; + rBound.endPos = aFieldPosition[i + 1]; + return sal_True; + } + } + return sal_False; +} +//-----IAccessibility2 Implementation 2009 void SwAccessiblePortionData::AdjustAndCheck( sal_Int32 nPos, size_t& nPortionNo, @@ -738,6 +816,50 @@ sal_Bool SwAccessiblePortionData::IsValidCorePosition( sal_uInt16 nPos ) const ( nPos <= aModelPositions[ aModelPositions.size()-1 ] ); } +//IAccessibility2 Implementation 2009----- +sal_Bool SwAccessiblePortionData::IsZeroCorePositionData() +{ + if( aModelPositions.size() < 1 ) return sal_True; + return aModelPositions[0] == 0 && aModelPositions[aModelPositions.size()-1] == 0; +} + +sal_Bool SwAccessiblePortionData::IsIndexInFootnode(sal_Int32 nIndex) +{ + VEC_PAIR_POS::iterator vi =m_vecPairPos.begin(); + for (;vi != m_vecPairPos.end() ; ++vi) + { + const PAIR_POS &pairPos = *vi; + if(nIndex >= pairPos.first && nIndex < pairPos.second ) + { + return sal_True; + } + } + return sal_False; +} + +sal_Bool SwAccessiblePortionData::IsInGrayPortion( sal_Int32 nPos ) +{ +// return IsGrayPortion( FindBreak( aAccessiblePositions, nPos ) ); + return IsPortionAttrSet( FindBreak( aAccessiblePositions, nPos ), + PORATTR_GRAY ); +} + +sal_Int32 SwAccessiblePortionData::GetFieldIndex(sal_Int32 nPos) +{ + sal_Int32 nIndex = -1; + if( aFieldPosition.size() >= 2 ) + { + for( sal_Int32 i = 0; i < aFieldPosition.size() - 1; i += 2 ) + { + if( nPos <= aFieldPosition[ i + 1 ] && nPos >= aFieldPosition[ i ] ) + { + nIndex = i/2; + break; + } + } + } + return nIndex; +} sal_uInt16 SwAccessiblePortionData::GetFirstValidCorePosition() const { return static_cast<sal_uInt16>( aModelPositions[0] ); diff --git a/sw/source/core/access/accportions.hxx b/sw/source/core/access/accportions.hxx index 1ecab653f3e2..a068f27458b4 100644 --- a/sw/source/core/access/accportions.hxx +++ b/sw/source/core/access/accportions.hxx @@ -61,6 +61,10 @@ class SwAccessiblePortionData : public SwPortionHandler Positions_t aLineBreaks; /// position of line breaks Positions_t aModelPositions; /// position of portion breaks in the model Positions_t aAccessiblePositions; /// portion breaks in sAccessibleString + //IAccessibility2 Implementation 2009----- + Positions_t aFieldPosition; + //-----IAccessibility2 Implementation 2009 + Positions_t aAttrFieldType; typedef std::vector<sal_uInt8> PortionAttrs_t; PortionAttrs_t aPortionAttrs; /// additional portion attributes @@ -104,7 +108,15 @@ public: virtual void Skip(sal_uInt16 nLength); virtual void Finish(); + //IAccessibility2 Implementation 2009----- + virtual void SetAttrFieldType( sal_uInt16 nAttrFldType ); + sal_Bool FillBoundaryIFDateField( com::sun::star::i18n::Boundary& rBound, const sal_Int32 nPos ); + sal_Bool IsIndexInFootnode(sal_Int32 nIndex); + sal_Bool IsInGrayPortion( sal_Int32 nPos ); + sal_Int32 GetFieldIndex(sal_Int32 nPos); + //-----IAccessibility2 Implementation 2009 + sal_Bool IsZeroCorePositionData(); // access to the portion data /// get the text string, as presented by the layout @@ -149,6 +161,7 @@ public: void GetAttributeBoundary( com::sun::star::i18n::Boundary& rBound, sal_Int32 nPos ) const; + sal_uInt16 GetAttrFldType( sal_Int32 nPos ); /// Convert start and end positions into core positions. /// @returns true if 'special' portions are included either completely /// or not at all. This can be used to test whether editing @@ -164,6 +177,12 @@ public: sal_Bool IsValidCorePosition( sal_uInt16 nPos ) const; sal_uInt16 GetFirstValidCorePosition() const; sal_uInt16 GetLastValidCorePosition() const; + //IAccessibility2 Implementation 2009----- +private: + typedef std::pair<sal_Int32,sal_Int32> PAIR_POS; + typedef std::vector<PAIR_POS> VEC_PAIR_POS; + VEC_PAIR_POS m_vecPairPos; + //-----IAccessibility2 Implementation 2009 }; diff --git a/sw/source/core/access/accpreview.cxx b/sw/source/core/access/accpreview.cxx index f67165600906..da9dab6dd725 100644 --- a/sw/source/core/access/accpreview.cxx +++ b/sw/source/core/access/accpreview.cxx @@ -32,6 +32,11 @@ #endif #include <accpreview.hxx> +//IAccessibility2 Implementation 2009----- +#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#endif +//-----IAccessibility2 Implementation 2009 const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextDocumentPageView"; const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleDocumentPageView"; @@ -54,7 +59,9 @@ using ::rtl::OUString; SwAccessiblePreview::SwAccessiblePreview( SwAccessibleMap *pMp ) : SwAccessibleDocumentBase( pMp ) { - SetName( GetResource( STR_ACCESS_DOC_NAME ) ); + //IAccessibility2 Implementation 2009----- + SetName( GetResource( STR_ACCESS_PREVIEW_DOC_NAME ) ); + //-----IAccessibility2 Implementation 2009 } SwAccessiblePreview::~SwAccessiblePreview() @@ -98,3 +105,21 @@ Sequence< sal_Int8 > SAL_CALL SwAccessiblePreview::getImplementationId() } return aId; } +//IAccessibility2 Implementation 2009----- +OUString SAL_CALL SwAccessiblePreview::getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException) +{ + return GetResource( STR_ACCESS_PREVIEW_DOC_NAME ); +} + +OUString SAL_CALL SwAccessiblePreview::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException) +{ + OUString sName = SwAccessibleDocumentBase::getAccessibleName(); + sName += OUString::createFromAscii(" "); + sName += GetResource( STR_ACCESS_PREVIEW_DOC_SUFFIX ); + return sName; +} +void SwAccessiblePreview::_InvalidateFocus() +{ + FireStateChangedEvent( ::com::sun::star::accessibility::AccessibleStateType::FOCUSED, sal_True ); +} +//-----IAccessibility2 Implementation 2009 diff --git a/sw/source/core/access/accpreview.hxx b/sw/source/core/access/accpreview.hxx index 215db22f653d..4907240c8d6a 100644 --- a/sw/source/core/access/accpreview.hxx +++ b/sw/source/core/access/accpreview.hxx @@ -66,6 +66,12 @@ public: //====== XTypeProvider ==================================================== virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + + //IAccessibility2 Implementation 2009----- + ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException); + ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException); + virtual void _InvalidateFocus(); + //-----IAccessibility2 Implementation 2009 }; #endif diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 0a651f3b5d42..9be9421fffd6 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -38,6 +38,14 @@ #include <flyfrm.hxx> +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/XAccessibleStateSet.hpp> +#include <fmtanchr.hxx> +//-----IAccessibility2 Implementation 2009 + +using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -111,6 +119,43 @@ void SwAccessibleSelectionHelper::selectAccessibleChild( // return bRet; } +//IAccessibility2 Implementation 2009----- +//When the selected state of the SwFrmOrObj is setted, return true. +static sal_Bool lcl_getSelectedState(const SwAccessibleChild& aChild, + SwAccessibleContext* pContext, + SwAccessibleMap* pMap) +{ + Reference< XAccessible > xAcc; + if ( aChild.GetSwFrm() ) + { + xAcc = pMap->GetContext( aChild.GetSwFrm(), sal_False ); + } + else if ( aChild.GetDrawObject() ) + { + xAcc = pMap->GetContext( aChild.GetDrawObject(), pContext, sal_False ); + } + + if( xAcc.is() ) + { + Reference< XAccessibleContext > pRContext = xAcc->getAccessibleContext(); + if(!pRContext.is()) + return sal_False; + Reference<XAccessibleStateSet> pRStateSet = pRContext->getAccessibleStateSet(); + if( pRStateSet.is() ) + { + Sequence<short> pStates = pRStateSet->getStates(); + long count = pStates.getLength(); + for( int i = 0; i < count; i++ ) + { + if( pStates[i] == AccessibleStateType::SELECTED) + return sal_True; + } + } + } + return sal_False; +} +//-----IAccessibility2 Implementation 2009 + sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( lang::IndexOutOfBoundsException, @@ -137,6 +182,14 @@ sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( { bRet = pFEShell->IsObjSelected( *aChild.GetDrawObject() ); } + //IAccessibility2 Implementation 2009----- + //If the SwFrmOrObj is not selected directly in the UI, we should check whether it is selected in the selection cursor. + if( !bRet ) + { + if( lcl_getSelectedState( aChild, &rContext, rContext.GetMap() ) == sal_True) + bRet = sal_True; + } + //-----IAccessibility2 Implementation 2009 } return bRet; @@ -194,11 +247,11 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) const SwFlyFrm* pFlyFrm = pFEShell->GetCurrFlyFrm(); if( pFlyFrm ) { - if( rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == - rContext.GetFrm() ) - { + //IAccessibility2 Implementation 2009----- + //if( rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == + // rContext.GetFrm() ) nCount = 1; - } + //-----IAccessibility2 Implementation 2009 } else { @@ -226,6 +279,26 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) } } } + //IAccessibility2 Implementation 2009----- + //If the SwFrmOrObj is not selected directly in the UI, + //we should check whether it is selected in the selection cursor. + if( nCount == 0 ) + { + ::std::list< SwAccessibleChild > aChildren; + rContext.GetChildren( *(rContext.GetMap()), aChildren ); + ::std::list< SwAccessibleChild >::const_iterator aIter = + aChildren.begin(); + ::std::list< SwAccessibleChild >::const_iterator aEndIter = + aChildren.end(); + while( aIter != aEndIter ) + { + const SwAccessibleChild& aChild = *aIter; + if( lcl_getSelectedState( aChild, &rContext, rContext.GetMap() ) ) + nCount++; + ++aIter; + } + } + //-----IAccessibility2 Implementation 2009 } return nCount; } @@ -249,12 +322,28 @@ Reference<XAccessible> SwAccessibleSelectionHelper::getSelectedAccessibleChild( const SwFlyFrm *pFlyFrm = pFEShell->GetCurrFlyFrm(); if( pFlyFrm ) { - if( 0 == nSelectedChildIndex && - rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == - rContext.GetFrm() ) + //IAccessibility2 Implementation 2009----- + if( 0 == nSelectedChildIndex ) { - aChild = pFlyFrm; + if(rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == rContext.GetFrm() ) + { + aChild = pFlyFrm; + } + else + { + const SwFrmFmt *pFrmFmt = pFlyFrm->GetFmt(); + if (pFrmFmt) + { + const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor(); + if( pAnchor.GetAnchorId() == FLY_AS_CHAR ) + { + const SwFrm *pParaFrm = rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview() ); + aChild = pParaFrm; + } + } + } } + //-----IAccessibility2 Implementation 2009 } else { diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index 60567153326f..3da5bec89c29 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -49,9 +49,14 @@ #include <accmap.hxx> #include <access.hrc> #include <acctable.hxx> - +#include <rowfrm.hxx> +#include <layfrm.hxx> #include <com/sun/star/accessibility/XAccessibleText.hpp> +#include <editeng/brshitem.hxx> +#include <swatrset.hxx> +#include <frmatr.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; @@ -67,6 +72,8 @@ typedef ::std::set < sal_Int32, Int32Less_Impl > Int32Set_Impl; typedef ::std::pair < sal_Int32, sal_Int32 > Int32Pair_Impl; typedef ::std::list < Int32Pair_Impl > Int32PairList_Impl; +const int SELECTION_WITH_NUM =10; + class SwAccTableSelHander_Impl { public: @@ -88,6 +95,10 @@ class SwAccessibleTableData_Impl bool mbOnlyTableColumnHeader; void CollectData( const SwFrm *pFrm ); + //IAccessibility2 Implementation 2009----- + void CollectColumnHeaderData( const SwFrm *pFrm ); + void CollectRowHeaderData( const SwFrm *pFrm ); + //-----IAccessibility2 Implementation 2009 void CollectExtents( const SwFrm *pFrm ); sal_Bool FindCell( const Point& rPos, const SwFrm *pFrm , @@ -182,6 +193,99 @@ void SwAccessibleTableData_Impl::CollectData( const SwFrm *pFrm ) } } +//IAccessibility2 Implementation 2009----- +void SwAccessibleTableData_Impl::CollectRowHeaderData( const SwFrm *pFrm ) +{ + const SwAccessibleChildSList aList( *pFrm, mrAccMap ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); + SwAccessibleChildSList::const_iterator aEndIter( aList.end() ); + while( aIter != aEndIter ) + { + const SwAccessibleChild& rLower = *aIter; + const SwFrm *pLower = rLower.GetSwFrm(); + if( pLower ) + { + if( pLower->IsRowFrm() ) + { + + const SwTableLine* pLine = ((SwRowFrm*)pLower)->GetTabLine(); + while( pLine->GetUpper() ) + pLine = pLine->GetUpper()->GetUpper(); + + // Headerline? + //if(mpTabFrm->GetTable()->GetTabLines()[ 0 ] != pLine) + //return ; + + maRows.insert( pLower->Frm().Top() - maTabFrmPos.Y() ); + + CollectRowHeaderData( pLower ); + + + } + else if( pLower->IsCellFrm() && + rLower.IsAccessible( mbIsInPagePreview ) ) + { + //Added by yanjun. Can't find the "GetRowHeaderFlag" function(Need vefiry). + //if(((SwCellFrm*)pLower)->GetRowHeaderFlag()) + // maColumns.insert( pLower->Frm().Left() - maTabFrmPos.X() ); + } + else + { + CollectRowHeaderData( pLower ); + } + } + ++aIter; + } +} +//-----IAccessibility2 Implementation 2009 + +void SwAccessibleTableData_Impl::CollectColumnHeaderData( const SwFrm *pFrm ) +{ + const SwAccessibleChildSList aList( *pFrm, mrAccMap ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); + SwAccessibleChildSList::const_iterator aEndIter( aList.end() ); + while( aIter != aEndIter ) + { + const SwAccessibleChild& rLower = *aIter; + const SwFrm *pLower = rLower.GetSwFrm(); + if( pLower ) + { + if( pLower->IsRowFrm() ) + { + + const SwTableLine* pLine = ((SwRowFrm*)pLower)->GetTabLine(); + while( pLine->GetUpper() ) + pLine = pLine->GetUpper()->GetUpper(); + + // Headerline? + //if(mpTabFrm->GetTable()->GetTabLines()[ 0 ] != pLine) + //return ; + + //if the current line is now header line, then return ; + sal_Int16 iCurrentRowIndex = mpTabFrm->GetTable()->GetTabLines().GetPos( pLine); + if(iCurrentRowIndex >= mpTabFrm->GetTable()->_GetRowsToRepeat()) + return ; + + maRows.insert( pLower->Frm().Top() - maTabFrmPos.Y() ); + + CollectColumnHeaderData( pLower ); + + + } + else if( pLower->IsCellFrm() && + rLower.IsAccessible( mbIsInPagePreview ) ) + { + maColumns.insert( pLower->Frm().Left() - maTabFrmPos.X() ); + } + else + { + CollectColumnHeaderData( pLower ); + } + } + ++aIter; + } +} +//-----IAccessibility2 Implementation 2009 void SwAccessibleTableData_Impl::CollectExtents( const SwFrm *pFrm ) { const SwAccessibleChildSList aList( *pFrm, mrAccMap ); @@ -396,7 +500,11 @@ const SwFrm *SwAccessibleTableData_Impl::GetCellAtPos( inline sal_Int32 SwAccessibleTableData_Impl::GetRowCount() const { - return static_cast< sal_Int32 >( maRows.size() ); + //IAccessibility2 Implementation 2009----- + sal_Int32 count = static_cast< sal_Int32 >( maRows.size() ) ; + count = (count <=0)? 1:count; + //-----IAccessibility2 Implementation 2009 + return count; } inline sal_Int32 SwAccessibleTableData_Impl::GetColumnCount() const @@ -696,8 +804,12 @@ void SwAccessibleTable::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) { SwAccessibleContext::GetStates( rStateSet ); - + //IAccessibility2 Implementation 2009----- + //Solution:Add resizable state to table + rStateSet.AddState( AccessibleStateType::RESIZABLE ); // MULTISELECTABLE + rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE ); + //-----IAccessibility2 Implementation 2009 SwCrsrShell* pCrsrShell = GetCrsrShell(); if( pCrsrShell ) rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE ); @@ -727,6 +839,9 @@ SwAccessibleTable::SwAccessibleTable( OUString sArg2( GetFormattedPageNumber() ); sDesc = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 ); + //IAccessibility2 Implementation 2009----- + UpdateTableData(); + //-----IAccessibility2 Implementation 2009 } SwAccessibleTable::~SwAccessibleTable() @@ -784,8 +899,7 @@ void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew case RES_OBJECTDYING: // mba: it seems that this class intentionally does not call code in base class SwClient - if( GetRegisteredIn() == - static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) + if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) ) GetRegisteredInNonConst()->Remove( this ); break; @@ -809,6 +923,13 @@ uno::Any SwAccessibleTable::queryInterface( const uno::Type& rType ) uno::Reference<XAccessibleSelection> xSelection( this ); aRet <<= xSelection; } + //IAccessibility2 Implementation 2009----- + else if ( rType == ::getCppuType((uno::Reference<XAccessibleTableSelection> *)0) ) + { + uno::Reference<XAccessibleTableSelection> xTableExtent( this ); + aRet <<= xTableExtent; + } + //-----IAccessibility2 Implementation 2009 else { aRet = SwAccessibleContext::queryInterface(rType); @@ -981,6 +1102,9 @@ sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRowExtentAt( CHECK_FOR_DEFUNC( XAccessibleTable ) + //IAccessibility2 Implementation 2009----- + UpdateTableData(); + //-----IAccessibility2 Implementation 2009 GetTableData().CheckRowAndCol( nRow, nColumn, this ); Int32Set_Impl::const_iterator aSttCol( @@ -1011,6 +1135,9 @@ sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumnExtentAt( vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleTable ) + //IAccessibility2 Implementation 2009----- + UpdateTableData(); + //-----IAccessibility2 Implementation 2009 GetTableData().CheckRowAndCol( nRow, nColumn, this ); @@ -1045,6 +1172,25 @@ uno::Reference< XAccessibleTable > SAL_CALL SwAccessibleTable::getAccessibleColumnHeaders( ) throw (uno::RuntimeException) { +// MT IA2: Which one should win nowadys??? +/* + // IA2 version: + uno::Reference< XAccessibleTable > xRet; + SwTabFrm* pTabFrm =( SwTabFrm*)( GetFrm() ); + if (pTabFrm) + { + if(pTabFrm->GetTable()->_GetRowsToRepeat() > 0) + { + //for errata table header + SwAccessibleTableData_Impl *mpHeadTableData = new SwAccessibleTableData_Impl( pTabFrm, sal_False, sal_True); + //for errata table header + SwAccessibleTable *pHeadAccessibleTable = new SwAccessibleTable(GetMap(),pTabFrm); + pHeadAccessibleTable->SetTableData(mpHeadTableData); + xRet = pHeadAccessibleTable; + } + } + return xRet; +*/ // --> OD 2010-03-10 #i87532# // assure that return accesible object is empty, if no column header exists. SwAccessibleTableColHeaders* pTableColHeaders = @@ -1346,6 +1492,15 @@ void SwAccessibleTable::InvalidatePosOrSize( const SwRect& rOldBox ) { vos::OGuard aGuard(Application::GetSolarMutex()); + //IAccessibility2 Implementation 2009----- + //need to update children + SwAccessibleTableData_Impl *pNewTableData = CreateNewTableData(); + if( !pNewTableData->CompareExtents( GetTableData() ) ) + { + delete mpTableData; + mpTableData = pNewTableData; + FireTableChangeEvent(*mpTableData); + } if( HasTableData() ) GetTableData().SetTablePos( GetFrm()->Frm().Pos() ); @@ -1402,6 +1557,34 @@ void SwAccessibleTable::InvalidateChildPosOrSize( const SwAccessibleChild& rChil // <-- if( !pNewTableData->CompareExtents( GetTableData() ) ) { + //IAccessibility2 Implementation 2009----- + if(pNewTableData->GetRowCount()!= mpTableData->GetRowCount()) + { + Int32Set_Impl::const_iterator aSttCol( GetTableData().GetColumnIter( 0 ) ); + Int32Set_Impl::const_iterator aSttRow( GetTableData().GetRowIter( 1 ) ); + const SwFrm *pCellFrm = GetTableData().GetCellAtPos( *aSttCol, *aSttRow, sal_False ); + Int32Set_Impl::const_iterator aSttCol2( pNewTableData->GetColumnIter( 0 ) ); + Int32Set_Impl::const_iterator aSttRow2( pNewTableData->GetRowIter( 0 ) ); + const SwFrm *pCellFrm2 = pNewTableData->GetCellAtPos( *aSttCol2, *aSttRow2, sal_False ); + + if(pCellFrm == pCellFrm2) + { + AccessibleTableModelChange aModelChange; + aModelChange.Type = AccessibleTableModelChangeType::UPDATE; + aModelChange.FirstRow = 0; + aModelChange.LastRow = mpTableData->GetRowCount() - 1; + aModelChange.FirstColumn = 0; + aModelChange.LastColumn = mpTableData->GetColumnCount() - 1; + + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED; + aEvent.NewValue <<= aModelChange; + + FireAccessibleEvent( aEvent ); + } + } + else + //-----IAccessibility2 Implementation 2009 FireTableChangeEvent( GetTableData() ); ClearTableData(); mpTableData = pNewTableData; @@ -1674,6 +1857,153 @@ void SAL_CALL SwAccessibleTable::deselectAccessibleChild( pCrsrShell->EndAction(); } +//IAccessibility2 Implementation 2009----- +void SwAccessibleTable::SetTableData(SwAccessibleTableData_Impl* mpNewTableData) +{ + mpTableData = mpNewTableData; +} + +sal_Int32 SAL_CALL SwAccessibleTable::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ + const SvxBrushItem &rBack = GetFrm()->GetAttrSet()->GetBackground(); + sal_uInt32 crBack = rBack.GetColor().GetColor(); + + if (COL_AUTO == crBack) + { + uno::Reference<XAccessible> xAccDoc = getAccessibleParent(); + if (xAccDoc.is()) + { + uno::Reference<XAccessibleComponent> xCompoentDoc(xAccDoc,uno::UNO_QUERY); + if (xCompoentDoc.is()) + { + crBack = (sal_uInt32)xCompoentDoc->getBackground(); + } + } + } + return crBack; +} + +void SwAccessibleTable::FireSelectionEvent( ) +{ + AccessibleEventObject aEvent; + + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; + +// int nRemove = m_vecCellRemove.size(); +// int nAdd = m_vecCellAdd.size(); + + VEC_CELL::iterator vi = m_vecCellRemove.begin(); + for (; vi != m_vecCellRemove.end() ; ++vi) + { + SwAccessibleContext *pAccCell = const_cast<SwAccessibleContext *>(*vi); + OSL_ASSERT(pAccCell != NULL ); + pAccCell->FireAccessibleEvent(aEvent); + } + + if (m_vecCellAdd.size() <= SELECTION_WITH_NUM) + { + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; + vi = m_vecCellAdd.begin(); + for (; vi != m_vecCellAdd.end() ; ++vi) + { + SwAccessibleContext *pAccCell = const_cast<SwAccessibleContext *>(*vi); + OSL_ASSERT(pAccCell != NULL ); + pAccCell->FireAccessibleEvent(aEvent); + } + return ; + } + else + { + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; + FireAccessibleEvent(aEvent); + } +} + +void SwAccessibleTable::ClearSelectionCellCache() +{ + m_vecCellAdd.clear(); + m_vecCellRemove.clear(); +} + +void SwAccessibleTable::AddSelectionCell(const SwAccessibleContext* pAccCell ,sal_Bool bAddOrRemove) +{ + if (bAddOrRemove) + { + m_vecCellAdd.push_back(pAccCell); + } + else + { + m_vecCellRemove.push_back(pAccCell); + } +} + +//===== XAccessibleTableSelection ============================================ +sal_Bool SAL_CALL SwAccessibleTable::selectRow( sal_Int32 row ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + if( isAccessibleColumnSelected( row ) ) + return sal_True; + + long lCol, lColumnCount, lChildIndex; + lColumnCount = getAccessibleColumnCount(); + for(lCol = 0; lCol < lColumnCount; lCol ++) + { + lChildIndex = getAccessibleIndex(row, lCol); + selectAccessibleChild(lChildIndex); + } + + return sal_True; +} +sal_Bool SAL_CALL SwAccessibleTable::selectColumn( sal_Int32 column ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + if( isAccessibleColumnSelected( column ) ) + return sal_True; + + long lRow, lRowCount, lChildIndex; + lRowCount = getAccessibleRowCount(); + + for(lRow = 0; lRow < lRowCount; lRow ++) + { + lChildIndex = getAccessibleIndex(lRow, column); + selectAccessibleChild(lChildIndex); + } + return sal_True; +} +sal_Bool SAL_CALL SwAccessibleTable::unselectRow( sal_Int32 row ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + if( isAccessibleSelected( row , 0 ) && isAccessibleSelected( row , getAccessibleColumnCount()-1 ) ) + { + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL ) + { + pCrsrShell->StartAction(); + pCrsrShell->ClearMark(); + pCrsrShell->EndAction(); + return sal_True; + } + } + return sal_True; +} +sal_Bool SAL_CALL SwAccessibleTable::unselectColumn( sal_Int32 column ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + if( isAccessibleSelected( 0 , column ) && isAccessibleSelected( getAccessibleRowCount()-1,column)) + { + SwCrsrShell* pCrsrShell = GetCrsrShell(); + if( pCrsrShell != NULL ) + { + pCrsrShell->StartAction(); + pCrsrShell->ClearMark(); + pCrsrShell->EndAction(); + return sal_True; + } + } + return sal_True; +} +//-----IAccessibility2 Implementation 2009 // --> OD 2007-06-28 #i77106# // implementation of class <SwAccessibleTableColHeaders> SwAccessibleTableColHeaders::SwAccessibleTableColHeaders( SwAccessibleMap *pMap2, diff --git a/sw/source/core/access/acctable.hxx b/sw/source/core/access/acctable.hxx index 3c68ac1868f0..908908b7b789 100644 --- a/sw/source/core/access/acctable.hxx +++ b/sw/source/core/access/acctable.hxx @@ -23,6 +23,12 @@ #ifndef _ACCTABLE_HXX #define _ACCTABLE_HXX #include <com/sun/star/accessibility/XAccessibleTable.hpp> +//IAccessibility2 Implementation 2009----- +#ifndef _COM_SUN_STAR_ACCESSIBILITY_XAccessibleTableSelection_HPP_ +#include <com/sun/star/accessibility/XAccessibleTableSelection.hpp> +#endif +#include <vector> +//-----IAccessibility2 Implementation 2009 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> #include <acccontext.hxx> @@ -40,6 +46,7 @@ class SwAccessibleTable : public SwAccessibleContext, public ::com::sun::star::accessibility::XAccessibleTable, public ::com::sun::star::accessibility::XAccessibleSelection, + public ::com::sun::star::accessibility::XAccessibleTableSelection, public SwClient { SwAccessibleTableData_Impl *mpTableData; // the table's data, prot by Sol-Mutex @@ -85,6 +92,9 @@ protected: // Is table data evailable? sal_Bool HasTableData() const { return (mpTableData != 0); } + //IAccessibility2 Implementation 2009----- + void SetTableData(SwAccessibleTableData_Impl* mpNewTableData) ; + //-----IAccessibility2 Implementation 2009 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew); public: @@ -187,7 +197,17 @@ public: virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - + //IAccessibility2 Implementation 2009----- + //===== XAccessibleTableSelection ============================================ + virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; + //-----IAccessibility2 Implementation 2009 //===== XServiceInfo ==================================================== /** Returns an identifier for the implementation of this object. @@ -254,6 +274,17 @@ public: throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); + //IAccessibility2 Implementation 2009----- + //===== XAccessibleComponent ============================================ + sal_Int32 SAL_CALL getBackground() + throw (::com::sun::star::uno::RuntimeException); + typedef std::vector<const SwAccessibleContext*> VEC_CELL; + VEC_CELL m_vecCellAdd; + VEC_CELL m_vecCellRemove; + void FireSelectionEvent( ); + void ClearSelectionCellCache(); + void AddSelectionCell(const SwAccessibleContext* ,sal_Bool bAddOrRemove); + //-----IAccessibility2 Implementation 2009 }; inline SwAccessibleTableData_Impl& SwAccessibleTable::GetTableData() diff --git a/sw/source/core/access/acctextframe.cxx b/sw/source/core/access/acctextframe.cxx index 893a45a8b4d0..0fedef797a63 100644 --- a/sw/source/core/access/acctextframe.cxx +++ b/sw/source/core/access/acctextframe.cxx @@ -44,6 +44,11 @@ // <-- #include "acctextframe.hxx" +//IAccessibility2 Implementation 2009----- +#ifndef _DOC_HXX +#include <doc.hxx> +#endif +//-----IAccessibility2 Implementation 2009 using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; @@ -152,6 +157,125 @@ void SwAccessibleTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * } } +//IAccessibility2 Implementation 2009----- +//===== XInterface ========================================================== + +com::sun::star::uno::Any SAL_CALL + SwAccessibleTextFrame::queryInterface (const com::sun::star::uno::Type & rType) + throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aReturn = SwAccessibleContext::queryInterface (rType); + if ( ! aReturn.hasValue()) + aReturn = ::cppu::queryInterface (rType, + static_cast< ::com::sun::star::accessibility::XAccessibleSelection* >(this) + ); + return aReturn; +} + + + + +void SAL_CALL + SwAccessibleTextFrame::acquire (void) + throw () +{ + SwAccessibleContext::acquire (); +} + +void SAL_CALL + SwAccessibleTextFrame::release (void) + throw () +{ + SwAccessibleContext::release (); +} + +// +//===== XAccessibleSelection ============================================ +// + +//-------------------------------------------------------------------------------- +void SAL_CALL SwAccessibleTextFrame::selectAccessibleChild( sal_Int32 ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + DBG_ASSERT( false, "<SwAccessibleTextFrame::selectAccessibleChild( sal_Int32 )> - missing implementation" ); +} + +//---------------------------------------------------------------------------------- +sal_Bool SAL_CALL SwAccessibleTextFrame::isAccessibleChildSelected( sal_Int32 nChildIndex ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + uno::Reference<XAccessible> xAcc = getAccessibleChild( nChildIndex ); + uno::Reference<XAccessibleContext> xContext; + if( xAcc.is() ) + xContext = xAcc->getAccessibleContext(); + + if( xContext.is() ) + { + if( xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) + { + uno::Reference< ::com::sun::star::accessibility::XAccessibleText > + xText(xAcc, uno::UNO_QUERY); + if( xText.is() ) + { + if( xText->getSelectionStart() >= 0 ) return sal_True; + } + } + } + + return sal_False; +} + +//--------------------------------------------------------------------- +void SAL_CALL SwAccessibleTextFrame::clearAccessibleSelection( ) + throw ( uno::RuntimeException ) +{ + DBG_ASSERT( false, "<SwAccessibleTextFrame::clearAccessibleSelection( )> - missing implementation" ); +} + +//------------------------------------------------------------------------- +void SAL_CALL SwAccessibleTextFrame::selectAllAccessibleChildren( ) + throw ( uno::RuntimeException ) +{ + DBG_ASSERT( false, "<SwAccessibleTextFrame::selectAllAccessibleChildren( )> - missing implementation" ); +} + +//---------------------------------------------------------------------------- +sal_Int32 SAL_CALL SwAccessibleTextFrame::getSelectedAccessibleChildCount() + throw ( uno::RuntimeException ) +{ + sal_Int32 nCount = 0; + sal_Int32 TotalCount = getAccessibleChildCount(); + for( sal_Int32 i = 0; i < TotalCount; i++ ) + if( isAccessibleChildSelected(i) ) nCount++; + + return nCount; +} + +//-------------------------------------------------------------------------------------- +uno::Reference<XAccessible> SAL_CALL SwAccessibleTextFrame::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + if ( nSelectedChildIndex > getSelectedAccessibleChildCount() ) + throw lang::IndexOutOfBoundsException(); + sal_Int32 i1, i2; + for( i1 = 0, i2 = 0; i1 < getAccessibleChildCount(); i1++ ) + if( isAccessibleChildSelected(i1) ) + { + if( i2 == nSelectedChildIndex ) + return getAccessibleChild( i1 ); + i2++; + } + return uno::Reference<XAccessible>(); +} + +//---------------------------------------------------------------------------------- +void SAL_CALL SwAccessibleTextFrame::deselectAccessibleChild( sal_Int32 ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + DBG_ASSERT( false, "<SwAccessibleTextFrame::selectAllAccessibleChildren( sal_Int32 )> - missing implementation" ); +} +//-----IAccessibility2 Implementation 2009 + // --> OD 2009-07-14 #i73249# OUString SAL_CALL SwAccessibleTextFrame::getAccessibleName (void) throw (uno::RuntimeException) @@ -168,15 +292,29 @@ OUString SAL_CALL SwAccessibleTextFrame::getAccessibleName (void) return SwAccessibleFrameBase::getAccessibleName(); } // <-- + OUString SAL_CALL SwAccessibleTextFrame::getAccessibleDescription (void) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleContext ) + /* MT: I guess msDesc is correct noadays? + //IAccessibility2 Implementation 2009----- + OUString longDesc; + const SwFlyFrmFmt* pFlyFmt = GetShell()->GetDoc()->FindFlyByName( GetName(), 0); + if( pFlyFmt ) + { + longDesc = OUString( pFlyFmt->GetDescription() ); + } + if( longDesc.getLength() > 0 ) + return GetName() + OUString(' ') + longDesc; + else + return GetName(); + //-----IAccessibility2 Implementation 2009 + */ return msDesc; - } OUString SAL_CALL SwAccessibleTextFrame::getImplementationName() diff --git a/sw/source/core/access/acctextframe.hxx b/sw/source/core/access/acctextframe.hxx index 0af8b806da89..0f51f82c5a26 100644 --- a/sw/source/core/access/acctextframe.hxx +++ b/sw/source/core/access/acctextframe.hxx @@ -24,13 +24,18 @@ #define _ACCTEXTFRAME_HXX #include "accframebase.hxx" +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +//-----IAccessibility2 Implementation 2009 + class SwFlyFrm; namespace utl { class AccessibleRelationSetHelper; } namespace com { namespace star { namespace accessibility { struct AccessibleRelation; } } } -class SwAccessibleTextFrame : public SwAccessibleFrameBase +class SwAccessibleTextFrame : public SwAccessibleFrameBase, + public ::com::sun::star::accessibility::XAccessibleSelection { private: // --> OD 2009-07-14 #i73249# @@ -48,6 +53,43 @@ public: SwAccessibleTextFrame( SwAccessibleMap* pInitMap, const SwFlyFrm* pFlyFrm ); + //IAccessibility2 Implementation 2009----- + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + ::com::sun::star::uno::Type const & rType ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + //===== XAccessibleSelection ============================================ + virtual void SAL_CALL selectAccessibleChild( + sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL isAccessibleChildSelected( + sal_Int32 nChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL clearAccessibleSelection( ) + throw ( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL selectAllAccessibleChildren( ) + throw ( ::com::sun::star::uno::RuntimeException ); + + virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) + throw ( ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL deselectAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException ); + //-----IAccessibility2 Implementation 2009 + //===== XAccessibleContext ============================================== // --> OD 2009-07-14 #i73249# diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 56eb9f0522df..3509bc4dfdb8 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -255,7 +255,9 @@ SwFmt::~SwFmt() } else { - while( GetDepends() ) + //IAccessibility2 Implementation 2009----- + while( GetDepends() && pParentFmt) + //-----IAccessibility2 Implementation 2009 { SwFmtChg aOldFmt(this); SwFmtChg aNewFmt(pParentFmt); diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 6a5d2e46e4c2..31dedef94112 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -315,7 +315,7 @@ SfxItemInfo __FAR_DATA aSlotTab[] = { 0, 0 }, // RES_TXTATR_CHARFMT { SID_ATTR_CHAR_CJK_RUBY, 0 }, // RES_TXTATR_CJK_RUBY { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_UNKNOWN_CONTAINER - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY5 + { 0, 0 }, // RES_TXTATR_INPUTFIELD { 0, 0 }, // RES_TXTATR_FIELD { 0, 0 }, // RES_TXTATR_FLYCNT @@ -528,8 +528,9 @@ void _InitCore() aAttrTab[ RES_TXTATR_CHARFMT- POOLATTR_BEGIN ] = new SwFmtCharFmt( 0 ); aAttrTab[ RES_TXTATR_CJK_RUBY - POOLATTR_BEGIN ] = new SwFmtRuby( aEmptyStr ); aAttrTab[ RES_TXTATR_UNKNOWN_CONTAINER - POOLATTR_BEGIN ] = new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER ); + aAttrTab[ RES_TXTATR_INPUTFIELD - POOLATTR_BEGIN ] = new SwFmtFld( RES_TXTATR_INPUTFIELD ); - aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld; + aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld( RES_TXTATR_FIELD ); aAttrTab[ RES_TXTATR_FLYCNT - POOLATTR_BEGIN ] = new SwFmtFlyCnt( 0 ); aAttrTab[ RES_TXTATR_FTN - POOLATTR_BEGIN ] = new SwFmtFtn; @@ -538,7 +539,6 @@ void _InitCore() aAttrTab[ RES_TXTATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY3 ); aAttrTab[ RES_TXTATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY1 ); aAttrTab[ RES_TXTATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY2 ); - aAttrTab[ RES_TXTATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY5 ); // TextAttr - Dummies aAttrTab[ RES_CHRATR_BIDIRTL - POOLATTR_BEGIN ] = new SfxInt16Item( RES_CHRATR_BIDIRTL, sal_Int16(-1) ); diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx index 3223d4139f81..b07fafbc0fc6 100644 --- a/sw/source/core/crsr/callnk.cxx +++ b/sw/source/core/crsr/callnk.cxx @@ -138,7 +138,7 @@ SwCallLink::~SwCallLink() for( n = 0; n < rHts.Count(); n++ ) { const SwTxtAttr* pHt = rHts[ n ]; - pEnd = pHt->GetEnd(); + pEnd = pHt->End(); nStart = *pHt->GetStart(); // nur Start oder Start und Ende gleich, dann immer diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 872d6569c819..992e1d22db0e 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -421,6 +421,66 @@ sal_Bool SwCrsrShell::LeftRight( sal_Bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMo } return bRet; } +//IAccessibility2 Implementation 2009----- +void SwCrsrShell::FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage) +{ +#ifdef ACCESSIBLE_LAYOUT + if( Imp()->IsAccessible() ) + Imp()->FirePageChangeEvent( nOldPage, nNewPage ); +#endif +} + +void SwCrsrShell::FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn) +{ +#ifdef ACCESSIBLE_LAYOUT + if( Imp()->IsAccessible() ) + Imp()->FireColumnChangeEvent( nOldColumn, nNewColumn); +#endif +} + + +void SwCrsrShell::FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection) +{ +#ifdef ACCESSIBLE_LAYOUT + if( Imp()->IsAccessible() ) + Imp()->FireSectionChangeEvent( nOldSection, nNewSection ); +#endif +} +bool SwCrsrShell::bColumnChange() +{ + + sal_uInt16 nCurrCol = 0; + SwFrm* pCurrFrm = GetCurrFrm(sal_False); + + if (pCurrFrm == NULL) + { + return sal_False; + } + + SwFrm* pCurrCol=((SwFrm*)pCurrFrm)->FindColFrm(); + + while(pCurrCol== NULL && pCurrFrm!=NULL ) + { + SwLayoutFrm* pParent = pCurrFrm->GetUpper(); + if(pParent!=NULL) + { + pCurrCol=((SwFrm*)pParent)->FindColFrm(); + pCurrFrm = (SwFrm*)pParent; + } + else + { + break; + } + } + if(oldColFrm == pCurrCol) + return sal_False; + else + { + oldColFrm = pCurrCol; + return sal_True; + } +} +//-----IAccessibility2 Implementation 2009 // --> OD 2008-04-02 #refactorlists# void SwCrsrShell::MarkListLevel( const String& sListId, @@ -899,8 +959,10 @@ void SwCrsrShell::SwapPam() // Ansonsten wird er auf die gewaehlte SSelection gesetzt. -sal_Bool SwCrsrShell::ChgCurrPam( const Point & rPt, - sal_Bool bTstOnly, sal_Bool bTstHit ) +sal_Bool SwCrsrShell::ChgCurrPam( + const Point & rPt, + sal_Bool bTstOnly, + sal_Bool bTstHit ) { SET_CURR_SHELL( this ); @@ -1351,9 +1413,7 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd ) return; // wenn nicht, dann kein Update !! } - // --> OD 2005-12-14 #i27301# SwNotifyAccAboutInvalidTextSelections aInvalidateTextSelections( *this ); - // <-- if ( bIgnoreReadonly ) { @@ -2086,6 +2146,7 @@ void SwCrsrShell::ShowCrsr() if( !bBasicHideCrsr ) { bSVCrsrVis = sal_True; + pCurCrsr->SetShowTxtInputFldOverlay( true ); UpdateCrsr(); } } @@ -2098,6 +2159,7 @@ void SwCrsrShell::HideCrsr() bSVCrsrVis = sal_False; // evt. die sel. Bereiche aufheben !! SET_CURR_SHELL( this ); + pCurCrsr->SetShowTxtInputFldOverlay( false ); pVisCrsr->Hide(); } } @@ -2599,6 +2661,9 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) // UpdateCrsr( 0 ); // OD 11.02.2003 #100556# mbMacroExecAllowed = rShell.IsMacroExecAllowed(); + //IAccessibility2 Implementation 2009----- + oldColFrm = NULL; + //-----IAccessibility2 Implementation 2009 } @@ -2936,38 +3001,34 @@ sal_Bool SwCrsrShell::FindValidCntntNode( sal_Bool bOnlyText ) } -void SwCrsrShell::NewCoreSelection() -{ -} - - sal_Bool SwCrsrShell::IsCrsrReadonly() const { if ( GetViewOptions()->IsReadonly() || - // --> FME 2004-06-29 #114856# Formular view - GetViewOptions()->IsFormView() ) - // <-- + GetViewOptions()->IsFormView() ) // Formular view { SwFrm *pFrm = GetCurrFrm( sal_False ); const SwFlyFrm* pFly; const SwSection* pSection; if( pFrm && pFrm->IsInFly() && - (pFly = pFrm->FindFlyFrm())->GetFmt()->GetEditInReadonly().GetValue() && - pFly->Lower() && - !pFly->Lower()->IsNoTxtFrm() && - !GetDrawView()->areSdrObjectsSelected() ) + (pFly = pFrm->FindFlyFrm())->GetFmt()->GetEditInReadonly().GetValue() && + pFly->Lower() && + !pFly->Lower()->IsNoTxtFrm() && + !GetDrawView()->areSdrObjectsSelected() ) { return sal_False; } - // --> FME 2004-06-22 #114856# edit in readonly sections + // edit in readonly sections else if ( pFrm && pFrm->IsInSct() && - 0 != ( pSection = pFrm->FindSctFrm()->GetSection() ) && - pSection->IsEditInReadonlyFlag() ) + 0 != ( pSection = pFrm->FindSctFrm()->GetSection() ) && + pSection->IsEditInReadonlyFlag() ) + { + return sal_False; + } + else if ( !IsMultiSelection() && CrsrInsideInputFld() ) { return sal_False; } - // <-- return sal_True; } diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index c27ec28cd874..34f06860285b 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -40,7 +40,7 @@ #include <pam.hxx> #include <ndtxt.hxx> #include <fldbas.hxx> -#include <swtable.hxx> // SwTxtFld +#include <swtable.hxx> #include <docary.hxx> #include <txtfld.hxx> #include <fmtfld.hxx> @@ -56,7 +56,7 @@ #include <docfld.hxx> #include <expfld.hxx> #include <reffld.hxx> -#include <flddat.hxx> // SwTxtFld +#include <flddat.hxx> #include <cellatr.hxx> #include <swundo.hxx> #include <redline.hxx> @@ -619,73 +619,84 @@ const SwTOXMark& SwCrsrShell::GotoTOXMark( const SwTOXMark& rStart, // springe zum naechsten / vorherigen FeldTypen -void lcl_MakeFldLst( _SetGetExpFlds& rLst, const SwFieldType& rFldType, - sal_uInt16 nSubType, sal_Bool bInReadOnly, - sal_Bool bChkInpFlag = sal_False ) +void lcl_MakeFldLst( + _SetGetExpFlds& rLst, + const SwFieldType& rFldType, + const bool bInReadOnly, + const bool bChkInpFlag = false ) { // es muss immer der 1. Frame gesucht werden Point aPt; - SwTxtFld* pTxtFld; + SwTxtFld* pTxtFld = NULL; SwIterator<SwFmtFld,SwFieldType> aIter(rFldType); - bool bSubType = nSubType != USHRT_MAX; for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() ) - if( 0 != ( pTxtFld = pFmtFld->GetTxtFld() ) && - ( !bChkInpFlag || ((SwSetExpField*)pTxtFld->GetFmtFld().GetField()) - ->GetInputFlag() ) && - (!bSubType || (pFmtFld->GetField()->GetSubType() - & 0xff ) == nSubType )) + { + pTxtFld = pFmtFld->GetTxtFld(); + if ( pTxtFld != NULL + && ( !bChkInpFlag + || ((SwSetExpField*)pTxtFld->GetFmtFld().GetField())->GetInputFlag() ) ) { - SwCntntFrm* pCFrm; const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode(); - if( 0 != ( pCFrm = rTxtNode.getLayoutFrm( rTxtNode.GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False )) && - ( bInReadOnly || !pCFrm->IsProtected() )) + const SwCntntFrm* pCFrm = + rTxtNode.getLayoutFrm( rTxtNode.GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False ); + if ( pCFrm != NULL + && ( bInReadOnly || !pCFrm->IsProtected() ) ) { - _SetGetExpFld* pNew = new _SetGetExpFld( - SwNodeIndex( rTxtNode ), pTxtFld ); + _SetGetExpFld* pNew = new _SetGetExpFld( SwNodeIndex( rTxtNode ), pTxtFld ); pNew->SetBodyPos( *pCFrm ); rLst.Insert( pNew ); } } + } } -sal_Bool SwCrsrShell::MoveFldType( const SwFieldType* pFldType, sal_Bool bNext, - sal_uInt16 nSubType, sal_uInt16 nResType ) +sal_Bool SwCrsrShell::MoveFldType( + const SwFieldType* pFldType, + const bool bNext, + const sal_uInt16 nResType, + const bool bAddSetExpressionFldsToInputFlds ) { // sortierte Liste aller Felder _SetGetExpFlds aSrtLst( 64 ); - if (pFldType) + if ( pFldType ) { if( RES_INPUTFLD != pFldType->Which() && !pFldType->GetDepends() ) + { return sal_False; + } // Modify-Object gefunden, trage alle Felder ins Array ein - ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType, IsReadOnlyAvailable() ); + ::lcl_MakeFldLst( aSrtLst, *pFldType, ( IsReadOnlyAvailable() ? true : false ) ); - if( RES_INPUTFLD == pFldType->Which() ) + if( RES_INPUTFLD == pFldType->Which() && bAddSetExpressionFldsToInputFlds ) { // es gibt noch versteckte InputFelder in den SetExp. Feldern const SwFldTypes& rFldTypes = *pDoc->GetFldTypes(); const sal_uInt16 nSize = rFldTypes.Count(); - - // Alle Typen abklappern for( sal_uInt16 i=0; i < nSize; ++i ) - if( RES_SETEXPFLD == ( pFldType = rFldTypes[ i ] )->Which() ) - ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType, - IsReadOnlyAvailable(), sal_True ); + { + pFldType = rFldTypes[ i ]; + if ( RES_SETEXPFLD == pFldType->Which() ) + { + ::lcl_MakeFldLst( aSrtLst, *pFldType, ( IsReadOnlyAvailable() ? true : false ), true ); + } + } } } else { const SwFldTypes& rFldTypes = *pDoc->GetFldTypes(); const sal_uInt16 nSize = rFldTypes.Count(); - - // Alle Typen abklappern for( sal_uInt16 i=0; i < nSize; ++i ) - if( nResType == ( pFldType = rFldTypes[ i ] )->Which() ) - ::lcl_MakeFldLst( aSrtLst, *pFldType, nSubType, - IsReadOnlyAvailable() ); + { + pFldType = rFldTypes[ i ]; + if( nResType == pFldType->Which() ) + { + ::lcl_MakeFldLst( aSrtLst, *pFldType, ( IsReadOnlyAvailable() ? true : false ) ); + } + } } // keine Felder gefunden? @@ -704,12 +715,11 @@ sal_Bool SwCrsrShell::MoveFldType( const SwFieldType* pFldType, sal_Bool bNext, SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode(); ASSERT( pTNd, "Wo ist mein CntntNode?" ); - SwTxtFld * pTxtFld = static_cast<SwTxtFld *>( - pTNd->GetTxtAttrForCharAt(rPos.nContent.GetIndex(), - RES_TXTATR_FIELD)); - sal_Bool bDelFld = 0 == pTxtFld; + SwTxtFld * pTxtFld = pTNd->GetFldTxtAttrAt( rPos.nContent.GetIndex(), true ); + const bool bDelFld = ( pTxtFld == NULL ); if( bDelFld ) { + // create dummy for the search SwFmtFld* pFmtFld = new SwFmtFld( SwDateTimeField( (SwDateTimeFieldType*)pDoc->GetSysFldType( RES_DATETIMEFLD ) ) ); @@ -717,7 +727,12 @@ sal_Bool SwCrsrShell::MoveFldType( const SwFieldType* pFldType, sal_Bool bNext, pTxtFld->ChgTxtNode( pTNd ); } - _SetGetExpFld aSrch( rPos.nNode, pTxtFld, &rPos.nContent ); + SwIndex aSearchIdx( rPos.nContent ); + if ( !bDelFld && pTxtFld->HasContent() ) + { + aSearchIdx = *(pTxtFld->GetStart()); + } + _SetGetExpFld aSrch( rPos.nNode, pTxtFld, &aSearchIdx ); if( rPos.nNode.GetIndex() < pDoc->GetNodes().GetEndOfExtras().GetIndex() ) { // auch beim Einsammeln wird nur der erste Frame benutzt! @@ -743,7 +758,9 @@ sal_Bool SwCrsrShell::MoveFldType( const SwFieldType* pFldType, sal_Bool bNext, return sal_False; // weiter nach vorne geht nicht } else if( bNext ? nPos >= aSrtLst.Count() : !nPos--) + { return sal_False; + } } const _SetGetExpFld& rFnd = **( aSrtLst.GetData() + nPos ); @@ -784,6 +801,128 @@ sal_Bool SwCrsrShell::GotoFld( const SwFmtFld& rFld ) } +SwTxtFld * SwCrsrShell::GetTxtFldAtPos( + const SwPosition* pPos, + const bool bIncludeInputFldAtStart ) const +{ + SwTxtFld* pTxtFld = NULL; + + SwTxtNode * const pNode = pPos->nNode.GetNode().GetTxtNode(); + if ( pNode != NULL ) + { + pTxtFld = pNode->GetFldTxtAttrAt( pPos->nContent.GetIndex(), bIncludeInputFldAtStart ); + } + + return pTxtFld; +} + + +SwField* SwCrsrShell::GetFieldAtCrsr( + const SwPaM* pCrsr, + const bool bIncludeInputFldAtStart ) const +{ + SwField* pFieldAtCrsr = NULL; + + SwTxtFld* pTxtFld = GetTxtFldAtPos( pCrsr->Start(), bIncludeInputFldAtStart ); + if ( pTxtFld != NULL + && pCrsr->Start()->nNode == pCrsr->End()->nNode ) + { + const xub_StrLen nTxtFldLength = + pTxtFld->End() != NULL + ? *(pTxtFld->End()) - *(pTxtFld->GetStart()) + : 1; + if ( ( pCrsr->End()->nContent.GetIndex() - pCrsr->Start()->nContent.GetIndex() ) <= nTxtFldLength ) + { + pFieldAtCrsr = (SwField*)pTxtFld->GetFmtFld().GetField(); + } + } + + return pFieldAtCrsr; +} + + +SwField* SwCrsrShell::GetCurFld( const bool bIncludeInputFldAtStart ) const +{ + SwPaM* pCrsr = GetCrsr(); + if ( pCrsr->GetNext() != pCrsr ) + { + // multi selection not handled. + return NULL; + } + + SwField* pCurFld = GetFieldAtCrsr( pCrsr, bIncludeInputFldAtStart );; + if ( pCurFld != NULL + && RES_TABLEFLD == pCurFld->GetTyp()->Which() ) + { + // TabellenFormel ? wandel internen in externen Namen um + const SwTableNode* pTblNd = IsCrsrInTbl(); + ((SwTblField*)pCurFld)->PtrToBoxNm( pTblNd ? &pTblNd->GetTable() : 0 ); + } + + return pCurFld; +} + + +bool SwCrsrShell::CrsrInsideInputFld() const +{ + bool bCrsrInsideInputFld = false; + + const SwPaM* pCrsr = GetCrsr(); + const SwPaM* pFirst = pCrsr; + do + { + bCrsrInsideInputFld = dynamic_cast<const SwInputField*>(GetFieldAtCrsr( pCrsr, false )) != NULL; + + pCrsr = static_cast<SwPaM*>(pCrsr->GetNext()); + } while ( !bCrsrInsideInputFld + && pCrsr != pFirst ); + + return bCrsrInsideInputFld; +} + + +bool SwCrsrShell::PosInsideInputFld( const SwPosition& rPos ) const +{ + return dynamic_cast<const SwTxtInputFld*>(GetTxtFldAtPos( &rPos, false )) != NULL; +} + + +bool SwCrsrShell::DocPtInsideInputFld( const Point& rDocPt ) const +{ + SwPosition aPos( *(GetCrsr()->Start()) ); + Point aDocPt( rDocPt ); + if ( GetLayout()->GetCrsrOfst( &aPos, aDocPt ) ) + { + return PosInsideInputFld( aPos ); + } + return false; +} + + +xub_StrLen SwCrsrShell::StartOfInputFldAtPos( const SwPosition& rPos ) const +{ + const SwTxtInputFld* pTxtInputFld = dynamic_cast<const SwTxtInputFld*>(GetTxtFldAtPos( &rPos, true )); + if ( pTxtInputFld == NULL ) + { + ASSERT( false, "<SwEditShell::StartOfInputFldAtPos(..)> - no Input Field at given position" ); + return 0; + } + return *(pTxtInputFld->GetStart()); +} + + +xub_StrLen SwCrsrShell::EndOfInputFldAtPos( const SwPosition& rPos ) const +{ + const SwTxtInputFld* pTxtInputFld = dynamic_cast<const SwTxtInputFld*>(GetTxtFldAtPos( &rPos, true )); + if ( pTxtInputFld == NULL ) + { + ASSERT( false, "<SwEditShell::EndOfInputFldAtPos(..)> - no Input Field at given position" ); + return 0; + } + return *(pTxtInputFld->End()); +} + + void SwCrsrShell::GotoOutline( sal_uInt16 nIdx ) { SwCursor* pCrsr = getShellCrsr( true ); @@ -1029,7 +1168,8 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, pTxtNd = aPos.nNode.GetNode().GetTxtNode(); const SwNodes& rNds = GetDoc()->GetNodes(); - if( pTxtNd && SwContentAtPos::SW_OUTLINE & rCntntAtPos.eCntntAtPos + if( pTxtNd + && SwContentAtPos::SW_OUTLINE & rCntntAtPos.eCntntAtPos && rNds.GetOutLineNds().Count() ) { const SwTxtNode* pONd = pTxtNd->FindOutlineNodeOfLevel( MAXLEVEL-1); @@ -1040,16 +1180,13 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, bRet = sal_True; } } - // --> FME 2005-05-13 #i43742# New function: SW_CONTENT_CHECK - else if ( SwContentAtPos::SW_CONTENT_CHECK & rCntntAtPos.eCntntAtPos && - bCrsrFoundExact ) + else if ( SwContentAtPos::SW_CONTENT_CHECK & rCntntAtPos.eCntntAtPos + && bCrsrFoundExact ) { bRet = sal_True; } - // <-- - // #i23726# - else if( pTxtNd && - SwContentAtPos::SW_NUMLABEL & rCntntAtPos.eCntntAtPos) + else if( pTxtNd + && SwContentAtPos::SW_NUMLABEL & rCntntAtPos.eCntntAtPos) { bRet = aTmpState.bInNumPortion; rCntntAtPos.aFnd.pNode = pTxtNd; @@ -1062,8 +1199,9 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, { if( !aTmpState.bPosCorr ) { - if( !bRet && SwContentAtPos::SW_SMARTTAG & rCntntAtPos.eCntntAtPos - && !aTmpState.bFtnNoInfo ) + if ( !bRet + && SwContentAtPos::SW_SMARTTAG & rCntntAtPos.eCntntAtPos + && !aTmpState.bFtnNoInfo ) { const SwWrongList* pSmartTagList = pTxtNd->GetSmartTags(); xub_StrLen nCurrent = aPos.nContent.GetIndex(); @@ -1090,22 +1228,14 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen pCurCrsr->DeleteMark(); *pCurCrsr->GetPoint() = aPos; - if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | - nsSwCursorSelOverFlags::SELOVER_TOGGLE) ) + if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | nsSwCursorSelOverFlags::SELOVER_TOGGLE) ) bRet = sal_False; else UpdateCrsr(); } if( bRet ) { -// rCntntAtPos.sStr = pTxtNd->GetExpandTxt( -// *pTxtAttr->GetStart(), -// *pTxtAttr->GetEnd() - *pTxtAttr->GetStart(), -// sal_False ); - -// rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr(); rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_SMARTTAG; -// rCntntAtPos.pFndTxtAttr = pTxtAttr; if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) ) pFrm->GetCharRect( *pFldRect, aPos, &aTmpState ); @@ -1113,19 +1243,21 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, } } - if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD ) - & rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo ) + if ( !bRet + && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD ) & rCntntAtPos.eCntntAtPos + && !aTmpState.bFtnNoInfo ) { - pTxtAttr = pTxtNd->GetTxtAttrForCharAt( - aPos.nContent.GetIndex(), RES_TXTATR_FIELD ); - const SwField* pFld = pTxtAttr - ? pTxtAttr->GetFmtFld().GetField() - : 0; - if( SwContentAtPos::SW_CLICKFIELD & rCntntAtPos.eCntntAtPos && - pFld && !pFld->HasClickHdl() ) + pTxtAttr = pTxtNd->GetFldTxtAttrAt( aPos.nContent.GetIndex() ); + const SwField* pFld = pTxtAttr != NULL + ? pTxtAttr->GetFmtFld().GetField() + : 0; + if ( SwContentAtPos::SW_CLICKFIELD & rCntntAtPos.eCntntAtPos + && pFld && !pFld->HasClickHdl() ) + { pFld = 0; + } - if( pFld ) + if ( pFld ) { if( pFldRect && 0 != ( pFrm = pTxtNd->getLayoutFrm( GetLayout(), &aPt ) ) ) pFrm->GetCharRect( *pFldRect, aPos, &aTmpState ); @@ -1141,14 +1273,14 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, // Click-Felder in geschuetzten Bereichen zulassen // Nur Platzhalter geht nicht! if( SwContentAtPos::SW_FIELD & rCntntAtPos.eCntntAtPos - || RES_JUMPEDITFLD == pFld->Which() ) + || RES_JUMPEDITFLD == pFld->Which() ) pFld = 0; } else UpdateCrsr(); } else if( RES_TABLEFLD == pFld->Which() && - ((SwTblField*)pFld)->IsIntrnlName() ) + ((SwTblField*)pFld)->IsIntrnlName() ) { // erzeuge aus der internen (fuer CORE) // die externe (fuer UI) Formel @@ -1167,16 +1299,16 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, } } - if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos ) - { - IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( ); - sw::mark::IFieldmark* pFldBookmark = pMarksAccess->getFieldmarkFor( aPos ); - if( bCrsrFoundExact && pTxtNd && pFldBookmark) { - rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL; - rCntntAtPos.aFnd.pFldmark = pFldBookmark; - bRet=sal_True; - } - } + if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos ) + { + IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( ); + sw::mark::IFieldmark* pFldBookmark = pMarksAccess->getFieldmarkFor( aPos ); + if( bCrsrFoundExact && pTxtNd && pFldBookmark) { + rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL; + rCntntAtPos.aFnd.pFldmark = pFldBookmark; + bRet=sal_True; + } + } if( !bRet && SwContentAtPos::SW_FTN & rCntntAtPos.eCntntAtPos ) { @@ -1194,7 +1326,7 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN; } else if ( 0 != ( pTxtAttr = pTxtNd->GetTxtAttrForCharAt( - aPos.nContent.GetIndex(), RES_TXTATR_FTN )) ) + aPos.nContent.GetIndex(), RES_TXTATR_FTN )) ) { bRet = sal_True; if( bSetCrsr ) @@ -1203,14 +1335,14 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, SwCrsrSaveState aSaveState( *pCurCrsr ); pCurCrsr->GetPoint()->nNode = *((SwTxtFtn*)pTxtAttr)->GetStartNode(); SwCntntNode* pCNd = GetDoc()->GetNodes().GoNextSection( - &pCurCrsr->GetPoint()->nNode, - sal_True, !IsReadOnlyAvailable() ); + &pCurCrsr->GetPoint()->nNode, + sal_True, !IsReadOnlyAvailable() ); if( pCNd ) { pCurCrsr->GetPoint()->nContent.Assign( pCNd, 0 ); if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | - nsSwCursorSelOverFlags::SELOVER_TOGGLE )) + nsSwCursorSelOverFlags::SELOVER_TOGGLE )) bRet = sal_False; else UpdateCrsr(); @@ -1231,9 +1363,9 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, } } - if( !bRet && ( SwContentAtPos::SW_TOXMARK | - SwContentAtPos::SW_REFMARK ) & - rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo ) + if( !bRet + && ( SwContentAtPos::SW_TOXMARK | SwContentAtPos::SW_REFMARK ) & rCntntAtPos.eCntntAtPos + && !aTmpState.bFtnNoInfo ) { pTxtAttr = 0; if( SwContentAtPos::SW_TOXMARK & rCntntAtPos.eCntntAtPos ) @@ -1268,8 +1400,7 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, SwCrsrSaveState aSaveState( *pCurCrsr ); pCurCrsr->DeleteMark(); *pCurCrsr->GetPoint() = aPos; - if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | - nsSwCursorSelOverFlags::SELOVER_TOGGLE ) ) + if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | nsSwCursorSelOverFlags::SELOVER_TOGGLE ) ) bRet = sal_False; else UpdateCrsr(); @@ -1277,19 +1408,18 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, if( bRet ) { - const xub_StrLen* pEnd = pTxtAttr->GetEnd(); + const xub_StrLen* pEnd = pTxtAttr->End(); if( pEnd ) - rCntntAtPos.sStr = pTxtNd->GetExpandTxt( - *pTxtAttr->GetStart(), - *pEnd - *pTxtAttr->GetStart() ); + rCntntAtPos.sStr = + pTxtNd->GetExpandTxt( *pTxtAttr->GetStart(), *pEnd - *pTxtAttr->GetStart() ); else if( RES_TXTATR_TOXMARK == pTxtAttr->Which()) - rCntntAtPos.sStr = pTxtAttr->GetTOXMark(). - GetAlternativeText(); + rCntntAtPos.sStr = + pTxtAttr->GetTOXMark().GetAlternativeText(); rCntntAtPos.eCntntAtPos = RES_TXTATR_TOXMARK == pTxtAttr->Which() - ? SwContentAtPos::SW_TOXMARK - : SwContentAtPos::SW_REFMARK; + ? SwContentAtPos::SW_TOXMARK + : SwContentAtPos::SW_REFMARK; rCntntAtPos.pFndTxtAttr = pTxtAttr; rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr(); @@ -1299,8 +1429,9 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, } } - if( !bRet && SwContentAtPos::SW_INETATTR & rCntntAtPos.eCntntAtPos - && !aTmpState.bFtnNoInfo ) + if ( !bRet + && SwContentAtPos::SW_INETATTR & rCntntAtPos.eCntntAtPos + && !aTmpState.bFtnNoInfo ) { pTxtAttr = pTxtNd->GetTxtAttrAt( aPos.nContent.GetIndex(), RES_TXTATR_INETFMT); @@ -1315,7 +1446,7 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, pCurCrsr->DeleteMark(); *pCurCrsr->GetPoint() = aPos; if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | - nsSwCursorSelOverFlags::SELOVER_TOGGLE) ) + nsSwCursorSelOverFlags::SELOVER_TOGGLE) ) bRet = sal_False; else UpdateCrsr(); @@ -1323,8 +1454,8 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, if( bRet ) { rCntntAtPos.sStr = pTxtNd->GetExpandTxt( - *pTxtAttr->GetStart(), - *pTxtAttr->GetEnd() - *pTxtAttr->GetStart() ); + *pTxtAttr->GetStart(), + *pTxtAttr->GetEnd() - *pTxtAttr->GetStart() ); rCntntAtPos.aFnd.pAttr = &pTxtAttr->GetAttr(); rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_INETATTR; @@ -1352,12 +1483,12 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, } } - if( !bRet && ( - SwContentAtPos::SW_TABLEBOXFML & rCntntAtPos.eCntntAtPos + if( !bRet + && ( SwContentAtPos::SW_TABLEBOXFML & rCntntAtPos.eCntntAtPos #ifdef DBG_UTIL - || SwContentAtPos::SW_TABLEBOXVALUE & rCntntAtPos.eCntntAtPos + || SwContentAtPos::SW_TABLEBOXVALUE & rCntntAtPos.eCntntAtPos #endif - )) + ) ) { const SwTableNode* pTblNd; const SwTableBox* pBox; @@ -1365,15 +1496,15 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, const SfxPoolItem* pItem; if( pSttNd && 0 != ( pTblNd = pTxtNd->FindTableNode()) && 0 != ( pBox = pTblNd->GetTable().GetTblBox( - pSttNd->GetIndex() )) && + pSttNd->GetIndex() )) && #ifdef DBG_UTIL ( SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState( - RES_BOXATR_FORMULA, sal_False, &pItem ) || - SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState( - RES_BOXATR_VALUE, sal_False, &pItem )) + RES_BOXATR_FORMULA, sal_False, &pItem ) || + SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState( + RES_BOXATR_VALUE, sal_False, &pItem )) #else SFX_ITEM_SET == pBox->GetFrmFmt()->GetItemState( - RES_BOXATR_FORMULA, sal_False, &pItem ) + RES_BOXATR_FORMULA, sal_False, &pItem ) #endif ) { @@ -1405,7 +1536,7 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_TABLEBOXVALUE; else #endif - ((SwTblBoxFormula*)pItem)->PtrToBoxNm( &pTblNd->GetTable() ); + ((SwTblBoxFormula*)pItem)->PtrToBoxNm( &pTblNd->GetTable() ); bRet = sal_True; if( bSetCrsr ) @@ -1414,7 +1545,7 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, SwCrsrSaveState aSaveState( *pCurCrsr ); *pCurCrsr->GetPoint() = aPos; if( pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION | - nsSwCursorSelOverFlags::SELOVER_TOGGLE) ) + nsSwCursorSelOverFlags::SELOVER_TOGGLE) ) bRet = sal_False; else UpdateCrsr(); @@ -1439,7 +1570,7 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, { xub_StrLen n = aPos.nContent.GetIndex(); SfxItemSet aSet( GetDoc()->GetAttrPool(), POOLATTR_BEGIN, - POOLATTR_END - 1 ); + POOLATTR_END - 1 ); if( pTxtNd->GetpSwpHints() ) { for( sal_uInt16 i = 0; i < pTxtNd->GetSwpHints().Count(); ++i ) @@ -1449,12 +1580,12 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, if( nAttrStart > n ) // ueber den Bereich hinaus break; - if( 0 != pHt->GetEnd() && ( + if( 0 != pHt->End() && ( ( nAttrStart < n && - ( pHt->DontExpand() ? n < *pHt->GetEnd() - : n <= *pHt->GetEnd() )) || + ( pHt->DontExpand() ? n < *pHt->End() + : n <= *pHt->End() )) || ( n == nAttrStart && - ( nAttrStart == *pHt->GetEnd() || !n ))) ) + ( nAttrStart == *pHt->End() || !n ))) ) { aSet.Put( pHt->GetAttr() ); } @@ -1473,18 +1604,18 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, pTxtNd->SwCntntNode::GetAttr( aSet ); rCntntAtPos.sStr.AssignAscii( - RTL_CONSTASCII_STRINGPARAM( "Pos: (" )); + RTL_CONSTASCII_STRINGPARAM( "Pos: (" )); rCntntAtPos.sStr += String::CreateFromInt32( aPos.nNode.GetIndex()); rCntntAtPos.sStr += ':'; rCntntAtPos.sStr += String::CreateFromInt32( aPos.nContent.GetIndex()); rCntntAtPos.sStr += ')'; rCntntAtPos.sStr.AppendAscii( - RTL_CONSTASCII_STRINGPARAM( "\nAbs.Vorl.: " )); + RTL_CONSTASCII_STRINGPARAM( "\nAbs.Vorl.: " )); rCntntAtPos.sStr += pTxtNd->GetFmtColl()->GetName(); if( pTxtNd->GetCondFmtColl() ) rCntntAtPos.sStr.AppendAscii( - RTL_CONSTASCII_STRINGPARAM( "\nBed.Vorl.: " )) - += pTxtNd->GetCondFmtColl()->GetName(); + RTL_CONSTASCII_STRINGPARAM( "\nBed.Vorl.: " )) + += pTxtNd->GetCondFmtColl()->GetName(); if( aSet.Count() ) { @@ -1497,11 +1628,11 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, { String aStr; GetDoc()->GetAttrPool().GetPresentation( *pItem, - SFX_ITEM_PRESENTATION_COMPLETE, - SFX_MAPUNIT_CM, aStr ); + SFX_ITEM_PRESENTATION_COMPLETE, + SFX_MAPUNIT_CM, aStr ); if( sAttrs.Len() ) sAttrs.AppendAscii( - RTL_CONSTASCII_STRINGPARAM( ", " )); + RTL_CONSTASCII_STRINGPARAM( ", " )); sAttrs += aStr; } if( aIter.IsAtEnd() ) @@ -1513,8 +1644,8 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, if( rCntntAtPos.sStr.Len() ) rCntntAtPos.sStr += '\n'; rCntntAtPos.sStr.AppendAscii( - RTL_CONSTASCII_STRINGPARAM( "Attr: " ) ) - += sAttrs; + RTL_CONSTASCII_STRINGPARAM( "Attr: " ) ) + += sAttrs; } } bRet = sal_True; @@ -1532,7 +1663,6 @@ sal_Bool SwCrsrShell::GetContentAtPos( const Point& rPt, return bRet; } -// --> OD 2008-06-19 #i90516# const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const { const SwPostItField* pPostItFld = 0; @@ -1543,9 +1673,8 @@ const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const const SwTxtNode* pTxtNd = pCursorPos->nNode.GetNode().GetTxtNode(); if ( pTxtNd ) { - SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt( - pCursorPos->nContent.GetIndex(), RES_TXTATR_FIELD ); - const SwField* pFld = pTxtAttr ? pTxtAttr->GetFmtFld().GetField() : 0; + SwTxtAttr* pTxtAttr = pTxtNd->GetFldTxtAttrAt( pCursorPos->nContent.GetIndex() ); + const SwField* pFld = pTxtAttr != NULL ? pTxtAttr->GetFmtFld().GetField() : 0; if ( pFld && pFld->Which()== RES_POSTITFLD ) { pPostItFld = static_cast<const SwPostItField*>(pFld); @@ -1555,7 +1684,6 @@ const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const return pPostItFld; } -// <-- // befindet sich der Node in einem geschuetzten Bereich? sal_Bool SwContentAtPos::IsInProtectSect() const @@ -1624,17 +1752,44 @@ bool SwContentAtPos::IsInRTLText()const return bRet; } -sal_Bool SwCrsrShell::SelectTxtAttr( sal_uInt16 nWhich, sal_Bool bExpand, - const SwTxtAttr* pTxtAttr ) + +sal_Bool SwCrsrShell::SelectTxt( const xub_StrLen nStart, + const xub_StrLen nEnd ) +{ + SET_CURR_SHELL( this ); + sal_Bool bRet = sal_False; + + SwCallLink aLk( *this ); + SwCrsrSaveState aSaveState( *pCurCrsr ); + + SwPosition& rPos = *pCurCrsr->GetPoint(); + pCurCrsr->DeleteMark(); + rPos.nContent = nStart; + pCurCrsr->SetMark(); + rPos.nContent = nEnd; + + if( !pCurCrsr->IsSelOvr() ) + { + UpdateCrsr(); + bRet = sal_True; + } + + return bRet; +} + + +sal_Bool SwCrsrShell::SelectTxtAttr( sal_uInt16 nWhich, + sal_Bool bExpand, + const SwTxtAttr* pTxtAttr ) { SET_CURR_SHELL( this ); sal_Bool bRet = sal_False; if( !IsTableMode() ) { - SwPosition& rPos = *pCurCrsr->GetPoint(); if( !pTxtAttr ) { + SwPosition& rPos = *pCurCrsr->GetPoint(); SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode(); pTxtAttr = (pTxtNd) ? pTxtNd->GetTxtAttrAt(rPos.nContent.GetIndex(), @@ -1645,20 +1800,8 @@ sal_Bool SwCrsrShell::SelectTxtAttr( sal_uInt16 nWhich, sal_Bool bExpand, if( pTxtAttr ) { - SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, - SwCrsrSaveState aSaveState( *pCurCrsr ); - - pCurCrsr->DeleteMark(); - rPos.nContent = *pTxtAttr->GetStart(); - pCurCrsr->SetMark(); - const xub_StrLen* pEnd = pTxtAttr->GetEnd(); - rPos.nContent = pEnd ? *pEnd : *pTxtAttr->GetStart() + 1; - - if( !pCurCrsr->IsSelOvr() ) - { - UpdateCrsr(); - bRet = sal_True; - } + const xub_StrLen* pEnd = pTxtAttr->End(); + bRet = SelectTxt( *pTxtAttr->GetStart(), ( pEnd ? *pEnd : *pTxtAttr->GetStart() + 1 ) ); } } return bRet; @@ -2177,7 +2320,7 @@ sal_Bool SwCrsrShell::SelectNxtPrvHyperlink( sal_Bool bNext ) aCmpPos.GetPosOfContent( *pCurCrsr->GetPoint() ); pCurCrsr->DeleteMark(); pCurCrsr->SetMark(); - pCurCrsr->GetPoint()->nContent = *pFndAttr->SwTxtAttr::GetEnd(); + pCurCrsr->GetPoint()->nContent = *pFndAttr->End(); if( !pCurCrsr->IsInProtectTable() && !pCurCrsr->IsSelOvr() ) { diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 9d2c2f1697ef..09c3e4da7c8e 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -154,7 +154,7 @@ sal_Bool lcl_Search( const SwTxtNode& rTxtNd, SwPaM& rPam, if( pTxtHt->Which() == rCmpItem.Which() && ( !bValue || CmpAttr( pTxtHt->GetAttr(), rCmpItem ))) { - lcl_SetAttrPam( rPam, *pTxtHt->GetStart(), pTxtHt->GetEnd(), bForward ); + lcl_SetAttrPam( rPam, *pTxtHt->GetStart(), pTxtHt->End(), bForward ); return sal_True; } return sal_False; @@ -902,7 +902,7 @@ sal_Bool SwPaM::Find( const SfxPoolItem& rAttr, sal_Bool bValue, SwMoveFn fnMove const SwPaM *pRegion, sal_Bool bInReadOnly ) { // stelle fest welches Attribut gesucht wird: - sal_uInt16 nWhich = rAttr.Which(); + const sal_uInt16 nWhich = rAttr.Which(); int bCharAttr = isCHRATR(nWhich) || isTXTATR(nWhich); SwPaM* pPam = MakeRegion( fnMove, pRegion ); diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 74cca2655f14..eee273145425 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -57,9 +57,10 @@ using namespace util; String *ReplaceBackReferences( const SearchOptions& rSearchOpt, SwPaM* pPam ); + String& lcl_CleanStr( const SwTxtNode& rNd, - xub_StrLen nStart, + const xub_StrLen nStart, xub_StrLen& rEnde, SvULongs& rArr, String& rRet, @@ -125,7 +126,6 @@ String& lcl_CleanStr( const SwTxtAttr* pHt = (*pHts)[n]; if ( pHt->HasDummyChar() && (nStt >= nStart) ) { - //JP 17.05.00: Task 75806 ask for ">=" and not for ">" switch( pHt->Which() ) { case RES_TXTATR_FLYCNT: @@ -136,14 +136,6 @@ String& lcl_CleanStr( case RES_TXTATR_META: case RES_TXTATR_METAFIELD: { - // JP 06.05.98: mit Bug 50100 werden sie als Trenner erwuenscht und nicht - // mehr zum Wort dazu gehoerend. - // MA 23.06.98: mit Bug 51215 sollen sie konsequenterweise auch am - // Satzanfang und -ende ignoriert werden wenn sie Leer sind. - // Dazu werden sie schlicht entfernt. Fuer den Anfang entfernen - // wir sie einfach. - // Fuer das Ende merken wir uns die Ersetzungen und entferenen - // hinterher alle am Stringende (koenten ja 'normale' 0x7f drinstehen sal_Bool bEmpty = RES_TXTATR_FIELD != pHt->Which() || !(static_cast<SwTxtFld const*>(pHt) ->GetFmtFld().GetField()->ExpandField(true).Len()); @@ -171,9 +163,9 @@ String& lcl_CleanStr( if ( bNewSoftHyphen ) { - rArr.Insert( nAkt, rArr.Count() ); + rArr.Insert( nAkt, rArr.Count() ); --rEnde; - rRet.Erase( nAkt, 1 ); + rRet.Erase( nAkt, 1 ); ++nSoftHyphen; } } @@ -203,8 +195,8 @@ xub_StrLen GetPostIt(xub_StrLen aCount,const SwpHints *pHts) { aIndex++; const SwTxtAttr* pTxtAttr = (*pHts)[i]; - if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) && - (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD)) + if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) + && (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD)) { aCount--; if (!aCount) @@ -216,8 +208,8 @@ xub_StrLen GetPostIt(xub_StrLen aCount,const SwpHints *pHts) for (xub_StrLen i = aIndex; i <pHts->Count();i++) { const SwTxtAttr* pTxtAttr = (*pHts)[i]; - if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) && - (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD)) + if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) + && (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD)) break; else aIndex++; @@ -309,10 +301,10 @@ sal_uInt8 SwPaM::Find( const SearchOptions& rSearchOpt, sal_Bool bSearchInNotes for (xub_StrLen i = 0; i <pHts->Count();i++) { - xub_StrLen aPos = *(*pHts)[i]->GetStart(); + const xub_StrLen aPos = *(*pHts)[i]->GetStart(); const SwTxtAttr* pTxtAttr = (*pHts)[i]; - if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) && - (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD)) + if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) + && (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD)) { if ( (aPos >= nStart) && (aPos <= nEnde) ) aNumberPostits++; diff --git a/sw/source/core/crsr/overlayrangesoutline.cxx b/sw/source/core/crsr/overlayrangesoutline.cxx new file mode 100644 index 000000000000..3859463f772c --- /dev/null +++ b/sw/source/core/crsr/overlayrangesoutline.cxx @@ -0,0 +1,117 @@ +/************************************************************** +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include <overlayrangesoutline.hxx> +#include <svx/sdr/overlay/overlaymanager.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygoncutter.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + // combine ranges geometrically to a single, ORed polygon + basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges) + { + const sal_uInt32 nCount(rRanges.size()); + basegfx::B2DPolyPolygon aRetval; + + for(sal_uInt32 a(0); a < nCount; a++) + { + const basegfx::B2DPolygon aDiscretePolygon(basegfx::tools::createPolygonFromRect(rRanges[a])); + + if(0 == a) + { + aRetval.append(aDiscretePolygon); + } + else + { + aRetval = basegfx::tools::solvePolygonOperationOr(aRetval, basegfx::B2DPolyPolygon(aDiscretePolygon)); + } + } + + return aRetval; + } +} + +namespace sw +{ + namespace overlay + { + drawinglayer::primitive2d::Primitive2DSequence OverlayRangesOutline::createOverlayObjectPrimitive2DSequence() + { + drawinglayer::primitive2d::Primitive2DSequence aRetval; + const sal_uInt32 nCount(getRanges().size()); + + if( nCount ) + { + const basegfx::BColor aRGBColor(getBaseColor().getBColor()); + const basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges())); + const drawinglayer::primitive2d::Primitive2DReference aOutline( + new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D( + aPolyPolygon, + aRGBColor)); + + aRetval.realloc(1); + aRetval[0] = aOutline; + } + + return aRetval; + } + + OverlayRangesOutline::OverlayRangesOutline( + const Color& rColor, + const std::vector< basegfx::B2DRange >& rRanges ) + : sdr::overlay::OverlayObject(rColor) + , maRanges(rRanges) + { + // no AA for highlight overlays + allowAntiAliase(false); + } + + OverlayRangesOutline::~OverlayRangesOutline() + { + if( getOverlayManager() ) + { + getOverlayManager()->remove(*this); + } + } + + void OverlayRangesOutline::setRanges(const std::vector< basegfx::B2DRange >& rNew) + { + if(rNew != maRanges) + { + maRanges = rNew; + objectChange(); + } + } + } // end of namespace overlay +} // end of namespace sdr + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/sw/source/core/crsr/overlayrangesoutline.hxx b/sw/source/core/crsr/overlayrangesoutline.hxx new file mode 100644 index 000000000000..58a2bbb4b60c --- /dev/null +++ b/sw/source/core/crsr/overlayrangesoutline.hxx @@ -0,0 +1,70 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + + + +#ifndef _SW_OVERLAY_OVERLAYRANGESOUTLINE_HXX +#define _SW_OVERLAY_OVERLAYRANGESOUTLINE_HXX + +#include <svx/sdr/overlay/overlayobject.hxx> +#include <basegfx/range/b2drange.hxx> + +#include <vector> + +////////////////////////////////////////////////////////////////////////////// + +namespace sw +{ + namespace overlay + { + class OverlayRangesOutline : public sdr::overlay::OverlayObject + { + protected: + // geometry of overlay + std::vector< basegfx::B2DRange > maRanges; + + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); + + public: + OverlayRangesOutline( + const Color& rColor, + const std::vector< basegfx::B2DRange >& rRanges ); + + virtual ~OverlayRangesOutline(); + + // data read access + inline const std::vector< basegfx::B2DRange >& getRanges() const + { + return maRanges; + } + + // data write access + void setRanges(const std::vector< basegfx::B2DRange >& rNew); + }; + } // end of namespace overlay +} // end of namespace sw + +////////////////////////////////////////////////////////////////////////////// + +#endif //_SW_OVERLAY_OVERLAYRANGESOUTLINE_HXX + +// eof diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index bd8c05c5bcaa..9dd182a3a1a9 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -56,6 +56,7 @@ #include <mdiexp.hxx> // ...Percent() #include <statstr.hrc> // ResId fuer Statusleiste #include <redline.hxx> // SwRedline +#include <txatbase.hxx> using namespace ::com::sun::star::i18n; @@ -238,18 +239,16 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) return sal_True; } -// neu: Bereiche ueberpruefen -// Anfang - if( pSavePos->nNode != GetPoint()->nNode.GetIndex() && - //JP 28.10.97: Bug 45129 - im UI-ReadOnly ist alles erlaubt - ( !pDoc->GetDocShell() || !pDoc->GetDocShell()->IsReadOnlyUI() )) + if( pSavePos->nNode != GetPoint()->nNode.GetIndex() + && ( !pDoc->GetDocShell() + || !pDoc->GetDocShell()->IsReadOnlyUI() ) ) { // teste doch mal die neuen Sections: SwNodeIndex& rPtIdx = GetPoint()->nNode; const SwSectionNode* pSectNd = rPtIdx.GetNode().FindSectionNode(); if( pSectNd && ((bSkipOverHiddenSections && pSectNd->GetSection().IsHiddenFlag() ) || - (bSkipOverProtectSections && pSectNd->GetSection().IsProtectFlag() ))) + (bSkipOverProtectSections && pSectNd->GetSection().IsProtectFlag() ))) { if( 0 == ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) ) { @@ -263,18 +262,18 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) xub_StrLen nCntntPos = pSavePos->nCntnt; int bGoNxt = pSavePos->nNode < rPtIdx.GetIndex(); SwCntntNode* pCNd = bGoNxt - ? rNds.GoNextSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections) - : rNds.GoPrevSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections); + ? rNds.GoNextSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections) + : rNds.GoPrevSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections); if( !pCNd && ( nsSwCursorSelOverFlags::SELOVER_ENABLEREVDIREKTION & eFlags )) { bGoNxt = !bGoNxt; pCNd = bGoNxt ? rNds.GoNextSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections) - : rNds.GoPrevSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections); + : rNds.GoPrevSection( &rPtIdx, bSkipOverHiddenSections, bSkipOverProtectSections); } int bIsValidPos = 0 != pCNd; sal_Bool bValidNodesRange = bIsValidPos && - ::CheckNodesRange( rPtIdx, aIdx, sal_True ); + ::CheckNodesRange( rPtIdx, aIdx, sal_True ); if( !bValidNodesRange ) { rPtIdx = pSavePos->nNode; @@ -297,15 +296,15 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) GetPoint()->nContent.Assign( pCNd, nTmpPos ); if( !bIsValidPos || !bValidNodesRange || // sollten wir in einer Tabelle gelandet sein? - IsInProtectTable( sal_True ) ) - return sal_True; + IsInProtectTable( sal_True ) ) + return sal_True; } // oder sollte eine geschuetzte Section innerhalb der Selektion liegen? if( HasMark() && bSkipOverProtectSections) { sal_uLong nSttIdx = GetMark()->nNode.GetIndex(), - nEndIdx = GetPoint()->nNode.GetIndex(); + nEndIdx = GetPoint()->nNode.GetIndex(); if( nEndIdx <= nSttIdx ) { sal_uLong nTmp = nSttIdx; @@ -339,22 +338,20 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) } } -// Ende -// neu: Bereiche ueberpruefen const SwNode* pNd = &GetPoint()->nNode.GetNode(); if( pNd->IsCntntNode() && !dynamic_cast<SwUnoCrsr*>(this) ) { const SwCntntFrm* pFrm = ((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() ); - if( pFrm && pFrm->IsValid() && 0 == pFrm->Frm().Height() && - 0 != ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) ) + if( pFrm && pFrm->IsValid() + && 0 == pFrm->Frm().Height() + && 0 != ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) ) { // skip to the next / prev valid paragraph with a layout SwNodeIndex& rPtIdx = GetPoint()->nNode; int bGoNxt = pSavePos->nNode < rPtIdx.GetIndex(); - while( 0 != ( pFrm = ( bGoNxt ? pFrm->GetNextCntntFrm() - : pFrm->GetPrevCntntFrm() )) && - 0 == pFrm->Frm().Height() ) + while( 0 != ( pFrm = ( bGoNxt ? pFrm->GetNextCntntFrm() : pFrm->GetPrevCntntFrm() )) + && 0 == pFrm->Frm().Height() ) ; // --> LIJIAN/FME 2007-11-27 #i72394# skip to prev /next valid paragraph @@ -382,7 +379,7 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) xub_StrLen nTmpPos = bGoNxt ? 0 : pCNd->Len(); GetPoint()->nContent.Assign( pCNd, nTmpPos ); - // sollten wir in einer Tabelle gelandet sein? + // sollten wir in einer Tabelle gelandet sein? if( IsInProtectTable( sal_True ) ) pFrm = 0; } @@ -416,25 +413,74 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) return sal_True; // ohne Frames geht gar nichts! } - const SwTableNode* pPtNd = pNd->FindTableNode(); - - if( (pNd = &GetMark()->nNode.GetNode())->IsCntntNode() && - !((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() ) && !dynamic_cast<SwUnoCrsr*>(this) ) + if( (pNd = &GetMark()->nNode.GetNode())->IsCntntNode() + && !((SwCntntNode*)pNd)->getLayoutFrm( pDoc->GetCurrentLayout() ) + && !dynamic_cast<SwUnoCrsr*>(this) ) { DeleteMark(); RestoreSavePos(); return sal_True; // ohne Frames geht gar nichts! } - const SwTableNode* pMrkNd = pNd->FindTableNode(); + // assure that selection is only inside an InputField or contains the InputField completely + { + const SwTxtAttr* pInputFldTxtAttrAtPoint = NULL; + SwTxtNode* pTxtNdAtPoint = GetPoint()->nNode.GetNode().GetTxtNode(); + if ( pTxtNdAtPoint != NULL ) + { + pInputFldTxtAttrAtPoint = + pTxtNdAtPoint->GetTxtAttrAt( GetPoint()->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT ); + } + + const SwTxtAttr* pInputFldTxtAttrAtMark = NULL; + SwTxtNode* pTxtNdAtMark = GetMark()->nNode.GetNode().GetTxtNode(); + if ( pTxtNdAtMark != NULL ) + { + pInputFldTxtAttrAtMark = + pTxtNdAtMark->GetTxtAttrAt( GetMark()->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT ); + } + + if ( pInputFldTxtAttrAtPoint != pInputFldTxtAttrAtMark ) + { + const sal_uLong nRefNodeIdx = + ( nsSwCursorSelOverFlags::SELOVER_TOGGLE & eFlags ) + ? pSavePos->nNode + : GetMark()->nNode.GetIndex(); + const xub_StrLen nRefContentIdx = + ( nsSwCursorSelOverFlags::SELOVER_TOGGLE & eFlags ) + ? pSavePos->nCntnt + : GetMark()->nContent.GetIndex(); + const bool bIsForwardSelection = + nRefNodeIdx < GetPoint()->nNode.GetIndex() + || ( nRefNodeIdx == GetPoint()->nNode.GetIndex() + && nRefContentIdx < GetPoint()->nContent.GetIndex() ); + + if ( pInputFldTxtAttrAtPoint != NULL ) + { + const xub_StrLen nNewPointPos = + bIsForwardSelection ? *(pInputFldTxtAttrAtPoint->End()) : *(pInputFldTxtAttrAtPoint->GetStart()); + GetPoint()->nContent.Assign( pTxtNdAtPoint, nNewPointPos ); + } + + if ( pInputFldTxtAttrAtMark != NULL ) + { + const xub_StrLen nNewMarkPos = + bIsForwardSelection ? *(pInputFldTxtAttrAtMark->GetStart()) : *(pInputFldTxtAttrAtMark->End()); + GetMark()->nContent.Assign( pTxtNdAtMark, nNewMarkPos ); + } + } + } + const SwTableNode* pPtNd = pNd->FindTableNode(); + const SwTableNode* pMrkNd = pNd->FindTableNode(); // beide in keinem oder beide im gleichen TableNode if( ( !pMrkNd && !pPtNd ) || pPtNd == pMrkNd ) return sal_False; // in unterschiedlichen Tabellen oder nur Mark in der Tabelle if( ( pPtNd && pMrkNd ) || pMrkNd ) - { // dann lasse das nicht zu, alte Pos zurueck + { + // dann lasse das nicht zu, alte Pos zurueck RestoreSavePos(); // Crsr bleibt an der alten Position return sal_True; @@ -446,8 +492,8 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) if( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) { sal_Bool bSelTop = GetPoint()->nNode.GetIndex() < - (( nsSwCursorSelOverFlags::SELOVER_TOGGLE & eFlags ) ? pSavePos->nNode - : GetMark()->nNode.GetIndex()); + (( nsSwCursorSelOverFlags::SELOVER_TOGGLE & eFlags ) ? pSavePos->nNode + : GetMark()->nNode.GetIndex()); do { // in Schleife fuer Tabelle hinter Tabelle @@ -478,7 +524,7 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) if( pMyNd->IsCntntNode() && // ist es ein ContentNode ?? ::CheckNodesRange( GetMark()->nNode, - GetPoint()->nNode, sal_True )) + GetPoint()->nNode, sal_True )) { // TABLE IN TABLE const SwTableNode* pOuterTableNd = pMyNd->FindTableNode(); @@ -503,7 +549,8 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) RestoreSavePos(); return sal_True; // Crsr bleibt an der alten Position } - return sal_False; // was bleibt noch ?? + + return sal_False; } #if defined( UNX ) @@ -1850,7 +1897,7 @@ sal_Bool SwCursor::UpDown( sal_Bool bUp, sal_uInt16 nCnt, } pFrm->GetCrsrOfst( GetPoint(), aPt, &eTmpState ); } - bRet = sal_True; + bRet = !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE | nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ); } else *GetPoint() = aOldPos; @@ -1870,8 +1917,10 @@ sal_Bool SwCursor::LeftRightMargin( sal_Bool bLeft, sal_Bool bAPI ) if ( pFrm ) SetCrsrBidiLevel( pFrm->IsRightToLeft() ? 1 : 0 ); - return pFrm && (bLeft ? pFrm->LeftMargin( this ) : - pFrm->RightMargin( this, bAPI ) ); + SwCrsrSaveState aSave( *this ); + return pFrm + && (bLeft ? pFrm->LeftMargin( this ) : pFrm->RightMargin( this, bAPI ) ) + && !IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE | nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ); } sal_Bool SwCursor::IsAtLeftRightMargin( sal_Bool bLeft, sal_Bool bAPI ) const diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 53069c7694f4..97e3e62d464d 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -42,12 +42,13 @@ #include <viewimp.hxx> #include <dview.hxx> #include <rootfrm.hxx> -#include <txtfrm.hxx> // SwTxtFrm +#include <txtfrm.hxx> #include <docary.hxx> #include <extinput.hxx> #include <ndtxt.hxx> +#include <txtfld.hxx> #include <scriptinfo.hxx> -#include <mdiexp.hxx> // GetSearchDialog +#include <mdiexp.hxx> #ifndef _COMCORE_HRC #include <comcore.hrc> // ResId fuer Abfrage wenn zu Search & Replaces #endif @@ -56,6 +57,9 @@ #include <svx/sdrpaintwindow.hxx> #include <vcl/svapp.hxx> #include <svx/sdr/overlay/overlayselection.hxx> +#include <overlayrangesoutline.hxx> + +#include <boost/scoped_ptr.hpp> extern void SwCalcPixStatics( OutputDevice *pOut ); @@ -510,9 +514,11 @@ void SwVisCrsr::_SetPosAndShow() ////////////////////////////////////////////////////////////////////////////// SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh ) -: SwRects( 0 ), - pCShell( &rCSh ), - mpCursorOverlay(0) + : SwRects( 0 ) + , pCShell( &rCSh ) + , mpCursorOverlay( 0 ) + , mbShowTxtInputFldOverlay( true ) + , mpTxtInputFldOverlay( NULL ) { } @@ -536,6 +542,14 @@ void SwSelPaintRects::swapContent(SwSelPaintRects& rSwap) sdr::overlay::OverlayObject* pTempOverlay = getCursorOverlay(); setCursorOverlay(rSwap.getCursorOverlay()); rSwap.setCursorOverlay(pTempOverlay); + + const bool bTempShowTxtInputFldOverlay = mbShowTxtInputFldOverlay; + mbShowTxtInputFldOverlay = rSwap.mbShowTxtInputFldOverlay; + rSwap.mbShowTxtInputFldOverlay = bTempShowTxtInputFldOverlay; + + sw::overlay::OverlayRangesOutline* pTempTxtInputFldOverlay = mpTxtInputFldOverlay; + mpTxtInputFldOverlay = rSwap.mpTxtInputFldOverlay; + rSwap.mpTxtInputFldOverlay = pTempTxtInputFldOverlay; } void SwSelPaintRects::Hide() @@ -546,6 +560,12 @@ void SwSelPaintRects::Hide() mpCursorOverlay = 0; } + if ( mpTxtInputFldOverlay != NULL ) + { + delete mpTxtInputFldOverlay; + mpTxtInputFldOverlay = NULL; + } + SwRects::Remove( 0, Count() ); } @@ -605,9 +625,78 @@ void SwSelPaintRects::Show() pTargetOverlay->add(*mpCursorOverlay); } } + + HighlightInputFld(); + } +} + + +void SwSelPaintRects::HighlightInputFld() +{ + std::vector< basegfx::B2DRange > aInputFldRanges; + + if ( mbShowTxtInputFldOverlay ) + { + SwTxtInputFld* pCurTxtInputFldAtCrsr = + dynamic_cast<SwTxtInputFld*>(GetShell()->GetTxtFldAtPos( GetShell()->GetCrsr()->Start(), false )); + if ( pCurTxtInputFldAtCrsr != NULL ) + { + SwTxtNode* pTxtNode = pCurTxtInputFldAtCrsr->GetpTxtNode(); + ::boost::scoped_ptr<SwShellCrsr> pCrsrForInputTxtFld( + new SwShellCrsr( *GetShell(), SwPosition( *pTxtNode, *(pCurTxtInputFldAtCrsr->GetStart()) ) ) ); + pCrsrForInputTxtFld->SetMark(); + pCrsrForInputTxtFld->GetMark()->nNode = *pTxtNode; + pCrsrForInputTxtFld->GetMark()->nContent.Assign( pTxtNode, *(pCurTxtInputFldAtCrsr->End()) ); + + pCrsrForInputTxtFld->FillRects(); + + for( sal_uInt16 a(0); a < pCrsrForInputTxtFld->Count(); ++a ) + { + const SwRect aNextRect((*pCrsrForInputTxtFld)[a]); + const Rectangle aPntRect(aNextRect.SVRect()); + + aInputFldRanges.push_back(basegfx::B2DRange( + aPntRect.Left(), aPntRect.Top(), + aPntRect.Right() + 1, aPntRect.Bottom() + 1)); + } + } + } + + if ( aInputFldRanges.size() > 0 ) + { + if ( mpTxtInputFldOverlay != NULL ) + { + mpTxtInputFldOverlay->setRanges( aInputFldRanges ); + } + else + { + SdrView* pView = (SdrView*)GetShell()->GetDrawView(); + SdrPaintWindow* pCandidate = pView->GetPaintWindow(0); + sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager(); + + if(pTargetOverlay) + { + // use system's hilight color with decreased luminance as highlight color + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor()); + aHighlight.DecreaseLuminance( 128 ); + + mpTxtInputFldOverlay = new sw::overlay::OverlayRangesOutline( aHighlight, aInputFldRanges ); + pTargetOverlay->add( *mpTxtInputFldOverlay ); + } + } + } + else + { + if ( mpTxtInputFldOverlay != NULL ) + { + delete mpTxtInputFldOverlay; + mpTxtInputFldOverlay = NULL; + } } } + void SwSelPaintRects::Invalidate( const SwRect& rRect ) { sal_uInt16 nSz = Count(); @@ -675,24 +764,38 @@ void SwSelPaintRects::Get1PixelInLogic( const ViewShell& rSh, /* */ -SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos ) - : SwCursor(rPos,0,false), SwSelPaintRects(rCShell), pPt(SwPaM::GetPoint()) +SwShellCrsr::SwShellCrsr( + const SwCrsrShell& rCShell, + const SwPosition &rPos ) + : SwCursor(rPos,0,false) + , SwSelPaintRects(rCShell) + , pPt(SwPaM::GetPoint()) {} -SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos, - const Point& rPtPos, SwPaM* pRing ) - : SwCursor(rPos, pRing, false), SwSelPaintRects(rCShell), aMkPt(rPtPos), - aPtPt(rPtPos), pPt(SwPaM::GetPoint()) +SwShellCrsr::SwShellCrsr( + const SwCrsrShell& rCShell, + const SwPosition &rPos, + const Point& rPtPos, + SwPaM* pRing ) + : SwCursor(rPos, pRing, false) + , SwSelPaintRects(rCShell) + , aMkPt(rPtPos) + , aPtPt(rPtPos) + , pPt(SwPaM::GetPoint()) {} SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr ) - : SwCursor(rICrsr), SwSelPaintRects(*rICrsr.GetShell()), - aMkPt(rICrsr.GetMkPos()), aPtPt(rICrsr.GetPtPos()), pPt(SwPaM::GetPoint()) + : SwCursor(rICrsr) + , SwSelPaintRects(*rICrsr.GetShell()) + , aMkPt(rICrsr.GetMkPos()) + , aPtPt(rICrsr.GetPtPos()) + , pPt(SwPaM::GetPoint()) {} -SwShellCrsr::~SwShellCrsr() {} +SwShellCrsr::~SwShellCrsr() +{} bool SwShellCrsr::IsReadOnlyAvailable() const @@ -717,7 +820,7 @@ void SwShellCrsr::FillRects() GetPoint()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) && (GetMark()->nNode == GetPoint()->nNode || (GetMark()->nNode.GetNode().IsCntntNode() && - GetMark()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) ) )) + GetMark()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) ) )) GetShell()->GetLayout()->CalcFrmRects( *this, GetShell()->IsTableMode() ); //swmod 071107//swmod 071225 } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 2906a6b42c26..7743f4aed000 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -170,7 +170,7 @@ map<sal_uInt16,String,CompareUShort> & GetItemWhichMap() aItemWhichMap[RES_TXTATR_REFMARK] = String("TXTATR_REFMARK", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_TOXMARK] = String("TXTATR_TOXMARK", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_CHARFMT] = String("TXTATR_CHARFMT", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY5] = String("TXTATR_DUMMY5", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_INPUTFIELD] = String("TXTATR_INPUTFIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_CJK_RUBY] = String("TXTATR_CJK_RUBY", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_UNKNOWN_CONTAINER] = String("TXTATR_UNKNOWN_CONTAINER", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_META] = String("TXTATR_META", RTL_TEXTENCODING_ASCII_US); @@ -320,7 +320,7 @@ const String lcl_dbg_out(const SwTxtAttr & rAttr) aStr += String::CreateFromInt32(*rAttr.GetStart()); aStr += String("->", RTL_TEXTENCODING_ASCII_US); - aStr += String::CreateFromInt32(*rAttr.GetEnd()); + aStr += String::CreateFromInt32(*rAttr.End()); aStr += String(" ", RTL_TEXTENCODING_ASCII_US); aStr += lcl_dbg_out(rAttr.GetAttr()); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 04ad4e595720..aefd4a07c723 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -260,9 +260,8 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) if (pOutlineRule) { pOutlineRule->Validate(); - // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()> + // counting of phantoms depends on <IsOldNumbering()> pOutlineRule->SetCountPhantoms( !mbOldNumbering ); - // <-- } } break; @@ -304,30 +303,31 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) mbDoNotCaptureDrawObjsOnPage = value; break; - // --> OD 2006-08-25 #i68949# case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: mbClipAsCharacterAnchoredWriterFlyFrames = value; break; - // <-- + case UNIX_FORCE_ZERO_EXT_LEADING: mbUnixForceZeroExtLeading = value; break; + case PROTECT_FORM: - mbProtectForm = value; - break; + mbProtectForm = value; + break; case USE_OLD_PRINTER_METRICS: mbOldPrinterMetrics = value; break; + case TABS_RELATIVE_TO_INDENT: mbTabRelativeToIndent = value; break; - // --> OD 2008-06-05 #i89181# + case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: mbTabAtLeftIndentForParagraphsInList = value; break; - // <-- - // COMPATIBILITY FLAGS END + + // COMPATIBILITY FLAGS END case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable mbLastBrowseMode = value; @@ -2707,24 +2707,21 @@ String SwDoc::GetPaMDescr(const SwPaM & rPam) const return aResult; } -// -> #111840# -SwField * SwDoc::GetField(const SwPosition & rPos) +SwField * SwDoc::GetFieldAtPos(const SwPosition & rPos) { - SwTxtFld * const pAttr = GetTxtFld(rPos); + SwTxtFld * const pAttr = GetTxtFldAtPos(rPos); return (pAttr) ? const_cast<SwField *>( pAttr->GetFmtFld().GetField() ) : 0; } -SwTxtFld * SwDoc::GetTxtFld(const SwPosition & rPos) +SwTxtFld * SwDoc::GetTxtFldAtPos(const SwPosition & rPos) { SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode(); - return (pNode) - ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( - rPos.nContent.GetIndex(), RES_TXTATR_FIELD) ) + return (pNode != NULL) + ? pNode->GetFldTxtAttrAt( rPos.nContent.GetIndex(), true ) : 0; } -// <- #111840# bool SwDoc::ContainsHiddenChars() const { diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 5923143cb1e1..11ba2b1db128 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -1501,7 +1501,7 @@ lcl_CalcBreaks( ::std::vector<xub_StrLen> & rBreaks, SwPaM const & rPam ) if ((CH_TXTATR_INWORD == c) || (CH_TXTATR_BREAKWORD == c)) { SwTxtAttr const * const pAttr( pTxtNode->GetTxtAttrForCharAt(i) ); - if (pAttr && pAttr->GetEnd() && (*pAttr->GetEnd() > nEnd)) + if (pAttr && pAttr->End() && (*pAttr->End() > nEnd)) { ASSERT(pAttr->HasDummyChar(), "GetTxtAttrForCharAt broken?"); rBreaks.push_back(i); @@ -1686,7 +1686,7 @@ bool SwDoc::DeleteRangeImplImpl(SwPaM & rPam) break; if( nMkCntPos == *pAttr->GetStart() && - 0 != (pEndIdx = pAttr->GetEnd()) && + 0 != (pEndIdx = pAttr->End()) && *pEndIdx == *pAttr->GetStart() ) pTxtNd->DestroyAttr( pHts->Cut( n ) ); } diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index be10fcefe9a7..f6e2ede98500 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -751,8 +751,10 @@ void SwDoc::SetNewFldLst(bool bFlag) // der StartIndex kann optional mit angegeben werden (z.B. wenn dieser // zuvor schon mal erfragt wurde - ist sonst eine virtuelle Methode !!) -_SetGetExpFld::_SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, - const SwIndex* pIdx ) +_SetGetExpFld::_SetGetExpFld( + const SwNodeIndex& rNdIdx, + const SwTxtFld* pFld, + const SwIndex* pIdx ) { eSetGetExpFldType = TEXTFIELD; CNTNT.pTxtFld = pFld; @@ -902,6 +904,15 @@ void _SetGetExpFld::SetBodyPos( const SwCntntFrm& rFrm ) } } +sal_Bool _SetGetExpFld::operator==( const _SetGetExpFld& rFld ) const +{ + return nNode == rFld.nNode + && nCntnt == rFld.nCntnt + && ( !CNTNT.pTxtFld + || !rFld.CNTNT.pTxtFld + || CNTNT.pTxtFld == rFld.CNTNT.pTxtFld ); +} + sal_Bool _SetGetExpFld::operator<( const _SetGetExpFld& rFld ) const { if( nNode < rFld.nNode || ( nNode == rFld.nNode && nCntnt < rFld.nCntnt )) @@ -2712,17 +2723,12 @@ bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, SwPosition aPosition( pDstTxtFld->GetTxtNode() ); aPosition.nContent = *pDstTxtFld->GetStart(); - SwUndo *const pUndo( new SwUndoFieldFromDoc( - aPosition, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds) ); + SwUndo *const pUndo( new SwUndoFieldFromDoc( aPosition, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds) ); GetIDocumentUndoRedo().AppendUndo(pUndo); } - // Das gefundene Feld wird angepasst ... - //pDstFld->ChangeFormat( rSrcFld.GetFormat() ); - //pDstFld->SetLanguage( rSrcFld.GetLanguage() ); - SwField * pNewFld = rSrcFld.CopyField(); - pDstFmtFld->SetFld(pNewFld); + pDstFmtFld->SetField(pNewFld); switch( nFldWhich ) { @@ -2798,7 +2804,7 @@ bool SwDoc::PutValueToField(const SwPosition & rPos, const Any& rVal, sal_uInt16 nWhich) { Any aOldVal; - SwField * pField = GetField(rPos); + SwField * pField = GetFieldAtPos(rPos); if (GetIDocumentUndoRedo().DoesUndo() && diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index f674ab056c81..6b0bad3f4e42 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -183,14 +183,14 @@ sal_Bool lcl_RstTxtAttr( const SwNodePtr& rpNd, void* pArgs ) // fuers Undo alle Attribute sichern SwRegHistory aRHst( *pTxtNode, pPara->pHistory ); pTxtNode->GetpSwpHints()->Register( &aRHst ); - pTxtNode->RstAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich, - pPara->pDelSet, pPara->bInclRefToxMark ); + pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich, + pPara->pDelSet, pPara->bInclRefToxMark ); if( pTxtNode->GetpSwpHints() ) pTxtNode->GetpSwpHints()->DeRegister(); } else - pTxtNode->RstAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich, - pPara->pDelSet, pPara->bInclRefToxMark ); + pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich, + pPara->pDelSet, pPara->bInclRefToxMark ); } return sal_True; } @@ -399,7 +399,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, if (pURLAttr && pURLAttr->GetINetFmt().GetValue().Len()) { nMkPos = *pURLAttr->GetStart(); - nPtPos = *pURLAttr->GetEnd(); + nPtPos = *pURLAttr->End(); } else { @@ -549,11 +549,15 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, // Einfuegen der Hints nach Inhaltsformen; // wird in SwDoc::Insert(..., SwFmtHint &rHt) benutzt -static bool -lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, -//Modify here for #119405, by easyfan, 2012-05-24 - const SetAttrMode nFlags, SwUndoAttr *const pUndo,bool bExpandCharToPara=false) -//End of modification, by easyfan +static bool lcl_InsAttr( + SwDoc *const pDoc, + const SwPaM &rRg, + const SfxItemSet& rChgSet, + const SetAttrMode nFlags, + SwUndoAttr *const pUndo, + //Modify here for #119405, by easyfan, 2012-05-24 + const bool bExpandCharToPara=false) + //End of modification, by easyfan { // teil die Sets auf (fuer Selektion in Nodes) const SfxItemSet* pCharSet = 0; @@ -609,9 +613,7 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SfxItemSet* pTmpOtherItemSet = new SfxItemSet( pDoc->GetAttrPool(), RES_PARATR_BEGIN, RES_PARATR_END-1, - // --> OD 2008-02-25 #refactorlists# RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, - // <-- RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_GRFATR_BEGIN, RES_GRFATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, @@ -639,7 +641,6 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwTxtNode * pTxtNd = pNode->GetTxtNode(); SwNumRule * pNumRule = pTxtNd->GetNumRule(); - // --> OD 2005-10-24 #126346# - make code robust: if ( !pNumRule ) { ASSERT( false, @@ -647,7 +648,6 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, DELETECHARSETS return false; } - // <-- SwNumFmt aNumFmt = pNumRule->Get(static_cast<sal_uInt16>(pTxtNd->GetActualListLevel())); SwCharFmt * pCharFmt = @@ -665,7 +665,6 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, DELETECHARSETS return true; } - // <- #i27615# const SwIndex& rSt = pStt->nContent; @@ -708,6 +707,7 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK, RES_TXTATR_META, RES_TXTATR_METAFIELD, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, + RES_TXTATR_INPUTFIELD, RES_TXTATR_INPUTFIELD, 0 ); aTxtSet.Put( rChgSet ); @@ -860,7 +860,7 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if (pURLAttr && pURLAttr->GetINetFmt().GetValue().Len()) { nMkPos = *pURLAttr->GetStart(); - nPtPos = *pURLAttr->GetEnd(); + nPtPos = *pURLAttr->End(); } else { @@ -894,12 +894,12 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // fuers Undo alle Attribute sichern SwRegHistory aRHst( *pTxtNd, pHistory ); pTxtNd->GetpSwpHints()->Register( &aRHst ); - pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet ); + pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet ); if( pTxtNd->GetpSwpHints() ) pTxtNd->GetpSwpHints()->DeRegister(); } else - pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet ); + pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet ); } // the SwRegHistory inserts the attribute into the TxtNode! @@ -981,7 +981,7 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if (pCurrentNd) { - pCurrentNd->TryCharSetExpandToNum(*pCharSet); + pCurrentNd->TryCharSetExpandToNum(*pCharSet); } } @@ -1089,7 +1089,6 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, ++nNodes; } - //Modify here for #119405, by easyfan, 2012-05-24 //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc, //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that //current setting attribute set is a character range properties set and comes from a MS word @@ -1111,23 +1110,22 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if (pCurrentNd) { - pCurrentNd->TryCharSetExpandToNum(*pCharSet); + pCurrentNd->TryCharSetExpandToNum(*pCharSet); } } } - //End of modification, by easyfan DELETECHARSETS return (nNodes != 0) || bRet; } -//Modify here for #119405, by chengjh, 2012-08-16 -//Add a para for the char attribute exp... -bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, - const SetAttrMode nFlags, bool bExpandCharToPara) -//End +bool SwDoc::InsertPoolItem( + const SwPaM &rRg, + const SfxPoolItem &rHt, + const SetAttrMode nFlags, + const bool bExpandCharToPara) { SwDataChanged aTmp( rRg, 0 ); SwUndoAttr* pUndoAttr = 0; @@ -1139,9 +1137,7 @@ bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() ); aSet.Put( rHt ); - //Modify here for #119405, by easyfan, 2012-05-24 - bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr,bExpandCharToPara ); - //End of modification, by easyfan + const bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr,bExpandCharToPara ); if (GetIDocumentUndoRedo().DoesUndo()) { @@ -1149,7 +1145,9 @@ bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, } if( bRet ) + { SetModified(); + } return bRet; } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 1363bd83534c..dcfb772cdd21 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1417,8 +1417,8 @@ lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, pNewSet->Put( SwFmtSurround( SURROUND_NONE ) ); pNewSet->Put( SvxOpaqueItem( RES_OPAQUE, sal_True ) ); - pNewSet->Put( SwFmtVertOrient( text::VertOrientation::TOP ) ); - pNewSet->Put( SwFmtHoriOrient( text::HoriOrientation::CENTER ) ); + pNewSet->Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) ); + pNewSet->Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ) ); aFrmSize = pOldFmt->GetFrmSize(); aFrmSize.SetWidthPercent( 100 ); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index f5229baa2c6a..29d95c8b209f 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1011,7 +1011,6 @@ void SwDoc::SetNumRule( const SwPaM& rPam, } } - // --> OD 2008-03-17 #refactorlists# if ( bSetItem ) { if ( bCreateNewList ) @@ -1030,22 +1029,18 @@ void SwDoc::SetNumRule( const SwPaM& rPam, "<SwDoc::SetNumRule(..)> - could not create new list. Serious defect -> please inform OD." ); sListId = pNewList->GetListId(); } - InsertPoolItem( rPam, - SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); + InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); } else if ( sContinuedListId.Len() > 0 ) { // apply given list id - InsertPoolItem( rPam, - SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); + InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); } } - // <-- if ( ! rPam.HasMark()) { SwTxtNode * pTxtNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode(); - // --> OD 2006-10-19 #134160# // consider case that the PaM doesn't denote a text node - e.g. it denotes a graphic node if ( pTxtNd ) { @@ -1054,15 +1049,13 @@ void SwDoc::SetNumRule( const SwPaM& rPam, if (pRule && pRule->GetName() == pNew->GetName()) { bSetItem = sal_False; - // --> OD 2008-06-02 #refactorlists# if ( !pTxtNd->IsInList() ) { pTxtNd->AddToList(); } - // <-- } - // --> OD 2005-10-26 #b6340308# - only clear numbering attribute at - // text node, if at paragraph style the new numbering rule is found. + // only clear numbering attribute at text node, + // if at paragraph style the new numbering rule is found. else if ( !pRule ) { SwTxtFmtColl* pColl = pTxtNd->GetTxtColl(); @@ -1076,25 +1069,19 @@ void SwDoc::SetNumRule( const SwPaM& rPam, } } } - // <-- } - // <-- } - // --> OD 2009-08-18 #i103817# if ( bSetItem ) - // <-- { InsertPoolItem( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); } - // --> OD 2008-02-08 #newlistlevelattrs# if ( bResetIndentAttrs && pNew && pNew->Get( 0 ).GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { SvUShortsSort aResetAttrsArray; aResetAttrsArray.Insert( RES_LR_SPACE ); - // --> OD 2010-10-05 #i114929# // On a selection setup a corresponding Point-and-Mark in order to get // the indentation attribute reset on all paragraphs touched by the selection if ( rPam.HasMark() && @@ -1110,9 +1097,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam, { ResetAttrs( rPam, sal_False, &aResetAttrsArray ); } - // <-- } - // <-- if (GetIDocumentUndoRedo().DoesUndo()) { @@ -1128,7 +1113,6 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) { SvUShortsSort aResetAttrsArray; aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED ); - // --> OD 2010-10-05 #i114929# // On a selection setup a corresponding Point-and-Mark in order to get // the list-is-counted attribute reset on all paragraphs touched by the selection if ( rPam.HasMark() && @@ -1144,12 +1128,10 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) { ResetAttrs( rPam, sal_False, &aResetAttrsArray ); } - // <-- } else { - InsertPoolItem( rPam, - SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, sal_False ), 0 ); + InsertPoolItem( rPam, SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, sal_False ), 0 ); } } diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 5a8501f3df4c..4407d4825283 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -2979,8 +2979,8 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const // eigentlich muesste hier das Attribut zurueck gesetzt werden!!! for( sal_uInt16 n = 0, nEnd = aWhichIds.Count(); n < nEnd; ++n ) { - pDoc->InsertPoolItem( rPam, *GetDfltAttr( aWhichIds[ n ] ), - nsSetAttrMode::SETATTR_DONTEXPAND ); + pDoc->InsertPoolItem( + rPam, *GetDfltAttr( aWhichIds[ n ] ), nsSetAttrMode::SETATTR_DONTEXPAND ); } pDoc->SetRedlineMode_intern( eOld ); diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx index d5417f5897e7..77430d8737e8 100644 --- a/sw/source/core/doc/docruby.cxx +++ b/sw/source/core/doc/docruby.cxx @@ -173,8 +173,8 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, InsertString( aPam, pEntry->GetText() ); aPam.SetMark(); aPam.GetMark()->nContent -= pEntry->GetText().Len(); - InsertPoolItem( aPam, pEntry->GetRubyAttr(), - nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertPoolItem( + aPam, pEntry->GetRubyAttr(), nsSetAttrMode::SETATTR_DONTEXPAND ); } else break; diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 12f98950ef21..6986430c1e3f 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -155,7 +155,7 @@ sal_uInt16 SwDoc::GetCurTOXMark( const SwPosition& rPos, if( ( nSttIdx = *pHt->GetStart() ) < nAktPos ) { // pruefe Ende mit ab - if( 0 == ( pEndIdx = pHt->GetEnd() ) || + if( 0 == ( pEndIdx = pHt->End() ) || *pEndIdx <= nAktPos ) continue; // weiter suchen } @@ -260,7 +260,7 @@ const SwTOXMark& SwDoc::GotoTOXMark( const SwTOXMark& rCurTOXMark, const SwTOXMark* pTOXMark; const SwCntntFrm* pCFrm; Point aPt; - for( sal_Int32 nMark=0; nMark<aMarks.Count(); nMark++ ) + for( sal_uInt16 nMark=0; nMark<aMarks.Count(); nMark++ ) { pTOXMark = aMarks[nMark]; if( pTOXMark != &rCurTOXMark && @@ -2105,7 +2105,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, for(sal_uInt16 nHintIdx = 0; nHintIdx < pHints->GetStartCount(); nHintIdx++) { SwTxtAttr* pAttr = pHints->GetStart(nHintIdx); - xub_StrLen nTmpEnd = pAttr->GetEnd() ? *pAttr->GetEnd() : 0; + const xub_StrLen nTmpEnd = pAttr->End() ? *pAttr->End() : 0; if( nStartPos >= *pAttr->GetStart() && (nStartPos + 2) <= nTmpEnd && pAttr->Which() == RES_TXTATR_CHARFMT) diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 4536a56c47d2..ee7030f20caa 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -1029,7 +1029,11 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, // loesche die Frames aFndBox.SetTableLines( *this ); - aFndBox.DelFrms( *this ); + //IAccessibility2 Implementation 2009----- + //Solution:Not dispose accessible table + //aFndBox.DelFrms( *this ); + aFndBox.DelFrms( *this,sal_False ); + //-----IAccessibility2 Implementation 2009 if( 1 == rCpyTbl.GetTabSortBoxes().Count() ) { diff --git a/sw/source/core/doc/visiturl.cxx b/sw/source/core/doc/visiturl.cxx index 99eb3e3d2b79..65314c6f3228 100644 --- a/sw/source/core/doc/visiturl.cxx +++ b/sw/source/core/doc/visiturl.cxx @@ -86,7 +86,7 @@ void SwURLStateChanged::Notify( SfxBroadcaster& , const SfxHint& rHint ) const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( false ); const SwTxtAttr* pAttr = pTxtAttr; SwUpdateAttr aUpdateAttr( *pAttr->GetStart(), - *pAttr->GetEnd(), + *pAttr->End(), RES_FMT_CHG ); ((SwTxtNode*)pTxtNd)->ModifyNotification( &aUpdateAttr, &aUpdateAttr ); } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index a0bcd7e9874a..7b49226de30b 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1039,7 +1039,9 @@ SwCntntNode::~SwCntntNode() // der Abhaengikeitsliste raus! // Daher muessen alle Frames in der Abhaengigkeitsliste geloescht werden. if( GetDepends() ) - DelFrms(); + //IAccessibility2 Implementation 2009----- + DelFrms(sal_True, sal_False); + //-----IAccessibility2 Implementation 2009 if( pCondColl ) delete pCondColl; @@ -1366,12 +1368,82 @@ void SwCntntNode::MakeFrms( SwCntntNode& rNode ) */ -void SwCntntNode::DelFrms() +//IAccessibility2 Implementation 2009----- +//Solution:Add a input param to identify if the acc table should be disposed. +//add a flag(bNeedDel) to indicate whether to del corresponding frm even in doc loading process, +//void SwCntntNode::DelFrms() +void SwCntntNode::DelFrms( sal_Bool bNeedDel, sal_Bool bIsDisposeAccTable ) +//-----IAccessibility2 Implementation 2009 { if( !GetDepends() ) return; - SwCntntFrm::DelFrms(*this); + SwClientIter aIter( *this ); + + for(SwClient* pCandidate = aIter.SwClientIter_First(); pCandidate; pCandidate = aIter.SwClientIter_Next() ) + { + SwCntntFrm* pFrm = dynamic_cast< SwCntntFrm* >(pCandidate); + + if(!pFrm) + { + continue; + } + + // --> OD 2005-12-01 #i27138# + // notify accessibility paragraphs objects about changed + // CONTENT_FLOWS_FROM/_TO relation. + // Relation CONTENT_FLOWS_FROM for current next paragraph will change + // and relation CONTENT_FLOWS_TO for current previous paragraph will change. + if ( pFrm->IsTxtFrm() ) + { + ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() ); + if ( pViewShell && pViewShell->GetLayout() && + pViewShell->GetLayout()->IsAnyShellAccessible() ) + { + pViewShell->InvalidateAccessibleParaFlowRelation( + dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )), + dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) ); + } + } + // <-- + if( pFrm->HasFollow() ) + pFrm->GetFollow()->_SetIsFollow( pFrm->IsFollow() ); + if( pFrm->IsFollow() ) + { + SwCntntFrm* pMaster = (SwTxtFrm*)pFrm->FindMaster(); + pMaster->SetFollow( pFrm->GetFollow() ); + pFrm->_SetIsFollow( sal_False ); + } + pFrm->SetFollow( 0 );//Damit er nicht auf dumme Gedanken kommt. + //Andernfalls kann es sein, dass ein Follow + //vor seinem Master zerstoert wird, der Master + //greift dann ueber den ungueltigen + //Follow-Pointer auf fremdes Memory zu. + //Die Kette darf hier zerknauscht werden, weil + //sowieso alle zerstoert werden. + if( pFrm->GetUpper() && pFrm->IsInFtn() && !pFrm->GetIndNext() && + !pFrm->GetIndPrev() ) + { + SwFtnFrm *pFtn = pFrm->FindFtnFrm(); + ASSERT( pFtn, "You promised a FtnFrm?" ); + SwCntntFrm* pCFrm; + if( !pFtn->GetFollow() && !pFtn->GetMaster() && + 0 != ( pCFrm = pFtn->GetRefFromAttr()) && pCFrm->IsFollow() ) + { + ASSERT( pCFrm->IsTxtFrm(), "NoTxtFrm has Footnote?" ); + ((SwTxtFrm*)pCFrm->FindMaster())->Prepare( PREP_FTN_GONE ); + } + } + //IAccessibility2 Implementation 2009----- + //Solution:Set acc table dispose state + pFrm->SetAccTableDispose( bIsDisposeAccTable ); + //End Added + pFrm->Cut(); + //Solution:Set acc table dispose state to default value + pFrm->SetAccTableDispose( sal_True ); + //-----IAccessibility2 Implementation 2009 + delete pFrm; + } if( IsTxtNode() ) { ((SwTxtNode*)this)->SetWrong( NULL ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 70019e459b48..f0905dc02f84 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -180,10 +180,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, if ( rNd.IsTxtNode() ) { SwTxtNode* pTxtNode = rNd.GetTxtNode(); - // --> OD 2008-03-13 #refactorlists# -// pTxtNode->UnregisterNumber(); pTxtNode->RemoveFromList(); - // <-- //if ( pTxtNode->GetTxtColl()->GetOutlineLevel() != NO_NUMBERING )//#outline level,zhaojianwei if ( pTxtNode->GetAttrOutlineLevel() != 0 )//<-end,zhaojianwei @@ -199,10 +196,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, if( rNd.IsTxtNode() ) { SwTxtNode& rTxtNd = (SwTxtNode&)rNd; - // --> OD 2008-03-13 #refactorlists# -// rTxtNd.SyncNumberAndNumRule(); rTxtNd.AddToList(); - // <-- if( bInsOutlineIdx && //NO_NUMBERING != rTxtNd.GetTxtColl()->GetOutlineLevel() )//#outline level,zhaojianwei @@ -273,10 +267,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, // Numerierungen auch aktualisiert werden. pTxtNd->InvalidateNumRule(); - // --> OD 2008-03-13 #refactorlists# -// pTxtNd->UnregisterNumber(); pTxtNd->RemoveFromList(); - // <-- } RemoveNode( rDelPos.GetIndex(), 1, sal_False ); // Indizies verschieben !! @@ -298,10 +289,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, rNds.pOutlineNds->Insert( pTxtNd ); } - // --> OD 2008-03-13 #refactorlists# -// pTxtNd->SyncNumberAndNumRule(); pTxtNd->AddToList(); - // <-- // Sonderbehandlung fuer die Felder! if( pHts && pHts->Count() ) @@ -316,9 +304,9 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, switch ( pAttr->Which() ) { case RES_TXTATR_FIELD: + case RES_TXTATR_INPUTFIELD: { - SwTxtFld* pTxtFld = - static_cast<SwTxtFld*>(pAttr); + SwTxtFld* pTxtFld = static_cast<SwTxtFld*>(pAttr); rNds.GetDoc()->InsDelFldInFldLst( !bToUndo, *pTxtFld ); const SwFieldType* pTyp = pTxtFld->GetFmtFld().GetField()->GetTyp(); @@ -909,6 +897,17 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, break; case ND_TEXTNODE: + //IAccessibility2 Implementation 2009----- + //Solution:Add special function to text node. + { + if( bNewFrms && pAktNode->GetCntntNode() ) + ((SwCntntNode*)pAktNode)->DelFrms( sal_False ); + pAktNode->pStartOfSection = aSttNdStack[ nLevel ]; + nInsPos++; + aRg.aEnd--; + } + break; + //-----IAccessibility2 Implementation 2009 case ND_GRFNODE: case ND_OLENODE: { diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 4983cc04e431..8a51c96d779f 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -1079,7 +1079,7 @@ void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView ) { SdrObject* pRefObj = &(static_cast<SwDrawVirtObj*>(pMarkObj)->ReferencedObj()); - if ( !_rMarkView.IsObjMarked( *pRefObj ) ) + if ( !_rMarkView.isSdrObjectSelected( *pRefObj ) ) { _rMarkView.MarkObj( *pRefObj ); } diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index a3fc31f1f51c..399880615a0b 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -518,7 +518,7 @@ void SwDontExpandItem::RestoreDontExpandItems( const SwPosition& rPos ) if( nAttrStart > nStart ) // ueber den Bereich hinaus break; - if( 0 != ( pAttrEnd = pHt->GetEnd() ) && + if( 0 != ( pAttrEnd = pHt->End() ) && ( ( nAttrStart < nStart && ( pHt->DontExpand() ? nStart < *pAttrEnd : nStart <= *pAttrEnd )) || diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx index 58aaa0dae3d3..f6ab9dafffc0 100644 --- a/sw/source/core/edit/edatmisc.cxx +++ b/sw/source/core/edit/edatmisc.cxx @@ -127,7 +127,7 @@ const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFmtHint ) const } -void SwEditShell::SetAttr( const SfxPoolItem& rHint, sal_uInt16 nFlags ) +void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, sal_uInt16 nFlags ) { SET_CURR_SHELL( this ); StartAllAction(); @@ -157,7 +157,7 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, sal_uInt16 nFlags ) } -void SwEditShell::SetAttr( const SfxItemSet& rSet, sal_uInt16 nFlags ) +void SwEditShell::SetAttrSet( const SfxItemSet& rSet, sal_uInt16 nFlags ) { SET_CURR_SHELL( this ); StartAllAction(); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 55c093d22a04..37bd0ab3d03c 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -242,9 +242,8 @@ bool SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) SwPaM* pCrsr = GetCrsr(), *pFirst = pCrsr; do { - bChgd |= pDoc->SetCurFtn( *pCrsr, rFillFtn.GetNumStr(), - rFillFtn.GetNumber(), - rFillFtn.IsEndNote() ); + bChgd |= + pDoc->SetCurFtn( *pCrsr, rFillFtn.GetNumStr(), rFillFtn.GetNumber(), rFillFtn.IsEndNote() ); } while( pFirst != ( pCrsr = (SwPaM*)pCrsr->GetNext() )); @@ -423,7 +422,6 @@ sal_Bool lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, { bRet = sal_False; - // --> OD 2008-03-19 #refactorlists# if ( rTNd.IsInList() ) { ASSERT( rTNd.GetNumRule(), @@ -435,19 +433,19 @@ sal_Bool lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, //other place in dev env... if ( pNumRule ) { - //End - const SwNumFmt &rNumFmt = pNumRule->Get( static_cast<sal_uInt16>(rTNd.GetActualListLevel()) ); - if( SVX_NUM_BITMAP != rNumFmt.GetNumberingType() ) - { - if ( SVX_NUM_CHAR_SPECIAL == rNumFmt.GetNumberingType() ) - sExp = rNumFmt.GetBulletChar(); - else - sExp = rTNd.GetNumString(); + //End + const SwNumFmt &rNumFmt = pNumRule->Get( static_cast<sal_uInt16>(rTNd.GetActualListLevel()) ); + if( SVX_NUM_BITMAP != rNumFmt.GetNumberingType() ) + { + if ( SVX_NUM_CHAR_SPECIAL == rNumFmt.GetNumberingType() ) + sExp = rNumFmt.GetBulletChar(); + else + sExp = rTNd.GetNumString(); } - //Modified for i119959,2012.6.12 - //Under this scenario,this pointer is null,but on win,it doesn't crash immediately - //it exits with exception,and associated memory will have problem which leads to crash problem in - //other place in dev env... + //Modified for i119959,2012.6.12 + //Under this scenario,this pointer is null,but on win,it doesn't crash immediately + //it exits with exception,and associated memory will have problem which leads to crash problem in + //other place in dev env... } //End } diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index c29454bf3d7a..5ae8f562b7c7 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -28,7 +28,6 @@ #include <unotools/charclass.hxx> #include <editsh.hxx> #include <fldbas.hxx> -#include <ndtxt.hxx> // GetCurFld #include <doc.hxx> #include <docary.hxx> #include <fmtfld.hxx> @@ -228,65 +227,15 @@ void SwEditShell::Insert2(SwField& rFld, const bool bForceExpandHints) ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND : nsSetAttrMode::SETATTR_DEFAULT; - FOREACHPAM_START(this) // fuer jeden PaM - bool bSuccess(GetDoc()->InsertPoolItem(*PCURCRSR, aFld, nInsertFlags)); + FOREACHPAM_START(this) + const bool bSuccess(GetDoc()->InsertPoolItem(*PCURCRSR, aFld, nInsertFlags)); ASSERT( bSuccess, "Doc->Insert(Field) failed"); (void) bSuccess; - FOREACHPAM_END() // fuer jeden PaM + FOREACHPAM_END() EndAllAction(); } -/************************************************************************* -|* -|* SwEditShell::GetCurFld() -|* -|* Beschreibung Stehen die PaMs auf Feldern ? -|* Quelle: edtfrm.cxx: -|* -*************************************************************************/ - -inline SwTxtFld *GetDocTxtFld( const SwPosition* pPos ) -{ - SwTxtNode * const pNode = pPos->nNode.GetNode().GetTxtNode(); - return (pNode) - ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( - pPos->nContent.GetIndex(), RES_TXTATR_FIELD )) - : 0; -} - -SwField* SwEditShell::GetCurFld() const -{ - // Wenn es keine Selektionen gibt, gilt der Wert der aktuellen - // Cursor-Position. - - SwPaM* pCrsr = GetCrsr(); - SwTxtFld *pTxtFld = GetDocTxtFld( pCrsr->Start() ); - SwField *pCurFld = NULL; - - /* #108536# Field was only recognized if no selection was - present. Now it is recognized if either the cursor is in the - field or the selection spans exactly over the field. */ - if( pTxtFld && - pCrsr->GetNext() == pCrsr && - pCrsr->Start()->nNode == pCrsr->End()->nNode && - (pCrsr->End()->nContent.GetIndex() - - pCrsr->Start()->nContent.GetIndex()) <= 1) - { - pCurFld = (SwField*)pTxtFld->GetFmtFld().GetField(); - // TabellenFormel ? wandel internen in externen Namen um - if( RES_TABLEFLD == pCurFld->GetTyp()->Which() ) - { - const SwTableNode* pTblNd = IsCrsrInTbl(); - ((SwTblField*)pCurFld)->PtrToBoxNm( pTblNd ? &pTblNd->GetTable() : 0 ); - } - - } - - /* #108536# removed handling of multi-selections */ - - return pCurFld; -} /************************************************************************* @@ -299,18 +248,28 @@ SwField* SwEditShell::GetCurFld() const *************************************************************************/ SwTxtFld* lcl_FindInputFld( SwDoc* pDoc, SwField& rFld ) { - // suche das Feld ueber seine Addresse. Muss fuer InputFelder in - // geschuetzten Feldern erfolgen SwTxtFld* pTFld = 0; - if( RES_INPUTFLD == rFld.Which() || ( RES_SETEXPFLD == rFld.Which() && - ((SwSetExpField&)rFld).GetInputFlag() ) ) + if( RES_INPUTFLD == rFld.Which() ) + { + const SfxPoolItem* pItem = NULL; + const sal_uInt32 nMaxItems = + pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD ); + for( sal_uInt32 n = 0; n < nMaxItems; ++n ) + if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n ) ) + && ((SwFmtFld*)pItem)->GetField() == &rFld ) + { + pTFld = ((SwFmtFld*)pItem)->GetTxtFld(); + break; + } + } + else if( RES_SETEXPFLD == rFld.Which() + && ((SwSetExpField&)rFld).GetInputFlag() ) { - const SfxPoolItem* pItem; - sal_uInt32 n, nMaxItems = + const SfxPoolItem* pItem = NULL; + const sal_uInt32 nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD ); - for( n = 0; n < nMaxItems; ++n ) - if( 0 != (pItem = - pDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n ) ) + for( sal_uInt32 n = 0; n < nMaxItems; ++n ) + if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n ) ) && ((SwFmtFld*)pItem)->GetField() == &rFld ) { pTFld = ((SwFmtFld*)pItem)->GetTxtFld(); @@ -339,14 +298,9 @@ void SwEditShell::UpdateFlds( SwField &rFld ) SwTxtFld *pTxtFld; SwFmtFld *pFmtFld; -// if( pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() && -// ( 0 != ( pTxtFld = GetDocTxtFld( pCrsr->Start() ) ) || -// 0 != ( pTxtFld = lcl_FindInputFld( GetDoc(), rFld ) ) ) && -// ( pFmtFld = (SwFmtFld*)&pTxtFld->GetFld())->GetFld() -// ->GetTyp()->Which() == rFld.GetTyp()->Which() ) if ( pCrsr->GetNext() == pCrsr && !pCrsr->HasMark()) { - pTxtFld = GetDocTxtFld(pCrsr->Start()); + pTxtFld = GetTxtFldAtPos( pCrsr->Start(), true ); if (!pTxtFld) // #i30221# pTxtFld = lcl_FindInputFld( GetDoc(), rFld); @@ -361,7 +315,8 @@ void SwEditShell::UpdateFlds( SwField &rFld ) sal_Bool bOkay = sal_True; sal_Bool bTblSelBreak = sal_False; - SwMsgPoolItem aHint( RES_TXTATR_FIELD ); // Such-Hint + SwMsgPoolItem aFldHint( RES_TXTATR_FIELD ); + SwMsgPoolItem aInputFldHint( RES_TXTATR_INPUTFIELD ); FOREACHPAM_START(this) // fuer jeden PaM if( PCURCRSR->HasMark() && bOkay ) // ... mit Selektion { @@ -382,13 +337,14 @@ void SwEditShell::UpdateFlds( SwField &rFld ) // Suche nach SwTxtFld ... while( bOkay && pCurStt->nContent != pCurEnd->nContent - && aPam.Find( aHint, sal_False, fnMoveForward, &aCurPam ) ) + && ( aPam.Find( aFldHint, sal_False, fnMoveForward, &aCurPam ) + || aPam.Find( aInputFldHint, sal_False, fnMoveForward, &aCurPam ) ) ) { // wenn nur ein Pam mehr als ein Feld enthaelt ... if( aPam.Start()->nContent != pCurStt->nContent ) bOkay = sal_False; - if( 0 != (pTxtFld = GetDocTxtFld( pCurStt )) ) + if( 0 != (pTxtFld = GetTxtFldAtPos( pCurStt, true )) ) { pFmtFld = (SwFmtFld*)&pTxtFld->GetFmtFld(); pCurFld = pFmtFld->GetField(); diff --git a/sw/source/core/edit/edfldexp.cxx b/sw/source/core/edit/edfldexp.cxx index 6e6dd1cc91ed..49d8f454c035 100644 --- a/sw/source/core/edit/edfldexp.cxx +++ b/sw/source/core/edit/edfldexp.cxx @@ -31,7 +31,6 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <doc.hxx> #include <docary.hxx> -#include <ndtxt.hxx> // GetCurFld #include <txtfld.hxx> #include <fmtfld.hxx> #include <edimp.hxx> diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 81c0f3b1ef9e..2e7260e4df60 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -785,7 +785,7 @@ sal_Bool SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, s else bInsTxt = sal_False; - SetAttr( rFmt ); + SetAttrItem( rFmt ); if (bInsTxt && !IsCrsrPtAtEnd()) SwapPam(); if(!bKeepSelection) @@ -815,7 +815,7 @@ sal_uInt16 SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr ) { SwTxtINetFmt& rAttr = *pFnd; String sTxt( pTxtNd->GetExpandTxt( *rAttr.GetStart(), - *rAttr.GetEnd() - *rAttr.GetStart() ) ); + *rAttr.End() - *rAttr.GetStart() ) ); sTxt.EraseAllChars( 0x0a ); sTxt.EraseLeadingChars().EraseTrailingChars(); diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index c22f261a82e0..6b3830afebb2 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -1382,13 +1382,13 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, pDoc->DeleteAndJoin(*pCrsr); // ... and apply language if necessary if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) - SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); + SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); } else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) { //apply language - SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); + SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); } else if( aCurrentNewPortion->bIgnoreThisError ) { @@ -1429,7 +1429,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, GetCurAttr( aSet ); const SvxLanguageItem& rLang = static_cast<const SvxLanguageItem& >(aSet.Get(nLangWhichId)); if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage) - SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) ); + SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) ); //insert the new string pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 743834791f73..857bba8acdf8 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -209,7 +209,7 @@ sal_Bool SwEditShell::SelectionHasNumber() const return bResult; } -//Sym3_879 add a new function to determine number on/off status +//add a new function to determine number on/off status sal_Bool SwEditShell::SelectionHasBullet() const { sal_Bool bResult = HasBullet(); @@ -731,7 +731,6 @@ sal_Bool SwEditShell::IsNoNum( sal_Bool bChkStart ) const return bResult; } -// --> OD 2008-02-29 #refactorlists# - removed <pHasChilds> sal_uInt8 SwEditShell::GetNumLevel() const { // gebe die akt. Ebene zurueck, auf der sich der Point vom Cursor befindet @@ -741,22 +740,18 @@ sal_uInt8 SwEditShell::GetNumLevel() const SwPaM* pCrsr = GetCrsr(); const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode(); - // --> FME 2005-09-12 #124972# Made code robust: ASSERT( pTxtNd, "GetNumLevel() without text node" ) if ( !pTxtNd ) return nLevel; - // <-- const SwNumRule* pRule = pTxtNd->GetNumRule(); if(pRule) { - // --> OD 2008-05-09 #refactorlists# const int nListLevelOfTxtNode( pTxtNd->GetActualListLevel() ); if ( nListLevelOfTxtNode >= 0 ) { nLevel = static_cast<sal_uInt8>( nListLevelOfTxtNode ); } - // <-- } return nLevel; @@ -784,21 +779,16 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule, SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n ) - { + { aRangeArr.SetPam( n, aPam ); - // --> OD 2008-02-08 #newlistlevelattrs# - // --> OD 2008-03-17 #refactorlists# GetDoc()->SetNumRule( aPam, rRule, bCreateNewList, sContinuedListId, sal_True, bResetIndentAttrs ); - // <-- GetDoc()->SetCounted( aPam, true ); - } + } } else { - // --> OD 2008-02-08 #newlistlevelattrs# - // --> OD 2008-03-17 #refactorlists# GetDoc()->SetNumRule( *pCrsr, rRule, bCreateNewList, sContinuedListId, sal_True, bResetIndentAttrs ); diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 5771a33f910b..8fa4676aa2a8 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -84,8 +84,8 @@ void SwEditShell::Insert(const SwTOXMark& rMark) } else if( *pEnd != *pStt ) { - GetDoc()->InsertPoolItem( *PCURCRSR, rMark, - nsSetAttrMode::SETATTR_DONTEXPAND ); + GetDoc()->InsertPoolItem( + *PCURCRSR, rMark, nsSetAttrMode::SETATTR_DONTEXPAND ); } FOREACHPAM_END() diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 67c533925e80..253e9aaf3b22 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -976,12 +976,162 @@ void SwSetExpField::SetPar2(const String& rStr) } } + +sal_Bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) +{ + sal_Int32 nTmp32 = 0; + sal_Int16 nTmp16 = 0; + String sTmp; + switch( nWhichId ) + { + case FIELD_PROP_BOOL2: + if(*(sal_Bool*)rAny.getValue()) + nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE; + else + nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; + break; + case FIELD_PROP_FORMAT: + rAny >>= nTmp32; + SetFormat(nTmp32); + break; + case FIELD_PROP_USHORT2: + { + rAny >>= nTmp16; + if(nTmp16 <= SVX_NUMBER_NONE ) + SetFormat(nTmp16); + else { + //exception(wrong_value) + ; + } + } + break; + case FIELD_PROP_USHORT1: + rAny >>= nTmp16; + nSeqNo = nTmp16; + break; + case FIELD_PROP_PAR1: + SetPar1( SwStyleNameMapper::GetUIName( + ::GetString( rAny, sTmp ), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); + break; + case FIELD_PROP_PAR2: + { + OUString uTmp; + rAny >>= uTmp; + //I18N - if the formula contains only "TypeName+1" + //and it's one of the initially created sequence fields + //then the localized names has to be replaced by a programmatic name + OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False); + SetFormula( sMyFormula ); + } + break; + case FIELD_PROP_DOUBLE: + { + double fVal = 0.0; + rAny >>= fVal; + SetValue(fVal); + } + break; + case FIELD_PROP_SUBTYPE: + nTmp32 = lcl_APIToSubType(rAny); + if(nTmp32 >= 0) + SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32)); + break; + case FIELD_PROP_PAR3: + ::GetString( rAny, aPText ); + break; + case FIELD_PROP_BOOL3: + if(*(sal_Bool*) rAny.getValue()) + nSubType |= nsSwExtendedSubType::SUB_CMD; + else + nSubType &= (~nsSwExtendedSubType::SUB_CMD); + break; + case FIELD_PROP_BOOL1: + SetInputFlag(*(sal_Bool*) rAny.getValue()); + break; + case FIELD_PROP_PAR4: + ChgExpStr( ::GetString( rAny, sTmp )); + break; + default: + return SwField::PutValue(rAny, nWhichId); + } + return sal_True; +} + + +sal_Bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const +{ + switch( nWhichId ) + { + case FIELD_PROP_BOOL2: + { + sal_Bool bVal = 0 == (nSubType & nsSwExtendedSubType::SUB_INVISIBLE); + rAny.setValue(&bVal, ::getBooleanCppuType()); + } + break; + case FIELD_PROP_FORMAT: + rAny <<= (sal_Int32)GetFormat(); + break; + case FIELD_PROP_USHORT2: + rAny <<= (sal_Int16)GetFormat(); + break; + case FIELD_PROP_USHORT1: + rAny <<= (sal_Int16)nSeqNo; + break; + case FIELD_PROP_PAR1: + rAny <<= OUString ( SwStyleNameMapper::GetProgName(GetPar1(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); + break; + case FIELD_PROP_PAR2: + { + //I18N - if the formula contains only "TypeName+1" + //and it's one of the initially created sequence fields + //then the localized names has to be replaced by a programmatic name + OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True); + rAny <<= OUString( sMyFormula ); + } + break; + case FIELD_PROP_DOUBLE: + rAny <<= (double)GetValue(); + break; + case FIELD_PROP_SUBTYPE: + { + sal_Int16 nRet = 0; + nRet = lcl_SubTypeToAPI(GetSubType() & 0xff); + rAny <<= nRet; + } + break; + case FIELD_PROP_PAR3: + rAny <<= OUString( aPText ); + break; + case FIELD_PROP_BOOL3: + { + sal_Bool bTmp = 0 != (nSubType & nsSwExtendedSubType::SUB_CMD); + rAny.setValue(&bTmp, ::getBooleanCppuType()); + } + break; + case FIELD_PROP_BOOL1: + { + sal_Bool bTmp = GetInputFlag(); + rAny.setValue(&bTmp, ::getBooleanCppuType()); + } + break; + case FIELD_PROP_PAR4: + rAny <<= rtl::OUString(GetExpStr()); + break; + default: + return SwField::QueryValue(rAny, nWhichId); + } + return sal_True; +} + + + /*-------------------------------------------------------------------- Beschreibung: Eingabefeld Type ---------------------------------------------------------------------*/ SwInputFieldType::SwInputFieldType( SwDoc* pD ) - : SwFieldType( RES_INPUTFLD ), pDoc( pD ) + : SwFieldType( RES_INPUTFLD ) + , pDoc( pD ) { } @@ -995,10 +1145,57 @@ SwFieldType* SwInputFieldType::Copy() const Beschreibung: Eingabefeld --------------------------------------------------------------------*/ -SwInputField::SwInputField(SwInputFieldType* pTyp, const String& rContent, - const String& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) : - SwField(pTyp, nFmt), aContent(rContent), aPText(rPrompt), nSubType(nSub) +SwInputField::SwInputField( SwInputFieldType* pFieldType, + const String& rContent, + const String& rPrompt, + sal_uInt16 nSub, + sal_uLong nFmt, + bool bIsFormField ) + : SwField( pFieldType, nFmt, LANGUAGE_SYSTEM, false ) + , aContent(rContent) + , aPText(rPrompt) + , nSubType(nSub) + , mpFmtFld( NULL ) + , mbIsFormField( bIsFormField ) +{ +} + +SwInputField::~SwInputField() +{ +} + + +void SwInputField::SetFmtFld( SwFmtFld& rFmtFld ) { + mpFmtFld = &rFmtFld; +} + +SwFmtFld* SwInputField::GetFmtFld() +{ + return mpFmtFld; +} + + +const String& SwInputField::getContent() const +{ + return aContent; +} + +void SwInputField::applyFieldContent( const String& rNewFieldContent ) +{ + if ( (nSubType & 0x00ff) == INP_TXT ) + { + aContent = rNewFieldContent; + } + else if( (nSubType & 0x00ff) == INP_USR ) + { + SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>( + static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->GetFldType( RES_USERFLD, getContent(), false ) ); + if( pUserTyp ) + { + pUserTyp->SetContent( rNewFieldContent ); + } + } } String SwInputField::GetFieldName() const @@ -1008,18 +1205,24 @@ String SwInputField::GetFieldName() const { aStr += GetTyp()->GetName(); aStr += ' '; - aStr += aContent; + aStr += getContent(); } return aStr; } SwField* SwInputField::Copy() const { - SwInputField* pFld = new SwInputField((SwInputFieldType*)GetTyp(), aContent, - aPText, GetSubType(), GetFormat()); + SwInputField* pFld = + new SwInputField( + static_cast<SwInputFieldType*>(GetTyp()), + getContent(), + aPText, + GetSubType(), + GetFormat(), + mbIsFormField ); - pFld->SetHelp(aHelp); - pFld->SetToolTip(aToolTip); + pFld->SetHelp( aHelp ); + pFld->SetToolTip( aToolTip ); pFld->SetAutomaticLanguage(IsAutomaticLanguage()); return pFld; @@ -1028,26 +1231,35 @@ SwField* SwInputField::Copy() const String SwInputField::Expand() const { String sRet; - if((nSubType & 0x00ff) == INP_TXT) - sRet = aContent; - + if ( (nSubType & 0x00ff) == INP_TXT ) + { + sRet = getContent(); + } else if( (nSubType & 0x00ff) == INP_USR ) { - SwUserFieldType* pUserTyp = (SwUserFieldType*) - ((SwInputFieldType*)GetTyp())->GetDoc()-> - GetFldType( RES_USERFLD, aContent, false ); + SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>( + static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->GetFldType( RES_USERFLD, getContent(), false ) ); if( pUserTyp ) sRet = pUserTyp->GetContent(); } return sRet; } + +bool SwInputField::isFormField() const +{ + return mbIsFormField + || aHelp.Len() > 0 + || aToolTip.Len() > 0; +} + + sal_Bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const { switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( aContent ); + rAny <<= OUString( getContent() ); break; case FIELD_PROP_PAR2: rAny <<= OUString( aPText ); @@ -1069,7 +1281,9 @@ sal_Bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_PAR1: - ::GetString( rAny, aContent ); + { + ::GetString( rAny, aContent ); + } break; case FIELD_PROP_PAR2: ::GetString( rAny, aPText ); @@ -1085,9 +1299,7 @@ sal_Bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } return sal_True; } -/*-------------------------------------------------------------------- - Beschreibung: Bedingung setzen - --------------------------------------------------------------------*/ + void SwInputField::SetPar1(const String& rStr) { @@ -1096,12 +1308,9 @@ void SwInputField::SetPar1(const String& rStr) const String& SwInputField::GetPar1() const { - return aContent; + return getContent(); } -/*-------------------------------------------------------------------- - Beschreibung: True/False Text - --------------------------------------------------------------------*/ void SwInputField::SetPar2(const String& rStr) { @@ -1133,11 +1342,6 @@ String SwInputField::GetToolTip() const return aToolTip; } -sal_Bool SwInputField::isFormField() const -{ - return aHelp.Len() > 0 || aToolTip.Len() > 0; -} - sal_uInt16 SwInputField::GetSubType() const { return nSubType; @@ -1148,150 +1352,3 @@ void SwInputField::SetSubType(sal_uInt16 nSub) nSubType = nSub; } -sal_Bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const -{ - switch( nWhichId ) - { - case FIELD_PROP_BOOL2: - { - sal_Bool bVal = 0 == (nSubType & nsSwExtendedSubType::SUB_INVISIBLE); - rAny.setValue(&bVal, ::getBooleanCppuType()); - } - break; - case FIELD_PROP_FORMAT: - rAny <<= (sal_Int32)GetFormat(); - break; - case FIELD_PROP_USHORT2: - rAny <<= (sal_Int16)GetFormat(); - break; - case FIELD_PROP_USHORT1: - rAny <<= (sal_Int16)nSeqNo; - break; - case FIELD_PROP_PAR1: - rAny <<= OUString ( SwStyleNameMapper::GetProgName(GetPar1(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); - break; - case FIELD_PROP_PAR2: - { - //I18N - if the formula contains only "TypeName+1" - //and it's one of the initially created sequence fields - //then the localized names has to be replaced by a programmatic name - OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True); - rAny <<= OUString( sMyFormula ); - } - break; - case FIELD_PROP_DOUBLE: - rAny <<= (double)GetValue(); - break; - case FIELD_PROP_SUBTYPE: - { - sal_Int16 nRet = 0; - nRet = lcl_SubTypeToAPI(GetSubType() & 0xff); - rAny <<= nRet; - } - break; - case FIELD_PROP_PAR3: - rAny <<= OUString( aPText ); - break; - case FIELD_PROP_BOOL3: - { - sal_Bool bTmp = 0 != (nSubType & nsSwExtendedSubType::SUB_CMD); - rAny.setValue(&bTmp, ::getBooleanCppuType()); - } - break; - case FIELD_PROP_BOOL1: - { - sal_Bool bTmp = GetInputFlag(); - rAny.setValue(&bTmp, ::getBooleanCppuType()); - } - break; - case FIELD_PROP_PAR4: - rAny <<= rtl::OUString(GetExpStr()); - break; - default: - return SwField::QueryValue(rAny, nWhichId); - } - return sal_True; -} - -sal_Bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) -{ - sal_Int32 nTmp32 = 0; - sal_Int16 nTmp16 = 0; - String sTmp; - switch( nWhichId ) - { - case FIELD_PROP_BOOL2: - if(*(sal_Bool*)rAny.getValue()) - nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE; - else - nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; - break; - case FIELD_PROP_FORMAT: - rAny >>= nTmp32; - SetFormat(nTmp32); - break; - case FIELD_PROP_USHORT2: - { - rAny >>= nTmp16; - if(nTmp16 <= SVX_NUMBER_NONE ) - SetFormat(nTmp16); - else { - //exception(wrong_value) - ; - } - } - break; - case FIELD_PROP_USHORT1: - rAny >>= nTmp16; - nSeqNo = nTmp16; - break; - case FIELD_PROP_PAR1: - SetPar1( SwStyleNameMapper::GetUIName( - ::GetString( rAny, sTmp ), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); - break; - case FIELD_PROP_PAR2: - { - OUString uTmp; - rAny >>= uTmp; - //I18N - if the formula contains only "TypeName+1" - //and it's one of the initially created sequence fields - //then the localized names has to be replaced by a programmatic name - OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False); - SetFormula( sMyFormula ); - } - break; - case FIELD_PROP_DOUBLE: - { - double fVal = 0.0; - rAny >>= fVal; - SetValue(fVal); - } - break; - case FIELD_PROP_SUBTYPE: - nTmp32 = lcl_APIToSubType(rAny); - if(nTmp32 >= 0) - SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32)); - break; - case FIELD_PROP_PAR3: - ::GetString( rAny, aPText ); - break; - case FIELD_PROP_BOOL3: - if(*(sal_Bool*) rAny.getValue()) - nSubType |= nsSwExtendedSubType::SUB_CMD; - else - nSubType &= (~nsSwExtendedSubType::SUB_CMD); - break; - case FIELD_PROP_BOOL1: - SetInputFlag(*(sal_Bool*) rAny.getValue()); - break; - case FIELD_PROP_PAR4: - ChgExpStr( ::GetString( rAny, sTmp )); - break; - default: - return SwField::PutValue(rAny, nWhichId); - } - return sal_True; -} - - - diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 2c70ae22f362..506de16f17e3 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -180,13 +180,19 @@ sal_Bool SwFieldType::PutValue( const uno::Any& , sal_uInt16 ) Felder sind n-mal vorhanden, Feldtypen nur einmal --------------------------------------------------------------------*/ -SwField::SwField(SwFieldType* pTyp, sal_uInt32 nFmt, sal_uInt16 nLng) : - nLang(nLng), - bIsAutomaticLanguage(sal_True), - nFormat(nFmt) +SwField::SwField( + SwFieldType* pTyp, + sal_uInt32 nFmt, + sal_uInt16 nLng, + bool bUseFieldValueCache ) + : m_Cache() + , m_bUseFieldValueCache( bUseFieldValueCache ) + , nLang( nLng ) + , bIsAutomaticLanguage( sal_True ) + , nFormat( nFmt ) + , pType( pTyp ) { ASSERT( pTyp, "SwField: ungueltiger SwFieldType" ); - pType = pTyp; } SwField::~SwField() @@ -425,11 +431,16 @@ sal_Bool SwField::IsFixed() const String SwField::ExpandField(bool const bCached) const { - if (!bCached) // #i85766# do not expand fields in clipboard documents + if ( m_bUseFieldValueCache ) { - m_Cache = Expand(); + if (!bCached) // #i85766# do not expand fields in clipboard documents + { + m_Cache = Expand(); + } + return m_Cache; } - return m_Cache; + + return Expand(); } SwField * SwField::CopyField() const @@ -438,6 +449,8 @@ SwField * SwField::CopyField() const // #i85766# cache expansion of source (for clipboard) // use this->cache, not this->Expand(): only text formatting calls Expand() pNew->m_Cache = m_Cache; + pNew->m_bUseFieldValueCache = m_bUseFieldValueCache; + return pNew; } diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 2996950307ab..3820a0ca1492 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -277,7 +277,6 @@ String SwGetRefField::GetFieldName() const return aStr; } -// --> OD 2007-09-07 #i81002# - parameter <pFldTxtAttr> added void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) { sTxt.Erase(); @@ -285,8 +284,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc(); sal_uInt16 nStt = USHRT_MAX; sal_uInt16 nEnd = USHRT_MAX; - SwTxtNode* pTxtNd = SwGetRefFieldType::FindAnchor( pDoc, sSetRefName, - nSubType, nSeqNo, &nStt, &nEnd ); + SwTxtNode* pTxtNd = SwGetRefFieldType::FindAnchor( pDoc, sSetRefName, nSubType, nSeqNo, &nStt, &nEnd ); if ( !pTxtNd ) { sTxt = ViewShell::GetShellRes()->aGetRefFld_RefItemNotFound; @@ -314,8 +312,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) case REF_ONLYCAPTION: { - const SwTxtAttr* const pTxtAttr = - pTxtNd->GetTxtAttrForCharAt(nStt, RES_TXTATR_FIELD); + const SwTxtAttr* const pTxtAttr = pTxtNd->GetTxtAttrForCharAt(nStt, RES_TXTATR_FIELD); if( pTxtAttr ) nStt = SwGetExpField::GetReferenceTextPos( pTxtAttr->GetFmtFld(), *pDoc ); @@ -423,32 +420,29 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) case REF_UPDOWN: { - // --> OD 2007-09-07 #i81002# // simplified: use parameter <pFldTxtAttr> if( !pFldTxtAttr || !pFldTxtAttr->GetpTxtNode() ) break; - LocaleDataWrapper aLocaleData( - ::comphelper::getProcessServiceFactory(), - SvxCreateLocale( GetLanguage() ) ); + LocaleDataWrapper aLocaleData( ::comphelper::getProcessServiceFactory(), SvxCreateLocale( GetLanguage() ) ); // erstmal ein "Kurz" - Test - falls beide im selben // Node stehen! if( pFldTxtAttr->GetpTxtNode() == pTxtNd ) { sTxt = nStt < *pFldTxtAttr->GetStart() - ? aLocaleData.getAboveWord() - : aLocaleData.getBelowWord(); + ? aLocaleData.getAboveWord() + : aLocaleData.getBelowWord(); break; } - sTxt = ::IsFrameBehind( *pFldTxtAttr->GetpTxtNode(), *pFldTxtAttr->GetStart(), - *pTxtNd, nStt ) - ? aLocaleData.getAboveWord() - : aLocaleData.getBelowWord(); + sTxt = + ::IsFrameBehind( *pFldTxtAttr->GetpTxtNode(), *pFldTxtAttr->GetStart(), *pTxtNd, nStt ) + ? aLocaleData.getAboveWord() + : aLocaleData.getBelowWord(); } break; - // --> OD 2007-08-24 #i81002# + case REF_NUMBER: case REF_NUMBER_NO_CONTEXT: case REF_NUMBER_FULL_CONTEXT: @@ -459,7 +453,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) } } break; - // <-- + default: DBG_ERROR("<SwGetRefField::UpdateField(..)> - unknown format type"); } diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 5a899698ad2a..f85fd91e5c59 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -121,8 +121,12 @@ sal_Bool lcl_SetNewFlyPos( const SwNode& rNode, SwFmtAnchor& rAnchor, return bRet; } -sal_Bool lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, - SfxItemSet& rSet ) +sal_Bool lcl_FindAnchorPos( + SwEditShell& rEditShell, + SwDoc& rDoc, + const Point& rPt, + const SwFrm& rFrm, + SfxItemSet& rSet ) { sal_Bool bRet = sal_True; SwFmtAnchor aNewAnch( (SwFmtAnchor&)rSet.Get( RES_ANCHOR ) ); @@ -163,6 +167,13 @@ sal_Bool lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, else pCNd->MakeEndIndex( &aPos.nContent ); } + else + { + if ( rEditShell.PosInsideInputFld( aPos ) ) + { + aPos.nContent = rEditShell.StartOfInputFldAtPos( aPos ); + } + } } aNewAnch.SetAnchor( &aPos ); } @@ -208,7 +219,10 @@ sal_Bool lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, // //! also used in unoframe.cxx // -sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ) +sal_Bool lcl_ChkAndSetNewAnchor( + SwEditShell& rEditShell, + const SwFlyFrm& rFly, + SfxItemSet& rSet ) { const SwFrmFmt& rFmt = *rFly.GetFmt(); const SwFmtAnchor &rOldAnch = rFmt.GetAnchor(); @@ -228,7 +242,7 @@ sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ) "Unerlaubter Ankerwechsel in Head/Foot." ); #endif - return ::lcl_FindAnchorPos( *pDoc, rFly.Frm().Pos(), rFly, rSet ); + return ::lcl_FindAnchorPos( rEditShell, *pDoc, rFly.Frm().Pos(), rFly, rSet ); } void SwFEShell::SelectFlyFrm( SwFlyFrm& rFrm, sal_Bool bNew ) @@ -455,7 +469,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) // --> OD 2004-07-16 #i28701# SwAnchoredObject* pAnchoredObj = ::findConnectionToSdrObject( pObj )->GetAnchoredObj( pObj ); SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); - RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId(); + const RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId(); if ( FLY_AS_CHAR == nAnchorId ) return aRet; @@ -494,18 +508,20 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) pFooterOrHeader = pCntnt->FindFooterOrHeader(); } - //Ausgehend von der linken oberen Ecke des Fly den - //dichtesten SwFlyFrm suchen. - SwCntntFrm *pTxtFrm; + SwCntntFrm *pTxtFrm = NULL; { SwCrsrMoveState aState( MV_SETONLYTEXT ); SwPosition aPos( GetDoc()->GetNodes().GetEndOfExtras() ); Point aTmpPnt( rAbsPos ); GetLayout()->GetCrsrOfst( &aPos, aTmpPnt, &aState ); - pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(),0,&aPos,sal_False ); + if ( nAnchorId != FLY_AT_CHAR + || !PosInsideInputFld( aPos ) ) + { + pTxtFrm = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(),0,&aPos,sal_False ); + } } - const SwFrm *pNewAnch; - if( pTxtFrm ) + const SwFrm *pNewAnch = NULL; + if( pTxtFrm != NULL ) { if ( FLY_AT_PAGE == nAnchorId ) { @@ -521,8 +537,6 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) } } } - else - pNewAnch = 0; if( pNewAnch && !pNewAnch->IsProtected() ) { @@ -562,6 +576,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) GetPhyPageNum() ); break; } + case FLY_AT_FLY: { SwPosition aPos( *((SwFlyFrm*)pNewAnch)->GetFmt()-> @@ -569,26 +584,29 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) aAnch.SetAnchor( &aPos ); break; } + case FLY_AT_CHAR: - { - SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); - Point aTmpPnt( rAbsPos ); - if( pTxtFrm->GetCrsrOfst( pPos, aTmpPnt, NULL ) ) - { - SwRect aTmpRect; - pTxtFrm->GetCharRect( aTmpRect, *pPos ); - aRet = aTmpRect.Pos(); - } - else { - pPos->nNode = *pTxtFrm->GetNode(); - pPos->nContent.Assign(0,0); + SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); + Point aTmpPnt( rAbsPos ); + if( pTxtFrm->GetCrsrOfst( pPos, aTmpPnt, NULL ) ) + { + SwRect aTmpRect; + pTxtFrm->GetCharRect( aTmpRect, *pPos ); + aRet = aTmpRect.Pos(); + } + else + { + pPos->nNode = *pTxtFrm->GetNode(); + pPos->nContent.Assign(0,0); + } + break; } - break; - } default: break; + } + if( bMoveIt ) { StartAllAction(); @@ -969,7 +987,7 @@ void SwFEShell::InsertDrawObj( SdrObject& rDrawObj, aRelativePos - aTopLeft + aAnchorPos)); } - ::lcl_FindAnchorPos( *GetDoc(), rInsertPosition, *pFrm, rFlyAttrSet ); + ::lcl_FindAnchorPos( *this, *GetDoc(), rInsertPosition, *pFrm, rFlyAttrSet ); } // insert drawing object into the document creating a new <SwDrawFrmFmt> instance SwDrawFrmFmt* pFmt = GetDoc()->Insert( aPam, rDrawObj, &rFlyAttrSet, 0 ); @@ -1166,7 +1184,7 @@ sal_Bool SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet ) const Point aPt( pFly->Frm().Pos() ); if( SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, sal_False )) - ::lcl_ChkAndSetNewAnchor( *pFly, rSet ); + ::lcl_ChkAndSetNewAnchor( *this, *pFly, rSet ); SwFlyFrmFmt* pFlyFmt = (SwFlyFrmFmt*)pFly->GetFmt(); if( GetDoc()->SetFlyFrmAttr( *pFlyFmt, rSet )) @@ -1333,7 +1351,7 @@ void SwFEShell::SetFrmFmt( SwFrmFmt *pNewFmt, sal_Bool bKeepOrient, Point* pDocP { pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange ); pSet->Put( *pItem ); - if( !::lcl_ChkAndSetNewAnchor( *pFly, *pSet )) + if( !::lcl_ChkAndSetNewAnchor( *this, *pFly, *pSet )) delete pSet, pSet = 0; } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index fabe65d2f858..b3581c580ab6 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1032,9 +1032,43 @@ sal_Bool SwFEShell::IsObjSelected( const SdrObject& rObj ) const if ( IsFrmSelected() || !Imp()->HasDrawView() ) return sal_False; else - return Imp()->GetDrawView()->IsObjMarked(rObj); + return Imp()->GetDrawView()->isSdrObjectSelected(rObj); } +//IAccessibility2 Implementation 2009----- +bool SwFEShell::IsObjSameLevelWithMarked(const SdrObject& rObj) const +{ + if(!Imp()->GetDrawView()->areSdrObjectsSelected()) + { + return true; + } + + const SdrObjectVector aSdrObjectVector(Imp()->GetDrawView()->getSelectedSdrObjectVectorFromSdrMarkView()); + + if(aSdrObjectVector.empty()) + { + OSL_ENSURE(false, "OOps, areSdrObjectsSelected is true, but SdrObjectVector is empty (!)"); + } + else + { + const SdrObject& rFirstMarked = *aSdrObjectVector[0]; + + return rFirstMarked.GetParentSdrObject() == rObj.GetParentSdrObject(); + } + + return false; +} + +SdrObject* SwFEShell::getSingleSelected() const +{ + if(Imp()->GetDrawView()) + { + return Imp()->GetDrawView()->getSelectedIfSingle(); + } + + return 0; +} +//-----IAccessibility2 Implementation 2009 /************************************************************************* |* |* SwFEShell::EndTextEdit() diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 9691a676e7ee..2c6435301008 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -2255,7 +2255,11 @@ inline void UnsetFollow( SwFlowFrm *pTab ) pTab->bIsFollow = sal_False; } -void _FndBox::DelFrms( SwTable &rTable ) +//IAccessibility2 Implementation 2009----- +//Solution:When bAccTableDispose is FALSE,the acc table should not be disposed. +//void _FndBox::DelFrms( SwTable &rTable ) +void _FndBox::DelFrms( SwTable &rTable,sal_Bool bAccTableDispose ) +//-----IAccessibility2 Implementation 2009 { //Alle Lines zwischen pLineBefore und pLineBehind muessen aus dem //Layout ausgeschnitten und geloescht werden. @@ -2373,9 +2377,14 @@ void _FndBox::DelFrms( SwTable &rTable ) // next turn. ((SwTabFrm*)pTabFrm)->SetFollowFlowLine( sal_False ); } - + //IAccessibility2 Implementation 2009----- + //Solution:Set acc table dispose state + pFrm->SetAccTableDispose( bAccTableDispose ); pFrm->Cut(); + //Solution:Set acc table dispose state to default value. + pFrm->SetAccTableDispose( sal_True ); delete pFrm; + //-----IAccessibility2 Implementation 2009 } } } diff --git a/sw/source/core/inc/SwPortionHandler.hxx b/sw/source/core/inc/SwPortionHandler.hxx index 34fcb94b6952..7d26954a150b 100644 --- a/sw/source/core/inc/SwPortionHandler.hxx +++ b/sw/source/core/inc/SwPortionHandler.hxx @@ -92,6 +92,10 @@ public: * paragraph's portions have been processed. */ virtual void Finish() = 0; + //IAccessibility2 Implementation 2009----- + virtual void SetAttrFieldType( sal_uInt16 ) + { return; } + //-----IAccessibility2 Implementation 2009 }; #endif diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx index 691dc53f4234..7da844b24565 100644 --- a/sw/source/core/inc/docfld.hxx +++ b/sw/source/core/inc/docfld.hxx @@ -80,10 +80,7 @@ public: _SetGetExpFld( const SwFlyFrmFmt& rFlyFmt, const SwPosition* pPos = 0 ); - sal_Bool operator==( const _SetGetExpFld& rFld ) const - { return nNode == rFld.nNode && nCntnt == rFld.nCntnt && - ( !CNTNT.pTxtFld || !rFld.CNTNT.pTxtFld || - CNTNT.pTxtFld == rFld.CNTNT.pTxtFld ); } + sal_Bool operator==( const _SetGetExpFld& rFld ) const; sal_Bool operator<( const _SetGetExpFld& rFld ) const; const SwTxtFld* GetTxtFld() const diff --git a/sw/source/core/inc/doctxm.hxx b/sw/source/core/inc/doctxm.hxx index 6cc70f26606d..7c9f0a23bbe9 100644 --- a/sw/source/core/inc/doctxm.hxx +++ b/sw/source/core/inc/doctxm.hxx @@ -101,6 +101,9 @@ public: void Update( const SfxItemSet* pAttr = 0, const bool _bNewTOX = false ); // Formatieren void UpdatePageNum(); // Seitennummern einfuegen +//IAccessibility2 Implementation 2009----- + SwTOXSortTabBases* GetTOXSortTabBases() { return &aSortArr; } +//-----IAccessibility2 Implementation 2009 sal_Bool SetPosAtStartEnd( SwPosition& rPos, sal_Bool bAtStart = sal_True ) const; }; diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 0c6867391d7b..9509bb5b3cf0 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -29,6 +29,11 @@ #include "calbck.hxx" // fuer SwClient #include <svl/brdcst.hxx> +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/style/TabStop.hpp> +#include <comphelper/stlunosequence.hxx> +using namespace ::com::sun::star; +//-----IAccessibility2 Implementation 2009 class SwLayoutFrm; class SwRootFrm; class SwPageFrm; @@ -292,6 +297,10 @@ class SwFrm: public SwClient, public SfxBroadcaster //Cache fuer (Umrandungs-)Attribute. static SwCache *pCache; + //IAccessibility2 Implementation 2009----- + //Solution:Member to identify if acc table should be disposed + sal_Bool bIfAccTableShouldDisposing; + //-----IAccessibility2 Implementation 2009 // --> OD 2006-05-10 #i65250# // frame ID is now in general available - used for layout loop control @@ -415,6 +424,12 @@ protected: sal_Bool bRetouche: 1; //Der Frame ist fuer Retusche verantwortlich //wenn sal_True. public: + //IAccessibility2 Implementation 2009----- + virtual uno::Sequence< style::TabStop > GetTabStopInfo( SwTwips ) + { + return uno::Sequence< style::TabStop >(); + } + //-----IAccessibility2 Implementation 2009 sal_Bool bUnUsed2: 1; protected: sal_Bool bInfInvalid: 1; //InfoFlags sind Invalid. @@ -767,6 +782,10 @@ public: virtual Size ChgSize( const Size& aNewSize ); virtual void Cut() = 0; + //IAccessibility2 Implementation 2009----- + //Solution:Add a method to change the acc table dispose state. + void SetAccTableDispose( sal_Bool bDispose){ bIfAccTableShouldDisposing = bDispose;} + //-----IAccessibility2 Implementation 2009 virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) = 0; void ValidateLineNum() { bValidLineNum = sal_True; } diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx index a90ef2ee331f..fdbd37979496 100644 --- a/sw/source/core/inc/rolbck.hxx +++ b/sw/source/core/inc/rolbck.hxx @@ -403,11 +403,14 @@ public: // helper methods for recording attribute in History // used by Undo classes (Delete/Overwrite/Inserts) - void CopyAttr( SwpHints* pHts, sal_uLong nNodeIdx, xub_StrLen nStart, - xub_StrLen nEnd, bool bFields ); - // --> OD 2008-02-27 #refactorlists# - removed <rDoc> + void CopyAttr( + SwpHints* pHts, + const sal_uLong nNodeIdx, + const xub_StrLen nStart, + const xub_StrLen nEnd, + const bool bCopyFields ); + void CopyFmtAttr( const SfxItemSet& rSet, sal_uLong nNodeIdx ); - // <-- }; #ifndef ROLBCK_HISTORY_ONLY diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx index 3371e612ef7e..073bc99a9d6b 100644 --- a/sw/source/core/inc/rootfrm.hxx +++ b/sw/source/core/inc/rootfrm.hxx @@ -268,8 +268,9 @@ public: // next page border const SwPageFrm* GetPageAtPos( const Point& rPt, const Size* pSize = 0, bool bExtend = false ) const; - //Der Crsr moechte die zu selektierenden Bereiche wissen. - void CalcFrmRects( SwShellCrsr&, sal_Bool bIsTblSel ); + void CalcFrmRects( + SwShellCrsr&, + const sal_Bool bIsTblSel ); // Calculates the cells included from the current selection // false: There was no result because of an invalid layout diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index c54e00ce4b6f..7fafafa3092b 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -126,16 +126,20 @@ public: #define SW_SCRIPTS 3 class SwFont -{ // CJK == Chinese, Japanese, Korean - // CTL == Complex text layout ( Hebrew, Arabic ) - SwSubFont aSub[SW_SCRIPTS]; // Latin-, CJK- and CTL-font - Color* pBackColor; // background color (i.e. at character styles) - Color aUnderColor; // color of the underlining - Color aOverColor; // color of the overlining - sal_uInt8 nToxCnt; // Zaehlt die Schachtelungstiefe der Tox - sal_uInt8 nRefCnt; // Zaehlt die Schachtelungstiefe der Refs - sal_uInt8 m_nMetaCount; // count META/METAFIELD - sal_uInt8 nActual; // actual font (Latin, CJK or CTL) +{ // CJK == Chinese, Japanese, Korean + // CTL == Complex text layout ( Hebrew, Arabic ) + SwSubFont aSub[SW_SCRIPTS]; // Latin-, CJK- and CTL-font + + Color* pBackColor; // background color (i.e. at character styles) + Color aUnderColor; // color of the underlining + Color aOverColor; // color of the overlining + + sal_uInt8 nToxCnt; // Zaehlt die Schachtelungstiefe der Tox + sal_uInt8 nRefCnt; // Zaehlt die Schachtelungstiefe der Refs + sal_uInt8 m_nMetaCount; // count META/METAFIELD + sal_uInt8 m_nInputFieldCount; // count INPUTFIELD + + sal_uInt8 nActual; // actual font (Latin, CJK or CTL) // Schalter fuer die Font-Extensions sal_Bool bNoHyph :1; // SwTxtNoHyphenHere: keine Trennstelle @@ -242,6 +246,9 @@ public: inline sal_uInt8 &GetMeta() { return m_nMetaCount; } inline sal_uInt8 GetMeta() const { return m_nMetaCount; } inline bool IsMeta() const { return (0 != m_nMetaCount); } + inline sal_uInt8 &GetInputField() { return m_nInputFieldCount; } + inline sal_uInt8 GetInputField() const { return m_nInputFieldCount; } + inline bool IsInputField() const { return (0 != m_nInputFieldCount); } inline void SetURL( const sal_Bool bURL ); inline sal_Bool IsURL() const { return bURL; } inline void SetGreyWave( const sal_Bool bNew ); diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx index 85c87db2c767..3cb3a72aea10 100644 --- a/sw/source/core/inc/tabfrm.hxx +++ b/sw/source/core/inc/tabfrm.hxx @@ -33,8 +33,6 @@ class SwAttrSetChg; class SwTabFrm: public SwLayoutFrm, public SwFlowFrm { - // OD 14.03.2003 #i11760# - adjustment, because of method signature change - //darf mit den Flags spielen. friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow ); //Fuert Spezialbehandlung fuer _Get[Next|Prev]Leaf() durch. @@ -44,22 +42,22 @@ class SwTabFrm: public SwLayoutFrm, public SwFlowFrm SwTable* pTable; sal_Bool bComplete :1; //Eintrage als Repaint ohne das CompletePaint - //der Basisklasse gesetzt werden muss. Damit - //sollen unertraegliche Tabellen-Repaints - //vermieden werden. + //der Basisklasse gesetzt werden muss. Damit + //sollen unertraegliche Tabellen-Repaints + //vermieden werden. sal_Bool bCalcLowers :1; //Im MakeAll auf jedenfall auch fuer Stabilitaet - //des Inhaltes sorgen. + //des Inhaltes sorgen. sal_Bool bLowersFormatted :1;//Kommunikation zwischen MakeAll und Layact sal_Bool bLockBackMove :1; //BackMove-Test hat der Master erledigt. sal_Bool bResizeHTMLTable :1; //Resize des HTMLTableLayout rufen im MakeAll - //Zur Optimierung, damit dies nicht im - //CntntFrm::Grow gerufen werden muss, denn dann - //wird es ggf. fuer jede Zelle gerufen #47483# + //Zur Optimierung, damit dies nicht im + //CntntFrm::Grow gerufen werden muss, denn dann + //wird es ggf. fuer jede Zelle gerufen #47483# sal_Bool bONECalcLowers :1; //Primaer fuer die StarONE-SS. Beim MakeAll werden - //die Cntnts auf jedenfall per Calc() formatiert. - //es finden keine zusaetzlichen Invalidierungen - //statt und dieser Weg kann auch kaum garantien - //geben. + //die Cntnts auf jedenfall per Calc() formatiert. + //es finden keine zusaetzlichen Invalidierungen + //statt und dieser Weg kann auch kaum garantien + //geben. sal_Bool bHasFollowFlowLine :1; // Means that the first line in the follow // is indented to contain content from a broken @@ -76,7 +74,6 @@ class SwTabFrm: public SwLayoutFrm, public SwFlowFrm // is necessary, in order to let the text // flow into the FollowFlowLine sal_Bool bRemoveFollowFlowLinePending :1; - // --> OD 2004-10-04 #i26945# sal_Bool bConsiderObjsForMinCellHeight :1; // Usually, the floating screen objects // are considered on the calculation // for the minimal cell height. @@ -85,12 +82,10 @@ class SwTabFrm: public SwLayoutFrm, public SwFlowFrm // screen object for the preparation // of the re-calculation of the // last table row. - // <-- - // --> OD 2004-10-15 #i26945# sal_Bool bObjsDoesFit :1; // For splitting table rows algorithm, this boolean // indicates, if the floating screen objects fits - // <-- - sal_Bool bDummy4 :1; + + bool mbInRecalcLowerRow : 1; //Split() spaltet den Frm an der angegebenen Stelle, es wird ein //Follow erzeugt und aufgebaut und direkt hinter this gepastet. @@ -98,8 +93,11 @@ class SwTabFrm: public SwLayoutFrm, public SwFlowFrm bool Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKeep ); bool Join(); - void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &, - SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 ); + void _UpdateAttr( + const SfxPoolItem*, + const SfxPoolItem*, sal_uInt8 &, + SwAttrSetChg *pa = 0, + SwAttrSetChg *pb = 0 ); virtual sal_Bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool bHead, sal_Bool &rReformat ); @@ -168,7 +166,15 @@ public: sal_Bool IsRemoveFollowFlowLinePending() const { return bRemoveFollowFlowLinePending; } void SetRemoveFollowFlowLinePending( sal_Bool bNew ) { bRemoveFollowFlowLinePending = bNew; } - // --> OD 2004-10-04 #i26945# + bool IsInRecalcLowerRow() const + { + return mbInRecalcLowerRow; + } + void SetInRecalcLowerRow( bool bNew ) + { + mbInRecalcLowerRow = bNew; + } + sal_Bool IsConsiderObjsForMinCellHeight() const { return bConsiderObjsForMinCellHeight; @@ -177,8 +183,7 @@ public: { bConsiderObjsForMinCellHeight = _bNewConsiderObjsForMinCellHeight; } - // <-- - // --> OD 2004-10-04 #i26945# + sal_Bool DoesObjsFit() const { return bObjsDoesFit; @@ -187,15 +192,16 @@ public: { bObjsDoesFit = _bNewObjsDoesFit; } - // <-- bool RemoveFollowFlowLine(); // // End: New stuff for breaking table rows // - sal_Bool CalcFlyOffsets( SwTwips& rUpper, long& rLeftOffset, - long& rRightOffset ) const; + sal_Bool CalcFlyOffsets( + SwTwips& rUpper, + long& rLeftOffset, + long& rRightOffset ) const; SwTwips CalcHeightOfFirstContentLine() const; @@ -204,12 +210,9 @@ public: bool IsLayoutSplitAllowed() const; - // --> collapsing borders FME 2005-05-27 #i29550# bool IsCollapsingBorders() const; - // used for collapsing border lines: sal_uInt16 GetBottomLineSize() const; - // <-- collapsing DECL_FIXEDMEMPOOL_NEWDEL(SwTabFrm) }; diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index 2898b1f6898d..2ac1146afaf9 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -26,7 +26,9 @@ #include <tools/mempool.hxx> #include <tools/string.hxx> #include "cntfrm.hxx" - +//IAccessibility2 Implementation 2009----- +#include "com/sun/star/uno/Sequence.hxx" +//-----IAccessibility2 Implementation 2009 #define STRSIZE(x) (sizeof(x)-1) class SwCharRange; @@ -229,6 +231,9 @@ protected: public: + //IAccessibility2 Implementation 2009----- + com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > GetTabStopInfo( SwTwips CurrentPos ); + //-----IAccessibility2 Implementation 2009 //public, weil der eine oder andere die Methode rufen darf um das //Prepare zu sparen - mit Vorsicht zu geniessen! void Init(); diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx index bac7ace26668..4f52fdedb9f9 100644 --- a/sw/source/core/inc/txttypes.hxx +++ b/sw/source/core/inc/txttypes.hxx @@ -51,6 +51,7 @@ #define POR_PARA 0x8002 #define POR_URL 0x8003 #define POR_HNG 0x8004 +#define POR_INPUTFLD 0x8005 #define POR_DROP 0x8080 #define POR_TOX 0x8089 diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index 6f3edf5854ce..bfba5d15b9c8 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -279,6 +279,12 @@ public: inline void AddAccessibleObj( const SdrObject *pObj ); + //IAccessibility2 Implementation 2009----- + void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage); + void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection); + void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn); + //-----IAccessibility2 Implementation 2009 + // Invalidate accessible frame's frame's content void InvalidateAccessibleFrmContent( const SwFrm *pFrm ); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index b0dc8343504c..b82ff44e7f97 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3295,3 +3295,19 @@ IMapObject* SwFrmFmt::GetIMapObject( const Point& rPoint, return 0; } +sal_Bool SwFrmFmt::HasCaption() const +{ + if(pCaptionFmt != NULL && pCaptionFmt->GetDepends()) + return sal_True; + return sal_False; +} + +void SwFrmFmt::SetCaptionFmt(SwFrmFmt * pFmt) +{ + pCaptionFmt = pFmt; +} + +SwFrmFmt* SwFrmFmt::GetCaptionFmt() const +{ + return pCaptionFmt; +} diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 2f86c798d0d6..ae7c9dce15d3 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -47,26 +47,19 @@ #include <fmtornt.hxx> #include <fmtfsize.hxx> #include <fmtsrnd.hxx> +#include <txatbase.hxx> #include "tabfrm.hxx" #include "flyfrms.hxx" #include "crstate.hxx" #include "sectfrm.hxx" -// OD 29.10.2003 #113049# #include <tocntntanchoredobjectposition.hxx> -// OD 2004-05-24 #i28701# #include <dcontact.hxx> #include <sortedobjs.hxx> -// --> OD 2005-09-29 #125370#,#125957# #include <layouter.hxx> -// <-- -// --> OD 2005-11-17 #i56300# #include <objectformattertxtfrm.hxx> -// <-- -// --> OD 2006-03-06 #125892# #include <HandleAnchorNodeChg.hxx> -// <-- using namespace ::com::sun::star; @@ -1475,6 +1468,15 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) if( pCnt->GetCrsrOfst( pPos, aPt, &eTmpState ) && pPos->nNode == *pCnt->GetNode() ) { + if ( pCnt->GetNode()->GetTxtNode() != NULL ) + { + const SwTxtAttr* pTxtInputFld = + pCnt->GetNode()->GetTxtNode()->GetTxtAttrAt( pPos->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT ); + if ( pTxtInputFld != NULL ) + { + pPos->nContent = *(pTxtInputFld->GetStart()); + } + } ResetLastCharRectHeight(); if( text::RelOrientation::CHAR == pFmt->GetVertOrient().GetRelationOrient() ) nY = LONG_MAX; @@ -1493,7 +1495,6 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) pPos->nContent.Assign( pCnt->GetNode(), 0 ); } - // --> OD 2006-02-27 #125892# // handle change of anchor node: // if count of the anchor frame also change, the fly frames have to be // re-created. Thus, delete all fly frames except the <this> before the @@ -1502,9 +1503,7 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) SwHandleAnchorNodeChg aHandleAnchorNodeChg( *pFmt, aAnch, this ); pFmt->GetDoc()->SetAttr( aAnch, *pFmt ); } - // <-- } - // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()> else if ( pTmpPage && pTmpPage != GetPageFrm() ) GetPageFrm()->MoveFly( this, pTmpPage ); @@ -1515,8 +1514,7 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) GetFmt()->GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); if ( pOldPage != FindPageFrm() ) - ::Notify_Background( GetVirtDrawObj(), pOldPage, aOld, PREP_FLY_LEAVE, - sal_False ); + ::Notify_Background( GetVirtDrawObj(), pOldPage, aOld, PREP_FLY_LEAVE, sal_False ); } // OD 2004-08-12 #i32795# - Note: method no longer used in <flyincnt.cxx> diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index b865bb634f55..e1de7061a804 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -727,8 +727,8 @@ void lcl_ApplyWorkaroundForB6375613( SwFrm* p_pFirstFrmOnNewPage ) SwDoc* pDoc( pFirstTextFrmOnNewPage->GetTxtNode()->GetDoc() ); IDocumentContentOperations* pIDCO = pFirstTextFrmOnNewPage->GetTxtNode()->getIDocumentContentOperations(); const SwPaM aTmpPaM( *(pFirstTextFrmOnNewPage->GetTxtNode()) ); - pIDCO->InsertPoolItem( aTmpPaM, - SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); + pIDCO->InsertPoolItem( + aTmpPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); pFirstTextFrmOnNewPage->GetTxtNode()->UnlockModify(); uno::Reference< document::XDocumentInfoSupplier > xDoc( diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 7ffd245f41bd..a4d0b35067b9 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -95,10 +95,9 @@ SwTabFrm::SwTabFrm( SwTable &rTab, SwFrm* pSib ): bComplete = bCalcLowers = bONECalcLowers = bLowersFormatted = bLockBackMove = bResizeHTMLTable = bHasFollowFlowLine = bIsRebuildLastLine = bRestrictTableGrowth = bRemoveFollowFlowLinePending = sal_False; - // --> OD 2004-10-04 #i26945# bConsiderObjsForMinCellHeight = sal_True; bObjsDoesFit = sal_True; - // <-- + mbInRecalcLowerRow = false; bFixSize = sal_False; //Nicht nochmal auf die Importfilter hereinfallen. nType = FRMC_TAB; @@ -128,10 +127,9 @@ SwTabFrm::SwTabFrm( SwTabFrm &rTab ) : bLockJoin = bComplete = bONECalcLowers = bCalcLowers = bLowersFormatted = bLockBackMove = bResizeHTMLTable = bHasFollowFlowLine = bIsRebuildLastLine = bRestrictTableGrowth = bRemoveFollowFlowLinePending = sal_False; - // --> OD 2004-10-04 #i26945# bConsiderObjsForMinCellHeight = sal_True; bObjsDoesFit = sal_True; - // <-- + mbInRecalcLowerRow = false; bFixSize = sal_False; //Nicht nochmal auf die Importfilter hereinfallen. nType = FRMC_TAB; @@ -2076,7 +2074,7 @@ void SwTabFrm::MakeAll() } SwFrm *pPre; if ( bKeep || (0 != (pPre = FindPrev()) && - pPre->GetAttrSet()->GetKeep().GetValue()) ) + pPre->GetAttrSet()->GetKeep().GetValue()) ) { bCalcLowers = sal_True; } @@ -2102,13 +2100,12 @@ void SwTabFrm::MakeAll() SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout(); if ( pLayout && - ((Prt().*fnRect->fnGetWidth)() != nOldPrtWidth || - (Frm().*fnRect->fnGetWidth)() != nOldFrmWidth) ) + ((Prt().*fnRect->fnGetWidth)() != nOldPrtWidth || + (Frm().*fnRect->fnGetWidth)() != nOldFrmWidth) ) { delete pAccess; bCalcLowers |= pLayout->Resize( - pLayout->GetBrowseWidthByTabFrm( *this ), sal_False ); -// GetFmt()->GetDoc()->GetDocShell()->IsReadOnly() ? sal_False : sal_True ); + pLayout->GetBrowseWidthByTabFrm( *this ), sal_False ); pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this ); pAttrs = pAccess->Get(); } @@ -2161,8 +2158,7 @@ void SwTabFrm::MakeAll() pHTMLLayout->GetBrowseWidthByTabFrm( *this ), sal_False ); - pAccess= new SwBorderAttrAccess( - SwFrm::GetCache(), this ); + pAccess= new SwBorderAttrAccess( SwFrm::GetCache(), this ); pAttrs = pAccess->Get(); } @@ -2173,27 +2169,10 @@ void SwTabFrm::MakeAll() bLowersFormatted = sal_True; if ( bKeep && KEEPTAB ) { - // --> OD 2005-09-28 #b6329202# - // Consider case that table is inside another table, - // because it has to be avoided, that superior table - // is formatted. - // Thus, find next content, table or section - // and, if a section is found, get its first - // content. -// SwFrm *pNxt = FindNextCnt(); -// if( pNxt && pNxt->IsInTab() ) -// pNxt = pNxt->FindTabFrm(); -// if ( pNxt ) -// { -// pNxt->Calc(); -// if ( !GetNext() ) -// bValidPos = sal_False; -// } if ( 0 != lcl_FormatNextCntntForKeep( this ) && !GetNext() ) { bValidPos = sal_False; } - // <-- } } } @@ -2205,17 +2184,14 @@ void SwTabFrm::MakeAll() // check, if calculation of table frame is ready. - /// OD 23.10.2002 #103517# - Local variable <nDistanceToUpperPrtBottom> - /// Introduce local variable and init it with the distance from the - /// table frame bottom to the bottom of the upper printing area. - /// Note: negative values denotes the situation that table frame doesn't - /// fit in its upper. - + // Local variable <nDistanceToUpperPrtBottom> + // Introduce local variable and init it with the distance from the + // table frame bottom to the bottom of the upper printing area. + // Note: negative values denotes the situation that table frame doesn't fit in its upper. SwTwips nDistanceToUpperPrtBottom = (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)()); - /// OD 23.10.2002 #103517# - In online layout try to grow upper of table - /// frame, if table frame doesn't fit in its upper. + // In online layout try to grow upper of table frame, if table frame doesn't fit in its upper. const ViewShell *pSh = getRootFrm()->GetCurrShell(); const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode(); if ( nDistanceToUpperPrtBottom < 0 && bBrowseMode ) @@ -2223,8 +2199,7 @@ void SwTabFrm::MakeAll() if ( GetUpper()->Grow( -nDistanceToUpperPrtBottom ) ) { // upper is grown --> recalculate <nDistanceToUpperPrtBottom> - nDistanceToUpperPrtBottom = - (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)()); + nDistanceToUpperPrtBottom = (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)()); } } @@ -2234,7 +2209,6 @@ void SwTabFrm::MakeAll() // the table to be split! Only skip this if condition once. if( nDistanceToUpperPrtBottom >= 0 && !bLastRowHasToMoveToFollow ) { - // OD 23.10.2002 - translate german commentary // If there is space left in the upper printing area, join as for trial // at least one further row of an existing follow. if ( !bSplit && GetFollow() ) @@ -2279,8 +2253,8 @@ void SwTabFrm::MakeAll() // SwRowFrm *pRow = GetFollow()->GetFirstNonHeadlineRow(); - //Der Follow wird leer und damit ueberfluessig. - if ( !pRow ) + //Der Follow wird leer und damit ueberfluessig. + if ( !pRow ) { Join(); continue; @@ -2301,8 +2275,10 @@ void SwTabFrm::MakeAll() SwFrm* pNextRow = pRowToMove->GetNext(); if ( !pNextRow ) + { //Der Follow wird leer und damit ueberfluessig. Join(); + } else { pRowToMove->Cut(); @@ -2311,8 +2287,7 @@ void SwTabFrm::MakeAll() //Die Fussnoten verschieben! if ( bMoveFtns ) - if ( ((SwLayoutFrm*)pRowToMove)->MoveLowerFtns( - 0, pOldBoss, FindFtnBossFrm( sal_True ), sal_True ) ) + if ( ((SwLayoutFrm*)pRowToMove)->MoveLowerFtns( 0, pOldBoss, FindFtnBossFrm( sal_True ), sal_True ) ) GetUpper()->Calc(); pRowToMove = pNextRow; @@ -2472,7 +2447,11 @@ void SwTabFrm::MakeAll() nDeadLine = (*fnRect->fnYInc)( nDeadLine, GetUpper()->Grow( LONG_MAX, sal_True ) ); - ::lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), nDeadLine ); + { + SetInRecalcLowerRow( true ); + ::lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), nDeadLine ); + SetInRecalcLowerRow( false ); + } bLowersFormatted = sal_True; aNotify.SetLowersComplete( sal_True ); @@ -2630,10 +2609,8 @@ void SwTabFrm::MakeAll() SwFrm* pNxt = ((SwFrm*)GetFollow())->FindNext(); if ( pNxt ) { - // OD 26.08.2003 #i18103# - no formatting - // of found next frame, if its a follow - // section of the 'ColLocked' section, - // the follow table is in. + // no formatting of found next frame, if its a follow + // section of the 'ColLocked' section, the follow table is in. bool bCalcNxt = true; if ( GetFollow()->IsInSct() && pNxt->IsSctFrm() ) { @@ -2679,19 +2656,19 @@ void SwTabFrm::MakeAll() if ( !bMovedFwd && !MoveFwd( bMakePage, sal_False ) ) bMakePage = sal_False; - // --> FME 2004-06-09 #i29771# Reset bSplitError flag on change of upper + // Reset bSplitError flag on change of upper if ( GetUpper() != pOldUpper ) { bTryToSplit = true; nUnSplitted = 5; } - // <-- SWREFRESHFN( this ) bMovedFwd = bCalcLowers = sal_True; aNotify.SetLowersComplete( sal_False ); if ( IsFollow() ) - { //Um Oszillationen zu vermeiden sollte kein ungueltiger Master + { + //Um Oszillationen zu vermeiden sollte kein ungueltiger Master //zurueckbleiben. SwTabFrm *pTab = FindMaster(); if ( pTab->GetUpper() ) @@ -2711,16 +2688,17 @@ void SwTabFrm::MakeAll() } if ( bMovedBwd && GetUpper() ) + { //Beim zurueckfliessen wurde der Upper angeregt sich vollstaendig //zu Painten, dass koennen wir uns jetzt nach dem hin und her //fliessen sparen. GetUpper()->ResetCompletePaint(); + } if ( bCalcLowers && IsValid() ) { - // --> OD 2005-05-11 #i44910# - format of lower frames unnecessary - // and can cause layout loops, if table doesn't fit and isn't - // allowed to split. + // format of lower frames unnecessary and can cause layout loops, + // if table doesn't fit and isn't allowed to split. SwTwips nDistToUpperPrtBottom = (Frm().*fnRect->fnBottomDist)( (GetUpper()->*fnRect->fnGetPrtBottom)()); if ( nDistToUpperPrtBottom >= 0 || bTryToSplit ) @@ -2735,7 +2713,6 @@ void SwTabFrm::MakeAll() ASSERT( false, "debug assertion: <SwTabFrm::MakeAll()> - format of table lowers suppressed by fix i44910" ); } #endif - // <-- } } //while ( !bValidPos || !bValidSize || !bValidPrtArea ) @@ -4829,8 +4806,10 @@ SwTwips SwRowFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo ) SetCompletePaint(); SwTabFrm *pTab = FindTabFrm(); - if ( !pTab->IsRebuildLastLine() && pTab->IsFollow() && - this == pTab->GetFirstNonHeadlineRow() ) + if ( !pTab->IsRebuildLastLine() + && pTab->IsFollow() + && this == pTab->GetFirstNonHeadlineRow() + && !pTab->IsInRecalcLowerRow() ) { SwTabFrm* pMasterTab = const_cast< SwTabFrm* >( pTab->FindMaster() ); pMasterTab->InvalidatePos(); diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 0769c70a334b..a6f8abe57a28 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -2007,7 +2007,9 @@ inline void Sub( SwRegionRects& rRegion, const SwRect& rRect ) rRegion -= rRect; } -void SwRootFrm::CalcFrmRects( SwShellCrsr &rCrsr, sal_Bool bIsTblMode ) +void SwRootFrm::CalcFrmRects( + SwShellCrsr &rCrsr, + const sal_Bool bIsTblMode ) { SwPosition *pStartPos = rCrsr.Start(), *pEndPos = rCrsr.GetPoint() == pStartPos ? rCrsr.GetMark() : rCrsr.GetPoint(); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 6ba2cce31cc6..bca2036605f7 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -96,6 +96,10 @@ SwFrm::SwFrm( SwModify *pMod, SwFrm* pSib ) : pNext( 0 ), pPrev( 0 ), pDrawObjs( 0 ) + //IAccessibility2 Implementation 2009----- + //Solution:Add a member to identify if the acc table should dispose + , bIfAccTableShouldDisposing( sal_False ) + //-----IAccessibility2 Implementation 2009 , bInfBody( sal_False ) , bInfTab ( sal_False ) , bInfFly ( sal_False ) diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index f9e0375485dd..5b3216d0892f 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -794,6 +794,15 @@ void SwOLEObj::SetNode( SwOLENode* pNode ) } } +//IAccessibility2 Implementation 2009----- +String SwOLEObj::GetStyleString() +{ + String strStyle; + if (xOLERef.is() && xOLERef.IsChart()) + strStyle = xOLERef.GetChartType(); + return strStyle; +} +//-----IAccessibility2 Implementation 2009 sal_Bool SwOLEObj::IsOleRef() const { return xOLERef.is(); diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx index c54129d2acf4..a46b64ef419f 100644 --- a/sw/source/core/text/atrhndl.hxx +++ b/sw/source/core/text/atrhndl.hxx @@ -25,7 +25,7 @@ #define _ATRHNDL_HXX #define INITIAL_NUM_ATTR 3 -#define NUM_ATTRIBUTE_STACKS 40 +#define NUM_ATTRIBUTE_STACKS 41 #include <txatbase.hxx> #include <swfntcch.hxx> diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index ad06d9fdc0b7..c3973a95a953 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -132,7 +132,7 @@ const sal_uInt8 StackPos[ static_cast<sal_uInt16>(RES_TXTATR_WITHEND_END) - 0, // RES_TXTATR_CHARFMT, // 49 39, // RES_TXTATR_CJK_RUBY, // 50 0, // RES_TXTATR_UNKNOWN_CONTAINER, // 51 - 0, // RES_TXTATR_DUMMY5 // 52 + 40, // RES_TXTATR_INPUTFIELD // 52 }; /************************************************************************* @@ -525,20 +525,21 @@ sal_Bool SwAttrHandler::Push( const SwTxtAttr& rAttr, const SfxPoolItem& rItem ) if ( RES_TXTATR_WITHEND_END <= rItem.Which() ) return sal_False; - sal_uInt16 nStack = StackPos[ rItem.Which() ]; + const sal_uInt16 nStack = StackPos[ rItem.Which() ]; // attributes originating from redlining have highest priority // second priority are hyperlink attributes, which have a color replacement const SwTxtAttr* pTopAttr = aAttrStack[ nStack ].Top(); - if ( !pTopAttr || rAttr.IsPriorityAttr() || - ( !pTopAttr->IsPriorityAttr() && - !lcl_ChgHyperLinkColor( *pTopAttr, rItem, mpShell, 0 ) ) ) + if ( !pTopAttr + || rAttr.IsPriorityAttr() + || ( !pTopAttr->IsPriorityAttr() + && !lcl_ChgHyperLinkColor( *pTopAttr, rItem, mpShell, 0 ) ) ) { aAttrStack[ nStack ].Push( rAttr ); return sal_True; } - sal_uInt16 nPos = aAttrStack[ nStack ].Count(); + const sal_uInt16 nPos = aAttrStack[ nStack ].Count(); ASSERT( nPos, "empty stack?" ); aAttrStack[ nStack ].Insert( rAttr, nPos - 1 ); return sal_False; @@ -688,6 +689,8 @@ void SwAttrHandler::ActivateTop( SwFont& rFnt, const sal_uInt16 nAttr ) bVertLayout ); } + else if ( RES_TXTATR_INPUTFIELD == nAttr ) + rFnt.GetInputField()--; } /************************************************************************* @@ -935,6 +938,12 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu else rFnt.GetMeta()--; break; + case RES_TXTATR_INPUTFIELD : + if ( bPush ) + rFnt.GetInputField()++; + else + rFnt.GetInputField()--; + break; } } diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 57a0255fac2a..e733df9fecf0 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -57,6 +57,11 @@ #include <frmfmt.hxx> // SwFrmFmt // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> +//IAccessibility2 Implementation 2009----- +#include <portab.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/tstpitem.hxx> +//-----IAccessibility2 Implementation 2009 class FormatLevel { @@ -556,6 +561,47 @@ void SwTxtFrm::AdjustFrm( const SwTwips nChgHght, sal_Bool bHasToFit ) UNDO_SWAP( this ) } +//IAccessibility2 Implementation 2009----- +com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > SwTxtFrm::GetTabStopInfo( SwTwips CurrentPos ) +{ + com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > tabs(1); + ::com::sun::star::style::TabStop ts; + + SwTxtFormatInfo aInf( this ); + SwTxtFormatter aLine( this, &aInf ); + SwTxtCursor TxtCursor( this, &aInf ); + const Point aCharPos( TxtCursor.GetTopLeft() ); + + + SwTwips nRight = aLine.Right(); + CurrentPos -= aCharPos.X(); + + // get current tab stop information stored in the Frm + const SvxTabStop *pTS = aLine.GetLineInfo().GetTabStop( CurrentPos, nRight ); + + if( !pTS ) + { + return com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop >(); + } + + // copy tab stop information into a Sequence, which only contains one element. + ts.Position = pTS->GetTabPos(); + ts.DecimalChar = pTS->GetDecimal(); + ts.FillChar = pTS->GetFill(); + switch( pTS->GetAdjustment() ) + { + case SVX_TAB_ADJUST_LEFT : ts.Alignment = ::com::sun::star::style::TabAlign_LEFT; break; + case SVX_TAB_ADJUST_CENTER : ts.Alignment = ::com::sun::star::style::TabAlign_CENTER; break; + case SVX_TAB_ADJUST_RIGHT : ts.Alignment = ::com::sun::star::style::TabAlign_RIGHT; break; + case SVX_TAB_ADJUST_DECIMAL: ts.Alignment = ::com::sun::star::style::TabAlign_DECIMAL; break; + case SVX_TAB_ADJUST_DEFAULT: ts.Alignment = ::com::sun::star::style::TabAlign_DEFAULT; break; + default: break; // prevent warning + } + + tabs[0] = ts; + return tabs; +} +//-----IAccessibility2 Implementation 2009 /************************************************************************* * SwTxtFrm::AdjustFollow() *************************************************************************/ diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 7f65234c4edc..b66cbe915f98 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1278,27 +1278,37 @@ void SwTxtPaintInfo::DrawViewOpt( const SwLinePortion &rPor, sal_Bool bDraw = sal_False; switch( nWhich ) { - case POR_FTN: - case POR_QUOVADIS: - case POR_NUMBER: - case POR_FLD: - case POR_URL: - case POR_HIDDEN: - case POR_TOX: - case POR_REF: - case POR_META: - case POR_CONTROLCHAR: - if ( !GetOpt().IsPagePreview() && - !GetOpt().IsReadonly() && - SwViewOption::IsFieldShadings() && - (POR_NUMBER != nWhich || - pFrm->GetTxtNode()->HasMarkedLabel())) // #i27615# - bDraw = sal_True; + case POR_FTN: + case POR_QUOVADIS: + case POR_NUMBER: + case POR_FLD: + case POR_URL: + case POR_HIDDEN: + case POR_TOX: + case POR_REF: + case POR_META: + case POR_CONTROLCHAR: + if ( !GetOpt().IsPagePreview() + && !GetOpt().IsReadonly() + && SwViewOption::IsFieldShadings() + && ( POR_NUMBER != nWhich + || pFrm->GetTxtNode()->HasMarkedLabel())) // #i27615# + { + bDraw = sal_True; + } + break; + case POR_INPUTFLD: + // input field shading also in read-only mode + if ( !GetOpt().IsPagePreview() + && SwViewOption::IsFieldShadings() ) + { + bDraw = sal_True; + } break; - case POR_TAB: if ( GetOpt().IsTab() ) bDraw = sal_True; break; - case POR_SOFTHYPH: if ( GetOpt().IsSoftHyph() )bDraw = sal_True; break; - case POR_BLANK: if ( GetOpt().IsHardBlank())bDraw = sal_True; break; - default: + case POR_TAB: if ( GetOpt().IsTab() ) bDraw = sal_True; break; + case POR_SOFTHYPH: if ( GetOpt().IsSoftHyph() )bDraw = sal_True; break; + case POR_BLANK: if ( GetOpt().IsHardBlank())bDraw = sal_True; break; + default: { ASSERT( !this, "SwTxtPaintInfo::DrawViewOpt: don't know how to draw this" ); break; @@ -1750,8 +1760,12 @@ sal_Bool SwTxtFormatInfo::LastKernPortion() * class SwTxtSlot *************************************************************************/ -SwTxtSlot::SwTxtSlot( const SwTxtSizeInfo *pNew, const SwLinePortion *pPor, - bool bTxtLen, bool bExgLists, const sal_Char *pCh ) +SwTxtSlot::SwTxtSlot( + const SwTxtSizeInfo *pNew, + const SwLinePortion *pPor, + bool bTxtLen, + bool bExgLists, + const sal_Char *pCh ) : pOldTxt( 0 ), pOldSmartTagList( 0 ), pOldGrammarCheckList( 0 ), diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index d9897dee7866..eb1871f5fd8c 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -865,7 +865,13 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const { SwTxtPortion *pPor = 0; if( GetFnt()->IsTox() ) + { pPor = new SwToxPortion; + } + else if ( GetFnt()->IsInputField() ) + { + pPor = new SwTxtInputFldPortion(); + } else { if( GetFnt()->IsRef() ) @@ -895,8 +901,10 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const else { pPor = new SwTxtPortion; - if( GetFnt()->IsURL() ) + if ( GetFnt()->IsURL() ) + { pPor->SetWhichPor( POR_URL ); + } } } } @@ -1321,20 +1329,18 @@ SwLinePortion *SwTxtFormatter::NewPortion( SwTxtFormatInfo &rInf ) case CHAR_ZWSP: // zero width space case CHAR_ZWNBSP : // word joiner -// case CHAR_RLM : // right to left mark -// case CHAR_LRM : // left to right mark pPor = new SwControlCharPortion( cChar ); break; case CH_TXTATR_BREAKWORD: case CH_TXTATR_INWORD: - if( rInf.HasHint( rInf.GetIdx() ) ) - { - pPor = NewExtraPortion( rInf ); - break; - } - // No break + if( rInf.HasHint( rInf.GetIdx() ) ) + { + pPor = NewExtraPortion( rInf ); + break; + } + // No break default : - { + { SwTabPortion* pLastTabPortion = rInf.GetLastTab(); if ( pLastTabPortion && cChar == rInf.GetTabDecimal() ) { diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 774ed8cf5d79..0b888c9f8a6d 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -68,10 +68,7 @@ SwFldPortion *SwFldPortion::Clone( const XubString &rExpand ) const { pNewFnt = new SwFont( *pFnt ); } - // --> OD 2009-11-25 #i107143# - // pass placeholder property to created <SwFldPortion> instance. SwFldPortion* pClone = new SwFldPortion( rExpand, pNewFnt, bPlaceHolder ); - // <-- pClone->SetNextOffset( nNextOffset ); pClone->m_bNoLength = this->m_bNoLength; return pClone; @@ -91,6 +88,9 @@ SwFldPortion::SwFldPortion( const XubString &rExpand, SwFont *pFont, sal_Bool bP , m_bNoLength( sal_False ) { SetWhichPor( POR_FLD ); + //IAccessibility2 Implementation 2009----- + m_nAttrFldType = 0; + //-----IAccessibility2 Implementation 2009 } SwFldPortion::SwFldPortion( const SwFldPortion& rFld ) @@ -394,20 +394,10 @@ sal_Bool SwFldPortion::Format( SwTxtFormatInfo &rInf ) case CHAR_HARDHYPHEN: // non-breaking hyphen case CHAR_SOFTHYPHEN: case CHAR_HARDBLANK: - // --> FME 2006-01-11 #i59759# Erase additional control - // characters from field string, otherwise we get stuck in - // a loop. case CHAR_ZWSP : case CHAR_ZWNBSP : - // case CHAR_RLM : - // case CHAR_LRM : - // <-- - // --> OD 2010-06-03 #i111750# - // - Erasing further control characters from field string in - // to avoid loop. case CH_TXTATR_BREAKWORD: case CH_TXTATR_INWORD: - // <-- { aNew.Erase( 0, 1 ); ++nNextOfst; @@ -481,6 +471,12 @@ sal_Bool SwFldPortion::GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) c void SwFldPortion::HandlePortion( SwPortionHandler& rPH ) const { rPH.Special( GetLen(), aExpand, GetWhichPor() ); + //IAccessibility2 Implementation 2009----- + if( GetWhichPor() == POR_FLD ) + { + rPH.SetAttrFieldType(m_nAttrFldType); + } + //-----IAccessibility2 Implementation 2009 } /************************************************************************* diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index 1c0ba2155abf..08482bf1d3bd 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -65,6 +65,9 @@ public: SwFldPortion( const XubString &rExpand, SwFont *pFnt = 0, sal_Bool bPlaceHolder = sal_False ); ~SwFldPortion(); + //IAccessibility2 Implementation 2009----- + sal_uInt16 m_nAttrFldType; + //-----IAccessibility2 Implementation 2009 void TakeNextOffset( const SwFldPortion* pFld ); void CheckScript( const SwTxtSizeInfo &rInf ); inline sal_Bool HasFont() const { return 0 != pFnt; } @@ -174,7 +177,6 @@ public: class SwBulletPortion : public SwNumberPortion { public: - // --> OD 2008-01-23 #newlistlevelattrs# SwBulletPortion( const xub_Unicode cCh, const XubString& rBulletFollowedBy, SwFont *pFnt, @@ -182,7 +184,6 @@ public: const sal_Bool bCenter, const KSHORT nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive ); - // <-- OUTPUT_OPERATOR }; @@ -198,7 +199,6 @@ class SwGrfNumPortion : public SwNumberPortion SwTwips nGrfHeight; sal_Int16 eOrient; public: - // --> OD 2008-01-23 #newlistlevelattrs# SwGrfNumPortion( SwFrm *pFrm, const XubString& rGraphicFollowedBy, const SvxBrushItem* pGrfBrush, @@ -208,7 +208,6 @@ public: const sal_Bool bCenter, const KSHORT nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive ); - // <-- ~SwGrfNumPortion(); virtual void Paint( const SwTxtPaintInfo &rInf ) const; virtual sal_Bool Format( SwTxtFormatInfo &rInf ); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 9e11a943d60a..e0b0ee524360 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -2398,8 +2398,8 @@ void SwScriptInfo::CalcHiddenRanges( const SwTxtNode& rNode, MultiSelection& rHi const SvxCharHiddenItem* pHiddenItem = static_cast<const SvxCharHiddenItem*>( CharFmt::GetItem( *pTxtAttr, RES_CHRATR_HIDDEN ) ); if( pHiddenItem ) { - xub_StrLen nSt = *pTxtAttr->GetStart(); - xub_StrLen nEnd = *pTxtAttr->GetEnd(); + const xub_StrLen nSt = *pTxtAttr->GetStart(); + const xub_StrLen nEnd = *pTxtAttr->End(); if( nEnd > nSt ) { Range aTmp( nSt, nEnd - 1 ); diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 5125d26e1bbb..43201ac3c536 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -992,7 +992,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, if( pRuby ) { // The winner is ... a ruby attribute and so // the end of the multiportion is the end of the ruby attribute. - rPos = *pRuby->GetEnd(); + rPos = *pRuby->End(); SwMultiCreator *pRet = new SwMultiCreator; pRet->pItem = NULL; pRet->pAttr = pRuby; @@ -1018,7 +1018,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, { pRet->pItem = NULL; pRet->pAttr = (*pHints)[n2Lines]; - aEnd.push_front( *pRet->pAttr->GetEnd() ); + aEnd.push_front( *pRet->pAttr->End() ); if( pItem ) { aEnd.front() = GetTxt().Len(); @@ -1094,8 +1094,8 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, if( bTwo == bOn ) { // .. with the same state, so the last attribute could // be continued. - if( aEnd.back() < *pTmp->GetEnd() ) - aEnd.back() = *pTmp->GetEnd(); + if( aEnd.back() < *pTmp->End() ) + aEnd.back() = *pTmp->End(); } else { // .. with a different state. @@ -1103,12 +1103,12 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, // If this is smaller than the last on the stack, we put // it on the stack. If it has the same endposition, the last // could be removed. - if( aEnd.back() > *pTmp->GetEnd() ) - aEnd.push_back( *pTmp->GetEnd() ); + if( aEnd.back() > *pTmp->End() ) + aEnd.push_back( *pTmp->End() ); else if( aEnd.size() > 1 ) aEnd.pop_back(); else - aEnd.back() = *pTmp->GetEnd(); + aEnd.back() = *pTmp->End(); } } } @@ -1166,18 +1166,18 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, { if( bTwo == bOn ) { - if( aEnd.back() < *pTmp->GetEnd() ) - aEnd.back() = *pTmp->GetEnd(); + if( aEnd.back() < *pTmp->End() ) + aEnd.back() = *pTmp->End(); } else { bOn = bTwo; - if( aEnd.back() > *pTmp->GetEnd() ) - aEnd.push_back( *pTmp->GetEnd() ); + if( aEnd.back() > *pTmp->End() ) + aEnd.push_back( *pTmp->End() ); else if( aEnd.size() > 1 ) aEnd.pop_back(); else - aEnd.back() = *pTmp->GetEnd(); + aEnd.back() = *pTmp->End(); } } } @@ -1192,7 +1192,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, { pRet->pItem = NULL; pRet->pAttr = (*pHints)[nRotate]; - aEnd.push_front( *pRet->pAttr->GetEnd() ); + aEnd.push_front( *pRet->pAttr->End() ); if( pRotItem ) { aEnd.front() = GetTxt().Len(); @@ -1237,18 +1237,18 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, { if( bTwo == bOn ) { - if( aEnd.back() < *pTmp->GetEnd() ) - aEnd.back() = *pTmp->GetEnd(); + if( aEnd.back() < *pTmp->End() ) + aEnd.back() = *pTmp->End(); } else { bOn = bTwo; - if( aEnd.back() > *pTmp->GetEnd() ) - aEnd.push_back( *pTmp->GetEnd() ); + if( aEnd.back() > *pTmp->End() ) + aEnd.push_back( *pTmp->End() ); else if( aEnd.size() > 1 ) aEnd.pop_back(); else - aEnd.back() = *pTmp->GetEnd(); + aEnd.back() = *pTmp->End(); } } } diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 2839917e5da7..720025ac1830 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -715,6 +715,124 @@ void SwTxtPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Text( GetLen(), GetWhichPor() ); } + +SwTxtInputFldPortion::SwTxtInputFldPortion() + : SwTxtPortion() + , mbContainsInputFieldStart( false ) + , mbContainsInputFieldEnd( false ) +{ + SetWhichPor( POR_INPUTFLD ); +} + + +sal_Bool SwTxtInputFldPortion::Format( SwTxtFormatInfo &rInf ) +{ + mbContainsInputFieldStart = + rInf.GetChar( rInf.GetIdx() ) == CH_TXT_ATR_INPUTFIELDSTART; + mbContainsInputFieldEnd = + rInf.GetChar( rInf.GetIdx() + rInf.GetLen() - 1 ) == CH_TXT_ATR_INPUTFIELDEND; + + sal_Bool bRet = sal_False; + if ( rInf.GetLen() == 1 + && ( mbContainsInputFieldStart || mbContainsInputFieldEnd ) ) + { + Width( 0 ); + } + else + { + SwTxtSlot aFormatTxt( &rInf, this, true, true, 0 ); + if ( rInf.GetLen() == 0 ) + { + Width( 0 ); + } + else + { + bRet = SwTxtPortion::Format( rInf ); + + if ( mbContainsInputFieldEnd ) + { + // adjust portion length accordingly, if complete text fits into the portion + if ( GetLen() == rInf.GetLen() ) + { + SetLen( GetLen() + 1 ); + } + } + + if ( mbContainsInputFieldStart ) + { + // adjust portion length accordingly + SetLen( GetLen() + 1 ); + } + } + } + + return bRet; +} + +void SwTxtInputFldPortion::Paint( const SwTxtPaintInfo &rInf ) const +{ + if ( Width() ) + { + rInf.DrawViewOpt( *this, POR_INPUTFLD ); + static sal_Char sSpace = ' '; + SwTxtSlot aPaintTxt( &rInf, this, true, true, + ContainsOnlyDummyChars() ? &sSpace : 0 ); + SwTxtPortion::Paint( rInf ); + } +} + +sal_Bool SwTxtInputFldPortion::GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const +{ + xub_StrLen nIdx = rInf.GetIdx(); + xub_StrLen nLen = rInf.GetLen(); + if ( rInf.GetChar( rInf.GetIdx() ) == CH_TXT_ATR_INPUTFIELDSTART ) + { + ++nIdx; + --nLen; + } + if ( rInf.GetChar( rInf.GetIdx() + rInf.GetLen() - 1 ) == CH_TXT_ATR_INPUTFIELDEND ) + { + --nLen; + } + rTxt = rInf.GetTxt().Copy( nIdx, nLen ); + + return sal_True; +} + + +SwPosSize SwTxtInputFldPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const +{ + SwTxtSlot aFormatTxt( &rInf, this, true, false, 0 ); + if ( rInf.GetLen() == 0 ) + { + return SwPosSize( 0, 0 ); + } + + return rInf.GetTxtSize(); +} + + +KSHORT SwTxtInputFldPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const +{ + if( !Width() + && ContainsOnlyDummyChars() + && !rInf.GetOpt().IsPagePreview() + && !rInf.GetOpt().IsReadonly() + && SwViewOption::IsFieldShadings() ) + { + return rInf.GetTxtSize( ' ' ).Width(); + } + + return SwTxtPortion::GetViewWidth( rInf ); +} + +bool SwTxtInputFldPortion::ContainsOnlyDummyChars() const +{ + return GetLen() <= 2 + && mbContainsInputFieldStart + && mbContainsInputFieldEnd; +} + /************************************************************************* * class SwHolePortion *************************************************************************/ diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx index 329055493d70..a778bff11583 100644 --- a/sw/source/core/text/portxt.hxx +++ b/sw/source/core/text/portxt.hxx @@ -62,6 +62,24 @@ public: DECL_FIXEDMEMPOOL_NEWDEL(SwTxtPortion) }; + +class SwTxtInputFldPortion : public SwTxtPortion +{ +public: + SwTxtInputFldPortion(); + + virtual sal_Bool Format( SwTxtFormatInfo &rInf ); + virtual void Paint( const SwTxtPaintInfo &rInf ) const; + virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const; + virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const; + virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const; + +private: + bool mbContainsInputFieldStart; + bool mbContainsInputFieldEnd; + bool ContainsOnlyDummyChars() const; +}; + /************************************************************************* * class SwHolePortion *************************************************************************/ diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 9c95883b7943..ccf2eeba6890 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -59,6 +59,14 @@ #include "fmtmeta.hxx" // lcl_NewMetaPortion +//IAccessibility2 Implementation 2009----- +#ifndef _REFFLD_HXX +#include "reffld.hxx" +#endif +#ifndef _FLDDAT_HXX +#include "flddat.hxx" +#endif +//-----IAccessibility2 Implementation 2009 /************************************************************************* * SwTxtFormatter::NewFldPortion() *************************************************************************/ @@ -90,7 +98,9 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, SwCharFmt* pChFmt = 0; sal_Bool bNewFlyPor = sal_False, bINet = sal_False; - + //IAccessibility2 Implementation 2009----- + sal_uInt16 subType; + //-----IAccessibility2 Implementation 2009 // set language ((SwTxtFormatter*)this)->SeekAndChg( rInf ); if (pFld->GetLanguage() != GetFnt()->GetLanguage()) @@ -162,6 +172,10 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, : pFld->ExpandField(bInClipboard) ); pRet = new SwFldPortion( str ); } + //IAccessibility2 Implementation 2009----- + if(pRet) + ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_PAGECOOUNTFLD; + //-----IAccessibility2 Implementation 2009 break; case RES_PAGENUMBERFLD: @@ -188,6 +202,10 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, : pFld->ExpandField(bInClipboard) ); pRet = new SwFldPortion( str ); } + //IAccessibility2 Implementation 2009----- + if(pRet) + ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_PAGENUMBERFLD; + //-----IAccessibility2 Implementation 2009 break; } case RES_GETEXPFLD: @@ -263,7 +281,40 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, bNewFlyPor = sal_True; bPlaceHolder = sal_True; break; - + //IAccessibility2 Implementation 2009----- + case RES_GETREFFLD: + subType = ((SwGetRefField*)pFld)->GetSubType(); + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } + if(pRet) + { + if( subType == REF_BOOKMARK ) + ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_BOOKMARKFLD; + else if( subType == REF_SETREFATTR ) + ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_SETREFATTRFLD; + break; + } + case RES_DATETIMEFLD: + subType = ((SwDateTimeField*)pFld)->GetSubType(); + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } + if(pRet) + { + if( subType & DATEFLD ) + ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_DATEFLD; + else if( subType & TIMEFLD ) + ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_TIMEFLD; + break; + } + //-----IAccessibility2 Implementation 2009 default: { String const str( (bName) @@ -369,9 +420,6 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) SwLinePortion *pRet = 0; if( !pHint ) { -#if OSL_DEBUG_LEVEL > 1 -// aDbstream << "NewExtraPortion: hint not found?" << endl; -#endif pRet = new SwTxtPortion; pRet->SetLen( 1 ); rInf.SetLen( 1 ); @@ -380,43 +428,40 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) switch( pHint->Which() ) { - case RES_TXTATR_FLYCNT : + case RES_TXTATR_FLYCNT : { pRet = NewFlyCntPortion( rInf, pHint ); break; } - case RES_TXTATR_FTN : + case RES_TXTATR_FTN : { pRet = NewFtnPortion( rInf, pHint ); break; } - case RES_TXTATR_FIELD : + case RES_TXTATR_FIELD : { pRet = NewFldPortion( rInf, pHint ); break; } - case RES_TXTATR_REFMARK : + case RES_TXTATR_REFMARK : { pRet = new SwIsoRefPortion; break; } - case RES_TXTATR_TOXMARK : + case RES_TXTATR_TOXMARK : { pRet = new SwIsoToxPortion; break; } - case RES_TXTATR_METAFIELD: + case RES_TXTATR_METAFIELD: { pRet = lcl_NewMetaPortion( *pHint, true ); break; } - default: ; + default: ; } if( !pRet ) { -#if OSL_DEBUG_LEVEL > 1 -// aDbstream << "NewExtraPortion: unknown hint" << endl; -#endif const XubString aNothing; pRet = new SwFldPortion( aNothing ); rInf.SetLen( 1 ); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index a58fceebc55f..9647364f9c6e 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1329,16 +1329,6 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) } break; -/* Seit dem neuen Blocksatz muessen wir immer neu formatieren: - case RES_PARATR_ADJUST: - { - if( GetShell() ) - { - Prepare( PREP_CLEAR ); - } - break; - } -*/ // 6870: SwDocPosUpdate auswerten. case RES_DOCPOS_UPDATE: { diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index abd205963c99..8945688013b5 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -240,7 +240,7 @@ String SwTOXMark::GetText() const aStr = aAltText; else if( pTxtAttr && pTxtAttr->GetpTxtNd() ) { - xub_StrLen* pEndIdx = pTxtAttr->GetEnd(); + const xub_StrLen* pEndIdx = pTxtAttr->GetEnd(); ASSERT( pEndIdx, "TOXMark ohne Mark!!"); if( pEndIdx ) { diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index e531761e042c..764b8d6828a0 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -232,8 +232,8 @@ sal_Bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp ) { // beide Pointer vorhanden -> vergleiche Text // beide Pointer nicht vorhanden -> vergleiche AlternativText - const xub_StrLen *pEnd = pTxtMark->GetEnd(), - *pEndCmp = rCmp.pTxtMark->GetEnd(); + const xub_StrLen* pEnd = pTxtMark->End(); + const xub_StrLen* pEndCmp = rCmp.pTxtMark->End(); String sMyTxt; String sMyTxtReading; @@ -275,8 +275,8 @@ sal_Bool SwTOXSortTabBase::operator<( const SwTOXSortTabBase& rCmp ) if( *pTxtMark->GetStart() == *rCmp.pTxtMark->GetStart() ) { - const xub_StrLen *pEnd = pTxtMark->GetEnd(), - *pEndCmp = rCmp.pTxtMark->GetEnd(); + const xub_StrLen* pEnd = pTxtMark->End(); + const xub_StrLen* pEndCmp = rCmp.pTxtMark->End(); String sMyTxt; String sMyTxtReading; @@ -432,7 +432,7 @@ void SwTOXIndex::GetText_Impl( String& rTxt, String& rTxtReading ) const void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const { - const xub_StrLen* pEnd = pTxtMark->GetEnd(); + const xub_StrLen* pEnd = pTxtMark->End(); String sTmp; String sTmpReading; if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() && @@ -549,7 +549,7 @@ SwTOXContent::SwTOXContent( const SwTxtNode& rNd, const SwTxtTOXMark* pMark, void SwTOXContent::GetText_Impl( String& rTxt, String& rTxtReading ) const { - const xub_StrLen* pEnd = pTxtMark->GetEnd(); + const xub_StrLen* pEnd = pTxtMark->End(); if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() ) { rTxt = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt( @@ -564,7 +564,7 @@ void SwTOXContent::GetText_Impl( String& rTxt, String& rTxtReading ) const void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const { - const xub_StrLen* pEnd = pTxtMark->GetEnd(); + const xub_StrLen* pEnd = pTxtMark->End(); if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() ) ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt( rNd, &rInsPos, *pTxtMark->GetStart(), diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index feee13492942..52720547f481 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -48,13 +48,13 @@ * ****************************************************************************/ - // Konstruktor fuers Default vom Attribut-Pool -SwFmtFld::SwFmtFld() - : SfxPoolItem( RES_TXTATR_FIELD ) - , SwClient( 0 ) +// constructor for default item in attribute-pool +SwFmtFld::SwFmtFld( sal_uInt16 nWhich ) + : SfxPoolItem( nWhich ) + , SwClient() , SfxBroadcaster() - , pField( 0 ) - , pTxtAttr( 0 ) + , mpField( NULL ) + , mpTxtFld( NULL ) { } @@ -62,10 +62,15 @@ SwFmtFld::SwFmtFld( const SwField &rFld ) : SfxPoolItem( RES_TXTATR_FIELD ) , SwClient( rFld.GetTyp() ) , SfxBroadcaster() - , pField( 0 ) - , pTxtAttr( 0 ) + , mpField( rFld.CopyField() ) + , mpTxtFld( NULL ) { - pField = rFld.CopyField(); + // input field in-place editing + if ( GetField()->GetTyp()->Which() == RES_INPUTFLD ) + { + SetWhich( RES_TXTATR_INPUTFIELD ); + dynamic_cast<SwInputField*>(GetField())->SetFmtFld( *this ); + } } // #i24434# @@ -76,25 +81,31 @@ SwFmtFld::SwFmtFld( const SwFmtFld& rAttr ) : SfxPoolItem( RES_TXTATR_FIELD ) , SwClient() , SfxBroadcaster() - , pField( 0 ) - , pTxtAttr( 0 ) + , mpField( NULL ) + , mpTxtFld( NULL ) { - if(rAttr.GetField()) + if ( rAttr.GetField() ) { rAttr.GetField()->GetTyp()->Add(this); - pField = rAttr.GetField()->CopyField(); + mpField = rAttr.GetField()->CopyField(); + // input field in-place editing + if ( GetField()->GetTyp()->Which() == RES_INPUTFLD ) + { + SetWhich( RES_TXTATR_INPUTFIELD ); + dynamic_cast<SwInputField*>(GetField())->SetFmtFld( *this ); + } } } SwFmtFld::~SwFmtFld() { - SwFieldType* pType = pField ? pField->GetTyp() : 0; + SwFieldType* pType = mpField ? mpField->GetTyp() : 0; if (pType && pType->Which() == RES_DBFLD) pType = 0; // DB-Feldtypen zerstoeren sich selbst Broadcast( SwFmtFldHint( this, SWFMTFLD_REMOVED ) ); - delete pField; + delete mpField; // bei einige FeldTypen muessen wir den FeldTypen noch loeschen if( pType && pType->IsLastDepend() ) @@ -131,22 +142,36 @@ void SwFmtFld::RegisterToFieldType( SwFieldType& rType ) // #111840# -void SwFmtFld::SetFld(SwField * _pField) +void SwFmtFld::SetField(SwField * _pField) { - if (NULL != pField) - delete pField; + if (NULL != mpField) + delete mpField; - pField = _pField; + mpField = _pField; + if ( GetField()->GetTyp()->Which() == RES_INPUTFLD ) + { + dynamic_cast<SwInputField* >(GetField())->SetFmtFld( *this ); + } Broadcast( SwFmtFldHint( this, SWFMTFLD_CHANGED ) ); } +void SwFmtFld::SetTxtFld( SwTxtFld& rTxtFld ) +{ + mpTxtFld = &rTxtFld; +} + +void SwFmtFld::ClearTxtFld() +{ + mpTxtFld = NULL; +} + int SwFmtFld::operator==( const SfxPoolItem& rAttr ) const { ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); - return ( ( pField && ((SwFmtFld&)rAttr).GetField() - && pField->GetTyp() == ((SwFmtFld&)rAttr).GetField()->GetTyp() - && pField->GetFormat() == ((SwFmtFld&)rAttr).GetField()->GetFormat() ) ) - || ( !pField && !((SwFmtFld&)rAttr).GetField() ); + return ( ( mpField && ((SwFmtFld&)rAttr).GetField() + && mpField->GetTyp() == ((SwFmtFld&)rAttr).GetField()->GetTyp() + && mpField->GetFormat() == ((SwFmtFld&)rAttr).GetField()->GetFormat() ) ) + || ( !mpField && !((SwFmtFld&)rAttr).GetField() ); } SfxPoolItem* SwFmtFld::Clone( SfxItemPool* ) const @@ -156,7 +181,7 @@ SfxPoolItem* SwFmtFld::Clone( SfxItemPool* ) const void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint ) { - if( !pTxtAttr ) + if( !mpTxtFld ) return; const SwFieldHint* pHint = dynamic_cast<const SwFieldHint*>( &rHint ); @@ -165,9 +190,9 @@ void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint ) // replace field content by text SwPaM* pPaM = pHint->GetPaM(); SwDoc* pDoc = pPaM->GetDoc(); - const SwTxtNode& rTxtNode = pTxtAttr->GetTxtNode(); + const SwTxtNode& rTxtNode = mpTxtFld->GetTxtNode(); pPaM->GetPoint()->nNode = rTxtNode; - pPaM->GetPoint()->nContent.Assign( (SwTxtNode*)&rTxtNode, *pTxtAttr->GetStart() ); + pPaM->GetPoint()->nContent.Assign( (SwTxtNode*)&rTxtNode, *mpTxtFld->GetStart() ); String const aEntry( GetField()->ExpandField( pDoc->IsClipBoard() ) ); pPaM->SetMark(); @@ -179,14 +204,14 @@ void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint ) void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) { - if( !pTxtAttr ) + if( !mpTxtFld ) return; // don't do anything, especially not expand! if( pNew && pNew->Which() == RES_OBJECTDYING ) return; - SwTxtNode* pTxtNd = (SwTxtNode*)&pTxtAttr->GetTxtNode(); + SwTxtNode* pTxtNd = (SwTxtNode*)&mpTxtFld->GetTxtNode(); ASSERT( pTxtNd, "wo ist denn mein Node?" ); if( pNew ) { @@ -203,7 +228,7 @@ void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) { // --> OD 2007-09-06 #i81002# // ((SwGetRefField*)GetFld())->UpdateField(); - dynamic_cast<SwGetRefField*>(GetField())->UpdateField( pTxtAttr ); + dynamic_cast<SwGetRefField*>(GetField())->UpdateField( mpTxtFld ); // <-- } break; @@ -243,14 +268,14 @@ void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) pType->GetValue( aCalc ); } } - pTxtAttr->Expand(); + mpTxtFld->ExpandTxtFld(); } sal_Bool SwFmtFld::GetInfo( SfxPoolItem& rInfo ) const { const SwTxtNode* pTxtNd; if( RES_AUTOFMT_DOCNODE != rInfo.Which() || - !pTxtAttr || 0 == ( pTxtNd = pTxtAttr->GetpTxtNode() ) || + !mpTxtFld || 0 == ( pTxtNd = mpTxtFld->GetpTxtNode() ) || &pTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) return sal_True; @@ -259,82 +284,68 @@ sal_Bool SwFmtFld::GetInfo( SfxPoolItem& rInfo ) const } -sal_Bool SwFmtFld::IsFldInDoc() const +bool SwFmtFld::IsFldInDoc() const { - const SwTxtNode* pTxtNd; - return pTxtAttr && 0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) && - pTxtNd->GetNodes().IsDocNodes(); + return mpTxtFld != NULL + && mpTxtFld->IsFldInDoc(); } sal_Bool SwFmtFld::IsProtect() const { - const SwTxtNode* pTxtNd; - return pTxtAttr && 0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) && - pTxtNd->IsProtect(); + return mpTxtFld != NULL + && mpTxtFld->GetpTxtNode() != NULL + && mpTxtFld->GetpTxtNode()->IsProtect(); } -/************************************************************************* -|* -|* SwTxtFld::SwTxtFld() -|* -|* Beschreibung Attribut fuer automatischen Text, Ctor -|* Ersterstellung BP 30.04.92 -|* Letzte Aenderung JP 15.08.94 -|* -*************************************************************************/ - -SwTxtFld::SwTxtFld(SwFmtFld & rAttr, xub_StrLen const nStartPos) + + + +SwTxtFld::SwTxtFld( + SwFmtFld & rAttr, + xub_StrLen const nStartPos ) : SwTxtAttr( rAttr, nStartPos ) , m_aExpand( rAttr.GetField()->ExpandField(true) ) - , m_pTxtNode( 0 ) + , m_pTxtNode( NULL ) { - rAttr.pTxtAttr = this; + rAttr.SetTxtFld( *this ); SetHasDummyChar(true); } SwTxtFld::~SwTxtFld( ) { SwFmtFld & rFmtFld( static_cast<SwFmtFld &>(GetAttr()) ); - if (this == rFmtFld.pTxtAttr) + if ( this == rFmtFld.GetTxtFld() ) { - rFmtFld.pTxtAttr = 0; // #i110140# invalidate! + rFmtFld.ClearTxtFld(); } } -/************************************************************************* -|* -|* SwTxtFld::Expand() -|* -|* Beschreibung exandiert das Feld und tauscht den Text im Node -|* Ersterstellung BP 30.04.92 -|* Letzte Aenderung JP 15.08.94 -|* -*************************************************************************/ - -void SwTxtFld::Expand() const + +bool SwTxtFld::IsFldInDoc() const +{ + return GetpTxtNode() != NULL + && GetpTxtNode()->GetNodes().IsDocNodes(); +} + +void SwTxtFld::ExpandTxtFld() const { - // Wenn das expandierte Feld sich nicht veraendert hat, wird returnt ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" ); const SwField* pFld = GetFmtFld().GetField(); - XubString aNewExpand( pFld->ExpandField(m_pTxtNode->GetDoc()->IsClipBoard()) ); + const XubString aNewExpand( pFld->ExpandField(m_pTxtNode->GetDoc()->IsClipBoard()) ); if( aNewExpand == m_aExpand ) { // Bei Seitennummernfeldern const sal_uInt16 nWhich = pFld->GetTyp()->Which(); - if( RES_CHAPTERFLD != nWhich && RES_PAGENUMBERFLD != nWhich && - RES_REFPAGEGETFLD != nWhich && - // --> FME 2005-05-23 #122919# Page count fields to not use aExpand - // during formatting, therefore an invalidation of the text frame - // has to be triggered even if aNewExpand == aExpand: - ( RES_DOCSTATFLD != nWhich || DS_PAGE != static_cast<const SwDocStatField*>(pFld)->GetSubType() ) && - // <-- - ( RES_GETEXPFLD != nWhich || ((SwGetExpField*)pFld)->IsInBodyTxt() ) ) + if ( RES_CHAPTERFLD != nWhich + && RES_PAGENUMBERFLD != nWhich + && RES_REFPAGEGETFLD != nWhich + // Page count fields to not use aExpand during formatting, + // therefore an invalidation of the text frame has to be triggered even if aNewExpand == aExpand: + && ( RES_DOCSTATFLD != nWhich || DS_PAGE != static_cast<const SwDocStatField*>(pFld)->GetSubType() ) + && ( RES_GETEXPFLD != nWhich || ((SwGetExpField*)pFld)->IsInBodyTxt() ) ) { - // BP: das muesste man noch optimieren! - //JP 12.06.97: stimmt, man sollte auf jedenfall eine Status- - // aenderung an die Frames posten if( m_pTxtNode->CalcHiddenParaField() ) { m_pTxtNode->ModifyNotification( 0, 0 ); @@ -345,15 +356,11 @@ void SwTxtFld::Expand() const m_aExpand = aNewExpand; - // 0, this for formatting - m_pTxtNode->ModifyNotification( 0, const_cast<SwFmtFld*>( &GetFmtFld() ) ); + const_cast<SwTxtFld*>(this)->NotifyContentChange( const_cast<SwFmtFld&>(GetFmtFld()) ); } -/************************************************************************* - * SwTxtFld::CopyFld() - *************************************************************************/ -void SwTxtFld::CopyFld( SwTxtFld *pDest ) const +void SwTxtFld::CopyTxtFld( SwTxtFld *pDest ) const { ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" ); ASSERT( pDest->m_pTxtNode, "SwTxtFld: where is pDest's TxtNode?" ); @@ -361,8 +368,8 @@ void SwTxtFld::CopyFld( SwTxtFld *pDest ) const IDocumentFieldsAccess* pIDFA = m_pTxtNode->getIDocumentFieldsAccess(); IDocumentFieldsAccess* pDestIDFA = pDest->m_pTxtNode->getIDocumentFieldsAccess(); - SwFmtFld& rFmtFld = (SwFmtFld&)pDest->GetFmtFld(); - const sal_uInt16 nFldWhich = rFmtFld.GetField()->GetTyp()->Which(); + SwFmtFld& rDestFmtFld = (SwFmtFld&)pDest->GetFmtFld(); + const sal_uInt16 nFldWhich = rDestFmtFld.GetField()->GetTyp()->Which(); if( pIDFA != pDestIDFA ) { @@ -370,47 +377,54 @@ void SwTxtFld::CopyFld( SwTxtFld *pDest ) const // der Feldtyp muss im neuen Dokument angemeldet werden. // Z.B: Kopieren ins ClipBoard. SwFieldType* pFldType; - if( nFldWhich != RES_DBFLD && nFldWhich != RES_USERFLD && - nFldWhich != RES_SETEXPFLD && nFldWhich != RES_DDEFLD && - RES_AUTHORITY != nFldWhich ) + if( nFldWhich != RES_DBFLD + && nFldWhich != RES_USERFLD + && nFldWhich != RES_SETEXPFLD + && nFldWhich != RES_DDEFLD + && RES_AUTHORITY != nFldWhich ) + { pFldType = pDestIDFA->GetSysFldType( nFldWhich ); + } else - pFldType = pDestIDFA->InsertFldType( *rFmtFld.GetField()->GetTyp() ); + { + pFldType = pDestIDFA->InsertFldType( *rDestFmtFld.GetField()->GetTyp() ); + } // Sonderbehandlung fuer DDE-Felder if( RES_DDEFLD == nFldWhich ) { - if( rFmtFld.GetTxtFld() ) - ((SwDDEFieldType*)rFmtFld.GetField()->GetTyp())->DecRefCnt(); + if( rDestFmtFld.GetTxtFld() ) + { + ((SwDDEFieldType*)rDestFmtFld.GetField()->GetTyp())->DecRefCnt(); + } ((SwDDEFieldType*)pFldType)->IncRefCnt(); } ASSERT( pFldType, "unbekannter FieldType" ); - pFldType->Add( &rFmtFld ); // ummelden - rFmtFld.GetField()->ChgTyp( pFldType ); + pFldType->Add( &rDestFmtFld ); // ummelden + rDestFmtFld.GetField()->ChgTyp( pFldType ); } // Expressionfelder Updaten - if( nFldWhich == RES_SETEXPFLD || nFldWhich == RES_GETEXPFLD || - nFldWhich == RES_HIDDENTXTFLD ) + if( nFldWhich == RES_SETEXPFLD + || nFldWhich == RES_GETEXPFLD + || nFldWhich == RES_HIDDENTXTFLD ) { SwTxtFld* pFld = (SwTxtFld*)this; pDestIDFA->UpdateExpFlds( pFld, true ); } // Tabellenfelder auf externe Darstellung - else if( RES_TABLEFLD == nFldWhich && - ((SwTblField*)rFmtFld.GetField())->IsIntrnlName() ) + else if( RES_TABLEFLD == nFldWhich + && ((SwTblField*)rDestFmtFld.GetField())->IsIntrnlName() ) { // erzeuge aus der internen (fuer CORE) die externe (fuer UI) Formel const SwTableNode* pTblNd = m_pTxtNode->FindTableNode(); if( pTblNd ) // steht in einer Tabelle - ((SwTblField*)rFmtFld.GetField())->PtrToBoxNm( &pTblNd->GetTable() ); + ((SwTblField*)rDestFmtFld.GetField())->PtrToBoxNm( &pTblNd->GetTable() ); } } -/* -----------------26.06.2003 13:54----------------- - --------------------------------------------------*/ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) { //if not in undo section notify the change @@ -421,3 +435,83 @@ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) } +// input field in-place editing +SwTxtInputFld::SwTxtInputFld( + SwFmtFld & rAttr, + xub_StrLen const nStart, + xub_StrLen const nEnd ) + + : SwTxtFld( rAttr, nStart ) + , m_nEnd( nEnd ) +{ + SetHasDummyChar( false ); + SetHasContent( true ); + + SetDontExpand( true ); + SetLockExpandFlag( true ); + SetDontExpandStartAttr( true ); + + SetNesting( true ); +} + +SwTxtInputFld::~SwTxtInputFld() +{ +} + +xub_StrLen* SwTxtInputFld::GetEnd() +{ + return &m_nEnd; +} + +void SwTxtInputFld::NotifyContentChange( SwFmtFld& rFmtFld ) +{ + SwTxtFld::NotifyContentChange( rFmtFld ); + + UpdateTextNodeContent( GetFieldContent() ); +} + +const String SwTxtInputFld::GetFieldContent() const +{ + return GetFmtFld().GetField()->ExpandField(false); +} + +void SwTxtInputFld::UpdateFieldContent() +{ + if ( IsFldInDoc() + && (*GetStart()) != (*End()) ) + { + ASSERT( (*End()) - (*GetStart()) >= 2, + "<SwTxtInputFld::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" ); + // skip CH_TXT_ATR_INPUTFIELDSTART character + const xub_StrLen nIdx = (*GetStart()) + 1; + // skip CH_TXT_ATR_INPUTFIELDEND character + const xub_StrLen nLen = static_cast<xub_StrLen>(std::max( 0, ( (*End()) - 1 - nIdx ) )); + const String aNewFieldContent = GetTxtNode().GetExpandTxt( nIdx, nLen ); + + const SwInputField* pInputFld = dynamic_cast<const SwInputField*>(GetFmtFld().GetField()); + ASSERT( pInputFld != NULL, + "<SwTxtInputFld::GetContent()> - Missing <SwInputFld> instance!" ); + if ( pInputFld != NULL ) + { + const_cast<SwInputField*>(pInputFld)->applyFieldContent( aNewFieldContent ); + } + } +} + +void SwTxtInputFld::UpdateTextNodeContent( const String& rNewContent ) +{ + if ( !IsFldInDoc() ) + { + ASSERT( false, "<SwTxtInputFld::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content." ); + return; + } + + ASSERT( (*End()) - (*GetStart()) >= 2, + "<SwTxtInputFld::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" ); + // skip CH_TXT_ATR_INPUTFIELDSTART character + const xub_StrLen nIdx = (*GetStart()) + 1; + // skip CH_TXT_ATR_INPUTFIELDEND character + const xub_StrLen nDelLen = static_cast<xub_StrLen>(std::max( 0, ( (*End()) - 1 - nIdx ) )); + SwIndex aIdx( &GetTxtNode(), nIdx ); + GetTxtNode().ReplaceText( aIdx, nDelLen, rNewContent ); +} diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index cd389440ffc2..9635fd988b9b 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -52,8 +52,8 @@ void DumpHints( const SwpHtStart &rHtStart, ((((aDbstream << '\t').WriteNumber( i )<< " [").WriteNumber( pHt->Which() ) << ']' << '\t').WriteNumber( long( pHt ) ) << '\t').WriteNumber( *pHt->GetStart() ); - if( pHt->GetEnd() ) - (aDbstream << " -> " ).WriteNumber( *pHt->GetEnd() ); + if( pHt->End() ) + (aDbstream << " -> " ).WriteNumber( *pHt->End() ); aDbstream << endl; } (aDbstream << "\tEnds:").WriteNumber( rHtEnd.Count() )<< endl; @@ -62,8 +62,8 @@ void DumpHints( const SwpHtStart &rHtStart, const SwTxtAttr *pHt = rHtEnd[i]; (((aDbstream << '\t').WriteNumber( i )<< " [").WriteNumber( pHt->Which() ) << ']' << '\t' ).WriteNumber( long( pHt ) ); - if( pHt->GetEnd() ) - (aDbstream << '\t').WriteNumber( *pHt->GetEnd() )<< " <- "; + if( pHt->End() ) + (aDbstream << '\t').WriteNumber( *pHt->End() )<< " <- "; aDbstream.WriteNumber( *pHt->GetStart() )<< endl; } aDbstream << endl; @@ -370,11 +370,11 @@ bool SwpHintsArray::Check() const CHECK_ERR( 0 == i || ( RES_TXTATR_CHARFMT != pHtLast->Which() && RES_TXTATR_AUTOFMT != pHtLast->Which() ) || ( RES_TXTATR_CHARFMT != pHtThis->Which() && RES_TXTATR_AUTOFMT != pHtThis->Which() ) || - ( *pHtThis->GetStart() >= *pHtLast->GetEnd() ) || + ( *pHtThis->GetStart() >= *pHtLast->End() ) || ( ( ( (*pHtThis->GetStart() == *pHtLast->GetStart()) - && (*pHtThis->GetEnd() == *pHtLast->GetEnd()) + && (*pHtThis->End() == *pHtLast->End()) ) // same range - || (*pHtThis->GetStart() == *pHtThis->GetEnd()) + || (*pHtThis->GetStart() == *pHtThis->End()) ) && ( (pHtThis->Which() != RES_TXTATR_AUTOFMT) || (pHtLast->Which() != RES_TXTATR_AUTOFMT) @@ -392,8 +392,8 @@ bool SwpHintsArray::Check() const if ( pOther->IsNesting() && (i != j) ) { SwComparePosition cmp = ComparePosition( - *pHtThis->GetStart(), *pHtThis->GetEnd(), - *pOther->GetStart(), *pOther->GetEnd()); + *pHtThis->GetStart(), *pHtThis->End(), + *pOther->GetStart(), *pOther->End()); CHECK_ERR( (POS_OVERLAP_BEFORE != cmp) && (POS_OVERLAP_BEHIND != cmp), "HintsCheck: overlapping nesting hints!!!" ); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 14c459587f5d..8fa75a677c50 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -259,22 +259,16 @@ SwTxtNode::~SwTxtNode() m_pSwpHints = 0; for( sal_uInt16 j = pTmpHints->Count(); j; ) + { // erst muss das Attribut aus dem Array entfernt werden, // denn sonst wuerde es sich selbst loeschen (Felder) !!!! DestroyAttr( pTmpHints->GetTextHint( --j ) ); + } delete pTmpHints; } - // --> OD 2008-03-13 #refactorlists# -// if ( mpNodeNum ) -// { -// mpNodeNum->RemoveMe(); -// delete mpNodeNum; -// mpNodeNum = 0L; -// } RemoveFromList(); - // <-- InitSwParaStatistics( false ); } @@ -857,8 +851,11 @@ void SwTxtNode::NewAttrSet( SwAttrPool& rPool ) // override SwIndexReg::Update => text hints do not need SwIndex for start/end! -void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, - const bool bNegative, const bool bDelete ) +void SwTxtNode::Update( + SwIndex const & rPos, + const xub_StrLen nChangeLen, + const bool bNegative, + const bool bDelete ) { SetAutoCompleteWordDirty( sal_True ); @@ -872,6 +869,8 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, const xub_StrLen nChangeEnd = nChangePos + nChangeLen; for ( sal_uInt16 n = 0; n < m_pSwpHints->Count(); ++n ) { + bool bTxtAttrChanged = false; + bool bStartOfTxtAttrChanged = false; SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); xub_StrLen * const pStart = pHint->GetStart(); if ( *pStart > nChangePos ) @@ -884,6 +883,7 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, { *pStart = nChangePos; } + bStartOfTxtAttrChanged = true; } xub_StrLen * const pEnd = pHint->GetEnd(); @@ -899,6 +899,17 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, { *pEnd = nChangePos; } + bTxtAttrChanged = !bStartOfTxtAttrChanged; + } + } + + if ( bTxtAttrChanged + && pHint->Which() == RES_TXTATR_INPUTFIELD ) + { + SwTxtInputFld* pTxtInputFld = dynamic_cast<SwTxtInputFld*>(pHint); + if ( pTxtInputFld ) + { + pTxtInputFld->UpdateFieldContent(); } } } @@ -909,14 +920,15 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, { bool bNoExp = false; bool bResort = false; - const sal_uInt16 coArrSz = static_cast<sal_uInt16>(RES_TXTATR_WITHEND_END) - - static_cast<sal_uInt16>(RES_CHRATR_BEGIN); + const sal_uInt16 coArrSz = + static_cast<sal_uInt16>(RES_TXTATR_WITHEND_END) - static_cast<sal_uInt16>(RES_CHRATR_BEGIN); sal_Bool aDontExp[ coArrSz ]; memset( &aDontExp, 0, coArrSz * sizeof(sal_Bool) ); for ( sal_uInt16 n = 0; n < m_pSwpHints->Count(); ++n ) { + bool bTxtAttrChanged = false; SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); xub_StrLen * const pStart = pHint->GetStart(); xub_StrLen * const pEnd = pHint->GetEnd(); @@ -933,6 +945,7 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, if ( (*pEnd > nChangePos) || IsIgnoreDontExpand() ) { *pEnd = *pEnd + nChangeLen; + bTxtAttrChanged = true; } else // *pEnd == nChangePos { @@ -975,26 +988,35 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, sal_uInt16 nCollCnt = pCollector->Count(); for( sal_uInt16 i = 0; i < nCollCnt; ++i ) { - SwTxtAttr *pTmp = (*pCollector)[ i ]; - if( nWhich == pTmp->Which() ) - { - pCollector->Remove( i ); - SwTxtAttr::Destroy( pTmp, - GetDoc()->GetAttrPool() ); - break; - } + SwTxtAttr *pTmp = (*pCollector)[ i ]; + if( nWhich == pTmp->Which() ) + { + pCollector->Remove( i ); + SwTxtAttr::Destroy( pTmp, GetDoc()->GetAttrPool() ); + break; + } } - SwTxtAttr * const pTmp = MakeTxtAttr( *GetDoc(), - pHint->GetAttr(), - nChangePos, nChangePos + nChangeLen); + SwTxtAttr * const pTmp = + MakeTxtAttr( *GetDoc(), pHint->GetAttr(), nChangePos, nChangePos + nChangeLen); pCollector->C40_INSERT( SwTxtAttr, pTmp, pCollector->Count() ); } else { *pEnd = *pEnd + nChangeLen; + bTxtAttrChanged = true; } } } + + if ( bTxtAttrChanged + && pHint->Which() == RES_TXTATR_INPUTFIELD ) + { + SwTxtInputFld* pTxtInputFld = dynamic_cast<SwTxtInputFld*>(pHint); + if ( pTxtInputFld ) + { + pTxtInputFld->UpdateFieldContent(); + } + } } if ( bResort ) { @@ -1047,10 +1069,9 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, } const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppMark = - pMarkAccess->getMarksBegin(); - ppMark != pMarkAccess->getMarksEnd(); - ppMark++) + for ( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + ppMark != pMarkAccess->getMarksEnd(); + ppMark++ ) { // Bookmarks must never grow to either side, when // editing (directly) to the left or right (#i29942#)! @@ -1184,9 +1205,11 @@ static bool lcl_GetTxtAttrParent(xub_StrLen const nIndex, static void lcl_GetTxtAttrs( - ::std::vector<SwTxtAttr *> *const pVector, SwTxtAttr **const ppTxtAttr, + ::std::vector<SwTxtAttr *> *const pVector, + SwTxtAttr **const ppTxtAttr, SwpHints *const pSwpHints, - xub_StrLen const nIndex, RES_TXTATR const nWhich, + xub_StrLen const nIndex, + RES_TXTATR const nWhich, enum SwTxtNode::GetTxtAttrMode const eMode) { sal_uInt16 const nSize = (pSwpHints) ? pSwpHints->Count() : 0; @@ -1215,10 +1238,9 @@ lcl_GetTxtAttrs( } xub_StrLen const*const pEndIdx = pHint->GetEnd(); - ASSERT(pEndIdx || pHint->HasDummyChar(), - "hint with no end and no dummy char?"); - // Wenn bExpand gesetzt ist, wird das Verhalten bei Eingabe - // simuliert, d.h. der Start wuede verschoben, das Ende expandiert, + ASSERT(pEndIdx || pHint->HasDummyChar(), "hint with no end and no dummy char?"); + // Wenn bExpand gesetzt ist, wird das Verhalten bei Eingabe + // simuliert, d.h. der Start wuede verschoben, das Ende expandiert, bool const bContained( (pEndIdx) ? (*pMatchFunc)(nIndex, nHintStart, *pEndIdx) : (nHintStart == nIndex) ); @@ -1263,7 +1285,8 @@ SwTxtNode::GetTxtAttrAt(xub_StrLen const nIndex, RES_TXTATR const nWhich, || (nWhich == RES_TXTATR_AUTOFMT) || (nWhich == RES_TXTATR_INETFMT) || (nWhich == RES_TXTATR_CJK_RUBY) - || (nWhich == RES_TXTATR_UNKNOWN_CONTAINER), + || (nWhich == RES_TXTATR_UNKNOWN_CONTAINER) + || (nWhich == RES_TXTATR_INPUTFIELD ), "GetTxtAttrAt() will give wrong result for this hint!"); SwTxtAttr * pRet(0); @@ -1271,6 +1294,40 @@ SwTxtNode::GetTxtAttrAt(xub_StrLen const nIndex, RES_TXTATR const nWhich, return pRet; } +const SwTxtInputFld* SwTxtNode::GetOverlappingInputFld( const SwTxtAttr& rTxtAttr ) const +{ + const SwTxtInputFld* pTxtInputFld = NULL; + + pTxtInputFld = dynamic_cast<const SwTxtInputFld*>(GetTxtAttrAt( *(rTxtAttr.GetStart()), RES_TXTATR_INPUTFIELD, PARENT )); + + if ( pTxtInputFld == NULL && rTxtAttr.End() != NULL ) + { + pTxtInputFld = dynamic_cast<const SwTxtInputFld*>(GetTxtAttrAt( *(rTxtAttr.End()), RES_TXTATR_INPUTFIELD, PARENT )); + } + + return pTxtInputFld; +} + +SwTxtFld* SwTxtNode::GetFldTxtAttrAt( + const xub_StrLen nIndex, + const bool bIncludeInputFldAtStart ) const +{ + SwTxtFld* pTxtFld = NULL; + + pTxtFld = dynamic_cast<SwTxtFld*>(GetTxtAttrForCharAt( nIndex, RES_TXTATR_FIELD )); + if ( pTxtFld == NULL ) + { + pTxtFld = + dynamic_cast<SwTxtFld*>( GetTxtAttrAt( + nIndex, + RES_TXTATR_INPUTFIELD, + bIncludeInputFldAtStart ? DEFAULT : PARENT )); + } + + return pTxtFld; +} + + /************************************************************************* * CopyHint() *************************************************************************/ @@ -1291,77 +1348,80 @@ SwCharFmt* lcl_FindCharFmt( const SwCharFmts* pCharFmts, const XubString& rName return NULL; } -void lcl_CopyHint( const sal_uInt16 nWhich, const SwTxtAttr * const pHt, - SwTxtAttr *const pNewHt, SwDoc *const pOtherDoc, SwTxtNode *const pDest ) +void lcl_CopyHint( + const sal_uInt16 nWhich, + const SwTxtAttr * const pHt, + SwTxtAttr *const pNewHt, + SwDoc *const pOtherDoc, + SwTxtNode *const pDest ) { ASSERT( nWhich == pHt->Which(), "Falsche Hint-Id" ); switch( nWhich ) { - // copy nodesarray section with footnote content - case RES_TXTATR_FTN : + // copy nodesarray section with footnote content + case RES_TXTATR_FTN : ASSERT(pDest, "lcl_CopyHint: no destination text node?"); - static_cast<const SwTxtFtn*>(pHt)->CopyFtn( - *static_cast<SwTxtFtn*>(pNewHt), *pDest); + static_cast<const SwTxtFtn*>(pHt)->CopyFtn( *static_cast<SwTxtFtn*>(pNewHt), *pDest); break; - // Beim Kopieren von Feldern in andere Dokumente - // muessen die Felder bei ihren neuen Feldtypen angemeldet werden. + // Beim Kopieren von Feldern in andere Dokumente + // muessen die Felder bei ihren neuen Feldtypen angemeldet werden. - // TabellenFormel muessen relativ kopiert werden. - case RES_TXTATR_FIELD : + // TabellenFormel muessen relativ kopiert werden. + case RES_TXTATR_FIELD : + case RES_TXTATR_INPUTFIELD : + { + if( pOtherDoc ) { - const SwFmtFld& rFld = pHt->GetFmtFld(); - if( pOtherDoc ) - { - static_cast<const SwTxtFld*>(pHt)->CopyFld( - static_cast<SwTxtFld*>(pNewHt) ); - } + static_cast<const SwTxtFld*>(pHt)->CopyTxtFld( static_cast<SwTxtFld*>(pNewHt) ); + } - // Tabellenformel ?? - if( RES_TABLEFLD == rFld.GetField()->GetTyp()->Which() - && static_cast<const SwTblField*>(rFld.GetField())->IsIntrnlName()) + // Tabellenformel ?? + const SwFmtFld& rFld = pHt->GetFmtFld(); + if( RES_TABLEFLD == rFld.GetField()->GetTyp()->Which() + && static_cast<const SwTblField*>(rFld.GetField())->IsIntrnlName()) + { + // wandel die interne in eine externe Formel um + const SwTableNode* const pDstTblNd = + static_cast<const SwTxtFld*>(pHt)->GetTxtNode().FindTableNode(); + if( pDstTblNd ) { - // wandel die interne in eine externe Formel um - const SwTableNode* const pDstTblNd = - static_cast<const SwTxtFld*>(pHt)->GetTxtNode().FindTableNode(); - if( pDstTblNd ) - { - SwTblField* const pTblFld = const_cast<SwTblField*>( - static_cast<const SwTblField*>(pNewHt->GetFmtFld().GetField())); - pTblFld->PtrToBoxNm( &pDstTblNd->GetTable() ); - } + SwTblField* const pTblFld = const_cast<SwTblField*>( + static_cast<const SwTblField*>(pNewHt->GetFmtFld().GetField())); + pTblFld->PtrToBoxNm( &pDstTblNd->GetTable() ); } } - break; + } + break; - case RES_TXTATR_TOXMARK : - if( pOtherDoc && pDest && pDest->GetpSwpHints() - && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) - { - // Beim Kopieren von TOXMarks(Client) in andere Dokumente - // muss der Verzeichnis (Modify) ausgetauscht werden - static_cast<SwTxtTOXMark*>(pNewHt)->CopyTOXMark( pOtherDoc ); - } - break; + case RES_TXTATR_TOXMARK : + if( pOtherDoc && pDest && pDest->GetpSwpHints() + && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) + { + // Beim Kopieren von TOXMarks(Client) in andere Dokumente + // muss der Verzeichnis (Modify) ausgetauscht werden + static_cast<SwTxtTOXMark*>(pNewHt)->CopyTOXMark( pOtherDoc ); + } + break; - case RES_TXTATR_CHARFMT : - // Wenn wir es mit einer Zeichenvorlage zu tun haben, - // muessen wir natuerlich auch die Formate kopieren. - if( pDest && pDest->GetpSwpHints() - && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) - { - SwCharFmt* pFmt = - static_cast<SwCharFmt*>(pHt->GetCharFmt().GetCharFmt()); + case RES_TXTATR_CHARFMT : + // Wenn wir es mit einer Zeichenvorlage zu tun haben, + // muessen wir natuerlich auch die Formate kopieren. + if( pDest && pDest->GetpSwpHints() + && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) + { + SwCharFmt* pFmt = + static_cast<SwCharFmt*>(pHt->GetCharFmt().GetCharFmt()); - if( pFmt && pOtherDoc ) - { - pFmt = pOtherDoc->CopyCharFmt( *pFmt ); - } - const_cast<SwFmtCharFmt&>( static_cast<const SwFmtCharFmt&>( - pNewHt->GetCharFmt() ) ).SetCharFmt( pFmt ); + if( pFmt && pOtherDoc ) + { + pFmt = pOtherDoc->CopyCharFmt( *pFmt ); } - break; - case RES_TXTATR_INETFMT : + const_cast<SwFmtCharFmt&>( static_cast<const SwFmtCharFmt&>( + pNewHt->GetCharFmt() ) ).SetCharFmt( pFmt ); + } + break; + case RES_TXTATR_INETFMT : { // Wenn wir es mit benutzerdefinierten INet-Zeichenvorlagen // zu tun haben, muessen wir natuerlich auch die Formate kopieren. @@ -1369,7 +1429,7 @@ void lcl_CopyHint( const sal_uInt16 nWhich, const SwTxtAttr * const pHt, && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { const SwDoc* const pDoc = static_cast<const SwTxtINetFmt*>(pHt) - ->GetTxtNode().GetDoc(); + ->GetTxtNode().GetDoc(); if ( pDoc ) { const SwCharFmts* pCharFmts = pDoc->GetCharFmts(); @@ -1396,13 +1456,13 @@ void lcl_CopyHint( const sal_uInt16 nWhich, const SwTxtAttr * const pHt, pINetHt->GetCharFmt(); break; } - case RES_TXTATR_META: - case RES_TXTATR_METAFIELD: - OSL_ENSURE(pNewHt, "copying Meta should not fail!"); - OSL_ENSURE(pDest && (CH_TXTATR_INWORD == - pDest->GetTxt().GetChar(*pNewHt->GetStart())), - "missing CH_TXTATR?"); - break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + OSL_ENSURE( pNewHt, "copying Meta should not fail!" ); + OSL_ENSURE( pDest + && (CH_TXTATR_INWORD == pDest->GetTxt().GetChar(*pNewHt->GetStart())), + "missing CH_TXTATR?"); + break; } } @@ -1428,34 +1488,33 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, SwTxtAttr *const pHt = m_pSwpHints->GetTextHint(i); xub_StrLen const nAttrStartIdx = *pHt->GetStart(); if ( nTxtStartIdx < nAttrStartIdx ) - break; // ueber das Textende, da nLen == 0 + break; // ueber das Textende, da nLen == 0 const xub_StrLen *const pEndIdx = pHt->GetEnd(); if ( pEndIdx && !pHt->HasDummyChar() ) { - if( ( *pEndIdx > nTxtStartIdx || - ( *pEndIdx == nTxtStartIdx && - nAttrStartIdx == nTxtStartIdx ) ) ) + if ( ( *pEndIdx > nTxtStartIdx + || ( *pEndIdx == nTxtStartIdx + && nAttrStartIdx == nTxtStartIdx ) ) ) { sal_uInt16 const nWhich = pHt->Which(); if ( RES_TXTATR_REFMARK != nWhich ) { // attribute in the area => copy - SwTxtAttr *const pNewHt = pDest->InsertItem( - pHt->GetAttr(), nOldPos, nOldPos, - nsSetAttrMode::SETATTR_IS_COPY); + SwTxtAttr *const pNewHt = + pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos, nsSetAttrMode::SETATTR_IS_COPY); if ( pNewHt ) { lcl_CopyHint( nWhich, pHt, pNewHt, - pOtherDoc, pDest ); + pOtherDoc, pDest ); } } - else if( !pOtherDoc ? GetDoc()->IsCopyIsMove() - : 0 == pOtherDoc->GetRefMark( - pHt->GetRefMark().GetRefName() ) ) + else if( !pOtherDoc + ? GetDoc()->IsCopyIsMove() + : 0 == pOtherDoc->GetRefMark( pHt->GetRefMark().GetRefName() ) ) { - pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos, - nsSetAttrMode::SETATTR_IS_COPY); + pDest->InsertItem( + pHt->GetAttr(), nOldPos, nOldPos, nsSetAttrMode::SETATTR_IS_COPY); } } } @@ -1476,7 +1535,6 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, |* wird angehaengt *************************************************************************/ -// --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rStart, @@ -1486,16 +1544,13 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, SwIndex aIdx( pDest, pDest->m_Text.Len() ); CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); } -// <-- -// --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rDestStart, const SwIndex &rStart, xub_StrLen nLen, const bool bForceCopyOfAllAttrs ) -// <-- { xub_StrLen nTxtStartIdx = rStart.GetIndex(); xub_StrLen nDestStart = rDestStart.GetIndex(); // alte Pos merken @@ -1557,26 +1612,23 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, if ( !nLen ) // string not longer? return; - SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? - pDest->GetDoc() : 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? pDest->GetDoc() : 0; // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) { // alle, oder nur die CharAttribute ? - // --> OD 2008-11-18 #i96213# - if ( !bForceCopyOfAllAttrs && - ( nDestStart || - pDest->HasSwAttrSet() || - nLen != pDest->GetTxt().Len() ) ) - // <-- + if ( !bForceCopyOfAllAttrs + && ( nDestStart + || pDest->HasSwAttrSet() + || nLen != pDest->GetTxt().Len() ) ) { SfxItemSet aCharSet( pDest->GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_CHRATR_END-1, - RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, - RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, - RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, - 0 ); + RES_CHRATR_BEGIN, RES_CHRATR_END-1, + RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, + 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) { @@ -1590,7 +1642,7 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, } bool const bUndoNodes = !pOtherDoc - && GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); + && GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); // Ende erst jetzt holen, weil beim Kopieren in sich selbst der // Start-Index und alle Attribute vorher aktualisiert werden. @@ -1611,11 +1663,11 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, SwpHts aRefMrkArr; sal_uInt16 nDeletedDummyChars(0); - //Achtung: kann ungueltig sein!! + //Achtung: kann ungueltig sein!! for (sal_uInt16 n = 0; ( n < nSize ); ++n) { const xub_StrLen nAttrStartIdx = *(*m_pSwpHints)[n]->GetStart(); - if (!( nAttrStartIdx < nEnd)) + if ( !( nAttrStartIdx < nEnd) ) break; SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); @@ -1628,16 +1680,32 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, // erkennen und sammeln, nach dem kopieren Loeschen. // Nimmt sein Zeichen mit ins Grab !! // JP 14.08.95: Duerfen RefMarks gemovt werden? - int bCopyRefMark = RES_TXTATR_REFMARK == nWhich && ( bUndoNodes || - (!pOtherDoc ? GetDoc()->IsCopyIsMove() - : 0 == pOtherDoc->GetRefMark( - pHt->GetRefMark().GetRefName() ))); + const bool bCopyRefMark = RES_TXTATR_REFMARK == nWhich + && ( bUndoNodes + || ( !pOtherDoc + ? GetDoc()->IsCopyIsMove() + : 0 == pOtherDoc->GetRefMark( pHt->GetRefMark().GetRefName() ) ) ); - if( pEndIdx && RES_TXTATR_REFMARK == nWhich && !bCopyRefMark ) + if ( pEndIdx + && RES_TXTATR_REFMARK == nWhich + && !bCopyRefMark ) { continue; } + // Input Fields are only copied, if completely covered by copied text + if ( nWhich == RES_TXTATR_INPUTFIELD ) + { + ASSERT( pEndIdx != NULL, + "<SwTxtNode::CopyText(..)> - RES_TXTATR_INPUTFIELD without EndIndex!" ); + if ( nAttrStartIdx < nTxtStartIdx + || ( pEndIdx != NULL + && *(pEndIdx) > nEnd ) ) + { + continue; + } + } + xub_StrLen nAttrStt; xub_StrLen nAttrEnd; @@ -1650,8 +1718,8 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, // attribute with extent and the end is in the selection nAttrStt = nDestStart; nAttrEnd = (*pEndIdx > nEnd) - ? rDestStart.GetIndex() - : nDestStart + (*pEndIdx) - nTxtStartIdx; + ? rDestStart.GetIndex() + : nDestStart + (*pEndIdx) - nTxtStartIdx; } else { @@ -1665,8 +1733,8 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, if( pEndIdx ) { nAttrEnd = *pEndIdx > nEnd - ? rDestStart.GetIndex() - : nDestStart + ( *pEndIdx - nTxtStartIdx ); + ? rDestStart.GetIndex() + : nDestStart + ( *pEndIdx - nTxtStartIdx ); } else { @@ -2284,7 +2352,7 @@ void SwTxtNode::EraseText(const SwIndex &rIdx, const xub_StrLen nCount, // 1. The hint ends before the deletion end position or // 2. The hint ends at the deletion end position and // we are not in empty expand mode and - // the hint is a [toxmark|refmark|ruby] text attribute + // the hint is a [toxmark|refmark|ruby|inputfield] text attribute // 3. deleting exactly the dummy char of an hint with end and dummy // char deletes the hint if ( (*pHtEndIdx < nEndIdx) @@ -2292,16 +2360,9 @@ void SwTxtNode::EraseText(const SwIndex &rIdx, const xub_StrLen nCount, !(IDocumentContentOperations::INS_EMPTYEXPAND & nMode) && ( (RES_TXTATR_TOXMARK == nWhich) || (RES_TXTATR_REFMARK == nWhich) || - // --> FME 2006-03-03 #i62668# Ruby text attribute must be - // treated just like toxmark and refmarks - (RES_TXTATR_CJK_RUBY == nWhich) ) ) - // <-- -#if 0 - || ( (nHintStart == nStartIdx) && - (nHintStart + 1 == nEndIdx)&& -#else // generalize this to left-overlapped dummy char hints (see ASSERT) + (RES_TXTATR_CJK_RUBY == nWhich) || + (RES_TXTATR_INPUTFIELD == nWhich) ) ) || ( (nHintStart < nEndIdx) && -#endif pHt->HasDummyChar() ) ) { @@ -2354,10 +2415,9 @@ void SwTxtNode::GCAttr() return; bool bChanged = false; - sal_uInt16 nMin = m_Text.Len(), - nMax = 0; - sal_Bool bAll = nMin != 0; // Bei leeren Absaetzen werden nur die - // INet-Formate entfernt. + sal_uInt16 nMin = m_Text.Len(); + sal_uInt16 nMax = 0; + const bool bAll = nMin != 0; // Bei leeren Absaetzen werden nur die INet-Formate entfernt. for ( sal_uInt16 i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { @@ -2426,84 +2486,7 @@ SwNumRule* SwTxtNode::_GetNumRule(sal_Bool bInParent) const } } } - - // --> OD 2006-11-20 #i71764# - // Document setting OUTLINE_LEVEL_YIELDS_OUTLINE_RULE has no influence - // any more. -// if ( !pRet && -// GetDoc()->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE) && -// GetOutlineLevel() != NO_NUMBERING ) -// { -// pRet = GetDoc()->GetOutlineNumRule(); -// } - // <-- } - // old code before tuning -// // --> OD 2005-10-25 #126347# -// // determine of numbering/bullet rule, which is set as a hard attribute -// // at the text node -// const SfxPoolItem* pItem( 0L ); -// if ( HasSwAttrSet() ) // does text node has hard attributes ? -// { -// if ( SFX_ITEM_SET != -// GetpSwAttrSet()->GetItemState( RES_PARATR_NUMRULE, sal_False, &pItem ) ) -// { -// pItem = 0L; -// } -// // else: <pItem> contains the numbering/bullet attribute, which is -// // hard set at the paragraph. - -// } -// // <-- -// bool bNoNumRule = false; -// if (pItem) -// { -// String sNumRuleName = static_cast<const SwNumRuleItem *>(pItem)->GetValue(); -// if (sNumRuleName.Len() > 0) -// { -// pRet = GetDoc()->FindNumRulePtr(sNumRuleName); -// } -// else // numbering is turned off by hard attribute -// bNoNumRule = true; -// } - -// if (! bNoNumRule) -// { -// if (! pRet && bInParent) -// { -// SwTxtFmtColl * pColl = GetTxtColl(); - -// if (pColl) -// { -// const SwNumRuleItem & rItem = pColl->GetNumRule(sal_True); - -// pRet = const_cast<SwDoc *>(GetDoc())-> -// FindNumRulePtrWithPool(rItem.GetValue()); -// // --> OD 2005-10-13 #125993# - The outline numbering rule -// // isn't allowed to be derived from a parent paragraph style -// // to a derived one. -// // Thus check, if the found outline numbering rule is directly -// // set at the paragraph style <pColl>. If not, don't return -// // the outline numbering rule. -// if ( pRet && pRet == GetDoc()->GetOutlineNumRule() ) -// { -// const SwNumRuleItem& rDirectItem = pColl->GetNumRule(sal_False); -// SwNumRule* pNumRuleAtParaStyle = const_cast<SwDoc*>(GetDoc())-> -// FindNumRulePtrWithPool(rDirectItem.GetValue()); -// if ( !pNumRuleAtParaStyle ) -// { -// pRet = 0L; -// } -// } -// // <-- -// } -// } - -// if (!pRet && GetDoc()->IsOutlineLevelYieldsOutlineRule() && -// GetOutlineLevel() != NO_NUMBERING) -// pRet = GetDoc()->GetOutlineNumRule(); -// } - // <-- return pRet; } @@ -2712,7 +2695,6 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) SwNodeIndex aIdx( rPos.nNode, 1 ); SwTxtNode* pNew = _MakeNewTxtNode( aIdx, sal_True ); - // --> OD 2008-05-14 #refactorlists# // reset list attributes at appended text node pNew->ResetAttr( RES_PARATR_LIST_ISRESTART ); pNew->ResetAttr( RES_PARATR_LIST_RESTARTVALUE ); @@ -2722,14 +2704,11 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) pNew->ResetAttr( RES_PARATR_LIST_ID ); pNew->ResetAttr( RES_PARATR_LIST_LEVEL ); } - // <-- - // --> OD 2008-03-13 #refactorlists# -// SyncNumberAndNumRule(); + if ( !IsInList() && GetNumRule() && GetListId().Len() > 0 ) { AddToList(); } - // <-- if( GetDepends() ) MakeFrms( *pNew ); @@ -2740,7 +2719,8 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) * SwTxtNode::GetTxtAttr *************************************************************************/ -SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( const xub_StrLen nIndex, +SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( + const xub_StrLen nIndex, const RES_TXTATR nWhich ) const { if ( HasHints() ) @@ -2756,7 +2736,7 @@ SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( const xub_StrLen nIndex, if ( (nIndex == nStartPos) && pHint->HasDummyChar() ) { return ( RES_TXTATR_END == nWhich || nWhich == pHint->Which() ) - ? pHint : 0; + ? pHint : 0; } } } @@ -3092,6 +3072,11 @@ XubString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx, XubString aTxt( GetTxt().Copy( nIdx, nLen ) ); xub_StrLen nTxtStt = nIdx; Replace0xFF( aTxt, nTxtStt, aTxt.Len(), sal_True ); + + // remove dummy characters of Input Fields + aTxt.EraseAllChars( CH_TXT_ATR_INPUTFIELDSTART ); + aTxt.EraseAllChars( CH_TXT_ATR_INPUTFIELDEND ); + if( bWithNum ) { XubString aListLabelStr = GetNumString(); @@ -3145,6 +3130,11 @@ sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, SwScriptInfo::MaskHiddenRanges( *this, sTmpText, 0, sTmpText.Len(), cChar ); sTmpText = sTmpText.Copy( nIdx, nLen ); + // remove dummy characters of Input Fields + { + sTmpText.EraseAllChars( CH_TXT_ATR_INPUTFIELDSTART ); + sTmpText.EraseAllChars( CH_TXT_ATR_INPUTFIELDEND ); + } rDestNd.InsertText( sTmpText, aDestIdx ); nLen = aDestIdx.GetIndex() - nDestStt; @@ -3160,7 +3150,7 @@ sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if (nIdx + nLen <= nAttrStartIdx) break; // ueber das Textende - const xub_StrLen *pEndIdx = pHt->GetEnd(); + const xub_StrLen *pEndIdx = pHt->End(); if( pEndIdx && *pEndIdx > nIdx && ( RES_CHRATR_FONT == nWhich || RES_TXTATR_CHARFMT == nWhich || @@ -3470,19 +3460,12 @@ namespace { bParagraphStyleChanged = true; if( rTxtNode.GetNodes().IsDocNodes() ) { - // --> OD 2008-12-17 #i70748# - // The former list style set at the paragraph can not be - // retrieved from the change set. -// sOldNumRule = -// dynamic_cast<const SwFmtChg*>(pOldValue)->pChangedFmt->GetNumRule().GetValue(); const SwNumRule* pFormerNumRuleAtTxtNode = rTxtNode.GetNum() ? rTxtNode.GetNum()->GetNumRule() : 0; if ( pFormerNumRuleAtTxtNode ) { sOldNumRule = pFormerNumRuleAtTxtNode->GetName(); } - // <-- - // --> OD 2008-11-19 #i70748# if ( rTxtNode.IsEmptyListStyleDueToSetOutlineLevelAttr() ) { const SwNumRuleItem& rNumRuleItem = rTxtNode.GetTxtColl()->GetNumRule(); @@ -3491,7 +3474,6 @@ namespace { rTxtNode.ResetEmptyListStyleDueToResetOutlineLevelAttr(); } } - // <-- const SwNumRule* pNumRuleAtTxtNode = rTxtNode.GetNumRule(); if ( pNumRuleAtTxtNode ) { @@ -3504,80 +3486,45 @@ namespace { case RES_ATTRSET_CHG: { const SfxPoolItem* pItem = 0; - // --> OD 2008-12-19 #i70748# - // The former list style set at the paragraph can not be - // retrieved from the change set. -// if ( dynamic_cast<const SwAttrSetChg*>(pOldValue)->GetChgSet()->GetItemState( RES_PARATR_NUMRULE, sal_False, &pItem ) == -// SFX_ITEM_SET ) -// { -// sOldNumRule = dynamic_cast<const SwNumRuleItem*>(pItem)->GetValue(); -// } const SwNumRule* pFormerNumRuleAtTxtNode = rTxtNode.GetNum() ? rTxtNode.GetNum()->GetNumRule() : 0; if ( pFormerNumRuleAtTxtNode ) { sOldNumRule = pFormerNumRuleAtTxtNode->GetName(); } - // <-- if ( dynamic_cast<const SwAttrSetChg*>(pNewValue)->GetChgSet()->GetItemState( RES_PARATR_NUMRULE, sal_False, &pItem ) == SFX_ITEM_SET ) { - // --> OD 2008-11-19 #i70748# rTxtNode.ResetEmptyListStyleDueToResetOutlineLevelAttr(); - // <-- bNumRuleSet = true; - // The new list style set at the paragraph can not be - // retrieved from the change set. -// sNumRule = dynamic_cast<const SwNumRuleItem*>(pItem)->GetValue(); - // <-- } - // --> OD 2008-12-17 #i70748# - // The new list style set at the paragraph. const SwNumRule* pNumRuleAtTxtNode = rTxtNode.GetNumRule(); if ( pNumRuleAtTxtNode ) { sNumRule = pNumRuleAtTxtNode->GetName(); } - // <-- break; } case RES_PARATR_NUMRULE: { if ( rTxtNode.GetNodes().IsDocNodes() ) { - // The former list style set at the paragraph can not be - // retrieved from the change set. -// if ( pOldValue ) -// { -// sOldNumRule = dynamic_cast<const SwNumRuleItem*>(pOldValue)->GetValue(); -// } const SwNumRule* pFormerNumRuleAtTxtNode = rTxtNode.GetNum() ? rTxtNode.GetNum()->GetNumRule() : 0; if ( pFormerNumRuleAtTxtNode ) { sOldNumRule = pFormerNumRuleAtTxtNode->GetName(); } - // <-- if ( pNewValue ) { - // --> OD 2008-11-19 #i70748# rTxtNode.ResetEmptyListStyleDueToResetOutlineLevelAttr(); - // <-- bNumRuleSet = true; - // --> OD 2008-12-17 #i70748# - // The new list style set at the paragraph can not be - // retrieved from the change set. -// sNumRule = dynamic_cast<const SwNumRuleItem*>(pNewValue)->GetValue(); - // <-- } - // --> OD 2008-12-17 #i70748# - // The new list style set at the paragraph. const SwNumRule* pNumRuleAtTxtNode = rTxtNode.GetNumRule(); if ( pNumRuleAtTxtNode ) { sNumRule = pNumRuleAtTxtNode->GetName(); } - // <-- } break; } @@ -3598,12 +3545,10 @@ namespace { aResetAttrsArray.Insert( RES_PARATR_LIST_RESTARTVALUE ); aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED ); SwPaM aPam( rTxtNode ); - // --> OD 2008-11-28 #i96644# // suppress side effect "send data changed events" rTxtNode.GetDoc()->ResetAttrs( aPam, sal_False, &aResetAttrsArray, false ); - // <-- } } else @@ -3614,12 +3559,9 @@ namespace { if ( sNumRule == String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ) ) { - // --> OD 2008-09-10 #i70748# ASSERT( rTxtNode.GetTxtColl()->IsAssignedToListLevelOfOutlineStyle(), "<HandleModifyAtTxtNode()> - text node with outline style, but its paragraph style is not assigned to outline style." ); - int nNewListLevel = - rTxtNode.GetTxtColl()->GetAssignedOutlineStyleLevel(); - // <-- + const int nNewListLevel = rTxtNode.GetTxtColl()->GetAssignedOutlineStyleLevel(); if ( 0 <= nNewListLevel && nNewListLevel < MAXLEVEL ) { rTxtNode.SetAttrListLevel( nNewListLevel ); @@ -3640,18 +3582,13 @@ namespace { aResetAttrsArray.Insert( RES_PARATR_LIST_RESTARTVALUE ); aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED ); SwPaM aPam( rTxtNode ); - // --> OD 2008-11-28 #i96644# - // suppress side effect "send data changed events" rTxtNode.GetDoc()->ResetAttrs( aPam, sal_False, &aResetAttrsArray, false ); - // <-- - // --> OD 2008-11-19 #i70748# if ( dynamic_cast<const SfxUInt16Item &>(rTxtNode.GetAttr( RES_PARATR_OUTLINELEVEL, sal_False )).GetValue() > 0 ) { rTxtNode.SetEmptyListStyleDueToSetOutlineLevelAttr(); } - // <-- } } } @@ -3659,7 +3596,6 @@ namespace { { rTxtNode.AddToList(); } - // <-- } // End of method <HandleModifyAtTxtNode> } @@ -5068,16 +5004,19 @@ SwTxtNode::MakeUnoObject() SwXParagraph::CreateXParagraph(*GetDoc(), *this), uno::UNO_QUERY); return xMeta; } + //Bug 120881:Modify here for Directly Page Numbering bool SwTxtNode::HasPageNumberField() { - xub_StrLen nEnd = Len(); - for(xub_StrLen nStart=0;nStart<nEnd;nStart++) + const xub_StrLen nEnd = Len(); + for( xub_StrLen nStart = 0; nStart < nEnd; ++nStart ) { - const SwTxtFld* pFld = GetTxtFld(nStart); - const SwField* pSwField = pFld - ? pFld->GetFmtFld().GetField() - : NULL; + const SwTxtAttr* pTxtAttr = GetTxtAttrAt( nStart, RES_TXTATR_FIELD ); + if ( pTxtAttr == NULL ) + { + continue; + } + const SwField* pSwField = pTxtAttr->GetFmtFld().GetField(); const SwFieldType* pType = pSwField ? pSwField->GetTyp() : NULL; diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 97ac87a1c5c1..03bf0b1f067f 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -441,6 +441,7 @@ SwFont::SwFont( const SwFont &rFont ) nToxCnt = 0; nRefCnt = 0; m_nMetaCount = 0; + m_nInputFieldCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; @@ -459,6 +460,7 @@ SwFont::SwFont( const SwAttrSet* pAttrSet, nToxCnt = 0; nRefCnt = 0; m_nMetaCount = 0; + m_nInputFieldCount = 0; bPaintBlank = sal_False; bPaintWrong = sal_False; bURL = sal_False; @@ -590,6 +592,7 @@ SwFont& SwFont::operator=( const SwFont &rFont ) nToxCnt = 0; nRefCnt = 0; m_nMetaCount = 0; + m_nInputFieldCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 451f57ff4348..35ce95c25ef4 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -123,7 +123,7 @@ struct TxtAttrContains TxtAttrContains( const xub_StrLen nPos ) : m_nPos( nPos ) { } bool operator() (SwTxtAttrEnd * const pAttr) { - return (*pAttr->GetStart() < m_nPos) && (m_nPos < *pAttr->GetEnd()); + return (*pAttr->GetStart() < m_nPos) && (m_nPos < *pAttr->End()); } }; @@ -167,7 +167,8 @@ static bool isSelfNestable(const sal_uInt16 nWhich) { if ((RES_TXTATR_INETFMT == nWhich) || - (RES_TXTATR_CJK_RUBY == nWhich)) + (RES_TXTATR_CJK_RUBY == nWhich) || + (RES_TXTATR_INPUTFIELD == nWhich)) return false; ASSERT((RES_TXTATR_META == nWhich) || (RES_TXTATR_METAFIELD == nWhich), "???"); @@ -181,7 +182,8 @@ bool isSplittable(const sal_uInt16 nWhich) (RES_TXTATR_CJK_RUBY == nWhich)) return true; ASSERT((RES_TXTATR_META == nWhich) || - (RES_TXTATR_METAFIELD == nWhich), "???"); + (RES_TXTATR_METAFIELD == nWhich) || + (RES_TXTATR_INPUTFIELD == nWhich), "???"); return false; } @@ -202,8 +204,10 @@ splitPolicy(const sal_uInt16 nWhichNew, const sal_uInt16 nWhichOther) } else { - if ((RES_TXTATR_INETFMT == nWhichNew) && - (RES_TXTATR_CJK_RUBY == nWhichOther)) + if ( RES_TXTATR_INPUTFIELD == nWhichNew ) + return FAIL; + else if ( (RES_TXTATR_INETFMT == nWhichNew) && + (RES_TXTATR_CJK_RUBY == nWhichOther) ) return SPLIT_NEW; else return SPLIT_OTHER; @@ -362,14 +366,14 @@ SwpHints::TryInsertNesting( SwTxtNode & rNode, SwTxtAttrNesting & rNewHint ) const sal_uInt16 nNewWhich( rNewHint.Which() ); const xub_StrLen nNewStart( *rNewHint.GetStart() ); const xub_StrLen nNewEnd ( *rNewHint.GetEnd() ); -//??? const bool bNoLengthAttribute( nNewStart == nNewEnd ); const bool bNewSelfNestable( isSelfNestable(nNewWhich) ); ASSERT( (RES_TXTATR_INETFMT == nNewWhich) || (RES_TXTATR_CJK_RUBY == nNewWhich) || (RES_TXTATR_META == nNewWhich) || - (RES_TXTATR_METAFIELD == nNewWhich), - "TryInsertNesting: Expecting INETFMT or RUBY or META or METAFIELD" ); + (RES_TXTATR_METAFIELD == nNewWhich) || + (RES_TXTATR_INPUTFIELD == nNewWhich), + "TryInsertNesting: Expecting INETFMT or RUBY or META or METAFIELD or INPUTFIELD" ); NestList_t OverlappingExisting; // existing hints to be split NestList_t OverwrittenExisting; // existing hints to be replaced @@ -681,7 +685,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, continue; const xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); + const xub_StrLen nOtherEnd = *pOther->End(); aBounds.insert( nOtherStart ); aBounds.insert( nOtherEnd ); @@ -989,9 +993,13 @@ SwTxtAttr* MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem & rAttr ) } // create new text attribute -SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, - xub_StrLen const nStt, xub_StrLen const nEnd, - CopyOrNew_t const bIsCopy, SwTxtNode *const pTxtNode) +SwTxtAttr* MakeTxtAttr( + SwDoc & rDoc, + SfxPoolItem& rAttr, + xub_StrLen const nStt, + xub_StrLen const nEnd, + CopyOrNew_t const bIsCopy, + SwTxtNode *const pTxtNode ) { if ( isCHRATR(rAttr.Which()) ) { @@ -1041,6 +1049,9 @@ SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, case RES_TXTATR_FIELD: pNew = new SwTxtFld( static_cast<SwFmtFld &>(rNew), nStt ); break; + case RES_TXTATR_INPUTFIELD: + pNew = new SwTxtInputFld( static_cast<SwFmtFld &>(rNew), nStt, nEnd ); + break; case RES_TXTATR_FLYCNT: { // erst hier wird das Frame-Format kopiert (mit Inhalt) !! @@ -1126,6 +1137,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) break; case RES_TXTATR_FIELD: + case RES_TXTATR_INPUTFIELD: if( !pDoc->IsInDtor() ) { // Wenn wir ein HiddenParaField sind, dann muessen wir @@ -1228,7 +1240,7 @@ SwTxtNode::InsertItem( SfxPoolItem& rAttr, // take ownership of pAttr; if insertion fails, delete pAttr bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) { - sal_Bool bHiddenPara = sal_False; + bool bHiddenPara = false; ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx out of bounds!" ); ASSERT( !pAttr->GetEnd() || (*pAttr->GetEnd() <= Len()), @@ -1250,7 +1262,7 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) sal_uInt16 nInsMode = nMode; switch( pAttr->Which() ) { - case RES_TXTATR_FLYCNT: + case RES_TXTATR_FLYCNT: { SwTxtFlyCnt *pFly = (SwTxtFlyCnt *)pAttr; SwFrmFmt* pFmt = pAttr->GetFlyCnt().GetFrmFmt(); @@ -1264,7 +1276,7 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) // erfolgen (Fehleranfaellig !) const SwFmtAnchor* pAnchor = 0; pFmt->GetItemState( RES_ANCHOR, sal_False, - (const SfxPoolItem**)&pAnchor ); + (const SfxPoolItem**)&pAnchor ); SwIndex aIdx( this, *pAttr->GetStart() ); const sal_Unicode c = GetCharOfTxtAttr(*pAttr); @@ -1325,7 +1337,7 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) break; } - case RES_TXTATR_FTN : + case RES_TXTATR_FTN : { // Fussnoten, man kommt an alles irgendwie heran. // CntntNode erzeugen und in die Inserts-Section stellen @@ -1343,10 +1355,10 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) { // loesche das Zeichen aus dem String ! ASSERT( ( CH_TXTATR_BREAKWORD == - m_Text.GetChar(*pAttr->GetStart() ) || - CH_TXTATR_INWORD == - m_Text.GetChar(*pAttr->GetStart())), - "where is my attribute character?" ); + m_Text.GetChar(*pAttr->GetStart() ) || + CH_TXTATR_INWORD == + m_Text.GetChar(*pAttr->GetStart())), + "where is my attribute character?" ); m_Text.Erase( *pAttr->GetStart(), 1 ); // Indizies Updaten SwIndex aTmpIdx( this, *pAttr->GetStart() ); @@ -1403,8 +1415,8 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) pDoc->GetFtnIdxs().Remove( n ); break; } - // wenn ueber Undo der StartNode gesetzt wurde, kann - // der Index noch gar nicht in der Verwaltung stehen !! + // wenn ueber Undo der StartNode gesetzt wurde, kann + // der Index noch gar nicht in der Verwaltung stehen !! } if( !pTxtFtn ) pTxtFtn = (SwTxtFtn*)pAttr; @@ -1434,9 +1446,10 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) { // fuer HiddenParaFields Benachrichtigungsmechanismus // anwerfen - if( RES_HIDDENPARAFLD == - pAttr->GetFmtFld().GetField()->GetTyp()->Which() ) - bHiddenPara = sal_True; + if( RES_HIDDENPARAFLD == pAttr->GetFmtFld().GetField()->GetTyp()->Which() ) + { + bHiddenPara = true; + } } break; @@ -1459,25 +1472,144 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) } } + // handle attributes which provide content + xub_StrLen nEnd = nStart; + bool bInputFieldStartCharInserted = false; + bool bInputFieldEndCharInserted = false; + const bool bHasContent( pAttr->HasContent() ); + if ( bHasContent ) + { + switch( pAttr->Which() ) + { + case RES_TXTATR_INPUTFIELD: + { + SwTxtInputFld* pTxtInputFld = dynamic_cast<SwTxtInputFld*>(pAttr); + if ( pTxtInputFld ) + { + if( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) ) + { + SwIndex aIdx( this, *pAttr->GetStart() ); + InsertText( CH_TXT_ATR_INPUTFIELDSTART, aIdx, nInsertFlags ); + const String aContent = pTxtInputFld->GetFieldContent(); + InsertText( aContent, aIdx, nInsertFlags ); + InsertText( CH_TXT_ATR_INPUTFIELDEND, aIdx, nInsertFlags ); + + xub_StrLen * const pEnd(pAttr->GetEnd()); + ASSERT( pEnd != NULL, "<SwTxtNode::InsertHint(..)> - missing end of RES_TXTATR_INPUTFIELD!" ); + if ( pEnd != NULL ) + { + *pEnd = *pEnd + 2 + aContent.Len(); + nEnd = *pEnd; + } + } + else + { + // assure that CH_TXT_ATR_INPUTFIELDSTART and CH_TXT_ATR_INPUTFIELDEND are inserted. + if ( m_Text.GetChar( *(pAttr->GetStart()) ) != CH_TXT_ATR_INPUTFIELDSTART ) + { + SwIndex aIdx( this, *pAttr->GetStart() ); + InsertText( CH_TXT_ATR_INPUTFIELDSTART, aIdx, nInsertFlags ); + bInputFieldStartCharInserted = true; + xub_StrLen * const pEnd(pAttr->GetEnd()); + ASSERT( pEnd != NULL, "<SwTxtNode::InsertHint(..)> - missing end of RES_TXTATR_INPUTFIELD!" ); + if ( pEnd != NULL ) + { + *pEnd = *pEnd + 1; + nEnd = *pEnd; + } + } + + xub_StrLen * const pEnd(pAttr->GetEnd()); + ASSERT( pEnd != NULL, "<SwTxtNode::InsertHint(..)> - missing end of RES_TXTATR_INPUTFIELD!" ); + if ( pEnd != NULL + && m_Text.GetChar( *(pEnd) - 1 ) != CH_TXT_ATR_INPUTFIELDEND ) + { + SwIndex aIdx( this, *(pEnd) ); + InsertText( CH_TXT_ATR_INPUTFIELDEND, aIdx, nInsertFlags ); + bInputFieldEndCharInserted = true; + *pEnd = *pEnd + 1; + nEnd = *pEnd; + } + } + } + } + break; + default: + break; + } + } + GetOrCreateSwpHints(); + // handle overlap with an existing InputField + bool bInsertHint = true; + { + const SwTxtInputFld* pTxtInputFld = GetOverlappingInputFld( *pAttr ); + if ( pTxtInputFld != NULL ) + { + if ( pAttr->End() == NULL ) + { + bInsertHint = false; + } + else + { + if ( *(pAttr->GetStart()) > *(pTxtInputFld->GetStart()) ) + { + *(pAttr->GetStart()) = *(pTxtInputFld->GetStart()); + } + if ( *(pAttr->End()) < *(pTxtInputFld->End()) ) + { + *(pAttr->GetEnd()) = *(pTxtInputFld->End()); + } + } + } + } + // 4263: AttrInsert durch TextInsert => kein Adjust - const bool bRet = m_pSwpHints->TryInsertHint( pAttr, *this, nMode ); + const bool bRet = bInsertHint + ? m_pSwpHints->TryInsertHint( pAttr, *this, nMode ) + : false; - if (!bRet && bDummyChar) + if ( !bRet ) { - // undo insertion of dummy character - // N.B. cannot insert the dummy character after inserting the hint, - // because if the hint has no extent it will be moved in InsertText, - // resulting in infinite recursion - if ( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) ) + if ( bDummyChar + && !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) ) { + // undo insertion of dummy character + // N.B. cannot insert the dummy character after inserting the hint, + // because if the hint has no extent it will be moved in InsertText, + // resulting in infinite recursion ASSERT( ( CH_TXTATR_BREAKWORD == m_Text.GetChar(nStart) || - CH_TXTATR_INWORD == m_Text.GetChar(nStart) ), - "where is my attribute character?" ); + CH_TXTATR_INWORD == m_Text.GetChar(nStart) ), + "where is my attribute character?" ); SwIndex aIdx( this, nStart ); EraseText( aIdx, 1 ); } + + if ( bHasContent ) + { + if ( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) + && (nEnd - nStart) > 0 ) + { + SwIndex aIdx( this, nStart ); + EraseText( aIdx, (nEnd - nStart) ); + } + else + { + if ( bInputFieldEndCharInserted + && (nEnd - nStart) > 0 ) + { + SwIndex aIdx( this, nEnd - 1 ); + EraseText( aIdx, 1 ); + } + + if ( bInputFieldStartCharInserted ) + { + SwIndex aIdx( this, nStart ); + EraseText( aIdx, 1 ); + } + } + } } if ( bHiddenPara ) @@ -1508,6 +1640,12 @@ void SwTxtNode::DeleteAttribute( SwTxtAttr * const pAttr ) // erase the CH_TXTATR, which will also delete pAttr EraseText( aIdx, 1 ); } + else if ( pAttr->HasContent() ) + { + const SwIndex aIdx( this, *pAttr->GetStart() ); + ASSERT( pAttr->End() != NULL, "<SwTxtNode::DeleteAttribute(..)> - missing End() at <SwTxtAttr> instance which has content" ); + EraseText( aIdx, *pAttr->End() - *pAttr->GetStart() ); + } else { // create MsgHint before start/end become invalid @@ -1526,8 +1664,10 @@ void SwTxtNode::DeleteAttribute( SwTxtAttr * const pAttr ) *************************************************************************/ //FIXME: this does NOT respect SORT NUMBER (for CHARFMT)! -void SwTxtNode::DeleteAttributes( const sal_uInt16 nWhich, - const xub_StrLen nStart, const xub_StrLen nEnd ) +void SwTxtNode::DeleteAttributes( + const sal_uInt16 nWhich, + const xub_StrLen nStart, + const xub_StrLen nEnd ) { if ( !HasHints() ) return; @@ -1555,7 +1695,7 @@ void SwTxtNode::DeleteAttributes( const sal_uInt16 nWhich, if ( SFX_ITEM_SET == pFmt->GetItemState( RES_CHRATR_HIDDEN, sal_True, &pItem ) ) SetCalcHiddenCharFlags(); } - // --> FME 2007-03-16 #i75430# Recalc hidden flags if necessary + // Recalc hidden flags if necessary else if ( nWhich == RES_TXTATR_AUTOFMT ) { // Check if auto style contains hidden attribute: @@ -1563,7 +1703,6 @@ void SwTxtNode::DeleteAttributes( const sal_uInt16 nWhich, if ( pHiddenItem ) SetCalcHiddenCharFlags(); } - // <-- xub_StrLen const * const pEndIdx = pTxtHt->GetEnd(); @@ -1574,6 +1713,12 @@ void SwTxtNode::DeleteAttributes( const sal_uInt16 nWhich, // erase the CH_TXTATR, which will also delete pTxtHt EraseText( aIdx, 1 ); } + else if ( pTxtHt->HasContent() ) + { + const SwIndex aIdx( this, nStart ); + ASSERT( pTxtHt->End() != NULL, "<SwTxtNode::DeleteAttributes(..)> - missing End() at <SwTxtAttr> instance which has content" ); + EraseText( aIdx, *pTxtHt->End() - nStart ); + } else if( *pEndIdx == nEnd ) { // den MsgHint jetzt fuettern, weil gleich sind @@ -1681,8 +1826,11 @@ bool SwTxtNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet) // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) -sal_Bool SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, - xub_StrLen nEnd, const SetAttrMode nMode ) +sal_Bool SwTxtNode::SetAttr( + const SfxItemSet& rSet, + const xub_StrLen nStt, + const xub_StrLen nEnd, + const SetAttrMode nMode ) { if( !rSet.Count() ) return sal_False; @@ -1760,7 +1908,7 @@ sal_Bool SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, static_cast<const SwFmtCharFmt*>(pItem)->GetCharFmt())) { SwIndex aIndex( this, nStt ); - RstAttr( aIndex, nEnd - nStt, RES_TXTATR_CHARFMT, 0 ); + RstTxtAttr( aIndex, nEnd - nStt, RES_TXTATR_CHARFMT, 0 ); DontExpandFmt( aIndex ); } else @@ -1947,7 +2095,7 @@ sal_Bool SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; - const xub_StrLen* pAttrEnd = pHt->GetEnd(); + const xub_StrLen* pAttrEnd = pHt->End(); if ( ! pAttrEnd ) // no attributes without end continue; @@ -1975,7 +2123,7 @@ sal_Bool SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; - const xub_StrLen* pAttrEnd = pHt->GetEnd(); + const xub_StrLen* pAttrEnd = pHt->End(); if ( ! pAttrEnd ) // no attributes without end continue; @@ -2208,7 +2356,7 @@ lcl_CollectHintSpans(const SwpHints& i_rHints, const sal_uInt16 nLength, const sal_uInt16 nWhich(pHint->Which()); if (nWhich == RES_TXTATR_CHARFMT || nWhich == RES_TXTATR_AUTOFMT) { - const AttrSpan_t aSpan(*pHint->GetStart(), *pHint->GetEnd()); + const AttrSpan_t aSpan(*pHint->GetStart(), *pHint->End()); o_rSpanMap.insert(AttrSpanMap_t::value_type(aSpan, pHint)); // < not != because there may be multiple CHARFMT at same range @@ -2555,7 +2703,7 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) { const SwTxtAttr* p1 = (*aIter1).second; const SwTxtAttr* p2 = (*aIter2).second; - if ( *p1->GetEnd() < *p2->GetStart() || p1->Which() != p2->Which() || !(*p1 == *p2) ) + if ( *p1->End() < *p2->GetStart() || p1->Which() != p2->Which() || !(*p1 == *p2) ) { bMerge = false; break; @@ -2632,7 +2780,7 @@ void lcl_CheckSortNumber( const SwpHints& rHints, SwTxtCharFmt& rNewCharFmt ) if ( RES_TXTATR_CHARFMT == pOtherHt->Which() ) { - const xub_StrLen nOtherEnd = *pOtherHt->GetEnd(); + const xub_StrLen nOtherEnd = *pOtherHt->End(); if ( nOtherStart == nHtStart && nOtherEnd == nHtEnd ) { @@ -2702,6 +2850,7 @@ bool SwpHints::TryInsertHint( SwTxtAttr* const pHint, SwTxtNode &rNode, static_cast<SwTxtINetFmt*>(pHint)->InitINetFmt(rNode); break; case RES_TXTATR_FIELD: + case RES_TXTATR_INPUTFIELD: { sal_Bool bDelFirst = 0 != ((SwTxtFld*)pHint)->GetpTxtNode(); ((SwTxtFld*)pHint)->ChgTxtNode( &rNode ); @@ -3023,6 +3172,7 @@ void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) break; case RES_TXTATR_FIELD: + case RES_TXTATR_INPUTFIELD: if( bDelFields ) bDel = true; break; @@ -3071,7 +3221,7 @@ sal_uInt16 SwTxtNode::GetLang( const xub_StrLen nBegin, const xub_StrLen nLen, if( nWhichId == nWhich || ( ( pHt->IsCharFmtAttr() || RES_TXTATR_AUTOFMT == nWhich ) && CharFmt::IsItemIncluded( nWhichId, pHt ) ) ) { - const xub_StrLen *pEndIdx = pHt->GetEnd(); + const xub_StrLen *pEndIdx = pHt->End(); // Ueberlappt das Attribut den Bereich? if( pEndIdx && diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 2a1f746f9097..75ddc60fc301 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -42,6 +42,7 @@ SwTxtAttr::SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ) , m_bDontExpandStart( false ) , m_bNesting( false ) , m_bHasDummyChar( false ) + , m_bHasContent( false ) { } diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx index 4c3e3074d080..e1c91ca2ee03 100644 --- a/sw/source/core/txtnode/txatritr.cxx +++ b/sw/source/core/txtnode/txatritr.cxx @@ -123,7 +123,7 @@ sal_Bool SwTxtAttrIterator::Next() { do { const SwTxtAttr* pHt = (SwTxtAttr*)aStack[ 0 ]; - sal_uInt16 nEndPos = *pHt->GetEnd(); + const sal_uInt16 nEndPos = *pHt->End(); if( nChgPos >= nEndPos ) aStack.Remove( 0 ); else @@ -138,7 +138,7 @@ sal_Bool SwTxtAttrIterator::Next() if( aStack.Count() ) { const SwTxtAttr* pHt = (SwTxtAttr*)aStack[ 0 ]; - sal_uInt16 nEndPos = *pHt->GetEnd(); + const sal_uInt16 nEndPos = *pHt->End(); if( nChgPos >= nEndPos ) { nChgPos = nEndPos; @@ -167,7 +167,7 @@ sal_Bool SwTxtAttrIterator::Next() void SwTxtAttrIterator::AddToStack( const SwTxtAttr& rAttr ) { void* pAdd = (void*)&rAttr; - sal_uInt16 nIns = 0, nEndPos = *rAttr.GetEnd(); + sal_uInt16 nIns = 0, nEndPos = *rAttr.End(); for( ; nIns < aStack.Count(); ++nIns ) if( *((SwTxtAttr*)aStack[ nIns ] )->GetEnd() > nEndPos ) break; @@ -213,7 +213,7 @@ void SwTxtAttrIterator::SearchNextChg() for( ; nAttrPos < pHts->Count(); ++nAttrPos ) { const SwTxtAttr* pHt = (*pHts)[ nAttrPos ]; - const sal_uInt16* pEnd = pHt->GetEnd(); + const sal_uInt16* pEnd = pHt->End(); const sal_uInt16 nHtStt = *pHt->GetStart(); if( nHtStt < nStt && ( !pEnd || *pEnd <= nStt )) continue; diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 77469bd83a80..c256b6222a7c 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -394,7 +394,7 @@ inline sal_Bool InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) { * -> nothing to do */ -void SwTxtNode::RstAttr( +void SwTxtNode::RstTxtAttr( const SwIndex &rIdx, const xub_StrLen nLen, const sal_uInt16 nWhich, @@ -404,8 +404,27 @@ void SwTxtNode::RstAttr( if ( !GetpSwpHints() ) return; - const xub_StrLen nStt = rIdx.GetIndex(); - const xub_StrLen nEnd = nStt + nLen; + xub_StrLen nStt = rIdx.GetIndex(); + xub_StrLen nEnd = nStt + nLen; + { + // enlarge range for the reset of text attributes in case of an overlapping input field + const SwTxtInputFld* pTxtInputFld = dynamic_cast<const SwTxtInputFld*>(GetTxtAttrAt( nStt, RES_TXTATR_INPUTFIELD, PARENT )); + if ( pTxtInputFld == NULL ) + { + pTxtInputFld = dynamic_cast<const SwTxtInputFld*>(GetTxtAttrAt(nEnd, RES_TXTATR_INPUTFIELD, PARENT )); + } + if ( pTxtInputFld != NULL ) + { + if ( nStt > *(pTxtInputFld->GetStart()) ) + { + nStt = *(pTxtInputFld->GetStart()); + } + if ( nEnd < *(pTxtInputFld->End()) ) + { + nEnd = *(pTxtInputFld->End()); + } + } + } bool bChanged = false; @@ -419,13 +438,13 @@ void SwTxtNode::RstAttr( // They may not be forgotten inside the "Forget" function //std::vector< const SwTxtAttr* > aNewAttributes; - // iterate over attribute array until start of attribute is behind - // deletion range + // iterate over attribute array until start of attribute is behind deletion range sal_uInt16 i = 0; xub_StrLen nAttrStart; SwTxtAttr *pHt = NULL; - while ((i < m_pSwpHints->Count()) && - ((( nAttrStart = *(*m_pSwpHints)[i]->GetStart()) < nEnd ) || nLen==0) ) + while ( (i < m_pSwpHints->Count()) + && ( ( ( nAttrStart = *(*m_pSwpHints)[i]->GetStart()) < nEnd ) + || nLen==0 ) ) { pHt = m_pSwpHints->GetTextHint(i); @@ -445,6 +464,12 @@ void SwTxtNode::RstAttr( i++; continue; } + // attributes with content stay in + if ( pHt->HasContent() ) + { + ++i; + continue; + } // Default behavior is to process all attributes: bool bSkipAttr = false;; diff --git a/sw/source/core/undo/SwUndoField.cxx b/sw/source/core/undo/SwUndoField.cxx index 2f04cad7266b..f39d8a724fcc 100644 --- a/sw/source/core/undo/SwUndoField.cxx +++ b/sw/source/core/undo/SwUndoField.cxx @@ -81,7 +81,7 @@ SwUndoFieldFromDoc::~SwUndoFieldFromDoc() void SwUndoFieldFromDoc::UndoImpl(::sw::UndoRedoContext &) { - SwTxtFld * pTxtFld = SwDoc::GetTxtFld(GetPosition()); + SwTxtFld * pTxtFld = SwDoc::GetTxtFldAtPos(GetPosition()); const SwField * pField = pTxtFld->GetFmtFld().GetField(); if (pField) @@ -92,7 +92,7 @@ void SwUndoFieldFromDoc::UndoImpl(::sw::UndoRedoContext &) void SwUndoFieldFromDoc::DoImpl() { - SwTxtFld * pTxtFld = SwDoc::GetTxtFld(GetPosition()); + SwTxtFld * pTxtFld = SwDoc::GetTxtFldAtPos(GetPosition()); const SwField * pField = pTxtFld->GetFmtFld().GetField(); if (pField) @@ -129,7 +129,7 @@ SwUndoFieldFromAPI::~SwUndoFieldFromAPI() void SwUndoFieldFromAPI::UndoImpl(::sw::UndoRedoContext &) { - SwField * pField = SwDoc::GetField(GetPosition()); + SwField * pField = SwDoc::GetFieldAtPos(GetPosition()); if (pField) pField->PutValue(aOldVal, nWhich); @@ -137,7 +137,7 @@ void SwUndoFieldFromAPI::UndoImpl(::sw::UndoRedoContext &) void SwUndoFieldFromAPI::DoImpl() { - SwField * pField = SwDoc::GetField(GetPosition()); + SwField * pField = SwDoc::GetFieldAtPos(GetPosition()); if (pField) pField->PutValue(aNewVal, nWhich); diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index ae10840fba5d..9ce89a1aa869 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -1036,10 +1036,8 @@ SwHistory::~SwHistory() |* *************************************************************************/ -// --> OD 2008-02-27 #refactorlists# - removed <rDoc> void SwHistory::Add( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue, sal_uLong nNodeIdx ) -// <-- { ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); @@ -1289,8 +1287,12 @@ void SwHistory::CopyFmtAttr( const SfxItemSet& rSet, sal_uLong nNodeIdx ) } } -void SwHistory::CopyAttr( SwpHints* pHts, sal_uLong nNodeIdx, - xub_StrLen nStart, xub_StrLen nEnd, bool bFields ) +void SwHistory::CopyAttr( + SwpHints* pHts, + const sal_uLong nNodeIdx, + const xub_StrLen nStart, + const xub_StrLen nEnd, + const bool bCopyFields ) { if( !pHts ) return; @@ -1301,11 +1303,8 @@ void SwHistory::CopyAttr( SwpHints* pHts, sal_uLong nNodeIdx, const xub_StrLen * pEndIdx; for( sal_uInt16 n = 0; n < pHts->Count(); n++ ) { - // BP: nAttrStt muss auch bei !pEndIdx gesetzt werden pHt = pHts->GetTextHint(n); nAttrStt = *pHt->GetStart(); -// JP: ???? wieso nAttrStt >= nEnd -// if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt >= nEnd ) if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt > nEnd ) break; @@ -1314,8 +1313,8 @@ void SwHistory::CopyAttr( SwpHints* pHts, sal_uLong nNodeIdx, switch( pHt->Which() ) { case RES_TXTATR_FIELD: - // keine Felder, .. kopieren ?? - if( !bFields ) + case RES_TXTATR_INPUTFIELD: + if( !bCopyFields ) bNextAttr = sal_True; break; case RES_TXTATR_FLYCNT: @@ -1325,15 +1324,12 @@ void SwHistory::CopyAttr( SwpHints* pHts, sal_uLong nNodeIdx, } if( bNextAttr ) - continue; + continue; // save all attributes that are somehow in this area if ( nStart <= nAttrStt ) { - if ( nEnd > nAttrStt -// JP: ???? wieso nAttrStt >= nEnd -// || (nEnd == nAttrStt && (!pEndIdx || nEnd == pEndIdx->GetIndex())) - ) + if ( nEnd > nAttrStt ) { Add( pHt, nNodeIdx, false ); } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index f26886621b17..c488485816c6 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -239,15 +239,16 @@ void SwUndoInsSection::Join( SwDoc& rDoc, sal_uLong nNode ) ASSERT( pTxtNd, "wo ist mein TextNode?" ); { - RemoveIdxRel( nNode + 1, SwPosition( aIdx, - SwIndex( pTxtNd, pTxtNd->GetTxt().Len() ))); + RemoveIdxRel( + nNode + 1, + SwPosition( aIdx, SwIndex( pTxtNd, pTxtNd->GetTxt().Len() ) ) ); } pTxtNd->JoinNext(); if (m_pHistory.get()) { SwIndex aCntIdx( pTxtNd, 0 ); - pTxtNd->RstAttr( aCntIdx, pTxtNd->Len(), 0, 0, true ); + pTxtNd->RstTxtAttr( aCntIdx, pTxtNd->Len(), 0, 0, true ); } } diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 4d186961ab59..44772872db5f 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2111,16 +2111,13 @@ CHECKTABLE(pTblNd->GetTable()) // evt. noch ueberflussige Attribute loeschen SwIndex aTmpIdx( pTxtNd, nDelPos ); if( pTxtNd->GetpSwpHints() && pTxtNd->GetpSwpHints()->Count() ) - pTxtNd->RstAttr( aTmpIdx, pTxtNd->GetTxt().Len() - - nDelPos + 1 ); + pTxtNd->RstTxtAttr( aTmpIdx, pTxtNd->GetTxt().Len() - nDelPos + 1 ); // das Trennzeichen loeschen pTxtNd->EraseText( aTmpIdx, 1 ); } -// delete pUndo; DUMPDOC( &rDoc, String( "d:\\tmp\\tab_") + String( aNewSttNds.Count() - i ) + String(".db") ) } -// pMoves->Remove( 0, pMoves->Count() ); nIdx = pBox->GetSttIdx(); } else diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 57a7d7313c13..b77e878740a6 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -248,7 +248,7 @@ void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext) pTxtNode->JoinNext(); } // reset all text attributes in the paragraph! - pTxtNode->RstAttr( SwIndex(pTxtNode, 0), pTxtNode->Len(), 0, 0, true ); + pTxtNode->RstTxtAttr( SwIndex(pTxtNode, 0), pTxtNode->Len(), 0, 0, true ); // setze alle Attribute im Node zurueck pTxtNode->ResetAllAttr(); diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index c53a8e6264e9..981e22c431aa 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -49,6 +49,7 @@ #include <ndtxt.hxx> #include <txtrfmrk.hxx> #include <fmtfld.hxx> +#include <txtfld.hxx> #include <docsh.hxx> #include <section.hxx> #include <shellio.hxx> @@ -135,19 +136,19 @@ GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex, /* -----------------16.09.98 12:27------------------- * Lesen spezieller Properties am Cursor * --------------------------------------------------*/ -sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry - , SwPaM& rPam - , Any *pAny - , PropertyState& eState - , const SwTxtNode* pNode ) +sal_Bool getCrsrPropertyValue( + const SfxItemPropertySimpleEntry& rEntry, + SwPaM& rPam, + Any *pAny, + PropertyState& eState, + const SwTxtNode* pNode ) { PropertyState eNewState = PropertyState_DIRECT_VALUE; -// PropertyState_DEFAULT_VALUE -// PropertyState_AMBIGUOUS_VALUE + // PropertyState_DEFAULT_VALUE + // PropertyState_AMBIGUOUS_VALUE sal_Bool bDone = sal_True; switch(rEntry.nWID) { - // --> OD 2008-11-26 #158694# case FN_UNO_PARA_CONT_PREV_SUBTREE: if (pAny) { @@ -168,6 +169,7 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry *pAny <<= bRet; } break; + case FN_UNO_PARA_NUM_STRING: if (pAny) { @@ -185,23 +187,7 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry *pAny <<= OUString(sRet); } break; - // <-- - // --> OD 2008-05-20 #outlinelevel# - no longer needed -// case FN_UNO_PARA_CHAPTER_NUMBERING_LEVEL: -// if (pAny) -// { -// const SwTxtNode * pTmpNode = pNode; - -// if (!pTmpNode) -// pTmpNode = rPam.GetNode()->GetTxtNode(); - -// sal_Int8 nRet = -1; -// if (pTmpNode && pTmpNode->GetOutlineLevel() != NO_NUMBERING) -// nRet = sal::static_int_cast< sal_Int8 >(pTmpNode->GetOutlineLevel()); -// *pAny <<= nRet; -// } -// break; - // <-- + case RES_PARATR_OUTLINELEVEL: //#outlinelevel added by zhaojianwei if (pAny) { @@ -217,9 +203,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry *pAny <<= nRet; } break; //<-end,zhaojianwei + case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: case FN_UNO_PARA_STYLE : - { + { SwFmtColl* pFmt = 0; if(pNode) pFmt = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID @@ -259,66 +246,62 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry *pAny <<= nValue; } break; + case FN_UNO_NUM_LEVEL : case FN_UNO_IS_NUMBER : - // --> OD 2008-07-14 #i91601# case FN_UNO_LIST_ID: - // <-- case FN_NUMBER_NEWSTART: - { - // a multi selection is not considered - const SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode(); - // --> OD 2010-01-13 #b6912256# - if ( pTxtNd && pTxtNd->IsInList() ) - // <-- { - if( pAny ) + // a multi selection is not considered + const SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode(); + if ( pTxtNd && pTxtNd->IsInList() ) { - if(rEntry.nWID == FN_UNO_NUM_LEVEL) - *pAny <<= (sal_Int16)(pTxtNd->GetActualListLevel()); - else if(rEntry.nWID == FN_UNO_IS_NUMBER) - { - sal_Bool bIsNumber = pTxtNd->IsCountedInList(); - pAny->setValue(&bIsNumber, ::getBooleanCppuType()); - } - // --> OD 2008-07-14 #i91601# - else if ( rEntry.nWID == FN_UNO_LIST_ID ) - { - const String sListId = pTxtNd->GetListId(); - *pAny <<= OUString(sListId); - } - // <-- - else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/ + if( pAny ) { - sal_Bool bIsRestart = pTxtNd->IsListRestart(); - pAny->setValue(&bIsRestart, ::getBooleanCppuType()); + if(rEntry.nWID == FN_UNO_NUM_LEVEL) + *pAny <<= (sal_Int16)(pTxtNd->GetActualListLevel()); + else if(rEntry.nWID == FN_UNO_IS_NUMBER) + { + sal_Bool bIsNumber = pTxtNd->IsCountedInList(); + pAny->setValue(&bIsNumber, ::getBooleanCppuType()); + } + else if ( rEntry.nWID == FN_UNO_LIST_ID ) + { + const String sListId = pTxtNd->GetListId(); + *pAny <<= OUString(sListId); + } + else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/ + { + sal_Bool bIsRestart = pTxtNd->IsListRestart(); + pAny->setValue(&bIsRestart, ::getBooleanCppuType()); + } } } - } - else - { - eNewState = PropertyState_DEFAULT_VALUE; - - if( pAny ) + else { - // #i30838# set default values for default properties - if(rEntry.nWID == FN_UNO_NUM_LEVEL) - *pAny <<= static_cast<sal_Int16>( 0 ); - else if(rEntry.nWID == FN_UNO_IS_NUMBER) - *pAny <<= false; - // --> OD 2008-07-14 #i91601# - else if ( rEntry.nWID == FN_UNO_LIST_ID ) + eNewState = PropertyState_DEFAULT_VALUE; + + if( pAny ) { - *pAny <<= OUString(); + // #i30838# set default values for default properties + if(rEntry.nWID == FN_UNO_NUM_LEVEL) + *pAny <<= static_cast<sal_Int16>( 0 ); + else if(rEntry.nWID == FN_UNO_IS_NUMBER) + *pAny <<= false; + // --> OD 2008-07-14 #i91601# + else if ( rEntry.nWID == FN_UNO_LIST_ID ) + { + *pAny <<= OUString(); + } + // <-- + else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/ + *pAny <<= false; } - // <-- - else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/ - *pAny <<= false; } + //PROPERTY_MAYBEVOID! } - //PROPERTY_MAYBEVOID! - } - break; + break; + case FN_UNO_NUM_RULES : if( pAny ) getNumberingProperty(rPam, eNewState, pAny); @@ -328,184 +311,182 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry eNewState = PropertyState_DEFAULT_VALUE; } break; + case FN_UNO_DOCUMENT_INDEX_MARK: - { - ::std::vector<SwTxtAttr *> const marks( - rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt( - rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK)); - if (marks.size()) { - if( pAny ) - { // hmm... can only return 1 here - SwTOXMark & rMark = - static_cast<SwTOXMark &>((*marks.begin())->GetAttr()); - const uno::Reference< text::XDocumentIndexMark > xRef = - SwXDocumentIndexMark::CreateXDocumentIndexMark( + ::std::vector<SwTxtAttr *> const marks( + rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt( + rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK)); + if (marks.size()) + { + if( pAny ) + { // hmm... can only return 1 here + SwTOXMark & rMark = + static_cast<SwTOXMark &>((*marks.begin())->GetAttr()); + const uno::Reference< text::XDocumentIndexMark > xRef = + SwXDocumentIndexMark::CreateXDocumentIndexMark( *rPam.GetDoc(), *const_cast<SwTOXType*>(rMark.GetTOXType()), rMark); - (*pAny) <<= xRef; + (*pAny) <<= xRef; + } } + else + //auch hier - nicht zu unterscheiden + eNewState = PropertyState_DEFAULT_VALUE; } - else - //auch hier - nicht zu unterscheiden - eNewState = PropertyState_DEFAULT_VALUE; - } - break; + break; + case FN_UNO_DOCUMENT_INDEX: - { - const SwTOXBase* pBase = rPam.GetDoc()->GetCurTOX( - *rPam.Start() ); - if( pBase ) { - if( pAny ) + const SwTOXBase* pBase = rPam.GetDoc()->GetCurTOX( + *rPam.Start() ); + if( pBase ) { - const uno::Reference< text::XDocumentIndex > xRef = - SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(), + if( pAny ) + { + const uno::Reference< text::XDocumentIndex > xRef = + SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(), *static_cast<SwTOXBaseSection const*>(pBase)); - (*pAny) <<= xRef; + (*pAny) <<= xRef; + } } + else + eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; + break; + case FN_UNO_TEXT_FIELD: - { - const SwPosition *pPos = rPam.Start(); - const SwTxtNode *pTxtNd = - rPam.GetDoc()->GetNodes()[pPos->nNode.GetIndex()]->GetTxtNode(); - SwTxtAttr *const pTxtAttr = (pTxtNd) - ? pTxtNd->GetTxtAttrForCharAt( - pPos->nContent.GetIndex(), RES_TXTATR_FIELD) - : 0; - if(pTxtAttr) { - if( pAny ) + const SwPosition *pPos = rPam.Start(); + const SwTxtNode *pTxtNd = + rPam.GetDoc()->GetNodes()[pPos->nNode.GetIndex()]->GetTxtNode(); + const SwTxtAttr* pTxtAttr = (pTxtNd) + ? pTxtNd->GetFldTxtAttrAt( pPos->nContent.GetIndex(), true ) + : 0; + if ( pTxtAttr != NULL ) { - SwXTextField* pField = - SwXTextField::CreateSwXTextField( *rPam.GetDoc(),pTxtAttr->GetFmtFld() ); - *pAny <<= uno::Reference< XTextField >( pField ); + if( pAny ) + { + SwXTextField* pField = + SwXTextField::CreateSwXTextField( *rPam.GetDoc(),pTxtAttr->GetFmtFld() ); + *pAny <<= uno::Reference< XTextField >( pField ); + } } + else + eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; -/* laesst sich nicht feststellen -* case FN_UNO_BOOKMARK: - { - if() - { - uno::Reference< XBookmark > xBkm = SwXBookmarks::GetObject(rBkm); - rAny.set(&xBkm, ::getCppuType((const XBookmark*)0)()); - } - } - break;*/ + break; + case FN_UNO_TEXT_TABLE: case FN_UNO_CELL: - { - SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode(); - SwStartNodeType eType = pSttNode->GetStartNodeType(); - if(SwTableBoxStartNode == eType) { - if( pAny ) + SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode(); + SwStartNodeType eType = pSttNode->GetStartNodeType(); + if(SwTableBoxStartNode == eType) { - const SwTableNode* pTblNode = pSttNode->FindTableNode(); - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - //SwTable& rTable = ((SwTableNode*)pSttNode)->GetTable(); - if(FN_UNO_TEXT_TABLE == rEntry.nWID) - { - uno::Reference< XTextTable > xTable = SwXTextTables::GetObject(*pTableFmt); - pAny->setValue(&xTable, ::getCppuType((uno::Reference<XTextTable>*)0)); - } - else + if( pAny ) { - SwTableBox* pBox = pSttNode->GetTblBox(); - uno::Reference< XCell > xCell = SwXCell::CreateXCell(pTableFmt, pBox); - pAny->setValue(&xCell, ::getCppuType((uno::Reference<XCell>*)0)); + const SwTableNode* pTblNode = pSttNode->FindTableNode(); + SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); + //SwTable& rTable = ((SwTableNode*)pSttNode)->GetTable(); + if(FN_UNO_TEXT_TABLE == rEntry.nWID) + { + uno::Reference< XTextTable > xTable = SwXTextTables::GetObject(*pTableFmt); + pAny->setValue(&xTable, ::getCppuType((uno::Reference<XTextTable>*)0)); + } + else + { + SwTableBox* pBox = pSttNode->GetTblBox(); + uno::Reference< XCell > xCell = SwXCell::CreateXCell(pTableFmt, pBox); + pAny->setValue(&xCell, ::getCppuType((uno::Reference<XCell>*)0)); + } } } + else + eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; - case FN_UNO_TEXT_FRAME: - { - SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode(); - SwStartNodeType eType = pSttNode->GetStartNodeType(); + break; - SwFrmFmt* pFmt; - if(eType == SwFlyStartNode && 0 != (pFmt = pSttNode->GetFlyFmt())) + case FN_UNO_TEXT_FRAME: { - if( pAny ) + SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode(); + SwStartNodeType eType = pSttNode->GetStartNodeType(); + + SwFrmFmt* pFmt; + if(eType == SwFlyStartNode && 0 != (pFmt = pSttNode->GetFlyFmt())) { - uno::Reference< XTextFrame > xFrm = (SwXTextFrame*) SwXFrames::GetObject(*pFmt, FLYCNTTYPE_FRM); - pAny->setValue(&xFrm, ::getCppuType((uno::Reference<XTextFrame>*)0)); + if( pAny ) + { + uno::Reference< XTextFrame > xFrm = (SwXTextFrame*) SwXFrames::GetObject(*pFmt, FLYCNTTYPE_FRM); + pAny->setValue(&xFrm, ::getCppuType((uno::Reference<XTextFrame>*)0)); + } } + else + eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; + break; + case FN_UNO_TEXT_SECTION: - { - SwSection* pSect = rPam.GetDoc()->GetCurrSection(*rPam.GetPoint()); - if(pSect) { - if( pAny ) + SwSection* pSect = rPam.GetDoc()->GetCurrSection(*rPam.GetPoint()); + if(pSect) { - uno::Reference< XTextSection > xSect = SwXTextSections::GetObject( *pSect->GetFmt() ); - pAny->setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0) ); + if( pAny ) + { + uno::Reference< XTextSection > xSect = SwXTextSections::GetObject( *pSect->GetFmt() ); + pAny->setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0) ); + } } + else + eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; + break; + case FN_UNO_ENDNOTE: case FN_UNO_FOOTNOTE: - { - SwTxtAttr *const pTxtAttr = - rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN); - if(pTxtAttr) { - const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); - if(rFtn.IsEndNote() == (FN_UNO_ENDNOTE == rEntry.nWID)) + SwTxtAttr *const pTxtAttr = + rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN); + if(pTxtAttr) { - if( pAny ) + const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); + if(rFtn.IsEndNote() == (FN_UNO_ENDNOTE == rEntry.nWID)) { - const uno::Reference< text::XFootnote > xFootnote = - SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn); - *pAny <<= xFootnote; + if( pAny ) + { + const uno::Reference< text::XFootnote > xFootnote = + SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn); + *pAny <<= xFootnote; + } } + else + eNewState = PropertyState_DEFAULT_VALUE; } else eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; + break; + case FN_UNO_REFERENCE_MARK: - { - ::std::vector<SwTxtAttr *> const marks( - rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt( - rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_REFMARK)); - if (marks.size()) { - if( pAny ) - { // hmm... can only return 1 here - const SwFmtRefMark& rRef = (*marks.begin())->GetRefMark(); - uno::Reference< XTextContent > xRef = SwXReferenceMarks::GetObject( rPam.GetDoc(), &rRef ); - pAny->setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0)); + ::std::vector<SwTxtAttr *> const marks( + rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt( + rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_REFMARK)); + if (marks.size()) + { + if( pAny ) + { // hmm... can only return 1 here + const SwFmtRefMark& rRef = (*marks.begin())->GetRefMark(); + uno::Reference< XTextContent > xRef = SwXReferenceMarks::GetObject( rPam.GetDoc(), &rRef ); + pAny->setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0)); + } } + else + eNewState = PropertyState_DEFAULT_VALUE; } - else - eNewState = PropertyState_DEFAULT_VALUE; - } - break; + break; + case FN_UNO_NESTED_TEXT_CONTENT: { uno::Reference<XTextContent> const xRet( @@ -524,6 +505,7 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry } } break; + case FN_UNO_CHARFMT_SEQUENCE: { @@ -586,8 +568,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry eNewState = PropertyState_DEFAULT_VALUE; } break; + case RES_TXTATR_CHARFMT: - // kein break hier! + // kein break hier! default: bDone = sal_False; } if( bDone ) diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index b394acefbba4..ed7363d7fdc7 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1254,8 +1254,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->DeleteAttributes( - RES_TXTATR_FLYCNT, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx ); //create a new one SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode(); DBG_ASSERT( pNd, "Cursor not at TxtNode." ); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index db1b868bf283..fb4953b4feee 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1619,9 +1619,10 @@ void SwXTextField::attachToRange( throw uno::RuntimeException(); sal_uInt16 nInpSubType = sal::static_int_cast< sal_uInt16 >(SW_SERVICE_FIELDTYPE_INPUT_USER == m_nServiceId ? INP_USR : INP_TXT); SwInputField * pTxtField = - new SwInputField((SwInputFieldType*)pFldType, - m_pProps->sPar1, m_pProps->sPar2, - nInpSubType); + new SwInputField( static_cast<SwInputFieldType*>(pFldType), + m_pProps->sPar1, + m_pProps->sPar2, + nInpSubType ); pTxtField->SetHelp(m_pProps->sPar3); pTxtField->SetToolTip(m_pProps->sPar4); @@ -1729,19 +1730,19 @@ void SwXTextField::attachToRange( if(aPam.HasMark()) pDoc->DeleteAndJoin(aPam); - SwXTextCursor const*const pTextCursor( - dynamic_cast<SwXTextCursor*>(pCursor)); - const bool bForceExpandHints( (pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) + SwXTextCursor const*const pTextCursor( dynamic_cast<SwXTextCursor*>(pCursor) ); + const bool bForceExpandHints( + (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() + : false ); + const SetAttrMode nInsertFlags = + (bForceExpandHints) ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND : nsSetAttrMode::SETATTR_DEFAULT; pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD); - + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetFldTxtAttrAt( aPam.GetPoint()->nContent.GetIndex()-1, true ); // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx) if(pTxtAttr) { @@ -1907,7 +1908,7 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An //#to the SwTxtFld if(RES_DBFLD == nWhich && pFmtFld->GetTxtFld()) { - pFmtFld->GetTxtFld()->Expand(); + pFmtFld->GetTxtFld()->ExpandTxtFld(); } //#i100374# changing a document field should set the modify flag diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 59263cf095ca..3720e26eaa9f 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -121,7 +121,7 @@ #include <switerator.hxx> // from fefly1.cxx -extern sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ); +extern sal_Bool lcl_ChkAndSetNewAnchor( SwEditShell& rEditShell, const SwFlyFrm& rFly, SfxItemSet& rSet ); using namespace ::com::sun::star; using ::rtl::OUString; @@ -1043,21 +1043,6 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: } } } - // --> OD 2009-07-13 #i73249# - // Attribute AlternativeText was never published. - // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances -// else if( FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID && eType != FLYCNTTYPE_FRM ) -// { -// const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); -// if(pIdx) -// { -// SwNodeIndex aIdx(*pIdx, 1); -// SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); -// OUString uTemp; -// aValue >>= uTemp; -// pNoTxt->SetAlternateText(uTemp); -// } -// } // New attribute Title else if( FN_UNO_TITLE == pEntry->nWID ) { @@ -1112,7 +1097,8 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: { pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrmFmtSetRange ); pSet->Put( *pItem ); - if ( !::lcl_ChkAndSetNewAnchor( *pFly, *pSet ) ) + if ( pFmt->GetDoc()->GetEditShell() != NULL + && !::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, *pSet ) ) delete pSet, pSet = 0; } } @@ -1388,7 +1374,10 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: if( SFX_ITEM_SET == aSet.GetItemState( RES_ANCHOR, sal_False, &pItem )) { aSet.Put( *pItem ); - ::lcl_ChkAndSetNewAnchor( *pFly, aSet ); + if ( pFmt->GetDoc()->GetEditShell() != NULL ) + { + ::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, aSet ); + } } } } diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 33e09fd8c65f..eb4c251a63ec 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1858,9 +1858,9 @@ throw (uno::RuntimeException) m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); - if(pTxtMark->GetEnd()) + if(pTxtMark->End()) { - aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); + aPam.GetPoint()->nContent = *pTxtMark->End(); } else aPam.GetPoint()->nContent++; @@ -2109,9 +2109,9 @@ SwXDocumentIndexMark::getAnchor() throw (uno::RuntimeException) const SwTxtTOXMark* pTxtMark = m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); - if(pTxtMark->GetEnd()) + if(pTxtMark->End()) { - aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); + aPam.GetPoint()->nContent = *pTxtMark->End(); } else { @@ -2270,9 +2270,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); - if(pTxtMark->GetEnd()) + if(pTxtMark->End()) { - aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); + aPam.GetPoint()->nContent = *pTxtMark->End(); } else { diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 27e546c248a7..da1f6f68f516 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -482,6 +482,32 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider() { SW_PROP_NMID(UNO_NAME_IS_FIELD_USED), FIELD_PROP_IS_FIELD_USED, CPPU_E2T(CPPUTYPE_FLOAT), PropertyAttribute::READONLY, 0},\ { SW_PROP_NMID(UNO_NAME_IS_FIELD_DISPLAYED), FIELD_PROP_IS_FIELD_DISPLAYED, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::READONLY, 0},\ +//IAccessibility2 Implementation 2009----- +#define COMMON_ACCESSIBILITY_TEXT_ATTRIBUTE \ + { SW_PROP_NMID(UNO_NAME_CHAR_BACK_COLOR), RES_CHRATR_BACKGROUND, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE ,MID_BACK_COLOR }, \ + { SW_PROP_NMID(UNO_NAME_CHAR_COLOR), RES_CHRATR_COLOR, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, 0}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_CONTOURED), RES_CHRATR_CONTOUR, CPPU_E2T(CPPUTYPE_BOOLEAN) , PROPERTY_NONE, 0}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_EMPHASIS), RES_CHRATR_EMPHASIS_MARK, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, MID_EMPHASIS}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_ESCAPEMENT), RES_CHRATR_ESCAPEMENT, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, MID_ESC }, \ + { SW_PROP_NMID(UNO_NAME_CHAR_FONT_NAME), RES_CHRATR_FONT, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::MAYBEVOID, MID_FONT_FAMILY_NAME }, \ + { SW_PROP_NMID(UNO_NAME_CHAR_HEIGHT), RES_CHRATR_FONTSIZE , CPPU_E2T(CPPUTYPE_FLOAT), PropertyAttribute::MAYBEVOID, MID_FONTHEIGHT|CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_POSTURE), RES_CHRATR_POSTURE , CPPU_E2T(CPPUTYPE_FONTSLANT), PropertyAttribute::MAYBEVOID, MID_POSTURE}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_SHADOWED), RES_CHRATR_SHADOWED , CPPU_E2T(CPPUTYPE_BOOLEAN) , PROPERTY_NONE, 0}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_STRIKEOUT), RES_CHRATR_CROSSEDOUT, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_UNDERLINE_COLOR), RES_CHRATR_UNDERLINE , CPPU_E2T(CPPUTYPE_INT32), PropertyAttribute::MAYBEVOID, MID_TL_COLOR}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_WEIGHT), RES_CHRATR_WEIGHT , CPPU_E2T(CPPUTYPE_FLOAT), PropertyAttribute::MAYBEVOID, MID_WEIGHT}, \ + { SW_PROP_NMID(UNO_NAME_NUMBERING_LEVEL), RES_PARATR_LIST_LEVEL,CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, 0}, \ + { SW_PROP_NMID(UNO_NAME_CHAR_UNDERLINE), RES_CHRATR_UNDERLINE , CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, MID_TL_STYLE}, \ + { SW_PROP_NMID(UNO_NAME_NUMBERING_RULES), RES_PARATR_NUMRULE,CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_PARA_ADJUST), RES_PARATR_ADJUST, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, MID_PARA_ADJUST}, \ + { SW_PROP_NMID(UNO_NAME_PARA_BOTTOM_MARGIN), RES_UL_SPACE, CPPU_E2T(CPPUTYPE_INT32), PropertyAttribute::MAYBEVOID, MID_LO_MARGIN|CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_PARA_FIRST_LINE_INDENT), RES_LR_SPACE, CPPU_E2T(CPPUTYPE_INT32), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT|CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_PARA_LEFT_MARGIN), RES_LR_SPACE, CPPU_E2T(CPPUTYPE_INT32), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN|CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_PARA_LINE_SPACING), RES_PARATR_LINESPACING, CPPU_E2T(CPPUTYPE_LINESPACE), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_PARA_RIGHT_MARGIN), RES_LR_SPACE, CPPU_E2T(CPPUTYPE_INT32), PropertyAttribute::MAYBEVOID, MID_R_MARGIN|CONVERT_TWIPS}, \ + { SW_PROP_NMID(UNO_NAME_TABSTOPS), RES_PARATR_TABSTOP, CPPU_E2T(CPPUTYPE_SEQTABSTOP), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ + +//-----IAccessibility2 Implementation 2009 const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(sal_uInt16 nPropertyId) { @@ -500,6 +526,18 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s aMapEntriesArr[nPropertyId] = aCharAndParaMap_Impl; } break; + //IAccessibility2 Implementation 2009----- + case PROPERTY_MAP_ACCESSIBILITY_TEXT_ATTRIBUTE: + { + static SfxItemPropertyMapEntry aAccessibilityTextAttrMap_Impl[] = + { + COMMON_ACCESSIBILITY_TEXT_ATTRIBUTE + {0,0,0,0,0,0} + }; + aMapEntriesArr[nPropertyId] = aAccessibilityTextAttrMap_Impl; + } + break; + //-----IAccessibility2 Implementation 2009 case PROPERTY_MAP_PARAGRAPH: { static SfxItemPropertyMapEntry aParagraphMap_Impl[] = diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index edd295269c2b..1cd9b56ee784 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -46,6 +46,8 @@ #include <unoredline.hxx> #include <unofield.hxx> #include <unometa.hxx> +#include <fmtfld.hxx> +#include <fldbas.hxx> #include <fmtmeta.hxx> #include <fmtanchr.hxx> #include <fmtrfmrk.hxx> @@ -438,7 +440,7 @@ lcl_CreateRefMarkPortion( { pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_START); pPortion->SetRefMark(xContent); - pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); + pPortion->SetCollapsed(rAttr.End() ? false : true); } else { @@ -459,7 +461,7 @@ lcl_InsertRubyPortion( SwXTextPortion* pPortion = new SwXTextPortion(pUnoCrsr, static_cast<const SwTxtRuby&>(rAttr), xParent, bEnd); rPortions.push_back(pPortion); - pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); + pPortion->SetCollapsed(rAttr.End() ? false : true); } //----------------------------------------------------------------------------- @@ -760,34 +762,56 @@ lcl_ExportHints( SwXTextField::CreateSwXTextField(*pDoc, pAttr->GetFmtFld()); pPortion->SetTextField(xField); } - break; - case RES_TXTATR_FLYCNT : + break; + + case RES_TXTATR_INPUTFIELD: if(!bRightMoveForbidden) { - pUnoCrsr->Right(1,CRSR_SKIP_CHARS,sal_False,sal_False); + + pUnoCrsr->Right( + pAttr->GetFmtFld().GetField()->GetPar1().Len() + 2, + CRSR_SKIP_CHARS, + sal_False, + sal_False ); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) - break; // Robust #i81708 content in covered cells - pUnoCrsr->Exchange(); - xRef = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_FRAME); + break; + SwXTextPortion* pPortion = + new SwXTextPortion( pUnoCrsr, xParent, PORTION_FIELD); + xRef = pPortion; + Reference<XTextField> xField = + SwXTextField::CreateSwXTextField(*pDoc, pAttr->GetFmtFld()); + pPortion->SetTextField(xField); } - break; - case RES_TXTATR_FTN : - { + break; + + case RES_TXTATR_FLYCNT: if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,sal_False,sal_False); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) - break; - SwXTextPortion* pPortion; - xRef = pPortion = new SwXTextPortion( + break; // Robust #i81708 content in covered cells + pUnoCrsr->Exchange(); + xRef = new SwXTextPortion( pUnoCrsr, xParent, PORTION_FRAME); + } + break; + + case RES_TXTATR_FTN: + { + if(!bRightMoveForbidden) + { + pUnoCrsr->Right(1,CRSR_SKIP_CHARS,sal_False,sal_False); + if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) + break; + SwXTextPortion* pPortion; + xRef = pPortion = new SwXTextPortion( pUnoCrsr, xParent, PORTION_FOOTNOTE); - Reference<XFootnote> xContent = - SwXFootnotes::GetObject(*pDoc, pAttr->GetFtn()); - pPortion->SetFootnote(xContent); + Reference<XFootnote> xContent = + SwXFootnotes::GetObject(*pDoc, pAttr->GetFtn()); + pPortion->SetFootnote(xContent); + } } - } - break; + break; + case RES_TXTATR_TOXMARK: case RES_TXTATR_REFMARK: { diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 13e66476bda0..369076f42b4c 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -356,8 +356,8 @@ SwXReferenceMark::getAnchor() throw (uno::RuntimeException) &m_pImpl->m_pDoc->GetNodes())) { SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); - const ::std::auto_ptr<SwPaM> pPam( (pTxtMark->GetEnd()) - ? new SwPaM( rTxtNode, *pTxtMark->GetEnd(), + const ::std::auto_ptr<SwPaM> pPam( (pTxtMark->End()) + ? new SwPaM( rTxtNode, *pTxtMark->End(), rTxtNode, *pTxtMark->GetStart()) : new SwPaM( rTxtNode, *pTxtMark->GetStart()) ); @@ -387,9 +387,10 @@ void SAL_CALL SwXReferenceMark::dispose() throw (uno::RuntimeException) &m_pImpl->m_pDoc->GetNodes())) { SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); - xub_StrLen nStt = *pTxtMark->GetStart(), - nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() - : nStt + 1; + const xub_StrLen nStt = *pTxtMark->GetStart(); + const xub_StrLen nEnd = pTxtMark->End() + ? *pTxtMark->End() + : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); m_pImpl->m_pDoc->DeleteAndJoin( aPam ); @@ -477,9 +478,10 @@ throw (uno::RuntimeException) &m_pImpl->m_pDoc->GetNodes())) { SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); - xub_StrLen nStt = *pTxtMark->GetStart(), - nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() - : nStt + 1; + const xub_StrLen nStt = *pTxtMark->GetStart(); + const xub_StrLen nEnd = pTxtMark->End() + ? *pTxtMark->End() + : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); // deletes the m_pImpl->m_pDoc member in the SwXReferenceMark! @@ -873,7 +875,7 @@ bool SwXMeta::SetContentRange( { // rStart points at the first position _within_ the meta! rStart = *pTxtAttr->GetStart() + 1; - rEnd = *pTxtAttr->GetEnd(); + rEnd = *pTxtAttr->End(); return true; } } diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index 323b0a75fbe8..519cbb04e3b9 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -446,6 +446,24 @@ void SwViewImp::MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj, } while ( pTmp != pVSh ); } +//IAccessibility2 Implementation 2009----- +void SwViewImp::FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage) +{ + if( IsAccessible() ) + GetAccessibleMap().FirePageChangeEvent( nOldPage, nNewPage); +} + +void SwViewImp::FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection) +{ + if( IsAccessible() ) + GetAccessibleMap().FireSectionChangeEvent(nOldSection, nNewSection); +} +void SwViewImp::FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn) +{ + if( IsAccessible() ) + GetAccessibleMap().FireColumnChangeEvent(nOldColumn, nNewColumn); +} +//-----IAccessibility2 Implementation 2009 void SwViewImp::InvalidateAccessibleFrmContent( const SwFrm *pFrm ) { ASSERT( pFrm->IsAccessibleFrm(), "frame is not accessible" ); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 14ee0f4a9133..1447555d2a62 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -662,6 +662,7 @@ sal_Bool ViewShell::IsAnyFieldInDoc() const const SfxPoolItem* pItem; sal_uInt32 nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD ); for( sal_uInt32 n = 0; n < nMaxItems; ++n ) + { if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n ))) { const SwFmtFld* pFmtFld = (SwFmtFld*)pItem; @@ -674,6 +675,22 @@ sal_Bool ViewShell::IsAnyFieldInDoc() const return sal_True; } } + } + + nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD ); + for( sal_uInt32 n = 0; n < nMaxItems; ++n ) + { + if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n ))) + { + const SwFmtFld* pFmtFld = (SwFmtFld*)pItem; + const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld(); + if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) + { + return sal_True; + } + } + } + return sal_False; } |