merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / navipi / content.cxx
blob78fefb39de11c3b5fface3e3e5f0e0cb4671ae37
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"
74 #include "clipparam.hxx"
76 using namespace com::sun::star;
78 // Reihenfolge der Kategorien im Navigator -------------------------------------
80 static USHORT pTypeList[SC_CONTENT_COUNT] =
82 SC_CONTENT_ROOT, // ROOT (0) muss vorne stehen
83 SC_CONTENT_TABLE,
84 SC_CONTENT_RANGENAME,
85 SC_CONTENT_DBAREA,
86 SC_CONTENT_AREALINK,
87 SC_CONTENT_GRAPHIC,
88 SC_CONTENT_OLEOBJECT,
89 SC_CONTENT_NOTE,
90 SC_CONTENT_DRAWING
93 BOOL ScContentTree::bIsInDrag = FALSE;
96 ScDocShell* ScContentTree::GetManualOrCurrent()
98 ScDocShell* pSh = NULL;
99 if ( aManualDoc.Len() )
101 TypeId aScType = TYPE(ScDocShell);
102 SfxObjectShell* pObjSh = SfxObjectShell::GetFirst( &aScType );
103 while ( pObjSh && !pSh )
105 if ( pObjSh->GetTitle() == aManualDoc )
106 pSh = PTR_CAST( ScDocShell, pObjSh );
107 pObjSh = SfxObjectShell::GetNext( *pObjSh, &aScType );
110 else
112 // Current nur, wenn keine manuell eingestellt ist
113 // (damit erkannt wird, wenn das Dokument nicht mehr existiert)
115 SfxViewShell* pViewSh = SfxViewShell::Current();
116 if ( pViewSh )
118 SfxObjectShell* pObjSh = pViewSh->GetViewFrame()->GetObjectShell();
119 pSh = PTR_CAST( ScDocShell, pObjSh );
123 return pSh;
127 // ScContentTree
130 ScContentTree::ScContentTree( Window* pParent, const ResId& rResId ) :
131 SvTreeListBox ( pParent, rResId ),
132 aEntryImages ( ScResId( RID_IMAGELIST_NAVCONT ) ),
133 aHCEntryImages ( ScResId( RID_IMAGELIST_H_NAVCONT ) ),
134 nRootType ( SC_CONTENT_ROOT ),
135 bHiddenDoc ( FALSE ),
136 pHiddenDocument ( NULL )
138 USHORT i;
139 for (i=0; i<SC_CONTENT_COUNT; i++)
140 pPosList[pTypeList[i]] = i; // invers zum suchen
142 pParentWindow = (ScNavigatorDlg*)pParent;
144 pRootNodes[0] = NULL;
145 for (i=1; i<SC_CONTENT_COUNT; i++)
146 InitRoot(i);
148 SetNodeDefaultImages();
150 SetDoubleClickHdl( LINK( this, ScContentTree, ContentDoubleClickHdl ) );
153 ScContentTree::~ScContentTree()
157 void ScContentTree::InitRoot( USHORT nType )
159 if ( !nType )
160 return;
162 if ( nRootType && nRootType != nType ) // ausgeblendet ?
164 pRootNodes[nType] = NULL;
165 return;
168 const Image& rImage = aEntryImages.GetImage( nType );
169 String aName( ScResId( SCSTR_CONTENT_ROOT + nType ) );
170 // wieder an die richtige Position:
171 USHORT nPos = nRootType ? 0 : pPosList[nType]-1;
172 SvLBoxEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, FALSE, nPos );
174 const Image& rHCImage = aHCEntryImages.GetImage( nType );
175 SetExpandedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
176 SetCollapsedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
178 pRootNodes[nType] = pNew;
181 void ScContentTree::ClearAll()
183 Clear();
184 for (USHORT i=1; i<SC_CONTENT_COUNT; i++)
185 InitRoot(i);
188 void ScContentTree::ClearType(USHORT nType)
190 if (!nType)
191 ClearAll();
192 else
194 SvLBoxEntry* pParent = pRootNodes[nType];
195 if ( !pParent || GetChildCount(pParent) ) // nicht, wenn ohne Children schon da
197 if (pParent)
198 GetModel()->Remove( pParent ); // mit allen Children
199 InitRoot( nType ); // ggf. neu eintragen
204 void ScContentTree::InsertContent( USHORT nType, const String& rValue )
206 if (nType >= SC_CONTENT_COUNT)
208 DBG_ERROR("ScContentTree::InsertContent mit falschem Typ");
209 return;
212 SvLBoxEntry* pParent = pRootNodes[nType];
213 if (pParent)
214 InsertEntry( rValue, pParent );
215 else
217 DBG_ERROR("InsertContent ohne Parent");
221 void ScContentTree::GetEntryIndexes( USHORT& rnRootIndex, ULONG& rnChildIndex, SvLBoxEntry* pEntry ) const
223 rnRootIndex = SC_CONTENT_ROOT;
224 rnChildIndex = SC_CONTENT_NOCHILD;
226 if( !pEntry )
227 return;
229 SvLBoxEntry* pParent = GetParent( pEntry );
230 bool bFound = false;
231 for( USHORT nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot )
233 if( pEntry == pRootNodes[ nRoot ] )
235 rnRootIndex = nRoot;
236 rnChildIndex = ~0UL;
237 bFound = true;
239 else if( pParent && (pParent == pRootNodes[ nRoot ]) )
241 rnRootIndex = nRoot;
243 // search the entry in all child entries of the parent
244 ULONG nEntry = 0;
245 SvLBoxEntry* pIterEntry = FirstChild( pParent );
246 while( !bFound && pIterEntry )
248 if ( pEntry == pIterEntry )
250 rnChildIndex = nEntry;
251 bFound = true; // exit the while loop
253 pIterEntry = NextSibling( pIterEntry );
254 ++nEntry;
257 bFound = true; // exit the for loop
262 ULONG ScContentTree::GetChildIndex( SvLBoxEntry* pEntry ) const
264 USHORT nRoot;
265 ULONG nChild;
266 GetEntryIndexes( nRoot, nChild, pEntry );
267 return nChild;
270 String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
272 String aRet;
273 if (pDoc)
275 ScDBCollection* pDbNames = pDoc->GetDBCollection();
276 USHORT nCount = pDbNames->GetCount();
277 for ( USHORT i=0; i<nCount; i++ )
279 ScDBData* pData = (*pDbNames)[i];
280 if ( pData->GetName() == rDBName )
282 ScRange aRange;
283 pData->GetArea(aRange);
284 aRange.Format( aRet, SCR_ABS_3D, pDoc );
285 break;
289 return aRet;
292 IMPL_LINK( ScContentTree, ContentDoubleClickHdl, ScContentTree *, EMPTYARG )
294 USHORT nType;
295 ULONG nChild;
296 SvLBoxEntry* pEntry = GetCurEntry();
297 GetEntryIndexes( nType, nChild, pEntry );
299 if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
301 if ( bHiddenDoc )
302 return 0; //! spaeter...
304 String aText( GetEntryText( pEntry ) );
306 if ( aManualDoc.Len() )
307 pParentWindow->SetCurrentDoc( aManualDoc );
309 switch( nType )
311 case SC_CONTENT_TABLE:
312 pParentWindow->SetCurrentTableStr( aText );
313 break;
315 case SC_CONTENT_RANGENAME:
316 pParentWindow->SetCurrentCellStr( aText );
317 break;
319 case SC_CONTENT_DBAREA:
321 // #47905# Wenn gleiche Bereichs- und DB-Namen existieren, wird
322 // bei SID_CURRENTCELL der Bereichsname genommen.
323 // DB-Bereiche darum direkt ueber die Adresse anspringen.
325 String aRangeStr = lcl_GetDBAreaRange( GetSourceDocument(), aText );
326 if (aRangeStr.Len())
327 pParentWindow->SetCurrentCellStr( aRangeStr );
329 break;
331 case SC_CONTENT_OLEOBJECT:
332 case SC_CONTENT_GRAPHIC:
333 case SC_CONTENT_DRAWING:
334 pParentWindow->SetCurrentObject( aText );
335 break;
337 case SC_CONTENT_NOTE:
339 ScAddress aPos = GetNotePos( nChild );
340 pParentWindow->SetCurrentTable( aPos.Tab() );
341 pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
343 break;
345 case SC_CONTENT_AREALINK:
347 const ScAreaLink* pLink = GetLink( nChild );
348 if( pLink )
350 ScRange aRange = pLink->GetDestArea();
351 String aRangeStr;
352 ScDocument* pSrcDoc = GetSourceDocument();
353 aRange.Format( aRangeStr, SCR_ABS_3D, pSrcDoc, pSrcDoc->GetAddressConvention() );
354 pParentWindow->SetCurrentCellStr( aRangeStr );
357 break;
360 ScNavigatorDlg::ReleaseFocus(); // set focus into document
363 return 0;
366 void ScContentTree::MouseButtonDown( const MouseEvent& rMEvt )
368 SvTreeListBox::MouseButtonDown( rMEvt );
369 StoreSettings();
372 void ScContentTree::KeyInput( const KeyEvent& rKEvt )
374 BOOL bUsed = FALSE;
376 const KeyCode aCode = rKEvt.GetKeyCode();
377 if (aCode.GetCode() == KEY_RETURN)
379 switch (aCode.GetModifier())
381 case KEY_MOD1:
382 ToggleRoot(); // toggle root mode (as in Writer)
383 bUsed = TRUE;
384 break;
385 case 0:
387 SvLBoxEntry* pEntry = GetCurEntry();
388 if( pEntry )
390 USHORT nType;
391 ULONG nChild;
392 GetEntryIndexes( nType, nChild, pEntry );
394 if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) )
396 String aText( GetEntryText( pEntry ) );
397 if ( IsExpanded( pEntry ) )
398 Collapse( pEntry );
399 else
400 Expand( pEntry );
402 else
403 ContentDoubleClickHdl(0); // select content as if double clicked
406 bUsed = TRUE;
408 break;
411 StoreSettings();
413 if( !bUsed )
414 SvTreeListBox::KeyInput(rKEvt);
417 //BOOL __EXPORT ScContentTree::Drop( const DropEvent& rEvt )
419 // return pParentWindow->Drop(rEvt); // Drop auf Navigator
422 //BOOL __EXPORT ScContentTree::QueryDrop( DropEvent& rEvt )
424 // return pParentWindow->QueryDrop(rEvt); // Drop auf Navigator
427 sal_Int8 ScContentTree::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
429 return DND_ACTION_NONE;
432 sal_Int8 ScContentTree::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
434 return DND_ACTION_NONE;
437 void ScContentTree::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
439 DoDrag();
442 void ScContentTree::DragFinished( sal_Int8 /* nAction */ )
446 void __EXPORT ScContentTree::Command( const CommandEvent& rCEvt )
448 BOOL bDone = FALSE;
450 switch ( rCEvt.GetCommand() )
452 case COMMAND_STARTDRAG:
453 // Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
454 // (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
455 // den StarView MouseMove-Handler, der Command() aufruft, umbringen.
456 // Deshalb Drag&Drop asynchron:
458 // DoDrag();
460 Application::PostUserEvent( STATIC_LINK( this, ScContentTree, ExecDragHdl ) );
462 bDone = TRUE;
463 break;
465 case COMMAND_CONTEXTMENU:
467 // Drag-Drop Modus
469 PopupMenu aPop;
470 ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
471 aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
472 aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
473 aPop.SetPopupMenu( 1, &aDropMenu );
475 // angezeigtes Dokument
477 ScPopupMenu aDocMenu;
478 aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
479 USHORT i=0;
480 USHORT nPos=0;
481 // geladene Dokumente
482 ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
483 SfxObjectShell* pSh = SfxObjectShell::GetFirst();
484 while ( pSh )
486 if ( pSh->ISA(ScDocShell) )
488 String aName = pSh->GetTitle();
489 String aEntry = aName;
490 if ( pSh == pCurrentSh )
491 aEntry += pParentWindow->aStrActive;
492 else
493 aEntry += pParentWindow->aStrNotActive;
494 aDocMenu.InsertItem( ++i, aEntry );
495 if ( !bHiddenDoc && aName == aManualDoc )
496 nPos = i;
498 pSh = SfxObjectShell::GetNext( *pSh );
500 // "aktives Fenster"
501 aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
502 if (!bHiddenDoc && !aManualDoc.Len())
503 nPos = i;
504 // verstecktes Dokument
505 if ( aHiddenTitle.Len() )
507 String aEntry = aHiddenTitle;
508 aEntry += pParentWindow->aStrHidden;
509 aDocMenu.InsertItem( ++i, aEntry );
510 if (bHiddenDoc)
511 nPos = i;
513 aDocMenu.CheckItem( nPos );
514 aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
515 aPop.SetPopupMenu( 2, &aDocMenu );
517 // ausfuehren
519 aPop.Execute( this, rCEvt.GetMousePosPixel() );
521 if ( aDropMenu.WasHit() ) // Drag-Drop Modus
523 USHORT nId = aDropMenu.GetSelected();
524 if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
525 pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
527 else if ( aDocMenu.WasHit() ) // angezeigtes Dokument
529 USHORT nId = aDocMenu.GetSelected();
530 String aName = aDocMenu.GetItemText(nId);
531 SelectDoc( aName );
534 break;
537 if (!bDone)
538 SvTreeListBox::Command(rCEvt);
541 void __EXPORT ScContentTree::RequestHelp( const HelpEvent& rHEvt )
543 BOOL bDone = FALSE;
544 if( rHEvt.GetMode() & HELPMODE_QUICK )
546 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
547 SvLBoxEntry* pEntry = GetEntry( aPos );
548 if ( pEntry )
550 BOOL bRet = FALSE;
551 String aHelpText;
552 SvLBoxEntry* pParent = GetParent(pEntry);
553 if ( !pParent ) // Top-Level ?
555 aHelpText = String::CreateFromInt32( GetChildCount(pEntry) );
556 aHelpText += ' ';
557 aHelpText += GetEntryText(pEntry);
558 bRet = TRUE;
560 else if ( pParent == pRootNodes[SC_CONTENT_NOTE] )
562 aHelpText = GetEntryText(pEntry); // Notizen als Help-Text
563 bRet = TRUE;
565 else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] )
567 ULONG nIndex = GetChildIndex(pEntry);
568 if( nIndex != SC_CONTENT_NOCHILD )
570 const ScAreaLink* pLink = GetLink(nIndex);
571 if (pLink)
573 aHelpText = pLink->GetFile(); // Source-Datei als Help-Text
574 bRet = TRUE;
579 if (bRet)
581 SvLBoxTab* pTab;
582 SvLBoxString* pItem = (SvLBoxString*)(GetItem( pEntry, aPos.X(), &pTab ));
583 if( pItem )
585 aPos = GetEntryPosition( pEntry );
586 aPos.X() = GetTabPos( pEntry, pTab );
587 aPos = OutputToScreenPixel(aPos);
588 Size aSize( pItem->GetSize( this, pEntry ) );
590 Rectangle aItemRect( aPos, aSize );
591 Help::ShowQuickHelp( this, aItemRect, aHelpText );
592 bDone = TRUE;
597 if (!bDone)
598 Window::RequestHelp( rHEvt );
601 ScDocument* ScContentTree::GetSourceDocument()
603 if (bHiddenDoc)
604 return pHiddenDocument;
605 else
607 ScDocShell* pSh = GetManualOrCurrent();
608 if (pSh)
609 return pSh->GetDocument();
612 return NULL;
615 void ScContentTree::Refresh( USHORT nType )
617 if ( bHiddenDoc && !pHiddenDocument )
618 return; // anderes Dokument angezeigt
620 // wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
622 if ( nType == SC_CONTENT_NOTE )
623 if (!NoteStringsChanged())
624 return;
625 if ( nType == SC_CONTENT_GRAPHIC )
626 if (!DrawNamesChanged(SC_CONTENT_GRAPHIC))
627 return;
628 if ( nType == SC_CONTENT_OLEOBJECT )
629 if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT))
630 return;
631 if ( nType == SC_CONTENT_DRAWING )
632 if (!DrawNamesChanged(SC_CONTENT_DRAWING))
633 return;
635 SetUpdateMode(FALSE);
637 ClearType( nType );
639 if ( !nType || nType == SC_CONTENT_TABLE )
640 GetTableNames();
641 if ( !nType || nType == SC_CONTENT_RANGENAME )
642 GetAreaNames();
643 if ( !nType || nType == SC_CONTENT_DBAREA )
644 GetDbNames();
645 if ( !nType || nType == SC_CONTENT_GRAPHIC )
646 GetGraphicNames();
647 if ( !nType || nType == SC_CONTENT_OLEOBJECT )
648 GetOleNames();
649 if ( !nType || nType == SC_CONTENT_DRAWING )
650 GetDrawingNames();
651 if ( !nType || nType == SC_CONTENT_NOTE )
652 GetNoteStrings();
653 if ( !nType || nType == SC_CONTENT_AREALINK )
654 GetLinkNames();
656 ApplySettings();
657 SetUpdateMode(TRUE);
660 void ScContentTree::GetTableNames()
662 if ( nRootType && nRootType != SC_CONTENT_TABLE ) // ausgeblendet ?
663 return;
665 ScDocument* pDoc = GetSourceDocument();
666 if (!pDoc)
667 return;
669 String aName;
670 SCTAB nCount = pDoc->GetTableCount();
671 for ( SCTAB i=0; i<nCount; i++ )
673 pDoc->GetName( i, aName );
674 InsertContent( SC_CONTENT_TABLE, aName );
678 void ScContentTree::GetAreaNames()
680 if ( nRootType && nRootType != SC_CONTENT_RANGENAME ) // ausgeblendet ?
681 return;
683 ScDocument* pDoc = GetSourceDocument();
684 if (!pDoc)
685 return;
687 ScRangeName* pRangeNames = pDoc->GetRangeName();
688 USHORT nCount = pRangeNames->GetCount();
689 if ( nCount > 0 )
691 USHORT nValidCount = 0;
692 ScRange aDummy;
693 USHORT i;
694 for ( i=0; i<nCount; i++ )
696 ScRangeData* pData = (*pRangeNames)[i];
697 if (pData->IsValidReference(aDummy))
698 nValidCount++;
700 if ( nValidCount )
702 ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
703 USHORT j;
704 for ( i=0, j=0; i<nCount; i++ )
706 ScRangeData* pData = (*pRangeNames)[i];
707 if (pData->IsValidReference(aDummy))
708 ppSortArray[j++] = pData;
710 #ifndef ICC
711 qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
712 &ScRangeData_QsortNameCompare );
713 #else
714 qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
715 ICCQsortNameCompare );
716 #endif
717 for ( j=0; j<nValidCount; j++ )
718 InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
719 delete [] ppSortArray;
724 void ScContentTree::GetDbNames()
726 if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ?
727 return;
729 ScDocument* pDoc = GetSourceDocument();
730 if (!pDoc)
731 return;
733 ScDBCollection* pDbNames = pDoc->GetDBCollection();
734 USHORT nCount = pDbNames->GetCount();
735 if ( nCount > 0 )
737 String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) );
738 for ( USHORT i=0; i<nCount; i++ )
740 ScDBData* pData = (*pDbNames)[i];
741 String aStrName = pData->GetName();
742 if ( aStrName != aStrNoName )
743 InsertContent( SC_CONTENT_DBAREA, aStrName );
748 bool ScContentTree::IsPartOfType( USHORT nContentType, USHORT nObjIdentifier ) // static
750 bool bRet = false;
751 switch ( nContentType )
753 case SC_CONTENT_GRAPHIC:
754 bRet = ( nObjIdentifier == OBJ_GRAF );
755 break;
756 case SC_CONTENT_OLEOBJECT:
757 bRet = ( nObjIdentifier == OBJ_OLE2 );
758 break;
759 case SC_CONTENT_DRAWING:
760 bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 ); // everything else
761 break;
762 default:
763 DBG_ERROR("unknown content type");
765 return bRet;
768 void ScContentTree::GetDrawNames( USHORT nType )
770 if ( nRootType && nRootType != nType ) // ausgeblendet ?
771 return;
773 ScDocument* pDoc = GetSourceDocument();
774 if (!pDoc)
775 return;
777 // iterate in flat mode for groups
778 SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
780 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
781 SfxObjectShell* pShell = pDoc->GetDocumentShell();
782 if (pDrawLayer && pShell)
784 SCTAB nTabCount = pDoc->GetTableCount();
785 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
787 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
788 DBG_ASSERT(pPage,"Page ?");
789 if (pPage)
791 SdrObjListIter aIter( *pPage, eIter );
792 SdrObject* pObject = aIter.Next();
793 while (pObject)
795 if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
797 String aName = ScDrawLayer::GetVisibleName( pObject );
798 if (aName.Len())
799 InsertContent( nType, aName );
802 pObject = aIter.Next();
809 void ScContentTree::GetGraphicNames()
811 GetDrawNames( SC_CONTENT_GRAPHIC );
814 void ScContentTree::GetOleNames()
816 GetDrawNames( SC_CONTENT_OLEOBJECT );
819 void ScContentTree::GetDrawingNames()
821 GetDrawNames( SC_CONTENT_DRAWING );
824 void ScContentTree::GetLinkNames()
826 if ( nRootType && nRootType != SC_CONTENT_AREALINK ) // ausgeblendet ?
827 return;
829 ScDocument* pDoc = GetSourceDocument();
830 if (!pDoc)
831 return;
833 SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
834 DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
835 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
836 USHORT nCount = rLinks.Count();
837 for (USHORT i=0; i<nCount; i++)
839 ::sfx2::SvBaseLink* pBase = *rLinks[i];
840 if (pBase->ISA(ScAreaLink))
841 InsertContent( SC_CONTENT_AREALINK, ((ScAreaLink*)pBase)->GetSource() );
843 // in der Liste die Namen der Quellbereiche
847 const ScAreaLink* ScContentTree::GetLink( ULONG nIndex )
849 ScDocument* pDoc = GetSourceDocument();
850 if (!pDoc)
851 return NULL;
853 ULONG nFound = 0;
854 SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
855 DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
856 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
857 USHORT nCount = rLinks.Count();
858 for (USHORT i=0; i<nCount; i++)
860 ::sfx2::SvBaseLink* pBase = *rLinks[i];
861 if (pBase->ISA(ScAreaLink))
863 if (nFound == nIndex)
864 return (const ScAreaLink*) pBase;
865 ++nFound;
869 DBG_ERROR("Link nicht gefunden");
870 return NULL;
873 String lcl_NoteString( const ScPostIt& rNote )
875 String aText = rNote.GetText();
876 xub_StrLen nAt;
877 while ( (nAt = aText.Search( '\n' )) != STRING_NOTFOUND )
878 aText.SetChar( nAt, ' ' );
879 return aText;
882 void ScContentTree::GetNoteStrings()
884 if ( nRootType && nRootType != SC_CONTENT_NOTE ) // ausgeblendet ?
885 return;
887 ScDocument* pDoc = GetSourceDocument();
888 if (!pDoc)
889 return;
891 SCTAB nTabCount = pDoc->GetTableCount();
892 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
894 ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
895 for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
896 if( const ScPostIt* pNote = pCell->GetNote() )
897 InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) );
901 ScAddress ScContentTree::GetNotePos( ULONG nIndex )
903 ScDocument* pDoc = GetSourceDocument();
904 if (!pDoc)
905 return ScAddress();
907 ULONG nFound = 0;
908 SCTAB nTabCount = pDoc->GetTableCount();
909 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
911 ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
912 ScBaseCell* pCell = aIter.GetFirst();
913 while (pCell)
915 if( pCell->HasNote() )
917 if (nFound == nIndex)
918 return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden
919 ++nFound;
921 pCell = aIter.GetNext();
925 DBG_ERROR("Notiz nicht gefunden");
926 return ScAddress();
929 BOOL ScContentTree::NoteStringsChanged()
931 ScDocument* pDoc = GetSourceDocument();
932 if (!pDoc)
933 return FALSE;
935 SvLBoxEntry* pParent = pRootNodes[SC_CONTENT_NOTE];
936 if (!pParent)
937 return FALSE;
939 SvLBoxEntry* pEntry = FirstChild( pParent );
941 BOOL bEqual = TRUE;
942 SCTAB nTabCount = pDoc->GetTableCount();
943 for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
945 ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
946 ScBaseCell* pCell = aIter.GetFirst();
947 while (pCell && bEqual)
949 if( const ScPostIt* pNote = pCell->GetNote() )
951 if ( !pEntry )
952 bEqual = FALSE;
953 else
955 if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
956 bEqual = FALSE;
958 pEntry = NextSibling( pEntry );
961 pCell = aIter.GetNext();
965 if ( pEntry )
966 bEqual = FALSE; // kommt noch was
968 return !bEqual;
971 BOOL ScContentTree::DrawNamesChanged( USHORT nType )
973 ScDocument* pDoc = GetSourceDocument();
974 if (!pDoc)
975 return FALSE;
977 SvLBoxEntry* pParent = pRootNodes[nType];
978 if (!pParent)
979 return FALSE;
981 SvLBoxEntry* pEntry = FirstChild( pParent );
983 // iterate in flat mode for groups
984 SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
986 BOOL bEqual = TRUE;
987 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
988 SfxObjectShell* pShell = pDoc->GetDocumentShell();
989 if (pDrawLayer && pShell)
991 SCTAB nTabCount = pDoc->GetTableCount();
992 for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
994 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
995 DBG_ASSERT(pPage,"Page ?");
996 if (pPage)
998 SdrObjListIter aIter( *pPage, eIter );
999 SdrObject* pObject = aIter.Next();
1000 while (pObject && bEqual)
1002 if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
1004 if ( !pEntry )
1005 bEqual = FALSE;
1006 else
1008 if ( ScDrawLayer::GetVisibleName( pObject ) != GetEntryText(pEntry) )
1009 bEqual = FALSE;
1011 pEntry = NextSibling( pEntry );
1014 pObject = aIter.Next();
1020 if ( pEntry )
1021 bEqual = FALSE; // kommt noch was
1023 return !bEqual;
1026 BOOL lcl_GetRange( ScDocument* pDoc, USHORT nType, const String& rName, ScRange& rRange )
1028 BOOL bFound = FALSE;
1029 USHORT nPos;
1031 if ( nType == SC_CONTENT_RANGENAME )
1033 ScRangeName* pList = pDoc->GetRangeName();
1034 if (pList)
1035 if (pList->SearchName( rName, nPos ))
1036 if ( (*pList)[nPos]->IsValidReference( rRange ) )
1037 bFound = TRUE;
1039 else if ( nType == SC_CONTENT_DBAREA )
1041 ScDBCollection* pList = pDoc->GetDBCollection();
1042 if (pList)
1043 if (pList->SearchName( rName, nPos ))
1045 SCTAB nTab;
1046 SCCOL nCol1, nCol2;
1047 SCROW nRow1, nRow2;
1048 (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
1049 rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
1050 bFound = TRUE;
1054 return bFound;
1057 void lcl_DoDragObject( ScDocShell* pSrcShell, const String& rName, USHORT nType, Window* pWin )
1059 ScDocument* pSrcDoc = pSrcShell->GetDocument();
1060 ScDrawLayer* pModel = pSrcDoc->GetDrawLayer();
1061 if (pModel)
1063 BOOL bOle = ( nType == SC_CONTENT_OLEOBJECT );
1064 BOOL bGraf = ( nType == SC_CONTENT_GRAPHIC );
1065 USHORT nDrawId = sal::static_int_cast<USHORT>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) );
1066 SCTAB nTab = 0;
1067 SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab );
1068 if (pObject)
1070 SdrView aEditView( pModel );
1071 aEditView.ShowSdrPage(aEditView.GetModel()->GetPage(nTab));
1072 SdrPageView* pPV = aEditView.GetSdrPageView();
1073 aEditView.MarkObj(pObject, pPV);
1075 SdrModel* pDragModel = aEditView.GetAllMarkedModel();
1077 TransferableObjectDescriptor aObjDesc;
1078 pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
1079 aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
1080 // maSize is set in ScDrawTransferObj ctor
1082 ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc );
1083 uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
1085 pTransferObj->SetDragSourceObj( pObject, nTab );
1086 pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
1088 SC_MOD()->SetDragObject( NULL, pTransferObj );
1089 pWin->ReleaseMouse();
1090 pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
1095 void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, USHORT nFlags, Window* pWin )
1097 ScMarkData aMark;
1098 aMark.SelectTable( rRange.aStart.Tab(), TRUE );
1099 aMark.SetMarkArea( rRange );
1101 ScDocument* pSrcDoc = pSrcShell->GetDocument();
1102 if ( !pSrcDoc->HasSelectedBlockMatrixFragment( rRange.aStart.Col(), rRange.aStart.Row(),
1103 rRange.aEnd.Col(), rRange.aEnd.Row(),
1104 aMark ) )
1106 ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
1107 ScClipParam aClipParam(rRange, false);
1108 pSrcDoc->CopyToClip(aClipParam, pClipDoc, &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 //------------------------------------------------------------------------