diff options
author | David Tardon <dtardon@redhat.com> | 2011-02-06 10:52:15 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2011-02-06 10:53:57 +0100 |
commit | 93997fb7fa58ef343e9ac8bdc39eb761695114f6 (patch) | |
tree | 5e33dba0c00c47d6db5a0c0cbae9ad431f9c80e6 | |
parent | 529b35cdd05bb07b65275d20832a154ce366c817 (diff) |
make (hopefully) more understandable
-rw-r--r-- | accessibility/source/extended/textwindowaccessibility.cxx | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index 99e41a626..04229966a 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -1722,33 +1722,38 @@ Document::getAccessibleChild(Paragraphs::iterator const & rIt) void Document::determineVisibleRange() { - m_aVisibleBegin = m_xParagraphs->end(); - m_aVisibleEnd = m_aVisibleBegin; + Paragraphs::iterator const aEnd = m_xParagraphs->end(); + + m_aVisibleBegin = aEnd; + m_aVisibleEnd = aEnd; + m_nVisibleBeginOffset = 0; + ::sal_Int32 nPos = 0; - for (Paragraphs::iterator aIt = m_xParagraphs->begin();;) + for (Paragraphs::iterator aIt = m_xParagraphs->begin(); m_aVisibleEnd == aEnd && aIt != aEnd; ++aIt) { - if (aIt == m_xParagraphs->end()) - { - m_nVisibleBeginOffset = 0; - break; - } - ::sal_Int32 nOldPos = nPos; + ::sal_Int32 const nOldPos = nPos; nPos += aIt->getHeight(); // XXX numeric overflow - if (m_aVisibleBegin == m_xParagraphs->end() && nPos >= m_nViewOffset) + if (m_aVisibleBegin == aEnd) { - m_aVisibleBegin = aIt; - m_nVisibleBeginOffset = m_nViewOffset - nOldPos; + if (nPos >= m_nViewOffset) + { + m_aVisibleBegin = aIt; + m_nVisibleBeginOffset = m_nViewOffset - nOldPos; + } } - ++aIt; - if (m_aVisibleBegin != m_xParagraphs->end() - && (aIt == m_xParagraphs->end() - || nPos >= m_nViewOffset + m_nViewHeight)) - // XXX numeric overflow + else { - m_aVisibleEnd = aIt; - break; + if (nPos >= m_nViewOffset + m_nViewHeight) // XXX numeric overflow + { + m_aVisibleEnd = aIt; + } } } + + OSL_POSTCOND( + (m_aVisibleBegin == m_xParagraphs->end() && m_aVisibleEnd == m_xParagraphs->end() && m_nVisibleBeginOffset == 0) + || (m_aVisibleBegin < m_aVisibleEnd && m_nVisibleBeginOffset >= 0), + "invalid visible range"); } void Document::notifyVisibleRangeChanges( |