[Libreoffice-commits] core.git: sw/source

Matteo Casalin matteo.casalin at yahoo.com
Sun Aug 25 07:36:11 PDT 2013


 sw/source/ui/inc/glossary.hxx  |    4 +++
 sw/source/ui/misc/glossary.cxx |   53 ++++++++++-------------------------------
 2 files changed, 18 insertions(+), 39 deletions(-)

New commits:
commit 743c7c09b4deb7b62e49268f9867b96e6aab158c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Aug 23 23:30:22 2013 +0200

    SwGlTreeListBox: NotifyCoping and NotifyMoving almost equal
    
    Change-Id: I4cb9f7fccb7d5525a84dc8f5b1f25d1350d0f106
    Reviewed-on: https://gerrit.libreoffice.org/5615
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/ui/inc/glossary.hxx b/sw/source/ui/inc/glossary.hxx
index 3beb52a..510fa83 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 7cb9983..414430d 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


More information about the Libreoffice-commits mailing list