LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - sdtreelb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 551 0.2 %
Date: 2012-12-17 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/XDesktop.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 SD_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(rtl::OUString(
     212           0 :         "application/x-openoffice-treelistbox-moveonly;windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\""));
     213           0 :     return mnListBoxDropFormatId;
     214             : }
     215             : 
     216             : 
     217             : 
     218             : 
     219             : /*************************************************************************
     220             : |*
     221             : |* Ctor1 SdPageObjsTLB
     222             : |*
     223             : \************************************************************************/
     224             : 
     225           0 : SdPageObjsTLB::SdPageObjsTLB( Window* pParentWin, const SdResId& rSdResId )
     226             : :   SvTreeListBox       ( pParentWin, rSdResId )
     227             : ,   mpParent            ( pParentWin )
     228             : ,   mpDoc               ( NULL )
     229             : ,   mpBookmarkDoc       ( NULL )
     230             : ,   mpMedium            ( NULL )
     231             : ,   mpOwnMedium         ( NULL )
     232             : ,   maImgOle             ( BitmapEx( SdResId( BMP_OLE ) ) )
     233             : ,   maImgGraphic         ( BitmapEx( SdResId( BMP_GRAPHIC ) ) )
     234             : ,   mbLinkableSelected  ( sal_False )
     235             : ,   mpDropNavWin        ( NULL )
     236             : ,   mbShowAllShapes     ( false )
     237           0 : ,   mbShowAllPages      ( false )
     238             : 
     239             : {
     240             :     // Tree-ListBox mit Linien versehen
     241           0 :     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
     242             :                            WB_HASBUTTONS | // WB_HASLINESATROOT |
     243             :                            WB_HSCROLL |
     244             :                            WB_HASBUTTONSATROOT |
     245           0 :                            WB_QUICK_SEARCH /* i31275 */ );
     246             :     SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND ) ),
     247           0 :                     Bitmap( SdResId( BMP_COLLAPSE ) ) );
     248             : 
     249             :     SetDragDropMode(
     250             :          SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY |
     251           0 :             SV_DRAGDROP_APP_MOVE  | SV_DRAGDROP_APP_COPY  | SV_DRAGDROP_APP_DROP );
     252           0 : }
     253             : 
     254             : /*************************************************************************
     255             : |*
     256             : |* Dtor SdPageObjsTLB
     257             : |*
     258             : \************************************************************************/
     259             : 
     260           0 : SdPageObjsTLB::~SdPageObjsTLB()
     261             : {
     262           0 :     if ( mpBookmarkDoc )
     263           0 :         CloseBookmarkDoc();
     264             :     else
     265             :         // no document was created from mpMedium, so this object is still the owner of it
     266           0 :         delete mpMedium;
     267           0 : }
     268             : 
     269             : /*************************************************************************
     270             : |*
     271             : |* return name of object
     272             : |*
     273             : \************************************************************************/
     274             : 
     275           0 : String SdPageObjsTLB::GetObjectName(
     276             :     const SdrObject* pObject,
     277             :     const bool bCreate) const
     278             : {
     279           0 :     String aRet;
     280             : 
     281           0 :     if ( pObject )
     282             :     {
     283           0 :         aRet = pObject->GetName();
     284             : 
     285           0 :         if( !aRet.Len() && pObject->ISA( SdrOle2Obj ) )
     286           0 :             aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
     287             :     }
     288             : 
     289           0 :     if (bCreate
     290             :         && mbShowAllShapes
     291           0 :         && aRet.Len() == 0
     292             :         && pObject!=NULL)
     293             :     {
     294           0 :         aRet = SD_RESSTR(STR_NAVIGATOR_SHAPE_BASE_NAME);
     295           0 :         aRet.SearchAndReplaceAscii("%1", String::CreateFromInt32(pObject->GetOrdNum() + 1));
     296             :     }
     297             : 
     298           0 :     return aRet;
     299             : }
     300             : 
     301             : /*************************************************************************
     302             : |*
     303             : |* In TreeLB Eintrag selektieren
     304             : |*
     305             : \************************************************************************/
     306             : 
     307           0 : sal_Bool SdPageObjsTLB::SelectEntry( const String& rName )
     308             : {
     309           0 :     sal_Bool bFound = sal_False;
     310             : 
     311           0 :     if( rName.Len() )
     312             :     {
     313           0 :         SvTreeListEntry* pEntry = NULL;
     314           0 :         String aTmp;
     315             : 
     316           0 :         for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
     317             :         {
     318           0 :             aTmp = GetEntryText( pEntry );
     319           0 :             if( aTmp == rName )
     320             :             {
     321           0 :                 bFound = sal_True;
     322           0 :                 SetCurEntry( pEntry );
     323             :             }
     324           0 :         }
     325             :     }
     326           0 :     return( bFound );
     327             : }
     328             : 
     329             : /*************************************************************************
     330             : |*
     331             : |* Gibt zurueck, ob Children des uebergebenen Strings selektiert sind
     332             : |*
     333             : \************************************************************************/
     334             : 
     335           0 : sal_Bool SdPageObjsTLB::HasSelectedChildren( const String& rName )
     336             : {
     337           0 :     sal_Bool bFound  = sal_False;
     338           0 :     sal_Bool bChildren = sal_False;
     339             : 
     340           0 :     if( rName.Len() )
     341             :     {
     342           0 :         SvTreeListEntry* pEntry = NULL;
     343           0 :         String aTmp;
     344             : 
     345           0 :         for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
     346             :         {
     347           0 :             aTmp = GetEntryText( pEntry );
     348           0 :             if( aTmp == rName )
     349             :             {
     350           0 :                 bFound = sal_True;
     351           0 :                 sal_Bool bExpanded = IsExpanded( pEntry );
     352           0 :                 long nCount = GetChildSelectionCount( pEntry );
     353           0 :                 if( bExpanded && nCount > 0 )
     354           0 :                     bChildren = sal_True;
     355             :             }
     356           0 :         }
     357             :     }
     358           0 :     return( bChildren );
     359             : }
     360             : 
     361             : 
     362             : /*************************************************************************
     363             : |*
     364             : |* TreeLB mit Seiten und Objekten fuellen
     365             : |*
     366             : \************************************************************************/
     367             : 
     368           0 : void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, sal_Bool bAllPages,
     369             :                           const String& rDocName)
     370             : {
     371           0 :     String aSelection;
     372           0 :     if( GetSelectionCount() > 0 )
     373             :     {
     374           0 :         aSelection = GetSelectEntry();
     375           0 :         Clear();
     376             :     }
     377             : 
     378           0 :     mpDoc = pInDoc;
     379           0 :     maDocName = rDocName;
     380           0 :     mbShowAllPages = (bAllPages == sal_True);
     381           0 :     mpMedium = NULL;
     382             : 
     383           0 :     SdPage*      pPage = NULL;
     384             : 
     385           0 :     IconProvider aIconProvider;
     386             : 
     387             :     // first insert all pages including objects
     388           0 :     sal_uInt16 nPage = 0;
     389           0 :     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
     390             : 
     391           0 :     while( nPage < nMaxPages )
     392             :     {
     393           0 :         pPage = (SdPage*) mpDoc->GetPage( nPage );
     394           0 :         if(  (mbShowAllPages || pPage->GetPageKind() == PK_STANDARD)
     395           0 :              && !(pPage->GetPageKind()==PK_HANDOUT)   ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
     396             :         {
     397           0 :             sal_Bool bPageExluded = pPage->IsExcluded();
     398             : 
     399           0 :             bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
     400           0 :             bPageExluded |= !bPageBelongsToShow;
     401             : 
     402           0 :             AddShapeList(*pPage, NULL, pPage->GetName(), bPageExluded, NULL, aIconProvider);
     403             :         }
     404           0 :         nPage++;
     405             :     }
     406             : 
     407             :     // dann alle MasterPages incl. Objekte einfuegen
     408           0 :     if( mbShowAllPages )
     409             :     {
     410           0 :         nPage = 0;
     411           0 :         const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
     412             : 
     413           0 :         while( nPage < nMaxMasterPages )
     414             :         {
     415           0 :             pPage = (SdPage*) mpDoc->GetMasterPage( nPage );
     416           0 :             AddShapeList(*pPage, NULL, pPage->GetName(), false, NULL, aIconProvider);
     417           0 :             nPage++;
     418             :         }
     419             :     }
     420           0 :     if( aSelection.Len() )
     421           0 :         SelectEntry( aSelection );
     422           0 : }
     423             : 
     424             : /*************************************************************************
     425             : |*
     426             : |* Es wird nur der erste Eintrag eingefuegt. Children werden OnDemand erzeugt
     427             : |*
     428             : \************************************************************************/
     429             : 
     430           0 : void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
     431             :                           const String& rDocName )
     432             : {
     433           0 :     mpDoc = pInDoc;
     434             : 
     435             :     // this object now owns the Medium
     436           0 :     mpMedium = pInMedium;
     437           0 :     maDocName = rDocName;
     438             : 
     439           0 :     Image aImgDocOpen=Image( BitmapEx( SdResId( BMP_DOC_OPEN ) ) );
     440           0 :     Image aImgDocClosed=Image( BitmapEx( SdResId( BMP_DOC_CLOSED ) ) );
     441             : 
     442             :     // Dokumentnamen einfuegen
     443             :     InsertEntry( maDocName, aImgDocOpen, aImgDocClosed, NULL, sal_True, LIST_APPEND,
     444             :                  reinterpret_cast< void* >( 1 )
     445           0 :     );
     446           0 : }
     447             : 
     448             : 
     449             : 
     450             : 
     451           0 : void SdPageObjsTLB::AddShapeList (
     452             :     const SdrObjList& rList,
     453             :     SdrObject* pShape,
     454             :     const ::rtl::OUString& rsName,
     455             :     const bool bIsExcluded,
     456             :     SvTreeListEntry* pParentEntry,
     457             :     const IconProvider& rIconProvider)
     458             : {
     459           0 :     Image aIcon (rIconProvider.maImgPage);
     460           0 :     if (bIsExcluded)
     461           0 :         aIcon = rIconProvider.maImgPageExcl;
     462           0 :     else if (pShape != NULL)
     463           0 :         aIcon = rIconProvider.maImgGroup;
     464             : 
     465           0 :     void* pUserData (reinterpret_cast<void*>(1));
     466           0 :     if (pShape != NULL)
     467           0 :         pUserData = pShape;
     468             : 
     469             :     SvTreeListEntry* pEntry = InsertEntry(
     470             :         rsName,
     471             :         aIcon,
     472             :         aIcon,
     473             :         pParentEntry,
     474             :         sal_False,
     475             :         LIST_APPEND,
     476           0 :         pUserData);
     477             : 
     478             :     SdrObjListIter aIter(
     479             :         rList,
     480           0 :         !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
     481             :         IM_FLAT,
     482           0 :         sal_False /*not reverse*/);
     483             : 
     484           0 :     while( aIter.IsMore() )
     485             :     {
     486           0 :         SdrObject* pObj = aIter.Next();
     487             :         OSL_ASSERT(pObj!=NULL);
     488             : 
     489             :         // Get the shape name.
     490           0 :         String aStr (GetObjectName( pObj ) );
     491             : 
     492           0 :         if( aStr.Len() )
     493             :         {
     494           0 :             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
     495             :             {
     496             :                 InsertEntry(
     497             :                     aStr,
     498             :                     maImgOle,
     499             :                     maImgOle,
     500             :                     pEntry,
     501             :                     sal_False,
     502             :                     LIST_APPEND,
     503             :                     pObj
     504           0 :                 );
     505             :             }
     506           0 :             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
     507             :             {
     508             :                 InsertEntry(
     509             :                     aStr,
     510             :                     maImgGraphic,
     511             :                     maImgGraphic,
     512             :                     pEntry,
     513             :                     sal_False,
     514             :                     LIST_APPEND,
     515             :                     pObj
     516           0 :                 );
     517             :             }
     518           0 :             else if (pObj->IsGroupObject())
     519             :             {
     520             :                 AddShapeList(
     521           0 :                     *pObj->GetSubList(),
     522             :                     pObj,
     523             :                     aStr,
     524             :                     false,
     525             :                     pEntry,
     526             :                     rIconProvider
     527           0 :                 );
     528             :             }
     529             :             else
     530             :             {
     531             :                 InsertEntry(
     532             :                     aStr,
     533             :                     rIconProvider.maImgObjects,
     534             :                     rIconProvider.maImgObjects,
     535             :                     pEntry,
     536             :                     sal_False,
     537             :                     LIST_APPEND,
     538             :                     pObj
     539           0 :                 );
     540             :             }
     541             :         }
     542           0 :     }
     543             : 
     544           0 :     if( pEntry->HasChildren() )
     545             :     {
     546             :         SetExpandedEntryBmp(
     547             :             pEntry,
     548           0 :             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
     549             :         SetCollapsedEntryBmp(
     550             :             pEntry,
     551           0 :             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
     552           0 :     }
     553           0 : }
     554             : 
     555             : 
     556             : 
     557             : 
     558           0 : void SdPageObjsTLB::SetShowAllShapes (
     559             :     const bool bShowAllShapes,
     560             :     const bool bFillList)
     561             : {
     562           0 :     mbShowAllShapes = bShowAllShapes;
     563           0 :     if (bFillList)
     564             :     {
     565           0 :         if (mpMedium == NULL)
     566           0 :             Fill(mpDoc, mbShowAllPages, maDocName);
     567             :         else
     568           0 :             Fill(mpDoc, mpMedium, maDocName);
     569             :     }
     570           0 : }
     571             : 
     572             : 
     573             : 
     574             : 
     575           0 : bool SdPageObjsTLB::GetShowAllShapes (void) const
     576             : {
     577           0 :     return mbShowAllShapes;
     578             : }
     579             : 
     580             : 
     581             : 
     582             : 
     583             : /*************************************************************************
     584             : |*
     585             : |* Prueft, ob die Seiten (PK_STANDARD) und die darauf befindlichen Objekte
     586             : |* des Docs und der TreeLB identisch sind.
     587             : |* Wird ein Doc uebergeben, wird dieses zum aktuellem Doc (Wichtig bei
     588             : |* mehreren Documenten).
     589             : |*
     590             : \************************************************************************/
     591             : 
     592           0 : sal_Bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
     593             : {
     594           0 :     if( pInDoc )
     595           0 :         mpDoc = pInDoc;
     596             : 
     597           0 :     if( !mpDoc )
     598           0 :         return( sal_False );
     599             : 
     600           0 :     SdrObject*   pObj = NULL;
     601           0 :     SdPage*      pPage = NULL;
     602           0 :     SvTreeListEntry* pEntry = First();
     603           0 :     String       aName;
     604             : 
     605             :     // Alle Pages incl. Objekte vergleichen
     606           0 :     sal_uInt16 nPage = 0;
     607           0 :     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
     608             : 
     609           0 :     while( nPage < nMaxPages )
     610             :     {
     611           0 :         pPage = (SdPage*) mpDoc->GetPage( nPage );
     612           0 :         if( pPage->GetPageKind() == PK_STANDARD )
     613             :         {
     614           0 :             if( !pEntry )
     615           0 :                 return( sal_False );
     616           0 :             aName = GetEntryText( pEntry );
     617             : 
     618           0 :             if( pPage->GetName() != aName )
     619           0 :                 return( sal_False );
     620             : 
     621           0 :             pEntry = Next( pEntry );
     622             : 
     623             :             SdrObjListIter aIter(
     624             :                 *pPage,
     625           0 :                 !pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
     626           0 :                 IM_DEEPWITHGROUPS );
     627             : 
     628           0 :             while( aIter.IsMore() )
     629             :             {
     630           0 :                 pObj = aIter.Next();
     631             : 
     632           0 :                 const String aObjectName( GetObjectName( pObj ) );
     633             : 
     634           0 :                 if( aObjectName.Len() )
     635             :                 {
     636           0 :                     if( !pEntry )
     637           0 :                         return( sal_False );
     638             : 
     639           0 :                     aName = GetEntryText( pEntry );
     640             : 
     641           0 :                     if( aObjectName != aName )
     642           0 :                         return( sal_False );
     643             : 
     644           0 :                     pEntry = Next( pEntry );
     645             :                 }
     646           0 :             }
     647             :         }
     648           0 :         nPage++;
     649             :     }
     650             :     // Wenn noch Eintraege in der Listbox vorhanden sind, wurden
     651             :     // Objekte (mit Namen) oder Seiten geloescht
     652           0 :     return( !pEntry );
     653             : }
     654             : 
     655             : /*************************************************************************
     656             : |*
     657             : |* Selectierten String zurueckgeben
     658             : |*
     659             : \************************************************************************/
     660             : 
     661           0 : String SdPageObjsTLB::GetSelectEntry()
     662             : {
     663           0 :     return( GetEntryText( GetCurEntry() ) );
     664             : }
     665             : 
     666           0 : std::vector<rtl::OUString> SdPageObjsTLB::GetSelectEntryList( const sal_uInt16 nDepth ) const
     667             : {
     668           0 :     std::vector<rtl::OUString> aEntries;
     669           0 :     SvTreeListEntry* pEntry = FirstSelected();
     670             : 
     671           0 :     while( pEntry )
     672             :     {
     673           0 :         sal_uInt16 nListDepth = GetModel()->GetDepth( pEntry );
     674             : 
     675           0 :         if( nListDepth == nDepth )
     676           0 :             aEntries.push_back(GetEntryText(pEntry));
     677             : 
     678           0 :         pEntry = NextSelected( pEntry );
     679             :     }
     680             : 
     681           0 :     return aEntries;
     682             : }
     683             : 
     684             : /*************************************************************************
     685             : |*
     686             : |* Eintraege werden erst auf Anforderung (Doppelklick) eingefuegt
     687             : |*
     688             : \************************************************************************/
     689             : 
     690           0 : void SdPageObjsTLB::RequestingChildren( SvTreeListEntry* pFileEntry )
     691             : {
     692           0 :     if( !pFileEntry->HasChildren() )
     693             :     {
     694           0 :         if( GetBookmarkDoc() )
     695             :         {
     696           0 :             SdrObject*   pObj = NULL;
     697           0 :             SdPage*      pPage = NULL;
     698           0 :             SvTreeListEntry* pPageEntry = NULL;
     699             : 
     700           0 :             Image aImgPage     = Image( BitmapEx( SdResId( BMP_PAGE     ) ) );
     701           0 :             Image aImgPageObjs = Image( BitmapEx( SdResId( BMP_PAGEOBJS ) ) );
     702           0 :             Image aImgObjects  = Image( BitmapEx( SdResId( BMP_OBJECTS  ) ) );
     703             : 
     704             :             // document name already inserted
     705             : 
     706             :             // only insert all "normal" ? slides with objects
     707           0 :             sal_uInt16 nPage = 0;
     708           0 :             const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount();
     709             : 
     710           0 :             while( nPage < nMaxPages )
     711             :             {
     712           0 :                 pPage = (SdPage*) mpBookmarkDoc->GetPage( nPage );
     713           0 :                 if( pPage->GetPageKind() == PK_STANDARD )
     714             :                 {
     715           0 :                     pPageEntry = InsertEntry( pPage->GetName(),
     716             :                                               aImgPage,
     717             :                                               aImgPage,
     718             :                                               pFileEntry,
     719             :                                               sal_False,
     720             :                                               LIST_APPEND,
     721           0 :                                               reinterpret_cast< void* >( 1 ) );
     722             : 
     723           0 :                     SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
     724             : 
     725           0 :                     while( aIter.IsMore() )
     726             :                     {
     727           0 :                         pObj = aIter.Next();
     728           0 :                         String aStr( GetObjectName( pObj ) );
     729           0 :                         if( aStr.Len() )
     730             :                         {
     731           0 :                             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
     732             :                             {
     733           0 :                                 InsertEntry(aStr, maImgOle, maImgOle, pPageEntry);
     734             :                             }
     735           0 :                             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
     736             :                             {
     737           0 :                                 InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry);
     738             :                             }
     739             :                             else
     740             :                             {
     741           0 :                                 InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry);
     742             :                             }
     743             :                         }
     744           0 :                     }
     745           0 :                     if( pPageEntry->HasChildren() )
     746             :                     {
     747           0 :                         SetExpandedEntryBmp(  pPageEntry, aImgPageObjs );
     748           0 :                         SetCollapsedEntryBmp( pPageEntry, aImgPageObjs );
     749           0 :                     }
     750             :                 }
     751           0 :                 nPage++;
     752           0 :             }
     753             :         }
     754             :     }
     755             :     else
     756           0 :         SvTreeListBox::RequestingChildren( pFileEntry );
     757           0 : }
     758             : 
     759             : /*************************************************************************
     760             : |*
     761             : |*  Prueft, ob es sich um eine Draw-Datei handelt und oeffnet anhand des
     762             : |*  uebergebenen Docs das BookmarkDoc
     763             : |*
     764             : \************************************************************************/
     765             : 
     766           0 : SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed)
     767             : {
     768           0 :     if (
     769           0 :        !mpBookmarkDoc ||
     770           0 :          (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName()))
     771             :       )
     772             :     {
     773             :         // create a new BookmarkDoc if now one exists or if a new Medium is provided
     774           0 :         if (mpOwnMedium != pMed)
     775             :         {
     776           0 :             CloseBookmarkDoc();
     777             :         }
     778             : 
     779           0 :         if (pMed)
     780             :         {
     781             :             // it looks that it is undefined if a Medium was set by Fill() allready
     782             :             DBG_ASSERT( !mpMedium, "SfxMedium confusion!" );
     783           0 :             delete mpMedium;
     784           0 :             mpMedium = NULL;
     785             : 
     786             :             // take over this Medium (currently used only be Navigator)
     787           0 :             mpOwnMedium = pMed;
     788             :         }
     789             : 
     790             :         DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" );
     791             : 
     792           0 :         if( pMed )
     793             :         {
     794             :             // in this mode the document is also owned and controlled by this instance
     795           0 :             mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
     796           0 :             if (mxBookmarkDocShRef->DoLoad(pMed))
     797           0 :                 mpBookmarkDoc = mxBookmarkDocShRef->GetDoc();
     798             :             else
     799           0 :                 mpBookmarkDoc = NULL;
     800             :         }
     801           0 :         else if ( mpMedium )
     802             :             // in this mode the document is owned and controlled by the SdDrawDocument
     803             :             // it can be released by calling the corresponding CloseBookmarkDoc method
     804             :             // successfull creation of a document makes this the owner of the medium
     805           0 :             mpBookmarkDoc = ((SdDrawDocument*) mpDoc)->OpenBookmarkDoc(*mpMedium);
     806             : 
     807           0 :         if ( !mpBookmarkDoc )
     808             :         {
     809           0 :             ErrorBox aErrorBox( this, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
     810           0 :             aErrorBox.Execute();
     811           0 :             mpMedium = 0; //On failure the SfxMedium is invalid
     812             :         }
     813             :     }
     814             : 
     815           0 :     return( mpBookmarkDoc );
     816             : }
     817             : 
     818             : /*************************************************************************
     819             : |*
     820             : |* Bookmark-Dokument schlie�en und loeschen
     821             : |*
     822             : \************************************************************************/
     823             : 
     824           0 : void SdPageObjsTLB::CloseBookmarkDoc()
     825             : {
     826           0 :     if (mxBookmarkDocShRef.Is())
     827             :     {
     828           0 :         mxBookmarkDocShRef->DoClose();
     829           0 :         mxBookmarkDocShRef.Clear();
     830             : 
     831             :         // Medium is owned by document, so it's destroyed already
     832           0 :         mpOwnMedium = 0;
     833             :     }
     834           0 :     else if ( mpBookmarkDoc )
     835             :     {
     836             :         DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" );
     837           0 :         if ( mpDoc )
     838             :         {
     839             :             // The document owns the Medium, so the Medium will be invalid after closing the document
     840           0 :             ((SdDrawDocument*) mpDoc)->CloseBookmarkDoc();
     841           0 :             mpMedium = 0;
     842             :         }
     843             :     }
     844             :     else
     845             :     {
     846             :         // perhaps mpOwnMedium provided, but no successfull creation of BookmarkDoc
     847           0 :         delete mpOwnMedium;
     848           0 :         mpOwnMedium = NULL;
     849             :     }
     850             : 
     851           0 :     mpBookmarkDoc = NULL;
     852           0 : }
     853             : 
     854           0 : void SdPageObjsTLB::SelectHdl()
     855             : {
     856           0 :     SvTreeListEntry* pEntry = FirstSelected();
     857             : 
     858           0 :     mbLinkableSelected = sal_True;
     859             : 
     860           0 :     while( pEntry && mbLinkableSelected )
     861             :     {
     862           0 :         if( NULL == pEntry->GetUserData() )
     863           0 :             mbLinkableSelected = sal_False;
     864             : 
     865           0 :         pEntry = NextSelected( pEntry );
     866             :     }
     867             : 
     868           0 :     SvTreeListBox::SelectHdl();
     869           0 : }
     870             : 
     871             : /*************************************************************************
     872             : |*
     873             : |* Ueberlaedt RETURN mit der Funktionsweise von DoubleClick
     874             : |*
     875             : \************************************************************************/
     876             : 
     877           0 : void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
     878             : {
     879           0 :     if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
     880             :     {
     881             :         // Auskommentierter Code aus svtools/source/contnr/svimpbox.cxx
     882           0 :         SvTreeListEntry* pCursor = GetCurEntry();
     883           0 :         if( pCursor->HasChildren() || pCursor->HasChildrenOnDemand() )
     884             :         {
     885           0 :             if( IsExpanded( pCursor ) )
     886           0 :                 Collapse( pCursor );
     887             :             else
     888           0 :                 Expand( pCursor );
     889             :         }
     890             : 
     891           0 :         DoubleClickHdl();
     892             :     }
     893             :     else
     894           0 :         SvTreeListBox::KeyInput( rKEvt );
     895           0 : }
     896             : 
     897             : /*************************************************************************
     898             : |*
     899             : |* StartDrag-Request
     900             : |*
     901             : \************************************************************************/
     902             : 
     903           0 : void SdPageObjsTLB::StartDrag( sal_Int8 nAction, const Point& rPosPixel)
     904             : {
     905             :     (void)nAction;
     906             :     (void)rPosPixel;
     907             : 
     908           0 :     SdNavigatorWin* pNavWin = NULL;
     909           0 :     SvTreeListEntry* pEntry = GetEntry(rPosPixel);
     910             : 
     911           0 :     if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
     912           0 :         pNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
     913             : 
     914           0 :     if (pEntry != NULL
     915             :         && pNavWin !=NULL
     916             :         && pNavWin == mpParent
     917           0 :         && pNavWin->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE )
     918             :     {
     919             :         // Mark only the children of the page under the mouse as drop
     920             :         // targets.  This prevents moving shapes from one page to another.
     921             : 
     922             :         // Select all entries and disable them as drop targets.
     923           0 :         SetSelectionMode(MULTIPLE_SELECTION);
     924           0 :         SetCursor(NULL, sal_False);
     925           0 :         SelectAll(sal_True, sal_False);
     926           0 :         EnableSelectionAsDropTarget(sal_False, sal_True);
     927             : 
     928             :         // Enable only the entries as drop targets that are children of the
     929             :         // page under the mouse.
     930           0 :         SvTreeListEntry* pParent = GetRootLevelParent(pEntry);
     931           0 :         if (pParent != NULL)
     932             :         {
     933           0 :             SelectAll(sal_False, sal_False);
     934           0 :             Select(pParent, sal_True);
     935             :             //            for (SvTreeListEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild))
     936             :             //                Select(pChild, sal_True);
     937           0 :             EnableSelectionAsDropTarget(sal_True, sal_True);//sal_False);
     938             :         }
     939             : 
     940             :         // Set selection back to the entry under the mouse.
     941           0 :         SelectAll(sal_False,sal_False);
     942           0 :         SetSelectionMode(SINGLE_SELECTION);
     943           0 :         Select(pEntry, sal_True);
     944             : 
     945             :         //  Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
     946             :         //  (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
     947             :         //  den StarView MouseMove-Handler, der Command() aufruft, umbringen.
     948             :         //  Deshalb Drag&Drop asynchron:
     949           0 :         Application::PostUserEvent( STATIC_LINK( this, SdPageObjsTLB, ExecDragHdl ) );
     950             :     }
     951           0 : }
     952             : 
     953             : /*************************************************************************
     954             : |*
     955             : |* Begin drag
     956             : |*
     957             : \************************************************************************/
     958             : 
     959           0 : void SdPageObjsTLB::DoDrag()
     960             : {
     961           0 :     mpDropNavWin = ( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) ?
     962           0 :                   (SdNavigatorWin*)( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ) :
     963           0 :                   NULL;
     964             : 
     965           0 :     if( mpDropNavWin )
     966             :     {
     967           0 :         ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
     968           0 :         String aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INET_PROT_FILE ).GetMainURL( INetURLObject::NO_DECODE );
     969           0 :         NavigatorDragType   eDragType = mpDropNavWin->GetNavigatorDragType();
     970             : 
     971           0 :         aURL.Append( '#' );
     972           0 :         aURL.Append( GetSelectEntry() );
     973             : 
     974           0 :         INetBookmark    aBookmark( aURL, GetSelectEntry() );
     975           0 :         sal_Int8        nDNDActions = DND_ACTION_COPYMOVE;
     976             : 
     977           0 :         if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
     978           0 :             nDNDActions = DND_ACTION_LINK;  // Either COPY *or* LINK, never both!
     979           0 :         else if (mpDoc->GetSdPageCount(PK_STANDARD) == 1)
     980             :         {
     981             :             // Can not move away the last slide in a document.
     982           0 :             nDNDActions = DND_ACTION_COPY;
     983             :         }
     984             : 
     985           0 :         SvTreeListBox::ReleaseMouse();
     986             : 
     987           0 :         bIsInDrag = sal_True;
     988             : 
     989             :         SvLBoxDDInfo aDDInfo;
     990           0 :         memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
     991           0 :         aDDInfo.pApp = GetpApp();
     992           0 :         aDDInfo.pSource = this;
     993             :         //            aDDInfo.pDDStartEntry = pEntry;
     994           0 :         ::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo));
     995           0 :         memcpy(aSequence.getArray(), (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo));
     996           0 :         ::com::sun::star::uno::Any aTreeListBoxData (aSequence);
     997             : 
     998             :         // object is destroyed by internal reference mechanism
     999             :         SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable(
    1000           0 :             *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData);
    1001             : 
    1002             :         // Get the view.
    1003           0 :         ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
    1004           0 :         if (pViewShell == NULL)
    1005             :         {
    1006             :             OSL_ASSERT(pViewShell!=NULL);
    1007             :             return;
    1008             :         }
    1009           0 :         sd::View* pView = pViewShell->GetView();
    1010           0 :         if (pView == NULL)
    1011             :         {
    1012             :             OSL_ASSERT(pView!=NULL);
    1013             :             return;
    1014             :         }
    1015             : 
    1016           0 :         SdrObject* pObject = NULL;
    1017           0 :         void* pUserData = GetCurEntry()->GetUserData();
    1018           0 :         if (pUserData != NULL && pUserData != (void*)1)
    1019           0 :             pObject = reinterpret_cast<SdrObject*>(pUserData);
    1020           0 :         if (pObject != NULL)
    1021             :         {
    1022             :             // For shapes without a user supplied name (the automatically
    1023             :             // created name does not count), a different drag and drop technique
    1024             :             // is used.
    1025           0 :             if (GetObjectName(pObject, false).Len() == 0)
    1026             :             {
    1027           0 :                 AddShapeToTransferable(*pTransferable, *pObject);
    1028           0 :                 pTransferable->SetView(pView);
    1029           0 :                 SD_MOD()->pTransferDrag = pTransferable;
    1030             :             }
    1031             : 
    1032             :             // Unnamed shapes have to be selected to be recognized by the
    1033             :             // current drop implementation.  In order to have a consistent
    1034             :             // behaviour for all shapes, every shape that is to be dragged is
    1035             :             // selected first.
    1036           0 :             SdrPageView* pPageView = pView->GetSdrPageView();
    1037           0 :             pView->UnmarkAllObj(pPageView);
    1038           0 :             pView->MarkObj(pObject, pPageView);
    1039             :         }
    1040             :         else
    1041             :         {
    1042           0 :             pTransferable->SetView(pView);
    1043           0 :             SD_MOD()->pTransferDrag = pTransferable;
    1044             :         }
    1045             : 
    1046           0 :         pTransferable->StartDrag( this, nDNDActions );
    1047             :     }
    1048             : }
    1049             : 
    1050             : /*************************************************************************
    1051             : |*
    1052             : |* Drag finished
    1053             : |*
    1054             : \************************************************************************/
    1055             : 
    1056           0 : void SdPageObjsTLB::OnDragFinished( sal_uInt8 )
    1057             : {
    1058           0 :     if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
    1059             :     {
    1060           0 :         SdNavigatorWin* pNewNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
    1061             : 
    1062           0 :         if( mpDropNavWin == pNewNavWin)
    1063             :         {
    1064           0 :             MouseEvent aMEvt( mpDropNavWin->GetPointerPosPixel() );
    1065           0 :             SvTreeListBox::MouseButtonUp( aMEvt );
    1066             :         }
    1067             :     }
    1068             : 
    1069           0 :     mpDropNavWin = NULL;
    1070           0 :     bIsInDrag = sal_False;
    1071           0 : }
    1072             : 
    1073             : /*************************************************************************
    1074             : |*
    1075             : |* AcceptDrop-Event
    1076             : |*
    1077             : \************************************************************************/
    1078             : 
    1079           0 : sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent)
    1080             : {
    1081           0 :     sal_Int8 nResult (DND_ACTION_NONE);
    1082             : 
    1083           0 :     if ( !bIsInDrag && IsDropFormatSupported( FORMAT_FILE ) )
    1084             :     {
    1085           0 :         nResult = rEvent.mnAction;
    1086             :     }
    1087             :     else
    1088             :     {
    1089           0 :         SvTreeListEntry* pEntry = GetDropTarget(rEvent.maPosPixel);
    1090           0 :         if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction ))
    1091             :         {
    1092           0 :             ImplShowTargetEmphasis( pTargetEntry, sal_False );
    1093             :         }
    1094           0 :         else if( !GetDragDropMode() )
    1095             :         {
    1096             :             SAL_WARN( "sc.ui", "SdPageObjsTLB::AcceptDrop(): no target" );
    1097             :         }
    1098           0 :         else if (IsDropAllowed(pEntry))
    1099             :         {
    1100           0 :             nResult = DND_ACTION_MOVE;
    1101             : 
    1102             :             // Draw emphasis.
    1103           0 :             if (pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS))
    1104             :             {
    1105           0 :                 ImplShowTargetEmphasis( pTargetEntry, sal_False );
    1106           0 :                 pTargetEntry = pEntry;
    1107           0 :                 ImplShowTargetEmphasis( pTargetEntry, sal_True );
    1108             :             }
    1109             :         }
    1110             :     }
    1111             : 
    1112             :     // Hide emphasis when there is no valid drop action.
    1113           0 :     if (nResult == DND_ACTION_NONE)
    1114           0 :         ImplShowTargetEmphasis(pTargetEntry, sal_False);
    1115             : 
    1116           0 :     return nResult;
    1117             : }
    1118             : 
    1119             : /*************************************************************************
    1120             : |*
    1121             : |* ExecuteDrop-Event
    1122             : |*
    1123             : \************************************************************************/
    1124             : 
    1125           0 : sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt )
    1126             : {
    1127           0 :     sal_Int8 nRet = DND_ACTION_NONE;
    1128             : 
    1129             :     try
    1130             :     {
    1131           0 :         if( !bIsInDrag )
    1132             :         {
    1133           0 :             SdNavigatorWin* pNavWin = NULL;
    1134           0 :             sal_uInt16          nId = SID_NAVIGATOR;
    1135             : 
    1136           0 :             if( mpFrame->HasChildWindow( nId ) )
    1137           0 :                 pNavWin = (SdNavigatorWin*)( mpFrame->GetChildWindow( nId )->GetContextWindow( SD_MOD() ) );
    1138             : 
    1139           0 :             if( pNavWin && ( pNavWin == mpParent ) )
    1140             :             {
    1141           0 :                 TransferableDataHelper  aDataHelper( rEvt.maDropEvent.Transferable );
    1142           0 :                 String                  aFile;
    1143             : 
    1144           0 :                 if( aDataHelper.GetString( FORMAT_FILE, aFile ) &&
    1145           0 :                     ( (SdNavigatorWin*) mpParent)->InsertFile( aFile ) )
    1146             :                 {
    1147           0 :                     nRet = rEvt.mnAction;
    1148           0 :                 }
    1149             :             }
    1150             :         }
    1151             :     }
    1152           0 :     catch (com::sun::star::uno::Exception&)
    1153             :     {
    1154             :         DBG_UNHANDLED_EXCEPTION();
    1155             :     }
    1156             : 
    1157           0 :     if (nRet == DND_ACTION_NONE)
    1158           0 :         SvTreeListBox::ExecuteDrop(rEvt, this);
    1159             : 
    1160             : 
    1161           0 :     return nRet;
    1162             : }
    1163             : 
    1164             : /*************************************************************************
    1165             : |*
    1166             : |* Handler fuers Dragging
    1167             : |*
    1168             : \************************************************************************/
    1169             : 
    1170           0 : IMPL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*, EMPTYARG)
    1171             : {
    1172             :     //  als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
    1173             :     //  Navigator geloescht werden darf
    1174           0 :     pThis->DoDrag();
    1175           0 :     return 0;
    1176             : }
    1177             : 
    1178             : 
    1179           0 : bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
    1180             : {
    1181             :     // Return <TRUE/> as default when there is no custom show or when none
    1182             :     // is used.  The page does then belong to the standard show.
    1183           0 :     bool bBelongsToShow = true;
    1184             : 
    1185           0 :     if (mpDoc->getPresentationSettings().mbCustomShow)
    1186             :     {
    1187             :         // Get the current custom show.
    1188           0 :         SdCustomShow* pCustomShow = NULL;
    1189           0 :         SdCustomShowList* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList();
    1190           0 :         if (pShowList != NULL)
    1191             :         {
    1192           0 :             sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
    1193           0 :             pCustomShow = (*pShowList)[nCurrentShowIndex];
    1194             :         }
    1195             : 
    1196             :         // Check whether the given page is part of that custom show.
    1197           0 :         if (pCustomShow != NULL)
    1198             :         {
    1199           0 :             bBelongsToShow = false;
    1200           0 :             sal_uLong nPageCount = pCustomShow->PagesVector().size();
    1201           0 :             for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++)
    1202           0 :                 if (pPage == pCustomShow->PagesVector()[i])
    1203           0 :                     bBelongsToShow = true;
    1204             :         }
    1205             :     }
    1206             : 
    1207           0 :     return bBelongsToShow;
    1208             : }
    1209             : 
    1210             : 
    1211             : 
    1212             : 
    1213           0 : sal_Bool SdPageObjsTLB::NotifyMoving(
    1214             :     SvTreeListEntry* pTarget,
    1215             :     SvTreeListEntry* pEntry,
    1216             :     SvTreeListEntry*& rpNewParent,
    1217             :     sal_uLong& rNewChildPos)
    1218             : {
    1219           0 :     SvTreeListEntry* pDestination = pTarget;
    1220           0 :     while (GetParent(pDestination) != NULL && GetParent(GetParent(pDestination)) != NULL)
    1221           0 :         pDestination = GetParent(pDestination);
    1222             : 
    1223           0 :     SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(pDestination->GetUserData());
    1224           0 :     SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(pEntry->GetUserData());
    1225           0 :     if (pSourceObject == reinterpret_cast<SdrObject*>(1))
    1226           0 :         pSourceObject = NULL;
    1227             : 
    1228           0 :     if (pTargetObject != NULL && pSourceObject != NULL)
    1229             :     {
    1230           0 :         SdrPage* pObjectList = pSourceObject->GetPage();
    1231           0 :         if (pObjectList != NULL)
    1232             :         {
    1233             :             sal_uInt32 nNewPosition;
    1234           0 :             if (pTargetObject == reinterpret_cast<SdrObject*>(1))
    1235           0 :                 nNewPosition = 0;
    1236             :             else
    1237           0 :                 nNewPosition = pTargetObject->GetNavigationPosition() + 1;
    1238           0 :             pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition);
    1239             :         }
    1240             : 
    1241             :         // Update the tree list.
    1242           0 :         if (pTarget == NULL)
    1243             :         {
    1244           0 :             rpNewParent = 0;
    1245           0 :             rNewChildPos = 0;
    1246           0 :             return sal_True;
    1247             :         }
    1248           0 :         else if (GetParent(pDestination) == NULL)
    1249             :         {
    1250           0 :             rpNewParent = pDestination;
    1251           0 :             rNewChildPos = 0;
    1252             :         }
    1253             :         else
    1254             :         {
    1255           0 :             rpNewParent = GetParent(pDestination);
    1256           0 :             rNewChildPos = pModel->GetRelPos(pDestination) + 1;
    1257           0 :             rNewChildPos += nCurEntrySelPos;
    1258           0 :             nCurEntrySelPos++;
    1259             :         }
    1260           0 :         return sal_True;
    1261             :     }
    1262             :     else
    1263           0 :         return sal_False;
    1264             : }
    1265             : 
    1266             : 
    1267             : 
    1268             : 
    1269           0 : SvTreeListEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation)
    1270             : {
    1271           0 :     SvTreeListEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation);
    1272           0 :     if (pEntry == NULL)
    1273           0 :         return NULL;
    1274             : 
    1275           0 :     if (GetParent(pEntry) == NULL)
    1276             :     {
    1277             :         // Use page entry as insertion position.
    1278             :     }
    1279             :     else
    1280             :     {
    1281             :         // Go to second hierarchy level, i.e. top level shapes,
    1282             :         // i.e. children of pages.
    1283           0 :         while (GetParent(pEntry) != NULL && GetParent(GetParent(pEntry)) != NULL)
    1284           0 :             pEntry = GetParent(pEntry);
    1285             : 
    1286             :         // Advance to next sibling.
    1287             :         SvTreeListEntry* pNext;
    1288           0 :         sal_uInt16 nDepth (0);
    1289           0 :         while (pEntry != NULL)
    1290             :         {
    1291           0 :             pNext = dynamic_cast<SvTreeListEntry*>(NextVisible(pEntry, &nDepth));
    1292           0 :             if (pNext != NULL && nDepth > 0 && nDepth!=0xffff)
    1293           0 :                 pEntry = pNext;
    1294             :             else
    1295           0 :                 break;
    1296             :         }
    1297             :     }
    1298             : 
    1299           0 :     return pEntry;
    1300             : }
    1301             : 
    1302             : 
    1303             : 
    1304             : 
    1305           0 : bool SdPageObjsTLB::IsDropAllowed (SvTreeListEntry* pEntry)
    1306             : {
    1307           0 :     if (pEntry == NULL)
    1308           0 :         return false;
    1309             : 
    1310           0 :     if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId()))
    1311           0 :         return false;
    1312             : 
    1313           0 :     if ((pEntry->GetFlags() & SV_ENTRYFLAG_DISABLE_DROP) != 0)
    1314           0 :         return false;
    1315             : 
    1316           0 :     return true;
    1317             : }
    1318             : 
    1319             : 
    1320             : 
    1321             : 
    1322           0 : void SdPageObjsTLB::AddShapeToTransferable (
    1323             :     SdTransferable& rTransferable,
    1324             :     SdrObject& rObject) const
    1325             : {
    1326           0 :     TransferableObjectDescriptor aObjectDescriptor;
    1327           0 :     bool bIsDescriptorFillingPending (true);
    1328             : 
    1329           0 :     const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
    1330           0 :     if (pOleObject != NULL && pOleObject->GetObjRef().is())
    1331             :     {
    1332             :         // If object has no persistence it must be copied as part of the document
    1333             :         try
    1334             :         {
    1335           0 :             uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY );
    1336           0 :             if (xPersObj.is() && xPersObj->hasEntry())
    1337             :             {
    1338             :                 SvEmbedTransferHelper::FillTransferableObjectDescriptor(
    1339             :                     aObjectDescriptor,
    1340             :                     pOleObject->GetObjRef(),
    1341             :                     pOleObject->GetGraphic(),
    1342           0 :                     pOleObject->GetAspect());
    1343           0 :                 bIsDescriptorFillingPending = false;
    1344           0 :             }
    1345             :         }
    1346           0 :         catch( uno::Exception& )
    1347             :         {
    1348             :         }
    1349             :     }
    1350             : 
    1351           0 :     ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
    1352           0 :     if (bIsDescriptorFillingPending && pDocShell!=NULL)
    1353             :     {
    1354           0 :         bIsDescriptorFillingPending = false;
    1355           0 :         pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor);
    1356             :     }
    1357             : 
    1358           0 :     Point aDragPos (rObject.GetCurrentBoundRect().Center());
    1359             :     //Point aDragPos (0,0);
    1360           0 :     aObjectDescriptor.maDragStartPos = aDragPos;
    1361             :     //  aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
    1362           0 :     if (pDocShell != NULL)
    1363           0 :         aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
    1364             :     else
    1365           0 :         aObjectDescriptor.maDisplayName = String();
    1366           0 :     aObjectDescriptor.mbCanLink = sal_False;
    1367             : 
    1368           0 :     rTransferable.SetStartPos(aDragPos);
    1369           0 :     rTransferable.SetObjectDescriptor( aObjectDescriptor );
    1370           0 : }
    1371             : 
    1372             : 
    1373             : 
    1374             : 
    1375           0 : ::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
    1376             : {
    1377             :     {
    1378           0 :         ::sd::ViewShell* pViewShell = rDocShell.GetViewShell();
    1379           0 :         if (pViewShell != NULL)
    1380           0 :             return pViewShell;
    1381             :     }
    1382             : 
    1383             :     try
    1384             :     {
    1385             :         // Get a component enumeration from the desktop and search it for documents.
    1386             :         uno::Reference<lang::XMultiServiceFactory> xFactory (
    1387           0 :             ::comphelper::getProcessServiceFactory ());
    1388           0 :         if ( ! xFactory.is())
    1389           0 :             return NULL;
    1390             : 
    1391           0 :         uno::Reference<frame::XDesktop> xDesktop (xFactory->createInstance (
    1392           0 :                 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), uno::UNO_QUERY);
    1393           0 :         if ( ! xDesktop.is())
    1394           0 :             return NULL;
    1395             : 
    1396           0 :         uno::Reference<frame::XFramesSupplier> xFrameSupplier (xDesktop, uno::UNO_QUERY);
    1397           0 :         if ( ! xFrameSupplier.is())
    1398           0 :             return NULL;
    1399             : 
    1400           0 :         uno::Reference<container::XIndexAccess> xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY);
    1401           0 :         if ( ! xFrameAccess.is())
    1402           0 :             return NULL;
    1403             : 
    1404           0 :         for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex)
    1405             :         {
    1406           0 :             uno::Reference<frame::XFrame> xFrame;
    1407           0 :             if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame))
    1408           0 :                 continue;
    1409             : 
    1410           0 :             ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get());
    1411           0 :             if (pController == NULL)
    1412           0 :                 continue;
    1413           0 :             ::sd::ViewShellBase* pBase = pController->GetViewShellBase();
    1414           0 :             if (pBase == NULL)
    1415           0 :                 continue;
    1416           0 :             if (pBase->GetDocShell() != &rDocShell)
    1417           0 :                 continue;
    1418             : 
    1419           0 :             const ::boost::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell());
    1420           0 :             if (pViewShell)
    1421           0 :                 return pViewShell.get();
    1422           0 :         }
    1423             :     }
    1424           0 :     catch (uno::Exception e)
    1425             :     {
    1426             :         // When there is an exception then simply use the default value of
    1427             :         // bIsEnabled and disable the controls.
    1428           0 :     }
    1429           0 :     return NULL;
    1430             : }
    1431             : 
    1432             : 
    1433             : 
    1434             : 
    1435             : //===== IconProvider ==========================================================
    1436             : 
    1437           0 : SdPageObjsTLB::IconProvider::IconProvider (void)
    1438             :     : maImgPage( BitmapEx( SdResId( BMP_PAGE ) ) ),
    1439             :       maImgPageExcl( BitmapEx( SdResId( BMP_PAGE_EXCLUDED ) ) ),
    1440             :       maImgPageObjsExcl( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED ) ) ),
    1441             :       maImgPageObjs( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ),
    1442             :       maImgObjects( BitmapEx( SdResId( BMP_OBJECTS ) ) ),
    1443           0 :       maImgGroup( BitmapEx( SdResId( BMP_GROUP ) ) )
    1444             : {
    1445          18 : }
    1446             : 
    1447             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10