LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/dlg - sdtreelb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 549 0.2 %
Date: 2013-07-09 Functions: 2 48 4.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <sal/types.h>
      22             : #include <sot/formats.hxx>
      23             : #include <sot/storage.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <svl/urihelper.hxx>
      26             : #include <svx/svditer.hxx>
      27             : #include <sfx2/docfile.hxx>
      28             : #include <svx/svdoole2.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : #include "cusshow.hxx"
      31             : #include <sfx2/childwin.hxx>
      32             : 
      33             : #include <sfx2/viewfrm.hxx>
      34             : 
      35             : #include "strmname.h"
      36             : #include "sdtreelb.hxx"
      37             : #include "DrawDocShell.hxx"
      38             : #include "drawdoc.hxx"
      39             : #include "sdpage.hxx"
      40             : #include "sdresid.hxx"
      41             : #include "navigatr.hxx"
      42             : #include "strings.hrc"
      43             : #include "res_bmp.hrc"
      44             : #include "customshowlist.hxx"
      45             : #include "ViewShell.hxx"
      46             : #include "DrawController.hxx"
      47             : #include "ViewShellBase.hxx"
      48             : 
      49             : #include <com/sun/star/embed/XEmbedPersist.hpp>
      50             : #include <com/sun/star/frame/Desktop.hpp>
      51             : #include <com/sun/star/frame/XFramesSupplier.hpp>
      52             : #include <svtools/embedtransfer.hxx>
      53             : #include "svtools/treelistentry.hxx"
      54             : #include <comphelper/servicehelper.hxx>
      55             : #include <comphelper/processfactory.hxx>
      56             : #include <tools/diagnose_ex.h>
      57             : 
      58             : using namespace com::sun::star;
      59             : 
      60           0 : class SdPageObjsTLB::IconProvider
      61             : {
      62             : public:
      63             :     IconProvider (void);
      64             : 
      65             :     // Regular icons.
      66             :     Image maImgPage;
      67             :     Image maImgPageExcl;
      68             :     Image maImgPageObjsExcl;
      69             :     Image maImgPageObjs;
      70             :     Image maImgObjects;
      71             :     Image maImgGroup;
      72             : };
      73             : 
      74             : 
      75             : sal_Bool SAL_DLLPRIVATE SdPageObjsTLB::bIsInDrag = sal_False;
      76             : 
      77           0 : sal_Bool SdPageObjsTLB::IsInDrag()
      78             : {
      79           0 :     return bIsInDrag;
      80             : }
      81             : 
      82             : sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::mnListBoxDropFormatId = SAL_MAX_UINT32;
      83             : 
      84             : // -----------------------------------------
      85             : // - SdPageObjsTLB::SdPageObjsTransferable -
      86             : // -----------------------------------------
      87             : 
      88           0 : SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable(
      89             :     SdPageObjsTLB& rParent,
      90             :         const INetBookmark& rBookmark,
      91             :     ::sd::DrawDocShell& rDocShell,
      92             :     NavigatorDragType eDragType,
      93             :     const ::com::sun::star::uno::Any& rTreeListBoxData )
      94             :     : SdTransferable(rDocShell.GetDoc(), NULL, sal_True),
      95             :       mrParent( rParent ),
      96             :       maBookmark( rBookmark ),
      97             :       mrDocShell( rDocShell ),
      98             :       meDragType( eDragType ),
      99           0 :       maTreeListBoxData( rTreeListBoxData )
     100             : {
     101           0 : }
     102             : 
     103             : 
     104             : 
     105             : 
     106           0 : SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable()
     107             : {
     108           0 : }
     109             : 
     110             : // -----------------------------------------------------------------------------
     111             : 
     112           0 : void SdPageObjsTLB::SdPageObjsTransferable::AddSupportedFormats()
     113             : {
     114           0 :     AddFormat(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK);
     115           0 :     AddFormat(SOT_FORMATSTR_ID_TREELISTBOX);
     116           0 :     AddFormat(GetListBoxDropFormatId());
     117           0 : }
     118             : 
     119             : // -----------------------------------------------------------------------------
     120             : 
     121           0 : sal_Bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
     122             : {
     123           0 :     sal_uLong nFormatId = SotExchange::GetFormat( rFlavor );
     124           0 :     switch (nFormatId)
     125             :     {
     126             :         case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
     127           0 :             SetINetBookmark( maBookmark, rFlavor );
     128           0 :             return sal_True;
     129             : 
     130             :         case SOT_FORMATSTR_ID_TREELISTBOX:
     131           0 :             SetAny(maTreeListBoxData, rFlavor);
     132           0 :             return sal_True;
     133             : 
     134             :         default:
     135           0 :             return sal_False;
     136             :     }
     137             : }
     138             : 
     139             : // -----------------------------------------------------------------------------
     140             : 
     141           0 : void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction )
     142             : {
     143           0 :     mrParent.OnDragFinished( nDropAction );
     144           0 :     SdTransferable::DragFinished(nDropAction);
     145           0 : }
     146             : 
     147             : // -----------------------------------------------------------------------------
     148             : 
     149           0 : ::sd::DrawDocShell& SdPageObjsTLB::SdPageObjsTransferable::GetDocShell() const
     150             : {
     151           0 :     return mrDocShell;
     152             : }
     153             : 
     154             : // -----------------------------------------------------------------------------
     155             : 
     156           0 : NavigatorDragType SdPageObjsTLB::SdPageObjsTransferable::GetDragType() const
     157             : {
     158           0 :     return meDragType;
     159             : }
     160             : 
     161             : // -----------------------------------------------------------------------------
     162             : 
     163           0 : sal_Int64 SAL_CALL SdPageObjsTLB::SdPageObjsTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException )
     164             : {
     165             :     sal_Int64 nRet;
     166             : 
     167           0 :     if( ( rId.getLength() == 16 ) &&
     168           0 :         ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
     169             :     {
     170           0 :         nRet = (sal_Int64)(sal_IntPtr)this;
     171             :     }
     172             :     else
     173           0 :         nRet = SdTransferable::getSomething(rId);
     174             : 
     175           0 :     return nRet;
     176             : }
     177             : 
     178             : namespace
     179             : {
     180             :     class theSdPageObjsTLBUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdPageObjsTLBUnoTunnelId > {};
     181             : }
     182             : 
     183           0 : const ::com::sun::star::uno::Sequence< sal_Int8 >& SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()
     184             : {
     185           0 :     return theSdPageObjsTLBUnoTunnelId::get().getSeq();
     186             : }
     187             : 
     188             : // -----------------------------------------------------------------------------
     189             : 
     190           0 : SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData )
     191             :     throw()
     192             : {
     193             :     try
     194             :     {
     195           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, ::com::sun::star::uno::UNO_QUERY_THROW );
     196             : 
     197             :         return reinterpret_cast<SdPageObjsTLB::SdPageObjsTransferable*>(
     198             :                 sal::static_int_cast<sal_uIntPtr>(
     199           0 :                     xUnoTunnel->getSomething( SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()) ) );
     200             :     }
     201           0 :     catch( const ::com::sun::star::uno::Exception& )
     202             :     {
     203             :     }
     204           0 :     return 0;
     205             : }
     206             : 
     207             : 
     208           0 : sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId (void)
     209             : {
     210           0 :     if (mnListBoxDropFormatId == SAL_MAX_UINT32)
     211             :         mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType(OUString(
     212           0 :         "application/x-openoffice-treelistbox-moveonly;windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\""));
     213           0 :     return mnListBoxDropFormatId;
     214             : }
     215             : 
     216             : 
     217           0 : SdPageObjsTLB::SdPageObjsTLB( Window* pParentWin, const SdResId& rSdResId )
     218             : :   SvTreeListBox       ( pParentWin, rSdResId )
     219             : ,   mpParent            ( pParentWin )
     220             : ,   mpDoc               ( NULL )
     221             : ,   mpBookmarkDoc       ( NULL )
     222             : ,   mpMedium            ( NULL )
     223             : ,   mpOwnMedium         ( NULL )
     224             : ,   maImgOle             ( BitmapEx( SdResId( BMP_OLE ) ) )
     225             : ,   maImgGraphic         ( BitmapEx( SdResId( BMP_GRAPHIC ) ) )
     226             : ,   mbLinkableSelected  ( sal_False )
     227             : ,   mpDropNavWin        ( NULL )
     228             : ,   mbShowAllShapes     ( false )
     229           0 : ,   mbShowAllPages      ( false )
     230             : 
     231             : {
     232             :     // add lines to Tree-ListBox
     233           0 :     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
     234             :                            WB_HASBUTTONS | // WB_HASLINESATROOT |
     235             :                            WB_HSCROLL |
     236             :                            WB_HASBUTTONSATROOT |
     237           0 :                            WB_QUICK_SEARCH /* i31275 */ );
     238             :     SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND ) ),
     239           0 :                     Bitmap( SdResId( BMP_COLLAPSE ) ) );
     240             : 
     241             :     SetDragDropMode(
     242             :          SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY |
     243           0 :             SV_DRAGDROP_APP_MOVE  | SV_DRAGDROP_APP_COPY  | SV_DRAGDROP_APP_DROP );
     244           0 : }
     245             : 
     246             : 
     247           0 : SdPageObjsTLB::~SdPageObjsTLB()
     248             : {
     249           0 :     if ( mpBookmarkDoc )
     250           0 :         CloseBookmarkDoc();
     251             :     else
     252             :         // no document was created from mpMedium, so this object is still the owner of it
     253           0 :         delete mpMedium;
     254           0 : }
     255             : 
     256           0 : String SdPageObjsTLB::GetObjectName(
     257             :     const SdrObject* pObject,
     258             :     const bool bCreate) const
     259             : {
     260           0 :     String aRet;
     261             : 
     262           0 :     if ( pObject )
     263             :     {
     264           0 :         aRet = pObject->GetName();
     265             : 
     266           0 :         if( !aRet.Len() && pObject->ISA( SdrOle2Obj ) )
     267           0 :             aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
     268             :     }
     269             : 
     270           0 :     if (bCreate
     271           0 :         && mbShowAllShapes
     272           0 :         && aRet.Len() == 0
     273           0 :         && pObject!=NULL)
     274             :     {
     275           0 :         aRet = SD_RESSTR(STR_NAVIGATOR_SHAPE_BASE_NAME);
     276           0 :         aRet.SearchAndReplaceAscii("%1", OUString::number(pObject->GetOrdNum() + 1));
     277             :     }
     278             : 
     279           0 :     return aRet;
     280             : }
     281             : 
     282             : /**
     283             :  * select a entry in TreeLB
     284             :  */
     285           0 : sal_Bool SdPageObjsTLB::SelectEntry( const String& rName )
     286             : {
     287           0 :     sal_Bool bFound = sal_False;
     288             : 
     289           0 :     if( rName.Len() )
     290             :     {
     291           0 :         SvTreeListEntry* pEntry = NULL;
     292           0 :         String aTmp;
     293             : 
     294           0 :         for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
     295             :         {
     296           0 :             aTmp = GetEntryText( pEntry );
     297           0 :             if( aTmp == rName )
     298             :             {
     299           0 :                 bFound = sal_True;
     300           0 :                 SetCurEntry( pEntry );
     301             :             }
     302           0 :         }
     303             :     }
     304           0 :     return( bFound );
     305             : }
     306             : 
     307             : /**
     308             :  * @return true if children of the specified string are selected
     309             :  */
     310           0 : sal_Bool SdPageObjsTLB::HasSelectedChildren( const String& rName )
     311             : {
     312           0 :     sal_Bool bFound  = sal_False;
     313           0 :     sal_Bool bChildren = sal_False;
     314             : 
     315           0 :     if( rName.Len() )
     316             :     {
     317           0 :         SvTreeListEntry* pEntry = NULL;
     318           0 :         String aTmp;
     319             : 
     320           0 :         for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
     321             :         {
     322           0 :             aTmp = GetEntryText( pEntry );
     323           0 :             if( aTmp == rName )
     324             :             {
     325           0 :                 bFound = sal_True;
     326           0 :                 sal_Bool bExpanded = IsExpanded( pEntry );
     327           0 :                 long nCount = GetChildSelectionCount( pEntry );
     328           0 :                 if( bExpanded && nCount > 0 )
     329           0 :                     bChildren = sal_True;
     330             :             }
     331           0 :         }
     332             :     }
     333           0 :     return( bChildren );
     334             : }
     335             : 
     336             : 
     337             : /**
     338             :  * Fill TreeLB with pages and objects
     339             :  */
     340           0 : void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, sal_Bool bAllPages,
     341             :                           const String& rDocName)
     342             : {
     343           0 :     String aSelection;
     344           0 :     if( GetSelectionCount() > 0 )
     345             :     {
     346           0 :         aSelection = GetSelectEntry();
     347           0 :         Clear();
     348             :     }
     349             : 
     350           0 :     mpDoc = pInDoc;
     351           0 :     maDocName = rDocName;
     352           0 :     mbShowAllPages = (bAllPages == sal_True);
     353           0 :     mpMedium = NULL;
     354             : 
     355           0 :     SdPage*      pPage = NULL;
     356             : 
     357           0 :     IconProvider aIconProvider;
     358             : 
     359             :     // first insert all pages including objects
     360           0 :     sal_uInt16 nPage = 0;
     361           0 :     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
     362             : 
     363           0 :     while( nPage < nMaxPages )
     364             :     {
     365           0 :         pPage = (SdPage*) mpDoc->GetPage( nPage );
     366           0 :         if(  (mbShowAllPages || pPage->GetPageKind() == PK_STANDARD)
     367           0 :              && !(pPage->GetPageKind()==PK_HANDOUT)   ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
     368             :         {
     369           0 :             sal_Bool bPageExluded = pPage->IsExcluded();
     370             : 
     371           0 :             bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
     372           0 :             bPageExluded |= !bPageBelongsToShow;
     373             : 
     374           0 :             AddShapeList(*pPage, NULL, pPage->GetName(), bPageExluded, NULL, aIconProvider);
     375             :         }
     376           0 :         nPage++;
     377             :     }
     378             : 
     379             :     // then insert all master pages including objects
     380           0 :     if( mbShowAllPages )
     381             :     {
     382           0 :         nPage = 0;
     383           0 :         const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
     384             : 
     385           0 :         while( nPage < nMaxMasterPages )
     386             :         {
     387           0 :             pPage = (SdPage*) mpDoc->GetMasterPage( nPage );
     388           0 :             AddShapeList(*pPage, NULL, pPage->GetName(), false, NULL, aIconProvider);
     389           0 :             nPage++;
     390             :         }
     391             :     }
     392           0 :     if( aSelection.Len() )
     393           0 :         SelectEntry( aSelection );
     394           0 : }
     395             : 
     396             : /**
     397             :  * We insert only the first entry. Children are created on demand.
     398             :  */
     399           0 : void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
     400             :                           const String& rDocName )
     401             : {
     402           0 :     mpDoc = pInDoc;
     403             : 
     404             :     // this object now owns the Medium
     405           0 :     mpMedium = pInMedium;
     406           0 :     maDocName = rDocName;
     407             : 
     408           0 :     Image aImgDocOpen=Image( BitmapEx( SdResId( BMP_DOC_OPEN ) ) );
     409           0 :     Image aImgDocClosed=Image( BitmapEx( SdResId( BMP_DOC_CLOSED ) ) );
     410             : 
     411             :     // insert document name
     412             :     InsertEntry( maDocName, aImgDocOpen, aImgDocClosed, NULL, sal_True, LIST_APPEND,
     413             :                  reinterpret_cast< void* >( 1 )
     414           0 :     );
     415           0 : }
     416             : 
     417             : 
     418             : 
     419             : 
     420           0 : void SdPageObjsTLB::AddShapeList (
     421             :     const SdrObjList& rList,
     422             :     SdrObject* pShape,
     423             :     const OUString& rsName,
     424             :     const bool bIsExcluded,
     425             :     SvTreeListEntry* pParentEntry,
     426             :     const IconProvider& rIconProvider)
     427             : {
     428           0 :     Image aIcon (rIconProvider.maImgPage);
     429           0 :     if (bIsExcluded)
     430           0 :         aIcon = rIconProvider.maImgPageExcl;
     431           0 :     else if (pShape != NULL)
     432           0 :         aIcon = rIconProvider.maImgGroup;
     433             : 
     434           0 :     void* pUserData (reinterpret_cast<void*>(1));
     435           0 :     if (pShape != NULL)
     436           0 :         pUserData = pShape;
     437             : 
     438             :     SvTreeListEntry* pEntry = InsertEntry(
     439             :         rsName,
     440             :         aIcon,
     441             :         aIcon,
     442             :         pParentEntry,
     443             :         sal_False,
     444             :         LIST_APPEND,
     445           0 :         pUserData);
     446             : 
     447             :     SdrObjListIter aIter(
     448             :         rList,
     449           0 :         !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
     450             :         IM_FLAT,
     451           0 :         sal_False /*not reverse*/);
     452             : 
     453           0 :     while( aIter.IsMore() )
     454             :     {
     455           0 :         SdrObject* pObj = aIter.Next();
     456             :         OSL_ASSERT(pObj!=NULL);
     457             : 
     458             :         // Get the shape name.
     459           0 :         String aStr (GetObjectName( pObj ) );
     460             : 
     461           0 :         if( aStr.Len() )
     462             :         {
     463           0 :             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
     464             :             {
     465             :                 InsertEntry(
     466             :                     aStr,
     467             :                     maImgOle,
     468             :                     maImgOle,
     469             :                     pEntry,
     470             :                     sal_False,
     471             :                     LIST_APPEND,
     472             :                     pObj
     473           0 :                 );
     474             :             }
     475           0 :             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
     476             :             {
     477             :                 InsertEntry(
     478             :                     aStr,
     479             :                     maImgGraphic,
     480             :                     maImgGraphic,
     481             :                     pEntry,
     482             :                     sal_False,
     483             :                     LIST_APPEND,
     484             :                     pObj
     485           0 :                 );
     486             :             }
     487           0 :             else if (pObj->IsGroupObject())
     488             :             {
     489             :                 AddShapeList(
     490           0 :                     *pObj->GetSubList(),
     491             :                     pObj,
     492             :                     aStr,
     493             :                     false,
     494             :                     pEntry,
     495             :                     rIconProvider
     496           0 :                 );
     497             :             }
     498             :             else
     499             :             {
     500             :                 InsertEntry(
     501             :                     aStr,
     502             :                     rIconProvider.maImgObjects,
     503             :                     rIconProvider.maImgObjects,
     504             :                     pEntry,
     505             :                     sal_False,
     506             :                     LIST_APPEND,
     507             :                     pObj
     508           0 :                 );
     509             :             }
     510             :         }
     511           0 :     }
     512             : 
     513           0 :     if( pEntry->HasChildren() )
     514             :     {
     515             :         SetExpandedEntryBmp(
     516             :             pEntry,
     517           0 :             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
     518             :         SetCollapsedEntryBmp(
     519             :             pEntry,
     520           0 :             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
     521           0 :     }
     522           0 : }
     523             : 
     524             : 
     525             : 
     526             : 
     527           0 : void SdPageObjsTLB::SetShowAllShapes (
     528             :     const bool bShowAllShapes,
     529             :     const bool bFillList)
     530             : {
     531           0 :     mbShowAllShapes = bShowAllShapes;
     532           0 :     if (bFillList)
     533             :     {
     534           0 :         if (mpMedium == NULL)
     535           0 :             Fill(mpDoc, mbShowAllPages, maDocName);
     536             :         else
     537           0 :             Fill(mpDoc, mpMedium, maDocName);
     538             :     }
     539           0 : }
     540             : 
     541             : 
     542             : 
     543             : 
     544           0 : bool SdPageObjsTLB::GetShowAllShapes (void) const
     545             : {
     546           0 :     return mbShowAllShapes;
     547             : }
     548             : 
     549             : 
     550             : 
     551             : 
     552             : /**
     553             :  * Checks if the pages (PK_STANDARD) of a doc and the objects on the pages
     554             :  * are identical to the TreeLB.
     555             :  * If a doc is provided, this will be the used doc (important by more than
     556             :  * one document).
     557             :  */
     558           0 : sal_Bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
     559             : {
     560           0 :     if( pInDoc )
     561           0 :         mpDoc = pInDoc;
     562             : 
     563           0 :     if( !mpDoc )
     564           0 :         return( sal_False );
     565             : 
     566           0 :     SdrObject*   pObj = NULL;
     567           0 :     SdPage*      pPage = NULL;
     568           0 :     SvTreeListEntry* pEntry = First();
     569           0 :     String       aName;
     570             : 
     571             :     // compare all pages including the objects
     572           0 :     sal_uInt16 nPage = 0;
     573           0 :     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
     574             : 
     575           0 :     while( nPage < nMaxPages )
     576             :     {
     577           0 :         pPage = (SdPage*) mpDoc->GetPage( nPage );
     578           0 :         if( pPage->GetPageKind() == PK_STANDARD )
     579             :         {
     580           0 :             if( !pEntry )
     581           0 :                 return( sal_False );
     582           0 :             aName = GetEntryText( pEntry );
     583             : 
     584           0 :             if( pPage->GetName() != aName )
     585           0 :                 return( sal_False );
     586             : 
     587           0 :             pEntry = Next( pEntry );
     588             : 
     589             :             SdrObjListIter aIter(
     590             :                 *pPage,
     591           0 :                 !pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
     592           0 :                 IM_DEEPWITHGROUPS );
     593             : 
     594           0 :             while( aIter.IsMore() )
     595             :             {
     596           0 :                 pObj = aIter.Next();
     597             : 
     598           0 :                 const String aObjectName( GetObjectName( pObj ) );
     599             : 
     600           0 :                 if( aObjectName.Len() )
     601             :                 {
     602           0 :                     if( !pEntry )
     603           0 :                         return( sal_False );
     604             : 
     605           0 :                     aName = GetEntryText( pEntry );
     606             : 
     607           0 :                     if( aObjectName != aName )
     608           0 :                         return( sal_False );
     609             : 
     610           0 :                     pEntry = Next( pEntry );
     611             :                 }
     612           0 :             }
     613             :         }
     614           0 :         nPage++;
     615             :     }
     616             :     // If there are still entries in the listbox,
     617             :     // then objects (with names) or pages were deleted
     618           0 :     return( !pEntry );
     619             : }
     620             : 
     621             : /**
     622             :  * @return selected string
     623             :  */
     624           0 : String SdPageObjsTLB::GetSelectEntry()
     625             : {
     626           0 :     return( GetEntryText( GetCurEntry() ) );
     627             : }
     628             : 
     629           0 : std::vector<OUString> SdPageObjsTLB::GetSelectEntryList( const sal_uInt16 nDepth ) const
     630             : {
     631           0 :     std::vector<OUString> aEntries;
     632           0 :     SvTreeListEntry* pEntry = FirstSelected();
     633             : 
     634           0 :     while( pEntry )
     635             :     {
     636           0 :         sal_uInt16 nListDepth = GetModel()->GetDepth( pEntry );
     637             : 
     638           0 :         if( nListDepth == nDepth )
     639           0 :             aEntries.push_back(GetEntryText(pEntry));
     640             : 
     641           0 :         pEntry = NextSelected( pEntry );
     642             :     }
     643             : 
     644           0 :     return aEntries;
     645             : }
     646             : 
     647             : /**
     648             :  * Entries are inserted only by request (double click)
     649             :  */
     650           0 : void SdPageObjsTLB::RequestingChildren( SvTreeListEntry* pFileEntry )
     651             : {
     652           0 :     if( !pFileEntry->HasChildren() )
     653             :     {
     654           0 :         if( GetBookmarkDoc() )
     655             :         {
     656           0 :             SdrObject*   pObj = NULL;
     657           0 :             SdPage*      pPage = NULL;
     658           0 :             SvTreeListEntry* pPageEntry = NULL;
     659             : 
     660           0 :             Image aImgPage     = Image( BitmapEx( SdResId( BMP_PAGE     ) ) );
     661           0 :             Image aImgPageObjs = Image( BitmapEx( SdResId( BMP_PAGEOBJS ) ) );
     662           0 :             Image aImgObjects  = Image( BitmapEx( SdResId( BMP_OBJECTS  ) ) );
     663             : 
     664             :             // document name already inserted
     665             : 
     666             :             // only insert all "normal" ? slides with objects
     667           0 :             sal_uInt16 nPage = 0;
     668           0 :             const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount();
     669             : 
     670           0 :             while( nPage < nMaxPages )
     671             :             {
     672           0 :                 pPage = (SdPage*) mpBookmarkDoc->GetPage( nPage );
     673           0 :                 if( pPage->GetPageKind() == PK_STANDARD )
     674             :                 {
     675           0 :                     pPageEntry = InsertEntry( pPage->GetName(),
     676             :                                               aImgPage,
     677             :                                               aImgPage,
     678             :                                               pFileEntry,
     679             :                                               sal_False,
     680             :                                               LIST_APPEND,
     681           0 :                                               reinterpret_cast< void* >( 1 ) );
     682             : 
     683           0 :                     SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
     684             : 
     685           0 :                     while( aIter.IsMore() )
     686             :                     {
     687           0 :                         pObj = aIter.Next();
     688           0 :                         String aStr( GetObjectName( pObj ) );
     689           0 :                         if( aStr.Len() )
     690             :                         {
     691           0 :                             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
     692             :                             {
     693           0 :                                 InsertEntry(aStr, maImgOle, maImgOle, pPageEntry);
     694             :                             }
     695           0 :                             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
     696             :                             {
     697           0 :                                 InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry);
     698             :                             }
     699             :                             else
     700             :                             {
     701           0 :                                 InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry);
     702             :                             }
     703             :                         }
     704           0 :                     }
     705           0 :                     if( pPageEntry->HasChildren() )
     706             :                     {
     707           0 :                         SetExpandedEntryBmp(  pPageEntry, aImgPageObjs );
     708           0 :                         SetCollapsedEntryBmp( pPageEntry, aImgPageObjs );
     709           0 :                     }
     710             :                 }
     711           0 :                 nPage++;
     712           0 :             }
     713             :         }
     714             :     }
     715             :     else
     716           0 :         SvTreeListBox::RequestingChildren( pFileEntry );
     717           0 : }
     718             : 
     719             : /**
     720             :  * Checks if it is a draw file and opens the BookmarkDoc depending of
     721             :  * the provided Docs
     722             :  */
     723           0 : SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed)
     724             : {
     725           0 :     if (
     726           0 :        !mpBookmarkDoc ||
     727           0 :          (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName()))
     728             :       )
     729             :     {
     730             :         // create a new BookmarkDoc if now one exists or if a new Medium is provided
     731           0 :         if (mpOwnMedium != pMed)
     732             :         {
     733           0 :             CloseBookmarkDoc();
     734             :         }
     735             : 
     736           0 :         if (pMed)
     737             :         {
     738             :             // it looks that it is undefined if a Medium was set by Fill() already
     739             :             DBG_ASSERT( !mpMedium, "SfxMedium confusion!" );
     740           0 :             delete mpMedium;
     741           0 :             mpMedium = NULL;
     742             : 
     743             :             // take over this Medium (currently used only be Navigator)
     744           0 :             mpOwnMedium = pMed;
     745             :         }
     746             : 
     747             :         DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" );
     748             : 
     749           0 :         if( pMed )
     750             :         {
     751             :             // in this mode the document is also owned and controlled by this instance
     752           0 :             mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
     753           0 :             if (mxBookmarkDocShRef->DoLoad(pMed))
     754           0 :                 mpBookmarkDoc = mxBookmarkDocShRef->GetDoc();
     755             :             else
     756           0 :                 mpBookmarkDoc = NULL;
     757             :         }
     758           0 :         else if ( mpMedium )
     759             :             // in this mode the document is owned and controlled by the SdDrawDocument
     760             :             // it can be released by calling the corresponding CloseBookmarkDoc method
     761             :             // successful creation of a document makes this the owner of the medium
     762           0 :             mpBookmarkDoc = ((SdDrawDocument*) mpDoc)->OpenBookmarkDoc(*mpMedium);
     763             : 
     764           0 :         if ( !mpBookmarkDoc )
     765             :         {
     766           0 :             ErrorBox aErrorBox( this, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
     767           0 :             aErrorBox.Execute();
     768           0 :             mpMedium = 0; //On failure the SfxMedium is invalid
     769             :         }
     770             :     }
     771             : 
     772           0 :     return( mpBookmarkDoc );
     773             : }
     774             : 
     775             : /**
     776             :  * Close and delete bookmark document
     777             :  */
     778           0 : void SdPageObjsTLB::CloseBookmarkDoc()
     779             : {
     780           0 :     if (mxBookmarkDocShRef.Is())
     781             :     {
     782           0 :         mxBookmarkDocShRef->DoClose();
     783           0 :         mxBookmarkDocShRef.Clear();
     784             : 
     785             :         // Medium is owned by document, so it's destroyed already
     786           0 :         mpOwnMedium = 0;
     787             :     }
     788           0 :     else if ( mpBookmarkDoc )
     789             :     {
     790             :         DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" );
     791           0 :         if ( mpDoc )
     792             :         {
     793             :             // The document owns the Medium, so the Medium will be invalid after closing the document
     794           0 :             ((SdDrawDocument*) mpDoc)->CloseBookmarkDoc();
     795           0 :             mpMedium = 0;
     796             :         }
     797             :     }
     798             :     else
     799             :     {
     800             :         // perhaps mpOwnMedium provided, but no successful creation of BookmarkDoc
     801           0 :         delete mpOwnMedium;
     802           0 :         mpOwnMedium = NULL;
     803             :     }
     804             : 
     805           0 :     mpBookmarkDoc = NULL;
     806           0 : }
     807             : 
     808           0 : void SdPageObjsTLB::SelectHdl()
     809             : {
     810           0 :     SvTreeListEntry* pEntry = FirstSelected();
     811             : 
     812           0 :     mbLinkableSelected = sal_True;
     813             : 
     814           0 :     while( pEntry && mbLinkableSelected )
     815             :     {
     816           0 :         if( NULL == pEntry->GetUserData() )
     817           0 :             mbLinkableSelected = sal_False;
     818             : 
     819           0 :         pEntry = NextSelected( pEntry );
     820             :     }
     821             : 
     822           0 :     SvTreeListBox::SelectHdl();
     823           0 : }
     824             : 
     825             : /**
     826             :  * Overloads RETURN with the functionality of DoubleClick
     827             :  */
     828           0 : void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
     829             : {
     830           0 :     if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
     831             :     {
     832             :         // commented code from svtools/source/contnr/svimpbox.cxx
     833           0 :         SvTreeListEntry* pCursor = GetCurEntry();
     834           0 :         if( pCursor->HasChildren() || pCursor->HasChildrenOnDemand() )
     835             :         {
     836           0 :             if( IsExpanded( pCursor ) )
     837           0 :                 Collapse( pCursor );
     838             :             else
     839           0 :                 Expand( pCursor );
     840             :         }
     841             : 
     842           0 :         DoubleClickHdl();
     843             :     }
     844             :     else
     845           0 :         SvTreeListBox::KeyInput( rKEvt );
     846           0 : }
     847             : 
     848             : /**
     849             :  * StartDrag-Request
     850             :  */
     851           0 : void SdPageObjsTLB::StartDrag( sal_Int8 nAction, const Point& rPosPixel)
     852             : {
     853             :     (void)nAction;
     854             :     (void)rPosPixel;
     855             : 
     856           0 :     SdNavigatorWin* pNavWin = NULL;
     857           0 :     SvTreeListEntry* pEntry = GetEntry(rPosPixel);
     858             : 
     859           0 :     if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
     860           0 :         pNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
     861             : 
     862           0 :     if (pEntry != NULL
     863           0 :         && pNavWin !=NULL
     864           0 :         && pNavWin == mpParent
     865           0 :         && pNavWin->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE )
     866             :     {
     867             :         // Mark only the children of the page under the mouse as drop
     868             :         // targets.  This prevents moving shapes from one page to another.
     869             : 
     870             :         // Select all entries and disable them as drop targets.
     871           0 :         SetSelectionMode(MULTIPLE_SELECTION);
     872           0 :         SetCursor(NULL, sal_False);
     873           0 :         SelectAll(sal_True, sal_False);
     874           0 :         EnableSelectionAsDropTarget(sal_False, sal_True);
     875             : 
     876             :         // Enable only the entries as drop targets that are children of the
     877             :         // page under the mouse.
     878           0 :         SvTreeListEntry* pParent = GetRootLevelParent(pEntry);
     879           0 :         if (pParent != NULL)
     880             :         {
     881           0 :             SelectAll(sal_False, sal_False);
     882           0 :             Select(pParent, sal_True);
     883             :             //            for (SvTreeListEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild))
     884             :             //                Select(pChild, sal_True);
     885           0 :             EnableSelectionAsDropTarget(sal_True, sal_True);//sal_False);
     886             :         }
     887             : 
     888             :         // Set selection back to the entry under the mouse.
     889           0 :         SelectAll(sal_False,sal_False);
     890           0 :         SetSelectionMode(SINGLE_SELECTION);
     891           0 :         Select(pEntry, sal_True);
     892             : 
     893             :         // We can delete the Navigator from ExecuteDrag (when switching to
     894             :         // another document type), but that would kill the StarView MouseMove
     895             :         // Handler which is calling Command().
     896             :         // For this reason, Drag&Drop is asynchronous.
     897           0 :         Application::PostUserEvent( STATIC_LINK( this, SdPageObjsTLB, ExecDragHdl ) );
     898             :     }
     899           0 : }
     900             : 
     901             : /**
     902             :  * Begin drag
     903             :  */
     904           0 : void SdPageObjsTLB::DoDrag()
     905             : {
     906           0 :     mpDropNavWin = ( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) ?
     907           0 :                   (SdNavigatorWin*)( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ) :
     908           0 :                   NULL;
     909             : 
     910           0 :     if( mpDropNavWin )
     911             :     {
     912           0 :         ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
     913           0 :         String aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INET_PROT_FILE ).GetMainURL( INetURLObject::NO_DECODE );
     914           0 :         NavigatorDragType   eDragType = mpDropNavWin->GetNavigatorDragType();
     915             : 
     916           0 :         aURL.Append( '#' );
     917           0 :         aURL.Append( GetSelectEntry() );
     918             : 
     919           0 :         INetBookmark    aBookmark( aURL, GetSelectEntry() );
     920           0 :         sal_Int8        nDNDActions = DND_ACTION_COPYMOVE;
     921             : 
     922           0 :         if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
     923           0 :             nDNDActions = DND_ACTION_LINK;  // Either COPY *or* LINK, never both!
     924           0 :         else if (mpDoc->GetSdPageCount(PK_STANDARD) == 1)
     925             :         {
     926             :             // Can not move away the last slide in a document.
     927           0 :             nDNDActions = DND_ACTION_COPY;
     928             :         }
     929             : 
     930           0 :         SvTreeListBox::ReleaseMouse();
     931             : 
     932           0 :         bIsInDrag = sal_True;
     933             : 
     934             :         SvLBoxDDInfo aDDInfo;
     935           0 :         memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
     936           0 :         aDDInfo.pApp = GetpApp();
     937           0 :         aDDInfo.pSource = this;
     938             :         //            aDDInfo.pDDStartEntry = pEntry;
     939           0 :         ::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo));
     940           0 :         memcpy(aSequence.getArray(), (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo));
     941           0 :         ::com::sun::star::uno::Any aTreeListBoxData (aSequence);
     942             : 
     943             :         // object is destroyed by internal reference mechanism
     944             :         SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable(
     945           0 :             *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData);
     946             : 
     947             :         // Get the view.
     948           0 :         ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
     949           0 :         if (pViewShell == NULL)
     950             :         {
     951             :             OSL_ASSERT(pViewShell!=NULL);
     952           0 :             return;
     953             :         }
     954           0 :         sd::View* pView = pViewShell->GetView();
     955           0 :         if (pView == NULL)
     956             :         {
     957             :             OSL_ASSERT(pView!=NULL);
     958           0 :             return;
     959             :         }
     960             : 
     961           0 :         SdrObject* pObject = NULL;
     962           0 :         void* pUserData = GetCurEntry()->GetUserData();
     963           0 :         if (pUserData != NULL && pUserData != (void*)1)
     964           0 :             pObject = reinterpret_cast<SdrObject*>(pUserData);
     965           0 :         if (pObject != NULL)
     966             :         {
     967             :             // For shapes without a user supplied name (the automatically
     968             :             // created name does not count), a different drag and drop technique
     969             :             // is used.
     970           0 :             if (GetObjectName(pObject, false).Len() == 0)
     971             :             {
     972           0 :                 AddShapeToTransferable(*pTransferable, *pObject);
     973           0 :                 pTransferable->SetView(pView);
     974           0 :                 SD_MOD()->pTransferDrag = pTransferable;
     975             :             }
     976             : 
     977             :             // Unnamed shapes have to be selected to be recognized by the
     978             :             // current drop implementation.  In order to have a consistent
     979             :             // behaviour for all shapes, every shape that is to be dragged is
     980             :             // selected first.
     981           0 :             SdrPageView* pPageView = pView->GetSdrPageView();
     982           0 :             pView->UnmarkAllObj(pPageView);
     983           0 :             pView->MarkObj(pObject, pPageView);
     984             :         }
     985             :         else
     986             :         {
     987           0 :             pTransferable->SetView(pView);
     988           0 :             SD_MOD()->pTransferDrag = pTransferable;
     989             :         }
     990             : 
     991           0 :         pTransferable->StartDrag( this, nDNDActions );
     992             :     }
     993             : }
     994             : 
     995           0 : void SdPageObjsTLB::OnDragFinished( sal_uInt8 )
     996             : {
     997           0 :     if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
     998             :     {
     999           0 :         SdNavigatorWin* pNewNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
    1000             : 
    1001           0 :         if( mpDropNavWin == pNewNavWin)
    1002             :         {
    1003           0 :             MouseEvent aMEvt( mpDropNavWin->GetPointerPosPixel() );
    1004           0 :             SvTreeListBox::MouseButtonUp( aMEvt );
    1005             :         }
    1006             :     }
    1007             : 
    1008           0 :     mpDropNavWin = NULL;
    1009           0 :     bIsInDrag = sal_False;
    1010           0 : }
    1011             : 
    1012             : /**
    1013             :  * AcceptDrop-Event
    1014             :  */
    1015           0 : sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent)
    1016             : {
    1017           0 :     sal_Int8 nResult (DND_ACTION_NONE);
    1018             : 
    1019           0 :     if ( !bIsInDrag && IsDropFormatSupported( FORMAT_FILE ) )
    1020             :     {
    1021           0 :         nResult = rEvent.mnAction;
    1022             :     }
    1023             :     else
    1024             :     {
    1025           0 :         SvTreeListEntry* pEntry = GetDropTarget(rEvent.maPosPixel);
    1026           0 :         if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction ))
    1027             :         {
    1028           0 :             ImplShowTargetEmphasis( pTargetEntry, sal_False );
    1029             :         }
    1030           0 :         else if( !GetDragDropMode() )
    1031             :         {
    1032             :             SAL_WARN( "sc.ui", "SdPageObjsTLB::AcceptDrop(): no target" );
    1033             :         }
    1034           0 :         else if (IsDropAllowed(pEntry))
    1035             :         {
    1036           0 :             nResult = DND_ACTION_MOVE;
    1037             : 
    1038             :             // Draw emphasis.
    1039           0 :             if (pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS))
    1040             :             {
    1041           0 :                 ImplShowTargetEmphasis( pTargetEntry, sal_False );
    1042           0 :                 pTargetEntry = pEntry;
    1043           0 :                 ImplShowTargetEmphasis( pTargetEntry, sal_True );
    1044             :             }
    1045             :         }
    1046             :     }
    1047             : 
    1048             :     // Hide emphasis when there is no valid drop action.
    1049           0 :     if (nResult == DND_ACTION_NONE)
    1050           0 :         ImplShowTargetEmphasis(pTargetEntry, sal_False);
    1051             : 
    1052           0 :     return nResult;
    1053             : }
    1054             : 
    1055             : /**
    1056             :  * ExecuteDrop-Event
    1057             :  */
    1058           0 : sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt )
    1059             : {
    1060           0 :     sal_Int8 nRet = DND_ACTION_NONE;
    1061             : 
    1062             :     try
    1063             :     {
    1064           0 :         if( !bIsInDrag )
    1065             :         {
    1066           0 :             SdNavigatorWin* pNavWin = NULL;
    1067           0 :             sal_uInt16          nId = SID_NAVIGATOR;
    1068             : 
    1069           0 :             if( mpFrame->HasChildWindow( nId ) )
    1070           0 :                 pNavWin = (SdNavigatorWin*)( mpFrame->GetChildWindow( nId )->GetContextWindow( SD_MOD() ) );
    1071             : 
    1072           0 :             if( pNavWin && ( pNavWin == mpParent ) )
    1073             :             {
    1074           0 :                 TransferableDataHelper  aDataHelper( rEvt.maDropEvent.Transferable );
    1075           0 :                 String                  aFile;
    1076             : 
    1077           0 :                 if( aDataHelper.GetString( FORMAT_FILE, aFile ) &&
    1078           0 :                     ( (SdNavigatorWin*) mpParent)->InsertFile( aFile ) )
    1079             :                 {
    1080           0 :                     nRet = rEvt.mnAction;
    1081           0 :                 }
    1082             :             }
    1083             :         }
    1084             :     }
    1085           0 :     catch (com::sun::star::uno::Exception&)
    1086             :     {
    1087             :         DBG_UNHANDLED_EXCEPTION();
    1088             :     }
    1089             : 
    1090           0 :     if (nRet == DND_ACTION_NONE)
    1091           0 :         SvTreeListBox::ExecuteDrop(rEvt, this);
    1092             : 
    1093             : 
    1094           0 :     return nRet;
    1095             : }
    1096             : 
    1097             : /**
    1098             :  * Handler for Dragging
    1099             :  */
    1100           0 : IMPL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*, EMPTYARG)
    1101             : {
    1102             :     // as link, then it is allowed to asynchronous, without ImpMouseMoveMsg on
    1103             :     // the stack, delete the Navigator
    1104           0 :     pThis->DoDrag();
    1105           0 :     return 0;
    1106             : }
    1107             : 
    1108             : 
    1109           0 : bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
    1110             : {
    1111             :     // Return <TRUE/> as default when there is no custom show or when none
    1112             :     // is used.  The page does then belong to the standard show.
    1113           0 :     bool bBelongsToShow = true;
    1114             : 
    1115           0 :     if (mpDoc->getPresentationSettings().mbCustomShow)
    1116             :     {
    1117             :         // Get the current custom show.
    1118           0 :         SdCustomShow* pCustomShow = NULL;
    1119           0 :         SdCustomShowList* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList();
    1120           0 :         if (pShowList != NULL)
    1121             :         {
    1122           0 :             sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
    1123           0 :             pCustomShow = (*pShowList)[nCurrentShowIndex];
    1124             :         }
    1125             : 
    1126             :         // Check whether the given page is part of that custom show.
    1127           0 :         if (pCustomShow != NULL)
    1128             :         {
    1129           0 :             bBelongsToShow = false;
    1130           0 :             sal_uLong nPageCount = pCustomShow->PagesVector().size();
    1131           0 :             for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++)
    1132           0 :                 if (pPage == pCustomShow->PagesVector()[i])
    1133           0 :                     bBelongsToShow = true;
    1134             :         }
    1135             :     }
    1136             : 
    1137           0 :     return bBelongsToShow;
    1138             : }
    1139             : 
    1140             : 
    1141             : 
    1142             : 
    1143           0 : sal_Bool SdPageObjsTLB::NotifyMoving(
    1144             :     SvTreeListEntry* pTarget,
    1145             :     SvTreeListEntry* pEntry,
    1146             :     SvTreeListEntry*& rpNewParent,
    1147             :     sal_uLong& rNewChildPos)
    1148             : {
    1149           0 :     SvTreeListEntry* pDestination = pTarget;
    1150           0 :     while (GetParent(pDestination) != NULL && GetParent(GetParent(pDestination)) != NULL)
    1151           0 :         pDestination = GetParent(pDestination);
    1152             : 
    1153           0 :     SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(pDestination->GetUserData());
    1154           0 :     SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(pEntry->GetUserData());
    1155           0 :     if (pSourceObject == reinterpret_cast<SdrObject*>(1))
    1156           0 :         pSourceObject = NULL;
    1157             : 
    1158           0 :     if (pTargetObject != NULL && pSourceObject != NULL)
    1159             :     {
    1160           0 :         SdrPage* pObjectList = pSourceObject->GetPage();
    1161           0 :         if (pObjectList != NULL)
    1162             :         {
    1163             :             sal_uInt32 nNewPosition;
    1164           0 :             if (pTargetObject == reinterpret_cast<SdrObject*>(1))
    1165           0 :                 nNewPosition = 0;
    1166             :             else
    1167           0 :                 nNewPosition = pTargetObject->GetNavigationPosition() + 1;
    1168           0 :             pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition);
    1169             :         }
    1170             : 
    1171             :         // Update the tree list.
    1172           0 :         if (pTarget == NULL)
    1173             :         {
    1174           0 :             rpNewParent = 0;
    1175           0 :             rNewChildPos = 0;
    1176           0 :             return sal_True;
    1177             :         }
    1178           0 :         else if (GetParent(pDestination) == NULL)
    1179             :         {
    1180           0 :             rpNewParent = pDestination;
    1181           0 :             rNewChildPos = 0;
    1182             :         }
    1183             :         else
    1184             :         {
    1185           0 :             rpNewParent = GetParent(pDestination);
    1186           0 :             rNewChildPos = pModel->GetRelPos(pDestination) + 1;
    1187           0 :             rNewChildPos += nCurEntrySelPos;
    1188           0 :             nCurEntrySelPos++;
    1189             :         }
    1190           0 :         return sal_True;
    1191             :     }
    1192             :     else
    1193           0 :         return sal_False;
    1194             : }
    1195             : 
    1196             : 
    1197             : 
    1198             : 
    1199           0 : SvTreeListEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation)
    1200             : {
    1201           0 :     SvTreeListEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation);
    1202           0 :     if (pEntry == NULL)
    1203           0 :         return NULL;
    1204             : 
    1205           0 :     if (GetParent(pEntry) == NULL)
    1206             :     {
    1207             :         // Use page entry as insertion position.
    1208             :     }
    1209             :     else
    1210             :     {
    1211             :         // Go to second hierarchy level, i.e. top level shapes,
    1212             :         // i.e. children of pages.
    1213           0 :         while (GetParent(pEntry) != NULL && GetParent(GetParent(pEntry)) != NULL)
    1214           0 :             pEntry = GetParent(pEntry);
    1215             : 
    1216             :         // Advance to next sibling.
    1217             :         SvTreeListEntry* pNext;
    1218           0 :         sal_uInt16 nDepth (0);
    1219           0 :         while (pEntry != NULL)
    1220             :         {
    1221           0 :             pNext = dynamic_cast<SvTreeListEntry*>(NextVisible(pEntry, &nDepth));
    1222           0 :             if (pNext != NULL && nDepth > 0 && nDepth!=0xffff)
    1223           0 :                 pEntry = pNext;
    1224             :             else
    1225             :                 break;
    1226             :         }
    1227             :     }
    1228             : 
    1229           0 :     return pEntry;
    1230             : }
    1231             : 
    1232             : 
    1233             : 
    1234             : 
    1235           0 : bool SdPageObjsTLB::IsDropAllowed (SvTreeListEntry* pEntry)
    1236             : {
    1237           0 :     if (pEntry == NULL)
    1238           0 :         return false;
    1239             : 
    1240           0 :     if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId()))
    1241           0 :         return false;
    1242             : 
    1243           0 :     if ((pEntry->GetFlags() & SV_ENTRYFLAG_DISABLE_DROP) != 0)
    1244           0 :         return false;
    1245             : 
    1246           0 :     return true;
    1247             : }
    1248             : 
    1249             : 
    1250             : 
    1251             : 
    1252           0 : void SdPageObjsTLB::AddShapeToTransferable (
    1253             :     SdTransferable& rTransferable,
    1254             :     SdrObject& rObject) const
    1255             : {
    1256           0 :     TransferableObjectDescriptor aObjectDescriptor;
    1257           0 :     bool bIsDescriptorFillingPending (true);
    1258             : 
    1259           0 :     const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
    1260           0 :     if (pOleObject != NULL && pOleObject->GetObjRef().is())
    1261             :     {
    1262             :         // If object has no persistence it must be copied as part of the document
    1263             :         try
    1264             :         {
    1265           0 :             uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY );
    1266           0 :             if (xPersObj.is() && xPersObj->hasEntry())
    1267             :             {
    1268             :                 SvEmbedTransferHelper::FillTransferableObjectDescriptor(
    1269             :                     aObjectDescriptor,
    1270             :                     pOleObject->GetObjRef(),
    1271             :                     pOleObject->GetGraphic(),
    1272           0 :                     pOleObject->GetAspect());
    1273           0 :                 bIsDescriptorFillingPending = false;
    1274           0 :             }
    1275             :         }
    1276           0 :         catch( uno::Exception& )
    1277             :         {
    1278             :         }
    1279             :     }
    1280             : 
    1281           0 :     ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
    1282           0 :     if (bIsDescriptorFillingPending && pDocShell!=NULL)
    1283             :     {
    1284           0 :         pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor);
    1285             :     }
    1286             : 
    1287           0 :     Point aDragPos (rObject.GetCurrentBoundRect().Center());
    1288             :     //Point aDragPos (0,0);
    1289           0 :     aObjectDescriptor.maDragStartPos = aDragPos;
    1290             :     //  aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
    1291           0 :     if (pDocShell != NULL)
    1292           0 :         aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
    1293             :     else
    1294           0 :         aObjectDescriptor.maDisplayName = String();
    1295           0 :     aObjectDescriptor.mbCanLink = sal_False;
    1296             : 
    1297           0 :     rTransferable.SetStartPos(aDragPos);
    1298           0 :     rTransferable.SetObjectDescriptor( aObjectDescriptor );
    1299           0 : }
    1300             : 
    1301             : 
    1302             : 
    1303             : 
    1304           0 : ::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
    1305             : {
    1306             :     {
    1307           0 :         ::sd::ViewShell* pViewShell = rDocShell.GetViewShell();
    1308           0 :         if (pViewShell != NULL)
    1309           0 :             return pViewShell;
    1310             :     }
    1311             : 
    1312             :     try
    1313             :     {
    1314             :         // Get a component enumeration from the desktop and search it for documents.
    1315           0 :         uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext());
    1316             : 
    1317           0 :         uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
    1318             : 
    1319           0 :         uno::Reference<frame::XFramesSupplier> xFrameSupplier (xDesktop, uno::UNO_QUERY);
    1320           0 :         if ( ! xFrameSupplier.is())
    1321           0 :             return NULL;
    1322             : 
    1323           0 :         uno::Reference<container::XIndexAccess> xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY);
    1324           0 :         if ( ! xFrameAccess.is())
    1325           0 :             return NULL;
    1326             : 
    1327           0 :         for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex)
    1328             :         {
    1329           0 :             uno::Reference<frame::XFrame> xFrame;
    1330           0 :             if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame))
    1331           0 :                 continue;
    1332             : 
    1333           0 :             ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get());
    1334           0 :             if (pController == NULL)
    1335           0 :                 continue;
    1336           0 :             ::sd::ViewShellBase* pBase = pController->GetViewShellBase();
    1337           0 :             if (pBase == NULL)
    1338           0 :                 continue;
    1339           0 :             if (pBase->GetDocShell() != &rDocShell)
    1340           0 :                 continue;
    1341             : 
    1342           0 :             const ::boost::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell());
    1343           0 :             if (pViewShell)
    1344           0 :                 return pViewShell.get();
    1345           0 :         }
    1346             :     }
    1347           0 :     catch (uno::Exception &)
    1348             :     {
    1349             :         // When there is an exception then simply use the default value of
    1350             :         // bIsEnabled and disable the controls.
    1351             :     }
    1352           0 :     return NULL;
    1353             : }
    1354             : 
    1355             : 
    1356             : 
    1357             : 
    1358             : //===== IconProvider ==========================================================
    1359             : 
    1360           0 : SdPageObjsTLB::IconProvider::IconProvider (void)
    1361             :     : maImgPage( BitmapEx( SdResId( BMP_PAGE ) ) ),
    1362             :       maImgPageExcl( BitmapEx( SdResId( BMP_PAGE_EXCLUDED ) ) ),
    1363             :       maImgPageObjsExcl( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED ) ) ),
    1364             :       maImgPageObjs( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ),
    1365             :       maImgObjects( BitmapEx( SdResId( BMP_OBJECTS ) ) ),
    1366           0 :       maImgGroup( BitmapEx( SdResId( BMP_GROUP ) ) )
    1367             : {
    1368          33 : }
    1369             : 
    1370             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10