sw/source/core/access/accpara.cxx          |   30 ++--
 sw/source/core/access/accpara.hxx          |    4 
 sw/source/core/access/accportions.cxx      |  181 ++++++++++++++---------------
 sw/source/core/access/accportions.hxx      |   57 ++++-----
 sw/source/core/access/textmarkuphelper.cxx |    2 
 sw/source/core/inc/SwPortionHandler.hxx    |    2 
 sw/source/core/layout/wsfrm.cxx            |    1 
 sw/source/core/text/porfld.cxx             |    4 
 sw/source/core/text/txtfrm.cxx             |    2 
 9 files changed, 137 insertions(+), 146 deletions(-)

New commits:
commit 09c6c033b9a29febcc3340ea4a19e42f9bd8c48c
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Fri Oct 5 18:50:53 2018 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Fri Oct 5 18:56:52 2018 +0200

    sw_redlinehide_3: stop SwAccessibleParagraph listening at SwTextNode
    
    The SwAccessibleParagraph is a client of SwTextNode, just so that it can
    dispose its mpParaChangeTrackInfo on any and all editing operations.
    
    This won't work with merged paragraphs, but on the other hand it's not
    necessary with merged paragraphs because the
    initChangeTrackTextMarkupLists() does nothing if IsHideRedlines().
    
    However there is the problem that the node and the frame might become
    mis-matched if the frame is "moved around", so to avoid problems due to
    that, listen on the SwTextFrame instead of the node, and have the
    SwTextFrame relay any events it gets.
    
    Though the frame is only SwClient, this is now possible thanks to
    the SfxBroadcaster on the SwFrame class, so convert to SfxListener;
    also the Accessible lifetime is tied to SwTextFrame anyway.
    
    In UnHideRedlines(), send a dummy event too so that toggling Show/Hide
    disposes the mpParaChangeTrackInfo too, which previously happened
    as a side effect of moving the redlines around in the nodes-array.
    
    Change-Id: I4e5a7107cb55d408266ee42463f9fa2a4a8b721b

diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index 16b06ef7dc72..c3fde94a1b3a 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -533,8 +533,7 @@ void SwAccessibleParagraph::InvalidateFocus_()
 SwAccessibleParagraph::SwAccessibleParagraph(
         std::shared_ptr<SwAccessibleMap> const& pInitMap,
         const SwTextFrame& rTextFrame )
-    : SwClient( const_cast<SwTextNode*>(rTextFrame.GetTextNode()) ) // 
#i108125#
-    , SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame )
+    : SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame )
     , m_sDesc()
     , m_nOldCaretPos( -1 )
     , m_bIsHeading( false )
@@ -544,6 +543,7 @@ SwAccessibleParagraph::SwAccessibleParagraph(
     , mpParaChangeTrackInfo( new SwParaChangeTrackingInfo( rTextFrame ) ) // 
#i108125#
     , m_bLastHasSelection(false)  //To add TEXT_SELECTION_CHANGED event
 {
+    StartListening(const_cast<SwTextFrame&>(rTextFrame));
     m_bIsHeading = IsHeading();
     //Get the real heading level, Heading1 ~ Heading10
     m_nHeadingLevel = GetRealHeadingLevel();
@@ -3517,11 +3517,9 @@ sal_Int32 SAL_CALL 
SwAccessibleParagraph::getNumberOfLineWithCaret()
 }
 
 // #i108125#
-void SwAccessibleParagraph::Modify( const SfxPoolItem* pOld, const 
SfxPoolItem* /*pNew*/ )
+void SwAccessibleParagraph::Notify(SfxBroadcaster&, const SfxHint&)
 {
     mpParaChangeTrackInfo->reset();
-
-    CheckRegistration( pOld );
 }
 
 bool SwAccessibleParagraph::GetSelectionAtIndex(
diff --git a/sw/source/core/access/accpara.hxx 
b/sw/source/core/access/accpara.hxx
index 3179edacd458..ef5234f46ae8 100644
--- a/sw/source/core/access/accpara.hxx
+++ b/sw/source/core/access/accpara.hxx
@@ -53,7 +53,7 @@ typedef std::unordered_map< OUString,
                          css::beans::PropertyValue > tAccParaPropValMap;
 
 class SwAccessibleParagraph :
-        public SwClient, // #i108125#
+        public SfxListener,
         public SwAccessibleContext,
         public css::accessibility::XAccessibleEditableText,
         public css::accessibility::XAccessibleSelection,
@@ -225,7 +225,7 @@ protected:
                               sal_Int32 nPos,
                               sal_Int16 aTextType );
 
-    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew) 
override;
+    virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
 
 public:
 
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 36ae515e767a..14ada1f0d5d4 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4341,6 +4341,7 @@ static void UnHideRedlines(SwRootFrame & rLayout,
                         pFrame->SetMergedPara(nullptr);
                     }
                 }
+                pFrame->Broadcast(SfxHint()); // notify SwAccessibleParagraph
             }
         }
         if (!rNode.IsCreateFrameWhenHidingRedlines())
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 86fa875516a4..af0422aa09ea 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1828,6 +1828,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, 
SfxHint const& rHint)
         }
     }
 
+    Broadcast(SfxHint()); // notify SwAccessibleParagraph
+
     // while locked ignore all modifications
     if( IsLocked() )
         return;
commit a4f4ef0cd7a9dabc770d0307f8a854420abf0f8c
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Fri Oct 5 16:06:49 2018 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Fri Oct 5 16:48:19 2018 +0200

    sw_redlinehide_3: convert SwAccessiblePortionData
    
    Change-Id: I0f6d2c09bc06a6de1b46627b205f3c7edd9e594c

diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index 8015d832d3f5..16b06ef7dc72 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -578,7 +578,7 @@ void SwAccessibleParagraph::UpdatePortionData()
 
     // build new portion data
     m_pPortionData.reset( new SwAccessiblePortionData(
-        pFrame->GetTextNode(), GetMap()->GetShell()->GetViewOptions() ) );
+        pFrame, GetMap()->GetShell()->GetViewOptions()) );
     pFrame->VisitPortions( *m_pPortionData );
 
     OSL_ENSURE( m_pPortionData != nullptr, "UpdatePortionData() failed" );
@@ -624,9 +624,9 @@ SwXTextPortion* SwAccessibleParagraph::CreateUnoPortion(
                 IsValidRange(nStartIndex, nEndIndex, GetString().getLength()),
                 "please check parameters before calling this method" );
 
-    const sal_Int32 nStart = GetPortionData().GetModelPosition( nStartIndex );
+    const sal_Int32 nStart = GetPortionData().GetCoreViewPosition(nStartIndex);
     const sal_Int32 nEnd = (nEndIndex == -1) ? (nStart + 1) :
-                        GetPortionData().GetModelPosition( nEndIndex );
+                        GetPortionData().GetCoreViewPosition(nEndIndex);
 
     // create UNO cursor
     SwTextNode* pTextNode = const_cast<SwTextNode*>( GetTextNode() );
@@ -741,7 +741,7 @@ bool SwAccessibleParagraph::GetWordBoundary(
     assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
 
     // get locale for this position
-    const sal_Int32 nModelPos = GetPortionData().GetModelPosition( nPos );
+    const sal_Int32 nModelPos = GetPortionData().GetCoreViewPosition(nPos);
     lang::Locale aLocale = g_pBreakIt->GetLocale(
                           GetTextNode()->GetLang( nModelPos ) );
 
@@ -808,7 +808,7 @@ bool SwAccessibleParagraph::GetGlyphBoundary(
     assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
 
     // get locale for this position
-    const sal_Int32 nModelPos = GetPortionData().GetModelPosition( nPos );
+    const sal_Int32 nModelPos = GetPortionData().GetCoreViewPosition(nPos);
     lang::Locale aLocale = g_pBreakIt->GetLocale(
                           GetTextNode()->GetLang( nModelPos ) );
 
@@ -1263,7 +1263,7 @@ sal_Bool SAL_CALL 
SwAccessibleParagraph::setCaretPosition( sal_Int32 nIndex )
     {
         // create pam for selection
         SwTextNode* pNode = const_cast<SwTextNode*>( GetTextNode() );
-        SwIndex aIndex( pNode, GetPortionData().GetModelPosition(nIndex));
+        SwIndex aIndex(pNode, GetPortionData().GetCoreViewPosition(nIndex));
         SwPosition aStartPos( *pNode, aIndex );
         SwPaM aPaM( aStartPos );
 
@@ -2474,12 +2474,12 @@ sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 
nStartIndex, sal_Int32 n
     {
         // create pam for selection
         SwTextNode* pNode = const_cast<SwTextNode*>( GetTextNode() );
-        SwIndex aIndex( pNode, GetPortionData().GetModelPosition(nStartIndex));
+        SwIndex aIndex(pNode, 
GetPortionData().GetCoreViewPosition(nStartIndex));
         SwPosition aStartPos( *pNode, aIndex );
         SwPaM aPaM( aStartPos );
         aPaM.SetMark();
         aPaM.GetPoint()->nContent =
-            GetPortionData().GetModelPosition(nEndIndex);
+            GetPortionData().GetCoreViewPosition(nEndIndex);
 
         // set PaM at cursor shell
         bRet = Select( aPaM );
@@ -3116,7 +3116,7 @@ sal_Int32 SAL_CALL 
SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharInde
         const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( 
GetFrame() );
         SwHyperlinkIter_Impl aHIter( pTextFrame );
 
-        const sal_Int32 nIdx = GetPortionData().GetModelPosition( nCharIndex );
+        const sal_Int32 nIdx = 
GetPortionData().GetCoreViewPosition(nCharIndex);
         sal_Int32 nPos = 0;
         const SwTextAttr *pHt = aHIter.next();
         while( pHt && !(nIdx >= pHt->GetStart() && nIdx < *pHt->GetAnyEnd()) )
@@ -3334,8 +3334,8 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::addSelection( 
sal_Int32, sal_Int32 sta
         pCursorShell->StartAction();
         SwPaM* aPaM = pCursorShell->CreateCursor();
         aPaM->SetMark();
-        aPaM->GetPoint()->nContent = 
GetPortionData().GetModelPosition(startOffset);
-        aPaM->GetMark()->nContent =  
GetPortionData().GetModelPosition(endOffset);
+        aPaM->GetPoint()->nContent = 
GetPortionData().GetCoreViewPosition(startOffset);
+        aPaM->GetMark()->nContent =  
GetPortionData().GetCoreViewPosition(endOffset);
         pCursorShell->EndAction();
     }
 
diff --git a/sw/source/core/access/accportions.cxx 
b/sw/source/core/access/accportions.cxx
index 5aba09456587..0a52bcde7784 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -29,6 +29,7 @@
 // for GetWordBoundary(...), GetSentenceBoundary(...):
 #include <breakit.hxx>
 #include <ndtxt.hxx>
+#include <txtfrm.hxx>
 
 // for FillSpecialPos(...)
 #include <crstate.hxx>
@@ -62,28 +63,37 @@ using i18n::Boundary;
 #define PORATTR_GRAY        4
 #define PORATTR_TERM        128
 
+/// returns the index of the first position whose value is smaller
+/// or equal, and whose following value is equal or larger
+template<typename T>
+size_t FindBreak(const std::vector<T>& rPositions, T nValue);
+
+/// like FindBreak, but finds the last equal or larger position
+template<typename T>
+size_t FindLastBreak(const std::vector<T>& rPositions, T nValue);
+
+
 SwAccessiblePortionData::SwAccessiblePortionData(
-    const SwTextNode* pTextNd,
+    const SwTextFrame *const pTextFrame,
     const SwViewOption* pViewOpt ) :
     SwPortionHandler(),
-    m_pTextNode( pTextNd ),
+    m_pTextFrame(pTextFrame),
     m_aBuffer(),
-    m_nModelPosition( 0 ),
+    m_nViewPosition( 0 ),
     m_pViewOptions( pViewOpt ),
     m_sAccessibleString(),
     m_aLineBreaks(),
-    m_aModelPositions(),
     m_aAccessiblePositions(),
     m_aFieldPosition(),
     m_aPortionAttrs(),
     m_nBeforePortions( 0 ),
     m_bFinished( false )
 {
-    OSL_ENSURE( m_pTextNode != nullptr, "Text node is needed!" );
+    OSL_ENSURE( m_pTextFrame != nullptr, "Need SwTextFrame!" );
 
     // reserve some space to reduce memory allocations
     m_aLineBreaks.reserve( 5 );
-    m_aModelPositions.reserve( 10 );
+    m_ViewPositions.reserve( 10 );
     m_aAccessiblePositions.reserve( 10 );
 
     // always include 'first' line-break position
@@ -97,34 +107,34 @@ SwAccessiblePortionData::~SwAccessiblePortionData()
 void SwAccessiblePortionData::Text(TextFrameIndex const nLength,
         sal_uInt16 nType, sal_Int32 /*nHeight*/, sal_Int32 /*nWidth*/)
 {
-    OSL_ENSURE( (m_nModelPosition + nLength) <= 
m_pTextNode->GetText().getLength(),
+    OSL_ENSURE((m_nViewPosition + nLength) <= 
TextFrameIndex(m_pTextFrame->GetText().getLength()),
                 "portion exceeds model string!" );
 
     OSL_ENSURE( !m_bFinished, "We are already done!" );
 
     // ignore zero-length portions
-    if( nLength == 0 )
+    if (nLength == TextFrameIndex(0))
         return;
 
     // store 'old' positions
-    m_aModelPositions.push_back( m_nModelPosition );
+    m_ViewPositions.push_back( m_nViewPosition );
     m_aAccessiblePositions.push_back( m_aBuffer.getLength() );
 
     // store portion attributes
     sal_uInt8 nAttr = IsGrayPortionType(nType) ? PORATTR_GRAY : 0;
     m_aPortionAttrs.push_back( nAttr );
 
-    // update buffer + nModelPosition
-    m_aBuffer.appendCopy( m_pTextNode->GetText(), m_nModelPosition, nLength );
-    m_nModelPosition += nLength;
+    // update buffer + nViewPosition
+    m_aBuffer.appendCopy(m_pTextFrame->GetText(), sal_Int32(m_nViewPosition), 
sal_Int32(nLength));
+    m_nViewPosition += nLength;
 }
 
 void SwAccessiblePortionData::Special(
     TextFrameIndex const nLength, const OUString& rText, sal_uInt16 nType,
     sal_Int32 /*nHeight*/, sal_Int32 /*nWidth*/, const SwFont* /*pFont*/)
 {
-    OSL_ENSURE( m_nModelPosition >= 0, "illegal position" );
-    OSL_ENSURE( (m_nModelPosition + nLength) <= 
m_pTextNode->GetText().getLength(),
+    OSL_ENSURE(m_nViewPosition >= TextFrameIndex(0), "illegal position");
+    OSL_ENSURE((m_nViewPosition + nLength) <= 
TextFrameIndex(m_pTextFrame->GetText().getLength()),
                 "portion exceeds model string!" );
 
     OSL_ENSURE( !m_bFinished, "We are already done!" );
@@ -171,7 +181,7 @@ void SwAccessiblePortionData::Special(
         // #i111768# - apply patch from kstribley:
         // Include the control characters.
         case POR_CONTROLCHAR:
-            sDisplay = rText + OUStringLiteral1( 
m_pTextNode->GetText()[m_nModelPosition] );
+            sDisplay = rText + 
OUStringLiteral1(m_pTextFrame->GetText()[sal_Int32(m_nViewPosition)]);
             break;
         default:
             sDisplay = rText;
@@ -179,28 +189,28 @@ void SwAccessiblePortionData::Special(
     }
 
     // ignore zero/zero portions (except for terminators)
-    if( (nLength == 0) && (sDisplay.getLength() == 0) && (nType != 
POR_TERMINATE) )
+    if ((nLength == TextFrameIndex(0)) && (sDisplay.getLength() == 0) && 
(nType != POR_TERMINATE))
         return;
 
     // special treatment for zero length portion at the beginning:
     // count as 'before' portion
-    if( ( nLength == 0 ) && ( m_nModelPosition == 0 ) )
+    if ((nLength == TextFrameIndex(0)) && (m_nViewPosition == 
TextFrameIndex(0)))
         m_nBeforePortions++;
 
     // store the 'old' positions
-    m_aModelPositions.push_back( m_nModelPosition );
+    m_ViewPositions.push_back( m_nViewPosition );
     m_aAccessiblePositions.push_back( m_aBuffer.getLength() );
 
     // store portion attributes
     sal_uInt8 nAttr = PORATTR_SPECIAL;
     if( IsGrayPortionType(nType) )      nAttr |= PORATTR_GRAY;
-    if( nLength == 0 )                  nAttr |= PORATTR_READONLY;
+    if (nLength == TextFrameIndex(0))   nAttr |= PORATTR_READONLY;
     if( nType == POR_TERMINATE )        nAttr |= PORATTR_TERM;
     m_aPortionAttrs.push_back( nAttr );
 
-    // update buffer + nModelPosition
+    // update buffer + nViewPosition
     m_aBuffer.append( sDisplay );
-    m_nModelPosition += nLength;
+    m_nViewPosition += nLength;
 }
 
 void SwAccessiblePortionData::LineBreak(sal_Int32 /*nWidth*/)
@@ -213,11 +223,11 @@ void SwAccessiblePortionData::LineBreak(sal_Int32 
/*nWidth*/)
 void SwAccessiblePortionData::Skip(TextFrameIndex const nLength)
 {
     OSL_ENSURE( !m_bFinished, "We are already done!" );
-    OSL_ENSURE( m_aModelPositions.empty(), "Never Skip() after portions" );
-    OSL_ENSURE( nLength <= m_pTextNode->GetText().getLength(),
+    OSL_ENSURE( m_ViewPositions.empty(), "Never Skip() after portions" );
+    OSL_ENSURE(nLength <= TextFrameIndex(m_pTextFrame->GetText().getLength()),
             "skip exceeds model string!" );
 
-    m_nModelPosition += nLength;
+    m_nViewPosition += nLength;
 }
 
 void SwAccessiblePortionData::Finish()
@@ -227,8 +237,8 @@ void SwAccessiblePortionData::Finish()
     // include terminator values: always include two 'last character'
     // markers in the position arrays to make sure we always find one
     // position before the end
-    Special( 0, OUString(), POR_TERMINATE );
-    Special( 0, OUString(), POR_TERMINATE );
+    Special( TextFrameIndex(0), OUString(), POR_TERMINATE );
+    Special( TextFrameIndex(0), OUString(), POR_TERMINATE );
     LineBreak(0);
     LineBreak(0);
 
@@ -339,7 +349,7 @@ void SwAccessiblePortionData::GetLastLineBoundary(
     FillBoundary( rBound, m_aLineBreaks, nBreaks <= 3 ? 0 : nBreaks-4 );
 }
 
-sal_Int32 SwAccessiblePortionData::GetModelPosition( sal_Int32 nPos ) const
+TextFrameIndex SwAccessiblePortionData::GetCoreViewPosition(sal_Int32 const 
nPos) const
 {
     OSL_ENSURE( nPos >= 0, "illegal position" );
     OSL_ENSURE( nPos <= m_sAccessibleString.getLength(), "illegal position" );
@@ -347,39 +357,38 @@ sal_Int32 SwAccessiblePortionData::GetModelPosition( 
sal_Int32 nPos ) const
     // find the portion number
     size_t nPortionNo = FindBreak( m_aAccessiblePositions, nPos );
 
-    // get model portion size
-    sal_Int32 nStartPos = m_aModelPositions[nPortionNo];
+    // get core view portion size
+    TextFrameIndex nStartPos = m_ViewPositions[nPortionNo];
 
     // if it's a non-special portion, move into the portion, else
     // return the portion start
     if( ! IsSpecialPortion( nPortionNo ) )
     {
         // 'wide' portions have to be of the same width
-        OSL_ENSURE( ( m_aModelPositions[nPortionNo+1] - nStartPos ) ==
+        OSL_ENSURE( sal_Int32(m_ViewPositions[nPortionNo+1] - nStartPos) ==
                     ( m_aAccessiblePositions[nPortionNo+1] -
                       m_aAccessiblePositions[nPortionNo] ),
                     "accessibility portion disagrees with text model" );
 
-        nStartPos += nPos - m_aAccessiblePositions[nPortionNo];
+        nStartPos += TextFrameIndex(nPos - m_aAccessiblePositions[nPortionNo]);
     }
     // else: return nStartPos unmodified
 
-    OSL_ENSURE( nStartPos >= 0, "There's something weird in number of 
characters of SwTextNode" );
+    OSL_ENSURE(nStartPos >= TextFrameIndex(0), "There's something weird in 
number of characters of SwTextFrame");
     return nStartPos;
 }
 
 void SwAccessiblePortionData::FillBoundary(
     Boundary& rBound,
-    const Positions_t& rPositions,
+    const AccessiblePositions& rPositions,
     size_t nPos )
 {
     rBound.startPos = rPositions[nPos];
     rBound.endPos = rPositions[nPos+1];
 }
 
-size_t SwAccessiblePortionData::FindBreak(
-    const Positions_t& rPositions,
-    sal_Int32 nValue )
+template<typename T>
+size_t FindBreak(const std::vector<T>& rPositions, T const nValue)
 {
     OSL_ENSURE( rPositions.size() >= 2, "need min + max value" );
     OSL_ENSURE( rPositions[0] <= nValue, "need min value" );
@@ -434,9 +443,8 @@ size_t SwAccessiblePortionData::FindBreak(
     return nMin;
 }
 
-size_t SwAccessiblePortionData::FindLastBreak(
-    const Positions_t& rPositions,
-    sal_Int32 nValue )
+template<typename T>
+size_t FindLastBreak(const std::vector<T>& rPositions, T const nValue)
 {
     size_t nResult = FindBreak( rPositions, nValue );
 
@@ -462,7 +470,7 @@ void SwAccessiblePortionData::GetSentenceBoundary(
     {
         assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
 
-        m_pSentences.reset( new Positions_t );
+        m_pSentences.reset(new AccessiblePositions);
         m_pSentences->reserve(10);
 
         // use xBreak->endOfSentence to iterate over all words; store
@@ -473,11 +481,11 @@ void SwAccessiblePortionData::GetSentenceBoundary(
         {
             m_pSentences->push_back( nCurrent );
 
-            const sal_Int32 nModelPos = GetModelPosition( nCurrent );
+            const TextFrameIndex nFramePos = GetCoreViewPosition(nCurrent);
 
             sal_Int32 nNew = g_pBreakIt->GetBreakIter()->endOfSentence(
                 m_sAccessibleString, nCurrent,
-                g_pBreakIt->GetLocale(m_pTextNode->GetLang(nModelPos)) ) + 1;
+                g_pBreakIt->GetLocale(m_pTextFrame->GetLangOfChar(nFramePos, 
0, true))) + 1;
 
             if( (nNew < 0) && (nNew > nLength) )
                 nNew = nLength;
@@ -500,37 +508,37 @@ void SwAccessiblePortionData::GetAttributeBoundary(
     Boundary& rBound,
     sal_Int32 nPos) const
 {
-    OSL_ENSURE( m_pTextNode != nullptr, "Need SwTextNode!" );
+    OSL_ENSURE( m_pTextFrame != nullptr, "Need SwTextNode!" );
 
     // attribute boundaries can only occur on portion boundaries
     FillBoundary( rBound, m_aAccessiblePositions,
                   FindBreak( m_aAccessiblePositions, nPos ) );
 }
 
-sal_Int32 SwAccessiblePortionData::GetAccessiblePosition( sal_Int32 nPos ) 
const
+sal_Int32 SwAccessiblePortionData::GetAccessiblePosition(TextFrameIndex const 
nPos) const
 {
-    OSL_ENSURE( nPos <= m_pTextNode->GetText().getLength(), "illegal position" 
);
+    OSL_ENSURE(nPos <= TextFrameIndex(m_pTextFrame->GetText().getLength()), 
"illegal position");
 
     // find the portion number
     // #i70538# - consider "empty" model portions - e.g. number portion
-    size_t nPortionNo = FindLastBreak( m_aModelPositions, nPos );
+    size_t nPortionNo = FindLastBreak( m_ViewPositions, nPos );
 
     sal_Int32 nRet = m_aAccessiblePositions[nPortionNo];
 
-    // if the model portion has more than one position, go into it;
+    // if the view portion has more than one position, go into it;
     // else return that position
-    sal_Int32 nStartPos = m_aModelPositions[nPortionNo];
-    sal_Int32 nEndPos = m_aModelPositions[nPortionNo+1];
-    if( (nEndPos - nStartPos) > 1 )
+    TextFrameIndex nStartPos = m_ViewPositions[nPortionNo];
+    TextFrameIndex nEndPos = m_ViewPositions[nPortionNo+1];
+    if ((nEndPos - nStartPos) > TextFrameIndex(1))
     {
         // 'wide' portions have to be of the same width
-        OSL_ENSURE( ( nEndPos - nStartPos ) ==
+        OSL_ENSURE( sal_Int32(nEndPos - nStartPos) ==
                     ( m_aAccessiblePositions[nPortionNo+1] -
                       m_aAccessiblePositions[nPortionNo] ),
                     "accessibility portion disagrees with text model" );
 
-        sal_Int32 nWithinPortion = nPos - m_aModelPositions[nPortionNo];
-        nRet += nWithinPortion;
+        TextFrameIndex nWithinPortion = nPos - m_ViewPositions[nPortionNo];
+        nRet += sal_Int32(nWithinPortion);
     }
     // else: return nRet unmodified
 
@@ -539,7 +547,7 @@ sal_Int32 SwAccessiblePortionData::GetAccessiblePosition( 
sal_Int32 nPos ) const
     return nRet;
 }
 
-sal_Int32 SwAccessiblePortionData::FillSpecialPos(
+TextFrameIndex SwAccessiblePortionData::FillSpecialPos(
     sal_Int32 nPos,
     SwSpecialPos& rPos,
     SwSpecialPos*& rpPos ) const
@@ -548,7 +556,7 @@ sal_Int32 SwAccessiblePortionData::FillSpecialPos(
 
     SwSPExtendRange nExtend(SwSPExtendRange::NONE);
     sal_Int32 nRefPos(0);
-    sal_Int32 nModelPos(0);
+    TextFrameIndex nCorePos(0);
 
     if( nPortionNo < m_nBeforePortions )
     {
@@ -557,28 +565,28 @@ sal_Int32 SwAccessiblePortionData::FillSpecialPos(
     }
     else
     {
-        sal_Int32 nModelEndPos = m_aModelPositions[nPortionNo+1];
-        nModelPos = m_aModelPositions[nPortionNo];
+        TextFrameIndex nCoreEndPos = m_ViewPositions[nPortionNo+1];
+        nCorePos = m_ViewPositions[nPortionNo];
 
         // skip backwards over zero-length portions, since GetCharRect()
         // counts all model-zero-length portions as belonging to the
         // previous portion
         size_t nCorePortionNo = nPortionNo;
-        while( nModelPos == nModelEndPos )
+        while (nCorePos == nCoreEndPos)
         {
             nCorePortionNo--;
-            nModelEndPos = nModelPos;
-            nModelPos = m_aModelPositions[nCorePortionNo];
+            nCoreEndPos = nCorePos;
+            nCorePos = m_ViewPositions[nCorePortionNo];
 
-            OSL_ENSURE( nModelPos >= 0, "Can't happen." );
+            OSL_ENSURE( nCorePos >= TextFrameIndex(0), "Can't happen." );
             OSL_ENSURE( nCorePortionNo >= m_nBeforePortions, "Can't happen." );
         }
-        OSL_ENSURE( nModelPos != nModelEndPos,
+        OSL_ENSURE( nCorePos != nCoreEndPos,
                     "portion with core-representation expected" );
 
         // if we have anything except plain text, compute nExtend + nRefPos
-        if( (nModelEndPos - nModelPos == 1) &&
-            (m_pTextNode->GetText()[nModelPos] != m_sAccessibleString[nPos]))
+        if ((nCoreEndPos - nCorePos == TextFrameIndex(1)) &&
+            (m_pTextFrame->GetText()[sal_Int32(nCorePos)] != 
m_sAccessibleString[nPos]))
         {
             // case 1: a one-character, non-text portion
             // reference position is the first accessibility for our
@@ -600,12 +608,12 @@ sal_Int32 SwAccessiblePortionData::FillSpecialPos(
         else
         {
             // case 3: regular text portion
-            OSL_ENSURE( ( nModelEndPos - nModelPos ) ==
+            OSL_ENSURE( sal_Int32(nCoreEndPos - nCorePos) ==
                         ( m_aAccessiblePositions[nPortionNo+1] -
                           m_aAccessiblePositions[nPortionNo] ),
                         "text portion expected" );
 
-            nModelPos += nPos - m_aAccessiblePositions[ nPortionNo ];
+            nCorePos += TextFrameIndex(nPos - 
m_aAccessiblePositions[nPortionNo]);
             rpPos = nullptr;
         }
     }
@@ -628,7 +636,7 @@ sal_Int32 SwAccessiblePortionData::FillSpecialPos(
         rPos.nLineOfst = nLineOffset;
     }
 
-    return nModelPos;
+    return nCorePos;
 }
 
 bool SwAccessiblePortionData::FillBoundaryIFDateField( css::i18n::Boundary& 
rBound, const sal_Int32 nPos )
@@ -650,31 +658,31 @@ bool SwAccessiblePortionData::FillBoundaryIFDateField( 
css::i18n::Boundary& rBou
 void SwAccessiblePortionData::AdjustAndCheck(
     sal_Int32 nPos,
     size_t& nPortionNo,
-    sal_Int32& nCorePos,
+    TextFrameIndex& rCorePos,
     bool& bEdit) const
 {
     // find portion and get mode position
     nPortionNo = FindBreak( m_aAccessiblePositions, nPos );
-    nCorePos = m_aModelPositions[ nPortionNo ];
+    rCorePos = m_ViewPositions[ nPortionNo ];
 
     // for special portions, make sure we're on a portion boundary
     // for text portions, add the in-portion offset
     if( IsSpecialPortion( nPortionNo ) )
         bEdit &= nPos == m_aAccessiblePositions[nPortionNo];
     else
-        nCorePos += nPos - m_aAccessiblePositions[nPortionNo];
+        rCorePos += TextFrameIndex(nPos - m_aAccessiblePositions[nPortionNo]);
 }
 
 bool SwAccessiblePortionData::GetEditableRange(
     sal_Int32 nStart, sal_Int32 nEnd,
-    sal_Int32& nCoreStart, sal_Int32& nCoreEnd ) const
+    TextFrameIndex& rCoreStart, TextFrameIndex& rCoreEnd) const
 {
     bool bIsEditable = true;
 
     // get start and end portions
     size_t nStartPortion, nEndPortion;
-    AdjustAndCheck( nStart, nStartPortion, nCoreStart, bIsEditable );
-    AdjustAndCheck( nEnd,   nEndPortion,   nCoreEnd,   bIsEditable );
+    AdjustAndCheck( nStart, nStartPortion, rCoreStart, bIsEditable );
+    AdjustAndCheck( nEnd,   nEndPortion,   rCoreEnd,   bIsEditable );
 
     // iterate over portions, and make sure there is no read-only portion
     // in-between
@@ -702,17 +710,18 @@ bool SwAccessiblePortionData::GetEditableRange(
     return bIsEditable;
 }
 
-bool SwAccessiblePortionData::IsValidCorePosition( sal_Int32 nPos ) const
+bool SwAccessiblePortionData::IsValidCorePosition(TextFrameIndex const nPos) 
const
 {
-    // a position is valid its within the model positions that we know
-    return ( m_aModelPositions[0] <= nPos ) &&
-           ( nPos <= m_aModelPositions[ m_aModelPositions.size()-1 ] );
+    // a position is valid if it's within the core view positions that we know
+    return (m_ViewPositions[0] <= nPos ) &&
+           (nPos <= m_ViewPositions.back());
 }
 
 bool SwAccessiblePortionData::IsZeroCorePositionData()
 {
-    if( m_aModelPositions.size() < 1  ) return true;
-    return m_aModelPositions[0] == 0 &&  
m_aModelPositions[m_aModelPositions.size()-1] == 0;
+    if (m_ViewPositions.size() < 1) return true;
+    return m_ViewPositions[0] == TextFrameIndex(0)
+        && m_ViewPositions.back() == TextFrameIndex(0);
 }
 
 bool SwAccessiblePortionData::IsIndexInFootnode(sal_Int32 nIndex)
@@ -751,14 +760,14 @@ sal_Int32 
SwAccessiblePortionData::GetFieldIndex(sal_Int32 nPos)
     return nIndex;
 }
 
-sal_Int32 SwAccessiblePortionData::GetFirstValidCorePosition() const
+TextFrameIndex SwAccessiblePortionData::GetFirstValidCorePosition() const
 {
-    return m_aModelPositions[0];
+    return m_ViewPositions[0];
 }
 
-sal_Int32 SwAccessiblePortionData::GetLastValidCorePosition() const
+TextFrameIndex SwAccessiblePortionData::GetLastValidCorePosition() const
 {
-    return m_aModelPositions[ m_aModelPositions.size()-1 ];
+    return m_ViewPositions.back();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/access/accportions.hxx 
b/sw/source/core/access/accportions.hxx
index 9c4610076e28..74506f3d9761 100644
--- a/sw/source/core/access/accportions.hxx
+++ b/sw/source/core/access/accportions.hxx
@@ -26,7 +26,7 @@
 #include <memory>
 #include <vector>
 
-class SwTextNode;
+class SwTextFrame;
 struct SwSpecialPos;
 class SwViewOption;
 namespace com { namespace sun { namespace star {
@@ -38,12 +38,12 @@ namespace com { namespace sun { namespace star {
  */
 class SwAccessiblePortionData : public SwPortionHandler
 {
-    // the node this portion is referring to
-    const SwTextNode* m_pTextNode;
+    // the frame this portion is referring to
+    SwTextFrame const* m_pTextFrame;
 
     // variables used while collecting the data
     OUStringBuffer m_aBuffer;
-    sal_Int32 m_nModelPosition;
+    TextFrameIndex m_nViewPosition;
     const SwViewOption* m_pViewOptions;
 
     // the accessible string
@@ -53,30 +53,24 @@ class SwAccessiblePortionData : public SwPortionHandler
     // instances of Position_t must always include the minimum and
     // maximum positions as first/last elements (to simplify the
     // algorithms)
-    typedef std::vector<sal_Int32> Positions_t;
+    typedef std::vector<sal_Int32> AccessiblePositions;
+    typedef std::vector<TextFrameIndex> FramePositions;
 
-    Positions_t m_aLineBreaks;        /// position of line breaks
-    Positions_t m_aModelPositions;    /// position of portion breaks in the 
model
-    Positions_t m_aAccessiblePositions;   /// portion breaks in 
sAccessibleString
-    Positions_t m_aFieldPosition;
+    AccessiblePositions m_aLineBreaks; /// position of line breaks
+    FramePositions m_ViewPositions; /// position of portion breaks in the core 
view
+    AccessiblePositions m_aAccessiblePositions; /// portion breaks in 
m_sAccessibleString
+    AccessiblePositions m_aFieldPosition;
 
     std::vector<sal_uInt8> m_aPortionAttrs;   /// additional portion attributes
 
-    std::unique_ptr<Positions_t> m_pSentences;    /// positions of sentence 
breaks
+    std::unique_ptr<AccessiblePositions> m_pSentences; /// positions of 
sentence breaks
 
-    size_t m_nBeforePortions;     /// # of portions before first model 
character
+    size_t m_nBeforePortions;     /// # of portions before first core character
     bool m_bFinished;
 
-    /// returns the index of the first position whose value is smaller
-    /// or equal, and whose following value is equal or larger
-    static size_t FindBreak( const Positions_t& rPositions, sal_Int32 nValue );
-
-    /// like FindBreak, but finds the last equal or larger position
-    static size_t FindLastBreak( const Positions_t& rPositions, sal_Int32 
nValue );
-
     /// fill the boundary with the values from rPositions[nPos]
     static void FillBoundary(css::i18n::Boundary& rBound,
-                      const Positions_t& rPositions,
+                      const AccessiblePositions& rPositions,
                       size_t nPos );
 
     /// Access to portion attributes
@@ -86,10 +80,10 @@ class SwAccessiblePortionData : public SwPortionHandler
 
     // helper method for GetEditableRange(...):
     void AdjustAndCheck( sal_Int32 nPos, size_t& nPortionNo,
-                         sal_Int32& nCorePos, bool& bEdit ) const;
+                         TextFrameIndex& rCorePos, bool& bEdit) const;
 
 public:
-    SwAccessiblePortionData( const SwTextNode* pTextNd,
+    SwAccessiblePortionData( const SwTextFrame* pTextFrame,
                              const SwViewOption* pViewOpt );
     virtual ~SwAccessiblePortionData() override;
 
@@ -124,12 +118,12 @@ public:
     ///  boundaries. In this case, only part of a paragraph is represented
     ///  through this object. This method determines whether one particular
     ///  position is valid for this object or not.)
-    bool IsValidCorePosition( sal_Int32 nPos ) const;
-    sal_Int32 GetFirstValidCorePosition() const;
-    sal_Int32 GetLastValidCorePosition() const;
+    bool IsValidCorePosition(TextFrameIndex nPos) const;
+    TextFrameIndex GetFirstValidCorePosition() const;
+    TextFrameIndex GetLastValidCorePosition() const;
 
-    /// get the position in the accessibility string for a given model position
-    sal_Int32 GetAccessiblePosition( sal_Int32 nPos ) const;
+    /// get the position in the accessibility string for a given view position
+    sal_Int32 GetAccessiblePosition(TextFrameIndex nPos) const;
 
     // #i89175#
     sal_Int32 GetLineCount() const;
@@ -137,15 +131,15 @@ public:
     void GetBoundaryOfLine( const sal_Int32 nLineNo,
                             css::i18n::Boundary& rLineBound );
 
-    /// get the position in the model string for a given
+    /// get the position in the core view string for a given
     /// (accessibility) position
-    sal_Int32 GetModelPosition( sal_Int32 nPos ) const;
+    TextFrameIndex GetCoreViewPosition(sal_Int32 nPos) const;
 
     /// fill a SwSpecialPos structure, suitable for calling
     /// SwTextFrame->GetCharRect
     /// Returns the core position, and fills rpPos either with NULL or
     /// with the &rPos, after putting the appropriate data into it.
-    sal_Int32 FillSpecialPos( sal_Int32 nPos,
+    TextFrameIndex FillSpecialPos(sal_Int32 nPos,
                            SwSpecialPos& rPos,
                            SwSpecialPos*& rpPos ) const;
 
@@ -163,7 +157,8 @@ public:
     ///          or not at all. This can be used to test whether editing
     ///          that range would be legal
     bool GetEditableRange( sal_Int32 nStart, sal_Int32 nEnd,
-                               sal_Int32& nCoreStart, sal_Int32& nCoreEnd ) 
const;
+           TextFrameIndex& rCoreStart, TextFrameIndex& rCoreEnd) const;
+
 private:
     std::vector< std::pair<sal_Int32,sal_Int32> > m_vecPairPos;
 };
diff --git a/sw/source/core/access/textmarkuphelper.cxx 
b/sw/source/core/access/textmarkuphelper.cxx
index 55df15b845e0..2bbc8ab81984 100644
--- a/sw/source/core/access/textmarkuphelper.cxx
+++ b/sw/source/core/access/textmarkuphelper.cxx
@@ -155,7 +155,7 @@ css::uno::Sequence< css::accessibility::TextSegment >
     // assumption:
     // value of <nCharIndex> is in range [0..length of accessible text)
 
-    const sal_Int32 nCoreCharIndex = mrPortionData.GetModelPosition( 
nCharIndex );
+    const sal_Int32 nCoreCharIndex = 
mrPortionData.GetCoreViewPosition(nCharIndex);
     // Handling of portions with core length == 0 at the beginning of the
     // paragraph - e.g. numbering portion.
     if ( mrPortionData.GetAccessiblePosition( nCoreCharIndex ) > nCharIndex )
commit f3b65efc631f9ea92a26303d2758cd243c63eda9
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Fri Oct 5 15:00:16 2018 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Fri Oct 5 15:00:16 2018 +0200

    sw: SwAccessiblePortionData::m_aAttrFieldType is dead
    
    Remove this IA2 appendix, it's also dead in aoo/trunk...
    
    Change-Id: Id13835fb20e13f5f84a289f6a94c99c3b55409df

diff --git a/sw/source/core/access/accportions.cxx 
b/sw/source/core/access/accportions.cxx
index 0d9bd2460819..5aba09456587 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -75,7 +75,6 @@ SwAccessiblePortionData::SwAccessiblePortionData(
     m_aModelPositions(),
     m_aAccessiblePositions(),
     m_aFieldPosition(),
-    m_aAttrFieldType(),
     m_aPortionAttrs(),
     m_nBeforePortions( 0 ),
     m_bFinished( false )
@@ -120,11 +119,6 @@ void SwAccessiblePortionData::Text(TextFrameIndex const 
nLength,
     m_nModelPosition += nLength;
 }
 
-void SwAccessiblePortionData::SetAttrFieldType( sal_uInt16 nAttrFieldType )
-{
-    m_aAttrFieldType.push_back(nAttrFieldType);
-}
-
 void SwAccessiblePortionData::Special(
     TextFrameIndex const nLength, const OUString& rText, sal_uInt16 nType,
     sal_Int32 /*nHeight*/, sal_Int32 /*nWidth*/, const SwFont* /*pFont*/)
diff --git a/sw/source/core/access/accportions.hxx 
b/sw/source/core/access/accportions.hxx
index 92d4ce6218b2..9c4610076e28 100644
--- a/sw/source/core/access/accportions.hxx
+++ b/sw/source/core/access/accportions.hxx
@@ -59,7 +59,6 @@ class SwAccessiblePortionData : public SwPortionHandler
     Positions_t m_aModelPositions;    /// position of portion breaks in the 
model
     Positions_t m_aAccessiblePositions;   /// portion breaks in 
sAccessibleString
     Positions_t m_aFieldPosition;
-    Positions_t m_aAttrFieldType;
 
     std::vector<sal_uInt8> m_aPortionAttrs;   /// additional portion attributes
 
@@ -101,7 +100,6 @@ public:
     virtual void Skip(TextFrameIndex nLength) override;
     virtual void Finish() override;
 
-    virtual void SetAttrFieldType( sal_uInt16 nAttrFieldType ) override;
     bool FillBoundaryIFDateField( css::i18n::Boundary& rBound, const sal_Int32 
nPos );
     bool IsIndexInFootnode(sal_Int32 nIndex);
     bool IsInGrayPortion( sal_Int32 nPos );
diff --git a/sw/source/core/inc/SwPortionHandler.hxx 
b/sw/source/core/inc/SwPortionHandler.hxx
index ec3c5d4de392..6596030f3c82 100644
--- a/sw/source/core/inc/SwPortionHandler.hxx
+++ b/sw/source/core/inc/SwPortionHandler.hxx
@@ -96,8 +96,6 @@ public:
      * paragraph's portions have been processed.
      */
     virtual void Finish() = 0;
-    virtual void SetAttrFieldType( sal_uInt16 )
-    { return; }
 };
 
 #endif
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index f1fd08a76cb4..4027834b7a98 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -458,10 +458,6 @@ void SwFieldPortion::HandlePortion( SwPortionHandler& rPH 
) const
         nW = m_pFont->GetSize(m_pFont->GetActual()).Width();
     }
     rPH.Special( GetLen(), m_aExpand, GetWhichPor(), nH, nW, m_pFont.get() );
-    if( GetWhichPor() == POR_FLD )
-    {
-        rPH.SetAttrFieldType(m_nAttrFieldType);
-    }
 }
 
 SwPosSize SwFieldPortion::GetTextSize( const SwTextSizeInfo &rInf ) const
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to