xref: /aoo42x/main/sc/source/ui/navipi/content.cxx (revision 22407013)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <svx/svditer.hxx>
30cdf0e10cSrcweir #include <svx/svdobj.hxx>
31cdf0e10cSrcweir #include <svx/svdpage.hxx>
32cdf0e10cSrcweir #include <svx/svdpagv.hxx>
33cdf0e10cSrcweir #include <svx/svdview.hxx>
34cdf0e10cSrcweir #include <svx/svdxcgv.hxx>
35cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
36cdf0e10cSrcweir #include <sfx2/docfile.hxx>
37cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
38cdf0e10cSrcweir #include <vcl/help.hxx>
39cdf0e10cSrcweir #include <vcl/sound.hxx>
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <tools/urlobj.hxx>
42cdf0e10cSrcweir #include <svl/urlbmk.hxx>
43cdf0e10cSrcweir #include <stdlib.h>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "content.hxx"
46cdf0e10cSrcweir #include "navipi.hxx"
47cdf0e10cSrcweir #include "global.hxx"
48cdf0e10cSrcweir #include "docsh.hxx"
49cdf0e10cSrcweir #include "scmod.hxx"
50cdf0e10cSrcweir #include "rangenam.hxx"
51cdf0e10cSrcweir #include "dbcolect.hxx"
52cdf0e10cSrcweir #include "tablink.hxx"			// fuer Loader
53cdf0e10cSrcweir #include "popmenu.hxx"
54cdf0e10cSrcweir #include "drwlayer.hxx"
55cdf0e10cSrcweir #include "transobj.hxx"
56cdf0e10cSrcweir #include "drwtrans.hxx"
57cdf0e10cSrcweir #include "lnktrans.hxx"
58cdf0e10cSrcweir #include "cell.hxx"
59cdf0e10cSrcweir #include "dociter.hxx"
60cdf0e10cSrcweir #include "scresid.hxx"
61cdf0e10cSrcweir #include "globstr.hrc"
62cdf0e10cSrcweir #include "navipi.hrc"
63cdf0e10cSrcweir #include "arealink.hxx"
64cdf0e10cSrcweir #include "navicfg.hxx"
65cdf0e10cSrcweir #include "navsett.hxx"
66cdf0e10cSrcweir #include "postit.hxx"
67cdf0e10cSrcweir #include "clipparam.hxx"
68cdf0e10cSrcweir 
69cdf0e10cSrcweir using namespace com::sun::star;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //	Reihenfolge der Kategorien im Navigator -------------------------------------
72cdf0e10cSrcweir 
73cdf0e10cSrcweir static sal_uInt16 pTypeList[SC_CONTENT_COUNT] =
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	SC_CONTENT_ROOT,			// ROOT (0) muss vorne stehen
76cdf0e10cSrcweir 	SC_CONTENT_TABLE,
77cdf0e10cSrcweir 	SC_CONTENT_RANGENAME,
78cdf0e10cSrcweir 	SC_CONTENT_DBAREA,
79cdf0e10cSrcweir 	SC_CONTENT_AREALINK,
80cdf0e10cSrcweir 	SC_CONTENT_GRAPHIC,
81cdf0e10cSrcweir 	SC_CONTENT_OLEOBJECT,
82cdf0e10cSrcweir 	SC_CONTENT_NOTE,
83cdf0e10cSrcweir 	SC_CONTENT_DRAWING
84cdf0e10cSrcweir };
85cdf0e10cSrcweir 
86cdf0e10cSrcweir sal_Bool ScContentTree::bIsInDrag = sal_False;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir ScDocShell* ScContentTree::GetManualOrCurrent()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	ScDocShell* pSh = NULL;
92cdf0e10cSrcweir 	if ( aManualDoc.Len() )
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 		TypeId aScType = TYPE(ScDocShell);
95cdf0e10cSrcweir 		SfxObjectShell* pObjSh = SfxObjectShell::GetFirst( &aScType );
96cdf0e10cSrcweir 		while ( pObjSh && !pSh )
97cdf0e10cSrcweir 		{
98cdf0e10cSrcweir 			if ( pObjSh->GetTitle() == aManualDoc )
99cdf0e10cSrcweir 				pSh = PTR_CAST( ScDocShell, pObjSh );
100cdf0e10cSrcweir 			pObjSh = SfxObjectShell::GetNext( *pObjSh, &aScType );
101cdf0e10cSrcweir 		}
102cdf0e10cSrcweir 	}
103cdf0e10cSrcweir 	else
104cdf0e10cSrcweir 	{
105cdf0e10cSrcweir 		//	Current nur, wenn keine manuell eingestellt ist
106cdf0e10cSrcweir 		//	(damit erkannt wird, wenn das Dokument nicht mehr existiert)
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 		SfxViewShell* pViewSh = SfxViewShell::Current();
109cdf0e10cSrcweir 		if ( pViewSh )
110cdf0e10cSrcweir 		{
111cdf0e10cSrcweir 			SfxObjectShell* pObjSh = pViewSh->GetViewFrame()->GetObjectShell();
112cdf0e10cSrcweir 			pSh = PTR_CAST( ScDocShell, pObjSh );
113cdf0e10cSrcweir 		}
114cdf0e10cSrcweir 	}
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	return pSh;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir //
120cdf0e10cSrcweir //			ScContentTree
121cdf0e10cSrcweir //
122cdf0e10cSrcweir 
123cdf0e10cSrcweir ScContentTree::ScContentTree( Window* pParent, const ResId& rResId ) :
124cdf0e10cSrcweir 	SvTreeListBox	( pParent, rResId ),
125cdf0e10cSrcweir 	aEntryImages	( ScResId( RID_IMAGELIST_NAVCONT ) ),
126cdf0e10cSrcweir 	aHCEntryImages	( ScResId( RID_IMAGELIST_H_NAVCONT ) ),
127cdf0e10cSrcweir 	nRootType		( SC_CONTENT_ROOT ),
128cdf0e10cSrcweir 	bHiddenDoc		( sal_False ),
129cdf0e10cSrcweir 	pHiddenDocument	( NULL )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	sal_uInt16 i;
132cdf0e10cSrcweir 	for (i=0; i<SC_CONTENT_COUNT; i++)
133cdf0e10cSrcweir 		pPosList[pTypeList[i]] = i;			// invers zum suchen
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	pParentWindow = (ScNavigatorDlg*)pParent;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	pRootNodes[0] = NULL;
138cdf0e10cSrcweir 	for (i=1; i<SC_CONTENT_COUNT; i++)
139cdf0e10cSrcweir 		InitRoot(i);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	SetNodeDefaultImages();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     SetDoubleClickHdl( LINK( this, ScContentTree, ContentDoubleClickHdl ) );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     SetStyle( GetStyle() | WB_QUICK_SEARCH );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir ScContentTree::~ScContentTree()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir void ScContentTree::InitRoot( sal_uInt16 nType )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	if ( !nType )
155cdf0e10cSrcweir 		return;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	if ( nRootType && nRootType != nType )				// ausgeblendet ?
158cdf0e10cSrcweir 	{
159cdf0e10cSrcweir 		pRootNodes[nType] = NULL;
160cdf0e10cSrcweir 		return;
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	const Image& rImage = aEntryImages.GetImage( nType );
164cdf0e10cSrcweir 	String aName( ScResId( SCSTR_CONTENT_ROOT + nType ) );
165cdf0e10cSrcweir 	// wieder an die richtige Position:
166cdf0e10cSrcweir 	sal_uInt16 nPos = nRootType ? 0 : pPosList[nType]-1;
167cdf0e10cSrcweir 	SvLBoxEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, sal_False, nPos );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	const Image& rHCImage = aHCEntryImages.GetImage( nType );
170cdf0e10cSrcweir 	SetExpandedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
171cdf0e10cSrcweir 	SetCollapsedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	pRootNodes[nType] = pNew;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir void ScContentTree::ClearAll()
177cdf0e10cSrcweir {
178cdf0e10cSrcweir 	Clear();
179cdf0e10cSrcweir 	for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++)
180cdf0e10cSrcweir 		InitRoot(i);
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir void ScContentTree::ClearType(sal_uInt16 nType)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	if (!nType)
186cdf0e10cSrcweir 		ClearAll();
187cdf0e10cSrcweir 	else
188cdf0e10cSrcweir 	{
189cdf0e10cSrcweir 		SvLBoxEntry* pParent = pRootNodes[nType];
190cdf0e10cSrcweir 		if ( !pParent || GetChildCount(pParent) )		// nicht, wenn ohne Children schon da
191cdf0e10cSrcweir 		{
192cdf0e10cSrcweir 			if (pParent)
193cdf0e10cSrcweir 				GetModel()->Remove( pParent );			// mit allen Children
194cdf0e10cSrcweir 			InitRoot( nType );							// ggf. neu eintragen
195cdf0e10cSrcweir 		}
196cdf0e10cSrcweir 	}
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir void ScContentTree::InsertContent( sal_uInt16 nType, const String& rValue )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir 	if (nType >= SC_CONTENT_COUNT)
202cdf0e10cSrcweir 	{
203cdf0e10cSrcweir 		DBG_ERROR("ScContentTree::InsertContent mit falschem Typ");
204cdf0e10cSrcweir 		return;
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	SvLBoxEntry* pParent = pRootNodes[nType];
208cdf0e10cSrcweir 	if (pParent)
209cdf0e10cSrcweir 		InsertEntry( rValue, pParent );
210cdf0e10cSrcweir 	else
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir 		DBG_ERROR("InsertContent ohne Parent");
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir void ScContentTree::GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChildIndex, SvLBoxEntry* pEntry ) const
217cdf0e10cSrcweir {
218cdf0e10cSrcweir     rnRootIndex = SC_CONTENT_ROOT;
219cdf0e10cSrcweir     rnChildIndex = SC_CONTENT_NOCHILD;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     if( !pEntry )
222cdf0e10cSrcweir         return;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     SvLBoxEntry* pParent = GetParent( pEntry );
225cdf0e10cSrcweir     bool bFound = false;
226cdf0e10cSrcweir     for( sal_uInt16 nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot )
227cdf0e10cSrcweir     {
228cdf0e10cSrcweir         if( pEntry == pRootNodes[ nRoot ] )
229cdf0e10cSrcweir         {
230cdf0e10cSrcweir             rnRootIndex = nRoot;
231cdf0e10cSrcweir             rnChildIndex = ~0UL;
232cdf0e10cSrcweir             bFound = true;
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir         else if( pParent && (pParent == pRootNodes[ nRoot ]) )
235cdf0e10cSrcweir         {
236cdf0e10cSrcweir             rnRootIndex = nRoot;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir             // search the entry in all child entries of the parent
239cdf0e10cSrcweir             sal_uLong nEntry = 0;
240cdf0e10cSrcweir             SvLBoxEntry* pIterEntry = FirstChild( pParent );
241cdf0e10cSrcweir             while( !bFound && pIterEntry )
242cdf0e10cSrcweir             {
243cdf0e10cSrcweir                 if ( pEntry == pIterEntry )
244cdf0e10cSrcweir                 {
245cdf0e10cSrcweir                     rnChildIndex = nEntry;
246cdf0e10cSrcweir                     bFound = true;  // exit the while loop
247cdf0e10cSrcweir                 }
248cdf0e10cSrcweir                 pIterEntry = NextSibling( pIterEntry );
249cdf0e10cSrcweir                 ++nEntry;
250cdf0e10cSrcweir             }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir             bFound = true;  // exit the for loop
253cdf0e10cSrcweir         }
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir sal_uLong ScContentTree::GetChildIndex( SvLBoxEntry* pEntry ) const
258cdf0e10cSrcweir {
259cdf0e10cSrcweir     sal_uInt16 nRoot;
260cdf0e10cSrcweir     sal_uLong nChild;
261cdf0e10cSrcweir     GetEntryIndexes( nRoot, nChild, pEntry );
262cdf0e10cSrcweir     return nChild;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir 	String aRet;
268cdf0e10cSrcweir 	if (pDoc)
269cdf0e10cSrcweir 	{
270cdf0e10cSrcweir 		ScDBCollection*	pDbNames = pDoc->GetDBCollection();
271cdf0e10cSrcweir 		sal_uInt16 nCount = pDbNames->GetCount();
272cdf0e10cSrcweir 		for ( sal_uInt16 i=0; i<nCount; i++ )
273cdf0e10cSrcweir 		{
274cdf0e10cSrcweir 			ScDBData* pData = (*pDbNames)[i];
275cdf0e10cSrcweir 			if ( pData->GetName() == rDBName )
276cdf0e10cSrcweir 			{
277cdf0e10cSrcweir 				ScRange aRange;
278cdf0e10cSrcweir 				pData->GetArea(aRange);
279cdf0e10cSrcweir 				aRange.Format( aRet, SCR_ABS_3D, pDoc );
280cdf0e10cSrcweir 				break;
281cdf0e10cSrcweir 			}
282cdf0e10cSrcweir 		}
283cdf0e10cSrcweir 	}
284cdf0e10cSrcweir 	return aRet;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir IMPL_LINK( ScContentTree, ContentDoubleClickHdl, ScContentTree *, EMPTYARG )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir     sal_uInt16 nType;
290cdf0e10cSrcweir     sal_uLong nChild;
291cdf0e10cSrcweir     SvLBoxEntry* pEntry = GetCurEntry();
292cdf0e10cSrcweir     GetEntryIndexes( nType, nChild, pEntry );
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir 		if ( bHiddenDoc )
297cdf0e10cSrcweir 			return 0;				//! spaeter...
298cdf0e10cSrcweir 
299cdf0e10cSrcweir         String aText( GetEntryText( pEntry ) );
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 		if ( aManualDoc.Len() )
302cdf0e10cSrcweir 			pParentWindow->SetCurrentDoc( aManualDoc );
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 		switch( nType )
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			case SC_CONTENT_TABLE:
307cdf0e10cSrcweir 				pParentWindow->SetCurrentTableStr( aText );
308cdf0e10cSrcweir             break;
309cdf0e10cSrcweir 
310cdf0e10cSrcweir             case SC_CONTENT_RANGENAME:
311cdf0e10cSrcweir 				pParentWindow->SetCurrentCellStr( aText );
312cdf0e10cSrcweir             break;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir             case SC_CONTENT_DBAREA:
315cdf0e10cSrcweir             {
316cdf0e10cSrcweir                 //  #47905# Wenn gleiche Bereichs- und DB-Namen existieren, wird
317cdf0e10cSrcweir                 //  bei SID_CURRENTCELL der Bereichsname genommen.
318cdf0e10cSrcweir                 //  DB-Bereiche darum direkt ueber die Adresse anspringen.
319cdf0e10cSrcweir 
320cdf0e10cSrcweir                 String aRangeStr = lcl_GetDBAreaRange( GetSourceDocument(), aText );
321cdf0e10cSrcweir                 if (aRangeStr.Len())
322cdf0e10cSrcweir                     pParentWindow->SetCurrentCellStr( aRangeStr );
323cdf0e10cSrcweir             }
324cdf0e10cSrcweir             break;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir             case SC_CONTENT_OLEOBJECT:
327cdf0e10cSrcweir 			case SC_CONTENT_GRAPHIC:
328cdf0e10cSrcweir 			case SC_CONTENT_DRAWING:
329cdf0e10cSrcweir 				pParentWindow->SetCurrentObject( aText );
330cdf0e10cSrcweir             break;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir             case SC_CONTENT_NOTE:
333cdf0e10cSrcweir             {
334cdf0e10cSrcweir                 ScAddress aPos = GetNotePos( nChild );
335cdf0e10cSrcweir                 pParentWindow->SetCurrentTable( aPos.Tab() );
336cdf0e10cSrcweir                 pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
337cdf0e10cSrcweir             }
338cdf0e10cSrcweir             break;
339cdf0e10cSrcweir 
340cdf0e10cSrcweir             case SC_CONTENT_AREALINK:
341cdf0e10cSrcweir             {
342cdf0e10cSrcweir                 const ScAreaLink* pLink = GetLink( nChild );
343cdf0e10cSrcweir                 if( pLink )
344cdf0e10cSrcweir                 {
345cdf0e10cSrcweir                     ScRange aRange = pLink->GetDestArea();
346cdf0e10cSrcweir                     String aRangeStr;
347cdf0e10cSrcweir                     ScDocument* pSrcDoc = GetSourceDocument();
348cdf0e10cSrcweir                     aRange.Format( aRangeStr, SCR_ABS_3D, pSrcDoc, pSrcDoc->GetAddressConvention() );
349cdf0e10cSrcweir                     pParentWindow->SetCurrentCellStr( aRangeStr );
350cdf0e10cSrcweir                 }
351cdf0e10cSrcweir             }
352cdf0e10cSrcweir             break;
353cdf0e10cSrcweir 		}
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		ScNavigatorDlg::ReleaseFocus();		// set focus into document
356cdf0e10cSrcweir 	}
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	return 0;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir void ScContentTree::MouseButtonDown( const MouseEvent& rMEvt )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir     SvTreeListBox::MouseButtonDown( rMEvt );
364cdf0e10cSrcweir     StoreSettings();
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir void ScContentTree::KeyInput( const KeyEvent& rKEvt )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir 	sal_Bool bUsed = sal_False;
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	const KeyCode aCode = rKEvt.GetKeyCode();
372cdf0e10cSrcweir 	if (aCode.GetCode() == KEY_RETURN)
373cdf0e10cSrcweir 	{
374cdf0e10cSrcweir 		switch (aCode.GetModifier())
375cdf0e10cSrcweir 		{
376cdf0e10cSrcweir 			case KEY_MOD1:
377cdf0e10cSrcweir 				ToggleRoot();		// toggle root mode (as in Writer)
378cdf0e10cSrcweir 				bUsed = sal_True;
379cdf0e10cSrcweir 				break;
380cdf0e10cSrcweir 			case 0:
381cdf0e10cSrcweir             {
382cdf0e10cSrcweir                 SvLBoxEntry* pEntry = GetCurEntry();
383cdf0e10cSrcweir                 if( pEntry )
384cdf0e10cSrcweir                 {
385cdf0e10cSrcweir                     sal_uInt16 nType;
386cdf0e10cSrcweir                     sal_uLong nChild;
387cdf0e10cSrcweir                     GetEntryIndexes( nType, nChild, pEntry );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir                     if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) )
390cdf0e10cSrcweir                     {
391cdf0e10cSrcweir                         String aText( GetEntryText( pEntry ) );
392cdf0e10cSrcweir                         if ( IsExpanded( pEntry ) )
393cdf0e10cSrcweir                             Collapse( pEntry );
394cdf0e10cSrcweir                         else
395cdf0e10cSrcweir                             Expand( pEntry );
396cdf0e10cSrcweir                     }
397cdf0e10cSrcweir                     else
398cdf0e10cSrcweir                         ContentDoubleClickHdl(0);      // select content as if double clicked
399cdf0e10cSrcweir                 }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir                 bUsed = sal_True;
402cdf0e10cSrcweir             }
403cdf0e10cSrcweir             break;
404cdf0e10cSrcweir 		}
405cdf0e10cSrcweir 	}
406cdf0e10cSrcweir     StoreSettings();
407cdf0e10cSrcweir 
408cdf0e10cSrcweir     if( !bUsed )
409cdf0e10cSrcweir 		SvTreeListBox::KeyInput(rKEvt);
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir //sal_Bool __EXPORT ScContentTree::Drop( const DropEvent& rEvt )
413cdf0e10cSrcweir //{
414cdf0e10cSrcweir //	return pParentWindow->Drop(rEvt);			// Drop auf Navigator
415cdf0e10cSrcweir //}
416cdf0e10cSrcweir 
417cdf0e10cSrcweir //sal_Bool __EXPORT ScContentTree::QueryDrop( DropEvent& rEvt )
418cdf0e10cSrcweir //{
419cdf0e10cSrcweir //	return pParentWindow->QueryDrop(rEvt);		// Drop auf Navigator
420cdf0e10cSrcweir //}
421cdf0e10cSrcweir 
422cdf0e10cSrcweir sal_Int8 ScContentTree::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	return DND_ACTION_NONE;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir sal_Int8 ScContentTree::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir 	return DND_ACTION_NONE;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir 
432cdf0e10cSrcweir void ScContentTree::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir 	DoDrag();
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir void ScContentTree::DragFinished( sal_Int8 /* nAction */ )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir void __EXPORT ScContentTree::Command( const CommandEvent& rCEvt )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	switch ( rCEvt.GetCommand() )
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		case COMMAND_STARTDRAG:
448cdf0e10cSrcweir 			//	Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
449cdf0e10cSrcweir 			//	(beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
450cdf0e10cSrcweir 			//	den StarView MouseMove-Handler, der Command() aufruft, umbringen.
451cdf0e10cSrcweir 			//	Deshalb Drag&Drop asynchron:
452cdf0e10cSrcweir 
453cdf0e10cSrcweir //			DoDrag();
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 			Application::PostUserEvent( STATIC_LINK( this, ScContentTree, ExecDragHdl ) );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 			bDone = sal_True;
458cdf0e10cSrcweir 			break;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 		case COMMAND_CONTEXTMENU:
461cdf0e10cSrcweir 			{
462cdf0e10cSrcweir 				//	Drag-Drop Modus
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 				PopupMenu aPop;
465cdf0e10cSrcweir 				ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
466cdf0e10cSrcweir 				aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
467cdf0e10cSrcweir 				aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
468cdf0e10cSrcweir 				aPop.SetPopupMenu( 1, &aDropMenu );
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 				//	angezeigtes Dokument
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 				ScPopupMenu aDocMenu;
473cdf0e10cSrcweir 				aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
474cdf0e10cSrcweir 				sal_uInt16 i=0;
475cdf0e10cSrcweir 				sal_uInt16 nPos=0;
476cdf0e10cSrcweir 				//	geladene Dokumente
477cdf0e10cSrcweir 				ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
478cdf0e10cSrcweir 				SfxObjectShell* pSh = SfxObjectShell::GetFirst();
479cdf0e10cSrcweir 				while ( pSh )
480cdf0e10cSrcweir 				{
481cdf0e10cSrcweir 					if ( pSh->ISA(ScDocShell) )
482cdf0e10cSrcweir 					{
483cdf0e10cSrcweir 						String aName = pSh->GetTitle();
484cdf0e10cSrcweir 						String aEntry = aName;
485cdf0e10cSrcweir 						if ( pSh == pCurrentSh )
486cdf0e10cSrcweir 							aEntry += pParentWindow->aStrActive;
487cdf0e10cSrcweir 						else
488cdf0e10cSrcweir 							aEntry += pParentWindow->aStrNotActive;
489cdf0e10cSrcweir 						aDocMenu.InsertItem( ++i, aEntry );
490cdf0e10cSrcweir 						if ( !bHiddenDoc && aName == aManualDoc )
491cdf0e10cSrcweir 							nPos = i;
492cdf0e10cSrcweir 					}
493cdf0e10cSrcweir 					pSh = SfxObjectShell::GetNext( *pSh );
494cdf0e10cSrcweir 				}
495cdf0e10cSrcweir 				//	"aktives Fenster"
496cdf0e10cSrcweir 				aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
497cdf0e10cSrcweir 				if (!bHiddenDoc && !aManualDoc.Len())
498cdf0e10cSrcweir 					nPos = i;
499cdf0e10cSrcweir 				//	verstecktes Dokument
500cdf0e10cSrcweir 				if ( aHiddenTitle.Len() )
501cdf0e10cSrcweir 				{
502cdf0e10cSrcweir 					String aEntry = aHiddenTitle;
503cdf0e10cSrcweir 					aEntry += pParentWindow->aStrHidden;
504cdf0e10cSrcweir 					aDocMenu.InsertItem( ++i, aEntry );
505cdf0e10cSrcweir 					if (bHiddenDoc)
506cdf0e10cSrcweir 						nPos = i;
507cdf0e10cSrcweir 				}
508cdf0e10cSrcweir 				aDocMenu.CheckItem( nPos );
509cdf0e10cSrcweir 				aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
510cdf0e10cSrcweir 				aPop.SetPopupMenu( 2, &aDocMenu );
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 				//	ausfuehren
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 				aPop.Execute( this, rCEvt.GetMousePosPixel() );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 				if ( aDropMenu.WasHit() )				//	Drag-Drop Modus
517cdf0e10cSrcweir 				{
518cdf0e10cSrcweir 					sal_uInt16 nId = aDropMenu.GetSelected();
519cdf0e10cSrcweir 					if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
520cdf0e10cSrcweir 						pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
521cdf0e10cSrcweir 				}
522cdf0e10cSrcweir 				else if ( aDocMenu.WasHit() )			//	angezeigtes Dokument
523cdf0e10cSrcweir 				{
524cdf0e10cSrcweir 					sal_uInt16 nId = aDocMenu.GetSelected();
525cdf0e10cSrcweir 					String aName = aDocMenu.GetItemText(nId);
526cdf0e10cSrcweir 					SelectDoc( aName );
527cdf0e10cSrcweir 				}
528cdf0e10cSrcweir 			}
529cdf0e10cSrcweir 			break;
530cdf0e10cSrcweir 	}
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	if (!bDone)
533cdf0e10cSrcweir 		SvTreeListBox::Command(rCEvt);
534cdf0e10cSrcweir }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir void __EXPORT ScContentTree::RequestHelp( const HelpEvent& rHEvt )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
539cdf0e10cSrcweir 	if( rHEvt.GetMode() & HELPMODE_QUICK )
540cdf0e10cSrcweir 	{
541cdf0e10cSrcweir 		Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
542cdf0e10cSrcweir 		SvLBoxEntry* pEntry = GetEntry( aPos );
543cdf0e10cSrcweir 		if ( pEntry )
544cdf0e10cSrcweir 		{
545cdf0e10cSrcweir 			sal_Bool bRet = sal_False;
546cdf0e10cSrcweir 			String aHelpText;
547cdf0e10cSrcweir 			SvLBoxEntry* pParent = GetParent(pEntry);
548cdf0e10cSrcweir 			if ( !pParent )									// Top-Level ?
549cdf0e10cSrcweir 			{
550cdf0e10cSrcweir 				aHelpText = String::CreateFromInt32( GetChildCount(pEntry) );
551cdf0e10cSrcweir 				aHelpText += ' ';
552cdf0e10cSrcweir 				aHelpText += GetEntryText(pEntry);
553cdf0e10cSrcweir 				bRet = sal_True;
554cdf0e10cSrcweir 			}
555cdf0e10cSrcweir 			else if ( pParent == pRootNodes[SC_CONTENT_NOTE] )
556cdf0e10cSrcweir 			{
557cdf0e10cSrcweir 				aHelpText = GetEntryText(pEntry);			// Notizen als Help-Text
558cdf0e10cSrcweir 				bRet = sal_True;
559cdf0e10cSrcweir 			}
560cdf0e10cSrcweir 			else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] )
561cdf0e10cSrcweir 			{
562cdf0e10cSrcweir                 sal_uLong nIndex = GetChildIndex(pEntry);
563cdf0e10cSrcweir                 if( nIndex != SC_CONTENT_NOCHILD )
564cdf0e10cSrcweir                 {
565cdf0e10cSrcweir                     const ScAreaLink* pLink = GetLink(nIndex);
566cdf0e10cSrcweir                     if (pLink)
567cdf0e10cSrcweir                     {
568cdf0e10cSrcweir                         aHelpText = pLink->GetFile();           // Source-Datei als Help-Text
569cdf0e10cSrcweir                         bRet = sal_True;
570cdf0e10cSrcweir                     }
571cdf0e10cSrcweir                 }
572cdf0e10cSrcweir 			}
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 			if (bRet)
575cdf0e10cSrcweir 			{
576cdf0e10cSrcweir 				SvLBoxTab* pTab;
577cdf0e10cSrcweir 				SvLBoxString* pItem = (SvLBoxString*)(GetItem( pEntry, aPos.X(), &pTab ));
578cdf0e10cSrcweir 				if( pItem )
579cdf0e10cSrcweir 				{
580cdf0e10cSrcweir 					aPos = GetEntryPosition( pEntry );
581cdf0e10cSrcweir 					aPos.X() = GetTabPos( pEntry, pTab );
582cdf0e10cSrcweir 					aPos = OutputToScreenPixel(aPos);
583cdf0e10cSrcweir 					Size aSize( pItem->GetSize( this, pEntry ) );
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 					Rectangle aItemRect( aPos, aSize );
586cdf0e10cSrcweir 					Help::ShowQuickHelp( this, aItemRect, aHelpText );
587cdf0e10cSrcweir 					bDone = sal_True;
588cdf0e10cSrcweir 				}
589cdf0e10cSrcweir 			}
590cdf0e10cSrcweir 		}
591cdf0e10cSrcweir 	}
592cdf0e10cSrcweir 	if (!bDone)
593cdf0e10cSrcweir 		Window::RequestHelp( rHEvt );
594cdf0e10cSrcweir }
595cdf0e10cSrcweir 
596cdf0e10cSrcweir ScDocument* ScContentTree::GetSourceDocument()
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	if (bHiddenDoc)
599cdf0e10cSrcweir 		return pHiddenDocument;
600cdf0e10cSrcweir 	else
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir 		ScDocShell* pSh = GetManualOrCurrent();
603cdf0e10cSrcweir 		if (pSh)
604cdf0e10cSrcweir 			return pSh->GetDocument();
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	}
607cdf0e10cSrcweir 	return NULL;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir 
610cdf0e10cSrcweir void ScContentTree::Refresh( sal_uInt16 nType )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir 	if ( bHiddenDoc && !pHiddenDocument )
613cdf0e10cSrcweir 		return;									// anderes Dokument angezeigt
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 	//	wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	if ( nType == SC_CONTENT_NOTE )
618cdf0e10cSrcweir 		if (!NoteStringsChanged())
619cdf0e10cSrcweir 			return;
620cdf0e10cSrcweir 	if ( nType == SC_CONTENT_GRAPHIC )
621cdf0e10cSrcweir 		if (!DrawNamesChanged(SC_CONTENT_GRAPHIC))
622cdf0e10cSrcweir 			return;
623cdf0e10cSrcweir 	if ( nType == SC_CONTENT_OLEOBJECT )
624cdf0e10cSrcweir 		if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT))
625cdf0e10cSrcweir 			return;
626cdf0e10cSrcweir 	if ( nType == SC_CONTENT_DRAWING )
627cdf0e10cSrcweir 		if (!DrawNamesChanged(SC_CONTENT_DRAWING))
628cdf0e10cSrcweir 			return;
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 	SetUpdateMode(sal_False);
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	ClearType( nType );
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_TABLE )
635cdf0e10cSrcweir 		GetTableNames();
636cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_RANGENAME )
637cdf0e10cSrcweir 		GetAreaNames();
638cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_DBAREA )
639cdf0e10cSrcweir 		GetDbNames();
640cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_GRAPHIC )
641cdf0e10cSrcweir 		GetGraphicNames();
642cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_OLEOBJECT )
643cdf0e10cSrcweir 		GetOleNames();
644cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_DRAWING )
645cdf0e10cSrcweir 		GetDrawingNames();
646cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_NOTE )
647cdf0e10cSrcweir 		GetNoteStrings();
648cdf0e10cSrcweir 	if ( !nType || nType == SC_CONTENT_AREALINK )
649cdf0e10cSrcweir 		GetLinkNames();
650cdf0e10cSrcweir 
651cdf0e10cSrcweir     ApplySettings();
652cdf0e10cSrcweir 	SetUpdateMode(sal_True);
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
655cdf0e10cSrcweir void ScContentTree::GetTableNames()
656cdf0e10cSrcweir {
657cdf0e10cSrcweir 	if ( nRootType && nRootType != SC_CONTENT_TABLE )		// ausgeblendet ?
658cdf0e10cSrcweir 		return;
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
661cdf0e10cSrcweir 	if (!pDoc)
662cdf0e10cSrcweir 		return;
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 	String aName;
665cdf0e10cSrcweir 	SCTAB nCount = pDoc->GetTableCount();
666cdf0e10cSrcweir 	for ( SCTAB i=0; i<nCount; i++ )
667cdf0e10cSrcweir 	{
668cdf0e10cSrcweir 		pDoc->GetName( i, aName );
669cdf0e10cSrcweir 		InsertContent( SC_CONTENT_TABLE, aName );
670cdf0e10cSrcweir 	}
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir void ScContentTree::GetAreaNames()
674cdf0e10cSrcweir {
675cdf0e10cSrcweir 	if ( nRootType && nRootType != SC_CONTENT_RANGENAME )		// ausgeblendet ?
676cdf0e10cSrcweir 		return;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
679cdf0e10cSrcweir 	if (!pDoc)
680cdf0e10cSrcweir 		return;
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 	ScRangeName* pRangeNames = pDoc->GetRangeName();
683cdf0e10cSrcweir 	sal_uInt16 nCount = pRangeNames->GetCount();
684cdf0e10cSrcweir 	if ( nCount > 0 )
685cdf0e10cSrcweir 	{
686cdf0e10cSrcweir 		sal_uInt16 nValidCount = 0;
687cdf0e10cSrcweir 		ScRange aDummy;
688cdf0e10cSrcweir 		sal_uInt16 i;
689cdf0e10cSrcweir 		for ( i=0; i<nCount; i++ )
690cdf0e10cSrcweir 		{
691cdf0e10cSrcweir 			ScRangeData* pData = (*pRangeNames)[i];
692cdf0e10cSrcweir 			if (pData->IsValidReference(aDummy))
693cdf0e10cSrcweir 				nValidCount++;
694cdf0e10cSrcweir 		}
695cdf0e10cSrcweir 		if ( nValidCount )
696cdf0e10cSrcweir 		{
697cdf0e10cSrcweir 			ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
698cdf0e10cSrcweir 			sal_uInt16 j;
699cdf0e10cSrcweir 			for ( i=0, j=0; i<nCount; i++ )
700cdf0e10cSrcweir 			{
701cdf0e10cSrcweir 				ScRangeData* pData = (*pRangeNames)[i];
702cdf0e10cSrcweir 				if (pData->IsValidReference(aDummy))
703cdf0e10cSrcweir 					ppSortArray[j++] = pData;
704cdf0e10cSrcweir 			}
705cdf0e10cSrcweir #ifndef ICC
706cdf0e10cSrcweir 			qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
707cdf0e10cSrcweir 				&ScRangeData_QsortNameCompare );
708cdf0e10cSrcweir #else
709cdf0e10cSrcweir 			qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
710cdf0e10cSrcweir 				ICCQsortNameCompare );
711cdf0e10cSrcweir #endif
712cdf0e10cSrcweir 			for ( j=0; j<nValidCount; j++ )
713cdf0e10cSrcweir 				InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
714cdf0e10cSrcweir 			delete [] ppSortArray;
715cdf0e10cSrcweir 		}
716cdf0e10cSrcweir 	}
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir void ScContentTree::GetDbNames()
720cdf0e10cSrcweir {
721*22407013SOliver-Rainer Wittmann     if ( nRootType && nRootType != SC_CONTENT_DBAREA )		// ausgeblendet ?
722*22407013SOliver-Rainer Wittmann         return;
723cdf0e10cSrcweir 
724*22407013SOliver-Rainer Wittmann     ScDocument* pDoc = GetSourceDocument();
725*22407013SOliver-Rainer Wittmann     if (!pDoc)
726*22407013SOliver-Rainer Wittmann         return;
727cdf0e10cSrcweir 
728*22407013SOliver-Rainer Wittmann     ScDBCollection*	pDbNames = pDoc->GetDBCollection();
729*22407013SOliver-Rainer Wittmann     sal_uInt16 nCount = pDbNames->GetCount();
730*22407013SOliver-Rainer Wittmann     if ( nCount > 0 )
731*22407013SOliver-Rainer Wittmann     {
732*22407013SOliver-Rainer Wittmann         for ( sal_uInt16 i=0; i<nCount; i++ )
733*22407013SOliver-Rainer Wittmann         {
734*22407013SOliver-Rainer Wittmann             ScDBData* pData = (*pDbNames)[i];
735*22407013SOliver-Rainer Wittmann             String aStrName = pData->GetName();
736*22407013SOliver-Rainer Wittmann             if ( !pData->IsInternalUnnamed()
737*22407013SOliver-Rainer Wittmann                  && !pData->IsInternalForAutoFilter() )
738*22407013SOliver-Rainer Wittmann             {
739*22407013SOliver-Rainer Wittmann                 InsertContent( SC_CONTENT_DBAREA, aStrName );
740*22407013SOliver-Rainer Wittmann             }
741*22407013SOliver-Rainer Wittmann         }
742*22407013SOliver-Rainer Wittmann     }
743cdf0e10cSrcweir }
744cdf0e10cSrcweir 
745cdf0e10cSrcweir bool ScContentTree::IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdentifier )  // static
746cdf0e10cSrcweir {
747cdf0e10cSrcweir     bool bRet = false;
748cdf0e10cSrcweir     switch ( nContentType )
749cdf0e10cSrcweir     {
750cdf0e10cSrcweir         case SC_CONTENT_GRAPHIC:
751cdf0e10cSrcweir             bRet = ( nObjIdentifier == OBJ_GRAF );
752cdf0e10cSrcweir             break;
753cdf0e10cSrcweir         case SC_CONTENT_OLEOBJECT:
754cdf0e10cSrcweir             bRet = ( nObjIdentifier == OBJ_OLE2 );
755cdf0e10cSrcweir             break;
756cdf0e10cSrcweir         case SC_CONTENT_DRAWING:
757cdf0e10cSrcweir             bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 );    // everything else
758cdf0e10cSrcweir             break;
759cdf0e10cSrcweir         default:
760cdf0e10cSrcweir             DBG_ERROR("unknown content type");
761cdf0e10cSrcweir     }
762cdf0e10cSrcweir     return bRet;
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir void ScContentTree::GetDrawNames( sal_uInt16 nType )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir 	if ( nRootType && nRootType != nType )				// ausgeblendet ?
768cdf0e10cSrcweir 		return;
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
771cdf0e10cSrcweir 	if (!pDoc)
772cdf0e10cSrcweir 		return;
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 	// iterate in flat mode for groups
775cdf0e10cSrcweir 	SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 	ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
778cdf0e10cSrcweir 	SfxObjectShell* pShell = pDoc->GetDocumentShell();
779cdf0e10cSrcweir 	if (pDrawLayer && pShell)
780cdf0e10cSrcweir 	{
781cdf0e10cSrcweir 		SCTAB nTabCount = pDoc->GetTableCount();
782cdf0e10cSrcweir 		for (SCTAB nTab=0; nTab<nTabCount; nTab++)
783cdf0e10cSrcweir 		{
784cdf0e10cSrcweir 			SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
785cdf0e10cSrcweir 			DBG_ASSERT(pPage,"Page ?");
786cdf0e10cSrcweir 			if (pPage)
787cdf0e10cSrcweir 			{
788cdf0e10cSrcweir 				SdrObjListIter aIter( *pPage, eIter );
789cdf0e10cSrcweir 				SdrObject* pObject = aIter.Next();
790cdf0e10cSrcweir 				while (pObject)
791cdf0e10cSrcweir 				{
792cdf0e10cSrcweir                     if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
793cdf0e10cSrcweir 					{
794cdf0e10cSrcweir 						String aName = ScDrawLayer::GetVisibleName( pObject );
795cdf0e10cSrcweir 						if (aName.Len())
796cdf0e10cSrcweir 							InsertContent( nType, aName );
797cdf0e10cSrcweir 					}
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 					pObject = aIter.Next();
800cdf0e10cSrcweir 				}
801cdf0e10cSrcweir 			}
802cdf0e10cSrcweir 		}
803cdf0e10cSrcweir 	}
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
806cdf0e10cSrcweir void ScContentTree::GetGraphicNames()
807cdf0e10cSrcweir {
808cdf0e10cSrcweir 	GetDrawNames( SC_CONTENT_GRAPHIC );
809cdf0e10cSrcweir }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir void ScContentTree::GetOleNames()
812cdf0e10cSrcweir {
813cdf0e10cSrcweir 	GetDrawNames( SC_CONTENT_OLEOBJECT );
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir void ScContentTree::GetDrawingNames()
817cdf0e10cSrcweir {
818cdf0e10cSrcweir 	GetDrawNames( SC_CONTENT_DRAWING );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir 
821cdf0e10cSrcweir void ScContentTree::GetLinkNames()
822cdf0e10cSrcweir {
823cdf0e10cSrcweir 	if ( nRootType && nRootType != SC_CONTENT_AREALINK )				// ausgeblendet ?
824cdf0e10cSrcweir 		return;
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
827cdf0e10cSrcweir 	if (!pDoc)
828cdf0e10cSrcweir 		return;
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
831cdf0e10cSrcweir 	DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
832cdf0e10cSrcweir 	const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
833cdf0e10cSrcweir 	sal_uInt16 nCount = rLinks.Count();
834cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<nCount; i++)
835cdf0e10cSrcweir 	{
836cdf0e10cSrcweir 		::sfx2::SvBaseLink* pBase = *rLinks[i];
837cdf0e10cSrcweir 		if (pBase->ISA(ScAreaLink))
838cdf0e10cSrcweir 			InsertContent( SC_CONTENT_AREALINK, ((ScAreaLink*)pBase)->GetSource() );
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 			//	in der Liste die Namen der Quellbereiche
841cdf0e10cSrcweir 	}
842cdf0e10cSrcweir }
843cdf0e10cSrcweir 
844cdf0e10cSrcweir const ScAreaLink* ScContentTree::GetLink( sal_uLong nIndex )
845cdf0e10cSrcweir {
846cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
847cdf0e10cSrcweir 	if (!pDoc)
848cdf0e10cSrcweir 		return NULL;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir 	sal_uLong nFound = 0;
851cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
852cdf0e10cSrcweir 	DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
853cdf0e10cSrcweir 	const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
854cdf0e10cSrcweir 	sal_uInt16 nCount = rLinks.Count();
855cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<nCount; i++)
856cdf0e10cSrcweir 	{
857cdf0e10cSrcweir 		::sfx2::SvBaseLink* pBase = *rLinks[i];
858cdf0e10cSrcweir 		if (pBase->ISA(ScAreaLink))
859cdf0e10cSrcweir 		{
860cdf0e10cSrcweir 			if (nFound == nIndex)
861cdf0e10cSrcweir 				return (const ScAreaLink*) pBase;
862cdf0e10cSrcweir 			++nFound;
863cdf0e10cSrcweir 		}
864cdf0e10cSrcweir 	}
865cdf0e10cSrcweir 
866cdf0e10cSrcweir 	DBG_ERROR("Link nicht gefunden");
867cdf0e10cSrcweir 	return NULL;
868cdf0e10cSrcweir }
869cdf0e10cSrcweir 
870cdf0e10cSrcweir String lcl_NoteString( const ScPostIt& rNote )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     String aText = rNote.GetText();
873cdf0e10cSrcweir 	xub_StrLen nAt;
874cdf0e10cSrcweir     while ( (nAt = aText.Search( '\n' )) != STRING_NOTFOUND )
875cdf0e10cSrcweir 		aText.SetChar( nAt, ' ' );
876cdf0e10cSrcweir 	return aText;
877cdf0e10cSrcweir }
878cdf0e10cSrcweir 
879cdf0e10cSrcweir void ScContentTree::GetNoteStrings()
880cdf0e10cSrcweir {
881cdf0e10cSrcweir 	if ( nRootType && nRootType != SC_CONTENT_NOTE )		// ausgeblendet ?
882cdf0e10cSrcweir 		return;
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
885cdf0e10cSrcweir 	if (!pDoc)
886cdf0e10cSrcweir 		return;
887cdf0e10cSrcweir 
888cdf0e10cSrcweir 	SCTAB nTabCount = pDoc->GetTableCount();
889cdf0e10cSrcweir 	for (SCTAB nTab=0; nTab<nTabCount; nTab++)
890cdf0e10cSrcweir 	{
891cdf0e10cSrcweir 		ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
892cdf0e10cSrcweir         for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
893cdf0e10cSrcweir             if( const ScPostIt* pNote = pCell->GetNote() )
894cdf0e10cSrcweir                 InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) );
895cdf0e10cSrcweir 	}
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
898cdf0e10cSrcweir ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
899cdf0e10cSrcweir {
900cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
901cdf0e10cSrcweir 	if (!pDoc)
902cdf0e10cSrcweir 		return ScAddress();
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 	sal_uLong nFound = 0;
905cdf0e10cSrcweir 	SCTAB nTabCount = pDoc->GetTableCount();
906cdf0e10cSrcweir 	for (SCTAB nTab=0; nTab<nTabCount; nTab++)
907cdf0e10cSrcweir 	{
908cdf0e10cSrcweir 		ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
909cdf0e10cSrcweir 		ScBaseCell* pCell = aIter.GetFirst();
910cdf0e10cSrcweir 		while (pCell)
911cdf0e10cSrcweir 		{
912cdf0e10cSrcweir             if( pCell->HasNote() )
913cdf0e10cSrcweir 			{
914cdf0e10cSrcweir 				if (nFound == nIndex)
915cdf0e10cSrcweir 					return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab );	// gefunden
916cdf0e10cSrcweir 				++nFound;
917cdf0e10cSrcweir 			}
918cdf0e10cSrcweir 			pCell = aIter.GetNext();
919cdf0e10cSrcweir 		}
920cdf0e10cSrcweir 	}
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 	DBG_ERROR("Notiz nicht gefunden");
923cdf0e10cSrcweir 	return ScAddress();
924cdf0e10cSrcweir }
925cdf0e10cSrcweir 
926cdf0e10cSrcweir sal_Bool ScContentTree::NoteStringsChanged()
927cdf0e10cSrcweir {
928cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
929cdf0e10cSrcweir 	if (!pDoc)
930cdf0e10cSrcweir 		return sal_False;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 	SvLBoxEntry* pParent = pRootNodes[SC_CONTENT_NOTE];
933cdf0e10cSrcweir 	if (!pParent)
934cdf0e10cSrcweir 		return sal_False;
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstChild( pParent );
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 	sal_Bool bEqual = sal_True;
939cdf0e10cSrcweir 	SCTAB nTabCount = pDoc->GetTableCount();
940cdf0e10cSrcweir 	for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
941cdf0e10cSrcweir 	{
942cdf0e10cSrcweir 		ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
943cdf0e10cSrcweir 		ScBaseCell* pCell = aIter.GetFirst();
944cdf0e10cSrcweir 		while (pCell && bEqual)
945cdf0e10cSrcweir 		{
946cdf0e10cSrcweir             if( const ScPostIt* pNote = pCell->GetNote() )
947cdf0e10cSrcweir 			{
948cdf0e10cSrcweir 				if ( !pEntry )
949cdf0e10cSrcweir 					bEqual = sal_False;
950cdf0e10cSrcweir 				else
951cdf0e10cSrcweir 				{
952cdf0e10cSrcweir                     if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
953cdf0e10cSrcweir 						bEqual = sal_False;
954cdf0e10cSrcweir 
955cdf0e10cSrcweir 					pEntry = NextSibling( pEntry );
956cdf0e10cSrcweir 				}
957cdf0e10cSrcweir 			}
958cdf0e10cSrcweir 			pCell = aIter.GetNext();
959cdf0e10cSrcweir 		}
960cdf0e10cSrcweir 	}
961cdf0e10cSrcweir 
962cdf0e10cSrcweir 	if ( pEntry )
963cdf0e10cSrcweir 		bEqual = sal_False;				// kommt noch was
964cdf0e10cSrcweir 
965cdf0e10cSrcweir 	return !bEqual;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir 
968cdf0e10cSrcweir sal_Bool ScContentTree::DrawNamesChanged( sal_uInt16 nType )
969cdf0e10cSrcweir {
970cdf0e10cSrcweir 	ScDocument* pDoc = GetSourceDocument();
971cdf0e10cSrcweir 	if (!pDoc)
972cdf0e10cSrcweir 		return sal_False;
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 	SvLBoxEntry* pParent = pRootNodes[nType];
975cdf0e10cSrcweir 	if (!pParent)
976cdf0e10cSrcweir 		return sal_False;
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstChild( pParent );
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 	// iterate in flat mode for groups
981cdf0e10cSrcweir 	SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	sal_Bool bEqual = sal_True;
984cdf0e10cSrcweir 	ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
985cdf0e10cSrcweir 	SfxObjectShell* pShell = pDoc->GetDocumentShell();
986cdf0e10cSrcweir 	if (pDrawLayer && pShell)
987cdf0e10cSrcweir 	{
988cdf0e10cSrcweir 		SCTAB nTabCount = pDoc->GetTableCount();
989cdf0e10cSrcweir 		for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
990cdf0e10cSrcweir 		{
991cdf0e10cSrcweir 			SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
992cdf0e10cSrcweir 			DBG_ASSERT(pPage,"Page ?");
993cdf0e10cSrcweir 			if (pPage)
994cdf0e10cSrcweir 			{
995cdf0e10cSrcweir 				SdrObjListIter aIter( *pPage, eIter );
996cdf0e10cSrcweir 				SdrObject* pObject = aIter.Next();
997cdf0e10cSrcweir 				while (pObject && bEqual)
998cdf0e10cSrcweir 				{
999cdf0e10cSrcweir                     if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
1000cdf0e10cSrcweir 					{
1001cdf0e10cSrcweir 						if ( !pEntry )
1002cdf0e10cSrcweir 							bEqual = sal_False;
1003cdf0e10cSrcweir 						else
1004cdf0e10cSrcweir 						{
1005cdf0e10cSrcweir 							if ( ScDrawLayer::GetVisibleName( pObject ) != GetEntryText(pEntry) )
1006cdf0e10cSrcweir 								bEqual = sal_False;
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 							pEntry = NextSibling( pEntry );
1009cdf0e10cSrcweir 						}
1010cdf0e10cSrcweir 					}
1011cdf0e10cSrcweir 					pObject = aIter.Next();
1012cdf0e10cSrcweir 				}
1013cdf0e10cSrcweir 			}
1014cdf0e10cSrcweir 		}
1015cdf0e10cSrcweir 	}
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 	if ( pEntry )
1018cdf0e10cSrcweir 		bEqual = sal_False;				// kommt noch was
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 	return !bEqual;
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRange& rRange )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
1026cdf0e10cSrcweir 	sal_uInt16 nPos;
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 	if ( nType == SC_CONTENT_RANGENAME )
1029cdf0e10cSrcweir 	{
1030cdf0e10cSrcweir 		ScRangeName* pList = pDoc->GetRangeName();
1031cdf0e10cSrcweir 		if (pList)
1032cdf0e10cSrcweir 			if (pList->SearchName( rName, nPos ))
1033cdf0e10cSrcweir 				if ( (*pList)[nPos]->IsValidReference( rRange ) )
1034cdf0e10cSrcweir 					bFound = sal_True;
1035cdf0e10cSrcweir 	}
1036cdf0e10cSrcweir 	else if ( nType == SC_CONTENT_DBAREA )
1037cdf0e10cSrcweir 	{
1038cdf0e10cSrcweir 		ScDBCollection*	pList = pDoc->GetDBCollection();
1039cdf0e10cSrcweir 		if (pList)
1040cdf0e10cSrcweir 			if (pList->SearchName( rName, nPos ))
1041cdf0e10cSrcweir 			{
1042cdf0e10cSrcweir                 SCTAB nTab;
1043cdf0e10cSrcweir                 SCCOL nCol1, nCol2;
1044cdf0e10cSrcweir                 SCROW nRow1, nRow2;
1045cdf0e10cSrcweir                 (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
1046cdf0e10cSrcweir 				rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
1047cdf0e10cSrcweir 				bFound = sal_True;
1048cdf0e10cSrcweir 			}
1049cdf0e10cSrcweir 	}
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 	return bFound;
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir void lcl_DoDragObject( ScDocShell* pSrcShell, const String& rName, sal_uInt16 nType, Window* pWin )
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir 	ScDocument* pSrcDoc = pSrcShell->GetDocument();
1057cdf0e10cSrcweir 	ScDrawLayer* pModel = pSrcDoc->GetDrawLayer();
1058cdf0e10cSrcweir 	if (pModel)
1059cdf0e10cSrcweir 	{
1060cdf0e10cSrcweir 		sal_Bool bOle = ( nType == SC_CONTENT_OLEOBJECT );
1061cdf0e10cSrcweir 		sal_Bool bGraf = ( nType == SC_CONTENT_GRAPHIC );
1062cdf0e10cSrcweir         sal_uInt16 nDrawId = sal::static_int_cast<sal_uInt16>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) );
1063cdf0e10cSrcweir 		SCTAB nTab = 0;
1064cdf0e10cSrcweir 		SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab );
1065cdf0e10cSrcweir 		if (pObject)
1066cdf0e10cSrcweir 		{
1067cdf0e10cSrcweir 			SdrView aEditView( pModel );
1068cdf0e10cSrcweir 			aEditView.ShowSdrPage(aEditView.GetModel()->GetPage(nTab));
1069cdf0e10cSrcweir 			SdrPageView* pPV = aEditView.GetSdrPageView();
1070cdf0e10cSrcweir 			aEditView.MarkObj(pObject, pPV);
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 			SdrModel* pDragModel = aEditView.GetAllMarkedModel();
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir 			TransferableObjectDescriptor aObjDesc;
1075cdf0e10cSrcweir 			pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1076cdf0e10cSrcweir 			aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1077cdf0e10cSrcweir 			// maSize is set in ScDrawTransferObj ctor
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir 			ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc );
1080cdf0e10cSrcweir 			uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir 			pTransferObj->SetDragSourceObj( pObject, nTab );
1083cdf0e10cSrcweir 			pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 			SC_MOD()->SetDragObject( NULL, pTransferObj );
1086cdf0e10cSrcweir 			pWin->ReleaseMouse();
1087cdf0e10cSrcweir 			pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1088cdf0e10cSrcweir 		}
1089cdf0e10cSrcweir 	}
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, sal_uInt16 nFlags, Window* pWin )
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir 	ScMarkData aMark;
1095cdf0e10cSrcweir 	aMark.SelectTable( rRange.aStart.Tab(), sal_True );
1096cdf0e10cSrcweir 	aMark.SetMarkArea( rRange );
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	ScDocument* pSrcDoc = pSrcShell->GetDocument();
1099cdf0e10cSrcweir 	if ( !pSrcDoc->HasSelectedBlockMatrixFragment( rRange.aStart.Col(), rRange.aStart.Row(),
1100cdf0e10cSrcweir 												   rRange.aEnd.Col(),   rRange.aEnd.Row(),
1101cdf0e10cSrcweir 												   aMark ) )
1102cdf0e10cSrcweir 	{
1103cdf0e10cSrcweir 		ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
1104cdf0e10cSrcweir         ScClipParam aClipParam(rRange, false);
1105cdf0e10cSrcweir         pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aMark);
1106cdf0e10cSrcweir 		// pClipDoc->ExtendMerge( rRange, sal_True );
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 		TransferableObjectDescriptor aObjDesc;
1109cdf0e10cSrcweir 		pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1110cdf0e10cSrcweir 		aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1111cdf0e10cSrcweir 		// maSize is set in ScTransferObj ctor
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 		ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
1114cdf0e10cSrcweir 		uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir 		pTransferObj->SetDragSource( pSrcShell, aMark );
1117cdf0e10cSrcweir 		pTransferObj->SetDragSourceFlags( nFlags );
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 		SC_MOD()->SetDragObject( pTransferObj, NULL );		// for internal D&D
1120cdf0e10cSrcweir 		pWin->ReleaseMouse();
1121cdf0e10cSrcweir 		pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1122cdf0e10cSrcweir 	}
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir void ScContentTree::DoDrag()
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir 	ScDocumentLoader* pDocLoader = NULL;
1128cdf0e10cSrcweir 	bIsInDrag = sal_True;
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir 	ScModule* pScMod = SC_MOD();
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir     sal_uInt16 nType;
1133cdf0e10cSrcweir     sal_uLong nChild;
1134cdf0e10cSrcweir     SvLBoxEntry* pEntry = GetCurEntry();
1135cdf0e10cSrcweir     GetEntryIndexes( nType, nChild, pEntry );
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir     if( pEntry &&
1138cdf0e10cSrcweir         (nChild != SC_CONTENT_NOCHILD) &&
1139cdf0e10cSrcweir         (nType != SC_CONTENT_ROOT) &&
1140cdf0e10cSrcweir         (nType != SC_CONTENT_NOTE) &&
1141cdf0e10cSrcweir         (nType != SC_CONTENT_AREALINK) )
1142cdf0e10cSrcweir     {
1143cdf0e10cSrcweir         String aText( GetEntryText( pEntry ) );
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir 		ScDocument* pLocalDoc = NULL;					// fuer URL-Drop
1146cdf0e10cSrcweir 		String aDocName;
1147cdf0e10cSrcweir 		if (bHiddenDoc)
1148cdf0e10cSrcweir 			aDocName = aHiddenName;
1149cdf0e10cSrcweir 		else
1150cdf0e10cSrcweir 		{
1151cdf0e10cSrcweir 			ScDocShell* pDocSh = GetManualOrCurrent();
1152cdf0e10cSrcweir 			if (pDocSh)
1153cdf0e10cSrcweir 			{
1154cdf0e10cSrcweir 				if (pDocSh->HasName())
1155cdf0e10cSrcweir 					aDocName = pDocSh->GetMedium()->GetName();
1156cdf0e10cSrcweir 				else
1157cdf0e10cSrcweir 					pLocalDoc = pDocSh->GetDocument();		// Drop nur in dieses Dokument
1158cdf0e10cSrcweir 			}
1159cdf0e10cSrcweir 		}
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir 		sal_Bool bDoLinkTrans = sal_False;		// use ScLinkTransferObj
1162cdf0e10cSrcweir 		String aLinkURL;				// for ScLinkTransferObj
1163cdf0e10cSrcweir 		String aLinkText;
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 		sal_uInt16 nDropMode = pParentWindow->GetDropMode();
1166cdf0e10cSrcweir 		switch ( nDropMode )
1167cdf0e10cSrcweir 		{
1168cdf0e10cSrcweir 			case SC_DROPMODE_URL:
1169cdf0e10cSrcweir 				{
1170cdf0e10cSrcweir 					String aUrl = aDocName;
1171cdf0e10cSrcweir 					aUrl += '#';
1172cdf0e10cSrcweir 					aUrl += aText;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 					pScMod->SetDragJump( pLocalDoc, aUrl, aText );
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir 					if (aDocName.Len())
1177cdf0e10cSrcweir 					{
1178cdf0e10cSrcweir 						//	provide URL to outside only if the document has a name
1179cdf0e10cSrcweir 						//	(without name, only internal D&D via SetDragJump)
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 						aLinkURL = aUrl;
1182cdf0e10cSrcweir 						aLinkText = aText;
1183cdf0e10cSrcweir 					}
1184cdf0e10cSrcweir 					bDoLinkTrans = sal_True;
1185cdf0e10cSrcweir 				}
1186cdf0e10cSrcweir 				break;
1187cdf0e10cSrcweir 			case SC_DROPMODE_LINK:
1188cdf0e10cSrcweir 				{
1189cdf0e10cSrcweir 					if ( aDocName.Len() )			// link only to named documents
1190cdf0e10cSrcweir 					{
1191cdf0e10cSrcweir 						// for internal D&D, set flag to insert a link
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir 						switch ( nType )
1194cdf0e10cSrcweir 						{
1195cdf0e10cSrcweir 							case SC_CONTENT_TABLE:
1196cdf0e10cSrcweir 								pScMod->SetDragLink( aDocName, aText, EMPTY_STRING );
1197cdf0e10cSrcweir 								bDoLinkTrans = sal_True;
1198cdf0e10cSrcweir 								break;
1199cdf0e10cSrcweir 							case SC_CONTENT_RANGENAME:
1200cdf0e10cSrcweir 							case SC_CONTENT_DBAREA:
1201cdf0e10cSrcweir 								pScMod->SetDragLink( aDocName, EMPTY_STRING, aText );
1202cdf0e10cSrcweir 								bDoLinkTrans = sal_True;
1203cdf0e10cSrcweir 								break;
1204cdf0e10cSrcweir 
1205cdf0e10cSrcweir 							// other types cannot be linked
1206cdf0e10cSrcweir 						}
1207cdf0e10cSrcweir 					}
1208cdf0e10cSrcweir 				}
1209cdf0e10cSrcweir 				break;
1210cdf0e10cSrcweir 			case SC_DROPMODE_COPY:
1211cdf0e10cSrcweir 				{
1212cdf0e10cSrcweir 					ScDocShell* pSrcShell = NULL;
1213cdf0e10cSrcweir 					if ( bHiddenDoc )
1214cdf0e10cSrcweir 					{
1215cdf0e10cSrcweir 						String aFilter, aOptions;
1216cdf0e10cSrcweir 						pDocLoader = new ScDocumentLoader( aHiddenName, aFilter, aOptions );
1217cdf0e10cSrcweir 						if (!pDocLoader->IsError())
1218cdf0e10cSrcweir 							pSrcShell = pDocLoader->GetDocShell();
1219cdf0e10cSrcweir 					}
1220cdf0e10cSrcweir 					else
1221cdf0e10cSrcweir 						pSrcShell = GetManualOrCurrent();
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 					if ( pSrcShell )
1224cdf0e10cSrcweir 					{
1225cdf0e10cSrcweir 						ScDocument* pSrcDoc = pSrcShell->GetDocument();
1226cdf0e10cSrcweir 						if ( nType == SC_CONTENT_RANGENAME || nType == SC_CONTENT_DBAREA )
1227cdf0e10cSrcweir 						{
1228cdf0e10cSrcweir 							ScRange aRange;
1229cdf0e10cSrcweir 							if ( lcl_GetRange( pSrcDoc, nType, aText, aRange ) )
1230cdf0e10cSrcweir 							{
1231cdf0e10cSrcweir 								lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this );
1232cdf0e10cSrcweir 							}
1233cdf0e10cSrcweir 						}
1234cdf0e10cSrcweir 						else if ( nType == SC_CONTENT_TABLE )
1235cdf0e10cSrcweir 						{
1236cdf0e10cSrcweir 							SCTAB nTab;
1237cdf0e10cSrcweir 							if ( pSrcDoc->GetTable( aText, nTab ) )
1238cdf0e10cSrcweir 							{
1239cdf0e10cSrcweir 								ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab );
1240cdf0e10cSrcweir 								lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this );
1241cdf0e10cSrcweir 							}
1242cdf0e10cSrcweir 						}
1243cdf0e10cSrcweir 						else if ( nType == SC_CONTENT_GRAPHIC || nType == SC_CONTENT_OLEOBJECT ||
1244cdf0e10cSrcweir 									nType == SC_CONTENT_DRAWING )
1245cdf0e10cSrcweir 						{
1246cdf0e10cSrcweir 							lcl_DoDragObject( pSrcShell, aText, nType, this );
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 							//	in ExecuteDrag kann der Navigator geloescht worden sein
1249cdf0e10cSrcweir 							//	-> nicht mehr auf Member zugreifen !!!
1250cdf0e10cSrcweir 						}
1251cdf0e10cSrcweir 					}
1252cdf0e10cSrcweir 				}
1253cdf0e10cSrcweir 				break;
1254cdf0e10cSrcweir 		}
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir 		if (bDoLinkTrans)
1257cdf0e10cSrcweir 		{
1258cdf0e10cSrcweir 			ScLinkTransferObj* pTransferObj = new ScLinkTransferObj;
1259cdf0e10cSrcweir 			uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir 			if ( aLinkURL.Len() )
1262cdf0e10cSrcweir 				pTransferObj->SetLinkURL( aLinkURL, aLinkText );
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir 			//	SetDragJump / SetDragLink has been done above
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir 			ReleaseMouse();
1267cdf0e10cSrcweir 			pTransferObj->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1268cdf0e10cSrcweir 		}
1269cdf0e10cSrcweir 	}
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 	bIsInDrag = sal_False;				// static Member
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir 	delete pDocLoader;				// falls Dokument zum Draggen geladen wurde
1274cdf0e10cSrcweir }
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir IMPL_STATIC_LINK(ScContentTree, ExecDragHdl, void*, EMPTYARG)
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir 	//	als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1279cdf0e10cSrcweir 	//	Navigator geloescht werden darf
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir 	pThis->DoDrag();
1282cdf0e10cSrcweir 	return 0;
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir //UNUSED2008-05  void ScContentTree::AdjustTitle()
1286cdf0e10cSrcweir //UNUSED2008-05  {
1287cdf0e10cSrcweir //UNUSED2008-05      String aTitle = pParentWindow->aTitleBase;
1288cdf0e10cSrcweir //UNUSED2008-05      if (bHiddenDoc)
1289cdf0e10cSrcweir //UNUSED2008-05      {
1290cdf0e10cSrcweir //UNUSED2008-05          aTitle.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
1291cdf0e10cSrcweir //UNUSED2008-05          aTitle += aHiddenTitle;
1292cdf0e10cSrcweir //UNUSED2008-05      }
1293cdf0e10cSrcweir //UNUSED2008-05      pParentWindow->SetText(aTitle);
1294cdf0e10cSrcweir //UNUSED2008-05  }
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir sal_Bool ScContentTree::LoadFile( const String& rUrl )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir 	String aDocName = rUrl;
1299cdf0e10cSrcweir 	xub_StrLen nPos = aDocName.Search('#');
1300cdf0e10cSrcweir 	if ( nPos != STRING_NOTFOUND )
1301cdf0e10cSrcweir 		aDocName.Erase(nPos);			// nur der Name, ohne #...
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
1304cdf0e10cSrcweir 	String aFilter, aOptions;
1305cdf0e10cSrcweir 	ScDocumentLoader aLoader( aDocName, aFilter, aOptions );
1306cdf0e10cSrcweir 	if ( !aLoader.IsError() )
1307cdf0e10cSrcweir 	{
1308cdf0e10cSrcweir 		bHiddenDoc = sal_True;
1309cdf0e10cSrcweir 		aHiddenName = aDocName;
1310cdf0e10cSrcweir 		aHiddenTitle = aLoader.GetTitle();
1311cdf0e10cSrcweir 		pHiddenDocument = aLoader.GetDocument();
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir 		Refresh();						// Inhalte aus geladenem Dokument holen
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir 		pHiddenDocument = NULL;
1316cdf0e10cSrcweir //		AdjustTitle();
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 		pParentWindow->GetDocNames( &aHiddenTitle );			// Liste fuellen
1319cdf0e10cSrcweir 	}
1320cdf0e10cSrcweir 	else
1321cdf0e10cSrcweir 		Sound::Beep();			// Fehler beim Laden
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir 	//	Dokument wird im dtor von ScDocumentLoader wieder geschlossen
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 	return bReturn;
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir void ScContentTree::InitWindowBits( sal_Bool bButtons )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir 	WinBits nFlags = GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL;
1331cdf0e10cSrcweir 	if (bButtons)
1332cdf0e10cSrcweir 		nFlags |= WB_HASBUTTONS|WB_HASBUTTONSATROOT;
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir 	SetStyle( nFlags );
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir void ScContentTree::SetRootType( sal_uInt16 nNew )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir 	if ( nNew != nRootType )
1340cdf0e10cSrcweir 	{
1341cdf0e10cSrcweir 		nRootType = nNew;
1342cdf0e10cSrcweir 		InitWindowBits( nNew == 0 );
1343cdf0e10cSrcweir 		Refresh();
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir 		ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1346cdf0e10cSrcweir 		rCfg.SetRootType( nRootType );
1347cdf0e10cSrcweir 	}
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir void ScContentTree::ToggleRoot()		// nach Selektion
1351cdf0e10cSrcweir {
1352cdf0e10cSrcweir 	sal_uInt16 nNew = SC_CONTENT_ROOT;
1353cdf0e10cSrcweir 	if ( nRootType == SC_CONTENT_ROOT )
1354cdf0e10cSrcweir 	{
1355cdf0e10cSrcweir 		SvLBoxEntry* pEntry = GetCurEntry();
1356cdf0e10cSrcweir 		if (pEntry)
1357cdf0e10cSrcweir 		{
1358cdf0e10cSrcweir 			SvLBoxEntry* pParent = GetParent(pEntry);
1359cdf0e10cSrcweir 			for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++)
1360cdf0e10cSrcweir 				if ( pEntry == pRootNodes[i] || pParent == pRootNodes[i] )
1361cdf0e10cSrcweir 					nNew = i;
1362cdf0e10cSrcweir 		}
1363cdf0e10cSrcweir 	}
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir 	SetRootType( nNew );
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir void ScContentTree::ResetManualDoc()
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir 	aManualDoc.Erase();
1371cdf0e10cSrcweir 	bHiddenDoc = sal_False;
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir 	ActiveDocChanged();
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir void ScContentTree::ActiveDocChanged()
1377cdf0e10cSrcweir {
1378cdf0e10cSrcweir 	if ( !bHiddenDoc && !aManualDoc.Len() )
1379cdf0e10cSrcweir 		Refresh();									// Inhalte nur wenn automatisch
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 		//	Listbox muss immer geupdated werden, wegen aktiv-Flag
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir 	String aCurrent;
1384cdf0e10cSrcweir 	if ( bHiddenDoc )
1385cdf0e10cSrcweir 		aCurrent = aHiddenTitle;
1386cdf0e10cSrcweir 	else
1387cdf0e10cSrcweir 	{
1388cdf0e10cSrcweir 		ScDocShell* pSh = GetManualOrCurrent();
1389cdf0e10cSrcweir 		if (pSh)
1390cdf0e10cSrcweir 			aCurrent = pSh->GetTitle();
1391cdf0e10cSrcweir 		else
1392cdf0e10cSrcweir 		{
1393cdf0e10cSrcweir 			//	eingestelltes Dokument existiert nicht mehr
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 			aManualDoc.Erase();				// wieder automatisch
1396cdf0e10cSrcweir 			Refresh();
1397cdf0e10cSrcweir 			pSh = GetManualOrCurrent();		// sollte jetzt aktives sein
1398cdf0e10cSrcweir 			if (pSh)
1399cdf0e10cSrcweir 				aCurrent = pSh->GetTitle();
1400cdf0e10cSrcweir 		}
1401cdf0e10cSrcweir 	}
1402cdf0e10cSrcweir 	pParentWindow->GetDocNames( &aCurrent );		// selektieren
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir void ScContentTree::SetManualDoc(const String& rName)
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir 	aManualDoc = rName;
1408cdf0e10cSrcweir 	if (!bHiddenDoc)
1409cdf0e10cSrcweir 	{
1410cdf0e10cSrcweir 		Refresh();
1411cdf0e10cSrcweir 		pParentWindow->GetDocNames( &aManualDoc );		// selektieren
1412cdf0e10cSrcweir 	}
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir void ScContentTree::SelectDoc(const String& rName)		// rName wie im Menue/Listbox angezeigt
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir 	if ( rName == pParentWindow->aStrActiveWin )
1418cdf0e10cSrcweir 	{
1419cdf0e10cSrcweir 		ResetManualDoc();
1420cdf0e10cSrcweir 		return;
1421cdf0e10cSrcweir 	}
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir 	//	"aktiv" oder "inaktiv" weglassen
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 	String aRealName = rName;
1426cdf0e10cSrcweir 	xub_StrLen nLen = rName.Len();
1427cdf0e10cSrcweir 	xub_StrLen nActiveStart = nLen - pParentWindow->aStrActive.Len();
1428cdf0e10cSrcweir 	if ( rName.Copy( nActiveStart ) == pParentWindow->aStrActive )
1429cdf0e10cSrcweir 		aRealName = rName.Copy( 0, nActiveStart );
1430cdf0e10cSrcweir 	xub_StrLen nNotActiveStart = nLen - pParentWindow->aStrNotActive.Len();
1431cdf0e10cSrcweir 	if ( rName.Copy( nNotActiveStart ) == pParentWindow->aStrNotActive )
1432cdf0e10cSrcweir 		aRealName = rName.Copy( 0, nNotActiveStart );
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir 	//
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir 	sal_Bool bLoaded = sal_False;
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir 		// ist es ein normal geladenes Doc ?
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir 	SfxObjectShell* pSh = SfxObjectShell::GetFirst();
1441cdf0e10cSrcweir 	while ( pSh && !bLoaded )
1442cdf0e10cSrcweir 	{
1443cdf0e10cSrcweir 		if ( pSh->ISA(ScDocShell) )
1444cdf0e10cSrcweir 			if ( pSh->GetTitle() == aRealName )
1445cdf0e10cSrcweir 				bLoaded = sal_True;
1446cdf0e10cSrcweir 		pSh = SfxObjectShell::GetNext( *pSh );
1447cdf0e10cSrcweir 	}
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 	if (bLoaded)
1450cdf0e10cSrcweir 	{
1451cdf0e10cSrcweir 		bHiddenDoc = sal_False;
1452cdf0e10cSrcweir 		SetManualDoc(aRealName);
1453cdf0e10cSrcweir 	}
1454cdf0e10cSrcweir 	else if (aHiddenTitle.Len())				// verstecktes ausgewaehlt
1455cdf0e10cSrcweir 	{
1456cdf0e10cSrcweir 		if (!bHiddenDoc)
1457cdf0e10cSrcweir 			LoadFile(aHiddenName);
1458cdf0e10cSrcweir 	}
1459cdf0e10cSrcweir 	else
1460cdf0e10cSrcweir 	{
1461cdf0e10cSrcweir 		DBG_ERROR("SelectDoc: nicht gefunden");
1462cdf0e10cSrcweir 	}
1463cdf0e10cSrcweir }
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir void ScContentTree::ApplySettings()
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir     const ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
1468cdf0e10cSrcweir     if( pSettings )
1469cdf0e10cSrcweir     {
1470cdf0e10cSrcweir         sal_uInt16 nRootSel = pSettings->GetRootSelected();
1471cdf0e10cSrcweir         sal_uLong nChildSel = pSettings->GetChildSelected();
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir         for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
1474cdf0e10cSrcweir         {
1475cdf0e10cSrcweir             if( pRootNodes[ nEntry ] )
1476cdf0e10cSrcweir             {
1477cdf0e10cSrcweir                 // expand
1478cdf0e10cSrcweir                 sal_Bool bExp = pSettings->IsExpanded( nEntry );
1479cdf0e10cSrcweir                 if( bExp != IsExpanded( pRootNodes[ nEntry ] ) )
1480cdf0e10cSrcweir                 {
1481cdf0e10cSrcweir                     if( bExp )
1482cdf0e10cSrcweir                         Expand( pRootNodes[ nEntry ] );
1483cdf0e10cSrcweir                     else
1484cdf0e10cSrcweir                         Collapse( pRootNodes[ nEntry ] );
1485cdf0e10cSrcweir                 }
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir                 // select
1488cdf0e10cSrcweir                 if( nRootSel == nEntry )
1489cdf0e10cSrcweir                 {
1490cdf0e10cSrcweir                     SvLBoxEntry* pEntry = NULL;
1491cdf0e10cSrcweir                     if( bExp && (nChildSel != SC_CONTENT_NOCHILD) )
1492cdf0e10cSrcweir                         pEntry = GetEntry( pRootNodes[ nEntry ], nChildSel );
1493cdf0e10cSrcweir                     Select( pEntry ? pEntry : pRootNodes[ nEntry ] );
1494cdf0e10cSrcweir                 }
1495cdf0e10cSrcweir             }
1496cdf0e10cSrcweir         }
1497cdf0e10cSrcweir     }
1498cdf0e10cSrcweir }
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir void ScContentTree::StoreSettings() const
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir     ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
1503cdf0e10cSrcweir     if( pSettings )
1504cdf0e10cSrcweir     {
1505cdf0e10cSrcweir         for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
1506cdf0e10cSrcweir         {
1507cdf0e10cSrcweir             sal_Bool bExp = pRootNodes[ nEntry ] && IsExpanded( pRootNodes[ nEntry ] );
1508cdf0e10cSrcweir             pSettings->SetExpanded( nEntry, bExp );
1509cdf0e10cSrcweir         }
1510cdf0e10cSrcweir         sal_uInt16 nRoot;
1511cdf0e10cSrcweir         sal_uLong nChild;
1512cdf0e10cSrcweir         GetEntryIndexes( nRoot, nChild, GetCurEntry() );
1513cdf0e10cSrcweir         pSettings->SetRootSelected( nRoot );
1514cdf0e10cSrcweir         pSettings->SetChildSelected( nChild );
1515cdf0e10cSrcweir     }
1516cdf0e10cSrcweir }
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir //
1520cdf0e10cSrcweir //------------------------------------------------------------------------
1521cdf0e10cSrcweir //
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir 
1527