diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-08-23 23:30:22 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-08-25 14:35:47 +0000 |
commit | 743c7c09b4deb7b62e49268f9867b96e6aab158c (patch) | |
tree | fcff85cd1a6e3e81636e5c3e7b6e7637d7c67bb7 | |
parent | 45f2cba6e31e7e0af189ec6b2d2234969144ca1a (diff) |
SwGlTreeListBox: NotifyCoping and NotifyMoving almost equal
Change-Id: I4cb9f7fccb7d5525a84dc8f5b1f25d1350d0f106
Reviewed-on: https://gerrit.libreoffice.org/5615
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | sw/source/ui/inc/glossary.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 53 |
2 files changed, 18 insertions, 39 deletions
diff --git a/sw/source/ui/inc/glossary.hxx b/sw/source/ui/inc/glossary.hxx index 3beb52ac1f7a..510fa837360e 100644 --- a/sw/source/ui/inc/glossary.hxx +++ b/sw/source/ui/inc/glossary.hxx @@ -70,6 +70,10 @@ class SwGlTreeListBox : public SvTreeListBox SvTreeListEntry* pEntry, SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos); + + sal_Bool NotifyCopyingOrMoving( SvTreeListEntry* pTarget, + SvTreeListEntry* pEntry, + bool bIsMove); public: SwGlTreeListBox(Window* pParent, WinBits nBits); diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 7cb9983b165d..414430d4eb62 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -954,44 +954,7 @@ sal_Bool SwGlTreeListBox::NotifyMoving( SvTreeListEntry* pTarget, sal_uLong& /*rNewChildPos*/ ) { - pDragEntry = 0; - if(!pTarget) // move to the beginning - { - pTarget = GetEntry(0); - } - // 1. move to different groups? - // 2. allowed to write in both groups? - SvTreeListEntry* pSrcParent = GetParent(pEntry); - SvTreeListEntry* pDestParent = - GetParent(pTarget) ? GetParent(pTarget) : pTarget; - sal_Bool bRet = sal_False; - if(pDestParent != pSrcParent) - { - SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParentDialog(); - SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True ); - - GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData(); - OUString sSourceGroup = pGroupData->sGroupName - + OUString(GLOS_DELIM) - + OUString::number(pGroupData->nPathIdx); - pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup); - OUString sTitle(GetEntryText(pEntry)); - OUString sShortName(*(String*)pEntry->GetUserData()); - - GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData(); - OUString sDestName = pDestData->sGroupName - + OUString(GLOS_DELIM) - + OUString::number(pDestData->nPathIdx); - bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName, - sDestName, sTitle, sal_True ); - if(bRet) - { - SvTreeListEntry* pChild = InsertEntry(sTitle, pDestParent); - pChild->SetUserData(new String(sShortName)); - GetModel()->Remove(pEntry); - } - } - return sal_False; // otherwise the entry is being set automatically + return NotifyCopyingOrMoving(pTarget, pEntry, true); } sal_Bool SwGlTreeListBox::NotifyCopying( SvTreeListEntry* pTarget, @@ -1000,6 +963,14 @@ sal_Bool SwGlTreeListBox::NotifyCopying( SvTreeListEntry* pTarget, sal_uLong& /*rNewChildPos*/ ) { + return NotifyCopyingOrMoving(pTarget, pEntry, false); +} + +sal_Bool SwGlTreeListBox::NotifyCopyingOrMoving( + SvTreeListEntry* pTarget, + SvTreeListEntry* pEntry, + bool bIsMove) +{ pDragEntry = 0; // 1. move in different groups? // 2. allowed to write to both groups? @@ -1031,11 +1002,15 @@ sal_Bool SwGlTreeListBox::NotifyCopying( SvTreeListEntry* pTarget, + OUString::number(pDestData->nPathIdx); bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName, - sDestName, sTitle, sal_False ); + sDestName, sTitle, bIsMove ); if(bRet) { SvTreeListEntry* pChild = InsertEntry(sTitle, pDestParent); pChild->SetUserData(new String(sShortName)); + if (bIsMove) + { + GetModel()->Remove(pEntry); + } } } return sal_False; // otherwise the entry is being set automatically |