1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svditer.hxx>
21 #include <svx/svdobj.hxx>
22 #include <svx/svdpage.hxx>
23 #include <svx/svdpagv.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/svdxcgv.hxx>
26 #include <sfx2/linkmgr.hxx>
27 #include <sfx2/docfile.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <vcl/help.hxx>
30 #include <vcl/svapp.hxx>
31 #include <tools/urlobj.hxx>
32 #include <svl/urlbmk.hxx>
33 #include <svtools/svlbitm.hxx>
34 #include <svtools/treelistentry.hxx>
37 #include "content.hxx"
42 #include "rangenam.hxx"
44 #include "tablink.hxx"
45 #include "popmenu.hxx"
46 #include "drwlayer.hxx"
47 #include "transobj.hxx"
48 #include "drwtrans.hxx"
49 #include "lnktrans.hxx"
50 #include "formulacell.hxx"
51 #include "dociter.hxx"
52 #include "scresid.hxx"
53 #include "globstr.hrc"
55 #include "arealink.hxx"
56 #include "navicfg.hxx"
57 #include "navsett.hxx"
59 #include "tabvwsh.hxx"
60 #include "drawview.hxx"
61 #include "clipparam.hxx"
62 #include "markdata.hxx"
64 using namespace com::sun::star
;
66 // Reihenfolge der Kategorien im Navigator -------------------------------------
68 static const sal_uInt16 pTypeList
[SC_CONTENT_COUNT
] =
70 SC_CONTENT_ROOT
, // ROOT (0) muss vorne stehen
81 bool ScContentTree::bIsInDrag
= false;
83 ScDocShell
* ScContentTree::GetManualOrCurrent()
85 ScDocShell
* pSh
= NULL
;
86 if ( !aManualDoc
.isEmpty() )
88 TypeId aScType
= TYPE(ScDocShell
);
89 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst( &aScType
);
90 while ( pObjSh
&& !pSh
)
92 if ( pObjSh
->GetTitle() == aManualDoc
)
93 pSh
= PTR_CAST( ScDocShell
, pObjSh
);
94 pObjSh
= SfxObjectShell::GetNext( *pObjSh
, &aScType
);
99 // Current nur, wenn keine manuell eingestellt ist
100 // (damit erkannt wird, wenn das Dokument nicht mehr existiert)
102 SfxViewShell
* pViewSh
= SfxViewShell::Current();
105 SfxObjectShell
* pObjSh
= pViewSh
->GetViewFrame()->GetObjectShell();
106 pSh
= PTR_CAST( ScDocShell
, pObjSh
);
115 ScContentTree::ScContentTree( vcl::Window
* pParent
, const ResId
& rResId
) :
116 SvTreeListBox ( pParent
, rResId
),
117 aEntryImages ( ScResId( RID_IMAGELIST_NAVCONT
) ),
118 nRootType ( SC_CONTENT_ROOT
),
119 bHiddenDoc ( false ),
120 pHiddenDocument ( NULL
),
121 bisInNavigatoeDlg ( false )
124 for (i
=0; i
<SC_CONTENT_COUNT
; i
++)
125 pPosList
[pTypeList
[i
]] = i
; // invers zum suchen
127 pParentWindow
= static_cast<ScNavigatorDlg
*>(pParent
);
129 pRootNodes
[0] = NULL
;
130 for (i
=1; i
<SC_CONTENT_COUNT
; i
++)
133 SetNodeDefaultImages();
135 SetDoubleClickHdl( LINK( this, ScContentTree
, ContentDoubleClickHdl
) );
140 SetStyle( GetStyle() | WB_QUICK_SEARCH
);
143 ScContentTree::~ScContentTree()
148 void ScContentTree::dispose()
150 pParentWindow
.clear();
151 SvTreeListBox::dispose();
154 // helper function for GetEntryAltText and GetEntryLongDescription
155 OUString
ScContentTree::getAltLongDescText( SvTreeListEntry
* pEntry
, bool isAltText
) const
157 SdrObject
* pFound
= NULL
;
161 GetEntryIndexes( nType
, nChild
, pEntry
);
164 case SC_CONTENT_OLEOBJECT
:
165 case SC_CONTENT_GRAPHIC
:
166 case SC_CONTENT_DRAWING
:
168 ScDocument
* pDoc
= ( const_cast< ScContentTree
* >(this) )->GetSourceDocument();
169 SdrIterMode eIter
= ( nType
== SC_CONTENT_DRAWING
) ? IM_FLAT
: IM_DEEPNOGROUPS
;
170 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
171 SfxObjectShell
* pShell
= pDoc
->GetDocumentShell();
172 if (pDrawLayer
&& pShell
)
174 sal_uInt16 nTabCount
= pDoc
->GetTableCount();
175 for (sal_uInt16 nTab
=0; nTab
<nTabCount
; nTab
++)
177 SdrPage
* pPage
= pDrawLayer
->GetPage(nTab
);
178 DBG_ASSERT(pPage
,"Page ?");
181 SdrObjListIter
aIter( *pPage
, eIter
);
182 SdrObject
* pObject
= aIter
.Next();
185 if( ScDrawLayer::GetVisibleName( pObject
) == GetEntryText( pEntry
) )
190 pObject
= aIter
.Next();
198 return pFound
->GetTitle();
200 return pFound
->GetDescription();
208 OUString
ScContentTree::GetEntryAltText( SvTreeListEntry
* pEntry
) const
210 return getAltLongDescText( pEntry
, true );
213 OUString
ScContentTree::GetEntryLongDescription( SvTreeListEntry
* pEntry
) const
215 return getAltLongDescText( pEntry
, false );
218 void ScContentTree::InitRoot( sal_uInt16 nType
)
223 if ( nRootType
&& nRootType
!= nType
) // ausgeblendet ?
225 pRootNodes
[nType
] = NULL
;
229 const Image
& rImage
= aEntryImages
.GetImage( nType
);
230 OUString
aName( ScResId( SCSTR_CONTENT_ROOT
+ nType
) );
231 // wieder an die richtige Position:
232 sal_uInt16 nPos
= nRootType
? 0 : pPosList
[nType
]-1;
233 SvTreeListEntry
* pNew
= InsertEntry( aName
, rImage
, rImage
, NULL
, false, nPos
);
235 pRootNodes
[nType
] = pNew
;
238 void ScContentTree::ClearAll()
240 //There are one method in Control::SetUpdateMode(), and one override method SvTreeListBox::SetUpdateMode(). Here although
241 //SvTreeListBox::SetUpdateMode() is called in refresh method, it only call SvTreeListBox::SetUpdateMode(), not Control::SetUpdateMode().
242 //In SvTreeList::Clear(), Broadcast( LISTACTION_CLEARED ) will be called and finally, it will be trapped into the event yield() loop. And
243 //the InitRoot() method won't be called. Then if a user click or press key to update the navigator tree, crash happens.
244 //So the solution is to disable the UpdateMode of Control, then call Clear(), then recover the update mode
245 bool bOldUpdate
= Control::IsUpdateMode();
246 Control::SetUpdateMode(false);
248 Control::SetUpdateMode(bOldUpdate
);
249 for (sal_uInt16 i
=1; i
<SC_CONTENT_COUNT
; i
++)
253 void ScContentTree::ClearType(sal_uInt16 nType
)
259 SvTreeListEntry
* pParent
= pRootNodes
[nType
];
260 if ( !pParent
|| GetChildCount(pParent
) ) // nicht, wenn ohne Children schon da
263 GetModel()->Remove( pParent
); // mit allen Children
264 InitRoot( nType
); // ggf. neu eintragen
269 void ScContentTree::InsertContent( sal_uInt16 nType
, const OUString
& rValue
)
271 if (nType
>= SC_CONTENT_COUNT
)
273 OSL_FAIL("ScContentTree::InsertContent mit falschem Typ");
277 SvTreeListEntry
* pParent
= pRootNodes
[nType
];
279 InsertEntry( rValue
, pParent
);
282 OSL_FAIL("InsertContent ohne Parent");
286 void ScContentTree::GetEntryIndexes( sal_uInt16
& rnRootIndex
, sal_uLong
& rnChildIndex
, SvTreeListEntry
* pEntry
) const
288 rnRootIndex
= SC_CONTENT_ROOT
;
289 rnChildIndex
= SC_CONTENT_NOCHILD
;
294 SvTreeListEntry
* pParent
= GetParent( pEntry
);
296 for( sal_uInt16 nRoot
= 1; !bFound
&& (nRoot
< SC_CONTENT_COUNT
); ++nRoot
)
298 if( pEntry
== pRootNodes
[ nRoot
] )
304 else if( pParent
&& (pParent
== pRootNodes
[ nRoot
]) )
308 // search the entry in all child entries of the parent
309 sal_uLong nEntry
= 0;
310 SvTreeListEntry
* pIterEntry
= FirstChild( pParent
);
311 while( !bFound
&& pIterEntry
)
313 if ( pEntry
== pIterEntry
)
315 rnChildIndex
= nEntry
;
316 bFound
= true; // exit the while loop
318 pIterEntry
= NextSibling( pIterEntry
);
322 bFound
= true; // exit the for loop
327 sal_uLong
ScContentTree::GetChildIndex( SvTreeListEntry
* pEntry
) const
331 GetEntryIndexes( nRoot
, nChild
, pEntry
);
335 static OUString
lcl_GetDBAreaRange( ScDocument
* pDoc
, const OUString
& rDBName
)
340 ScDBCollection
* pDbNames
= pDoc
->GetDBCollection();
341 const ScDBData
* pData
= pDbNames
->getNamedDBs().findByUpperName(ScGlobal::pCharClass
->uppercase(rDBName
));
345 pData
->GetArea(aRange
);
346 aRet
= aRange
.Format(SCR_ABS_3D
, pDoc
);
352 IMPL_LINK_NOARG(ScContentTree
, ContentDoubleClickHdl
)
356 SvTreeListEntry
* pEntry
= GetCurEntry();
357 GetEntryIndexes( nType
, nChild
, pEntry
);
359 if( pEntry
&& (nType
!= SC_CONTENT_ROOT
) && (nChild
!= SC_CONTENT_NOCHILD
) )
362 return 0; //! spaeter...
364 OUString
aText( GetEntryText( pEntry
) );
366 if ( !aManualDoc
.isEmpty() )
367 pParentWindow
->SetCurrentDoc( aManualDoc
);
371 case SC_CONTENT_TABLE
:
372 pParentWindow
->SetCurrentTableStr( aText
);
375 case SC_CONTENT_RANGENAME
:
376 pParentWindow
->SetCurrentCellStr( aText
);
379 case SC_CONTENT_DBAREA
:
381 // Wenn gleiche Bereichs- und DB-Namen existieren, wird
382 // bei SID_CURRENTCELL der Bereichsname genommen.
383 // DB-Bereiche darum direkt ueber die Adresse anspringen.
385 OUString aRangeStr
= lcl_GetDBAreaRange( GetSourceDocument(), aText
);
386 if (!aRangeStr
.isEmpty())
387 pParentWindow
->SetCurrentCellStr( aRangeStr
);
391 case SC_CONTENT_OLEOBJECT
:
392 case SC_CONTENT_GRAPHIC
:
393 case SC_CONTENT_DRAWING
:
394 pParentWindow
->SetCurrentObject( aText
);
397 case SC_CONTENT_NOTE
:
399 ScAddress aPos
= GetNotePos( nChild
);
400 pParentWindow
->SetCurrentTable( aPos
.Tab() );
401 pParentWindow
->SetCurrentCell( aPos
.Col(), aPos
.Row() );
405 case SC_CONTENT_AREALINK
:
407 const ScAreaLink
* pLink
= GetLink( nChild
);
410 ScRange aRange
= pLink
->GetDestArea();
411 ScDocument
* pSrcDoc
= GetSourceDocument();
412 OUString
aRangeStr(aRange
.Format(SCR_ABS_3D
, pSrcDoc
, pSrcDoc
->GetAddressConvention()));
413 pParentWindow
->SetCurrentCellStr( aRangeStr
);
419 ScNavigatorDlg::ReleaseFocus(); // set focus into document
425 void ScContentTree::MouseButtonDown( const MouseEvent
& rMEvt
)
427 SvTreeListBox::MouseButtonDown( rMEvt
);
428 StoreNavigatorSettings();
431 void ScContentTree::KeyInput( const KeyEvent
& rKEvt
)
435 const vcl::KeyCode aCode
= rKEvt
.GetKeyCode();
436 if (aCode
.GetCode() == KEY_RETURN
)
438 switch (aCode
.GetModifier())
441 ToggleRoot(); // toggle root mode (as in Writer)
446 SvTreeListEntry
* pEntry
= GetCurEntry();
451 GetEntryIndexes( nType
, nChild
, pEntry
);
453 if( (nType
!= SC_CONTENT_ROOT
) && (nChild
== SC_CONTENT_NOCHILD
) )
455 if ( IsExpanded( pEntry
) )
461 ContentDoubleClickHdl(0); // select content as if double clicked
469 //Make KEY_SPACE has same function as DoubleClick
470 if ( bisInNavigatoeDlg
)
472 if(aCode
.GetCode() == KEY_SPACE
)
477 SvTreeListEntry
* pEntry
= GetCurEntry();
478 GetEntryIndexes( nType
, nChild
, pEntry
);
479 if( pEntry
&& (nType
!= SC_CONTENT_ROOT
) && (nChild
!= SC_CONTENT_NOCHILD
) )
482 return ; //! spaeter...
483 OUString
aText( GetEntryText( pEntry
) );
485 if (!aManualDoc
.isEmpty())
486 pParentWindow
->SetCurrentDoc( aManualDoc
);
489 case SC_CONTENT_OLEOBJECT
:
490 case SC_CONTENT_GRAPHIC
:
491 case SC_CONTENT_DRAWING
:
493 vcl::Window
* pWindow
=reinterpret_cast<vcl::Window
*>(GetParent(pEntry
));
494 ScNavigatorDlg
* pScNavigatorDlg
= static_cast<ScNavigatorDlg
*>(pWindow
);
495 ScTabViewShell
* pScTabViewShell
= NULL
;
496 ScDrawView
* pScDrawView
= NULL
;
497 if (pScNavigatorDlg
!=NULL
)
498 pScTabViewShell
= ScNavigatorDlg::GetTabViewShell();
499 if(pScTabViewShell
!=NULL
)
500 pScDrawView
=pScTabViewShell
->GetViewData().GetScDrawView();
501 if(pScDrawView
!=NULL
)
503 pScDrawView
->SelectCurrentViewObject(aText
);
504 bool bHasMakredObject
= false;
505 SvTreeListEntry
* pParent
= pRootNodes
[nType
];
506 SvTreeListEntry
* pBeginEntry
= NULL
;
508 pBeginEntry
= FirstChild(pParent
);
511 OUString
aTempText( GetEntryText( pBeginEntry
) );
512 if( pScDrawView
->GetObjectIsMarked( pScDrawView
->GetObjectByName( aTempText
) ) )
514 bHasMakredObject
= true;
517 pBeginEntry
= Next( pBeginEntry
);
519 if( !bHasMakredObject
&& pScTabViewShell
)
520 pScTabViewShell
->SetDrawShell(false);
521 ObjectFresh( nType
,pEntry
);
532 if(aCode
.GetCode() == KEY_F5
)
534 StoreNavigatorSettings();
535 SvTreeListBox::KeyInput(rKEvt
);
539 SvTreeListBox::KeyInput(rKEvt
);
540 StoreNavigatorSettings();
545 sal_Int8
ScContentTree::AcceptDrop( const AcceptDropEvent
& /* rEvt */ )
547 return DND_ACTION_NONE
;
550 sal_Int8
ScContentTree::ExecuteDrop( const ExecuteDropEvent
& /* rEvt */ )
552 return DND_ACTION_NONE
;
555 void ScContentTree::StartDrag( sal_Int8
/* nAction */, const Point
& /* rPosPixel */ )
560 void ScContentTree::DragFinished( sal_Int8
/* nAction */ )
564 void ScContentTree::Command( const CommandEvent
& rCEvt
)
568 switch ( rCEvt
.GetCommand() )
570 case CommandEventId::StartDrag
:
571 // Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
572 // (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
573 // den StarView MouseMove-Handler, der Command() aufruft, umbringen.
574 // Deshalb Drag&Drop asynchron:
576 Application::PostUserEvent( LINK( this, ScContentTree
, ExecDragHdl
), NULL
, true );
581 case CommandEventId::ContextMenu
:
586 ScPopupMenu
aDropMenu( ScResId( RID_POPUP_DROPMODE
) );
587 aDropMenu
.CheckItem( RID_DROPMODE_URL
+ pParentWindow
->GetDropMode() );
588 aPop
.InsertItem( 1, pParentWindow
->GetStrDragMode() );
589 aPop
.SetPopupMenu( 1, &aDropMenu
);
591 // angezeigtes Dokument
593 ScPopupMenu aDocMenu
;
594 aDocMenu
.SetMenuFlags( aDocMenu
.GetMenuFlags() | MenuFlags::NoAutoMnemonics
);
597 // geladene Dokumente
598 ScDocShell
* pCurrentSh
= PTR_CAST( ScDocShell
, SfxObjectShell::Current() );
599 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
602 if ( pSh
->ISA(ScDocShell
) )
604 OUString aName
= pSh
->GetTitle();
605 OUString aEntry
= aName
;
606 if ( pSh
== pCurrentSh
)
607 aEntry
+= pParentWindow
->aStrActive
;
609 aEntry
+= pParentWindow
->aStrNotActive
;
610 aDocMenu
.InsertItem( ++i
, aEntry
);
611 if ( !bHiddenDoc
&& aName
== aManualDoc
)
614 pSh
= SfxObjectShell::GetNext( *pSh
);
617 aDocMenu
.InsertItem( ++i
, pParentWindow
->aStrActiveWin
);
618 if (!bHiddenDoc
&& aManualDoc
.isEmpty())
620 // verstecktes Dokument
621 if ( !aHiddenTitle
.isEmpty() )
623 OUString aEntry
= aHiddenTitle
;
624 aEntry
+= pParentWindow
->aStrHidden
;
625 aDocMenu
.InsertItem( ++i
, aEntry
);
629 aDocMenu
.CheckItem( nPos
);
630 aPop
.InsertItem( 2, pParentWindow
->GetStrDisplay() );
631 aPop
.SetPopupMenu( 2, &aDocMenu
);
635 aPop
.Execute( this, rCEvt
.GetMousePosPixel() );
637 if ( aDropMenu
.WasHit() ) // Drag-Drop Modus
639 sal_uInt16 nId
= aDropMenu
.GetSelected();
640 if ( nId
>= RID_DROPMODE_URL
&& nId
<= RID_DROPMODE_COPY
)
641 pParentWindow
->SetDropMode( nId
- RID_DROPMODE_URL
);
643 else if ( aDocMenu
.WasHit() ) // angezeigtes Dokument
645 sal_uInt16 nId
= aDocMenu
.GetSelected();
646 OUString aName
= aDocMenu
.GetItemText(nId
);
655 SvTreeListBox::Command(rCEvt
);
658 void ScContentTree::RequestHelp( const HelpEvent
& rHEvt
)
661 if( rHEvt
.GetMode() & HelpEventMode::QUICK
)
663 Point
aPos( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ));
664 SvTreeListEntry
* pEntry
= GetEntry( aPos
);
669 SvTreeListEntry
* pParent
= GetParent(pEntry
);
670 if ( !pParent
) // Top-Level ?
672 aHelpText
= OUString::number( GetChildCount(pEntry
) ) +
673 " " + GetEntryText(pEntry
);
676 else if ( pParent
== pRootNodes
[SC_CONTENT_NOTE
] )
678 aHelpText
= GetEntryText(pEntry
); // Notizen als Help-Text
681 else if ( pParent
== pRootNodes
[SC_CONTENT_AREALINK
] )
683 sal_uLong nIndex
= GetChildIndex(pEntry
);
684 if( nIndex
!= SC_CONTENT_NOCHILD
)
686 const ScAreaLink
* pLink
= GetLink(nIndex
);
689 aHelpText
= pLink
->GetFile(); // Source-Datei als Help-Text
698 SvLBoxString
* pItem
= static_cast<SvLBoxString
*>(GetItem( pEntry
, aPos
.X(), &pTab
));
701 aPos
= GetEntryPosition( pEntry
);
702 aPos
.X() = GetTabPos( pEntry
, pTab
);
703 aPos
= OutputToScreenPixel(aPos
);
704 Size
aSize( pItem
->GetSize( this, pEntry
) );
706 Rectangle
aItemRect( aPos
, aSize
);
707 Help::ShowQuickHelp( this, aItemRect
, aHelpText
);
714 Window::RequestHelp( rHEvt
);
717 ScDocument
* ScContentTree::GetSourceDocument()
720 return pHiddenDocument
;
723 ScDocShell
* pSh
= GetManualOrCurrent();
725 return &pSh
->GetDocument();
731 //Move along and draw "*" sign .
732 void ScContentTree::ObjectFresh( sal_uInt16 nType
, SvTreeListEntry
* pEntry
)
734 if ( bHiddenDoc
&& !pHiddenDocument
)
735 return; // anderes Dokument angezeigt
736 if(nType
==SC_CONTENT_GRAPHIC
||nType
==SC_CONTENT_OLEOBJECT
||nType
==SC_CONTENT_DRAWING
)
738 SetUpdateMode(false);
740 GetDrawNames( nType
/*, nId*/ );
742 ApplyNavigatorSettings();
746 SvTreeListEntry
* pParent
= pRootNodes
[nType
];
747 SvTreeListEntry
* pBeginEntry
= NULL
;
748 SvTreeListEntry
* pOldEntry
= NULL
;
750 pBeginEntry
= FirstChild(pParent
);
753 OUString
aTempText( GetEntryText( pBeginEntry
) );
754 if( aTempText
== sKeyString
)
756 pOldEntry
= pBeginEntry
;
759 pBeginEntry
= Next( pBeginEntry
);
764 Select( pOldEntry
, true);
770 void ScContentTree::Refresh( sal_uInt16 nType
)
772 if ( bHiddenDoc
&& !pHiddenDocument
)
773 return; // anderes Dokument angezeigt
775 // wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
777 if ( nType
== SC_CONTENT_NOTE
)
778 if (!NoteStringsChanged())
780 if ( nType
== SC_CONTENT_GRAPHIC
)
781 if (!DrawNamesChanged(SC_CONTENT_GRAPHIC
))
783 if ( nType
== SC_CONTENT_OLEOBJECT
)
784 if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT
))
786 if ( nType
== SC_CONTENT_DRAWING
)
787 if (!DrawNamesChanged(SC_CONTENT_DRAWING
))
790 SetUpdateMode(false);
794 if ( !nType
|| nType
== SC_CONTENT_TABLE
)
796 if ( !nType
|| nType
== SC_CONTENT_RANGENAME
)
798 if ( !nType
|| nType
== SC_CONTENT_DBAREA
)
800 if ( !nType
|| nType
== SC_CONTENT_GRAPHIC
)
802 if ( !nType
|| nType
== SC_CONTENT_OLEOBJECT
)
804 if ( !nType
|| nType
== SC_CONTENT_DRAWING
)
806 if ( !nType
|| nType
== SC_CONTENT_NOTE
)
808 if ( !nType
|| nType
== SC_CONTENT_AREALINK
)
811 ApplyNavigatorSettings();
815 void ScContentTree::GetTableNames()
817 if ( nRootType
&& nRootType
!= SC_CONTENT_TABLE
) // ausgeblendet ?
820 ScDocument
* pDoc
= GetSourceDocument();
825 SCTAB nCount
= pDoc
->GetTableCount();
826 for ( SCTAB i
=0; i
<nCount
; i
++ )
828 pDoc
->GetName( i
, aName
);
829 InsertContent( SC_CONTENT_TABLE
, aName
);
835 OUString
createLocalRangeName(const OUString
& rName
, const OUString
& rTableName
)
837 OUStringBuffer
aString (rName
);
838 aString
.append(" (");
839 aString
.append(rTableName
);
841 return aString
.makeStringAndClear();
845 void ScContentTree::GetAreaNames()
847 if ( nRootType
&& nRootType
!= SC_CONTENT_RANGENAME
) // ausgeblendet ?
850 ScDocument
* pDoc
= GetSourceDocument();
855 std::set
<OUString
> aSet
;
856 ScRangeName
* pRangeNames
= pDoc
->GetRangeName();
857 if (!pRangeNames
->empty())
859 ScRangeName::const_iterator itrBeg
= pRangeNames
->begin(), itrEnd
= pRangeNames
->end();
860 for (ScRangeName::const_iterator itr
= itrBeg
; itr
!= itrEnd
; ++itr
)
862 if (itr
->second
->IsValidReference(aDummy
))
863 aSet
.insert(itr
->second
->GetName());
866 for (SCTAB i
= 0; i
< pDoc
->GetTableCount(); ++i
)
868 ScRangeName
* pLocalRangeName
= pDoc
->GetRangeName(i
);
869 if (pLocalRangeName
&& !pLocalRangeName
->empty())
872 pDoc
->GetName(i
, aTableName
);
873 for (ScRangeName::const_iterator itr
= pLocalRangeName
->begin(); itr
!= pLocalRangeName
->end(); ++itr
)
875 if (itr
->second
->IsValidReference(aDummy
))
876 aSet
.insert(createLocalRangeName(itr
->second
->GetName(), aTableName
));
883 for (std::set
<OUString
>::iterator itr
= aSet
.begin();
884 itr
!= aSet
.end(); ++itr
)
886 InsertContent(SC_CONTENT_RANGENAME
, *itr
);
891 void ScContentTree::GetDbNames()
893 if ( nRootType
&& nRootType
!= SC_CONTENT_DBAREA
) // ausgeblendet ?
896 ScDocument
* pDoc
= GetSourceDocument();
900 ScDBCollection
* pDbNames
= pDoc
->GetDBCollection();
901 const ScDBCollection::NamedDBs
& rDBs
= pDbNames
->getNamedDBs();
902 ScDBCollection::NamedDBs::const_iterator itr
= rDBs
.begin(), itrEnd
= rDBs
.end();
903 for (; itr
!= itrEnd
; ++itr
)
905 const OUString
& aStrName
= itr
->GetName();
906 InsertContent(SC_CONTENT_DBAREA
, aStrName
);
910 bool ScContentTree::IsPartOfType( sal_uInt16 nContentType
, sal_uInt16 nObjIdentifier
)
913 switch ( nContentType
)
915 case SC_CONTENT_GRAPHIC
:
916 bRet
= ( nObjIdentifier
== OBJ_GRAF
);
918 case SC_CONTENT_OLEOBJECT
:
919 bRet
= ( nObjIdentifier
== OBJ_OLE2
);
921 case SC_CONTENT_DRAWING
:
922 bRet
= ( nObjIdentifier
!= OBJ_GRAF
&& nObjIdentifier
!= OBJ_OLE2
); // everything else
925 OSL_FAIL("unknown content type");
930 void ScContentTree::GetDrawNames( sal_uInt16 nType
)
932 if ( nRootType
&& nRootType
!= nType
) // ausgeblendet ?
935 ScDocument
* pDoc
= GetSourceDocument();
939 // iterate in flat mode for groups
940 SdrIterMode eIter
= ( nType
== SC_CONTENT_DRAWING
) ? IM_FLAT
: IM_DEEPNOGROUPS
;
942 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
943 SfxObjectShell
* pShell
= pDoc
->GetDocumentShell();
944 if (pDrawLayer
&& pShell
)
946 SCTAB nTabCount
= pDoc
->GetTableCount();
947 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
949 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
950 OSL_ENSURE(pPage
,"Page ?");
953 SdrObjListIter
aIter( *pPage
, eIter
);
954 SdrObject
* pObject
= aIter
.Next();
957 if ( IsPartOfType( nType
, pObject
->GetObjIdentifier() ) )
959 OUString aName
= ScDrawLayer::GetVisibleName( pObject
);
960 if (!aName
.isEmpty())
962 if( bisInNavigatoeDlg
)
964 if (nType
>= SC_CONTENT_COUNT
)
966 SAL_WARN("sc", "ScContentTree::InsertContent mit falschem Typ");
970 SvTreeListEntry
* pParent
= pRootNodes
[nType
];
973 SvTreeListEntry
* pChild
=InsertEntry( aName
, pParent
);
975 pChild
->SetMarked(false);
976 vcl::Window
* pWindow
=NULL
;
977 ScTabViewShell
* pScTabViewShell
=NULL
;
978 ScDrawView
* pScDrawView
=NULL
;
979 ScNavigatorDlg
* pScNavigatorDlg
=NULL
;
981 pWindow
=reinterpret_cast<vcl::Window
*>(GetParent(pChild
));
983 pScNavigatorDlg
= static_cast<ScNavigatorDlg
*>(pWindow
);
984 if (pScNavigatorDlg
!=NULL
)
985 pScTabViewShell
= ScNavigatorDlg::GetTabViewShell();
986 if(pScTabViewShell
!=NULL
)
987 pScDrawView
=pScTabViewShell
->GetViewData().GetScDrawView();
988 if(pScDrawView
!=NULL
)
990 bool bMarked
=pScDrawView
->GetObjectIsMarked(pObject
);
991 pChild
->SetMarked( bMarked
);
995 SAL_WARN("sc", "InsertContent ohne Parent");
1001 pObject
= aIter
.Next();
1008 void ScContentTree::GetGraphicNames()
1010 GetDrawNames( SC_CONTENT_GRAPHIC
);
1013 void ScContentTree::GetOleNames()
1015 GetDrawNames( SC_CONTENT_OLEOBJECT
);
1018 void ScContentTree::GetDrawingNames()
1020 GetDrawNames( SC_CONTENT_DRAWING
);
1023 void ScContentTree::GetLinkNames()
1025 if ( nRootType
&& nRootType
!= SC_CONTENT_AREALINK
) // ausgeblendet ?
1028 ScDocument
* pDoc
= GetSourceDocument();
1032 sfx2::LinkManager
* pLinkManager
= pDoc
->GetLinkManager();
1033 OSL_ENSURE(pLinkManager
, "kein LinkManager am Dokument?");
1034 const ::sfx2::SvBaseLinks
& rLinks
= pLinkManager
->GetLinks();
1035 sal_uInt16 nCount
= rLinks
.size();
1036 for (sal_uInt16 i
=0; i
<nCount
; i
++)
1038 ::sfx2::SvBaseLink
* pBase
= *rLinks
[i
];
1039 if (pBase
->ISA(ScAreaLink
))
1040 InsertContent( SC_CONTENT_AREALINK
, static_cast<ScAreaLink
*>(pBase
)->GetSource() );
1042 // in der Liste die Namen der Quellbereiche
1046 const ScAreaLink
* ScContentTree::GetLink( sal_uLong nIndex
)
1048 ScDocument
* pDoc
= GetSourceDocument();
1052 sal_uLong nFound
= 0;
1053 sfx2::LinkManager
* pLinkManager
= pDoc
->GetLinkManager();
1054 OSL_ENSURE(pLinkManager
, "kein LinkManager am Dokument?");
1055 const ::sfx2::SvBaseLinks
& rLinks
= pLinkManager
->GetLinks();
1056 sal_uInt16 nCount
= rLinks
.size();
1057 for (sal_uInt16 i
=0; i
<nCount
; i
++)
1059 ::sfx2::SvBaseLink
* pBase
= *rLinks
[i
];
1060 if (pBase
->ISA(ScAreaLink
))
1062 if (nFound
== nIndex
)
1063 return static_cast<const ScAreaLink
*>(pBase
);
1068 OSL_FAIL("link not found");
1072 static OUString
lcl_NoteString( const ScPostIt
& rNote
)
1074 OUString aText
= rNote
.GetText();
1076 while ( (nAt
= aText
.indexOf( '\n' )) != -1 )
1077 aText
= aText
.replaceAt( nAt
, 1, " " );
1081 void ScContentTree::GetNoteStrings()
1083 if ( nRootType
&& nRootType
!= SC_CONTENT_NOTE
) // ausgeblendet ?
1086 ScDocument
* pDoc
= GetSourceDocument();
1090 // loop over cell notes
1091 std::vector
<sc::NoteEntry
> aEntries
;
1092 pDoc
->GetAllNoteEntries(aEntries
);
1093 std::vector
<sc::NoteEntry
>::const_iterator it
= aEntries
.begin(), itEnd
= aEntries
.end();
1094 for (; it
!= itEnd
; ++it
)
1095 InsertContent(SC_CONTENT_NOTE
, lcl_NoteString(*it
->mpNote
));
1098 ScAddress
ScContentTree::GetNotePos( sal_uLong nIndex
)
1100 ScDocument
* pDoc
= GetSourceDocument();
1104 return pDoc
->GetNotePosition(nIndex
);
1107 bool ScContentTree::NoteStringsChanged()
1109 ScDocument
* pDoc
= GetSourceDocument();
1113 SvTreeListEntry
* pParent
= pRootNodes
[SC_CONTENT_NOTE
];
1117 SvTreeListEntry
* pEntry
= FirstChild( pParent
);
1119 std::vector
<sc::NoteEntry
> aEntries
;
1120 pDoc
->GetAllNoteEntries(aEntries
);
1121 std::vector
<sc::NoteEntry
>::const_iterator it
= aEntries
.begin(), itEnd
= aEntries
.end();
1122 for (; it
!= itEnd
; ++it
)
1124 const ScPostIt
* pNote
= it
->mpNote
;
1128 if (lcl_NoteString(*pNote
) != GetEntryText(pEntry
))
1131 pEntry
= NextSibling(pEntry
);
1140 bool ScContentTree::DrawNamesChanged( sal_uInt16 nType
)
1142 ScDocument
* pDoc
= GetSourceDocument();
1146 SvTreeListEntry
* pParent
= pRootNodes
[nType
];
1150 SvTreeListEntry
* pEntry
= FirstChild( pParent
);
1152 // iterate in flat mode for groups
1153 SdrIterMode eIter
= ( nType
== SC_CONTENT_DRAWING
) ? IM_FLAT
: IM_DEEPNOGROUPS
;
1156 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
1157 SfxObjectShell
* pShell
= pDoc
->GetDocumentShell();
1158 if (pDrawLayer
&& pShell
)
1160 SCTAB nTabCount
= pDoc
->GetTableCount();
1161 for (SCTAB nTab
=0; nTab
<nTabCount
&& bEqual
; nTab
++)
1163 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
1164 OSL_ENSURE(pPage
,"Page ?");
1167 SdrObjListIter
aIter( *pPage
, eIter
);
1168 SdrObject
* pObject
= aIter
.Next();
1169 while (pObject
&& bEqual
)
1171 if ( IsPartOfType( nType
, pObject
->GetObjIdentifier() ) )
1177 if ( ScDrawLayer::GetVisibleName( pObject
) != GetEntryText(pEntry
) )
1180 pEntry
= NextSibling( pEntry
);
1183 pObject
= aIter
.Next();
1190 bEqual
= false; // kommt noch was
1195 static bool lcl_GetRange( ScDocument
* pDoc
, sal_uInt16 nType
, const OUString
& rName
, ScRange
& rRange
)
1197 bool bFound
= false;
1199 if ( nType
== SC_CONTENT_RANGENAME
)
1201 ScRangeName
* pList
= pDoc
->GetRangeName();
1204 const ScRangeData
* p
= pList
->findByUpperName(ScGlobal::pCharClass
->uppercase(rName
));
1205 if (p
&& p
->IsValidReference(rRange
))
1209 else if ( nType
== SC_CONTENT_DBAREA
)
1211 ScDBCollection
* pList
= pDoc
->GetDBCollection();
1214 const ScDBData
* p
= pList
->getNamedDBs().findByUpperName(ScGlobal::pCharClass
->uppercase(rName
));
1220 p
->GetArea(nTab
, nCol1
, nRow1
, nCol2
, nRow2
);
1221 rRange
= ScRange(nCol1
, nRow1
, nTab
, nCol2
, nRow2
, nTab
);
1230 static void lcl_DoDragObject( ScDocShell
* pSrcShell
, const OUString
& rName
, sal_uInt16 nType
, vcl::Window
* pWin
)
1232 ScDocument
& rSrcDoc
= pSrcShell
->GetDocument();
1233 ScDrawLayer
* pModel
= rSrcDoc
.GetDrawLayer();
1236 bool bOle
= ( nType
== SC_CONTENT_OLEOBJECT
);
1237 bool bGraf
= ( nType
== SC_CONTENT_GRAPHIC
);
1238 sal_uInt16 nDrawId
= sal::static_int_cast
<sal_uInt16
>( bOle
? OBJ_OLE2
: ( bGraf
? OBJ_GRAF
: OBJ_GRUP
) );
1240 SdrObject
* pObject
= pModel
->GetNamedObject( rName
, nDrawId
, nTab
);
1243 SdrView
aEditView( pModel
);
1244 aEditView
.ShowSdrPage(aEditView
.GetModel()->GetPage(nTab
));
1245 SdrPageView
* pPV
= aEditView
.GetSdrPageView();
1246 aEditView
.MarkObj(pObject
, pPV
);
1248 SdrModel
* pDragModel
= aEditView
.GetMarkedObjModel();
1250 TransferableObjectDescriptor aObjDesc
;
1251 pSrcShell
->FillTransferableObjectDescriptor( aObjDesc
);
1252 aObjDesc
.maDisplayName
= pSrcShell
->GetMedium()->GetURLObject().GetURLNoPass();
1253 // maSize is set in ScDrawTransferObj ctor
1255 ScDrawTransferObj
* pTransferObj
= new ScDrawTransferObj( pDragModel
, pSrcShell
, aObjDesc
);
1256 uno::Reference
<datatransfer::XTransferable
> xTransferable( pTransferObj
);
1258 pTransferObj
->SetDragSourceObj( pObject
, nTab
);
1259 pTransferObj
->SetDragSourceFlags( SC_DROP_NAVIGATOR
);
1261 SC_MOD()->SetDragObject( NULL
, pTransferObj
);
1262 pWin
->ReleaseMouse();
1263 pTransferObj
->StartDrag( pWin
, DND_ACTION_COPYMOVE
| DND_ACTION_LINK
);
1268 static void lcl_DoDragCells( ScDocShell
* pSrcShell
, const ScRange
& rRange
, sal_uInt16 nFlags
, vcl::Window
* pWin
)
1271 aMark
.SelectTable( rRange
.aStart
.Tab(), true );
1272 aMark
.SetMarkArea( rRange
);
1274 ScDocument
& rSrcDoc
= pSrcShell
->GetDocument();
1275 if ( !rSrcDoc
.HasSelectedBlockMatrixFragment( rRange
.aStart
.Col(), rRange
.aStart
.Row(),
1276 rRange
.aEnd
.Col(), rRange
.aEnd
.Row(),
1279 ScDocument
* pClipDoc
= new ScDocument( SCDOCMODE_CLIP
);
1280 ScClipParam
aClipParam(rRange
, false);
1281 rSrcDoc
.CopyToClip(aClipParam
, pClipDoc
, &aMark
);
1282 // pClipDoc->ExtendMerge( rRange, sal_True );
1284 TransferableObjectDescriptor aObjDesc
;
1285 pSrcShell
->FillTransferableObjectDescriptor( aObjDesc
);
1286 aObjDesc
.maDisplayName
= pSrcShell
->GetMedium()->GetURLObject().GetURLNoPass();
1287 // maSize is set in ScTransferObj ctor
1289 ScTransferObj
* pTransferObj
= new ScTransferObj( pClipDoc
, aObjDesc
);
1290 uno::Reference
<datatransfer::XTransferable
> xTransferable( pTransferObj
);
1292 pTransferObj
->SetDragSource( pSrcShell
, aMark
);
1293 pTransferObj
->SetDragSourceFlags( nFlags
);
1295 SC_MOD()->SetDragObject( pTransferObj
, NULL
); // for internal D&D
1296 pWin
->ReleaseMouse();
1297 pTransferObj
->StartDrag( pWin
, DND_ACTION_COPYMOVE
| DND_ACTION_LINK
);
1301 void ScContentTree::DoDrag()
1303 ScDocumentLoader
* pDocLoader
= NULL
;
1306 ScModule
* pScMod
= SC_MOD();
1310 SvTreeListEntry
* pEntry
= GetCurEntry();
1311 GetEntryIndexes( nType
, nChild
, pEntry
);
1314 (nChild
!= SC_CONTENT_NOCHILD
) &&
1315 (nType
!= SC_CONTENT_ROOT
) &&
1316 (nType
!= SC_CONTENT_NOTE
) &&
1317 (nType
!= SC_CONTENT_AREALINK
) )
1319 OUString
aText( GetEntryText( pEntry
) );
1321 ScDocument
* pLocalDoc
= NULL
; // fuer URL-Drop
1324 aDocName
= aHiddenName
;
1327 ScDocShell
* pDocSh
= GetManualOrCurrent();
1330 if (pDocSh
->HasName())
1331 aDocName
= pDocSh
->GetMedium()->GetName();
1333 pLocalDoc
= &pDocSh
->GetDocument(); // Drop nur in dieses Dokument
1337 bool bDoLinkTrans
= false; // use ScLinkTransferObj
1338 OUString aLinkURL
; // for ScLinkTransferObj
1341 sal_uInt16 nDropMode
= pParentWindow
->GetDropMode();
1342 switch ( nDropMode
)
1344 case SC_DROPMODE_URL
:
1346 OUString aUrl
= aDocName
+ "#" + aText
;
1348 pScMod
->SetDragJump( pLocalDoc
, aUrl
, aText
);
1350 if (!aDocName
.isEmpty())
1352 // provide URL to outside only if the document has a name
1353 // (without name, only internal D&D via SetDragJump)
1358 bDoLinkTrans
= true;
1361 case SC_DROPMODE_LINK
:
1363 if ( !aDocName
.isEmpty() ) // link only to named documents
1365 // for internal D&D, set flag to insert a link
1369 case SC_CONTENT_TABLE
:
1370 pScMod
->SetDragLink( aDocName
, aText
, EMPTY_OUSTRING
);
1371 bDoLinkTrans
= true;
1373 case SC_CONTENT_RANGENAME
:
1374 case SC_CONTENT_DBAREA
:
1375 pScMod
->SetDragLink( aDocName
, EMPTY_OUSTRING
, aText
);
1376 bDoLinkTrans
= true;
1379 // other types cannot be linked
1384 case SC_DROPMODE_COPY
:
1386 ScDocShell
* pSrcShell
= NULL
;
1389 OUString aFilter
, aOptions
;
1390 OUString aURL
= aHiddenName
;
1391 pDocLoader
= new ScDocumentLoader( aURL
, aFilter
, aOptions
);
1392 if (!pDocLoader
->IsError())
1393 pSrcShell
= pDocLoader
->GetDocShell();
1396 pSrcShell
= GetManualOrCurrent();
1400 ScDocument
& rSrcDoc
= pSrcShell
->GetDocument();
1401 if ( nType
== SC_CONTENT_RANGENAME
|| nType
== SC_CONTENT_DBAREA
)
1404 if ( lcl_GetRange( &rSrcDoc
, nType
, aText
, aRange
) )
1406 lcl_DoDragCells( pSrcShell
, aRange
, SC_DROP_NAVIGATOR
, this );
1409 else if ( nType
== SC_CONTENT_TABLE
)
1412 if ( rSrcDoc
.GetTable( aText
, nTab
) )
1414 ScRange
aRange( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
);
1415 lcl_DoDragCells( pSrcShell
, aRange
, SC_DROP_NAVIGATOR
| SC_DROP_TABLE
, this );
1418 else if ( nType
== SC_CONTENT_GRAPHIC
|| nType
== SC_CONTENT_OLEOBJECT
||
1419 nType
== SC_CONTENT_DRAWING
)
1421 lcl_DoDragObject( pSrcShell
, aText
, nType
, this );
1423 // in ExecuteDrag kann der Navigator geloescht worden sein
1424 // -> nicht mehr auf Member zugreifen !!!
1433 ScLinkTransferObj
* pTransferObj
= new ScLinkTransferObj
;
1434 uno::Reference
<datatransfer::XTransferable
> xTransferable( pTransferObj
);
1436 if ( !aLinkURL
.isEmpty() )
1437 pTransferObj
->SetLinkURL( aLinkURL
, aLinkText
);
1439 // SetDragJump / SetDragLink has been done above
1442 pTransferObj
->StartDrag( this, DND_ACTION_COPYMOVE
| DND_ACTION_LINK
);
1446 bIsInDrag
= false; // static Member
1448 delete pDocLoader
; // falls Dokument zum Draggen geladen wurde
1451 IMPL_LINK_NOARG(ScContentTree
, ExecDragHdl
)
1453 // als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1454 // Navigator geloescht werden darf
1460 bool ScContentTree::LoadFile( const OUString
& rUrl
)
1462 OUString aDocName
= rUrl
;
1463 sal_Int32 nPos
= aDocName
.indexOf('#');
1465 aDocName
= aDocName
.copy(0, nPos
); // nur der Name, ohne #...
1467 bool bReturn
= false;
1468 OUString aURL
= aDocName
;
1469 OUString aFilter
, aOptions
;
1470 ScDocumentLoader
aLoader( aURL
, aFilter
, aOptions
);
1471 if ( !aLoader
.IsError() )
1474 aHiddenName
= aDocName
;
1475 aHiddenTitle
= aLoader
.GetTitle();
1476 pHiddenDocument
= aLoader
.GetDocument();
1478 Refresh(); // Inhalte aus geladenem Dokument holen
1480 pHiddenDocument
= NULL
;
1482 pParentWindow
->GetDocNames( &aHiddenTitle
); // Liste fuellen
1485 // Dokument wird im dtor von ScDocumentLoader wieder geschlossen
1490 void ScContentTree::InitWindowBits( bool bButtons
)
1492 WinBits nFlags
= GetStyle() | WB_CLIPCHILDREN
| WB_HSCROLL
;
1494 nFlags
|= WB_HASBUTTONS
| WB_HASBUTTONSATROOT
;
1499 void ScContentTree::SetRootType( sal_uInt16 nNew
)
1501 if ( nNew
!= nRootType
)
1504 InitWindowBits( nNew
== 0 );
1507 ScNavipiCfg
& rCfg
= SC_MOD()->GetNavipiCfg();
1508 rCfg
.SetRootType( nRootType
);
1512 void ScContentTree::ToggleRoot() // nach Selektion
1514 sal_uInt16 nNew
= SC_CONTENT_ROOT
;
1515 if ( nRootType
== SC_CONTENT_ROOT
)
1517 SvTreeListEntry
* pEntry
= GetCurEntry();
1520 SvTreeListEntry
* pParent
= GetParent(pEntry
);
1521 for (sal_uInt16 i
=1; i
<SC_CONTENT_COUNT
; i
++)
1522 if ( pEntry
== pRootNodes
[i
] || pParent
== pRootNodes
[i
] )
1527 SetRootType( nNew
);
1530 void ScContentTree::ResetManualDoc()
1538 void ScContentTree::ActiveDocChanged()
1540 if ( !bHiddenDoc
&& aManualDoc
.isEmpty() )
1541 Refresh(); // Inhalte nur wenn automatisch
1543 // Listbox muss immer geupdated werden, wegen aktiv-Flag
1547 aCurrent
= aHiddenTitle
;
1550 ScDocShell
* pSh
= GetManualOrCurrent();
1552 aCurrent
= pSh
->GetTitle();
1555 // eingestelltes Dokument existiert nicht mehr
1557 aManualDoc
.clear(); // wieder automatisch
1559 pSh
= GetManualOrCurrent(); // sollte jetzt aktives sein
1561 aCurrent
= pSh
->GetTitle();
1564 pParentWindow
->GetDocNames( &aCurrent
); // selektieren
1567 void ScContentTree::SetManualDoc(const OUString
& rName
)
1573 pParentWindow
->GetDocNames( &aManualDoc
); // selektieren
1577 void ScContentTree::SelectDoc(const OUString
& rName
) // rName wie im Menue/Listbox angezeigt
1579 if ( rName
== pParentWindow
->aStrActiveWin
)
1585 // "aktiv" oder "inaktiv" weglassen
1587 OUString aRealName
= rName
;
1588 sal_Int32 nLen
= rName
.getLength();
1589 sal_Int32 nActiveStart
= nLen
- pParentWindow
->aStrActive
.getLength();
1590 if ( rName
.copy( nActiveStart
) == pParentWindow
->aStrActive
)
1591 aRealName
= rName
.copy( 0, nActiveStart
);
1592 sal_Int32 nNotActiveStart
= nLen
- pParentWindow
->aStrNotActive
.getLength();
1593 if ( rName
.copy( nNotActiveStart
) == pParentWindow
->aStrNotActive
)
1594 aRealName
= rName
.copy( 0, nNotActiveStart
);
1596 bool bLoaded
= false;
1598 // ist es ein normal geladenes Doc ?
1600 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
1601 while ( pSh
&& !bLoaded
)
1603 if ( pSh
->ISA(ScDocShell
) )
1604 if ( pSh
->GetTitle() == aRealName
)
1606 pSh
= SfxObjectShell::GetNext( *pSh
);
1612 SetManualDoc(aRealName
);
1614 else if (!aHiddenTitle
.isEmpty()) // verstecktes ausgewaehlt
1617 LoadFile(aHiddenName
);
1621 OSL_FAIL("SelectDoc: nicht gefunden");
1625 void ScContentTree::ApplyNavigatorSettings()
1627 const ScNavigatorSettings
* pSettings
= ScNavigatorDlg::GetNavigatorSettings();
1630 sal_uInt16 nRootSel
= pSettings
->GetRootSelected();
1631 sal_uLong nChildSel
= pSettings
->GetChildSelected();
1633 for( sal_uInt16 nEntry
= 1; nEntry
< SC_CONTENT_COUNT
; ++nEntry
)
1635 if( pRootNodes
[ nEntry
] )
1638 bool bExp
= pSettings
->IsExpanded( nEntry
);
1639 if( bExp
!= IsExpanded( pRootNodes
[ nEntry
] ) )
1642 Expand( pRootNodes
[ nEntry
] );
1644 Collapse( pRootNodes
[ nEntry
] );
1648 if( nRootSel
== nEntry
)
1650 SvTreeListEntry
* pEntry
= NULL
;
1651 if( bExp
&& (nChildSel
!= SC_CONTENT_NOCHILD
) )
1652 pEntry
= GetEntry( pRootNodes
[ nEntry
], nChildSel
);
1653 Select( pEntry
? pEntry
: pRootNodes
[ nEntry
] );
1660 void ScContentTree::StoreNavigatorSettings() const
1662 ScNavigatorSettings
* pSettings
= ScNavigatorDlg::GetNavigatorSettings();
1665 for( sal_uInt16 nEntry
= 1; nEntry
< SC_CONTENT_COUNT
; ++nEntry
)
1667 bool bExp
= pRootNodes
[ nEntry
] && IsExpanded( pRootNodes
[ nEntry
] );
1668 pSettings
->SetExpanded( nEntry
, bExp
);
1672 GetEntryIndexes( nRoot
, nChild
, GetCurEntry() );
1673 pSettings
->SetRootSelected( nRoot
);
1674 pSettings
->SetChildSelected( nChild
);
1678 void ScContentTree::InitEntry(SvTreeListEntry
* pEntry
,
1679 const OUString
& rStr
, const Image
& rImg1
, const Image
& rImg2
, SvLBoxButtonKind eButtonKind
)
1681 sal_uInt16 nColToHilite
= 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
1682 SvTreeListBox::InitEntry( pEntry
, rStr
, rImg1
, rImg2
, eButtonKind
);
1683 SvLBoxString
* pCol
= static_cast<SvLBoxString
*>(pEntry
->GetItem( nColToHilite
));
1684 SvLBoxString
* pStr
= new SvLBoxString( pEntry
, 0, pCol
->GetText() );
1685 pEntry
->ReplaceItem( pStr
, nColToHilite
);
1688 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */