[Libreoffice-commits] core.git: Branch 'libreoffice-4-1-6' - sw/source

2014-04-22 Thread Michael Stahl
 sw/source/core/fields/reffld.cxx |   73 ++-
 1 file changed, 34 insertions(+), 39 deletions(-)

New commits:
commit 96c60b814c487a23aa7d1ae8db4407304a50b097
Author: Michael Stahl mst...@redhat.com
Date:   Thu Apr 17 15:25:23 2014 +0200

fdo#77342: sw: fix copy/paste of footnote cross references

The fix for sequence fields broke the footnote references some more;
simplify it by handling the footnotes in the same way as the sequence
fields, and not remapping GetExp fields for which the corresponding
SetExp field / footnote is missing.

Also, don't do any remapping when the target is a clipboard document, to
prevent modifying the source document.

(regression from bb665affbd8870652ade3951d626d76e99143f67)

(cherry picked from commit cbfcb837fb06a14daf5281ae13fc1886328cee6f)

Conflicts:
sw/source/core/fields/reffld.cxx

Change-Id: If1be1e1d9742182a4085bbbff53e26a8fa8665b8
Reviewed-on: https://gerrit.libreoffice.org/9084
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com
(cherry picked from commit 4786291566320aaf21fe4c9a7fb52269ddba4f3c)
Reviewed-on: https://gerrit.libreoffice.org/9087
Reviewed-by: Miklos Vajna vmik...@collabora.co.uk
Reviewed-by: Björn Michaelsen bjoern.michael...@canonical.com

diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index ba0e4bb..fee6d0e 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1014,6 +1014,17 @@ void _RefIdsMap::Init( SwDoc rDoc, SwDoc rDestDoc, 
bool bField )
 {
 GetNoteIdsFromDoc( rDestDoc, aIds );
 GetNoteIdsFromDoc( rDoc, aDstIds );
+
+for (std::setsal_uInt16::iterator pIt = aDstIds.begin(); pIt != 
aDstIds.end(); ++pIt)
+AddId( GetFirstUnusedId(aIds), *pIt );
+
+// Change the footnotes/endnotes in the source doc to the new ID
+for (sal_uInt16 i = 0, nCnt = rDoc.GetFtnIdxs().size(); i  nCnt; ++i)
+{
+SwTxtFtn *const pFtnIdx = rDoc.GetFtnIdxs()[i];
+sal_uInt16 const n = pFtnIdx-GetSeqRefNo();
+pFtnIdx-SetSeqNo(sequencedIds[n]);
+}
 }
 bInit = true;
 }
@@ -1051,54 +1062,38 @@ void _RefIdsMap::Check( SwDoc rDoc, SwDoc rDestDoc, 
SwGetRefField rFld,
 {
 Init( rDoc, rDestDoc, bField);
 
-sal_uInt16 nSeqNo = rFld.GetSeqNo();
+sal_uInt16 const nSeqNo = rFld.GetSeqNo();
 
-// Check if the number is used in both documents
-// Note: For fields, aIds contains both the ids of SetExp from rDestDoc
-// and the targets of the already remapped ones from rDoc.
-// It is possible that aDstIds contains numbers that aIds does not contain!
-// For example, copying a selection to clipboard that does not contain
-// the first SwSetExpField will result in id 0 missing, then pasting that
-// into empty document gives a mapping 1-0 ... N-N-1 (fdo#63553).
-if (aIds.count(nSeqNo) || aDstIds.count(nSeqNo))
+// check if it needs to be remapped
+// if sequencedIds doesn't contain the number, it means there is no
+// SetExp field / footnote in the source document: do not modify
+// the number, which works well for copy from/paste to same document
+// (and if it is not the same document, there's no correct result anyway)
+if (sequencedIds.count(nSeqNo))
 {
-// Number already taken, so need a new one.
-if( sequencedIds.count(nSeqNo) )
-rFld.SetSeqNo( sequencedIds[nSeqNo] );
-else
-{
-assert(!bField || !aDstIds.count(nSeqNo)); // postcond of Init
-
-sal_uInt16 n = GetFirstUnusedId( aIds );
-
-// die neue SeqNo eintragen, damit die belegt ist
-AddId( n, nSeqNo );
-rFld.SetSeqNo( n );
-
-// und noch die Fuss-/EndNote auf die neue Id umsetzen
-if( !bField )
-{
-SwTxtFtn* pFtnIdx;
-for( sal_uInt16 i = 0, nCnt = rDoc.GetFtnIdxs().size(); i  
nCnt; ++i )
-if( nSeqNo == (pFtnIdx = rDoc.GetFtnIdxs()[ i 
])-GetSeqRefNo() )
-{
-pFtnIdx-SetSeqNo( n );
-break;
-}
-}
-}
-}
-else
-{
-AddId( nSeqNo, nSeqNo ); // this requires that nSeqNo is unused in 
both!
+rFld.SetSeqNo( sequencedIds[nSeqNo] );
 }
 }
 
-
+/// 1. if _both_ SetExp + GetExp / Footnote + GetExp field are copied,
+///enusure that both get a new unused matching number
+/// 2. if only SetExp / Footnote is copied, it gets a new unused number
+/// 3. if only GetExp field is copied, for the case of copy from / paste to
+///same document it's desirable to keep the same number;
+///for other cases of copy/paste or master documents it's not obvious
+///what is most desirable 

[Libreoffice-commits] core.git: Branch 'libreoffice-4-1-6' - sw/source

2014-04-14 Thread Lennard Wasserthal
 sw/source/ui/docvw/edtwin.cxx |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

New commits:
commit a0fb0d938434477898ee8b54bc7da523d5120ea0
Author: Lennard Wasserthal wassert...@nefkom.net
Date:   Sat Apr 5 11:55:24 2014 +0200

fdo#69157 Apply object-in front selection on mouseUp

Before, all selection was recklessly replaced when you clicked something
else than a scaling handle (or the like).
It caused bug 69157.

But now, you can still drag the frame by gripping the interior one.
Btw, that the timer did not correctly start was because of the return
statement in the prior state.

Change-Id: I5e02cfb2d5fe9cdb9fd7f50d0c961dcc418fadd6
Signed-off-by: Lennard Wasserthal wassert...@nefkom.net
Signed-off-by: Michael Stahl mst...@redhat.com
(cherry picked from commit 351ab7b879a1e5bf879600bf47909181029a4d11)
Reviewed-on: https://gerrit.libreoffice.org/8907
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com
(cherry picked from commit c7cec7bb9ea7ef0aaa18a5c39eca13c446f974c5)
Reviewed-on: https://gerrit.libreoffice.org/8935
Reviewed-by: David Tardon dtar...@redhat.com

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 3dd87c0..cd838c0 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2618,8 +2618,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent _rMEvt)
 {
 SwWrtShell rSh = m_rView.GetWrtShell();
 
-SdrObject* pObj;
-SdrPageView* pPV;
 // We have to check if a context menu is shown and we have an UI
 // active inplace client. In that case we have to ignore the mouse
 // button down event. Otherwise we would crash (context menu has been
@@ -2936,12 +2934,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent _rMEvt)
 // only if no position to size was hit.
 if (!bHitHandle)
 {
-if (pSdrView-PickObj(aDocPos, 
pSdrView-getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | 
SDRSEARCH_BEFOREMARK))
-{
-pSdrView-UnmarkAllObj();
-
pSdrView-MarkObj(pObj,pPV,false,false);
-return;
-}
 StartDDTimer();
 SwEditWin::m_nDDStartPosY = aDocPos.Y();
 SwEditWin::m_nDDStartPosX = aDocPos.X();
@@ -4029,6 +4021,8 @@ void SwEditWin::MouseMove(const MouseEvent _rMEvt)
  */
 void SwEditWin::MouseButtonUp(const MouseEvent rMEvt)
 {
+SdrObject* pObj;
+SdrPageView* pPV;
 bool bCallBase = true;
 
 sal_Bool bCallShadowCrsr = m_bWasShdwCrsr;
@@ -4080,6 +4074,15 @@ void SwEditWin::MouseButtonUp(const MouseEvent rMEvt)
 bFrmDrag = false;
 }
 bNoInterrupt = false;
+const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+if ((PixelToLogic(m_aStartPos).Y() == (aDocPos.Y()))  
(PixelToLogic(m_aStartPos).X() == (aDocPos.X(//To make sure it was not moved
+{
+if (pSdrView-PickObj(aDocPos, pSdrView-getHitTolLog(), pObj, 
pPV, SDRSEARCH_ALSOONMASTER ))
+{
+pSdrView-UnmarkAllObj();
+pSdrView-MarkObj(pObj,pPV,false,false);
+}
+}
 ReleaseMouse();
 return;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits