xref: /trunk/main/sd/source/ui/dlg/sdtreelb.cxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/types.h>
28cdf0e10cSrcweir #include <sot/formats.hxx>
29cdf0e10cSrcweir #include <sot/storage.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <svl/urihelper.hxx>
32cdf0e10cSrcweir #include <svx/svditer.hxx>
33cdf0e10cSrcweir #include <sfx2/docfile.hxx>
34cdf0e10cSrcweir #include <svx/svdoole2.hxx>
35cdf0e10cSrcweir #include <vcl/svapp.hxx>
36cdf0e10cSrcweir #include "cusshow.hxx"
37cdf0e10cSrcweir #include <sfx2/childwin.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "strmname.h"
42cdf0e10cSrcweir #include "sdtreelb.hxx"
43cdf0e10cSrcweir #include "DrawDocShell.hxx"
44cdf0e10cSrcweir #include "drawdoc.hxx"
45cdf0e10cSrcweir #include "sdpage.hxx"
46cdf0e10cSrcweir #include "sdresid.hxx"
47cdf0e10cSrcweir #include "navigatr.hxx"
48cdf0e10cSrcweir #ifndef _SD_CFGID_HXX
49cdf0e10cSrcweir #include "strings.hrc"
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #include "res_bmp.hrc"
52cdf0e10cSrcweir #include "ViewShell.hxx"
53cdf0e10cSrcweir #include "DrawController.hxx"
54cdf0e10cSrcweir #include "ViewShellBase.hxx"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedPersist.hpp>
57cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
58cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
59cdf0e10cSrcweir #include <svtools/embedtransfer.hxx>
60cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
61cdf0e10cSrcweir #include <tools/diagnose_ex.h>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir using namespace com::sun::star;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir class SdPageObjsTLB::IconProvider
66cdf0e10cSrcweir {
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir     IconProvider (void);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     // Regular icons.
71cdf0e10cSrcweir     Image maImgPage;
72cdf0e10cSrcweir     Image maImgPageExcl;
73cdf0e10cSrcweir     Image maImgPageObjsExcl;
74cdf0e10cSrcweir     Image maImgPageObjs;
75cdf0e10cSrcweir     Image maImgObjects;
76cdf0e10cSrcweir     Image maImgGroup;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     // High contrast icons.
79cdf0e10cSrcweir     Image maImgPageH;
80cdf0e10cSrcweir     Image maImgPageExclH;
81cdf0e10cSrcweir     Image maImgPageObjsExclH;
82cdf0e10cSrcweir     Image maImgPageObjsH;
83cdf0e10cSrcweir     Image maImgObjectsH;
84cdf0e10cSrcweir     Image maImgGroupH;
85cdf0e10cSrcweir };
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir sal_Bool SD_DLLPRIVATE SdPageObjsTLB::bIsInDrag = sal_False;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir sal_Bool SdPageObjsTLB::IsInDrag()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     return bIsInDrag;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::mnListBoxDropFormatId = SAL_MAX_UINT32;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir // -----------------------------------------
98cdf0e10cSrcweir // - SdPageObjsTLB::SdPageObjsTransferable -
99cdf0e10cSrcweir // -----------------------------------------
100cdf0e10cSrcweir 
101cdf0e10cSrcweir SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable(
102cdf0e10cSrcweir     SdPageObjsTLB& rParent,
103cdf0e10cSrcweir         const INetBookmark& rBookmark,
104cdf0e10cSrcweir     ::sd::DrawDocShell& rDocShell,
105cdf0e10cSrcweir     NavigatorDragType eDragType,
106cdf0e10cSrcweir     const ::com::sun::star::uno::Any& rTreeListBoxData )
107cdf0e10cSrcweir     : SdTransferable(rDocShell.GetDoc(), NULL, sal_True),
108cdf0e10cSrcweir       mrParent( rParent ),
109cdf0e10cSrcweir       maBookmark( rBookmark ),
110cdf0e10cSrcweir       mrDocShell( rDocShell ),
111cdf0e10cSrcweir       meDragType( eDragType ),
112cdf0e10cSrcweir       maTreeListBoxData( rTreeListBoxData )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable()
120cdf0e10cSrcweir {
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // -----------------------------------------------------------------------------
124cdf0e10cSrcweir 
125cdf0e10cSrcweir void SdPageObjsTLB::SdPageObjsTransferable::AddSupportedFormats()
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     AddFormat(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK);
128cdf0e10cSrcweir     AddFormat(SOT_FORMATSTR_ID_TREELISTBOX);
129cdf0e10cSrcweir     AddFormat(GetListBoxDropFormatId());
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir // -----------------------------------------------------------------------------
133cdf0e10cSrcweir 
134cdf0e10cSrcweir sal_Bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     sal_uLong nFormatId = SotExchange::GetFormat( rFlavor );
137cdf0e10cSrcweir     switch (nFormatId)
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir         case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
140cdf0e10cSrcweir             SetINetBookmark( maBookmark, rFlavor );
141cdf0e10cSrcweir             return sal_True;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir         case SOT_FORMATSTR_ID_TREELISTBOX:
144cdf0e10cSrcweir             SetAny(maTreeListBoxData, rFlavor);
145cdf0e10cSrcweir             return sal_True;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         default:
148cdf0e10cSrcweir             return sal_False;
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir // -----------------------------------------------------------------------------
153cdf0e10cSrcweir 
154cdf0e10cSrcweir void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     mrParent.OnDragFinished( nDropAction );
157cdf0e10cSrcweir     SdTransferable::DragFinished(nDropAction);
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir // -----------------------------------------------------------------------------
161cdf0e10cSrcweir 
162cdf0e10cSrcweir ::sd::DrawDocShell& SdPageObjsTLB::SdPageObjsTransferable::GetDocShell() const
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     return mrDocShell;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir // -----------------------------------------------------------------------------
168cdf0e10cSrcweir 
169cdf0e10cSrcweir NavigatorDragType SdPageObjsTLB::SdPageObjsTransferable::GetDragType() const
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     return meDragType;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir // -----------------------------------------------------------------------------
175cdf0e10cSrcweir 
176cdf0e10cSrcweir sal_Int64 SAL_CALL SdPageObjsTLB::SdPageObjsTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     sal_Int64 nRet;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     if( ( rId.getLength() == 16 ) &&
181cdf0e10cSrcweir         ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
182cdf0e10cSrcweir     {
183cdf0e10cSrcweir         nRet = (sal_Int64)(sal_IntPtr)this;
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir     else
186cdf0e10cSrcweir         nRet = SdTransferable::getSomething(rId);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     return nRet;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // -----------------------------------------------------------------------------
192cdf0e10cSrcweir 
193cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< sal_Int8 >& SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     if( !aSeq.getLength() )
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir         static osl::Mutex   aCreateMutex;
200cdf0e10cSrcweir         osl::MutexGuard     aGuard( aCreateMutex );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir         aSeq.realloc( 16 );
203cdf0e10cSrcweir         rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
204cdf0e10cSrcweir     }
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     return aSeq;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir // -----------------------------------------------------------------------------
210cdf0e10cSrcweir 
211cdf0e10cSrcweir SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData )
212cdf0e10cSrcweir     throw()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     try
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, ::com::sun::star::uno::UNO_QUERY_THROW );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir         return reinterpret_cast<SdPageObjsTLB::SdPageObjsTransferable*>(
219cdf0e10cSrcweir                 sal::static_int_cast<sal_uIntPtr>(
220cdf0e10cSrcweir                     xUnoTunnel->getSomething( SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()) ) );
221cdf0e10cSrcweir     }
222cdf0e10cSrcweir     catch( const ::com::sun::star::uno::Exception& )
223cdf0e10cSrcweir     {
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir     return 0;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 
229cdf0e10cSrcweir sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId (void)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     if (mnListBoxDropFormatId == SAL_MAX_UINT32)
232cdf0e10cSrcweir         mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType(
233cdf0e10cSrcweir             ::rtl::OUString::createFromAscii(
234cdf0e10cSrcweir                 "application/x-openoffice-treelistbox-moveonly;"
235cdf0e10cSrcweir                     "windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\""));
236cdf0e10cSrcweir     return mnListBoxDropFormatId;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 
242cdf0e10cSrcweir /*************************************************************************
243cdf0e10cSrcweir |*
244cdf0e10cSrcweir |* Ctor1 SdPageObjsTLB
245cdf0e10cSrcweir |*
246cdf0e10cSrcweir \************************************************************************/
247cdf0e10cSrcweir 
248cdf0e10cSrcweir SdPageObjsTLB::SdPageObjsTLB( Window* pParentWin, const SdResId& rSdResId )
249cdf0e10cSrcweir :   SvTreeListBox       ( pParentWin, rSdResId )
250*0deba7fbSSteve Yin ,   bisInSdNavigatorWin  ( sal_False )
251cdf0e10cSrcweir ,   mpParent            ( pParentWin )
252cdf0e10cSrcweir ,   mpDoc               ( NULL )
253cdf0e10cSrcweir ,   mpBookmarkDoc       ( NULL )
254cdf0e10cSrcweir ,   mpMedium            ( NULL )
255cdf0e10cSrcweir ,   mpOwnMedium         ( NULL )
256cdf0e10cSrcweir ,   maImgOle             ( BitmapEx( SdResId( BMP_OLE ) ) )
257cdf0e10cSrcweir ,   maImgGraphic         ( BitmapEx( SdResId( BMP_GRAPHIC ) ) )
258cdf0e10cSrcweir ,   maImgOleH            ( BitmapEx( SdResId( BMP_OLE_H ) ) )
259cdf0e10cSrcweir ,   maImgGraphicH        ( BitmapEx( SdResId( BMP_GRAPHIC_H ) ) )
260cdf0e10cSrcweir ,   mbLinkableSelected  ( sal_False )
261cdf0e10cSrcweir ,   mpDropNavWin        ( NULL )
262cdf0e10cSrcweir ,   mbShowAllShapes     ( false )
263cdf0e10cSrcweir ,   mbShowAllPages      ( false )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir     // Tree-ListBox mit Linien versehen
266cdf0e10cSrcweir     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
267cdf0e10cSrcweir                            WB_HASBUTTONS | // WB_HASLINESATROOT |
268cdf0e10cSrcweir                            WB_HSCROLL | // #31562#
269cdf0e10cSrcweir                            WB_HASBUTTONSATROOT |
270cdf0e10cSrcweir                            WB_QUICK_SEARCH /* i31275 */ );
271cdf0e10cSrcweir     SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND ) ),
272cdf0e10cSrcweir                     Bitmap( SdResId( BMP_COLLAPSE ) ) );
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND_H ) ),
275cdf0e10cSrcweir                     Bitmap( SdResId( BMP_COLLAPSE_H ) ),
276cdf0e10cSrcweir                     BMP_COLOR_HIGHCONTRAST );
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     SetDragDropMode(
279cdf0e10cSrcweir         SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY |
280cdf0e10cSrcweir             SV_DRAGDROP_APP_MOVE  | SV_DRAGDROP_APP_COPY  | SV_DRAGDROP_APP_DROP );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir /*************************************************************************
284cdf0e10cSrcweir |*
285cdf0e10cSrcweir |* Dtor SdPageObjsTLB
286cdf0e10cSrcweir |*
287cdf0e10cSrcweir \************************************************************************/
288cdf0e10cSrcweir 
289cdf0e10cSrcweir SdPageObjsTLB::~SdPageObjsTLB()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     if ( mpBookmarkDoc )
292cdf0e10cSrcweir         CloseBookmarkDoc();
293cdf0e10cSrcweir     else
294cdf0e10cSrcweir         // no document was created from mpMedium, so this object is still the owner of it
295cdf0e10cSrcweir         delete mpMedium;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
299*0deba7fbSSteve Yin // helper function for  GetEntryAltText and GetEntryLongDescription
300*0deba7fbSSteve Yin String SdPageObjsTLB::getAltLongDescText( SvLBoxEntry* pEntry , sal_Bool isAltText) const
301*0deba7fbSSteve Yin {
302*0deba7fbSSteve Yin     sal_uInt16 maxPages = mpDoc->GetPageCount();
303*0deba7fbSSteve Yin     sal_uInt16 pageNo;
304*0deba7fbSSteve Yin     SdrObject*   pObj = NULL;
305*0deba7fbSSteve Yin     SdPage* pPage = NULL;
306*0deba7fbSSteve Yin 
307*0deba7fbSSteve Yin 
308*0deba7fbSSteve Yin     String ParentName = GetEntryText( GetRootLevelParent( pEntry ) );
309*0deba7fbSSteve Yin 
310*0deba7fbSSteve Yin     for( pageNo = 0;  pageNo < maxPages; pageNo++ )
311*0deba7fbSSteve Yin     {
312*0deba7fbSSteve Yin         pPage = (SdPage*) mpDoc->GetPage( pageNo );
313*0deba7fbSSteve Yin         if( pPage->GetPageKind() != PK_STANDARD ) continue;
314*0deba7fbSSteve Yin         if( pPage->GetName() !=  ParentName ) continue;
315*0deba7fbSSteve Yin         SdrObjListIter aIter( *pPage, IM_FLAT );
316*0deba7fbSSteve Yin         while( aIter.IsMore() )
317*0deba7fbSSteve Yin         {
318*0deba7fbSSteve Yin             pObj = aIter.Next();
319*0deba7fbSSteve Yin             if( GetEntryText(pEntry) ==  GetObjectName( pObj )  )
320*0deba7fbSSteve Yin             {
321*0deba7fbSSteve Yin                 if( isAltText )
322*0deba7fbSSteve Yin                     return pObj->GetTitle();
323*0deba7fbSSteve Yin                 else
324*0deba7fbSSteve Yin                     return pObj->GetDescription();
325*0deba7fbSSteve Yin             }
326*0deba7fbSSteve Yin         }
327*0deba7fbSSteve Yin     }
328*0deba7fbSSteve Yin     return String();
329*0deba7fbSSteve Yin 
330*0deba7fbSSteve Yin }
331*0deba7fbSSteve Yin 
332*0deba7fbSSteve Yin String SdPageObjsTLB::GetEntryAltText( SvLBoxEntry* pEntry ) const
333*0deba7fbSSteve Yin {
334*0deba7fbSSteve Yin     return getAltLongDescText( pEntry, sal_True );
335*0deba7fbSSteve Yin }
336*0deba7fbSSteve Yin 
337*0deba7fbSSteve Yin String SdPageObjsTLB::GetEntryLongDescription( SvLBoxEntry* pEntry ) const
338*0deba7fbSSteve Yin {
339*0deba7fbSSteve Yin     return getAltLongDescText( pEntry, sal_False);
340*0deba7fbSSteve Yin }
341*0deba7fbSSteve Yin 
342*0deba7fbSSteve Yin void  SdPageObjsTLB::MarkCurEntry( const String& rName )
343*0deba7fbSSteve Yin {
344*0deba7fbSSteve Yin 
345*0deba7fbSSteve Yin     if( rName.Len() )
346*0deba7fbSSteve Yin     {
347*0deba7fbSSteve Yin         SvLBoxEntry* pCurEntry =GetCurEntry();
348*0deba7fbSSteve Yin         SvLBoxEntry* pEntry =NULL;
349*0deba7fbSSteve Yin         String aTmp1;
350*0deba7fbSSteve Yin         String aTmp2;
351*0deba7fbSSteve Yin 
352*0deba7fbSSteve Yin            if( GetParent(pCurEntry)==NULL )
353*0deba7fbSSteve Yin            {
354*0deba7fbSSteve Yin                   aTmp1 = GetEntryText( pCurEntry );
355*0deba7fbSSteve Yin                for( pEntry = First(); pEntry ; pEntry = Next( pEntry ) )
356*0deba7fbSSteve Yin             {
357*0deba7fbSSteve Yin                    if(GetParent( pEntry )==NULL)
358*0deba7fbSSteve Yin                          continue;
359*0deba7fbSSteve Yin                 aTmp2 = GetEntryText( GetParent( pEntry ));
360*0deba7fbSSteve Yin                 if( aTmp1 != aTmp2)
361*0deba7fbSSteve Yin                 {
362*0deba7fbSSteve Yin                     // IA2 CWS. MT: Removed in SvLBoxEntry for now - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this
363*0deba7fbSSteve Yin                     pEntry->SetMarked(sal_False);
364*0deba7fbSSteve Yin                 }
365*0deba7fbSSteve Yin             }
366*0deba7fbSSteve Yin 
367*0deba7fbSSteve Yin            }
368*0deba7fbSSteve Yin               else
369*0deba7fbSSteve Yin               {
370*0deba7fbSSteve Yin                   for( pEntry = First(); pEntry ; pEntry = Next( pEntry ) )
371*0deba7fbSSteve Yin             {
372*0deba7fbSSteve Yin                 aTmp2 = GetEntryText( pEntry );
373*0deba7fbSSteve Yin                 if( aTmp2 == rName)
374*0deba7fbSSteve Yin                 {
375*0deba7fbSSteve Yin                     pEntry->SetMarked(sal_True);
376*0deba7fbSSteve Yin                 }
377*0deba7fbSSteve Yin                 else
378*0deba7fbSSteve Yin                 {
379*0deba7fbSSteve Yin                         pEntry->SetMarked(sal_False);
380*0deba7fbSSteve Yin                 }
381*0deba7fbSSteve Yin             }
382*0deba7fbSSteve Yin               }
383*0deba7fbSSteve Yin     }
384*0deba7fbSSteve Yin     Invalidate();
385*0deba7fbSSteve Yin }
386*0deba7fbSSteve Yin 
387*0deba7fbSSteve Yin void  SdPageObjsTLB:: FreshCurEntry()
388*0deba7fbSSteve Yin {
389*0deba7fbSSteve Yin        SvLBoxEntry* pEntry =NULL;
390*0deba7fbSSteve Yin        for( pEntry = First(); pEntry ; pEntry = Next( pEntry ) )
391*0deba7fbSSteve Yin     {
392*0deba7fbSSteve Yin                 pEntry->SetMarked(sal_False);
393*0deba7fbSSteve Yin     }
394*0deba7fbSSteve Yin     Invalidate();
395*0deba7fbSSteve Yin }
396*0deba7fbSSteve Yin 
397*0deba7fbSSteve Yin class SdContentLBoxString : public SvLBoxString
398*0deba7fbSSteve Yin {
399*0deba7fbSSteve Yin public:
400*0deba7fbSSteve Yin     SdContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
401*0deba7fbSSteve Yin         const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {}
402*0deba7fbSSteve Yin 
403*0deba7fbSSteve Yin     virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
404*0deba7fbSSteve Yin         SvLBoxEntry* pEntry);
405*0deba7fbSSteve Yin };
406*0deba7fbSSteve Yin 
407*0deba7fbSSteve Yin void SdPageObjsTLB::InitEntry(SvLBoxEntry* pEntry,
408*0deba7fbSSteve Yin         const XubString& rStr ,const Image& rImg1,const Image& rImg2,SvLBoxButtonKind eButtonKind)
409*0deba7fbSSteve Yin {
410*0deba7fbSSteve Yin     sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
411*0deba7fbSSteve Yin     SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
412*0deba7fbSSteve Yin     SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
413*0deba7fbSSteve Yin     SdContentLBoxString* pStr = new SdContentLBoxString( pEntry, 0, pCol->GetText() );
414*0deba7fbSSteve Yin     pEntry->ReplaceItem( pStr, nColToHilite );
415*0deba7fbSSteve Yin }
416*0deba7fbSSteve Yin 
417*0deba7fbSSteve Yin void SdContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
418*0deba7fbSSteve Yin     SvLBoxEntry* pEntry )
419*0deba7fbSSteve Yin {
420*0deba7fbSSteve Yin     // IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this
421*0deba7fbSSteve Yin     /*
422*0deba7fbSSteve Yin     if (pEntry->IsMarked())
423*0deba7fbSSteve Yin     {
424*0deba7fbSSteve Yin             rDev.DrawText( rPos, GetText() );
425*0deba7fbSSteve Yin             XubString str;
426*0deba7fbSSteve Yin             str = XubString::CreateFromAscii("*");
427*0deba7fbSSteve Yin             Point rPosStar(rPos.X()-6,rPos.Y());
428*0deba7fbSSteve Yin             Font aOldFont( rDev.GetFont());
429*0deba7fbSSteve Yin             Font aFont(aOldFont);
430*0deba7fbSSteve Yin             Color aCol( aOldFont.GetColor() );
431*0deba7fbSSteve Yin             aCol.DecreaseLuminance( 200 );
432*0deba7fbSSteve Yin             aFont.SetColor( aCol );
433*0deba7fbSSteve Yin             rDev.SetFont( aFont );
434*0deba7fbSSteve Yin             rDev.DrawText( rPosStar, str);
435*0deba7fbSSteve Yin             rDev.SetFont( aOldFont );
436*0deba7fbSSteve Yin     }
437*0deba7fbSSteve Yin     else
438*0deba7fbSSteve Yin     */
439*0deba7fbSSteve Yin         SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
440*0deba7fbSSteve Yin 
441*0deba7fbSSteve Yin }
442*0deba7fbSSteve Yin 
443*0deba7fbSSteve Yin void SdPageObjsTLB::SaveExpandedTreeItemState(SvLBoxEntry* pEntry, vector<String>& vectTreeItem)
444*0deba7fbSSteve Yin {
445*0deba7fbSSteve Yin     if (pEntry)
446*0deba7fbSSteve Yin     {
447*0deba7fbSSteve Yin         SvLBoxEntry* pListEntry = pEntry;
448*0deba7fbSSteve Yin         while (pListEntry)
449*0deba7fbSSteve Yin         {
450*0deba7fbSSteve Yin             if (pListEntry->HasChilds())
451*0deba7fbSSteve Yin             {
452*0deba7fbSSteve Yin                 if (IsExpanded(pListEntry))
453*0deba7fbSSteve Yin                     vectTreeItem.push_back(GetEntryText(pListEntry));
454*0deba7fbSSteve Yin                 SvLBoxEntry* pChildEntry = FirstChild(pListEntry);
455*0deba7fbSSteve Yin                 SaveExpandedTreeItemState(pChildEntry, vectTreeItem);
456*0deba7fbSSteve Yin             }
457*0deba7fbSSteve Yin             pListEntry = NextSibling(pListEntry);
458*0deba7fbSSteve Yin         }
459*0deba7fbSSteve Yin     }
460*0deba7fbSSteve Yin }
461*0deba7fbSSteve Yin void SdPageObjsTLB::Clear()
462*0deba7fbSSteve Yin {
463*0deba7fbSSteve Yin     //Save the expanded tree item
464*0deba7fbSSteve Yin     if (mbSaveTreeItemState)
465*0deba7fbSSteve Yin     {
466*0deba7fbSSteve Yin         maSelectionEntryText = String();
467*0deba7fbSSteve Yin         maTreeItem.clear();
468*0deba7fbSSteve Yin         if (GetCurEntry())
469*0deba7fbSSteve Yin             maSelectionEntryText = GetSelectEntry();
470*0deba7fbSSteve Yin         SvLBoxEntry* pEntry = FirstChild(NULL);
471*0deba7fbSSteve Yin         SaveExpandedTreeItemState(pEntry, maTreeItem);
472*0deba7fbSSteve Yin     }
473*0deba7fbSSteve Yin     return SvTreeListBox::Clear();
474*0deba7fbSSteve Yin }
475*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
476cdf0e10cSrcweir /*************************************************************************
477cdf0e10cSrcweir |*
478cdf0e10cSrcweir |* return name of object
479cdf0e10cSrcweir |*
480cdf0e10cSrcweir \************************************************************************/
481cdf0e10cSrcweir 
482cdf0e10cSrcweir String SdPageObjsTLB::GetObjectName(
483cdf0e10cSrcweir     const SdrObject* pObject,
484cdf0e10cSrcweir     const bool bCreate) const
485cdf0e10cSrcweir {
486cdf0e10cSrcweir     String aRet;
487cdf0e10cSrcweir 
488cdf0e10cSrcweir     if ( pObject )
489cdf0e10cSrcweir     {
490cdf0e10cSrcweir         aRet = pObject->GetName();
491cdf0e10cSrcweir 
492cdf0e10cSrcweir         if( !aRet.Len() && pObject->ISA( SdrOle2Obj ) )
493cdf0e10cSrcweir             aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
494cdf0e10cSrcweir     }
495cdf0e10cSrcweir 
496cdf0e10cSrcweir     if (bCreate
497cdf0e10cSrcweir         && mbShowAllShapes
498cdf0e10cSrcweir         && aRet.Len() == 0
499cdf0e10cSrcweir         && pObject!=NULL)
500cdf0e10cSrcweir     {
501cdf0e10cSrcweir         aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME);
502cdf0e10cSrcweir         aRet.SearchAndReplaceAscii("%1", String::CreateFromInt32(pObject->GetOrdNum() + 1));
503cdf0e10cSrcweir     }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     return aRet;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir /*************************************************************************
509cdf0e10cSrcweir |*
510cdf0e10cSrcweir |* In TreeLB Eintrag selektieren
511cdf0e10cSrcweir |*
512cdf0e10cSrcweir \************************************************************************/
513cdf0e10cSrcweir 
514cdf0e10cSrcweir sal_Bool SdPageObjsTLB::SelectEntry( const String& rName )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir     sal_Bool bFound = sal_False;
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     if( rName.Len() )
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         SvLBoxEntry* pEntry = NULL;
521cdf0e10cSrcweir         String aTmp;
522cdf0e10cSrcweir 
523cdf0e10cSrcweir         for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
524cdf0e10cSrcweir         {
525cdf0e10cSrcweir             aTmp = GetEntryText( pEntry );
526cdf0e10cSrcweir             if( aTmp == rName )
527cdf0e10cSrcweir             {
528cdf0e10cSrcweir                 bFound = sal_True;
529cdf0e10cSrcweir                 SetCurEntry( pEntry );
530cdf0e10cSrcweir             }
531cdf0e10cSrcweir         }
532cdf0e10cSrcweir     }
533cdf0e10cSrcweir     return( bFound );
534cdf0e10cSrcweir }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir /*************************************************************************
537cdf0e10cSrcweir |*
538cdf0e10cSrcweir |* Gibt zurueck, ob Childs des uebergebenen Strings selektiert sind
539cdf0e10cSrcweir |*
540cdf0e10cSrcweir \************************************************************************/
541cdf0e10cSrcweir 
542cdf0e10cSrcweir sal_Bool SdPageObjsTLB::HasSelectedChilds( const String& rName )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir     sal_Bool bFound  = sal_False;
545cdf0e10cSrcweir     sal_Bool bChilds = sal_False;
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     if( rName.Len() )
548cdf0e10cSrcweir     {
549cdf0e10cSrcweir         SvLBoxEntry* pEntry = NULL;
550cdf0e10cSrcweir         String aTmp;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir         for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
553cdf0e10cSrcweir         {
554cdf0e10cSrcweir             aTmp = GetEntryText( pEntry );
555cdf0e10cSrcweir             if( aTmp == rName )
556cdf0e10cSrcweir             {
557cdf0e10cSrcweir                 bFound = sal_True;
558cdf0e10cSrcweir                 sal_Bool bExpanded = IsExpanded( pEntry );
559cdf0e10cSrcweir                 long nCount = GetChildSelectionCount( pEntry );
560cdf0e10cSrcweir                 if( bExpanded && nCount > 0 )
561cdf0e10cSrcweir                     bChilds = sal_True;
562cdf0e10cSrcweir             }
563cdf0e10cSrcweir         }
564cdf0e10cSrcweir     }
565cdf0e10cSrcweir     return( bChilds );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 
569cdf0e10cSrcweir /*************************************************************************
570cdf0e10cSrcweir |*
571cdf0e10cSrcweir |* TreeLB mit Seiten und Objekten fuellen
572cdf0e10cSrcweir |*
573cdf0e10cSrcweir \************************************************************************/
574cdf0e10cSrcweir 
575cdf0e10cSrcweir void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, sal_Bool bAllPages,
576cdf0e10cSrcweir                           const String& rDocName)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     String aSelection;
579cdf0e10cSrcweir     if( GetSelectionCount() > 0 )
580cdf0e10cSrcweir     {
581cdf0e10cSrcweir         aSelection = GetSelectEntry();
582cdf0e10cSrcweir         Clear();
583cdf0e10cSrcweir     }
584cdf0e10cSrcweir 
585cdf0e10cSrcweir     mpDoc = pInDoc;
586cdf0e10cSrcweir     maDocName = rDocName;
587cdf0e10cSrcweir     mbShowAllPages = (bAllPages == sal_True);
588cdf0e10cSrcweir     mpMedium = NULL;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir     SdPage*      pPage = NULL;
591cdf0e10cSrcweir 
592cdf0e10cSrcweir     IconProvider aIconProvider;
593cdf0e10cSrcweir 
594cdf0e10cSrcweir     // first insert all pages including objects
595cdf0e10cSrcweir     sal_uInt16 nPage = 0;
596cdf0e10cSrcweir     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
597cdf0e10cSrcweir 
598cdf0e10cSrcweir     while( nPage < nMaxPages )
599cdf0e10cSrcweir     {
600cdf0e10cSrcweir         pPage = (SdPage*) mpDoc->GetPage( nPage );
601cdf0e10cSrcweir         if(  (mbShowAllPages || pPage->GetPageKind() == PK_STANDARD)
602cdf0e10cSrcweir              && !(pPage->GetPageKind()==PK_HANDOUT)   ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
603cdf0e10cSrcweir         {
604cdf0e10cSrcweir             sal_Bool bPageExluded = pPage->IsExcluded();
605cdf0e10cSrcweir 
606cdf0e10cSrcweir             bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
607cdf0e10cSrcweir             bPageExluded |= !bPageBelongsToShow;
608cdf0e10cSrcweir 
609cdf0e10cSrcweir             AddShapeList(*pPage, NULL, pPage->GetName(), bPageExluded, NULL, aIconProvider);
610cdf0e10cSrcweir         }
611cdf0e10cSrcweir         nPage++;
612cdf0e10cSrcweir     }
613cdf0e10cSrcweir 
614cdf0e10cSrcweir     // dann alle MasterPages incl. Objekte einfuegen
615cdf0e10cSrcweir     if( mbShowAllPages )
616cdf0e10cSrcweir     {
617cdf0e10cSrcweir         nPage = 0;
618cdf0e10cSrcweir         const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
619cdf0e10cSrcweir 
620cdf0e10cSrcweir         while( nPage < nMaxMasterPages )
621cdf0e10cSrcweir         {
622cdf0e10cSrcweir             pPage = (SdPage*) mpDoc->GetMasterPage( nPage );
623cdf0e10cSrcweir             AddShapeList(*pPage, NULL, pPage->GetName(), false, NULL, aIconProvider);
624cdf0e10cSrcweir             nPage++;
625cdf0e10cSrcweir         }
626cdf0e10cSrcweir     }
627cdf0e10cSrcweir     if( aSelection.Len() )
628cdf0e10cSrcweir         SelectEntry( aSelection );
629*0deba7fbSSteve Yin     else if (mbSaveTreeItemState && maSelectionEntryText.Len())
630*0deba7fbSSteve Yin     {
631*0deba7fbSSteve Yin         SelectEntry(maSelectionEntryText);
632*0deba7fbSSteve Yin     }
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir /*************************************************************************
636cdf0e10cSrcweir |*
637cdf0e10cSrcweir |* Es wird nur der erste Eintrag eingefuegt. Childs werden OnDemand erzeugt
638cdf0e10cSrcweir |*
639cdf0e10cSrcweir \************************************************************************/
640cdf0e10cSrcweir 
641cdf0e10cSrcweir void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
642cdf0e10cSrcweir                           const String& rDocName )
643cdf0e10cSrcweir {
644cdf0e10cSrcweir     mpDoc = pInDoc;
645cdf0e10cSrcweir 
646cdf0e10cSrcweir     // this object now owns the Medium
647cdf0e10cSrcweir     mpMedium = pInMedium;
648cdf0e10cSrcweir     maDocName = rDocName;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir     Image aImgDocOpen=Image( BitmapEx( SdResId( BMP_DOC_OPEN ) ) );
651cdf0e10cSrcweir     Image aImgDocClosed=Image( BitmapEx( SdResId( BMP_DOC_CLOSED ) ) );
652cdf0e10cSrcweir     Image aImgDocOpenH=Image( BitmapEx( SdResId( BMP_DOC_OPEN_H ) ) );
653cdf0e10cSrcweir     Image aImgDocClosedH=Image( BitmapEx( SdResId( BMP_DOC_CLOSED_H ) ) );
654cdf0e10cSrcweir 
655cdf0e10cSrcweir     // Dokumentnamen einfuegen
656cdf0e10cSrcweir     SvLBoxEntry* pFileEntry = InsertEntry( maDocName,
657cdf0e10cSrcweir                               aImgDocOpen,
658cdf0e10cSrcweir                               aImgDocClosed,
659cdf0e10cSrcweir                               NULL,
660cdf0e10cSrcweir                               sal_True,
661cdf0e10cSrcweir                               LIST_APPEND,
662cdf0e10cSrcweir                               reinterpret_cast< void* >( 1 ) );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     SetExpandedEntryBmp( pFileEntry, aImgDocOpenH, BMP_COLOR_HIGHCONTRAST );
665cdf0e10cSrcweir     SetCollapsedEntryBmp( pFileEntry, aImgDocClosedH, BMP_COLOR_HIGHCONTRAST );
666cdf0e10cSrcweir }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 
671cdf0e10cSrcweir void SdPageObjsTLB::AddShapeList (
672cdf0e10cSrcweir     const SdrObjList& rList,
673cdf0e10cSrcweir     SdrObject* pShape,
674cdf0e10cSrcweir     const ::rtl::OUString& rsName,
675cdf0e10cSrcweir     const bool bIsExcluded,
676cdf0e10cSrcweir     SvLBoxEntry* pParentEntry,
677cdf0e10cSrcweir     const IconProvider& rIconProvider)
678cdf0e10cSrcweir {
679cdf0e10cSrcweir     Image aIcon (rIconProvider.maImgPage);
680cdf0e10cSrcweir     if (bIsExcluded)
681cdf0e10cSrcweir         aIcon = rIconProvider.maImgPageExcl;
682cdf0e10cSrcweir     else if (pShape != NULL)
683cdf0e10cSrcweir         aIcon = rIconProvider.maImgGroup;
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     void* pUserData (reinterpret_cast<void*>(1));
686cdf0e10cSrcweir     if (pShape != NULL)
687cdf0e10cSrcweir         pUserData = pShape;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     SvLBoxEntry* pEntry = InsertEntry(
690cdf0e10cSrcweir         rsName,
691cdf0e10cSrcweir         aIcon,
692cdf0e10cSrcweir         aIcon,
693cdf0e10cSrcweir         pParentEntry,
694cdf0e10cSrcweir         sal_False,
695cdf0e10cSrcweir         LIST_APPEND,
696cdf0e10cSrcweir         pUserData);
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     SetExpandedEntryBmp(
699cdf0e10cSrcweir         pEntry,
700cdf0e10cSrcweir         bIsExcluded ? rIconProvider.maImgPageExclH : rIconProvider.maImgPageH,
701cdf0e10cSrcweir         BMP_COLOR_HIGHCONTRAST );
702cdf0e10cSrcweir     SetCollapsedEntryBmp(
703cdf0e10cSrcweir         pEntry,
704cdf0e10cSrcweir         bIsExcluded ? rIconProvider.maImgPageExclH : rIconProvider.maImgPageH,
705cdf0e10cSrcweir         BMP_COLOR_HIGHCONTRAST );
706cdf0e10cSrcweir 
707cdf0e10cSrcweir     SdrObjListIter aIter(
708cdf0e10cSrcweir         rList,
709cdf0e10cSrcweir         !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
710cdf0e10cSrcweir         IM_FLAT,
711cdf0e10cSrcweir         sal_False /*not reverse*/);
712cdf0e10cSrcweir 
713*0deba7fbSSteve Yin     //IAccessibility2 Implementation 2009-----
714*0deba7fbSSteve Yin     sal_Bool  bMarked=sal_False;
715*0deba7fbSSteve Yin     if(bisInSdNavigatorWin)
716*0deba7fbSSteve Yin     {
717*0deba7fbSSteve Yin         Window* pWindow=NULL;
718*0deba7fbSSteve Yin         SdNavigatorWin* pSdNavigatorWin=NULL;
719*0deba7fbSSteve Yin         sd::DrawDocShell* pSdDrawDocShell = NULL;
720*0deba7fbSSteve Yin         if(pEntry)
721*0deba7fbSSteve Yin             pWindow=(Window*)GetParent(pEntry);
722*0deba7fbSSteve Yin         if(pWindow)
723*0deba7fbSSteve Yin             pSdNavigatorWin = (SdNavigatorWin*)pWindow;
724*0deba7fbSSteve Yin         if( pSdNavigatorWin )
725*0deba7fbSSteve Yin             pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc);
726*0deba7fbSSteve Yin         if(pSdDrawDocShell)
727*0deba7fbSSteve Yin             bMarked=pSdDrawDocShell->IsMarked(pShape);
728*0deba7fbSSteve Yin         if(pEntry)
729*0deba7fbSSteve Yin         {
730*0deba7fbSSteve Yin             if(bMarked)
731*0deba7fbSSteve Yin                 pEntry->SetMarked(sal_True);
732*0deba7fbSSteve Yin             else
733*0deba7fbSSteve Yin                 pEntry->SetMarked( sal_False );
734*0deba7fbSSteve Yin         }
735*0deba7fbSSteve Yin     }
736*0deba7fbSSteve Yin     //-----IAccessibility2 Implementation 2009
737cdf0e10cSrcweir     while( aIter.IsMore() )
738cdf0e10cSrcweir     {
739cdf0e10cSrcweir         SdrObject* pObj = aIter.Next();
740cdf0e10cSrcweir         OSL_ASSERT(pObj!=NULL);
741cdf0e10cSrcweir 
742cdf0e10cSrcweir         // Get the shape name.
743cdf0e10cSrcweir         String aStr (GetObjectName( pObj ) );
744cdf0e10cSrcweir 
745cdf0e10cSrcweir         if( aStr.Len() )
746cdf0e10cSrcweir         {
747cdf0e10cSrcweir             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
748cdf0e10cSrcweir             {
749cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = InsertEntry( aStr, maImgOle, maImgOle, pEntry,
750cdf0e10cSrcweir                     sal_False, LIST_APPEND, pObj);
751*0deba7fbSSteve Yin                 //IAccessibility2 Implementation 2009-----
752*0deba7fbSSteve Yin                 if(bisInSdNavigatorWin)
753*0deba7fbSSteve Yin                 {
754*0deba7fbSSteve Yin                     Window* pWindow=NULL;
755*0deba7fbSSteve Yin                     SdNavigatorWin* pSdNavigatorWin=NULL;
756*0deba7fbSSteve Yin                     sd::DrawDocShell* pSdDrawDocShell = NULL;
757*0deba7fbSSteve Yin                     if(pNewEntry)
758*0deba7fbSSteve Yin                         pWindow=(Window*)GetParent(pNewEntry);
759*0deba7fbSSteve Yin                     if(pWindow)
760*0deba7fbSSteve Yin                         pSdNavigatorWin = (SdNavigatorWin*)pWindow;
761*0deba7fbSSteve Yin                     if( pSdNavigatorWin )
762*0deba7fbSSteve Yin                         pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc);
763*0deba7fbSSteve Yin                     if(pSdDrawDocShell)
764*0deba7fbSSteve Yin                         bMarked=pSdDrawDocShell->IsMarked((SdrObject*)pObj);
765*0deba7fbSSteve Yin                     if(pNewEntry)
766*0deba7fbSSteve Yin                     {
767*0deba7fbSSteve Yin                         if(bMarked)
768*0deba7fbSSteve Yin                             pNewEntry->SetMarked(sal_True);
769*0deba7fbSSteve Yin                         else
770*0deba7fbSSteve Yin                             pNewEntry->SetMarked( sal_False );
771*0deba7fbSSteve Yin                     }
772*0deba7fbSSteve Yin                 }
773*0deba7fbSSteve Yin                 //-----IAccessibility2 Implementation 2009
774cdf0e10cSrcweir                 SetExpandedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
775cdf0e10cSrcweir                 SetCollapsedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
776cdf0e10cSrcweir             }
777cdf0e10cSrcweir             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
778cdf0e10cSrcweir             {
779cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = InsertEntry( aStr, maImgGraphic, maImgGraphic, pEntry,
780cdf0e10cSrcweir                     sal_False, LIST_APPEND, pObj );
781*0deba7fbSSteve Yin                 //IAccessibility2 Implementation 2009-----
782*0deba7fbSSteve Yin                 if(bisInSdNavigatorWin)
783*0deba7fbSSteve Yin                 {
784*0deba7fbSSteve Yin                     Window* pWindow=NULL;
785*0deba7fbSSteve Yin                     SdNavigatorWin* pSdNavigatorWin=NULL;
786*0deba7fbSSteve Yin                     sd::DrawDocShell* pSdDrawDocShell = NULL;
787*0deba7fbSSteve Yin                     if(pNewEntry)
788*0deba7fbSSteve Yin                         pWindow=(Window*)GetParent(pNewEntry);
789*0deba7fbSSteve Yin                     if(pWindow)
790*0deba7fbSSteve Yin                         pSdNavigatorWin = (SdNavigatorWin*)pWindow;
791*0deba7fbSSteve Yin                     if( pSdNavigatorWin )
792*0deba7fbSSteve Yin                         pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc);
793*0deba7fbSSteve Yin                     if(pSdDrawDocShell)
794*0deba7fbSSteve Yin                         bMarked=pSdDrawDocShell->IsMarked((SdrObject*)pObj);
795*0deba7fbSSteve Yin                     if(pNewEntry)
796*0deba7fbSSteve Yin                     {
797*0deba7fbSSteve Yin                         if(bMarked)
798*0deba7fbSSteve Yin                         {
799*0deba7fbSSteve Yin                             pNewEntry->SetMarked(sal_True);
800*0deba7fbSSteve Yin                         }
801*0deba7fbSSteve Yin                         else
802*0deba7fbSSteve Yin                         {
803*0deba7fbSSteve Yin                             pNewEntry->SetMarked( sal_False );
804*0deba7fbSSteve Yin                         }
805*0deba7fbSSteve Yin                     }
806*0deba7fbSSteve Yin                 }
807*0deba7fbSSteve Yin                 //-----IAccessibility2 Implementation 2009
808cdf0e10cSrcweir                 SetExpandedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
809cdf0e10cSrcweir                 SetCollapsedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
810cdf0e10cSrcweir             }
811cdf0e10cSrcweir             else if (pObj->IsGroupObject())
812cdf0e10cSrcweir             {
813cdf0e10cSrcweir                 AddShapeList(
814cdf0e10cSrcweir                     *pObj->GetSubList(),
815cdf0e10cSrcweir                     pObj,
816cdf0e10cSrcweir                     aStr,
817cdf0e10cSrcweir                     false,
818cdf0e10cSrcweir                     pEntry,
819cdf0e10cSrcweir                     rIconProvider);
820cdf0e10cSrcweir             }
821cdf0e10cSrcweir             else
822cdf0e10cSrcweir             {
823cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = InsertEntry( aStr, rIconProvider.maImgObjects, rIconProvider.maImgObjects, pEntry,
824cdf0e10cSrcweir                     sal_False, LIST_APPEND, pObj );
825*0deba7fbSSteve Yin                 //IAccessibility2 Implementation 2009-----
826*0deba7fbSSteve Yin                 if(bisInSdNavigatorWin)
827*0deba7fbSSteve Yin                 {
828*0deba7fbSSteve Yin                     Window* pWindow=NULL;
829*0deba7fbSSteve Yin                     SdNavigatorWin* pSdNavigatorWin=NULL;
830*0deba7fbSSteve Yin                     sd::DrawDocShell* pSdDrawDocShell = NULL;
831*0deba7fbSSteve Yin                     if(pNewEntry)
832*0deba7fbSSteve Yin                         pWindow=(Window*)GetParent(pNewEntry);
833*0deba7fbSSteve Yin                     if(pWindow)
834*0deba7fbSSteve Yin                         pSdNavigatorWin = (SdNavigatorWin*)pWindow;
835*0deba7fbSSteve Yin                     if( pSdNavigatorWin )
836*0deba7fbSSteve Yin                         pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc);
837*0deba7fbSSteve Yin                     if(pSdDrawDocShell)
838*0deba7fbSSteve Yin                         bMarked=pSdDrawDocShell->IsMarked((SdrObject*)pObj);
839*0deba7fbSSteve Yin                     if(pNewEntry)
840*0deba7fbSSteve Yin                     {
841*0deba7fbSSteve Yin                         if(bMarked)
842*0deba7fbSSteve Yin                         {
843*0deba7fbSSteve Yin                             pNewEntry->SetMarked(sal_True);
844*0deba7fbSSteve Yin                         }
845*0deba7fbSSteve Yin                         else
846*0deba7fbSSteve Yin                         {
847*0deba7fbSSteve Yin                             pNewEntry->SetMarked( sal_False );
848*0deba7fbSSteve Yin                         }
849*0deba7fbSSteve Yin                     }
850*0deba7fbSSteve Yin                 }
851*0deba7fbSSteve Yin                 //-----IAccessibility2 Implementation 2009
852cdf0e10cSrcweir                 SetExpandedEntryBmp( pNewEntry, rIconProvider.maImgObjectsH, BMP_COLOR_HIGHCONTRAST );
853cdf0e10cSrcweir                 SetCollapsedEntryBmp( pNewEntry, rIconProvider.maImgObjectsH, BMP_COLOR_HIGHCONTRAST );
854cdf0e10cSrcweir             }
855cdf0e10cSrcweir         }
856cdf0e10cSrcweir     }
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     if( pEntry->HasChilds() )
859cdf0e10cSrcweir     {
860cdf0e10cSrcweir         SetExpandedEntryBmp(
861cdf0e10cSrcweir             pEntry,
862cdf0e10cSrcweir             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
863cdf0e10cSrcweir         SetCollapsedEntryBmp(
864cdf0e10cSrcweir             pEntry,
865cdf0e10cSrcweir             bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
866cdf0e10cSrcweir         SetExpandedEntryBmp(
867cdf0e10cSrcweir             pEntry,
868cdf0e10cSrcweir             bIsExcluded ? rIconProvider.maImgPageObjsExclH : rIconProvider.maImgPageObjsH,
869cdf0e10cSrcweir             BMP_COLOR_HIGHCONTRAST);
870cdf0e10cSrcweir         SetCollapsedEntryBmp(
871cdf0e10cSrcweir             pEntry,
872cdf0e10cSrcweir             bIsExcluded ? rIconProvider.maImgPageObjsExclH : rIconProvider.maImgPageObjsH,
873cdf0e10cSrcweir             BMP_COLOR_HIGHCONTRAST);
874*0deba7fbSSteve Yin         //IAccessibility2 Implementation 2009-----
875*0deba7fbSSteve Yin         if (mbSaveTreeItemState)
876*0deba7fbSSteve Yin         {
877*0deba7fbSSteve Yin             vector<String>:: iterator iteStart = maTreeItem.begin();
878*0deba7fbSSteve Yin             while (iteStart != maTreeItem.end())
879*0deba7fbSSteve Yin             {
880*0deba7fbSSteve Yin                 String strEntry = GetEntryText(pEntry);
881*0deba7fbSSteve Yin                 if (*iteStart == strEntry)
882*0deba7fbSSteve Yin                 {
883*0deba7fbSSteve Yin                     Expand( pEntry );
884*0deba7fbSSteve Yin                     break;
885*0deba7fbSSteve Yin                 }
886*0deba7fbSSteve Yin                 ++iteStart;
887*0deba7fbSSteve Yin             }
888*0deba7fbSSteve Yin         }
889*0deba7fbSSteve Yin         else
890*0deba7fbSSteve Yin             Expand( pEntry );
891*0deba7fbSSteve Yin         //-----IAccessibility2 Implementation 2009
892cdf0e10cSrcweir     }
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 
898cdf0e10cSrcweir void SdPageObjsTLB::SetShowAllShapes (
899cdf0e10cSrcweir     const bool bShowAllShapes,
900cdf0e10cSrcweir     const bool bFillList)
901cdf0e10cSrcweir {
902cdf0e10cSrcweir     mbShowAllShapes = bShowAllShapes;
903cdf0e10cSrcweir     if (bFillList)
904cdf0e10cSrcweir     {
905cdf0e10cSrcweir         if (mpMedium == NULL)
906cdf0e10cSrcweir             Fill(mpDoc, mbShowAllPages, maDocName);
907cdf0e10cSrcweir         else
908cdf0e10cSrcweir             Fill(mpDoc, mpMedium, maDocName);
909cdf0e10cSrcweir     }
910cdf0e10cSrcweir }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 
915cdf0e10cSrcweir bool SdPageObjsTLB::GetShowAllShapes (void) const
916cdf0e10cSrcweir {
917cdf0e10cSrcweir     return mbShowAllShapes;
918cdf0e10cSrcweir }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 
923cdf0e10cSrcweir /*************************************************************************
924cdf0e10cSrcweir |*
925cdf0e10cSrcweir |* Prueft, ob die Seiten (PK_STANDARD) und die darauf befindlichen Objekte
926cdf0e10cSrcweir |* des Docs und der TreeLB identisch sind.
927cdf0e10cSrcweir |* Wird ein Doc uebergeben, wird dieses zum aktuellem Doc (Wichtig bei
928cdf0e10cSrcweir |* mehreren Documenten).
929cdf0e10cSrcweir |*
930cdf0e10cSrcweir \************************************************************************/
931cdf0e10cSrcweir 
932cdf0e10cSrcweir sal_Bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir     if( pInDoc )
935cdf0e10cSrcweir         mpDoc = pInDoc;
936cdf0e10cSrcweir 
937cdf0e10cSrcweir     if( !mpDoc )
938cdf0e10cSrcweir         return( sal_False );
939cdf0e10cSrcweir 
940cdf0e10cSrcweir     SdrObject*   pObj = NULL;
941cdf0e10cSrcweir     SdPage*      pPage = NULL;
942cdf0e10cSrcweir     SvLBoxEntry* pEntry = First();
943cdf0e10cSrcweir     String       aName;
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     // Alle Pages incl. Objekte vergleichen
946cdf0e10cSrcweir     sal_uInt16 nPage = 0;
947cdf0e10cSrcweir     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
948cdf0e10cSrcweir 
949cdf0e10cSrcweir     while( nPage < nMaxPages )
950cdf0e10cSrcweir     {
951cdf0e10cSrcweir         pPage = (SdPage*) mpDoc->GetPage( nPage );
952cdf0e10cSrcweir         if( pPage->GetPageKind() == PK_STANDARD )
953cdf0e10cSrcweir         {
954cdf0e10cSrcweir             if( !pEntry )
955cdf0e10cSrcweir                 return( sal_False );
956cdf0e10cSrcweir             aName = GetEntryText( pEntry );
957cdf0e10cSrcweir 
958cdf0e10cSrcweir             if( pPage->GetName() != aName )
959cdf0e10cSrcweir                 return( sal_False );
960cdf0e10cSrcweir 
961cdf0e10cSrcweir             pEntry = Next( pEntry );
962cdf0e10cSrcweir 
963cdf0e10cSrcweir             SdrObjListIter aIter(
964cdf0e10cSrcweir                 *pPage,
965cdf0e10cSrcweir                 !pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
966cdf0e10cSrcweir                 IM_DEEPWITHGROUPS );
967cdf0e10cSrcweir 
968cdf0e10cSrcweir             while( aIter.IsMore() )
969cdf0e10cSrcweir             {
970cdf0e10cSrcweir                 pObj = aIter.Next();
971cdf0e10cSrcweir 
972cdf0e10cSrcweir                 const String aObjectName( GetObjectName( pObj ) );
973cdf0e10cSrcweir 
974cdf0e10cSrcweir                 if( aObjectName.Len() )
975cdf0e10cSrcweir                 {
976cdf0e10cSrcweir                     if( !pEntry )
977cdf0e10cSrcweir                         return( sal_False );
978cdf0e10cSrcweir 
979cdf0e10cSrcweir                     aName = GetEntryText( pEntry );
980cdf0e10cSrcweir 
981cdf0e10cSrcweir                     if( aObjectName != aName )
982cdf0e10cSrcweir                         return( sal_False );
983cdf0e10cSrcweir 
984cdf0e10cSrcweir                     pEntry = Next( pEntry );
985cdf0e10cSrcweir                 }
986cdf0e10cSrcweir             }
987cdf0e10cSrcweir         }
988cdf0e10cSrcweir         nPage++;
989cdf0e10cSrcweir     }
990cdf0e10cSrcweir     // Wenn noch Eintraege in der Listbox vorhanden sind, wurden
991cdf0e10cSrcweir     // Objekte (mit Namen) oder Seiten geloescht
992cdf0e10cSrcweir     return( !pEntry );
993cdf0e10cSrcweir }
994cdf0e10cSrcweir 
995cdf0e10cSrcweir /*************************************************************************
996cdf0e10cSrcweir |*
997cdf0e10cSrcweir |* Selectierten String zurueckgeben
998cdf0e10cSrcweir |*
999cdf0e10cSrcweir \************************************************************************/
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir String SdPageObjsTLB::GetSelectEntry()
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir     return( GetEntryText( GetCurEntry() ) );
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir /*************************************************************************
1007cdf0e10cSrcweir |*
1008cdf0e10cSrcweir |* Selektierte Eintrage zurueckgeben
1009cdf0e10cSrcweir |* nDepth == 0 -> Seiten
1010cdf0e10cSrcweir |* nDepth == 1 -> Objekte
1011cdf0e10cSrcweir |*
1012cdf0e10cSrcweir \************************************************************************/
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir List* SdPageObjsTLB::GetSelectEntryList( sal_uInt16 nDepth )
1015cdf0e10cSrcweir {
1016cdf0e10cSrcweir     List*        pList  = NULL;
1017cdf0e10cSrcweir     SvLBoxEntry* pEntry = FirstSelected();
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir     while( pEntry )
1020cdf0e10cSrcweir     {
1021cdf0e10cSrcweir         sal_uInt16 nListDepth = GetModel()->GetDepth( pEntry );
1022cdf0e10cSrcweir         if( nListDepth == nDepth )
1023cdf0e10cSrcweir         {
1024cdf0e10cSrcweir             if( !pList )
1025cdf0e10cSrcweir                 pList = new List();
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir             const String aEntryText( GetEntryText( pEntry ) );
1028cdf0e10cSrcweir             pList->Insert( new String( aEntryText ), LIST_APPEND );
1029cdf0e10cSrcweir         }
1030cdf0e10cSrcweir         pEntry = NextSelected( pEntry );
1031cdf0e10cSrcweir     }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir     return( pList );
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir /*************************************************************************
1037cdf0e10cSrcweir |*
1038cdf0e10cSrcweir |* Eintraege werden erst auf Anforderung (Doppelklick) eingefuegt
1039cdf0e10cSrcweir |*
1040cdf0e10cSrcweir \************************************************************************/
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir void SdPageObjsTLB::RequestingChilds( SvLBoxEntry* pFileEntry )
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir     if( !pFileEntry->HasChilds() )
1045cdf0e10cSrcweir     {
1046cdf0e10cSrcweir         if( GetBookmarkDoc() )
1047cdf0e10cSrcweir         {
1048cdf0e10cSrcweir             SdrObject*   pObj = NULL;
1049cdf0e10cSrcweir             SdPage*      pPage = NULL;
1050cdf0e10cSrcweir             SvLBoxEntry* pPageEntry = NULL;
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir             Image aImgPage=Image( BitmapEx( SdResId( BMP_PAGE ) ) );
1053cdf0e10cSrcweir             Image aImgPageObjs=Image( BitmapEx( SdResId( BMP_PAGEOBJS ) ) );
1054cdf0e10cSrcweir             Image aImgObjects=Image( BitmapEx( SdResId( BMP_OBJECTS ) ) );
1055cdf0e10cSrcweir             Image aImgPageH=Image( BitmapEx( SdResId( BMP_PAGE_H ) ) );
1056cdf0e10cSrcweir             Image aImgPageObjsH=Image( BitmapEx( SdResId( BMP_PAGEOBJS_H ) ) );
1057cdf0e10cSrcweir             Image aImgObjectsH=Image( BitmapEx( SdResId( BMP_OBJECTS_H ) ) );
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir             // document name already inserted
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir             // only insert all "normal" ? slides with objects
1062cdf0e10cSrcweir             sal_uInt16 nPage = 0;
1063cdf0e10cSrcweir             const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount();
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir             while( nPage < nMaxPages )
1066cdf0e10cSrcweir             {
1067cdf0e10cSrcweir                 pPage = (SdPage*) mpBookmarkDoc->GetPage( nPage );
1068cdf0e10cSrcweir                 if( pPage->GetPageKind() == PK_STANDARD )
1069cdf0e10cSrcweir                 {
1070cdf0e10cSrcweir                     pPageEntry = InsertEntry( pPage->GetName(),
1071cdf0e10cSrcweir                                               aImgPage,
1072cdf0e10cSrcweir                                               aImgPage,
1073cdf0e10cSrcweir                                               pFileEntry,
1074cdf0e10cSrcweir                                               sal_False,
1075cdf0e10cSrcweir                                               LIST_APPEND,
1076cdf0e10cSrcweir                                               reinterpret_cast< void* >( 1 ) );
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir                     SetExpandedEntryBmp( pPageEntry, aImgPageH, BMP_COLOR_HIGHCONTRAST );
1079cdf0e10cSrcweir                     SetCollapsedEntryBmp( pPageEntry, aImgPageH, BMP_COLOR_HIGHCONTRAST );
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir                     SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir                     while( aIter.IsMore() )
1084cdf0e10cSrcweir                     {
1085cdf0e10cSrcweir                         pObj = aIter.Next();
1086cdf0e10cSrcweir                         String aStr( GetObjectName( pObj ) );
1087cdf0e10cSrcweir                         if( aStr.Len() )
1088cdf0e10cSrcweir                         {
1089cdf0e10cSrcweir                             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
1090cdf0e10cSrcweir                             {
1091cdf0e10cSrcweir                                 SvLBoxEntry* pNewEntry = InsertEntry(aStr, maImgOle, maImgOle, pPageEntry);
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir                                 SetExpandedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
1095cdf0e10cSrcweir                                 SetCollapsedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST );
1096cdf0e10cSrcweir                             }
1097cdf0e10cSrcweir                             else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
1098cdf0e10cSrcweir                             {
1099cdf0e10cSrcweir                                 SvLBoxEntry* pNewEntry = InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry);
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir                                 SetExpandedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
1102cdf0e10cSrcweir                                 SetCollapsedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST );
1103cdf0e10cSrcweir                             }
1104cdf0e10cSrcweir                             else
1105cdf0e10cSrcweir                             {
1106cdf0e10cSrcweir                                 SvLBoxEntry* pNewEntry = InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry);
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir                                 SetExpandedEntryBmp( pNewEntry, aImgObjectsH, BMP_COLOR_HIGHCONTRAST );
1109cdf0e10cSrcweir                                 SetCollapsedEntryBmp( pNewEntry, aImgObjectsH, BMP_COLOR_HIGHCONTRAST );
1110cdf0e10cSrcweir                             }
1111cdf0e10cSrcweir                         }
1112cdf0e10cSrcweir                     }
1113cdf0e10cSrcweir                     if( pPageEntry->HasChilds() )
1114cdf0e10cSrcweir                     {
1115cdf0e10cSrcweir                         SetExpandedEntryBmp( pPageEntry, aImgPageObjs );
1116cdf0e10cSrcweir                         SetCollapsedEntryBmp( pPageEntry, aImgPageObjs );
1117cdf0e10cSrcweir                         SetExpandedEntryBmp( pPageEntry, aImgPageObjsH, BMP_COLOR_HIGHCONTRAST );
1118cdf0e10cSrcweir                         SetCollapsedEntryBmp( pPageEntry, aImgPageObjsH, BMP_COLOR_HIGHCONTRAST );
1119cdf0e10cSrcweir                     }
1120cdf0e10cSrcweir                 }
1121cdf0e10cSrcweir                 nPage++;
1122cdf0e10cSrcweir             }
1123cdf0e10cSrcweir         }
1124cdf0e10cSrcweir     }
1125cdf0e10cSrcweir     else
1126cdf0e10cSrcweir         SvTreeListBox::RequestingChilds( pFileEntry );
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir /*************************************************************************
1130cdf0e10cSrcweir |*
1131cdf0e10cSrcweir |*  Prueft, ob es sich um eine Draw-Datei handelt und oeffnet anhand des
1132cdf0e10cSrcweir |*  uebergebenen Docs das BookmarkDoc
1133cdf0e10cSrcweir |*
1134cdf0e10cSrcweir \************************************************************************/
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed)
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir     if (
1139cdf0e10cSrcweir        !mpBookmarkDoc ||
1140cdf0e10cSrcweir          (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName()))
1141cdf0e10cSrcweir       )
1142cdf0e10cSrcweir     {
1143cdf0e10cSrcweir         // create a new BookmarkDoc if now one exists or if a new Medium is provided
1144cdf0e10cSrcweir         if (mpOwnMedium != pMed)
1145cdf0e10cSrcweir         {
1146cdf0e10cSrcweir             CloseBookmarkDoc();
1147cdf0e10cSrcweir         }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir         if (pMed)
1150cdf0e10cSrcweir         {
1151cdf0e10cSrcweir             // it looks that it is undefined if a Medium was set by Fill() allready
1152cdf0e10cSrcweir             DBG_ASSERT( !mpMedium, "SfxMedium confusion!" );
1153cdf0e10cSrcweir             delete mpMedium;
1154cdf0e10cSrcweir             mpMedium = NULL;
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir             // take over this Medium (currently used only be Navigator)
1157cdf0e10cSrcweir             mpOwnMedium = pMed;
1158cdf0e10cSrcweir         }
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir         DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" );
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir         if( pMed )
1163cdf0e10cSrcweir         {
1164cdf0e10cSrcweir             // in this mode the document is also owned and controlled by this instance
1165cdf0e10cSrcweir             mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
1166cdf0e10cSrcweir             if (mxBookmarkDocShRef->DoLoad(pMed))
1167cdf0e10cSrcweir                 mpBookmarkDoc = mxBookmarkDocShRef->GetDoc();
1168cdf0e10cSrcweir             else
1169cdf0e10cSrcweir                 mpBookmarkDoc = NULL;
1170cdf0e10cSrcweir         }
1171cdf0e10cSrcweir         else if ( mpMedium )
1172cdf0e10cSrcweir             // in this mode the document is owned and controlled by the SdDrawDocument
1173cdf0e10cSrcweir             // it can be released by calling the corresponding CloseBookmarkDoc method
1174cdf0e10cSrcweir             // successfull creation of a document makes this the owner of the medium
1175cdf0e10cSrcweir             mpBookmarkDoc = ((SdDrawDocument*) mpDoc)->OpenBookmarkDoc(*mpMedium);
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir         if ( !mpBookmarkDoc )
1178cdf0e10cSrcweir         {
1179cdf0e10cSrcweir             ErrorBox aErrorBox( this, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
1180cdf0e10cSrcweir             aErrorBox.Execute();
1181cdf0e10cSrcweir             mpMedium = 0; //On failure the SfxMedium is invalid
1182cdf0e10cSrcweir         }
1183cdf0e10cSrcweir     }
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir     return( mpBookmarkDoc );
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir /*************************************************************************
1189cdf0e10cSrcweir |*
1190cdf0e10cSrcweir |* Bookmark-Dokument schlie�en und loeschen
1191cdf0e10cSrcweir |*
1192cdf0e10cSrcweir \************************************************************************/
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir void SdPageObjsTLB::CloseBookmarkDoc()
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir     if (mxBookmarkDocShRef.Is())
1197cdf0e10cSrcweir     {
1198cdf0e10cSrcweir         mxBookmarkDocShRef->DoClose();
1199cdf0e10cSrcweir         mxBookmarkDocShRef.Clear();
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir         // Medium is owned by document, so it's destroyed already
1202cdf0e10cSrcweir         mpOwnMedium = 0;
1203cdf0e10cSrcweir     }
1204cdf0e10cSrcweir     else if ( mpBookmarkDoc )
1205cdf0e10cSrcweir     {
1206cdf0e10cSrcweir         DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" );
1207cdf0e10cSrcweir         if ( mpDoc )
1208cdf0e10cSrcweir         {
1209cdf0e10cSrcweir             // The document owns the Medium, so the Medium will be invalid after closing the document
1210cdf0e10cSrcweir             ((SdDrawDocument*) mpDoc)->CloseBookmarkDoc();
1211cdf0e10cSrcweir             mpMedium = 0;
1212cdf0e10cSrcweir         }
1213cdf0e10cSrcweir     }
1214cdf0e10cSrcweir     else
1215cdf0e10cSrcweir     {
1216cdf0e10cSrcweir         // perhaps mpOwnMedium provided, but no successfull creation of BookmarkDoc
1217cdf0e10cSrcweir         delete mpOwnMedium;
1218cdf0e10cSrcweir         mpOwnMedium = NULL;
1219cdf0e10cSrcweir     }
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir     mpBookmarkDoc = NULL;
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir /*************************************************************************
1225cdf0e10cSrcweir |*
1226cdf0e10cSrcweir |*
1227cdf0e10cSrcweir |*
1228cdf0e10cSrcweir \************************************************************************/
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir void SdPageObjsTLB::SelectHdl()
1231cdf0e10cSrcweir {
1232cdf0e10cSrcweir     SvLBoxEntry* pEntry = FirstSelected();
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     mbLinkableSelected = sal_True;
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir     while( pEntry && mbLinkableSelected )
1237cdf0e10cSrcweir     {
1238cdf0e10cSrcweir         if( NULL == pEntry->GetUserData() )
1239cdf0e10cSrcweir             mbLinkableSelected = sal_False;
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir         pEntry = NextSelected( pEntry );
1242cdf0e10cSrcweir     }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir     SvTreeListBox::SelectHdl();
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir /*************************************************************************
1248cdf0e10cSrcweir |*
1249cdf0e10cSrcweir |* Ueberlaedt RETURN mit der Funktionsweise von DoubleClick
1250cdf0e10cSrcweir |*
1251cdf0e10cSrcweir \************************************************************************/
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir     if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
1256cdf0e10cSrcweir     {
1257cdf0e10cSrcweir         // Auskommentierter Code aus svtools/source/contnr/svimpbox.cxx
1258cdf0e10cSrcweir         SvLBoxEntry* pCursor = GetCurEntry();
1259cdf0e10cSrcweir         if( pCursor->HasChilds() || pCursor->HasChildsOnDemand() )
1260cdf0e10cSrcweir         {
1261cdf0e10cSrcweir             if( IsExpanded( pCursor ) )
1262cdf0e10cSrcweir                 Collapse( pCursor );
1263cdf0e10cSrcweir             else
1264cdf0e10cSrcweir                 Expand( pCursor );
1265cdf0e10cSrcweir         }
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir         DoubleClickHdl();
1268cdf0e10cSrcweir     }
1269*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
1270*0deba7fbSSteve Yin     else if (rKEvt.GetKeyCode().GetCode() == KEY_SPACE)
1271*0deba7fbSSteve Yin     {
1272*0deba7fbSSteve Yin        if(bisInSdNavigatorWin)
1273*0deba7fbSSteve Yin        {
1274*0deba7fbSSteve Yin            sal_Bool bMarked=sal_False;
1275*0deba7fbSSteve Yin            SvLBoxEntry* pNewEntry = GetCurEntry();
1276*0deba7fbSSteve Yin            if( GetParent(pNewEntry) == NULL )
1277*0deba7fbSSteve Yin                return;
1278*0deba7fbSSteve Yin            String  aStr=GetSelectEntry();
1279*0deba7fbSSteve Yin            Window* pWindow=NULL;
1280*0deba7fbSSteve Yin            SdNavigatorWin* pSdNavigatorWin=NULL;
1281*0deba7fbSSteve Yin            sd::DrawDocShell* pSdDrawDocShell = NULL;
1282*0deba7fbSSteve Yin            if(pNewEntry)
1283*0deba7fbSSteve Yin                pWindow=(Window*)GetParent(pNewEntry);
1284*0deba7fbSSteve Yin            if(pWindow)
1285*0deba7fbSSteve Yin                pSdNavigatorWin = (SdNavigatorWin*)pWindow;
1286*0deba7fbSSteve Yin            if( pSdNavigatorWin )
1287*0deba7fbSSteve Yin                pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc);
1288*0deba7fbSSteve Yin            if(pSdDrawDocShell)
1289*0deba7fbSSteve Yin            {
1290*0deba7fbSSteve Yin                pSdDrawDocShell->GotoTreeBookmark(aStr);
1291*0deba7fbSSteve Yin                bMarked=pSdDrawDocShell->GetObjectIsmarked(aStr);
1292*0deba7fbSSteve Yin            }
1293*0deba7fbSSteve Yin            //Removed by yanjun for sym2_6385
1294*0deba7fbSSteve Yin            //The symphony2.0 can support morn than one level tree list, also support to select tow or more items in different level.
1295*0deba7fbSSteve Yin            /*
1296*0deba7fbSSteve Yin            SvLBoxEntry* pBeginEntry = First();
1297*0deba7fbSSteve Yin            if( pBeginEntry )
1298*0deba7fbSSteve Yin            {
1299*0deba7fbSSteve Yin                if( GetParent(pBeginEntry) !=  GetParent(pNewEntry) )
1300*0deba7fbSSteve Yin                    pBeginEntry->SetMarked( sal_False );
1301*0deba7fbSSteve Yin                SvLBoxEntry* pNextEntry = Next( pBeginEntry );
1302*0deba7fbSSteve Yin                while( pNextEntry )
1303*0deba7fbSSteve Yin                {
1304*0deba7fbSSteve Yin                    if( GetParent(pNextEntry) !=  GetParent(pNewEntry) )
1305*0deba7fbSSteve Yin                        pNextEntry->SetMarked( sal_False );
1306*0deba7fbSSteve Yin                    pNextEntry =  Next( pNextEntry );
1307*0deba7fbSSteve Yin                }
1308*0deba7fbSSteve Yin            }
1309*0deba7fbSSteve Yin            End*/
1310*0deba7fbSSteve Yin            if(pNewEntry)
1311*0deba7fbSSteve Yin            {
1312*0deba7fbSSteve Yin                if(bMarked)
1313*0deba7fbSSteve Yin                {
1314*0deba7fbSSteve Yin                    pNewEntry->SetMarked(sal_True);
1315*0deba7fbSSteve Yin                }
1316*0deba7fbSSteve Yin                else
1317*0deba7fbSSteve Yin                {
1318*0deba7fbSSteve Yin                    pNewEntry->SetMarked( sal_False );
1319*0deba7fbSSteve Yin                }
1320*0deba7fbSSteve Yin            }
1321*0deba7fbSSteve Yin            Invalidate();
1322*0deba7fbSSteve Yin        }
1323*0deba7fbSSteve Yin     }
1324*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
1325cdf0e10cSrcweir     else
1326cdf0e10cSrcweir         SvTreeListBox::KeyInput( rKEvt );
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir /*************************************************************************
1330cdf0e10cSrcweir |*
1331cdf0e10cSrcweir |* StartDrag-Request
1332cdf0e10cSrcweir |*
1333cdf0e10cSrcweir \************************************************************************/
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir void SdPageObjsTLB::StartDrag( sal_Int8 nAction, const Point& rPosPixel)
1336cdf0e10cSrcweir {
1337cdf0e10cSrcweir     (void)nAction;
1338cdf0e10cSrcweir     (void)rPosPixel;
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir     SdNavigatorWin* pNavWin = NULL;
1341cdf0e10cSrcweir     SvLBoxEntry* pEntry = GetEntry(rPosPixel);
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir     if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
1344cdf0e10cSrcweir         pNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir     if (pEntry != NULL
1347cdf0e10cSrcweir         && pNavWin !=NULL
1348cdf0e10cSrcweir         && pNavWin == mpParent
1349cdf0e10cSrcweir         && pNavWin->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE )
1350cdf0e10cSrcweir     {
1351cdf0e10cSrcweir         // Mark only the children of the page under the mouse as drop
1352cdf0e10cSrcweir         // targets.  This prevents moving shapes from one page to another.
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir         // Select all entries and disable them as drop targets.
1355cdf0e10cSrcweir         SetSelectionMode(MULTIPLE_SELECTION);
1356cdf0e10cSrcweir         SetCursor(NULL, sal_False);
1357cdf0e10cSrcweir         SelectAll(sal_True, sal_False);
1358cdf0e10cSrcweir         EnableSelectionAsDropTarget(sal_False, sal_True);
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir         // Enable only the entries as drop targets that are children of the
1361cdf0e10cSrcweir         // page under the mouse.
1362cdf0e10cSrcweir         SvLBoxEntry* pParent = GetRootLevelParent(pEntry);
1363cdf0e10cSrcweir         if (pParent != NULL)
1364cdf0e10cSrcweir         {
1365cdf0e10cSrcweir             SelectAll(sal_False, sal_False);
1366cdf0e10cSrcweir             Select(pParent, sal_True);
1367cdf0e10cSrcweir             //            for (SvLBoxEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild))
1368cdf0e10cSrcweir             //                Select(pChild, sal_True);
1369cdf0e10cSrcweir             EnableSelectionAsDropTarget(sal_True, sal_True);//sal_False);
1370cdf0e10cSrcweir         }
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir         // Set selection back to the entry under the mouse.
1373cdf0e10cSrcweir         SelectAll(sal_False,sal_False);
1374cdf0e10cSrcweir         SetSelectionMode(SINGLE_SELECTION);
1375cdf0e10cSrcweir         Select(pEntry, sal_True);
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir         //  Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
1378cdf0e10cSrcweir         //  (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
1379cdf0e10cSrcweir         //  den StarView MouseMove-Handler, der Command() aufruft, umbringen.
1380cdf0e10cSrcweir         //  Deshalb Drag&Drop asynchron:
1381cdf0e10cSrcweir         Application::PostUserEvent( STATIC_LINK( this, SdPageObjsTLB, ExecDragHdl ) );
1382cdf0e10cSrcweir     }
1383cdf0e10cSrcweir }
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir /*************************************************************************
1386cdf0e10cSrcweir |*
1387cdf0e10cSrcweir |* Begin drag
1388cdf0e10cSrcweir |*
1389cdf0e10cSrcweir \************************************************************************/
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir void SdPageObjsTLB::DoDrag()
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir     mpDropNavWin = ( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) ?
1394cdf0e10cSrcweir                   (SdNavigatorWin*)( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ) :
1395cdf0e10cSrcweir                   NULL;
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir     if( mpDropNavWin )
1398cdf0e10cSrcweir     {
1399cdf0e10cSrcweir         ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
1400cdf0e10cSrcweir         String aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INET_PROT_FILE ).GetMainURL( INetURLObject::NO_DECODE );
1401cdf0e10cSrcweir         NavigatorDragType   eDragType = mpDropNavWin->GetNavigatorDragType();
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir         aURL.Append( '#' );
1404cdf0e10cSrcweir         aURL.Append( GetSelectEntry() );
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir         INetBookmark    aBookmark( aURL, GetSelectEntry() );
1407cdf0e10cSrcweir         sal_Int8        nDNDActions = DND_ACTION_COPYMOVE;
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir         if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
1410cdf0e10cSrcweir             nDNDActions = DND_ACTION_LINK;  // #93240# Either COPY *or* LINK, never both!
1411cdf0e10cSrcweir         else if (mpDoc->GetSdPageCount(PK_STANDARD) == 1)
1412cdf0e10cSrcweir         {
1413cdf0e10cSrcweir             // Can not move away the last slide in a document.
1414cdf0e10cSrcweir             nDNDActions = DND_ACTION_COPY;
1415cdf0e10cSrcweir         }
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir         SvTreeListBox::ReleaseMouse();
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir         bIsInDrag = sal_True;
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir         SvLBoxDDInfo aDDInfo;
1422cdf0e10cSrcweir         memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
1423cdf0e10cSrcweir         aDDInfo.pApp = GetpApp();
1424cdf0e10cSrcweir         aDDInfo.pSource = this;
1425cdf0e10cSrcweir         //            aDDInfo.pDDStartEntry = pEntry;
1426cdf0e10cSrcweir         ::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo));
1427cdf0e10cSrcweir         memcpy(aSequence.getArray(), (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo));
1428cdf0e10cSrcweir         ::com::sun::star::uno::Any aTreeListBoxData (aSequence);
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir         // object is destroyed by internal reference mechanism
1431cdf0e10cSrcweir         SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable(
1432cdf0e10cSrcweir             *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData);
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir         // Get the view.
1435cdf0e10cSrcweir         ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
1436cdf0e10cSrcweir         if (pViewShell == NULL)
1437cdf0e10cSrcweir         {
1438cdf0e10cSrcweir             OSL_ASSERT(pViewShell!=NULL);
1439cdf0e10cSrcweir             return;
1440cdf0e10cSrcweir         }
1441cdf0e10cSrcweir         sd::View* pView = pViewShell->GetView();
1442cdf0e10cSrcweir         if (pView == NULL)
1443cdf0e10cSrcweir         {
1444cdf0e10cSrcweir             OSL_ASSERT(pView!=NULL);
1445cdf0e10cSrcweir             return;
1446cdf0e10cSrcweir         }
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir         SdrObject* pObject = NULL;
1449cdf0e10cSrcweir         void* pUserData = GetCurEntry()->GetUserData();
1450cdf0e10cSrcweir         if (pUserData != NULL && pUserData != (void*)1)
1451cdf0e10cSrcweir             pObject = reinterpret_cast<SdrObject*>(pUserData);
1452cdf0e10cSrcweir         if (pObject != NULL)
1453cdf0e10cSrcweir         {
1454cdf0e10cSrcweir             // For shapes without a user supplied name (the automatically
1455cdf0e10cSrcweir             // created name does not count), a different drag and drop technique
1456cdf0e10cSrcweir             // is used.
1457cdf0e10cSrcweir             if (GetObjectName(pObject, false).Len() == 0)
1458cdf0e10cSrcweir             {
1459cdf0e10cSrcweir                 AddShapeToTransferable(*pTransferable, *pObject);
1460cdf0e10cSrcweir                 pTransferable->SetView(pView);
1461cdf0e10cSrcweir                 SD_MOD()->pTransferDrag = pTransferable;
1462cdf0e10cSrcweir             }
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir             // Unnamed shapes have to be selected to be recognized by the
1465cdf0e10cSrcweir             // current drop implementation.  In order to have a consistent
1466cdf0e10cSrcweir             // behaviour for all shapes, every shape that is to be dragged is
1467cdf0e10cSrcweir             // selected first.
1468cdf0e10cSrcweir             SdrPageView* pPageView = pView->GetSdrPageView();
1469cdf0e10cSrcweir             pView->UnmarkAllObj(pPageView);
1470cdf0e10cSrcweir             pView->MarkObj(pObject, pPageView);
1471cdf0e10cSrcweir         }
1472cdf0e10cSrcweir         else
1473cdf0e10cSrcweir         {
1474cdf0e10cSrcweir             pTransferable->SetView(pView);
1475cdf0e10cSrcweir             SD_MOD()->pTransferDrag = pTransferable;
1476cdf0e10cSrcweir         }
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir         pTransferable->StartDrag( this, nDNDActions );
1479cdf0e10cSrcweir     }
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir /*************************************************************************
1483cdf0e10cSrcweir |*
1484cdf0e10cSrcweir |* Drag finished
1485cdf0e10cSrcweir |*
1486cdf0e10cSrcweir \************************************************************************/
1487cdf0e10cSrcweir 
1488cdf0e10cSrcweir void SdPageObjsTLB::OnDragFinished( sal_uInt8 )
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir     if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
1491cdf0e10cSrcweir     {
1492cdf0e10cSrcweir         SdNavigatorWin* pNewNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir         if( mpDropNavWin == pNewNavWin)
1495cdf0e10cSrcweir         {
1496cdf0e10cSrcweir             MouseEvent aMEvt( mpDropNavWin->GetPointerPosPixel() );
1497cdf0e10cSrcweir             SvTreeListBox::MouseButtonUp( aMEvt );
1498cdf0e10cSrcweir         }
1499cdf0e10cSrcweir     }
1500cdf0e10cSrcweir 
1501cdf0e10cSrcweir     mpDropNavWin = NULL;
1502cdf0e10cSrcweir     bIsInDrag = sal_False;
1503cdf0e10cSrcweir }
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir /*************************************************************************
1506cdf0e10cSrcweir |*
1507cdf0e10cSrcweir |* AcceptDrop-Event
1508cdf0e10cSrcweir |*
1509cdf0e10cSrcweir \************************************************************************/
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent)
1512cdf0e10cSrcweir {
1513cdf0e10cSrcweir     sal_Int8 nResult (DND_ACTION_NONE);
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir     if ( !bIsInDrag && IsDropFormatSupported( FORMAT_FILE ) )
1516cdf0e10cSrcweir     {
1517cdf0e10cSrcweir         nResult = rEvent.mnAction;
1518cdf0e10cSrcweir     }
1519cdf0e10cSrcweir     else
1520cdf0e10cSrcweir     {
1521cdf0e10cSrcweir         SvLBoxEntry* pEntry = GetDropTarget(rEvent.maPosPixel);
1522cdf0e10cSrcweir         if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction ))
1523cdf0e10cSrcweir         {
1524cdf0e10cSrcweir             ImplShowTargetEmphasis( pTargetEntry, sal_False );
1525cdf0e10cSrcweir         }
1526cdf0e10cSrcweir         else if( !nDragDropMode )
1527cdf0e10cSrcweir         {
1528cdf0e10cSrcweir             DBG_ERRORFILE( "SdPageObjsTLB::AcceptDrop(): no target" );
1529cdf0e10cSrcweir         }
1530cdf0e10cSrcweir         else if (IsDropAllowed(pEntry))
1531cdf0e10cSrcweir         {
1532cdf0e10cSrcweir             nResult = DND_ACTION_MOVE;
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir             // Draw emphasis.
1535cdf0e10cSrcweir             if (pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS))
1536cdf0e10cSrcweir             {
1537cdf0e10cSrcweir                 ImplShowTargetEmphasis( pTargetEntry, sal_False );
1538cdf0e10cSrcweir                 pTargetEntry = pEntry;
1539cdf0e10cSrcweir                 ImplShowTargetEmphasis( pTargetEntry, sal_True );
1540cdf0e10cSrcweir             }
1541cdf0e10cSrcweir         }
1542cdf0e10cSrcweir     }
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir     // Hide emphasis when there is no valid drop action.
1545cdf0e10cSrcweir     if (nResult == DND_ACTION_NONE)
1546cdf0e10cSrcweir         ImplShowTargetEmphasis(pTargetEntry, sal_False);
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir     return nResult;
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir /*************************************************************************
1552cdf0e10cSrcweir |*
1553cdf0e10cSrcweir |* ExecuteDrop-Event
1554cdf0e10cSrcweir |*
1555cdf0e10cSrcweir \************************************************************************/
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt )
1558cdf0e10cSrcweir {
1559cdf0e10cSrcweir     sal_Int8 nRet = DND_ACTION_NONE;
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir     try
1562cdf0e10cSrcweir     {
1563cdf0e10cSrcweir         if( !bIsInDrag )
1564cdf0e10cSrcweir         {
1565cdf0e10cSrcweir             SdNavigatorWin* pNavWin = NULL;
1566cdf0e10cSrcweir             sal_uInt16          nId = SID_NAVIGATOR;
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir             if( mpFrame->HasChildWindow( nId ) )
1569cdf0e10cSrcweir                 pNavWin = (SdNavigatorWin*)( mpFrame->GetChildWindow( nId )->GetContextWindow( SD_MOD() ) );
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir             if( pNavWin && ( pNavWin == mpParent ) )
1572cdf0e10cSrcweir             {
1573cdf0e10cSrcweir                 TransferableDataHelper  aDataHelper( rEvt.maDropEvent.Transferable );
1574cdf0e10cSrcweir                 String                  aFile;
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir                 if( aDataHelper.GetString( FORMAT_FILE, aFile ) &&
1577cdf0e10cSrcweir                     ( (SdNavigatorWin*) mpParent)->InsertFile( aFile ) )
1578cdf0e10cSrcweir                 {
1579cdf0e10cSrcweir                     nRet = rEvt.mnAction;
1580cdf0e10cSrcweir                 }
1581cdf0e10cSrcweir             }
1582cdf0e10cSrcweir         }
1583cdf0e10cSrcweir     }
1584cdf0e10cSrcweir     catch (com::sun::star::uno::Exception&)
1585cdf0e10cSrcweir     {
1586cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
1587cdf0e10cSrcweir     }
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir     if (nRet == DND_ACTION_NONE)
1590cdf0e10cSrcweir         SvTreeListBox::ExecuteDrop(rEvt, this);
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir     return nRet;
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir /*************************************************************************
1597cdf0e10cSrcweir |*
1598cdf0e10cSrcweir |* Handler fuers Dragging
1599cdf0e10cSrcweir |*
1600cdf0e10cSrcweir \************************************************************************/
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir IMPL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*, EMPTYARG)
1603cdf0e10cSrcweir {
1604cdf0e10cSrcweir     //  als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1605cdf0e10cSrcweir     //  Navigator geloescht werden darf
1606cdf0e10cSrcweir     pThis->DoDrag();
1607cdf0e10cSrcweir     return 0;
1608cdf0e10cSrcweir }
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
1612cdf0e10cSrcweir {
1613cdf0e10cSrcweir     // Return <TRUE/> as default when there is no custom show or when none
1614cdf0e10cSrcweir     // is used.  The page does then belong to the standard show.
1615cdf0e10cSrcweir     bool bBelongsToShow = true;
1616cdf0e10cSrcweir 
1617cdf0e10cSrcweir     if (mpDoc->getPresentationSettings().mbCustomShow)
1618cdf0e10cSrcweir     {
1619cdf0e10cSrcweir         // Get the current custom show.
1620cdf0e10cSrcweir         SdCustomShow* pCustomShow = NULL;
1621cdf0e10cSrcweir         List* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList();
1622cdf0e10cSrcweir         if (pShowList != NULL)
1623cdf0e10cSrcweir         {
1624cdf0e10cSrcweir             sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
1625cdf0e10cSrcweir             void* pObject = pShowList->GetObject(nCurrentShowIndex);
1626cdf0e10cSrcweir             pCustomShow = static_cast<SdCustomShow*>(pObject);
1627cdf0e10cSrcweir         }
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir         // Check whether the given page is part of that custom show.
1630cdf0e10cSrcweir         if (pCustomShow != NULL)
1631cdf0e10cSrcweir         {
1632cdf0e10cSrcweir             bBelongsToShow = false;
1633cdf0e10cSrcweir             sal_uLong nPageCount = pCustomShow->Count();
1634cdf0e10cSrcweir             for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++)
1635cdf0e10cSrcweir                 if (pPage == static_cast<SdPage*>(pCustomShow->GetObject (i)))
1636cdf0e10cSrcweir                     bBelongsToShow = true;
1637cdf0e10cSrcweir         }
1638cdf0e10cSrcweir     }
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir     return bBelongsToShow;
1641cdf0e10cSrcweir }
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir sal_Bool SdPageObjsTLB::NotifyMoving(
1647cdf0e10cSrcweir     SvLBoxEntry* pTarget,
1648cdf0e10cSrcweir     SvLBoxEntry* pEntry,
1649cdf0e10cSrcweir     SvLBoxEntry*& rpNewParent,
1650cdf0e10cSrcweir     sal_uLong& rNewChildPos)
1651cdf0e10cSrcweir {
1652cdf0e10cSrcweir     SvLBoxEntry* pDestination = pTarget;
1653cdf0e10cSrcweir     while (GetParent(pDestination) != NULL && GetParent(GetParent(pDestination)) != NULL)
1654cdf0e10cSrcweir         pDestination = GetParent(pDestination);
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir     SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(pDestination->GetUserData());
1657cdf0e10cSrcweir     SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(pEntry->GetUserData());
1658cdf0e10cSrcweir     if (pSourceObject == reinterpret_cast<SdrObject*>(1))
1659cdf0e10cSrcweir         pSourceObject = NULL;
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir     if (pTargetObject != NULL && pSourceObject != NULL)
1662cdf0e10cSrcweir     {
1663cdf0e10cSrcweir         SdrPage* pObjectList = pSourceObject->GetPage();
1664cdf0e10cSrcweir         if (pObjectList != NULL)
1665cdf0e10cSrcweir         {
1666cdf0e10cSrcweir             sal_uInt32 nNewPosition;
1667cdf0e10cSrcweir             if (pTargetObject == reinterpret_cast<SdrObject*>(1))
1668cdf0e10cSrcweir                 nNewPosition = 0;
1669cdf0e10cSrcweir             else
1670cdf0e10cSrcweir                 nNewPosition = pTargetObject->GetNavigationPosition() + 1;
1671cdf0e10cSrcweir             pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition);
1672cdf0e10cSrcweir         }
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir         // Update the tree list.
1675cdf0e10cSrcweir         if (pTarget == NULL)
1676cdf0e10cSrcweir         {
1677cdf0e10cSrcweir             rpNewParent = 0;
1678cdf0e10cSrcweir             rNewChildPos = 0;
1679cdf0e10cSrcweir             return sal_True;
1680cdf0e10cSrcweir         }
1681cdf0e10cSrcweir         else if (GetParent(pDestination) == NULL)
1682cdf0e10cSrcweir         {
1683cdf0e10cSrcweir             rpNewParent = pDestination;
1684cdf0e10cSrcweir             rNewChildPos = 0;
1685cdf0e10cSrcweir         }
1686cdf0e10cSrcweir         else
1687cdf0e10cSrcweir         {
1688cdf0e10cSrcweir             rpNewParent = GetParent(pDestination);
1689cdf0e10cSrcweir             rNewChildPos = pModel->GetRelPos(pDestination) + 1;
1690cdf0e10cSrcweir             rNewChildPos += nCurEntrySelPos;
1691cdf0e10cSrcweir             nCurEntrySelPos++;
1692cdf0e10cSrcweir         }
1693cdf0e10cSrcweir         return sal_True;
1694cdf0e10cSrcweir     }
1695cdf0e10cSrcweir     else
1696cdf0e10cSrcweir         return sal_False;
1697cdf0e10cSrcweir }
1698cdf0e10cSrcweir 
1699cdf0e10cSrcweir 
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir SvLBoxEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation)
1703cdf0e10cSrcweir {
1704cdf0e10cSrcweir     SvLBoxEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation);
1705cdf0e10cSrcweir     if (pEntry == NULL)
1706cdf0e10cSrcweir         return NULL;
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir     if (GetParent(pEntry) == NULL)
1709cdf0e10cSrcweir     {
1710cdf0e10cSrcweir         // Use page entry as insertion position.
1711cdf0e10cSrcweir     }
1712cdf0e10cSrcweir     else
1713cdf0e10cSrcweir     {
1714cdf0e10cSrcweir         // Go to second hierarchy level, i.e. top level shapes,
1715cdf0e10cSrcweir         // i.e. children of pages.
1716cdf0e10cSrcweir         while (GetParent(pEntry) != NULL && GetParent(GetParent(pEntry)) != NULL)
1717cdf0e10cSrcweir             pEntry = GetParent(pEntry);
1718cdf0e10cSrcweir 
1719cdf0e10cSrcweir         // Advance to next sibling.
1720cdf0e10cSrcweir         SvLBoxEntry* pNext;
1721cdf0e10cSrcweir         sal_uInt16 nDepth (0);
1722cdf0e10cSrcweir         while (pEntry != NULL)
1723cdf0e10cSrcweir         {
1724cdf0e10cSrcweir             pNext = dynamic_cast<SvLBoxEntry*>(NextVisible(pEntry, &nDepth));
1725cdf0e10cSrcweir             if (pNext != NULL && nDepth > 0 && nDepth!=0xffff)
1726cdf0e10cSrcweir                 pEntry = pNext;
1727cdf0e10cSrcweir             else
1728cdf0e10cSrcweir                 break;
1729cdf0e10cSrcweir         }
1730cdf0e10cSrcweir     }
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir     return pEntry;
1733cdf0e10cSrcweir }
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir 
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir bool SdPageObjsTLB::IsDropAllowed (SvLBoxEntry* pEntry)
1739cdf0e10cSrcweir {
1740cdf0e10cSrcweir     if (pEntry == NULL)
1741cdf0e10cSrcweir         return false;
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir     if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId()))
1744cdf0e10cSrcweir         return false;
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir     if ((pEntry->GetFlags() & SV_ENTRYFLAG_DISABLE_DROP) != 0)
1747cdf0e10cSrcweir         return false;
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir     return true;
1750cdf0e10cSrcweir }
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir 
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir void SdPageObjsTLB::AddShapeToTransferable (
1756cdf0e10cSrcweir     SdTransferable& rTransferable,
1757cdf0e10cSrcweir     SdrObject& rObject) const
1758cdf0e10cSrcweir {
1759cdf0e10cSrcweir     TransferableObjectDescriptor aObjectDescriptor;
1760cdf0e10cSrcweir     bool bIsDescriptorFillingPending (true);
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir     const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
1763cdf0e10cSrcweir     if (pOleObject != NULL && pOleObject->GetObjRef().is())
1764cdf0e10cSrcweir     {
1765cdf0e10cSrcweir         // If object has no persistence it must be copied as part of the document
1766cdf0e10cSrcweir         try
1767cdf0e10cSrcweir         {
1768cdf0e10cSrcweir             uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY );
1769cdf0e10cSrcweir             if (xPersObj.is() && xPersObj->hasEntry())
1770cdf0e10cSrcweir             {
1771cdf0e10cSrcweir                 SvEmbedTransferHelper::FillTransferableObjectDescriptor(
1772cdf0e10cSrcweir                     aObjectDescriptor,
1773cdf0e10cSrcweir                     pOleObject->GetObjRef(),
1774cdf0e10cSrcweir                     pOleObject->GetGraphic(),
1775cdf0e10cSrcweir                     pOleObject->GetAspect());
1776cdf0e10cSrcweir                 bIsDescriptorFillingPending = false;
1777cdf0e10cSrcweir             }
1778cdf0e10cSrcweir         }
1779cdf0e10cSrcweir         catch( uno::Exception& )
1780cdf0e10cSrcweir         {
1781cdf0e10cSrcweir         }
1782cdf0e10cSrcweir     }
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir     ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
1785cdf0e10cSrcweir     if (bIsDescriptorFillingPending && pDocShell!=NULL)
1786cdf0e10cSrcweir     {
1787cdf0e10cSrcweir         bIsDescriptorFillingPending = false;
1788cdf0e10cSrcweir         pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor);
1789cdf0e10cSrcweir     }
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir     Point aDragPos (rObject.GetCurrentBoundRect().Center());
1792cdf0e10cSrcweir     //Point aDragPos (0,0);
1793cdf0e10cSrcweir     aObjectDescriptor.maDragStartPos = aDragPos;
1794cdf0e10cSrcweir     //  aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
1795cdf0e10cSrcweir     if (pDocShell != NULL)
1796cdf0e10cSrcweir         aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
1797cdf0e10cSrcweir     else
1798cdf0e10cSrcweir         aObjectDescriptor.maDisplayName = String();
1799cdf0e10cSrcweir     aObjectDescriptor.mbCanLink = sal_False;
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir     rTransferable.SetStartPos(aDragPos);
1802cdf0e10cSrcweir     rTransferable.SetObjectDescriptor( aObjectDescriptor );
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir 
1808cdf0e10cSrcweir ::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
1809cdf0e10cSrcweir {
1810cdf0e10cSrcweir     {
1811cdf0e10cSrcweir         ::sd::ViewShell* pViewShell = rDocShell.GetViewShell();
1812cdf0e10cSrcweir         if (pViewShell != NULL)
1813cdf0e10cSrcweir             return pViewShell;
1814cdf0e10cSrcweir     }
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir     try
1817cdf0e10cSrcweir     {
1818cdf0e10cSrcweir         // Get a component enumeration from the desktop and search it for documents.
1819cdf0e10cSrcweir         uno::Reference<lang::XMultiServiceFactory> xFactory (
1820cdf0e10cSrcweir             ::comphelper::getProcessServiceFactory ());
1821cdf0e10cSrcweir         if ( ! xFactory.is())
1822cdf0e10cSrcweir             return NULL;
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir         uno::Reference<frame::XDesktop> xDesktop (xFactory->createInstance (
1825cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), uno::UNO_QUERY);
1826cdf0e10cSrcweir         if ( ! xDesktop.is())
1827cdf0e10cSrcweir             return NULL;
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir         uno::Reference<frame::XFramesSupplier> xFrameSupplier (xDesktop, uno::UNO_QUERY);
1830cdf0e10cSrcweir         if ( ! xFrameSupplier.is())
1831cdf0e10cSrcweir             return NULL;
1832cdf0e10cSrcweir 
1833cdf0e10cSrcweir         uno::Reference<container::XIndexAccess> xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY);
1834cdf0e10cSrcweir         if ( ! xFrameAccess.is())
1835cdf0e10cSrcweir             return NULL;
1836cdf0e10cSrcweir 
1837cdf0e10cSrcweir         for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex)
1838cdf0e10cSrcweir         {
1839cdf0e10cSrcweir             uno::Reference<frame::XFrame> xFrame;
1840cdf0e10cSrcweir             if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame))
1841cdf0e10cSrcweir                 continue;
1842cdf0e10cSrcweir 
1843cdf0e10cSrcweir             ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get());
1844cdf0e10cSrcweir             if (pController == NULL)
1845cdf0e10cSrcweir                 continue;
1846cdf0e10cSrcweir             ::sd::ViewShellBase* pBase = pController->GetViewShellBase();
1847cdf0e10cSrcweir             if (pBase == NULL)
1848cdf0e10cSrcweir                 continue;
1849cdf0e10cSrcweir             if (pBase->GetDocShell() != &rDocShell)
1850cdf0e10cSrcweir                 continue;
1851cdf0e10cSrcweir 
1852cdf0e10cSrcweir             const ::boost::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell());
1853cdf0e10cSrcweir             if (pViewShell)
1854cdf0e10cSrcweir                 return pViewShell.get();
1855cdf0e10cSrcweir         }
1856cdf0e10cSrcweir     }
1857cdf0e10cSrcweir     catch (uno::Exception e)
1858cdf0e10cSrcweir     {
1859cdf0e10cSrcweir         // When there is an exception then simply use the default value of
1860cdf0e10cSrcweir         // bIsEnabled and disable the controls.
1861cdf0e10cSrcweir     }
1862cdf0e10cSrcweir     return NULL;
1863cdf0e10cSrcweir }
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir 
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir //===== IconProvider ==========================================================
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir SdPageObjsTLB::IconProvider::IconProvider (void)
1871cdf0e10cSrcweir     : maImgPage( BitmapEx( SdResId( BMP_PAGE ) ) ),
1872cdf0e10cSrcweir       maImgPageExcl( BitmapEx( SdResId( BMP_PAGE_EXCLUDED ) ) ),
1873cdf0e10cSrcweir       maImgPageObjsExcl( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED ) ) ),
1874cdf0e10cSrcweir       maImgPageObjs( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ),
1875cdf0e10cSrcweir       maImgObjects( BitmapEx( SdResId( BMP_OBJECTS ) ) ),
1876cdf0e10cSrcweir       maImgGroup( BitmapEx( SdResId( BMP_GROUP ) ) ),
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir       maImgPageH( BitmapEx( SdResId( BMP_PAGE_H ) ) ),
1879cdf0e10cSrcweir       maImgPageExclH( BitmapEx( SdResId( BMP_PAGE_EXCLUDED_H ) ) ),
1880cdf0e10cSrcweir       maImgPageObjsExclH( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED_H ) ) ),
1881cdf0e10cSrcweir       maImgPageObjsH( BitmapEx( SdResId( BMP_PAGEOBJS_H ) ) ),
1882cdf0e10cSrcweir       maImgObjectsH( BitmapEx( SdResId( BMP_OBJECTS_H ) ) ),
1883cdf0e10cSrcweir       maImgGroupH( BitmapEx( SdResId( BMP_GROUP_H ) ) )
1884cdf0e10cSrcweir {
1885cdf0e10cSrcweir }
1886