Kaydet (Commit) 9c7ee273 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Michael Stahl

fdo#59573 position after fieldmark and before annotation anchor is read-only

Also revert "SwTxtPaintInfo::_DrawBackBrush: draw dark border around
comment highlight" (commit 57c8c34f), as
it draws confusing vertical lines inside the comment when it has
multiple runs.

(cherry picked from commit bd505fdb)

Conflicts:
	sw/qa/core/swdoc-test.cxx

Change-Id: If0f60e4a28878c2b31327ae3c04ae11470bc1f52
Reviewed-on: https://gerrit.libreoffice.org/2101Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 61217a8c
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <sfx2/sfxmodelfactory.hxx> #include <sfx2/sfxmodelfactory.hxx>
#include <xmloff/odffields.hxx>
#include "breakit.hxx" #include "breakit.hxx"
#include "doc.hxx" #include "doc.hxx"
#include "docsh.hxx" #include "docsh.hxx"
...@@ -88,6 +90,7 @@ public: ...@@ -88,6 +90,7 @@ public:
void testSwScanner(); void testSwScanner();
void testUserPerceivedCharCount(); void testUserPerceivedCharCount();
void testGraphicAnchorDeletion(); void testGraphicAnchorDeletion();
void testFdo59573();
CPPUNIT_TEST_SUITE(SwDocTest); CPPUNIT_TEST_SUITE(SwDocTest);
CPPUNIT_TEST(randomTest); CPPUNIT_TEST(randomTest);
...@@ -98,6 +101,7 @@ public: ...@@ -98,6 +101,7 @@ public:
CPPUNIT_TEST(testSwScanner); CPPUNIT_TEST(testSwScanner);
CPPUNIT_TEST(testUserPerceivedCharCount); CPPUNIT_TEST(testUserPerceivedCharCount);
CPPUNIT_TEST(testGraphicAnchorDeletion); CPPUNIT_TEST(testGraphicAnchorDeletion);
CPPUNIT_TEST(testFdo59573);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -878,6 +882,26 @@ void SwDocTest::randomTest() ...@@ -878,6 +882,26 @@ void SwDocTest::randomTest()
} }
} }
void SwDocTest::testFdo59573()
{
SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
// Insert "abc" and create a fieldmark around "b".
OUString aTest("abc");
m_pDoc->InsertString(aPaM, aTest);
aPaM.SetMark();
aPaM.GetPoint()->nContent = 1;
aPaM.GetMark()->nContent = 2;
IDocumentMarkAccess* pMarksAccess = m_pDoc->getIDocumentMarkAccess();
pMarksAccess->makeFieldBookmark(aPaM, "", ODF_COMMENTRANGE);
aPaM.GetPoint()->nContent = 4;
aPaM.GetMark()->nContent = 4;
// The problem was that the position after the fieldmark end and before the
// annotation anchor wasn't read-only.
CPPUNIT_ASSERT_EQUAL(sal_True, aPaM.HasReadonlySel(false));
}
void SwDocTest::setUp() void SwDocTest::setUp()
{ {
BootstrapFixture::setUp(); BootstrapFixture::setUp();
......
...@@ -686,9 +686,9 @@ sal_Bool SwPaM::HasReadonlySel( bool bFormView ) const ...@@ -686,9 +686,9 @@ sal_Bool SwPaM::HasReadonlySel( bool bFormView ) const
sw::mark::IMark* pB = NULL; sw::mark::IMark* pB = NULL;
bool bUnhandledMark = false; bool bUnhandledMark = false;
bool bCommentrangeMark = false; bool bCommentrangeMark = false;
const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
if ( pDoc ) if ( pDoc )
{ {
const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess( );
pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : NULL; pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : NULL;
pB = GetMark( ) ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA; pB = GetMark( ) ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
...@@ -729,6 +729,24 @@ sal_Bool SwPaM::HasReadonlySel( bool bFormView ) const ...@@ -729,6 +729,24 @@ sal_Bool SwPaM::HasReadonlySel( bool bFormView ) const
{ {
bRet = !( pA == pB && pA != NULL ); bRet = !( pA == pB && pA != NULL );
} }
// Don't allow inserting characters between the 'field mark end' and
// the 'comment anchor'.
if (!bRet)
{
if (!pA && GetPoint() && GetPoint()->nNode.GetNode().IsTxtNode() && GetPoint()->nContent.GetIndex() > 0)
{
// getFieldmarkFor() searches for >= start and < end, so check for
// the previous character, to also get the fieldmark, if we're
// exactly at the end.
SwPosition aPrevChar(*GetPoint());
aPrevChar.nContent--;
sw::mark::IFieldmark* pFieldmark = pMarksAccess->getFieldmarkFor(aPrevChar);
if (pFieldmark && pFieldmark->GetMarkEnd() == *GetPoint())
bRet = true;
}
}
return bRet; return bRet;
} }
......
...@@ -1117,15 +1117,12 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const ...@@ -1117,15 +1117,12 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const
const OUString& rAuthor = rPostItField.GetFld()->GetPar1(); const OUString& rAuthor = rPostItField.GetFld()->GetPar1();
sal_uInt16 nIndex = pNd->GetDoc()->InsertRedlineAuthor(rAuthor); sal_uInt16 nIndex = pNd->GetDoc()->InsertRedlineAuthor(rAuthor);
pOutDev->SetFillColor( SwPostItMgr::GetColorLight(nIndex) ); pOutDev->SetFillColor( SwPostItMgr::GetColorLight(nIndex) );
pOutDev->SetLineColor( SwPostItMgr::GetColorAnchor(nIndex) );
bFilled = true; bFilled = true;
} }
} }
if (!bFilled) if (!bFilled)
{
pOutDev->SetFillColor( SwViewOption::GetFieldShadingsColor() ); pOutDev->SetFillColor( SwViewOption::GetFieldShadingsColor() );
pOutDev->SetLineColor( ); pOutDev->SetLineColor( );
}
pOutDev->DrawRect( aIntersect.SVRect() ); pOutDev->DrawRect( aIntersect.SVRect() );
pOutDev->Pop(); pOutDev->Pop();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment