[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source
Julien Nabet
serval2412 at yahoo.fr
Fri Oct 31 15:04:51 PDT 2014
sw/qa/complex/writer/TextPortionEnumerationTest.java | 23 ++++++++++++++
sw/source/core/txtnode/thints.cxx | 30 ++++++++++++-------
sw/source/uibase/wrtsh/wrtsh2.cxx | 8 ++---
3 files changed, 46 insertions(+), 15 deletions(-)
New commits:
commit 5aa299c034a89ffa9e332899bef33816d0b90963
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Fri Oct 31 22:44:41 2014 +0100
fdo#85562: sw: fix crash on insert of input field and set variable field
When a new field is inserted it doesn't have a SwFmtFld yet and it is
also not yet in the document so it is not necessary to listen for its
deletion.
(regression from bbd97fe57d9ec184ef6aee36bd57d6d7e53b4719)
Change-Id: I23c18aa8c490a6ad1de63a33f87679cc2358d7f5
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 484a551..fec7e86 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -211,24 +211,24 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
FieldDeletionModify aModify(pDlg.get());
SwInputField *const pInputField(dynamic_cast<SwInputField*>(pFld));
SwSetExpField *const pSetExpFld(dynamic_cast<SwSetExpField*>(pFld));
- if (pInputField)
+ if (pInputField && pInputField->GetFmtFld())
{
// Register for possible input field deletion while dialog is open
pInputField->GetFmtFld()->Add(&aModify);
}
- else if (pSetExpFld)
+ else if (pSetExpFld && pSetExpFld->GetFmtFld())
{
pSetExpFld->GetFmtFld()->Add(&aModify);
}
bool bRet = RET_CANCEL == pDlg->Execute();
- if (pInputField)
+ if (pInputField && pInputField->GetFmtFld())
{
// Dialog closed, remove modification listener
pInputField->GetFmtFld()->Remove(&aModify);
}
- else if (pSetExpFld)
+ else if (pSetExpFld && pSetExpFld->GetFmtFld())
{
pSetExpFld->GetFmtFld()->Remove(&aModify);
}
commit 9b7542b0928f81b36365b13228a402e8cd64e8cd
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Oct 31 22:06:40 2014 +0100
sw: fix insertion of hyperlink inside hyperlink...
... when either the start or the end position of the new hint is equal
to an existing hint. There is not just 1 case here but 3 different
ones; don't attempt to insert hints with start > end.
Change-Id: I39cf8a352f67d77b56b0d01de5872f4d341f6bdd
diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java
index 4e62d33..b793b9a 100644
--- a/sw/qa/complex/writer/TextPortionEnumerationTest.java
+++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java
@@ -2051,6 +2051,29 @@ public class TextPortionEnumerationTest
// this one gets eaten, but we still need to test inserting it (#i106930#)
// .appendChild( url6.dup().appendChild( new TextNode("") ) )
.appendChild( new TextNode("89") );
+ // inside (left-edge)
+ TreeNode url7 = new HyperlinkNode( mkName("url") );
+ inserter.insertRange( new Range(0, 1, url7) );
+ root = new TreeNode()
+ .appendChild( url7.dup().appendChild( new TextNode("1") ) )
+ .appendChild( url2.dup().appendChild( new TextNode("2") ) )
+ .appendChild( url1.dup().appendChild( new TextNode("3") ) )
+ .appendChild( url4.dup().appendChild( new TextNode("4") ) )
+ .appendChild( url5.dup().appendChild( new TextNode("56") ) )
+ .appendChild( url4.dup().appendChild( new TextNode("7") ) )
+ .appendChild( new TextNode("89") );
+ // inside (right-edge)
+ TreeNode url8 = new HyperlinkNode( mkName("url") );
+ inserter.insertRange( new Range(5, 6, url8) );
+ root = new TreeNode()
+ .appendChild( url7.dup().appendChild( new TextNode("1") ) )
+ .appendChild( url2.dup().appendChild( new TextNode("2") ) )
+ .appendChild( url1.dup().appendChild( new TextNode("3") ) )
+ .appendChild( url4.dup().appendChild( new TextNode("4") ) )
+ .appendChild( url5.dup().appendChild( new TextNode("5") ) )
+ .appendChild( url8.dup().appendChild( new TextNode("6") ) )
+ .appendChild( url4.dup().appendChild( new TextNode("7") ) )
+ .appendChild( new TextNode("89") );
doTest(root, false);
}
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index c29f87e..1494553 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -550,23 +550,31 @@ SwpHints::TryInsertNesting( SwTxtNode & rNode, SwTxtAttrNesting & rNewHint )
}
else
{
- assert((nOtherStart < nNewStart) && (nNewEnd < nOtherEnd));
+ assert((nOtherStart < nNewStart) || (nNewEnd < nOtherEnd));
// scenario: there is a RUBY, and contained within that a META;
// now a RUBY is inserted within the META => the exising RUBY is split:
// here it is not possible to simply insert the left/right fragment
// of the existing RUBY because they <em>overlap</em> with the META!
Delete( *itOther ); // this also does NoteInHistory!
- *(*itOther)->GetEnd() = nNewStart;
- bool bSuccess( TryInsertNesting(rNode, **itOther) );
- OSL_ENSURE(bSuccess, "recursive call 1 failed?");
- SwTxtAttrNesting * const pOtherRight(
- MakeTxtAttrNesting(
- rNode, **itOther, nNewEnd, nOtherEnd ) );
- bSuccess = TryInsertNesting(rNode, *pOtherRight);
- OSL_ENSURE(bSuccess, "recursive call 2 failed?");
- (void)bSuccess;
+ if (nNewEnd < nOtherEnd)
+ {
+ SwTxtAttrNesting * const pOtherRight(
+ MakeTxtAttrNesting(
+ rNode, **itOther, nNewEnd, nOtherEnd ) );
+ bool const bSuccess( TryInsertNesting(rNode, *pOtherRight) );
+ SAL_WARN_IF(!bSuccess, "sw.core", "recursive call 1 failed?");
+ }
+ if (nOtherStart < nNewStart)
+ {
+ *(*itOther)->GetEnd() = nNewStart;
+ bool const bSuccess( TryInsertNesting(rNode, **itOther) );
+ SAL_WARN_IF(!bSuccess, "sw.core", "recursive call 2 failed?");
+ }
+ else
+ {
+ rNode.DestroyAttr(*itOther);
+ }
}
-
}
return true;
More information about the Libreoffice-commits
mailing list