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"
67*0deba7fbSSteve Yin #include "tabvwsh.hxx"
68*0deba7fbSSteve Yin #include "drawview.hxx"
69cdf0e10cSrcweir #include "clipparam.hxx"
70cdf0e10cSrcweir
71cdf0e10cSrcweir using namespace com::sun::star;
72cdf0e10cSrcweir
73cdf0e10cSrcweir // Reihenfolge der Kategorien im Navigator -------------------------------------
74cdf0e10cSrcweir
75cdf0e10cSrcweir static sal_uInt16 pTypeList[SC_CONTENT_COUNT] =
76cdf0e10cSrcweir {
77cdf0e10cSrcweir SC_CONTENT_ROOT, // ROOT (0) muss vorne stehen
78cdf0e10cSrcweir SC_CONTENT_TABLE,
79cdf0e10cSrcweir SC_CONTENT_RANGENAME,
80cdf0e10cSrcweir SC_CONTENT_DBAREA,
81cdf0e10cSrcweir SC_CONTENT_AREALINK,
82cdf0e10cSrcweir SC_CONTENT_GRAPHIC,
83cdf0e10cSrcweir SC_CONTENT_OLEOBJECT,
84cdf0e10cSrcweir SC_CONTENT_NOTE,
85cdf0e10cSrcweir SC_CONTENT_DRAWING
86cdf0e10cSrcweir };
87cdf0e10cSrcweir
88cdf0e10cSrcweir sal_Bool ScContentTree::bIsInDrag = sal_False;
89cdf0e10cSrcweir
90cdf0e10cSrcweir
GetManualOrCurrent()91cdf0e10cSrcweir ScDocShell* ScContentTree::GetManualOrCurrent()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir ScDocShell* pSh = NULL;
94cdf0e10cSrcweir if ( aManualDoc.Len() )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir TypeId aScType = TYPE(ScDocShell);
97cdf0e10cSrcweir SfxObjectShell* pObjSh = SfxObjectShell::GetFirst( &aScType );
98cdf0e10cSrcweir while ( pObjSh && !pSh )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir if ( pObjSh->GetTitle() == aManualDoc )
101cdf0e10cSrcweir pSh = PTR_CAST( ScDocShell, pObjSh );
102cdf0e10cSrcweir pObjSh = SfxObjectShell::GetNext( *pObjSh, &aScType );
103cdf0e10cSrcweir }
104cdf0e10cSrcweir }
105cdf0e10cSrcweir else
106cdf0e10cSrcweir {
107cdf0e10cSrcweir // Current nur, wenn keine manuell eingestellt ist
108cdf0e10cSrcweir // (damit erkannt wird, wenn das Dokument nicht mehr existiert)
109cdf0e10cSrcweir
110cdf0e10cSrcweir SfxViewShell* pViewSh = SfxViewShell::Current();
111cdf0e10cSrcweir if ( pViewSh )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir SfxObjectShell* pObjSh = pViewSh->GetViewFrame()->GetObjectShell();
114cdf0e10cSrcweir pSh = PTR_CAST( ScDocShell, pObjSh );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir return pSh;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir //
122cdf0e10cSrcweir // ScContentTree
123cdf0e10cSrcweir //
124cdf0e10cSrcweir
ScContentTree(Window * pParent,const ResId & rResId)125cdf0e10cSrcweir ScContentTree::ScContentTree( Window* pParent, const ResId& rResId ) :
126cdf0e10cSrcweir SvTreeListBox ( pParent, rResId ),
127cdf0e10cSrcweir aEntryImages ( ScResId( RID_IMAGELIST_NAVCONT ) ),
128cdf0e10cSrcweir aHCEntryImages ( ScResId( RID_IMAGELIST_H_NAVCONT ) ),
129cdf0e10cSrcweir nRootType ( SC_CONTENT_ROOT ),
130cdf0e10cSrcweir bHiddenDoc ( sal_False ),
131*0deba7fbSSteve Yin pHiddenDocument ( NULL ),
132*0deba7fbSSteve Yin bisInNavigatoeDlg ( sal_False )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir sal_uInt16 i;
135cdf0e10cSrcweir for (i=0; i<SC_CONTENT_COUNT; i++)
136cdf0e10cSrcweir pPosList[pTypeList[i]] = i; // invers zum suchen
137cdf0e10cSrcweir
138cdf0e10cSrcweir pParentWindow = (ScNavigatorDlg*)pParent;
139cdf0e10cSrcweir
140cdf0e10cSrcweir pRootNodes[0] = NULL;
141cdf0e10cSrcweir for (i=1; i<SC_CONTENT_COUNT; i++)
142cdf0e10cSrcweir InitRoot(i);
143cdf0e10cSrcweir
144cdf0e10cSrcweir SetNodeDefaultImages();
145cdf0e10cSrcweir
146cdf0e10cSrcweir SetDoubleClickHdl( LINK( this, ScContentTree, ContentDoubleClickHdl ) );
147cdf0e10cSrcweir
148*0deba7fbSSteve Yin pTmpEntry= NULL;
149*0deba7fbSSteve Yin m_bFirstPaint=true;
150*0deba7fbSSteve Yin
151cdf0e10cSrcweir SetStyle( GetStyle() | WB_QUICK_SEARCH );
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
~ScContentTree()154cdf0e10cSrcweir ScContentTree::~ScContentTree()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir }
157*0deba7fbSSteve Yin // helper function for GetEntryAltText and GetEntryLongDescription
getAltLongDescText(SvLBoxEntry * pEntry,sal_Bool isAltText) const158*0deba7fbSSteve Yin String ScContentTree::getAltLongDescText( SvLBoxEntry* pEntry , sal_Bool isAltText) const
159*0deba7fbSSteve Yin {
160*0deba7fbSSteve Yin SdrObject* pFound = NULL;
161*0deba7fbSSteve Yin
162*0deba7fbSSteve Yin sal_uInt16 nType;
163*0deba7fbSSteve Yin sal_uLong nChild;
164*0deba7fbSSteve Yin GetEntryIndexes( nType, nChild, pEntry );
165*0deba7fbSSteve Yin switch( nType )
166*0deba7fbSSteve Yin {
167*0deba7fbSSteve Yin case SC_CONTENT_OLEOBJECT:
168*0deba7fbSSteve Yin case SC_CONTENT_GRAPHIC:
169*0deba7fbSSteve Yin case SC_CONTENT_DRAWING:
170*0deba7fbSSteve Yin {
171*0deba7fbSSteve Yin ScDocument* pDoc = ( const_cast< ScContentTree* >(this) )->GetSourceDocument();
172*0deba7fbSSteve Yin SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
173*0deba7fbSSteve Yin ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
174*0deba7fbSSteve Yin SfxObjectShell* pShell = pDoc->GetDocumentShell();
175*0deba7fbSSteve Yin if (pDrawLayer && pShell)
176*0deba7fbSSteve Yin {
177*0deba7fbSSteve Yin sal_uInt16 nTabCount = pDoc->GetTableCount();
178*0deba7fbSSteve Yin for (sal_uInt16 nTab=0; nTab<nTabCount; nTab++)
179*0deba7fbSSteve Yin {
180*0deba7fbSSteve Yin SdrPage* pPage = pDrawLayer->GetPage(nTab);
181*0deba7fbSSteve Yin DBG_ASSERT(pPage,"Page ?");
182*0deba7fbSSteve Yin if (pPage)
183*0deba7fbSSteve Yin {
184*0deba7fbSSteve Yin SdrObjListIter aIter( *pPage, eIter );
185*0deba7fbSSteve Yin SdrObject* pObject = aIter.Next();
186*0deba7fbSSteve Yin while (pObject)
187*0deba7fbSSteve Yin {
188*0deba7fbSSteve Yin if( ScDrawLayer::GetVisibleName( pObject ) == GetEntryText( pEntry ) )
189*0deba7fbSSteve Yin {
190*0deba7fbSSteve Yin pFound = pObject;
191*0deba7fbSSteve Yin break;
192*0deba7fbSSteve Yin }
193*0deba7fbSSteve Yin pObject = aIter.Next();
194*0deba7fbSSteve Yin }
195*0deba7fbSSteve Yin }
196*0deba7fbSSteve Yin }
197*0deba7fbSSteve Yin }
198*0deba7fbSSteve Yin if( pFound )
199*0deba7fbSSteve Yin {
200*0deba7fbSSteve Yin if( isAltText )
201*0deba7fbSSteve Yin return pFound->GetTitle();
202*0deba7fbSSteve Yin else
203*0deba7fbSSteve Yin return pFound->GetDescription();
204*0deba7fbSSteve Yin }
205*0deba7fbSSteve Yin }
206*0deba7fbSSteve Yin break;
207*0deba7fbSSteve Yin }
208*0deba7fbSSteve Yin return String();
209*0deba7fbSSteve Yin }
GetEntryAltText(SvLBoxEntry * pEntry) const210*0deba7fbSSteve Yin String ScContentTree::GetEntryAltText( SvLBoxEntry* pEntry ) const
211*0deba7fbSSteve Yin {
212*0deba7fbSSteve Yin return getAltLongDescText( pEntry, sal_True );
213*0deba7fbSSteve Yin }
GetEntryLongDescription(SvLBoxEntry * pEntry) const214*0deba7fbSSteve Yin String ScContentTree::GetEntryLongDescription( SvLBoxEntry* pEntry ) const
215*0deba7fbSSteve Yin {
216*0deba7fbSSteve Yin return getAltLongDescText( pEntry, sal_False);
217*0deba7fbSSteve Yin }
218cdf0e10cSrcweir
InitRoot(sal_uInt16 nType)219cdf0e10cSrcweir void ScContentTree::InitRoot( sal_uInt16 nType )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir if ( !nType )
222cdf0e10cSrcweir return;
223cdf0e10cSrcweir
224cdf0e10cSrcweir if ( nRootType && nRootType != nType ) // ausgeblendet ?
225cdf0e10cSrcweir {
226cdf0e10cSrcweir pRootNodes[nType] = NULL;
227cdf0e10cSrcweir return;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir const Image& rImage = aEntryImages.GetImage( nType );
231cdf0e10cSrcweir String aName( ScResId( SCSTR_CONTENT_ROOT + nType ) );
232cdf0e10cSrcweir // wieder an die richtige Position:
233cdf0e10cSrcweir sal_uInt16 nPos = nRootType ? 0 : pPosList[nType]-1;
234cdf0e10cSrcweir SvLBoxEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, sal_False, nPos );
235cdf0e10cSrcweir
236cdf0e10cSrcweir const Image& rHCImage = aHCEntryImages.GetImage( nType );
237cdf0e10cSrcweir SetExpandedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
238cdf0e10cSrcweir SetCollapsedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
239cdf0e10cSrcweir
240cdf0e10cSrcweir pRootNodes[nType] = pNew;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
ClearAll()243cdf0e10cSrcweir void ScContentTree::ClearAll()
244cdf0e10cSrcweir {
245*0deba7fbSSteve Yin //There are one method in Control::SetUpdateMode(), and one override method SvTreeListBox::SetUpdateMode(). Here although
246*0deba7fbSSteve Yin //SvTreeListBox::SetUpdateMode() is called in refresh method, it only call SvTreeListBox::SetUpdateMode(), not Control::SetUpdateMode().
247*0deba7fbSSteve Yin //In SvTreeList::Clear(), Broadcast( LISTACTION_CLEARED ) will be called and finally, it will be trapped into the event yield() loop. And
248*0deba7fbSSteve Yin //the InitRoot() method won't be called. Then if a user click or press key to update the navigator tree, crash happens.
249*0deba7fbSSteve Yin //So the solution is to disable the UpdateMode of Control, then call Clear(), then recover the update mode
250*0deba7fbSSteve Yin sal_Bool bOldUpdate = Control::IsUpdateMode();
251*0deba7fbSSteve Yin Control::SetUpdateMode(sal_False);
252cdf0e10cSrcweir Clear();
253*0deba7fbSSteve Yin Control::SetUpdateMode(bOldUpdate);
254cdf0e10cSrcweir for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++)
255cdf0e10cSrcweir InitRoot(i);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
ClearType(sal_uInt16 nType)258cdf0e10cSrcweir void ScContentTree::ClearType(sal_uInt16 nType)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir if (!nType)
261cdf0e10cSrcweir ClearAll();
262cdf0e10cSrcweir else
263cdf0e10cSrcweir {
264cdf0e10cSrcweir SvLBoxEntry* pParent = pRootNodes[nType];
265cdf0e10cSrcweir if ( !pParent || GetChildCount(pParent) ) // nicht, wenn ohne Children schon da
266cdf0e10cSrcweir {
267cdf0e10cSrcweir if (pParent)
268cdf0e10cSrcweir GetModel()->Remove( pParent ); // mit allen Children
269cdf0e10cSrcweir InitRoot( nType ); // ggf. neu eintragen
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
InsertContent(sal_uInt16 nType,const String & rValue)274cdf0e10cSrcweir void ScContentTree::InsertContent( sal_uInt16 nType, const String& rValue )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir if (nType >= SC_CONTENT_COUNT)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir DBG_ERROR("ScContentTree::InsertContent mit falschem Typ");
279cdf0e10cSrcweir return;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
282cdf0e10cSrcweir SvLBoxEntry* pParent = pRootNodes[nType];
283cdf0e10cSrcweir if (pParent)
284cdf0e10cSrcweir InsertEntry( rValue, pParent );
285cdf0e10cSrcweir else
286cdf0e10cSrcweir {
287cdf0e10cSrcweir DBG_ERROR("InsertContent ohne Parent");
288cdf0e10cSrcweir }
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
GetEntryIndexes(sal_uInt16 & rnRootIndex,sal_uLong & rnChildIndex,SvLBoxEntry * pEntry) const291cdf0e10cSrcweir void ScContentTree::GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChildIndex, SvLBoxEntry* pEntry ) const
292cdf0e10cSrcweir {
293cdf0e10cSrcweir rnRootIndex = SC_CONTENT_ROOT;
294cdf0e10cSrcweir rnChildIndex = SC_CONTENT_NOCHILD;
295cdf0e10cSrcweir
296cdf0e10cSrcweir if( !pEntry )
297cdf0e10cSrcweir return;
298cdf0e10cSrcweir
299cdf0e10cSrcweir SvLBoxEntry* pParent = GetParent( pEntry );
300cdf0e10cSrcweir bool bFound = false;
301cdf0e10cSrcweir for( sal_uInt16 nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir if( pEntry == pRootNodes[ nRoot ] )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir rnRootIndex = nRoot;
306cdf0e10cSrcweir rnChildIndex = ~0UL;
307cdf0e10cSrcweir bFound = true;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir else if( pParent && (pParent == pRootNodes[ nRoot ]) )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir rnRootIndex = nRoot;
312cdf0e10cSrcweir
313cdf0e10cSrcweir // search the entry in all child entries of the parent
314cdf0e10cSrcweir sal_uLong nEntry = 0;
315cdf0e10cSrcweir SvLBoxEntry* pIterEntry = FirstChild( pParent );
316cdf0e10cSrcweir while( !bFound && pIterEntry )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir if ( pEntry == pIterEntry )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir rnChildIndex = nEntry;
321cdf0e10cSrcweir bFound = true; // exit the while loop
322cdf0e10cSrcweir }
323cdf0e10cSrcweir pIterEntry = NextSibling( pIterEntry );
324cdf0e10cSrcweir ++nEntry;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir bFound = true; // exit the for loop
328cdf0e10cSrcweir }
329cdf0e10cSrcweir }
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
GetChildIndex(SvLBoxEntry * pEntry) const332cdf0e10cSrcweir sal_uLong ScContentTree::GetChildIndex( SvLBoxEntry* pEntry ) const
333cdf0e10cSrcweir {
334cdf0e10cSrcweir sal_uInt16 nRoot;
335cdf0e10cSrcweir sal_uLong nChild;
336cdf0e10cSrcweir GetEntryIndexes( nRoot, nChild, pEntry );
337cdf0e10cSrcweir return nChild;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
lcl_GetDBAreaRange(ScDocument * pDoc,const String & rDBName)340cdf0e10cSrcweir String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir String aRet;
343cdf0e10cSrcweir if (pDoc)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir ScDBCollection* pDbNames = pDoc->GetDBCollection();
346cdf0e10cSrcweir sal_uInt16 nCount = pDbNames->GetCount();
347cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i++ )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir ScDBData* pData = (*pDbNames)[i];
350cdf0e10cSrcweir if ( pData->GetName() == rDBName )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir ScRange aRange;
353cdf0e10cSrcweir pData->GetArea(aRange);
354cdf0e10cSrcweir aRange.Format( aRet, SCR_ABS_3D, pDoc );
355cdf0e10cSrcweir break;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir }
358cdf0e10cSrcweir }
359cdf0e10cSrcweir return aRet;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
IMPL_LINK(ScContentTree,ContentDoubleClickHdl,ScContentTree *,EMPTYARG)362cdf0e10cSrcweir IMPL_LINK( ScContentTree, ContentDoubleClickHdl, ScContentTree *, EMPTYARG )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir sal_uInt16 nType;
365cdf0e10cSrcweir sal_uLong nChild;
366cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry();
367cdf0e10cSrcweir GetEntryIndexes( nType, nChild, pEntry );
368cdf0e10cSrcweir
369cdf0e10cSrcweir if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir if ( bHiddenDoc )
372cdf0e10cSrcweir return 0; //! spaeter...
373cdf0e10cSrcweir
374cdf0e10cSrcweir String aText( GetEntryText( pEntry ) );
375cdf0e10cSrcweir
376cdf0e10cSrcweir if ( aManualDoc.Len() )
377cdf0e10cSrcweir pParentWindow->SetCurrentDoc( aManualDoc );
378cdf0e10cSrcweir
379cdf0e10cSrcweir switch( nType )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir case SC_CONTENT_TABLE:
382cdf0e10cSrcweir pParentWindow->SetCurrentTableStr( aText );
383cdf0e10cSrcweir break;
384cdf0e10cSrcweir
385cdf0e10cSrcweir case SC_CONTENT_RANGENAME:
386cdf0e10cSrcweir pParentWindow->SetCurrentCellStr( aText );
387cdf0e10cSrcweir break;
388cdf0e10cSrcweir
389cdf0e10cSrcweir case SC_CONTENT_DBAREA:
390cdf0e10cSrcweir {
391cdf0e10cSrcweir // #47905# Wenn gleiche Bereichs- und DB-Namen existieren, wird
392cdf0e10cSrcweir // bei SID_CURRENTCELL der Bereichsname genommen.
393cdf0e10cSrcweir // DB-Bereiche darum direkt ueber die Adresse anspringen.
394cdf0e10cSrcweir
395cdf0e10cSrcweir String aRangeStr = lcl_GetDBAreaRange( GetSourceDocument(), aText );
396cdf0e10cSrcweir if (aRangeStr.Len())
397cdf0e10cSrcweir pParentWindow->SetCurrentCellStr( aRangeStr );
398cdf0e10cSrcweir }
399cdf0e10cSrcweir break;
400cdf0e10cSrcweir
401cdf0e10cSrcweir case SC_CONTENT_OLEOBJECT:
402cdf0e10cSrcweir case SC_CONTENT_GRAPHIC:
403cdf0e10cSrcweir case SC_CONTENT_DRAWING:
404cdf0e10cSrcweir pParentWindow->SetCurrentObject( aText );
405cdf0e10cSrcweir break;
406cdf0e10cSrcweir
407cdf0e10cSrcweir case SC_CONTENT_NOTE:
408cdf0e10cSrcweir {
409cdf0e10cSrcweir ScAddress aPos = GetNotePos( nChild );
410cdf0e10cSrcweir pParentWindow->SetCurrentTable( aPos.Tab() );
411cdf0e10cSrcweir pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
412cdf0e10cSrcweir }
413cdf0e10cSrcweir break;
414cdf0e10cSrcweir
415cdf0e10cSrcweir case SC_CONTENT_AREALINK:
416cdf0e10cSrcweir {
417cdf0e10cSrcweir const ScAreaLink* pLink = GetLink( nChild );
418cdf0e10cSrcweir if( pLink )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir ScRange aRange = pLink->GetDestArea();
421cdf0e10cSrcweir String aRangeStr;
422cdf0e10cSrcweir ScDocument* pSrcDoc = GetSourceDocument();
423cdf0e10cSrcweir aRange.Format( aRangeStr, SCR_ABS_3D, pSrcDoc, pSrcDoc->GetAddressConvention() );
424cdf0e10cSrcweir pParentWindow->SetCurrentCellStr( aRangeStr );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir }
427cdf0e10cSrcweir break;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir
430cdf0e10cSrcweir ScNavigatorDlg::ReleaseFocus(); // set focus into document
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir return 0;
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)436cdf0e10cSrcweir void ScContentTree::MouseButtonDown( const MouseEvent& rMEvt )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir SvTreeListBox::MouseButtonDown( rMEvt );
439cdf0e10cSrcweir StoreSettings();
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)442cdf0e10cSrcweir void ScContentTree::KeyInput( const KeyEvent& rKEvt )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir sal_Bool bUsed = sal_False;
445cdf0e10cSrcweir
446cdf0e10cSrcweir const KeyCode aCode = rKEvt.GetKeyCode();
447cdf0e10cSrcweir if (aCode.GetCode() == KEY_RETURN)
448cdf0e10cSrcweir {
449cdf0e10cSrcweir switch (aCode.GetModifier())
450cdf0e10cSrcweir {
451cdf0e10cSrcweir case KEY_MOD1:
452cdf0e10cSrcweir ToggleRoot(); // toggle root mode (as in Writer)
453cdf0e10cSrcweir bUsed = sal_True;
454cdf0e10cSrcweir break;
455cdf0e10cSrcweir case 0:
456cdf0e10cSrcweir {
457cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry();
458cdf0e10cSrcweir if( pEntry )
459cdf0e10cSrcweir {
460cdf0e10cSrcweir sal_uInt16 nType;
461cdf0e10cSrcweir sal_uLong nChild;
462cdf0e10cSrcweir GetEntryIndexes( nType, nChild, pEntry );
463cdf0e10cSrcweir
464cdf0e10cSrcweir if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir String aText( GetEntryText( pEntry ) );
467cdf0e10cSrcweir if ( IsExpanded( pEntry ) )
468cdf0e10cSrcweir Collapse( pEntry );
469cdf0e10cSrcweir else
470cdf0e10cSrcweir Expand( pEntry );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir else
473cdf0e10cSrcweir ContentDoubleClickHdl(0); // select content as if double clicked
474cdf0e10cSrcweir }
475cdf0e10cSrcweir
476cdf0e10cSrcweir bUsed = sal_True;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir break;
479cdf0e10cSrcweir }
480cdf0e10cSrcweir }
481*0deba7fbSSteve Yin //Solution: Make KEY_SPACE has same function as DoubleClick
482*0deba7fbSSteve Yin if ( bisInNavigatoeDlg )
483*0deba7fbSSteve Yin {
484*0deba7fbSSteve Yin if(aCode.GetCode() == KEY_SPACE )
485*0deba7fbSSteve Yin {
486*0deba7fbSSteve Yin bUsed = sal_True;
487*0deba7fbSSteve Yin sal_uInt16 nType;
488*0deba7fbSSteve Yin sal_uLong nChild;
489*0deba7fbSSteve Yin SvLBoxEntry* pEntry = GetCurEntry();
490*0deba7fbSSteve Yin GetEntryIndexes( nType, nChild, pEntry );
491*0deba7fbSSteve Yin if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
492*0deba7fbSSteve Yin {
493*0deba7fbSSteve Yin if ( bHiddenDoc )
494*0deba7fbSSteve Yin return ; //! spaeter...
495*0deba7fbSSteve Yin String aText( GetEntryText( pEntry ) );
496*0deba7fbSSteve Yin sKeyString = aText;
497*0deba7fbSSteve Yin if ( aManualDoc.Len() )
498*0deba7fbSSteve Yin pParentWindow->SetCurrentDoc( aManualDoc );
499*0deba7fbSSteve Yin switch( nType )
500*0deba7fbSSteve Yin {
501*0deba7fbSSteve Yin case SC_CONTENT_OLEOBJECT:
502*0deba7fbSSteve Yin case SC_CONTENT_GRAPHIC:
503*0deba7fbSSteve Yin case SC_CONTENT_DRAWING:
504*0deba7fbSSteve Yin {
505*0deba7fbSSteve Yin Window* pWindow=(Window*)GetParent(pEntry);
506*0deba7fbSSteve Yin ScNavigatorDlg* pScNavigatorDlg = (ScNavigatorDlg*)pWindow;
507*0deba7fbSSteve Yin ScTabViewShell* pScTabViewShell = NULL;
508*0deba7fbSSteve Yin ScDrawView* pScDrawView = NULL;
509*0deba7fbSSteve Yin if (pScNavigatorDlg!=NULL)
510*0deba7fbSSteve Yin pScTabViewShell=pScNavigatorDlg->GetTabViewShell();
511*0deba7fbSSteve Yin if(pScTabViewShell !=NULL)
512*0deba7fbSSteve Yin pScDrawView =pScTabViewShell->GetViewData()->GetScDrawView();
513*0deba7fbSSteve Yin if(pScDrawView!=NULL)
514*0deba7fbSSteve Yin {
515*0deba7fbSSteve Yin pScDrawView->SelectCurrentViewObject(aText );
516*0deba7fbSSteve Yin sal_Bool bHasMakredObject = sal_False;
517*0deba7fbSSteve Yin SvLBoxEntry* pParent = pRootNodes[nType];
518*0deba7fbSSteve Yin SvLBoxEntry* pBeginEntry = NULL;
519*0deba7fbSSteve Yin if( pParent )
520*0deba7fbSSteve Yin pBeginEntry = FirstChild(pParent);
521*0deba7fbSSteve Yin while( pBeginEntry )
522*0deba7fbSSteve Yin {
523*0deba7fbSSteve Yin String aTempText( GetEntryText( pBeginEntry ) );
524*0deba7fbSSteve Yin if( pScDrawView->GetObjectIsMarked( pScDrawView->GetObjectByName( aTempText ) ) )
525*0deba7fbSSteve Yin {
526*0deba7fbSSteve Yin bHasMakredObject = sal_True;
527*0deba7fbSSteve Yin break;
528*0deba7fbSSteve Yin }
529*0deba7fbSSteve Yin pBeginEntry = Next( pBeginEntry );
530*0deba7fbSSteve Yin }
531*0deba7fbSSteve Yin if( !bHasMakredObject && pScTabViewShell)
532*0deba7fbSSteve Yin pScTabViewShell->SetDrawShell(sal_False);
533*0deba7fbSSteve Yin ObjectFresh( nType,pEntry );
534*0deba7fbSSteve Yin }
535*0deba7fbSSteve Yin }
536*0deba7fbSSteve Yin break;
537*0deba7fbSSteve Yin }
538*0deba7fbSSteve Yin }
539*0deba7fbSSteve Yin }
540*0deba7fbSSteve Yin }
541*0deba7fbSSteve Yin //StoreSettings();
542cdf0e10cSrcweir
543cdf0e10cSrcweir if( !bUsed )
544*0deba7fbSSteve Yin {
545*0deba7fbSSteve Yin if(aCode.GetCode() == KEY_F5 )
546*0deba7fbSSteve Yin {
547*0deba7fbSSteve Yin StoreSettings();
548cdf0e10cSrcweir SvTreeListBox::KeyInput(rKEvt);
549*0deba7fbSSteve Yin }
550*0deba7fbSSteve Yin else
551*0deba7fbSSteve Yin {
552*0deba7fbSSteve Yin SvTreeListBox::KeyInput(rKEvt);
553*0deba7fbSSteve Yin StoreSettings();
554*0deba7fbSSteve Yin }
555*0deba7fbSSteve Yin }
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
558cdf0e10cSrcweir //sal_Bool __EXPORT ScContentTree::Drop( const DropEvent& rEvt )
559cdf0e10cSrcweir //{
560cdf0e10cSrcweir // return pParentWindow->Drop(rEvt); // Drop auf Navigator
561cdf0e10cSrcweir //}
562cdf0e10cSrcweir
563cdf0e10cSrcweir //sal_Bool __EXPORT ScContentTree::QueryDrop( DropEvent& rEvt )
564cdf0e10cSrcweir //{
565cdf0e10cSrcweir // return pParentWindow->QueryDrop(rEvt); // Drop auf Navigator
566cdf0e10cSrcweir //}
567cdf0e10cSrcweir
AcceptDrop(const AcceptDropEvent &)568cdf0e10cSrcweir sal_Int8 ScContentTree::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir return DND_ACTION_NONE;
571cdf0e10cSrcweir }
572cdf0e10cSrcweir
ExecuteDrop(const ExecuteDropEvent &)573cdf0e10cSrcweir sal_Int8 ScContentTree::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
574cdf0e10cSrcweir {
575cdf0e10cSrcweir return DND_ACTION_NONE;
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
StartDrag(sal_Int8,const Point &)578cdf0e10cSrcweir void ScContentTree::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir DoDrag();
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
DragFinished(sal_Int8)583cdf0e10cSrcweir void ScContentTree::DragFinished( sal_Int8 /* nAction */ )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir }
586cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)587cdf0e10cSrcweir void __EXPORT ScContentTree::Command( const CommandEvent& rCEvt )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir sal_Bool bDone = sal_False;
590cdf0e10cSrcweir
591cdf0e10cSrcweir switch ( rCEvt.GetCommand() )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir case COMMAND_STARTDRAG:
594cdf0e10cSrcweir // Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
595cdf0e10cSrcweir // (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
596cdf0e10cSrcweir // den StarView MouseMove-Handler, der Command() aufruft, umbringen.
597cdf0e10cSrcweir // Deshalb Drag&Drop asynchron:
598cdf0e10cSrcweir
599cdf0e10cSrcweir // DoDrag();
600cdf0e10cSrcweir
601cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK( this, ScContentTree, ExecDragHdl ) );
602cdf0e10cSrcweir
603cdf0e10cSrcweir bDone = sal_True;
604cdf0e10cSrcweir break;
605cdf0e10cSrcweir
606cdf0e10cSrcweir case COMMAND_CONTEXTMENU:
607cdf0e10cSrcweir {
608cdf0e10cSrcweir // Drag-Drop Modus
609cdf0e10cSrcweir
610cdf0e10cSrcweir PopupMenu aPop;
611cdf0e10cSrcweir ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
612cdf0e10cSrcweir aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
613cdf0e10cSrcweir aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
614cdf0e10cSrcweir aPop.SetPopupMenu( 1, &aDropMenu );
615cdf0e10cSrcweir
616cdf0e10cSrcweir // angezeigtes Dokument
617cdf0e10cSrcweir
618cdf0e10cSrcweir ScPopupMenu aDocMenu;
619cdf0e10cSrcweir aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
620cdf0e10cSrcweir sal_uInt16 i=0;
621cdf0e10cSrcweir sal_uInt16 nPos=0;
622cdf0e10cSrcweir // geladene Dokumente
623cdf0e10cSrcweir ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
624cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::GetFirst();
625cdf0e10cSrcweir while ( pSh )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir if ( pSh->ISA(ScDocShell) )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir String aName = pSh->GetTitle();
630cdf0e10cSrcweir String aEntry = aName;
631cdf0e10cSrcweir if ( pSh == pCurrentSh )
632cdf0e10cSrcweir aEntry += pParentWindow->aStrActive;
633cdf0e10cSrcweir else
634cdf0e10cSrcweir aEntry += pParentWindow->aStrNotActive;
635cdf0e10cSrcweir aDocMenu.InsertItem( ++i, aEntry );
636cdf0e10cSrcweir if ( !bHiddenDoc && aName == aManualDoc )
637cdf0e10cSrcweir nPos = i;
638cdf0e10cSrcweir }
639cdf0e10cSrcweir pSh = SfxObjectShell::GetNext( *pSh );
640cdf0e10cSrcweir }
641cdf0e10cSrcweir // "aktives Fenster"
642cdf0e10cSrcweir aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
643cdf0e10cSrcweir if (!bHiddenDoc && !aManualDoc.Len())
644cdf0e10cSrcweir nPos = i;
645cdf0e10cSrcweir // verstecktes Dokument
646cdf0e10cSrcweir if ( aHiddenTitle.Len() )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir String aEntry = aHiddenTitle;
649cdf0e10cSrcweir aEntry += pParentWindow->aStrHidden;
650cdf0e10cSrcweir aDocMenu.InsertItem( ++i, aEntry );
651cdf0e10cSrcweir if (bHiddenDoc)
652cdf0e10cSrcweir nPos = i;
653cdf0e10cSrcweir }
654cdf0e10cSrcweir aDocMenu.CheckItem( nPos );
655cdf0e10cSrcweir aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
656cdf0e10cSrcweir aPop.SetPopupMenu( 2, &aDocMenu );
657cdf0e10cSrcweir
658cdf0e10cSrcweir // ausfuehren
659cdf0e10cSrcweir
660cdf0e10cSrcweir aPop.Execute( this, rCEvt.GetMousePosPixel() );
661cdf0e10cSrcweir
662cdf0e10cSrcweir if ( aDropMenu.WasHit() ) // Drag-Drop Modus
663cdf0e10cSrcweir {
664cdf0e10cSrcweir sal_uInt16 nId = aDropMenu.GetSelected();
665cdf0e10cSrcweir if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
666cdf0e10cSrcweir pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
667cdf0e10cSrcweir }
668cdf0e10cSrcweir else if ( aDocMenu.WasHit() ) // angezeigtes Dokument
669cdf0e10cSrcweir {
670cdf0e10cSrcweir sal_uInt16 nId = aDocMenu.GetSelected();
671cdf0e10cSrcweir String aName = aDocMenu.GetItemText(nId);
672cdf0e10cSrcweir SelectDoc( aName );
673cdf0e10cSrcweir }
674cdf0e10cSrcweir }
675cdf0e10cSrcweir break;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
678cdf0e10cSrcweir if (!bDone)
679cdf0e10cSrcweir SvTreeListBox::Command(rCEvt);
680cdf0e10cSrcweir }
681cdf0e10cSrcweir
RequestHelp(const HelpEvent & rHEvt)682cdf0e10cSrcweir void __EXPORT ScContentTree::RequestHelp( const HelpEvent& rHEvt )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir sal_Bool bDone = sal_False;
685cdf0e10cSrcweir if( rHEvt.GetMode() & HELPMODE_QUICK )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
688cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( aPos );
689cdf0e10cSrcweir if ( pEntry )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir sal_Bool bRet = sal_False;
692cdf0e10cSrcweir String aHelpText;
693cdf0e10cSrcweir SvLBoxEntry* pParent = GetParent(pEntry);
694cdf0e10cSrcweir if ( !pParent ) // Top-Level ?
695cdf0e10cSrcweir {
696cdf0e10cSrcweir aHelpText = String::CreateFromInt32( GetChildCount(pEntry) );
697cdf0e10cSrcweir aHelpText += ' ';
698cdf0e10cSrcweir aHelpText += GetEntryText(pEntry);
699cdf0e10cSrcweir bRet = sal_True;
700cdf0e10cSrcweir }
701cdf0e10cSrcweir else if ( pParent == pRootNodes[SC_CONTENT_NOTE] )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir aHelpText = GetEntryText(pEntry); // Notizen als Help-Text
704cdf0e10cSrcweir bRet = sal_True;
705cdf0e10cSrcweir }
706cdf0e10cSrcweir else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir sal_uLong nIndex = GetChildIndex(pEntry);
709cdf0e10cSrcweir if( nIndex != SC_CONTENT_NOCHILD )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir const ScAreaLink* pLink = GetLink(nIndex);
712cdf0e10cSrcweir if (pLink)
713cdf0e10cSrcweir {
714cdf0e10cSrcweir aHelpText = pLink->GetFile(); // Source-Datei als Help-Text
715cdf0e10cSrcweir bRet = sal_True;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir }
718cdf0e10cSrcweir }
719cdf0e10cSrcweir
720cdf0e10cSrcweir if (bRet)
721cdf0e10cSrcweir {
722cdf0e10cSrcweir SvLBoxTab* pTab;
723cdf0e10cSrcweir SvLBoxString* pItem = (SvLBoxString*)(GetItem( pEntry, aPos.X(), &pTab ));
724cdf0e10cSrcweir if( pItem )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir aPos = GetEntryPosition( pEntry );
727cdf0e10cSrcweir aPos.X() = GetTabPos( pEntry, pTab );
728cdf0e10cSrcweir aPos = OutputToScreenPixel(aPos);
729cdf0e10cSrcweir Size aSize( pItem->GetSize( this, pEntry ) );
730cdf0e10cSrcweir
731cdf0e10cSrcweir Rectangle aItemRect( aPos, aSize );
732cdf0e10cSrcweir Help::ShowQuickHelp( this, aItemRect, aHelpText );
733cdf0e10cSrcweir bDone = sal_True;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir }
736cdf0e10cSrcweir }
737cdf0e10cSrcweir }
738cdf0e10cSrcweir if (!bDone)
739cdf0e10cSrcweir Window::RequestHelp( rHEvt );
740cdf0e10cSrcweir }
741cdf0e10cSrcweir
GetSourceDocument()742cdf0e10cSrcweir ScDocument* ScContentTree::GetSourceDocument()
743cdf0e10cSrcweir {
744cdf0e10cSrcweir if (bHiddenDoc)
745cdf0e10cSrcweir return pHiddenDocument;
746cdf0e10cSrcweir else
747cdf0e10cSrcweir {
748cdf0e10cSrcweir ScDocShell* pSh = GetManualOrCurrent();
749cdf0e10cSrcweir if (pSh)
750cdf0e10cSrcweir return pSh->GetDocument();
751cdf0e10cSrcweir
752cdf0e10cSrcweir }
753cdf0e10cSrcweir return NULL;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir
756*0deba7fbSSteve Yin //Solution: move along and draw "*" sign .
ObjectFresh(sal_uInt16 nType,SvLBoxEntry * pEntry)757*0deba7fbSSteve Yin void ScContentTree::ObjectFresh( sal_uInt16 nType,SvLBoxEntry* pEntry )
758*0deba7fbSSteve Yin {
759*0deba7fbSSteve Yin if ( bHiddenDoc && !pHiddenDocument )
760*0deba7fbSSteve Yin return; // anderes Dokument angezeigt
761*0deba7fbSSteve Yin if(nType ==SC_CONTENT_GRAPHIC||nType ==SC_CONTENT_OLEOBJECT||nType ==SC_CONTENT_DRAWING)
762*0deba7fbSSteve Yin {
763*0deba7fbSSteve Yin SetUpdateMode(sal_False);
764*0deba7fbSSteve Yin ClearType( nType );
765*0deba7fbSSteve Yin /*sal_uInt16 nId = OBJ_GRAF;
766*0deba7fbSSteve Yin switch( nType )
767*0deba7fbSSteve Yin {
768*0deba7fbSSteve Yin case SC_CONTENT_OLEOBJECT:
769*0deba7fbSSteve Yin nId = OBJ_OLE2;
770*0deba7fbSSteve Yin break;
771*0deba7fbSSteve Yin case SC_CONTENT_DRAWING:
772*0deba7fbSSteve Yin nId = OBJ_GRUP;
773*0deba7fbSSteve Yin break;
774*0deba7fbSSteve Yin }*/
775*0deba7fbSSteve Yin GetDrawNames( nType/*, nId*/ );
776*0deba7fbSSteve Yin if( !pEntry )
777*0deba7fbSSteve Yin ApplySettings();
778*0deba7fbSSteve Yin SetUpdateMode(sal_True);
779*0deba7fbSSteve Yin if( pEntry )
780*0deba7fbSSteve Yin {
781*0deba7fbSSteve Yin SvLBoxEntry* pParent = pRootNodes[nType];
782*0deba7fbSSteve Yin SvLBoxEntry* pBeginEntry = NULL;
783*0deba7fbSSteve Yin SvLBoxEntry* pOldEntry = NULL;
784*0deba7fbSSteve Yin if( pParent )
785*0deba7fbSSteve Yin pBeginEntry = FirstChild(pParent);
786*0deba7fbSSteve Yin while( pBeginEntry )
787*0deba7fbSSteve Yin {
788*0deba7fbSSteve Yin String aTempText( GetEntryText( pBeginEntry ) );
789*0deba7fbSSteve Yin if( aTempText == sKeyString )
790*0deba7fbSSteve Yin {
791*0deba7fbSSteve Yin pOldEntry = pBeginEntry;
792*0deba7fbSSteve Yin break;
793*0deba7fbSSteve Yin }
794*0deba7fbSSteve Yin pBeginEntry = Next( pBeginEntry );
795*0deba7fbSSteve Yin }
796*0deba7fbSSteve Yin if( pOldEntry )
797*0deba7fbSSteve Yin {
798*0deba7fbSSteve Yin Expand(pParent);
799*0deba7fbSSteve Yin Select( pOldEntry,sal_True);
800*0deba7fbSSteve Yin }
801*0deba7fbSSteve Yin }
802*0deba7fbSSteve Yin }
803*0deba7fbSSteve Yin }
Refresh(sal_uInt16 nType)804cdf0e10cSrcweir void ScContentTree::Refresh( sal_uInt16 nType )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir if ( bHiddenDoc && !pHiddenDocument )
807cdf0e10cSrcweir return; // anderes Dokument angezeigt
808cdf0e10cSrcweir
809cdf0e10cSrcweir // wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
810cdf0e10cSrcweir
811cdf0e10cSrcweir if ( nType == SC_CONTENT_NOTE )
812cdf0e10cSrcweir if (!NoteStringsChanged())
813cdf0e10cSrcweir return;
814cdf0e10cSrcweir if ( nType == SC_CONTENT_GRAPHIC )
815cdf0e10cSrcweir if (!DrawNamesChanged(SC_CONTENT_GRAPHIC))
816cdf0e10cSrcweir return;
817cdf0e10cSrcweir if ( nType == SC_CONTENT_OLEOBJECT )
818cdf0e10cSrcweir if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT))
819cdf0e10cSrcweir return;
820cdf0e10cSrcweir if ( nType == SC_CONTENT_DRAWING )
821cdf0e10cSrcweir if (!DrawNamesChanged(SC_CONTENT_DRAWING))
822cdf0e10cSrcweir return;
823cdf0e10cSrcweir
824cdf0e10cSrcweir SetUpdateMode(sal_False);
825cdf0e10cSrcweir
826cdf0e10cSrcweir ClearType( nType );
827cdf0e10cSrcweir
828cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_TABLE )
829cdf0e10cSrcweir GetTableNames();
830cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_RANGENAME )
831cdf0e10cSrcweir GetAreaNames();
832cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_DBAREA )
833cdf0e10cSrcweir GetDbNames();
834cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_GRAPHIC )
835cdf0e10cSrcweir GetGraphicNames();
836cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_OLEOBJECT )
837cdf0e10cSrcweir GetOleNames();
838cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_DRAWING )
839cdf0e10cSrcweir GetDrawingNames();
840cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_NOTE )
841cdf0e10cSrcweir GetNoteStrings();
842cdf0e10cSrcweir if ( !nType || nType == SC_CONTENT_AREALINK )
843cdf0e10cSrcweir GetLinkNames();
844cdf0e10cSrcweir
845cdf0e10cSrcweir ApplySettings();
846cdf0e10cSrcweir SetUpdateMode(sal_True);
847cdf0e10cSrcweir }
848cdf0e10cSrcweir
GetTableNames()849cdf0e10cSrcweir void ScContentTree::GetTableNames()
850cdf0e10cSrcweir {
851cdf0e10cSrcweir if ( nRootType && nRootType != SC_CONTENT_TABLE ) // ausgeblendet ?
852cdf0e10cSrcweir return;
853cdf0e10cSrcweir
854cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
855cdf0e10cSrcweir if (!pDoc)
856cdf0e10cSrcweir return;
857cdf0e10cSrcweir
858cdf0e10cSrcweir String aName;
859cdf0e10cSrcweir SCTAB nCount = pDoc->GetTableCount();
860cdf0e10cSrcweir for ( SCTAB i=0; i<nCount; i++ )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir pDoc->GetName( i, aName );
863cdf0e10cSrcweir InsertContent( SC_CONTENT_TABLE, aName );
864cdf0e10cSrcweir }
865cdf0e10cSrcweir }
866cdf0e10cSrcweir
GetAreaNames()867cdf0e10cSrcweir void ScContentTree::GetAreaNames()
868cdf0e10cSrcweir {
869cdf0e10cSrcweir if ( nRootType && nRootType != SC_CONTENT_RANGENAME ) // ausgeblendet ?
870cdf0e10cSrcweir return;
871cdf0e10cSrcweir
872cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
873cdf0e10cSrcweir if (!pDoc)
874cdf0e10cSrcweir return;
875cdf0e10cSrcweir
876cdf0e10cSrcweir ScRangeName* pRangeNames = pDoc->GetRangeName();
877cdf0e10cSrcweir sal_uInt16 nCount = pRangeNames->GetCount();
878cdf0e10cSrcweir if ( nCount > 0 )
879cdf0e10cSrcweir {
880cdf0e10cSrcweir sal_uInt16 nValidCount = 0;
881cdf0e10cSrcweir ScRange aDummy;
882cdf0e10cSrcweir sal_uInt16 i;
883cdf0e10cSrcweir for ( i=0; i<nCount; i++ )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir ScRangeData* pData = (*pRangeNames)[i];
886cdf0e10cSrcweir if (pData->IsValidReference(aDummy))
887cdf0e10cSrcweir nValidCount++;
888cdf0e10cSrcweir }
889cdf0e10cSrcweir if ( nValidCount )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
892cdf0e10cSrcweir sal_uInt16 j;
893cdf0e10cSrcweir for ( i=0, j=0; i<nCount; i++ )
894cdf0e10cSrcweir {
895cdf0e10cSrcweir ScRangeData* pData = (*pRangeNames)[i];
896cdf0e10cSrcweir if (pData->IsValidReference(aDummy))
897cdf0e10cSrcweir ppSortArray[j++] = pData;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir #ifndef ICC
900cdf0e10cSrcweir qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
901cdf0e10cSrcweir &ScRangeData_QsortNameCompare );
902cdf0e10cSrcweir #else
903cdf0e10cSrcweir qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
904cdf0e10cSrcweir ICCQsortNameCompare );
905cdf0e10cSrcweir #endif
906cdf0e10cSrcweir for ( j=0; j<nValidCount; j++ )
907cdf0e10cSrcweir InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
908cdf0e10cSrcweir delete [] ppSortArray;
909cdf0e10cSrcweir }
910cdf0e10cSrcweir }
911cdf0e10cSrcweir }
912cdf0e10cSrcweir
GetDbNames()913cdf0e10cSrcweir void ScContentTree::GetDbNames()
914cdf0e10cSrcweir {
91522407013SOliver-Rainer Wittmann if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ?
91622407013SOliver-Rainer Wittmann return;
917cdf0e10cSrcweir
91822407013SOliver-Rainer Wittmann ScDocument* pDoc = GetSourceDocument();
91922407013SOliver-Rainer Wittmann if (!pDoc)
92022407013SOliver-Rainer Wittmann return;
921cdf0e10cSrcweir
92222407013SOliver-Rainer Wittmann ScDBCollection* pDbNames = pDoc->GetDBCollection();
92322407013SOliver-Rainer Wittmann sal_uInt16 nCount = pDbNames->GetCount();
92422407013SOliver-Rainer Wittmann if ( nCount > 0 )
92522407013SOliver-Rainer Wittmann {
92622407013SOliver-Rainer Wittmann for ( sal_uInt16 i=0; i<nCount; i++ )
92722407013SOliver-Rainer Wittmann {
92822407013SOliver-Rainer Wittmann ScDBData* pData = (*pDbNames)[i];
92922407013SOliver-Rainer Wittmann String aStrName = pData->GetName();
93022407013SOliver-Rainer Wittmann if ( !pData->IsInternalUnnamed()
93122407013SOliver-Rainer Wittmann && !pData->IsInternalForAutoFilter() )
93222407013SOliver-Rainer Wittmann {
93322407013SOliver-Rainer Wittmann InsertContent( SC_CONTENT_DBAREA, aStrName );
93422407013SOliver-Rainer Wittmann }
93522407013SOliver-Rainer Wittmann }
93622407013SOliver-Rainer Wittmann }
937cdf0e10cSrcweir }
938cdf0e10cSrcweir
IsPartOfType(sal_uInt16 nContentType,sal_uInt16 nObjIdentifier)939cdf0e10cSrcweir bool ScContentTree::IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdentifier ) // static
940cdf0e10cSrcweir {
941cdf0e10cSrcweir bool bRet = false;
942cdf0e10cSrcweir switch ( nContentType )
943cdf0e10cSrcweir {
944cdf0e10cSrcweir case SC_CONTENT_GRAPHIC:
945cdf0e10cSrcweir bRet = ( nObjIdentifier == OBJ_GRAF );
946cdf0e10cSrcweir break;
947cdf0e10cSrcweir case SC_CONTENT_OLEOBJECT:
948cdf0e10cSrcweir bRet = ( nObjIdentifier == OBJ_OLE2 );
949cdf0e10cSrcweir break;
950cdf0e10cSrcweir case SC_CONTENT_DRAWING:
951cdf0e10cSrcweir bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 ); // everything else
952cdf0e10cSrcweir break;
953cdf0e10cSrcweir default:
954cdf0e10cSrcweir DBG_ERROR("unknown content type");
955cdf0e10cSrcweir }
956cdf0e10cSrcweir return bRet;
957cdf0e10cSrcweir }
958cdf0e10cSrcweir
GetDrawNames(sal_uInt16 nType)959cdf0e10cSrcweir void ScContentTree::GetDrawNames( sal_uInt16 nType )
960cdf0e10cSrcweir {
961cdf0e10cSrcweir if ( nRootType && nRootType != nType ) // ausgeblendet ?
962cdf0e10cSrcweir return;
963cdf0e10cSrcweir
964cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
965cdf0e10cSrcweir if (!pDoc)
966cdf0e10cSrcweir return;
967cdf0e10cSrcweir
968cdf0e10cSrcweir // iterate in flat mode for groups
969cdf0e10cSrcweir SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
970cdf0e10cSrcweir
971cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
972cdf0e10cSrcweir SfxObjectShell* pShell = pDoc->GetDocumentShell();
973cdf0e10cSrcweir if (pDrawLayer && pShell)
974cdf0e10cSrcweir {
975cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount();
976cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount; nTab++)
977cdf0e10cSrcweir {
978cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
979cdf0e10cSrcweir DBG_ASSERT(pPage,"Page ?");
980cdf0e10cSrcweir if (pPage)
981cdf0e10cSrcweir {
982cdf0e10cSrcweir SdrObjListIter aIter( *pPage, eIter );
983cdf0e10cSrcweir SdrObject* pObject = aIter.Next();
984cdf0e10cSrcweir while (pObject)
985cdf0e10cSrcweir {
986cdf0e10cSrcweir if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
987cdf0e10cSrcweir {
988cdf0e10cSrcweir String aName = ScDrawLayer::GetVisibleName( pObject );
989cdf0e10cSrcweir if (aName.Len())
990*0deba7fbSSteve Yin {
991*0deba7fbSSteve Yin if( bisInNavigatoeDlg )
992*0deba7fbSSteve Yin {
993*0deba7fbSSteve Yin if (nType >= SC_CONTENT_COUNT)
994*0deba7fbSSteve Yin {
995*0deba7fbSSteve Yin DBG_ERROR("ScContentTree::InsertContent mit falschem Typ");
996*0deba7fbSSteve Yin return;
997cdf0e10cSrcweir }
998*0deba7fbSSteve Yin SvLBoxEntry* pParent = pRootNodes[nType];
999*0deba7fbSSteve Yin if (pParent)
1000*0deba7fbSSteve Yin {
1001*0deba7fbSSteve Yin SvLBoxEntry* pChild=InsertEntry( aName, pParent );
1002*0deba7fbSSteve Yin if(pChild)
1003*0deba7fbSSteve Yin pChild->SetMarked( sal_False);
1004*0deba7fbSSteve Yin Window* pWindow=NULL;
1005*0deba7fbSSteve Yin ScTabViewShell* pScTabViewShell=NULL;
1006*0deba7fbSSteve Yin ScDrawView* pScDrawView=NULL;
1007*0deba7fbSSteve Yin ScNavigatorDlg* pScNavigatorDlg=NULL;
1008*0deba7fbSSteve Yin if(pChild)
1009*0deba7fbSSteve Yin pWindow=(Window*)GetParent(pChild);
1010*0deba7fbSSteve Yin if(pWindow)
1011*0deba7fbSSteve Yin pScNavigatorDlg = (ScNavigatorDlg*)pWindow;
1012*0deba7fbSSteve Yin if (pScNavigatorDlg!=NULL)
1013*0deba7fbSSteve Yin pScTabViewShell=pScNavigatorDlg->GetTabViewShell();
1014*0deba7fbSSteve Yin if(pScTabViewShell !=NULL)
1015*0deba7fbSSteve Yin pScDrawView =pScTabViewShell->GetViewData()->GetScDrawView();
1016*0deba7fbSSteve Yin if(pScDrawView!=NULL)
1017*0deba7fbSSteve Yin {
1018*0deba7fbSSteve Yin sal_Bool bMarked =pScDrawView->GetObjectIsMarked(pObject);
1019*0deba7fbSSteve Yin pChild->SetMarked( bMarked );
1020*0deba7fbSSteve Yin }
1021*0deba7fbSSteve Yin }//end if parent
1022*0deba7fbSSteve Yin else
1023*0deba7fbSSteve Yin DBG_ERROR("InsertContent ohne Parent");
1024*0deba7fbSSteve Yin }
1025*0deba7fbSSteve Yin }
1026*0deba7fbSSteve Yin }
1027cdf0e10cSrcweir pObject = aIter.Next();
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir
GetGraphicNames()1034cdf0e10cSrcweir void ScContentTree::GetGraphicNames()
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir GetDrawNames( SC_CONTENT_GRAPHIC );
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir
GetOleNames()1039cdf0e10cSrcweir void ScContentTree::GetOleNames()
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir GetDrawNames( SC_CONTENT_OLEOBJECT );
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir
GetDrawingNames()1044cdf0e10cSrcweir void ScContentTree::GetDrawingNames()
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir GetDrawNames( SC_CONTENT_DRAWING );
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir
GetLinkNames()1049cdf0e10cSrcweir void ScContentTree::GetLinkNames()
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir if ( nRootType && nRootType != SC_CONTENT_AREALINK ) // ausgeblendet ?
1052cdf0e10cSrcweir return;
1053cdf0e10cSrcweir
1054cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
1055cdf0e10cSrcweir if (!pDoc)
1056cdf0e10cSrcweir return;
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
1059cdf0e10cSrcweir DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
1060cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
1061cdf0e10cSrcweir sal_uInt16 nCount = rLinks.Count();
1062cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++)
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir ::sfx2::SvBaseLink* pBase = *rLinks[i];
1065cdf0e10cSrcweir if (pBase->ISA(ScAreaLink))
1066cdf0e10cSrcweir InsertContent( SC_CONTENT_AREALINK, ((ScAreaLink*)pBase)->GetSource() );
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir // in der Liste die Namen der Quellbereiche
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir
GetLink(sal_uLong nIndex)1072cdf0e10cSrcweir const ScAreaLink* ScContentTree::GetLink( sal_uLong nIndex )
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
1075cdf0e10cSrcweir if (!pDoc)
1076cdf0e10cSrcweir return NULL;
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir sal_uLong nFound = 0;
1079cdf0e10cSrcweir sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
1080cdf0e10cSrcweir DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
1081cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
1082cdf0e10cSrcweir sal_uInt16 nCount = rLinks.Count();
1083cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++)
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir ::sfx2::SvBaseLink* pBase = *rLinks[i];
1086cdf0e10cSrcweir if (pBase->ISA(ScAreaLink))
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir if (nFound == nIndex)
1089cdf0e10cSrcweir return (const ScAreaLink*) pBase;
1090cdf0e10cSrcweir ++nFound;
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir DBG_ERROR("Link nicht gefunden");
1095cdf0e10cSrcweir return NULL;
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir
lcl_NoteString(const ScPostIt & rNote)1098cdf0e10cSrcweir String lcl_NoteString( const ScPostIt& rNote )
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir String aText = rNote.GetText();
1101cdf0e10cSrcweir xub_StrLen nAt;
1102cdf0e10cSrcweir while ( (nAt = aText.Search( '\n' )) != STRING_NOTFOUND )
1103cdf0e10cSrcweir aText.SetChar( nAt, ' ' );
1104cdf0e10cSrcweir return aText;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir
GetNoteStrings()1107cdf0e10cSrcweir void ScContentTree::GetNoteStrings()
1108cdf0e10cSrcweir {
1109cdf0e10cSrcweir if ( nRootType && nRootType != SC_CONTENT_NOTE ) // ausgeblendet ?
1110cdf0e10cSrcweir return;
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
1113cdf0e10cSrcweir if (!pDoc)
1114cdf0e10cSrcweir return;
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount();
1117cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
1120cdf0e10cSrcweir for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
1121cdf0e10cSrcweir if( const ScPostIt* pNote = pCell->GetNote() )
1122cdf0e10cSrcweir InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) );
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir
GetNotePos(sal_uLong nIndex)1126cdf0e10cSrcweir ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
1129cdf0e10cSrcweir if (!pDoc)
1130cdf0e10cSrcweir return ScAddress();
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir sal_uLong nFound = 0;
1133cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount();
1134cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
1137cdf0e10cSrcweir ScBaseCell* pCell = aIter.GetFirst();
1138cdf0e10cSrcweir while (pCell)
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir if( pCell->HasNote() )
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir if (nFound == nIndex)
1143cdf0e10cSrcweir return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden
1144cdf0e10cSrcweir ++nFound;
1145cdf0e10cSrcweir }
1146cdf0e10cSrcweir pCell = aIter.GetNext();
1147cdf0e10cSrcweir }
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir DBG_ERROR("Notiz nicht gefunden");
1151cdf0e10cSrcweir return ScAddress();
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir
NoteStringsChanged()1154cdf0e10cSrcweir sal_Bool ScContentTree::NoteStringsChanged()
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
1157cdf0e10cSrcweir if (!pDoc)
1158cdf0e10cSrcweir return sal_False;
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir SvLBoxEntry* pParent = pRootNodes[SC_CONTENT_NOTE];
1161cdf0e10cSrcweir if (!pParent)
1162cdf0e10cSrcweir return sal_False;
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstChild( pParent );
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir sal_Bool bEqual = sal_True;
1167cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount();
1168cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
1171cdf0e10cSrcweir ScBaseCell* pCell = aIter.GetFirst();
1172cdf0e10cSrcweir while (pCell && bEqual)
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir if( const ScPostIt* pNote = pCell->GetNote() )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir if ( !pEntry )
1177cdf0e10cSrcweir bEqual = sal_False;
1178cdf0e10cSrcweir else
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
1181cdf0e10cSrcweir bEqual = sal_False;
1182cdf0e10cSrcweir
1183cdf0e10cSrcweir pEntry = NextSibling( pEntry );
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir }
1186cdf0e10cSrcweir pCell = aIter.GetNext();
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir if ( pEntry )
1191cdf0e10cSrcweir bEqual = sal_False; // kommt noch was
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir return !bEqual;
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir
DrawNamesChanged(sal_uInt16 nType)1196cdf0e10cSrcweir sal_Bool ScContentTree::DrawNamesChanged( sal_uInt16 nType )
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir ScDocument* pDoc = GetSourceDocument();
1199cdf0e10cSrcweir if (!pDoc)
1200cdf0e10cSrcweir return sal_False;
1201cdf0e10cSrcweir
1202cdf0e10cSrcweir SvLBoxEntry* pParent = pRootNodes[nType];
1203cdf0e10cSrcweir if (!pParent)
1204cdf0e10cSrcweir return sal_False;
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstChild( pParent );
1207cdf0e10cSrcweir
1208cdf0e10cSrcweir // iterate in flat mode for groups
1209cdf0e10cSrcweir SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir sal_Bool bEqual = sal_True;
1212cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1213cdf0e10cSrcweir SfxObjectShell* pShell = pDoc->GetDocumentShell();
1214cdf0e10cSrcweir if (pDrawLayer && pShell)
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount();
1217cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1220cdf0e10cSrcweir DBG_ASSERT(pPage,"Page ?");
1221cdf0e10cSrcweir if (pPage)
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir SdrObjListIter aIter( *pPage, eIter );
1224cdf0e10cSrcweir SdrObject* pObject = aIter.Next();
1225cdf0e10cSrcweir while (pObject && bEqual)
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir if ( !pEntry )
1230cdf0e10cSrcweir bEqual = sal_False;
1231cdf0e10cSrcweir else
1232cdf0e10cSrcweir {
1233cdf0e10cSrcweir if ( ScDrawLayer::GetVisibleName( pObject ) != GetEntryText(pEntry) )
1234cdf0e10cSrcweir bEqual = sal_False;
1235cdf0e10cSrcweir
1236cdf0e10cSrcweir pEntry = NextSibling( pEntry );
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir }
1239cdf0e10cSrcweir pObject = aIter.Next();
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir if ( pEntry )
1246cdf0e10cSrcweir bEqual = sal_False; // kommt noch was
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir return !bEqual;
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir
lcl_GetRange(ScDocument * pDoc,sal_uInt16 nType,const String & rName,ScRange & rRange)1251cdf0e10cSrcweir sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRange& rRange )
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir sal_Bool bFound = sal_False;
1254cdf0e10cSrcweir sal_uInt16 nPos;
1255cdf0e10cSrcweir
1256cdf0e10cSrcweir if ( nType == SC_CONTENT_RANGENAME )
1257cdf0e10cSrcweir {
1258cdf0e10cSrcweir ScRangeName* pList = pDoc->GetRangeName();
1259cdf0e10cSrcweir if (pList)
1260cdf0e10cSrcweir if (pList->SearchName( rName, nPos ))
1261cdf0e10cSrcweir if ( (*pList)[nPos]->IsValidReference( rRange ) )
1262cdf0e10cSrcweir bFound = sal_True;
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir else if ( nType == SC_CONTENT_DBAREA )
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir ScDBCollection* pList = pDoc->GetDBCollection();
1267cdf0e10cSrcweir if (pList)
1268cdf0e10cSrcweir if (pList->SearchName( rName, nPos ))
1269cdf0e10cSrcweir {
1270cdf0e10cSrcweir SCTAB nTab;
1271cdf0e10cSrcweir SCCOL nCol1, nCol2;
1272cdf0e10cSrcweir SCROW nRow1, nRow2;
1273cdf0e10cSrcweir (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
1274cdf0e10cSrcweir rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
1275cdf0e10cSrcweir bFound = sal_True;
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir }
1278cdf0e10cSrcweir
1279cdf0e10cSrcweir return bFound;
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir
lcl_DoDragObject(ScDocShell * pSrcShell,const String & rName,sal_uInt16 nType,Window * pWin)1282cdf0e10cSrcweir void lcl_DoDragObject( ScDocShell* pSrcShell, const String& rName, sal_uInt16 nType, Window* pWin )
1283cdf0e10cSrcweir {
1284cdf0e10cSrcweir ScDocument* pSrcDoc = pSrcShell->GetDocument();
1285cdf0e10cSrcweir ScDrawLayer* pModel = pSrcDoc->GetDrawLayer();
1286cdf0e10cSrcweir if (pModel)
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir sal_Bool bOle = ( nType == SC_CONTENT_OLEOBJECT );
1289cdf0e10cSrcweir sal_Bool bGraf = ( nType == SC_CONTENT_GRAPHIC );
1290cdf0e10cSrcweir sal_uInt16 nDrawId = sal::static_int_cast<sal_uInt16>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) );
1291cdf0e10cSrcweir SCTAB nTab = 0;
1292cdf0e10cSrcweir SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab );
1293cdf0e10cSrcweir if (pObject)
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir SdrView aEditView( pModel );
1296cdf0e10cSrcweir aEditView.ShowSdrPage(aEditView.GetModel()->GetPage(nTab));
1297cdf0e10cSrcweir SdrPageView* pPV = aEditView.GetSdrPageView();
1298cdf0e10cSrcweir aEditView.MarkObj(pObject, pPV);
1299cdf0e10cSrcweir
1300cdf0e10cSrcweir SdrModel* pDragModel = aEditView.GetAllMarkedModel();
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc;
1303cdf0e10cSrcweir pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1304cdf0e10cSrcweir aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1305cdf0e10cSrcweir // maSize is set in ScDrawTransferObj ctor
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc );
1308cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1309cdf0e10cSrcweir
1310cdf0e10cSrcweir pTransferObj->SetDragSourceObj( pObject, nTab );
1311cdf0e10cSrcweir pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
1312cdf0e10cSrcweir
1313cdf0e10cSrcweir SC_MOD()->SetDragObject( NULL, pTransferObj );
1314cdf0e10cSrcweir pWin->ReleaseMouse();
1315cdf0e10cSrcweir pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir
lcl_DoDragCells(ScDocShell * pSrcShell,const ScRange & rRange,sal_uInt16 nFlags,Window * pWin)1320cdf0e10cSrcweir void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, sal_uInt16 nFlags, Window* pWin )
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir ScMarkData aMark;
1323cdf0e10cSrcweir aMark.SelectTable( rRange.aStart.Tab(), sal_True );
1324cdf0e10cSrcweir aMark.SetMarkArea( rRange );
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir ScDocument* pSrcDoc = pSrcShell->GetDocument();
1327cdf0e10cSrcweir if ( !pSrcDoc->HasSelectedBlockMatrixFragment( rRange.aStart.Col(), rRange.aStart.Row(),
1328cdf0e10cSrcweir rRange.aEnd.Col(), rRange.aEnd.Row(),
1329cdf0e10cSrcweir aMark ) )
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
1332cdf0e10cSrcweir ScClipParam aClipParam(rRange, false);
1333cdf0e10cSrcweir pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aMark);
1334cdf0e10cSrcweir // pClipDoc->ExtendMerge( rRange, sal_True );
1335cdf0e10cSrcweir
1336cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc;
1337cdf0e10cSrcweir pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1338cdf0e10cSrcweir aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1339cdf0e10cSrcweir // maSize is set in ScTransferObj ctor
1340cdf0e10cSrcweir
1341cdf0e10cSrcweir ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
1342cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1343cdf0e10cSrcweir
1344cdf0e10cSrcweir pTransferObj->SetDragSource( pSrcShell, aMark );
1345cdf0e10cSrcweir pTransferObj->SetDragSourceFlags( nFlags );
1346cdf0e10cSrcweir
1347cdf0e10cSrcweir SC_MOD()->SetDragObject( pTransferObj, NULL ); // for internal D&D
1348cdf0e10cSrcweir pWin->ReleaseMouse();
1349cdf0e10cSrcweir pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir
DoDrag()1353cdf0e10cSrcweir void ScContentTree::DoDrag()
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir ScDocumentLoader* pDocLoader = NULL;
1356cdf0e10cSrcweir bIsInDrag = sal_True;
1357cdf0e10cSrcweir
1358cdf0e10cSrcweir ScModule* pScMod = SC_MOD();
1359cdf0e10cSrcweir
1360cdf0e10cSrcweir sal_uInt16 nType;
1361cdf0e10cSrcweir sal_uLong nChild;
1362cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry();
1363cdf0e10cSrcweir GetEntryIndexes( nType, nChild, pEntry );
1364cdf0e10cSrcweir
1365cdf0e10cSrcweir if( pEntry &&
1366cdf0e10cSrcweir (nChild != SC_CONTENT_NOCHILD) &&
1367cdf0e10cSrcweir (nType != SC_CONTENT_ROOT) &&
1368cdf0e10cSrcweir (nType != SC_CONTENT_NOTE) &&
1369cdf0e10cSrcweir (nType != SC_CONTENT_AREALINK) )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir String aText( GetEntryText( pEntry ) );
1372cdf0e10cSrcweir
1373cdf0e10cSrcweir ScDocument* pLocalDoc = NULL; // fuer URL-Drop
1374cdf0e10cSrcweir String aDocName;
1375cdf0e10cSrcweir if (bHiddenDoc)
1376cdf0e10cSrcweir aDocName = aHiddenName;
1377cdf0e10cSrcweir else
1378cdf0e10cSrcweir {
1379cdf0e10cSrcweir ScDocShell* pDocSh = GetManualOrCurrent();
1380cdf0e10cSrcweir if (pDocSh)
1381cdf0e10cSrcweir {
1382cdf0e10cSrcweir if (pDocSh->HasName())
1383cdf0e10cSrcweir aDocName = pDocSh->GetMedium()->GetName();
1384cdf0e10cSrcweir else
1385cdf0e10cSrcweir pLocalDoc = pDocSh->GetDocument(); // Drop nur in dieses Dokument
1386cdf0e10cSrcweir }
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir
1389cdf0e10cSrcweir sal_Bool bDoLinkTrans = sal_False; // use ScLinkTransferObj
1390cdf0e10cSrcweir String aLinkURL; // for ScLinkTransferObj
1391cdf0e10cSrcweir String aLinkText;
1392cdf0e10cSrcweir
1393cdf0e10cSrcweir sal_uInt16 nDropMode = pParentWindow->GetDropMode();
1394cdf0e10cSrcweir switch ( nDropMode )
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir case SC_DROPMODE_URL:
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir String aUrl = aDocName;
1399cdf0e10cSrcweir aUrl += '#';
1400cdf0e10cSrcweir aUrl += aText;
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir pScMod->SetDragJump( pLocalDoc, aUrl, aText );
1403cdf0e10cSrcweir
1404cdf0e10cSrcweir if (aDocName.Len())
1405cdf0e10cSrcweir {
1406cdf0e10cSrcweir // provide URL to outside only if the document has a name
1407cdf0e10cSrcweir // (without name, only internal D&D via SetDragJump)
1408cdf0e10cSrcweir
1409cdf0e10cSrcweir aLinkURL = aUrl;
1410cdf0e10cSrcweir aLinkText = aText;
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir bDoLinkTrans = sal_True;
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir break;
1415cdf0e10cSrcweir case SC_DROPMODE_LINK:
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir if ( aDocName.Len() ) // link only to named documents
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir // for internal D&D, set flag to insert a link
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir switch ( nType )
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir case SC_CONTENT_TABLE:
1424cdf0e10cSrcweir pScMod->SetDragLink( aDocName, aText, EMPTY_STRING );
1425cdf0e10cSrcweir bDoLinkTrans = sal_True;
1426cdf0e10cSrcweir break;
1427cdf0e10cSrcweir case SC_CONTENT_RANGENAME:
1428cdf0e10cSrcweir case SC_CONTENT_DBAREA:
1429cdf0e10cSrcweir pScMod->SetDragLink( aDocName, EMPTY_STRING, aText );
1430cdf0e10cSrcweir bDoLinkTrans = sal_True;
1431cdf0e10cSrcweir break;
1432cdf0e10cSrcweir
1433cdf0e10cSrcweir // other types cannot be linked
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir }
1437cdf0e10cSrcweir break;
1438cdf0e10cSrcweir case SC_DROPMODE_COPY:
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir ScDocShell* pSrcShell = NULL;
1441cdf0e10cSrcweir if ( bHiddenDoc )
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir String aFilter, aOptions;
1444cdf0e10cSrcweir pDocLoader = new ScDocumentLoader( aHiddenName, aFilter, aOptions );
1445cdf0e10cSrcweir if (!pDocLoader->IsError())
1446cdf0e10cSrcweir pSrcShell = pDocLoader->GetDocShell();
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir else
1449cdf0e10cSrcweir pSrcShell = GetManualOrCurrent();
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir if ( pSrcShell )
1452cdf0e10cSrcweir {
1453cdf0e10cSrcweir ScDocument* pSrcDoc = pSrcShell->GetDocument();
1454cdf0e10cSrcweir if ( nType == SC_CONTENT_RANGENAME || nType == SC_CONTENT_DBAREA )
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir ScRange aRange;
1457cdf0e10cSrcweir if ( lcl_GetRange( pSrcDoc, nType, aText, aRange ) )
1458cdf0e10cSrcweir {
1459cdf0e10cSrcweir lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this );
1460cdf0e10cSrcweir }
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir else if ( nType == SC_CONTENT_TABLE )
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir SCTAB nTab;
1465cdf0e10cSrcweir if ( pSrcDoc->GetTable( aText, nTab ) )
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab );
1468cdf0e10cSrcweir lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this );
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir else if ( nType == SC_CONTENT_GRAPHIC || nType == SC_CONTENT_OLEOBJECT ||
1472cdf0e10cSrcweir nType == SC_CONTENT_DRAWING )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir lcl_DoDragObject( pSrcShell, aText, nType, this );
1475cdf0e10cSrcweir
1476cdf0e10cSrcweir // in ExecuteDrag kann der Navigator geloescht worden sein
1477cdf0e10cSrcweir // -> nicht mehr auf Member zugreifen !!!
1478cdf0e10cSrcweir }
1479cdf0e10cSrcweir }
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir break;
1482cdf0e10cSrcweir }
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir if (bDoLinkTrans)
1485cdf0e10cSrcweir {
1486cdf0e10cSrcweir ScLinkTransferObj* pTransferObj = new ScLinkTransferObj;
1487cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1488cdf0e10cSrcweir
1489cdf0e10cSrcweir if ( aLinkURL.Len() )
1490cdf0e10cSrcweir pTransferObj->SetLinkURL( aLinkURL, aLinkText );
1491cdf0e10cSrcweir
1492cdf0e10cSrcweir // SetDragJump / SetDragLink has been done above
1493cdf0e10cSrcweir
1494cdf0e10cSrcweir ReleaseMouse();
1495cdf0e10cSrcweir pTransferObj->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir
1499cdf0e10cSrcweir bIsInDrag = sal_False; // static Member
1500cdf0e10cSrcweir
1501cdf0e10cSrcweir delete pDocLoader; // falls Dokument zum Draggen geladen wurde
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir
IMPL_STATIC_LINK(ScContentTree,ExecDragHdl,void *,EMPTYARG)1504cdf0e10cSrcweir IMPL_STATIC_LINK(ScContentTree, ExecDragHdl, void*, EMPTYARG)
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir // als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1507cdf0e10cSrcweir // Navigator geloescht werden darf
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir pThis->DoDrag();
1510cdf0e10cSrcweir return 0;
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir
1513cdf0e10cSrcweir //UNUSED2008-05 void ScContentTree::AdjustTitle()
1514cdf0e10cSrcweir //UNUSED2008-05 {
1515cdf0e10cSrcweir //UNUSED2008-05 String aTitle = pParentWindow->aTitleBase;
1516cdf0e10cSrcweir //UNUSED2008-05 if (bHiddenDoc)
1517cdf0e10cSrcweir //UNUSED2008-05 {
1518cdf0e10cSrcweir //UNUSED2008-05 aTitle.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
1519cdf0e10cSrcweir //UNUSED2008-05 aTitle += aHiddenTitle;
1520cdf0e10cSrcweir //UNUSED2008-05 }
1521cdf0e10cSrcweir //UNUSED2008-05 pParentWindow->SetText(aTitle);
1522cdf0e10cSrcweir //UNUSED2008-05 }
1523cdf0e10cSrcweir
LoadFile(const String & rUrl)1524cdf0e10cSrcweir sal_Bool ScContentTree::LoadFile( const String& rUrl )
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir String aDocName = rUrl;
1527cdf0e10cSrcweir xub_StrLen nPos = aDocName.Search('#');
1528cdf0e10cSrcweir if ( nPos != STRING_NOTFOUND )
1529cdf0e10cSrcweir aDocName.Erase(nPos); // nur der Name, ohne #...
1530cdf0e10cSrcweir
1531cdf0e10cSrcweir sal_Bool bReturn = sal_False;
1532cdf0e10cSrcweir String aFilter, aOptions;
1533cdf0e10cSrcweir ScDocumentLoader aLoader( aDocName, aFilter, aOptions );
1534cdf0e10cSrcweir if ( !aLoader.IsError() )
1535cdf0e10cSrcweir {
1536cdf0e10cSrcweir bHiddenDoc = sal_True;
1537cdf0e10cSrcweir aHiddenName = aDocName;
1538cdf0e10cSrcweir aHiddenTitle = aLoader.GetTitle();
1539cdf0e10cSrcweir pHiddenDocument = aLoader.GetDocument();
1540cdf0e10cSrcweir
1541cdf0e10cSrcweir Refresh(); // Inhalte aus geladenem Dokument holen
1542cdf0e10cSrcweir
1543cdf0e10cSrcweir pHiddenDocument = NULL;
1544cdf0e10cSrcweir // AdjustTitle();
1545cdf0e10cSrcweir
1546cdf0e10cSrcweir pParentWindow->GetDocNames( &aHiddenTitle ); // Liste fuellen
1547cdf0e10cSrcweir }
1548cdf0e10cSrcweir else
1549cdf0e10cSrcweir Sound::Beep(); // Fehler beim Laden
1550cdf0e10cSrcweir
1551cdf0e10cSrcweir // Dokument wird im dtor von ScDocumentLoader wieder geschlossen
1552cdf0e10cSrcweir
1553cdf0e10cSrcweir return bReturn;
1554cdf0e10cSrcweir }
1555cdf0e10cSrcweir
InitWindowBits(sal_Bool bButtons)1556cdf0e10cSrcweir void ScContentTree::InitWindowBits( sal_Bool bButtons )
1557cdf0e10cSrcweir {
1558cdf0e10cSrcweir WinBits nFlags = GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL;
1559cdf0e10cSrcweir if (bButtons)
1560cdf0e10cSrcweir nFlags |= WB_HASBUTTONS|WB_HASBUTTONSATROOT;
1561cdf0e10cSrcweir
1562cdf0e10cSrcweir SetStyle( nFlags );
1563cdf0e10cSrcweir }
1564cdf0e10cSrcweir
SetRootType(sal_uInt16 nNew)1565cdf0e10cSrcweir void ScContentTree::SetRootType( sal_uInt16 nNew )
1566cdf0e10cSrcweir {
1567cdf0e10cSrcweir if ( nNew != nRootType )
1568cdf0e10cSrcweir {
1569cdf0e10cSrcweir nRootType = nNew;
1570cdf0e10cSrcweir InitWindowBits( nNew == 0 );
1571cdf0e10cSrcweir Refresh();
1572cdf0e10cSrcweir
1573cdf0e10cSrcweir ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1574cdf0e10cSrcweir rCfg.SetRootType( nRootType );
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir
ToggleRoot()1578cdf0e10cSrcweir void ScContentTree::ToggleRoot() // nach Selektion
1579cdf0e10cSrcweir {
1580cdf0e10cSrcweir sal_uInt16 nNew = SC_CONTENT_ROOT;
1581cdf0e10cSrcweir if ( nRootType == SC_CONTENT_ROOT )
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry();
1584cdf0e10cSrcweir if (pEntry)
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir SvLBoxEntry* pParent = GetParent(pEntry);
1587cdf0e10cSrcweir for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++)
1588cdf0e10cSrcweir if ( pEntry == pRootNodes[i] || pParent == pRootNodes[i] )
1589cdf0e10cSrcweir nNew = i;
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir
1593cdf0e10cSrcweir SetRootType( nNew );
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir
ResetManualDoc()1596cdf0e10cSrcweir void ScContentTree::ResetManualDoc()
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir aManualDoc.Erase();
1599cdf0e10cSrcweir bHiddenDoc = sal_False;
1600cdf0e10cSrcweir
1601cdf0e10cSrcweir ActiveDocChanged();
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir
ActiveDocChanged()1604cdf0e10cSrcweir void ScContentTree::ActiveDocChanged()
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir if ( !bHiddenDoc && !aManualDoc.Len() )
1607cdf0e10cSrcweir Refresh(); // Inhalte nur wenn automatisch
1608cdf0e10cSrcweir
1609cdf0e10cSrcweir // Listbox muss immer geupdated werden, wegen aktiv-Flag
1610cdf0e10cSrcweir
1611cdf0e10cSrcweir String aCurrent;
1612cdf0e10cSrcweir if ( bHiddenDoc )
1613cdf0e10cSrcweir aCurrent = aHiddenTitle;
1614cdf0e10cSrcweir else
1615cdf0e10cSrcweir {
1616cdf0e10cSrcweir ScDocShell* pSh = GetManualOrCurrent();
1617cdf0e10cSrcweir if (pSh)
1618cdf0e10cSrcweir aCurrent = pSh->GetTitle();
1619cdf0e10cSrcweir else
1620cdf0e10cSrcweir {
1621cdf0e10cSrcweir // eingestelltes Dokument existiert nicht mehr
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir aManualDoc.Erase(); // wieder automatisch
1624cdf0e10cSrcweir Refresh();
1625cdf0e10cSrcweir pSh = GetManualOrCurrent(); // sollte jetzt aktives sein
1626cdf0e10cSrcweir if (pSh)
1627cdf0e10cSrcweir aCurrent = pSh->GetTitle();
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir }
1630cdf0e10cSrcweir pParentWindow->GetDocNames( &aCurrent ); // selektieren
1631cdf0e10cSrcweir }
1632cdf0e10cSrcweir
SetManualDoc(const String & rName)1633cdf0e10cSrcweir void ScContentTree::SetManualDoc(const String& rName)
1634cdf0e10cSrcweir {
1635cdf0e10cSrcweir aManualDoc = rName;
1636cdf0e10cSrcweir if (!bHiddenDoc)
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir Refresh();
1639cdf0e10cSrcweir pParentWindow->GetDocNames( &aManualDoc ); // selektieren
1640cdf0e10cSrcweir }
1641cdf0e10cSrcweir }
1642cdf0e10cSrcweir
SelectDoc(const String & rName)1643cdf0e10cSrcweir void ScContentTree::SelectDoc(const String& rName) // rName wie im Menue/Listbox angezeigt
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir if ( rName == pParentWindow->aStrActiveWin )
1646cdf0e10cSrcweir {
1647cdf0e10cSrcweir ResetManualDoc();
1648cdf0e10cSrcweir return;
1649cdf0e10cSrcweir }
1650cdf0e10cSrcweir
1651cdf0e10cSrcweir // "aktiv" oder "inaktiv" weglassen
1652cdf0e10cSrcweir
1653cdf0e10cSrcweir String aRealName = rName;
1654cdf0e10cSrcweir xub_StrLen nLen = rName.Len();
1655cdf0e10cSrcweir xub_StrLen nActiveStart = nLen - pParentWindow->aStrActive.Len();
1656cdf0e10cSrcweir if ( rName.Copy( nActiveStart ) == pParentWindow->aStrActive )
1657cdf0e10cSrcweir aRealName = rName.Copy( 0, nActiveStart );
1658cdf0e10cSrcweir xub_StrLen nNotActiveStart = nLen - pParentWindow->aStrNotActive.Len();
1659cdf0e10cSrcweir if ( rName.Copy( nNotActiveStart ) == pParentWindow->aStrNotActive )
1660cdf0e10cSrcweir aRealName = rName.Copy( 0, nNotActiveStart );
1661cdf0e10cSrcweir
1662cdf0e10cSrcweir //
1663cdf0e10cSrcweir
1664cdf0e10cSrcweir sal_Bool bLoaded = sal_False;
1665cdf0e10cSrcweir
1666cdf0e10cSrcweir // ist es ein normal geladenes Doc ?
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::GetFirst();
1669cdf0e10cSrcweir while ( pSh && !bLoaded )
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir if ( pSh->ISA(ScDocShell) )
1672cdf0e10cSrcweir if ( pSh->GetTitle() == aRealName )
1673cdf0e10cSrcweir bLoaded = sal_True;
1674cdf0e10cSrcweir pSh = SfxObjectShell::GetNext( *pSh );
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir
1677cdf0e10cSrcweir if (bLoaded)
1678cdf0e10cSrcweir {
1679cdf0e10cSrcweir bHiddenDoc = sal_False;
1680cdf0e10cSrcweir SetManualDoc(aRealName);
1681cdf0e10cSrcweir }
1682cdf0e10cSrcweir else if (aHiddenTitle.Len()) // verstecktes ausgewaehlt
1683cdf0e10cSrcweir {
1684cdf0e10cSrcweir if (!bHiddenDoc)
1685cdf0e10cSrcweir LoadFile(aHiddenName);
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir else
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir DBG_ERROR("SelectDoc: nicht gefunden");
1690cdf0e10cSrcweir }
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir
ApplySettings()1693cdf0e10cSrcweir void ScContentTree::ApplySettings()
1694cdf0e10cSrcweir {
1695cdf0e10cSrcweir const ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
1696cdf0e10cSrcweir if( pSettings )
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir sal_uInt16 nRootSel = pSettings->GetRootSelected();
1699cdf0e10cSrcweir sal_uLong nChildSel = pSettings->GetChildSelected();
1700cdf0e10cSrcweir
1701cdf0e10cSrcweir for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
1702cdf0e10cSrcweir {
1703cdf0e10cSrcweir if( pRootNodes[ nEntry ] )
1704cdf0e10cSrcweir {
1705cdf0e10cSrcweir // expand
1706cdf0e10cSrcweir sal_Bool bExp = pSettings->IsExpanded( nEntry );
1707cdf0e10cSrcweir if( bExp != IsExpanded( pRootNodes[ nEntry ] ) )
1708cdf0e10cSrcweir {
1709cdf0e10cSrcweir if( bExp )
1710cdf0e10cSrcweir Expand( pRootNodes[ nEntry ] );
1711cdf0e10cSrcweir else
1712cdf0e10cSrcweir Collapse( pRootNodes[ nEntry ] );
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir // select
1716cdf0e10cSrcweir if( nRootSel == nEntry )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir SvLBoxEntry* pEntry = NULL;
1719cdf0e10cSrcweir if( bExp && (nChildSel != SC_CONTENT_NOCHILD) )
1720cdf0e10cSrcweir pEntry = GetEntry( pRootNodes[ nEntry ], nChildSel );
1721cdf0e10cSrcweir Select( pEntry ? pEntry : pRootNodes[ nEntry ] );
1722cdf0e10cSrcweir }
1723cdf0e10cSrcweir }
1724cdf0e10cSrcweir }
1725cdf0e10cSrcweir }
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir
StoreSettings() const1728cdf0e10cSrcweir void ScContentTree::StoreSettings() const
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
1731cdf0e10cSrcweir if( pSettings )
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
1734cdf0e10cSrcweir {
1735cdf0e10cSrcweir sal_Bool bExp = pRootNodes[ nEntry ] && IsExpanded( pRootNodes[ nEntry ] );
1736cdf0e10cSrcweir pSettings->SetExpanded( nEntry, bExp );
1737cdf0e10cSrcweir }
1738cdf0e10cSrcweir sal_uInt16 nRoot;
1739cdf0e10cSrcweir sal_uLong nChild;
1740cdf0e10cSrcweir GetEntryIndexes( nRoot, nChild, GetCurEntry() );
1741cdf0e10cSrcweir pSettings->SetRootSelected( nRoot );
1742cdf0e10cSrcweir pSettings->SetChildSelected( nChild );
1743cdf0e10cSrcweir }
1744cdf0e10cSrcweir }
1745cdf0e10cSrcweir
1746*0deba7fbSSteve Yin class ScContentLBoxString : public SvLBoxString
1747*0deba7fbSSteve Yin {
1748*0deba7fbSSteve Yin public:
ScContentLBoxString(SvLBoxEntry * pEntry,sal_uInt16 nFlags,const String & rStr)1749*0deba7fbSSteve Yin ScContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
1750*0deba7fbSSteve Yin const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {}
1751cdf0e10cSrcweir
1752*0deba7fbSSteve Yin virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
1753*0deba7fbSSteve Yin SvLBoxEntry* pEntry);
1754*0deba7fbSSteve Yin };
InitEntry(SvLBoxEntry * pEntry,const XubString & rStr,const Image & rImg1,const Image & rImg2,SvLBoxButtonKind eButtonKind)1755*0deba7fbSSteve Yin void ScContentTree::InitEntry(SvLBoxEntry* pEntry,
1756*0deba7fbSSteve Yin const XubString& rStr ,const Image& rImg1,const Image& rImg2, SvLBoxButtonKind eButtonKind)
1757*0deba7fbSSteve Yin {
1758*0deba7fbSSteve Yin sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
1759*0deba7fbSSteve Yin SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
1760*0deba7fbSSteve Yin SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
1761*0deba7fbSSteve Yin ScContentLBoxString* pStr = new ScContentLBoxString( pEntry, 0, pCol->GetText() );
1762*0deba7fbSSteve Yin pEntry->ReplaceItem( pStr, nColToHilite );
1763*0deba7fbSSteve Yin }
Paint(const Point & rPos,SvLBox & rDev,sal_uInt16 nFlags,SvLBoxEntry * pEntry)1764*0deba7fbSSteve Yin void ScContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
1765*0deba7fbSSteve Yin SvLBoxEntry* pEntry )
1766*0deba7fbSSteve Yin {
1767*0deba7fbSSteve Yin // IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this
1768*0deba7fbSSteve Yin /*
1769*0deba7fbSSteve Yin if (pEntry->IsMarked())
1770*0deba7fbSSteve Yin {
1771*0deba7fbSSteve Yin rDev.DrawText( rPos, GetText() );
1772*0deba7fbSSteve Yin XubString str;
1773*0deba7fbSSteve Yin str = XubString::CreateFromAscii("*");
1774*0deba7fbSSteve Yin Point rPosStar(rPos.X()-6,rPos.Y());
1775*0deba7fbSSteve Yin Font aOldFont( rDev.GetFont());
1776*0deba7fbSSteve Yin Font aFont(aOldFont);
1777*0deba7fbSSteve Yin Color aCol( aOldFont.GetColor() );
1778*0deba7fbSSteve Yin aCol.DecreaseLuminance( 200 );
1779*0deba7fbSSteve Yin aFont.SetColor( aCol );
1780*0deba7fbSSteve Yin rDev.SetFont( aFont );
1781*0deba7fbSSteve Yin rDev.DrawText( rPosStar, str);
1782*0deba7fbSSteve Yin rDev.SetFont( aOldFont );
1783*0deba7fbSSteve Yin }
1784*0deba7fbSSteve Yin else
1785*0deba7fbSSteve Yin */
1786*0deba7fbSSteve Yin SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
1787*0deba7fbSSteve Yin }
1788cdf0e10cSrcweir //
1789cdf0e10cSrcweir //------------------------------------------------------------------------
1790cdf0e10cSrcweir //
1791cdf0e10cSrcweir
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir
1794cdf0e10cSrcweir
1795cdf0e10cSrcweir
1796