update dev300-m57
[ooovba.git] / sc / source / ui / navipi / content.cxx
blobe6451f46ea1c8cbbd2f57d9b64e9555684717ed7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: content.cxx,v $
10 * $Revision: 1.26.102.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // INCLUDE ---------------------------------------------------------------
36 #include <svx/svditer.hxx>
37 #include <svx/svdobj.hxx>
38 #include <svx/svdpage.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdview.hxx>
41 #include <svx/svdxcgv.hxx>
42 #include <svx/linkmgr.hxx>
43 #include <sfx2/docfile.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <vcl/help.hxx>
46 #include <vcl/sound.hxx>
47 #include <vcl/svapp.hxx>
48 #include <tools/urlobj.hxx>
49 #include <svtools/urlbmk.hxx>
50 #include <stdlib.h>
52 #include "content.hxx"
53 #include "navipi.hxx"
54 #include "global.hxx"
55 #include "docsh.hxx"
56 #include "scmod.hxx"
57 #include "rangenam.hxx"
58 #include "dbcolect.hxx"
59 #include "tablink.hxx" // fuer Loader
60 #include "popmenu.hxx"
61 #include "drwlayer.hxx"
62 #include "transobj.hxx"
63 #include "drwtrans.hxx"
64 #include "lnktrans.hxx"
65 #include "cell.hxx"
66 #include "dociter.hxx"
67 #include "scresid.hxx"
68 #include "globstr.hrc"
69 #include "navipi.hrc"
70 #include "arealink.hxx"
71 #include "navicfg.hxx"
72 #include "navsett.hxx"
73 #include "postit.hxx"
75 using namespace com::sun::star;
77 // Reihenfolge der Kategorien im Navigator -------------------------------------
79 static USHORT pTypeList[SC_CONTENT_COUNT] =
81 SC_CONTENT_ROOT, // ROOT (0) muss vorne stehen
82 SC_CONTENT_TABLE,
83 SC_CONTENT_RANGENAME,
84 SC_CONTENT_DBAREA,
85 SC_CONTENT_AREALINK,
86 SC_CONTENT_GRAPHIC,
87 SC_CONTENT_OLEOBJECT,
88 SC_CONTENT_NOTE,
89 SC_CONTENT_DRAWING
92 BOOL ScContentTree::bIsInDrag = FALSE;
95 ScDocShell* ScContentTree::GetManualOrCurrent()
97 ScDocShell* pSh = NULL;
98 if ( aManualDoc.Len() )
100 TypeId aScType = TYPE(ScDocShell);
101 SfxObjectShell* pObjSh = SfxObjectShell::GetFirst( &aScType );
102 while ( pObjSh && !pSh )
104 if ( pObjSh->GetTitle() == aManualDoc )
105 pSh = PTR_CAST( ScDocShell, pObjSh );
106 pObjSh = SfxObjectShell::GetNext( *pObjSh, &aScType );
109 else
111 // Current nur, wenn keine manuell eingestellt ist
112 // (damit erkannt wird, wenn das Dokument nicht mehr existiert)
114 SfxViewShell* pViewSh = SfxViewShell::Current();
115 if ( pViewSh )
117 SfxObjectShell* pObjSh = pViewSh->GetViewFrame()->GetObjectShell();
118 pSh = PTR_CAST( ScDocShell, pObjSh );
122 return pSh;
126 // ScContentTree
129 ScContentTree::ScContentTree( Window* pParent, const ResId& rResId ) :
130 SvTreeListBox ( pParent, rResId ),
131 aEntryImages ( ScResId( RID_IMAGELIST_NAVCONT ) ),
132 aHCEntryImages ( ScResId( RID_IMAGELIST_H_NAVCONT ) ),
133 nRootType ( SC_CONTENT_ROOT ),
134 bHiddenDoc ( FALSE ),
135 pHiddenDocument ( NULL )
137 USHORT i;
138 for (i=0; i<SC_CONTENT_COUNT; i++)
139 pPosList[pTypeList[i]] = i; // invers zum suchen
141 pParentWindow = (ScNavigatorDlg*)pParent;
143 pRootNodes[0] = NULL;
144 for (i=1; i<SC_CONTENT_COUNT; i++)
145 InitRoot(i);
147 SetNodeDefaultImages();
149 SetDoubleClickHdl( LINK( this, ScContentTree, ContentDoubleClickHdl ) );
152 ScContentTree::~ScContentTree()
156 void ScContentTree::InitRoot( USHORT nType )
158 if ( !nType )
159 return;
161 if ( nRootType && nRootType != nType ) // ausgeblendet ?
163 pRootNodes[nType] = NULL;
164 return;
167 const Image& rImage = aEntryImages.GetImage( nType );
168 String aName( ScResId( SCSTR_CONTENT_ROOT + nType ) );
169 // wieder an die richtige Position:
170 USHORT nPos = nRootType ? 0 : pPosList[nType]-1;
171 SvLBoxEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, FALSE, nPos );
173 const Image& rHCImage = aHCEntryImages.GetImage( nType );
174 SetExpandedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
175 SetCollapsedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
177 pRootNodes[nType] = pNew;
180 void ScContentTree::ClearAll()
182 Clear();
183 for (USHORT i=1; i<SC_CONTENT_COUNT; i++)
184 InitRoot(i);
187 void ScContentTree::ClearType(USHORT nType)
189 if (!nType)
190 ClearAll();
191 else
193 SvLBoxEntry* pParent = pRootNodes[nType];
194 if ( !pParent || GetChildCount(pParent) ) // nicht, wenn ohne Children schon da
196 if (pParent)
197 GetModel()->Remove( pParent ); // mit allen Children
198 InitRoot( nType ); // ggf. neu eintragen
203 void ScContentTree::InsertContent( USHORT nType, const String& rValue )
205 if (nType >= SC_CONTENT_COUNT)
207 DBG_ERROR("ScContentTree::InsertContent mit falschem Typ");
208 return;
211 SvLBoxEntry* pParent = pRootNodes[nType];
212 if (pParent)
213 InsertEntry( rValue, pParent );
214 else
216 DBG_ERROR("InsertContent ohne Parent");
220 void ScContentTree::GetEntryIndexes( USHORT& rnRootIndex, ULONG& rnChildIndex, SvLBoxEntry* pEntry ) const
222 rnRootIndex = SC_CONTENT_ROOT;
223 rnChildIndex = SC_CONTENT_NOCHILD;
225 if( !pEntry )
226 return;
228 SvLBoxEntry* pParent = GetParent( pEntry );
229 bool bFound = false;
230 for( USHORT nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot )
232 if( pEntry == pRootNodes[ nRoot ] )
234 rnRootIndex = nRoot;
235 rnChildIndex = ~0UL;
236 bFound = true;
238 else if( pParent && (pParent == pRootNodes[ nRoot ]) )
240 rnRootIndex = nRoot;
242 // search the entry in all child entries of the parent
243 ULONG nEntry = 0;
244 SvLBoxEntry* pIterEntry = FirstChild( pParent );
245 while( !bFound && pIterEntry )
247 if ( pEntry == pIterEntry )
249 rnChildIndex = nEntry;
250 bFound = true; // exit the while loop
252 pIterEntry = NextSibling( pIterEntry );
253 ++nEntry;
256 bFound = true; // exit the for loop
261 ULONG ScContentTree::GetChildIndex( SvLBoxEntry* pEntry ) const
263 USHORT nRoot;
264 ULONG nChild;
265 GetEntryIndexes( nRoot, nChild, pEntry );
266 return nChild;
269 String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
271 String aRet;
272 if (pDoc)
274 ScDBCollection* pDbNames = pDoc->GetDBCollection();
275 USHORT nCount = pDbNames->GetCount();
276 for ( USHORT i=0; i<nCount; i++ )
278 ScDBData* pData = (*pDbNames)[i];
279 if ( pData->GetName() == rDBName )
281 ScRange aRange;
282 pData->GetArea(aRange);
283 aRange.Format( aRet, SCR_ABS_3D, pDoc );
284 break;
288 return aRet;
291 IMPL_LINK( ScContentTree, ContentDoubleClickHdl, ScContentTree *, EMPTYARG )
293 USHORT nType;
294 ULONG nChild;
295 SvLBoxEntry* pEntry = GetCurEntry();
296 GetEntryIndexes( nType, nChild, pEntry );
298 if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
300 if ( bHiddenDoc )
301 return 0; //! spaeter...
303 String aText( GetEntryText( pEntry ) );
305 if ( aManualDoc.Len() )
306 pParentWindow->SetCurrentDoc( aManualDoc );
308 switch( nType )
310 case SC_CONTENT_TABLE:
311 pParentWindow->SetCurrentTableStr( aText );
312 break;
314 case SC_CONTENT_RANGENAME:
315 pParentWindow->SetCurrentCellStr( aText );
316 break;
318 case SC_CONTENT_DBAREA:
320 // #47905# Wenn gleiche Bereichs- und DB-Namen existieren, wird
321 // bei SID_CURRENTCELL der Bereichsname genommen.
322 // DB-Bereiche darum direkt ueber die Adresse anspringen.
324 String aRangeStr = lcl_GetDBAreaRange( GetSourceDocument(), aText );
325 if (aRangeStr.Len())
326 pParentWindow->SetCurrentCellStr( aRangeStr );
328 break;
330 case SC_CONTENT_OLEOBJECT:
331 case SC_CONTENT_GRAPHIC:
332 case SC_CONTENT_DRAWING:
333 pParentWindow->SetCurrentObject( aText );
334 break;
336 case SC_CONTENT_NOTE:
338 ScAddress aPos = GetNotePos( nChild );
339 pParentWindow->SetCurrentTable( aPos.Tab() );
340 pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
342 break;
344 case SC_CONTENT_AREALINK:
346 const ScAreaLink* pLink = GetLink( nChild );
347 if( pLink )
349 ScRange aRange = pLink->GetDestArea();
350 String aRangeStr;
351 ScDocument* pSrcDoc = GetSourceDocument();
352 aRange.Format( aRangeStr, SCR_ABS_3D, pSrcDoc, pSrcDoc->GetAddressConvention() );
353 pParentWindow->SetCurrentCellStr( aRangeStr );
356 break;
359 ScNavigatorDlg::ReleaseFocus(); // set focus into document
362 return 0;
365 void ScContentTree::MouseButtonDown( const MouseEvent& rMEvt )
367 SvTreeListBox::MouseButtonDown( rMEvt );
368 StoreSettings();
371 void ScContentTree::KeyInput( const KeyEvent& rKEvt )
373 BOOL bUsed = FALSE;
375 const KeyCode aCode = rKEvt.GetKeyCode();
376 if (aCode.GetCode() == KEY_RETURN)
378 switch (aCode.GetModifier())
380 case KEY_MOD1:
381 ToggleRoot(); // toggle root mode (as in Writer)
382 bUsed = TRUE;
383 break;
384 case 0:
386 SvLBoxEntry* pEntry = GetCurEntry();
387 if( pEntry )
389 USHORT nType;
390 ULONG nChild;
391 GetEntryIndexes( nType, nChild, pEntry );
393 if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) )
395 String aText( GetEntryText( pEntry ) );
396 if ( IsExpanded( pEntry ) )
397 Collapse( pEntry );
398 else
399 Expand( pEntry );
401 else
402 ContentDoubleClickHdl(0); // select content as if double clicked
405 bUsed = TRUE;
407 break;
410 StoreSettings();
412 if( !bUsed )
413 SvTreeListBox::KeyInput(rKEvt);
416 //BOOL __EXPORT ScContentTree::Drop( const DropEvent& rEvt )
418 // return pParentWindow->Drop(rEvt); // Drop auf Navigator
421 //BOOL __EXPORT ScContentTree::QueryDrop( DropEvent& rEvt )
423 // return pParentWindow->QueryDrop(rEvt); // Drop auf Navigator
426 sal_Int8 ScContentTree::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
428 return DND_ACTION_NONE;
431 sal_Int8 ScContentTree::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
433 return DND_ACTION_NONE;
436 void ScContentTree::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
438 DoDrag();
441 void ScContentTree::DragFinished( sal_Int8 /* nAction */ )
445 void __EXPORT ScContentTree::Command( const CommandEvent& rCEvt )
447 BOOL bDone = FALSE;
449 switch ( rCEvt.GetCommand() )
451 case COMMAND_STARTDRAG:
452 // Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
453 // (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
454 // den StarView MouseMove-Handler, der Command() aufruft, umbringen.
455 // Deshalb Drag&Drop asynchron:
457 // DoDrag();
459 Application::PostUserEvent( STATIC_LINK( this, ScContentTree, ExecDragHdl ) );
461 bDone = TRUE;
462 break;
464 case COMMAND_CONTEXTMENU:
466 // Drag-Drop Modus
468 PopupMenu aPop;
469 ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
470 aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
471 aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
472 aPop.SetPopupMenu( 1, &aDropMenu );
474 // angezeigtes Dokument
476 ScPopupMenu aDocMenu;
477 aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
478 USHORT i=0;
479 USHORT nPos=0;
480 // geladene Dokumente
481 ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
482 SfxObjectShell* pSh = SfxObjectShell::GetFirst();
483 while ( pSh )
485 if ( pSh->ISA(ScDocShell) )
487 String aName = pSh->GetTitle();
488 String aEntry = aName;
489 if ( pSh == pCurrentSh )
490 aEntry += pParentWindow->aStrActive;
491 else
492 aEntry += pParentWindow->aStrNotActive;
493 aDocMenu.InsertItem( ++i, aEntry );
494 if ( !bHiddenDoc && aName == aManualDoc )
495 nPos = i;
497 pSh = SfxObjectShell::GetNext( *pSh );
499 // "aktives Fenster"
500 aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
501 if (!bHiddenDoc && !aManualDoc.Len())
502 nPos = i;
503 // verstecktes Dokument
504 if ( aHiddenTitle.Len() )
506 String aEntry = aHiddenTitle;
507 aEntry += pParentWindow->aStrHidden;
508 aDocMenu.InsertItem( ++i, aEntry );
509 if (bHiddenDoc)
510 nPos = i;
512 aDocMenu.CheckItem( nPos );
513 aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
514 aPop.SetPopupMenu( 2, &aDocMenu );
516 // ausfuehren
518 aPop.Execute( this, rCEvt.GetMousePosPixel() );
520 if ( aDropMenu.WasHit() ) // Drag-Drop Modus
522 USHORT nId = aDropMenu.GetSelected();
523 if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
524 pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
526 else if ( aDocMenu.WasHit() ) // angezeigtes Dokument
528 USHORT nId = aDocMenu.GetSelected();
529 String aName = aDocMenu.GetItemText(nId);
530 SelectDoc( aName );
533 break;
536 if (!bDone)
537 SvTreeListBox::Command(rCEvt);
540 void __EXPORT ScContentTree::RequestHelp( const HelpEvent& rHEvt )
542 BOOL bDone = FALSE;
543 if( rHEvt.GetMode() & HELPMODE_QUICK )
545 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
546 SvLBoxEntry* pEntry = GetEntry( aPos );
547 if ( pEntry )
549 BOOL bRet = FALSE;
550 String aHelpText;
551 SvLBoxEntry* pParent = GetParent(pEntry);
552 if ( !pParent ) // Top-Level ?
554 aHelpText = String::CreateFromInt32( GetChildCount(pEntry) );
555 aHelpText += ' ';
556 aHelpText += GetEntryText(pEntry);
557 bRet = TRUE;
559 else if ( pParent == pRootNodes[SC_CONTENT_NOTE] )
561 aHelpText = GetEntryText(pEntry); // Notizen als Help-Text
562 bRet = TRUE;
564 else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] )
566 ULONG nIndex = GetChildIndex(pEntry);
567 if( nIndex != SC_CONTENT_NOCHILD )
569 const ScAreaLink* pLink = GetLink(nIndex);
570 if (pLink)
572 aHelpText = pLink->GetFile(); // Source-Datei als Help-Text
573 bRet = TRUE;
578 if (bRet)
580 SvLBoxTab* pTab;
581 SvLBoxString* pItem = (SvLBoxString*)(GetItem( pEntry, aPos.X(), &pTab ));
582 if( pItem )
584 aPos = GetEntryPosition( pEntry );
585 aPos.X() = GetTabPos( pEntry, pTab );
586 aPos = OutputToScreenPixel(aPos);
587 Size aSize( pItem->GetSize( this, pEntry ) );
589 Rectangle aItemRect( aPos, aSize );
590 Help::ShowQuickHelp( this, aItemRect, aHelpText );
591 bDone = TRUE;
596 if (!bDone)
597 Window::RequestHelp( rHEvt );
600 ScDocument* ScContentTree::GetSourceDocument()
602 if (bHiddenDoc)
603 return pHiddenDocument;
604 else
606 ScDocShell* pSh = GetManualOrCurrent();
607 if (pSh)
608 return pSh->GetDocument();
611 return NULL;
614 void ScContentTree::Refresh( USHORT nType )
616 if ( bHiddenDoc && !pHiddenDocument )
617 return; // anderes Dokument angezeigt
619 // wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
621 if ( nType == SC_CONTENT_NOTE )
622 if (!NoteStringsChanged())
623 return;
624 if ( nType == SC_CONTENT_GRAPHIC )
625 if (!DrawNamesChanged(SC_CONTENT_GRAPHIC))
626 return;
627 if ( nType == SC_CONTENT_OLEOBJECT )
628 if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT))
629 return;
630 if ( nType == SC_CONTENT_DRAWING )
631 if (!DrawNamesChanged(SC_CONTENT_DRAWING))
632 return;
634 SetUpdateMode(FALSE);
636 ClearType( nType );
638 if ( !nType || nType == SC_CONTENT_TABLE )
639 GetTableNames();
640 if ( !nType || nType == SC_CONTENT_RANGENAME )
641 GetAreaNames();
642 if ( !nType || nType == SC_CONTENT_DBAREA )
643 GetDbNames();
644 if ( !nType || nType == SC_CONTENT_GRAPHIC )
645 GetGraphicNames();
646 if ( !nType || nType == SC_CONTENT_OLEOBJECT )
647 GetOleNames();
648 if ( !nType || nType == SC_CONTENT_DRAWING )
649 GetDrawingNames();
650 if ( !nType || nType == SC_CONTENT_NOTE )
651 GetNoteStrings();
652 if ( !nType || nType == SC_CONTENT_AREALINK )
653 GetLinkNames();
655 ApplySettings();
656 SetUpdateMode(TRUE);
659 void ScContentTree::GetTableNames()
661 if ( nRootType && nRootType != SC_CONTENT_TABLE ) // ausgeblendet ?
662 return;
664 ScDocument* pDoc = GetSourceDocument();
665 if (!pDoc)
666 return;
668 String aName;
669 SCTAB nCount = pDoc->GetTableCount();
670 for ( SCTAB i=0; i<nCount; i++ )
672 pDoc->GetName( i, aName );
673 InsertContent( SC_CONTENT_TABLE, aName );
677 void ScContentTree::GetAreaNames()
679 if ( nRootType && nRootType != SC_CONTENT_RANGENAME ) // ausgeblendet ?
680 return;
682 ScDocument* pDoc = GetSourceDocument();
683 if (!pDoc)
684 return;
686 ScRangeName* pRangeNames = pDoc->GetRangeName();
687 USHORT nCount = pRangeNames->GetCount();
688 if ( nCount > 0 )
690 USHORT nValidCount = 0;
691 ScRange aDummy;
692 USHORT i;
693 for ( i=0; i<nCount; i++ )
695 ScRangeData* pData = (*pRangeNames)[i];
696 if (pData->IsValidReference(aDummy))
697 nValidCount++;
699 if ( nValidCount )
701 ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
702 USHORT j;
703 for ( i=0, j=0; i<nCount; i++ )
705 ScRangeData* pData = (*pRangeNames)[i];
706 if (pData->IsValidReference(aDummy))
707 ppSortArray[j++] = pData;
709 #ifndef ICC
710 qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
711 &ScRangeData_QsortNameCompare );
712 #else
713 qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
714 ICCQsortNameCompare );
715 #endif
716 for ( j=0; j<nValidCount; j++ )
717 InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
718 delete [] ppSortArray;
723 void ScContentTree::GetDbNames()
725 if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ?
726 return;
728 ScDocument* pDoc = GetSourceDocument();
729 if (!pDoc)
730 return;
732 ScDBCollection* pDbNames = pDoc->GetDBCollection();
733 USHORT nCount = pDbNames->GetCount();
734 if ( nCount > 0 )
736 String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) );
737 for ( USHORT i=0; i<nCount; i++ )
739 ScDBData* pData = (*pDbNames)[i];
740 String aStrName = pData->GetName();
741 if ( aStrName != aStrNoName )
742 InsertContent( SC_CONTENT_DBAREA, aStrName );
747 bool ScContentTree::IsPartOfType( USHORT nContentType, USHORT nObjIdentifier ) // static
749 bool bRet = false;
750 switch ( nContentType )
752 case SC_CONTENT_GRAPHIC:
753 bRet = ( nObjIdentifier == OBJ_GRAF );
754 break;
755 case SC_CONTENT_OLEOBJECT:
756 bRet = ( nObjIdentifier == OBJ_OLE2 );
757 break;
758 case SC_CONTENT_DRAWING:
759 bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 ); // everything else
760 break;
761 default:
762 DBG_ERROR("unknown content type");
764 return bRet;
767 void ScContentTree::GetDrawNames( USHORT nType )
769 if ( nRootType && nRootType != nType ) // ausgeblendet ?
770 return;
772 ScDocument* pDoc = GetSourceDocument();
773 if (!pDoc)
774 return;
776 // iterate in flat mode for groups
777 SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
779 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
780 SfxObjectShell* pShell = pDoc->GetDocumentShell();
781 if (pDrawLayer && pShell)
783 SCTAB nTabCount = pDoc->GetTableCount();
784 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
786 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
787 DBG_ASSERT(pPage,"Page ?");
788 if (pPage)
790 SdrObjListIter aIter( *pPage, eIter );
791 SdrObject* pObject = aIter.Next();
792 while (pObject)
794 if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
796 String aName = ScDrawLayer::GetVisibleName( pObject );
797 if (aName.Len())
798 InsertContent( nType, aName );
801 pObject = aIter.Next();
808 void ScContentTree::GetGraphicNames()
810 GetDrawNames( SC_CONTENT_GRAPHIC );
813 void ScContentTree::GetOleNames()
815 GetDrawNames( SC_CONTENT_OLEOBJECT );
818 void ScContentTree::GetDrawingNames()
820 GetDrawNames( SC_CONTENT_DRAWING );
823 void ScContentTree::GetLinkNames()
825 if ( nRootType && nRootType != SC_CONTENT_AREALINK ) // ausgeblendet ?
826 return;
828 ScDocument* pDoc = GetSourceDocument();
829 if (!pDoc)
830 return;
832 SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
833 DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
834 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
835 USHORT nCount = rLinks.Count();
836 for (USHORT i=0; i<nCount; i++)
838 ::sfx2::SvBaseLink* pBase = *rLinks[i];
839 if (pBase->ISA(ScAreaLink))
840 InsertContent( SC_CONTENT_AREALINK, ((ScAreaLink*)pBase)->GetSource() );
842 // in der Liste die Namen der Quellbereiche
846 const ScAreaLink* ScContentTree::GetLink( ULONG nIndex )
848 ScDocument* pDoc = GetSourceDocument();
849 if (!pDoc)
850 return NULL;
852 ULONG nFound = 0;
853 SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
854 DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
855 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
856 USHORT nCount = rLinks.Count();
857 for (USHORT i=0; i<nCount; i++)
859 ::sfx2::SvBaseLink* pBase = *rLinks[i];
860 if (pBase->ISA(ScAreaLink))
862 if (nFound == nIndex)
863 return (const ScAreaLink*) pBase;
864 ++nFound;
868 DBG_ERROR("Link nicht gefunden");
869 return NULL;
872 String lcl_NoteString( const ScPostIt& rNote )
874 String aText = rNote.GetText();
875 xub_StrLen nAt;
876 while ( (nAt = aText.Search( '\n' )) != STRING_NOTFOUND )
877 aText.SetChar( nAt, ' ' );
878 return aText;
881 void ScContentTree::GetNoteStrings()
883 if ( nRootType && nRootType != SC_CONTENT_NOTE ) // ausgeblendet ?
884 return;
886 ScDocument* pDoc = GetSourceDocument();
887 if (!pDoc)
888 return;
890 SCTAB nTabCount = pDoc->GetTableCount();
891 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
893 ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
894 for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
895 if( const ScPostIt* pNote = pCell->GetNote() )
896 InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) );
900 ScAddress ScContentTree::GetNotePos( ULONG nIndex )
902 ScDocument* pDoc = GetSourceDocument();
903 if (!pDoc)
904 return ScAddress();
906 ULONG nFound = 0;
907 SCTAB nTabCount = pDoc->GetTableCount();
908 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
910 ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
911 ScBaseCell* pCell = aIter.GetFirst();
912 while (pCell)
914 if( pCell->HasNote() )
916 if (nFound == nIndex)
917 return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden
918 ++nFound;
920 pCell = aIter.GetNext();
924 DBG_ERROR("Notiz nicht gefunden");
925 return ScAddress();
928 BOOL ScContentTree::NoteStringsChanged()
930 ScDocument* pDoc = GetSourceDocument();
931 if (!pDoc)
932 return FALSE;
934 SvLBoxEntry* pParent = pRootNodes[SC_CONTENT_NOTE];
935 if (!pParent)
936 return FALSE;
938 SvLBoxEntry* pEntry = FirstChild( pParent );
940 BOOL bEqual = TRUE;
941 SCTAB nTabCount = pDoc->GetTableCount();
942 for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
944 ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
945 ScBaseCell* pCell = aIter.GetFirst();
946 while (pCell && bEqual)
948 if( const ScPostIt* pNote = pCell->GetNote() )
950 if ( !pEntry )
951 bEqual = FALSE;
952 else
954 if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
955 bEqual = FALSE;
957 pEntry = NextSibling( pEntry );
960 pCell = aIter.GetNext();
964 if ( pEntry )
965 bEqual = FALSE; // kommt noch was
967 return !bEqual;
970 BOOL ScContentTree::DrawNamesChanged( USHORT nType )
972 ScDocument* pDoc = GetSourceDocument();
973 if (!pDoc)
974 return FALSE;
976 SvLBoxEntry* pParent = pRootNodes[nType];
977 if (!pParent)
978 return FALSE;
980 SvLBoxEntry* pEntry = FirstChild( pParent );
982 // iterate in flat mode for groups
983 SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
985 BOOL bEqual = TRUE;
986 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
987 SfxObjectShell* pShell = pDoc->GetDocumentShell();
988 if (pDrawLayer && pShell)
990 SCTAB nTabCount = pDoc->GetTableCount();
991 for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
993 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
994 DBG_ASSERT(pPage,"Page ?");
995 if (pPage)
997 SdrObjListIter aIter( *pPage, eIter );
998 SdrObject* pObject = aIter.Next();
999 while (pObject && bEqual)
1001 if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
1003 if ( !pEntry )
1004 bEqual = FALSE;
1005 else
1007 if ( ScDrawLayer::GetVisibleName( pObject ) != GetEntryText(pEntry) )
1008 bEqual = FALSE;
1010 pEntry = NextSibling( pEntry );
1013 pObject = aIter.Next();
1019 if ( pEntry )
1020 bEqual = FALSE; // kommt noch was
1022 return !bEqual;
1025 BOOL lcl_GetRange( ScDocument* pDoc, USHORT nType, const String& rName, ScRange& rRange )
1027 BOOL bFound = FALSE;
1028 USHORT nPos;
1030 if ( nType == SC_CONTENT_RANGENAME )
1032 ScRangeName* pList = pDoc->GetRangeName();
1033 if (pList)
1034 if (pList->SearchName( rName, nPos ))
1035 if ( (*pList)[nPos]->IsValidReference( rRange ) )
1036 bFound = TRUE;
1038 else if ( nType == SC_CONTENT_DBAREA )
1040 ScDBCollection* pList = pDoc->GetDBCollection();
1041 if (pList)
1042 if (pList->SearchName( rName, nPos ))
1044 SCTAB nTab;
1045 SCCOL nCol1, nCol2;
1046 SCROW nRow1, nRow2;
1047 (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
1048 rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
1049 bFound = TRUE;
1053 return bFound;
1056 void lcl_DoDragObject( ScDocShell* pSrcShell, const String& rName, USHORT nType, Window* pWin )
1058 ScDocument* pSrcDoc = pSrcShell->GetDocument();
1059 ScDrawLayer* pModel = pSrcDoc->GetDrawLayer();
1060 if (pModel)
1062 BOOL bOle = ( nType == SC_CONTENT_OLEOBJECT );
1063 BOOL bGraf = ( nType == SC_CONTENT_GRAPHIC );
1064 USHORT nDrawId = sal::static_int_cast<USHORT>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) );
1065 SCTAB nTab = 0;
1066 SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab );
1067 if (pObject)
1069 SdrView aEditView( pModel );
1070 aEditView.ShowSdrPage(aEditView.GetModel()->GetPage(nTab));
1071 SdrPageView* pPV = aEditView.GetSdrPageView();
1072 aEditView.MarkObj(pObject, pPV);
1074 SdrModel* pDragModel = aEditView.GetAllMarkedModel();
1076 TransferableObjectDescriptor aObjDesc;
1077 pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1078 aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1079 // maSize is set in ScDrawTransferObj ctor
1081 ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc );
1082 uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1084 pTransferObj->SetDragSourceObj( pObject, nTab );
1085 pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
1087 SC_MOD()->SetDragObject( NULL, pTransferObj );
1088 pWin->ReleaseMouse();
1089 pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1094 void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, USHORT nFlags, Window* pWin )
1096 ScMarkData aMark;
1097 aMark.SelectTable( rRange.aStart.Tab(), TRUE );
1098 aMark.SetMarkArea( rRange );
1100 ScDocument* pSrcDoc = pSrcShell->GetDocument();
1101 if ( !pSrcDoc->HasSelectedBlockMatrixFragment( rRange.aStart.Col(), rRange.aStart.Row(),
1102 rRange.aEnd.Col(), rRange.aEnd.Row(),
1103 aMark ) )
1105 ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
1106 pSrcDoc->CopyToClip( rRange.aStart.Col(), rRange.aStart.Row(),
1107 rRange.aEnd.Col(), rRange.aEnd.Row(),
1108 FALSE, pClipDoc, FALSE, &aMark );
1109 // pClipDoc->ExtendMerge( rRange, TRUE );
1111 TransferableObjectDescriptor aObjDesc;
1112 pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1113 aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1114 // maSize is set in ScTransferObj ctor
1116 ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
1117 uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1119 pTransferObj->SetDragSource( pSrcShell, aMark );
1120 pTransferObj->SetDragSourceFlags( nFlags );
1122 SC_MOD()->SetDragObject( pTransferObj, NULL ); // for internal D&D
1123 pWin->ReleaseMouse();
1124 pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1128 void ScContentTree::DoDrag()
1130 ScDocumentLoader* pDocLoader = NULL;
1131 bIsInDrag = TRUE;
1133 ScModule* pScMod = SC_MOD();
1135 USHORT nType;
1136 ULONG nChild;
1137 SvLBoxEntry* pEntry = GetCurEntry();
1138 GetEntryIndexes( nType, nChild, pEntry );
1140 if( pEntry &&
1141 (nChild != SC_CONTENT_NOCHILD) &&
1142 (nType != SC_CONTENT_ROOT) &&
1143 (nType != SC_CONTENT_NOTE) &&
1144 (nType != SC_CONTENT_AREALINK) )
1146 String aText( GetEntryText( pEntry ) );
1148 ScDocument* pLocalDoc = NULL; // fuer URL-Drop
1149 String aDocName;
1150 if (bHiddenDoc)
1151 aDocName = aHiddenName;
1152 else
1154 ScDocShell* pDocSh = GetManualOrCurrent();
1155 if (pDocSh)
1157 if (pDocSh->HasName())
1158 aDocName = pDocSh->GetMedium()->GetName();
1159 else
1160 pLocalDoc = pDocSh->GetDocument(); // Drop nur in dieses Dokument
1164 BOOL bDoLinkTrans = FALSE; // use ScLinkTransferObj
1165 String aLinkURL; // for ScLinkTransferObj
1166 String aLinkText;
1168 USHORT nDropMode = pParentWindow->GetDropMode();
1169 switch ( nDropMode )
1171 case SC_DROPMODE_URL:
1173 String aUrl = aDocName;
1174 aUrl += '#';
1175 aUrl += aText;
1177 pScMod->SetDragJump( pLocalDoc, aUrl, aText );
1179 if (aDocName.Len())
1181 // provide URL to outside only if the document has a name
1182 // (without name, only internal D&D via SetDragJump)
1184 aLinkURL = aUrl;
1185 aLinkText = aText;
1187 bDoLinkTrans = TRUE;
1189 break;
1190 case SC_DROPMODE_LINK:
1192 if ( aDocName.Len() ) // link only to named documents
1194 // for internal D&D, set flag to insert a link
1196 switch ( nType )
1198 case SC_CONTENT_TABLE:
1199 pScMod->SetDragLink( aDocName, aText, EMPTY_STRING );
1200 bDoLinkTrans = TRUE;
1201 break;
1202 case SC_CONTENT_RANGENAME:
1203 case SC_CONTENT_DBAREA:
1204 pScMod->SetDragLink( aDocName, EMPTY_STRING, aText );
1205 bDoLinkTrans = TRUE;
1206 break;
1208 // other types cannot be linked
1212 break;
1213 case SC_DROPMODE_COPY:
1215 ScDocShell* pSrcShell = NULL;
1216 if ( bHiddenDoc )
1218 String aFilter, aOptions;
1219 pDocLoader = new ScDocumentLoader( aHiddenName, aFilter, aOptions );
1220 if (!pDocLoader->IsError())
1221 pSrcShell = pDocLoader->GetDocShell();
1223 else
1224 pSrcShell = GetManualOrCurrent();
1226 if ( pSrcShell )
1228 ScDocument* pSrcDoc = pSrcShell->GetDocument();
1229 if ( nType == SC_CONTENT_RANGENAME || nType == SC_CONTENT_DBAREA )
1231 ScRange aRange;
1232 if ( lcl_GetRange( pSrcDoc, nType, aText, aRange ) )
1234 lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this );
1237 else if ( nType == SC_CONTENT_TABLE )
1239 SCTAB nTab;
1240 if ( pSrcDoc->GetTable( aText, nTab ) )
1242 ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab );
1243 lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this );
1246 else if ( nType == SC_CONTENT_GRAPHIC || nType == SC_CONTENT_OLEOBJECT ||
1247 nType == SC_CONTENT_DRAWING )
1249 lcl_DoDragObject( pSrcShell, aText, nType, this );
1251 // in ExecuteDrag kann der Navigator geloescht worden sein
1252 // -> nicht mehr auf Member zugreifen !!!
1256 break;
1259 if (bDoLinkTrans)
1261 ScLinkTransferObj* pTransferObj = new ScLinkTransferObj;
1262 uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1264 if ( aLinkURL.Len() )
1265 pTransferObj->SetLinkURL( aLinkURL, aLinkText );
1267 // SetDragJump / SetDragLink has been done above
1269 ReleaseMouse();
1270 pTransferObj->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1274 bIsInDrag = FALSE; // static Member
1276 delete pDocLoader; // falls Dokument zum Draggen geladen wurde
1279 IMPL_STATIC_LINK(ScContentTree, ExecDragHdl, void*, EMPTYARG)
1281 // als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1282 // Navigator geloescht werden darf
1284 pThis->DoDrag();
1285 return 0;
1288 //UNUSED2008-05 void ScContentTree::AdjustTitle()
1289 //UNUSED2008-05 {
1290 //UNUSED2008-05 String aTitle = pParentWindow->aTitleBase;
1291 //UNUSED2008-05 if (bHiddenDoc)
1292 //UNUSED2008-05 {
1293 //UNUSED2008-05 aTitle.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
1294 //UNUSED2008-05 aTitle += aHiddenTitle;
1295 //UNUSED2008-05 }
1296 //UNUSED2008-05 pParentWindow->SetText(aTitle);
1297 //UNUSED2008-05 }
1299 BOOL ScContentTree::LoadFile( const String& rUrl )
1301 String aDocName = rUrl;
1302 xub_StrLen nPos = aDocName.Search('#');
1303 if ( nPos != STRING_NOTFOUND )
1304 aDocName.Erase(nPos); // nur der Name, ohne #...
1306 BOOL bReturn = FALSE;
1307 String aFilter, aOptions;
1308 ScDocumentLoader aLoader( aDocName, aFilter, aOptions );
1309 if ( !aLoader.IsError() )
1311 bHiddenDoc = TRUE;
1312 aHiddenName = aDocName;
1313 aHiddenTitle = aLoader.GetTitle();
1314 pHiddenDocument = aLoader.GetDocument();
1316 Refresh(); // Inhalte aus geladenem Dokument holen
1318 pHiddenDocument = NULL;
1319 // AdjustTitle();
1321 pParentWindow->GetDocNames( &aHiddenTitle ); // Liste fuellen
1323 else
1324 Sound::Beep(); // Fehler beim Laden
1326 // Dokument wird im dtor von ScDocumentLoader wieder geschlossen
1328 return bReturn;
1331 void ScContentTree::InitWindowBits( BOOL bButtons )
1333 WinBits nFlags = WB_CLIPCHILDREN|WB_HSCROLL;
1334 if (bButtons)
1335 nFlags |= WB_HASBUTTONS|WB_HASBUTTONSATROOT;
1337 SetWindowBits( nFlags );
1340 void ScContentTree::SetRootType( USHORT nNew )
1342 if ( nNew != nRootType )
1344 nRootType = nNew;
1345 InitWindowBits( nNew == 0 );
1346 Refresh();
1348 ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
1349 rCfg.SetRootType( nRootType );
1353 void ScContentTree::ToggleRoot() // nach Selektion
1355 USHORT nNew = SC_CONTENT_ROOT;
1356 if ( nRootType == SC_CONTENT_ROOT )
1358 SvLBoxEntry* pEntry = GetCurEntry();
1359 if (pEntry)
1361 SvLBoxEntry* pParent = GetParent(pEntry);
1362 for (USHORT i=1; i<SC_CONTENT_COUNT; i++)
1363 if ( pEntry == pRootNodes[i] || pParent == pRootNodes[i] )
1364 nNew = i;
1368 SetRootType( nNew );
1371 void ScContentTree::ResetManualDoc()
1373 aManualDoc.Erase();
1374 bHiddenDoc = FALSE;
1376 ActiveDocChanged();
1379 void ScContentTree::ActiveDocChanged()
1381 if ( !bHiddenDoc && !aManualDoc.Len() )
1382 Refresh(); // Inhalte nur wenn automatisch
1384 // Listbox muss immer geupdated werden, wegen aktiv-Flag
1386 String aCurrent;
1387 if ( bHiddenDoc )
1388 aCurrent = aHiddenTitle;
1389 else
1391 ScDocShell* pSh = GetManualOrCurrent();
1392 if (pSh)
1393 aCurrent = pSh->GetTitle();
1394 else
1396 // eingestelltes Dokument existiert nicht mehr
1398 aManualDoc.Erase(); // wieder automatisch
1399 Refresh();
1400 pSh = GetManualOrCurrent(); // sollte jetzt aktives sein
1401 if (pSh)
1402 aCurrent = pSh->GetTitle();
1405 pParentWindow->GetDocNames( &aCurrent ); // selektieren
1408 void ScContentTree::SetManualDoc(const String& rName)
1410 aManualDoc = rName;
1411 if (!bHiddenDoc)
1413 Refresh();
1414 pParentWindow->GetDocNames( &aManualDoc ); // selektieren
1418 void ScContentTree::SelectDoc(const String& rName) // rName wie im Menue/Listbox angezeigt
1420 if ( rName == pParentWindow->aStrActiveWin )
1422 ResetManualDoc();
1423 return;
1426 // "aktiv" oder "inaktiv" weglassen
1428 String aRealName = rName;
1429 xub_StrLen nLen = rName.Len();
1430 xub_StrLen nActiveStart = nLen - pParentWindow->aStrActive.Len();
1431 if ( rName.Copy( nActiveStart ) == pParentWindow->aStrActive )
1432 aRealName = rName.Copy( 0, nActiveStart );
1433 xub_StrLen nNotActiveStart = nLen - pParentWindow->aStrNotActive.Len();
1434 if ( rName.Copy( nNotActiveStart ) == pParentWindow->aStrNotActive )
1435 aRealName = rName.Copy( 0, nNotActiveStart );
1439 BOOL bLoaded = FALSE;
1441 // ist es ein normal geladenes Doc ?
1443 SfxObjectShell* pSh = SfxObjectShell::GetFirst();
1444 while ( pSh && !bLoaded )
1446 if ( pSh->ISA(ScDocShell) )
1447 if ( pSh->GetTitle() == aRealName )
1448 bLoaded = TRUE;
1449 pSh = SfxObjectShell::GetNext( *pSh );
1452 if (bLoaded)
1454 bHiddenDoc = FALSE;
1455 SetManualDoc(aRealName);
1457 else if (aHiddenTitle.Len()) // verstecktes ausgewaehlt
1459 if (!bHiddenDoc)
1460 LoadFile(aHiddenName);
1462 else
1464 DBG_ERROR("SelectDoc: nicht gefunden");
1468 void ScContentTree::ApplySettings()
1470 const ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
1471 if( pSettings )
1473 USHORT nRootSel = pSettings->GetRootSelected();
1474 ULONG nChildSel = pSettings->GetChildSelected();
1476 for( USHORT nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
1478 if( pRootNodes[ nEntry ] )
1480 // expand
1481 BOOL bExp = pSettings->IsExpanded( nEntry );
1482 if( bExp != IsExpanded( pRootNodes[ nEntry ] ) )
1484 if( bExp )
1485 Expand( pRootNodes[ nEntry ] );
1486 else
1487 Collapse( pRootNodes[ nEntry ] );
1490 // select
1491 if( nRootSel == nEntry )
1493 SvLBoxEntry* pEntry = NULL;
1494 if( bExp && (nChildSel != SC_CONTENT_NOCHILD) )
1495 pEntry = GetEntry( pRootNodes[ nEntry ], nChildSel );
1496 Select( pEntry ? pEntry : pRootNodes[ nEntry ] );
1503 void ScContentTree::StoreSettings() const
1505 ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
1506 if( pSettings )
1508 for( USHORT nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
1510 BOOL bExp = pRootNodes[ nEntry ] && IsExpanded( pRootNodes[ nEntry ] );
1511 pSettings->SetExpanded( nEntry, bExp );
1513 USHORT nRoot;
1514 ULONG nChild;
1515 GetEntryIndexes( nRoot, nChild, GetCurEntry() );
1516 pSettings->SetRootSelected( nRoot );
1517 pSettings->SetChildSelected( nChild );
1523 //------------------------------------------------------------------------