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.55.34.1 $
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_sw.hxx"
35 #define _SVSTDARR_STRINGSDTOR
36 #include <svtools/svstdarr.hxx>
38 #include <svtools/urlbmk.hxx>
39 #include <tools/urlobj.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/dispatch.hxx>
43 #include <vcl/help.hxx>
45 #include <sot/formats.hxx>
46 #include <vcl/sound.hxx>
47 #include <uiitems.hxx>
48 #include <fmtinfmt.hxx>
49 #include <txtinet.hxx>
51 #include <swmodule.hxx>
60 #include <content.hxx>
65 #include <section.hxx>
69 #include <navicont.hxx>
70 #include <navicfg.hxx>
73 #include <unotools.hxx>
74 #include <crsskip.hxx>
91 #include <comcore.hrc>
93 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
94 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
95 #include <com/sun/star/text/XTextTablesSupplier.hpp>
96 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
97 #include <com/sun/star/text/XDocumentIndex.hpp>
98 #include <com/sun/star/text/XBookmarksSupplier.hpp>
99 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
100 #include <com/sun/star/text/XTextFramesSupplier.hpp>
101 #include <dcontact.hxx>
102 #include <svx/svdogrp.hxx>
103 #include <svx/svdmodel.hxx>
104 #include <svx/svdpage.hxx>
105 #include <svx/svdview.hxx>
106 #include <vcl/scrbar.hxx>
107 #include <comcore.hrc>
108 #include <undobj.hxx>
109 #include <swundo.hxx>
111 #include <PostItMgr.hxx>
112 #include <postit.hxx>
113 #include <postithelper.hxx>
114 #include <redline.hxx>
115 #include <docary.hxx>
117 #include "swabstdlg.hxx"
118 #include "globals.hrc"
125 using namespace ::std
;
126 using namespace ::com::sun::star
;
127 using namespace ::com::sun::star::text
;
128 using namespace ::com::sun::star::uno
;
129 using namespace ::com::sun::star::container
;
132 #define NAVI_BOOKMARK_DELIM (sal_Unicode)1
134 /***************************************************************************
136 ***************************************************************************/
138 typedef SwContent
* SwContentPtr
;
139 SV_DECL_PTRARR_SORT_DEL( SwContentArr
, SwContentPtr
, 0,4)
140 SV_IMPL_OP_PTRARR_SORT(SwContentArr
, SwContentPtr
)
142 sal_Bool
SwContentTree::bIsInDrag
= sal_False
;
147 static sal_Bool
lcl_IsContent(SvLBoxEntry
* pEntry
)
149 return ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId() == CTYPE_CNT
;
153 static sal_Bool
lcl_IsContentType(SvLBoxEntry
* pEntry
)
155 return ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId() == CTYPE_CTT
;
159 static sal_Bool
lcl_FindShell(SwWrtShell
* pShell
)
161 sal_Bool bFound
= sal_False
;
162 SwView
*pView
= SwModule::GetFirstView();
165 if(pShell
== &pView
->GetWrtShell())
170 pView
= SwModule::GetNextView(pView
);
175 static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t
& rpMark
)
177 return IDocumentMarkAccess::GetType(*rpMark
) == IDocumentMarkAccess::BOOKMARK
;
181 /***************************************************************************
182 Beschreibung: Inhalt, enthaelt Namen und Verweis auf den Inhalstyp
183 ***************************************************************************/
186 SwContent::SwContent(const SwContentType
* pCnt
, const String
& rName
, long nYPos
) :
187 SwTypeNumber(CTYPE_CNT
),
191 bInvisible(sal_False
)
196 sal_uInt8
SwTypeNumber::GetTypeId()
201 SwTypeNumber::~SwTypeNumber()
205 sal_Bool
SwContent::IsProtect() const
210 sal_Bool
SwPostItContent::IsProtect() const
213 return pFld
->IsProtect();
218 sal_Bool
SwURLFieldContent::IsProtect() const
220 return pINetAttr
->IsProtect();
223 SwGraphicContent::~SwGraphicContent()
226 SwTOXBaseContent::~SwTOXBaseContent()
230 /***************************************************************************
231 Beschreibung: Inhaltstyp, kennt seine Inhalte und die WrtShell
232 ***************************************************************************/
235 SwContentType::SwContentType(SwWrtShell
* pShell
, sal_uInt16 nType
, sal_uInt8 nLevel
) :
236 SwTypeNumber(CTYPE_CTT
),
239 sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST
+ nType
)),
240 sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST
+ nType
)),
243 nOutlineLevel(nLevel
),
244 bMemberFilled(sal_False
),
245 bDataValid(sal_False
),
252 /***************************************************************************
253 Beschreibung: Initialisierung
254 ***************************************************************************/
257 void SwContentType::Init(sal_Bool
* pbInvalidateWindow
)
259 // wenn sich der MemberCount aendert ...
260 sal_uInt16 nOldMemberCount
= nMemberCount
;
264 case CONTENT_TYPE_OUTLINE
:
266 sTypeToken
= C2S(pMarkToOutline
);
267 sal_uInt16 nOutlineCount
= nMemberCount
=
268 static_cast<sal_uInt16
>(pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
269 if(nOutlineLevel
< MAXLEVEL
)
271 for(sal_uInt16 j
= 0; j
< nOutlineCount
; j
++)
273 if(pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineLevel(j
) > nOutlineLevel
)
281 case CONTENT_TYPE_TABLE
:
282 sTypeToken
= C2S(pMarkToTable
);
283 nMemberCount
= pWrtShell
->GetTblFrmFmtCount(sal_True
);
287 case CONTENT_TYPE_FRAME
:
288 case CONTENT_TYPE_GRAPHIC
:
289 case CONTENT_TYPE_OLE
:
291 FlyCntType eType
= FLYCNTTYPE_FRM
;
292 sTypeToken
= C2S(pMarkToFrame
);
293 if(nContentType
== CONTENT_TYPE_OLE
)
295 eType
= FLYCNTTYPE_OLE
;
296 sTypeToken
= C2S(pMarkToOLE
);
298 else if(nContentType
== CONTENT_TYPE_GRAPHIC
)
300 eType
= FLYCNTTYPE_GRF
;
301 sTypeToken
= C2S(pMarkToGraphic
);
303 nMemberCount
= pWrtShell
->GetFlyCount(eType
);
307 case CONTENT_TYPE_BOOKMARK
:
309 IDocumentMarkAccess
* const pMarkAccess
= pWrtShell
->getIDocumentMarkAccess();
310 nMemberCount
= static_cast<USHORT
>(count_if(
311 pMarkAccess
->getBookmarksBegin(),
312 pMarkAccess
->getBookmarksEnd(),
313 &lcl_IsUiVisibleBookmark
));
314 sTypeToken
= aEmptyStr
;
318 case CONTENT_TYPE_REGION
:
320 SwContentArr
* pOldMember
= 0;
321 sal_uInt16 nOldRegionCount
= 0;
322 sal_Bool bInvalidate
= sal_False
;
324 pMember
= new SwContentArr
;
325 else if(pMember
->Count())
327 pOldMember
= pMember
;
328 nOldRegionCount
= pOldMember
->Count();
329 pMember
= new SwContentArr
;
332 nMemberCount
= pWrtShell
->GetSectionFmtCount();
333 for(sal_uInt16 i
= 0; i
< nMemberCount
; i
++)
335 const SwSectionFmt
* pFmt
;
336 SectionType eTmpType
;
337 if( (pFmt
= &pWrtShell
->GetSectionFmt(i
))->IsInNodesArr() &&
338 (eTmpType
= pFmt
->GetSection()->GetType()) != TOX_CONTENT_SECTION
339 && TOX_HEADER_SECTION
!= eTmpType
)
341 const String
& rSectionName
= pFmt
->GetSection()->GetName();
343 SwSectionFmt
* pParentFmt
= pFmt
->GetParent();
347 pParentFmt
= pParentFmt
->GetParent();
350 SwContent
* pCnt
= new SwRegionContent(this, rSectionName
,
352 pFmt
->FindLayoutRect( sal_False
, &aNullPt
).Top());
354 SwPtrMsgPoolItem
aAskItem( RES_CONTENT_VISIBLE
, 0 );
355 if( !pFmt
->GetInfo( aAskItem
) &&
356 !aAskItem
.pObject
) // not visible
357 pCnt
->SetInvisible();
358 pMember
->Insert(pCnt
);//, pMember->Count());
360 sal_uInt16 nPos
= pMember
->Count() - 1;
361 if(nOldRegionCount
> nPos
&&
362 (pOldMember
->GetObject(nPos
))->IsInvisible()
363 != pCnt
->IsInvisible())
364 bInvalidate
= sal_True
;
367 nMemberCount
= pMember
->Count();
368 sTypeToken
= C2S(pMarkToRegion
);
373 pOldMember
->DeleteAndDestroy(0, pOldMember
->Count());
375 if(pbInvalidateWindow
&& bInvalidate
)
376 *pbInvalidateWindow
= sal_True
;
380 case CONTENT_TYPE_INDEX
:
382 nMemberCount
= pWrtShell
->GetTOXCount();
387 case CONTENT_TYPE_REFERENCE
:
389 nMemberCount
= pWrtShell
->GetRefMarks( 0 );
393 case CONTENT_TYPE_URLFIELD
:
397 pMember
= new SwContentArr
;
398 else if(pMember
->Count())
399 pMember
->DeleteAndDestroy(0, pMember
->Count());
402 nMemberCount
= pWrtShell
->GetINetAttrs( aArr
);
403 for( sal_uInt16 n
= 0; n
< nMemberCount
; ++n
)
405 SwGetINetAttr
* p
= aArr
[ n
];
406 SwURLFieldContent
* pCnt
= new SwURLFieldContent(
409 INetURLObject::decode(
410 p
->rINetAttr
.GetINetFmt().GetValue(),
412 INetURLObject::DECODE_UNAMBIGUOUS
,
413 RTL_TEXTENCODING_UTF8
),
416 pMember
->Insert( pCnt
);//, n );
419 nOldMemberCount
= nMemberCount
;
423 case CONTENT_TYPE_POSTIT
:
427 pMember
= new SwContentArr
;
428 else if(pMember
->Count())
429 pMember
->DeleteAndDestroy(0, pMember
->Count());
431 SwPostItMgr
* aMgr
= pWrtShell
->GetView().GetPostItMgr();
434 for(SwPostItMgr::const_iterator i
= aMgr
->begin(); i
!= aMgr
->end(); ++i
)
436 if ( (*i
)->GetBroadCaster()->ISA(SwFmtFld
)) // SwPostit
438 SwFmtFld
* aFmtFld
= static_cast<SwFmtFld
*>((*i
)->GetBroadCaster());
439 if (aFmtFld
->GetTxtFld() && aFmtFld
->IsFldInDoc() &&
440 (*i
)->mLayoutStatus
!=SwPostItHelper::INVISIBLE
)
442 String sEntry
= aFmtFld
->GetFld()->GetPar2();
443 RemoveNewline(sEntry
);
444 SwPostItContent
* pCnt
= new SwPostItContent(
447 (const SwFmtFld
*)aFmtFld
,
449 pMember
->Insert(pCnt
);
454 // this code can be used once we want redline comments in the margin
457 SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster());
458 if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) )
460 String sEntry = pRedline->GetComment();
461 RemoveNewline(sEntry);
462 SwPostItContent* pCnt = new SwPostItContent(
464 sEntry, // hier steht der Text
467 pMember->Insert(pCnt);
475 sTypeToken
= aEmptyStr
;
477 nOldMemberCount
= nMemberCount
;
480 case CONTENT_TYPE_DRAWOBJECT
:
482 sTypeToken
= aEmptyStr
;
484 SdrModel
* pModel
= pWrtShell
->getIDocumentDrawModelAccess()->GetDrawModel();
487 SdrPage
* pPage
= pModel
->GetPage(0);
488 sal_uInt32 nCount
= pPage
->GetObjCount();
489 for( sal_uInt32 i
=0; i
< nCount
; i
++ )
491 SdrObject
* pTemp
= pPage
->GetObj(i
);
492 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
493 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len())
494 if ( pTemp
->GetName().Len() )
502 // ... dann koennen die Daten auch nicht mehr gueltig sein
503 // abgesehen von denen, die schon korrigiert wurden, dann ist
504 // nOldMemberCount doch nicht so old
505 if( nOldMemberCount
!= nMemberCount
)
506 bDataValid
= sal_False
;
509 /***************************************************************************
511 ***************************************************************************/
514 SwContentType::~SwContentType()
519 /***************************************************************************
520 Beschreibung: Inhalt liefern, dazu gfs. die Liste fuellen
521 ***************************************************************************/
524 const SwContent
* SwContentType::GetMember(sal_uInt16 nIndex
)
526 if(!bDataValid
|| !pMember
)
530 if(nIndex
< pMember
->Count())
531 return pMember
->GetObject(nIndex
);
538 /***************************************************************************
540 ***************************************************************************/
543 void SwContentType::Invalidate()
545 bDataValid
= sal_False
;
548 /***************************************************************************
549 Beschreibung: Liste der Inhalte fuellen
550 ***************************************************************************/
553 void SwContentType::FillMemberList(sal_Bool
* pbLevelOrVisibiblityChanged
)
555 SwContentArr
* pOldMember
= 0;
556 int nOldMemberCount
= -1;
557 SwPtrMsgPoolItem
aAskItem( RES_CONTENT_VISIBLE
, 0 );
558 if(pMember
&& pbLevelOrVisibiblityChanged
)
560 pOldMember
= pMember
;
561 nOldMemberCount
= pOldMember
->Count();
562 pMember
= new SwContentArr
;
563 *pbLevelOrVisibiblityChanged
= sal_False
;
566 pMember
= new SwContentArr
;
567 else if(pMember
->Count())
568 pMember
->DeleteAndDestroy(0, pMember
->Count());
571 case CONTENT_TYPE_OUTLINE
:
573 sal_uInt16 nOutlineCount
= nMemberCount
=
574 static_cast<sal_uInt16
>(pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
577 for (sal_uInt16 i
= 0; i
< nOutlineCount
; ++i
)
579 const sal_Int8 nLevel
= (sal_Int8
)pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineLevel(i
);
580 if(nLevel
>= nOutlineLevel
)
584 String
aEntry(pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineText(i
));
585 aEntry
.EraseLeadingChars();
586 SwNavigationPI::CleanEntry( aEntry
);
587 SwOutlineContent
* pCnt
= new SwOutlineContent(this, aEntry
, i
, nLevel
,
588 pWrtShell
->IsOutlineMovable( i
), nPos
);
589 pMember
->Insert(pCnt
);//, nPos);
590 // bei gleicher Anzahl und vorhandenem pOldMember wird die
591 // alte mit der neuen OutlinePos verglichen
593 if(nOldMemberCount
> (int)nPos
&&
594 ((SwOutlineContent
*)pOldMember
->GetObject(nPos
))->GetOutlineLevel() != nLevel
)
595 *pbLevelOrVisibiblityChanged
= sal_True
;
604 case CONTENT_TYPE_TABLE
:
606 DBG_ASSERT(nMemberCount
==
607 pWrtShell
->GetTblFrmFmtCount(sal_True
),
608 "MemberCount differiert");
610 nMemberCount
= pWrtShell
->GetTblFrmFmtCount(sal_True
);
611 for(sal_uInt16 i
= 0; i
< nMemberCount
; i
++)
613 const SwFrmFmt
& rTblFmt
= pWrtShell
->GetTblFrmFmt(i
, sal_True
);
614 String
sTblName( rTblFmt
.GetName() );
616 SwContent
* pCnt
= new SwContent(this, sTblName
,
617 rTblFmt
.FindLayoutRect(sal_False
, &aNullPt
).Top() );
618 if( !rTblFmt
.GetInfo( aAskItem
) &&
619 !aAskItem
.pObject
) // not visible
620 pCnt
->SetInvisible();
622 pMember
->Insert(pCnt
);//, i);
624 if(nOldMemberCount
> (int)i
&&
625 (pOldMember
->GetObject(i
))->IsInvisible() != pCnt
->IsInvisible())
626 *pbLevelOrVisibiblityChanged
= sal_True
;
630 case CONTENT_TYPE_OLE
:
631 case CONTENT_TYPE_FRAME
:
632 case CONTENT_TYPE_GRAPHIC
:
634 FlyCntType eType
= FLYCNTTYPE_FRM
;
635 if(nContentType
== CONTENT_TYPE_OLE
)
636 eType
= FLYCNTTYPE_OLE
;
637 else if(nContentType
== CONTENT_TYPE_GRAPHIC
)
638 eType
= FLYCNTTYPE_GRF
;
639 DBG_ASSERT(nMemberCount
== pWrtShell
->GetFlyCount(eType
),
640 "MemberCount differiert");
642 nMemberCount
= pWrtShell
->GetFlyCount(eType
);
643 for(sal_uInt16 i
= 0; i
< nMemberCount
; i
++)
645 const SwFrmFmt
* pFrmFmt
= pWrtShell
->GetFlyNum(i
,eType
);
646 String sFrmName
= pFrmFmt
->GetName();
649 if(CONTENT_TYPE_GRAPHIC
== nContentType
)
652 pWrtShell
->GetGrfNms( &sLink
, 0, (SwFlyFrmFmt
*) pFrmFmt
);
653 pCnt
= new SwGraphicContent(this, sFrmName
,
654 INetURLObject::decode( sLink
, INET_HEX_ESCAPE
,
655 INetURLObject::DECODE_UNAMBIGUOUS
,
656 RTL_TEXTENCODING_UTF8
),
657 pFrmFmt
->FindLayoutRect(sal_False
, &aNullPt
).Top());
661 pCnt
= new SwContent(this, sFrmName
,
662 pFrmFmt
->FindLayoutRect(sal_False
, &aNullPt
).Top() );
664 if( !pFrmFmt
->GetInfo( aAskItem
) &&
665 !aAskItem
.pObject
) // not visible
666 pCnt
->SetInvisible();
667 pMember
->Insert(pCnt
);//, i);
668 if(nOldMemberCount
> (int)i
&&
669 (pOldMember
->GetObject(i
))->IsInvisible() != pCnt
->IsInvisible())
670 *pbLevelOrVisibiblityChanged
= sal_True
;
674 case CONTENT_TYPE_BOOKMARK
:
676 IDocumentMarkAccess
* const pMarkAccess
= pWrtShell
->getIDocumentMarkAccess();
677 for(IDocumentMarkAccess::const_iterator_t ppBookmark
= pMarkAccess
->getBookmarksBegin();
678 ppBookmark
!= pMarkAccess
->getBookmarksEnd();
681 if(lcl_IsUiVisibleBookmark(*ppBookmark
))
683 const String
& rBkmName
= ppBookmark
->get()->GetName();
684 //nYPos von 0 -> text::Bookmarks werden nach Alphabet sortiert
685 SwContent
* pCnt
= new SwContent(this, rBkmName
, 0);
686 pMember
->Insert(pCnt
);//, pMember->Count());
691 case CONTENT_TYPE_REGION
:
694 nMemberCount
= pWrtShell
->GetSectionFmtCount();
695 for(sal_uInt16 i
= 0; i
< nMemberCount
; i
++)
697 const SwSectionFmt
* pFmt
;
698 SectionType eTmpType
;
699 if( (pFmt
= &pWrtShell
->GetSectionFmt(i
))->IsInNodesArr() &&
700 (eTmpType
= pFmt
->GetSection()->GetType()) != TOX_CONTENT_SECTION
701 && TOX_HEADER_SECTION
!= eTmpType
)
703 String sSectionName
= pFmt
->GetSection()->GetName();
706 SwSectionFmt
* pParentFmt
= pFmt
->GetParent();
710 pParentFmt
= pParentFmt
->GetParent();
713 SwContent
* pCnt
= new SwRegionContent(this, sSectionName
,
715 pFmt
->FindLayoutRect( sal_False
, &aNullPt
).Top());
716 if( !pFmt
->GetInfo( aAskItem
) &&
717 !aAskItem
.pObject
) // not visible
718 pCnt
->SetInvisible();
719 pMember
->Insert(pCnt
);//, pMember->Count());
721 sal_uInt16 nPos
= pMember
->Count() - 1;
722 if(nOldMemberCount
> nPos
&&
723 (pOldMember
->GetObject(nPos
))->IsInvisible()
724 != pCnt
->IsInvisible())
725 *pbLevelOrVisibiblityChanged
= sal_True
;
728 nMemberCount
= pMember
->Count();
731 case CONTENT_TYPE_REFERENCE
:
733 SvStringsDtor aRefMarks
;
734 nMemberCount
= pWrtShell
->GetRefMarks( &aRefMarks
);
736 for(sal_uInt16 i
=0; i
<nMemberCount
; i
++)
738 //Referenzen nach Alphabet sortiert
739 SwContent
* pCnt
= new SwContent(
740 this, *aRefMarks
.GetObject(i
), 0);
741 pMember
->Insert(pCnt
);//, i);
745 case CONTENT_TYPE_URLFIELD
:
748 nMemberCount
= pWrtShell
->GetINetAttrs( aArr
);
749 for( sal_uInt16 n
= 0; n
< nMemberCount
; ++n
)
751 SwGetINetAttr
* p
= aArr
[ n
];
752 SwURLFieldContent
* pCnt
= new SwURLFieldContent(
755 INetURLObject::decode(
756 p
->rINetAttr
.GetINetFmt().GetValue(),
758 INetURLObject::DECODE_UNAMBIGUOUS
,
759 RTL_TEXTENCODING_UTF8
),
762 pMember
->Insert( pCnt
);//, n );
766 case CONTENT_TYPE_INDEX
:
769 sal_uInt16 nCount
= nMemberCount
= pWrtShell
->GetTOXCount();
770 for ( sal_uInt16 nTox
= 0; nTox
< nCount
; nTox
++ )
772 const SwTOXBase
* pBase
= pWrtShell
->GetTOX( nTox
);
773 String
sTOXNm( pBase
->GetTOXName() );
775 SwContent
* pCnt
= new SwTOXBaseContent(
776 this, sTOXNm
, nTox
, *pBase
);
778 if( !pBase
->GetInfo( aAskItem
) &&
779 !aAskItem
.pObject
) // not visible
780 pCnt
->SetInvisible();
782 pMember
->Insert( pCnt
);//, nTox );
783 sal_uInt16 nPos
= pMember
->Count() - 1;
784 if(nOldMemberCount
> nPos
&&
785 (pOldMember
->GetObject(nPos
))->IsInvisible()
786 != pCnt
->IsInvisible())
787 *pbLevelOrVisibiblityChanged
= sal_True
;
791 case CONTENT_TYPE_POSTIT
:
795 pMember
= new SwContentArr
;
796 else if(pMember
->Count())
797 pMember
->DeleteAndDestroy(0, pMember
->Count());
798 SwPostItMgr
* aMgr
= pWrtShell
->GetView().GetPostItMgr();
801 for(SwPostItMgr::const_iterator i
= aMgr
->begin(); i
!= aMgr
->end(); ++i
)
803 if ( (*i
)->GetBroadCaster()->ISA(SwFmtFld
)) // SwPostit
805 SwFmtFld
* aFmtFld
= static_cast<SwFmtFld
*>((*i
)->GetBroadCaster());
806 if (aFmtFld
->GetTxtFld() && aFmtFld
->IsFldInDoc() &&
807 (*i
)->mLayoutStatus
!=SwPostItHelper::INVISIBLE
)
809 String sEntry
= aFmtFld
->GetFld()->GetPar2();
810 RemoveNewline(sEntry
);
811 SwPostItContent
* pCnt
= new SwPostItContent(
814 (const SwFmtFld
*)aFmtFld
,
816 pMember
->Insert(pCnt
);
820 /* this code can be used once we want redline comments in the margin
823 SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster());
824 if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) )
826 String sEntry = pRedline->GetComment();
827 RemoveNewline(sEntry);
828 SwPostItContent* pCnt = new SwPostItContent(
833 pMember->Insert(pCnt);
843 case CONTENT_TYPE_DRAWOBJECT
:
847 pMember
= new SwContentArr
;
848 else if(pMember
->Count())
849 pMember
->DeleteAndDestroy(0, pMember
->Count());
851 IDocumentDrawModelAccess
* pIDDMA
= pWrtShell
->getIDocumentDrawModelAccess();
852 SdrModel
* pModel
= pIDDMA
->GetDrawModel();
855 SdrPage
* pPage
= pModel
->GetPage(0);
856 sal_uInt32 nCount
= pPage
->GetObjCount();
857 for( sal_uInt32 i
=0; i
< nCount
; i
++ )
859 SdrObject
* pTemp
= pPage
->GetObj(i
);
860 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
861 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len())
862 if ( pTemp
->GetName().Len() )
865 SwContact
* pContact
= (SwContact
*)pTemp
->GetUserCall();
868 if(pContact
&& pContact
->GetFmt())
869 nYPos
= pContact
->GetFmt()->FindLayoutRect(sal_False
, &aNullPt
).Top();
870 SwContent
* pCnt
= new SwContent(
874 if(!pIDDMA
->IsVisibleLayerId(pTemp
->GetLayer()))
875 pCnt
->SetInvisible();
876 pMember
->Insert(pCnt
);
878 if(nOldMemberCount
> (int)i
&&
879 (pOldMember
->GetObject((USHORT
)i
))->IsInvisible() != pCnt
->IsInvisible())
880 *pbLevelOrVisibiblityChanged
= sal_True
;
887 bDataValid
= sal_True
;
889 pOldMember
->DeleteAndDestroy(0, pOldMember
->Count());
893 /***************************************************************************
894 Beschreibung: TreeListBox fuer Inhaltsanzeige
895 ***************************************************************************/
898 SwContentTree::SwContentTree(Window
* pParent
, const ResId
& rResId
) :
899 SvTreeListBox( pParent
, rResId
),
903 sRemoveIdx(SW_RES(ST_REMOVE_INDEX
)),
904 sUpdateIdx(SW_RES(ST_UPDATE
)),
905 sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION
)),
906 sRename(SW_RES(ST_RENAME
)),
907 sReadonlyIdx(SW_RES(ST_READONLY_IDX
)),
908 sInvisible(SW_RES(ST_INVISIBLE
)),
909 sPostItShow(SW_RES(ST_POSTIT_SHOW
)),
910 sPostItHide(SW_RES(ST_POSTIT_HIDE
)),
911 sPostItDelete(SW_RES(ST_POSTIT_DELETE
)),
915 pConfig(SW_MOD()->GetNavigationConfig()),
920 nRootType(USHRT_MAX
),
921 nLastSelType(USHRT_MAX
),
922 nOutlineLevel(MAXLEVEL
),
925 bIsConstant(sal_False
),
926 bIsHidden(sal_False
),
927 bDocChgdInDragging(sal_False
),
928 bIsInternalDrag(sal_False
),
930 bIsIdleClear(sal_False
),
931 bIsLastReadOnly(sal_False
),
932 bIsOutlineMoveable(sal_True
),
933 bViewHasChanged(sal_False
),
934 bIsImageListInitialized(sal_False
)
938 SetHelpId(HID_NAVIGATOR_TREELIST
);
940 SetNodeDefaultImages();
941 SetDoubleClickHdl(LINK(this, SwContentTree
, ContentDoubleClickHdl
));
942 SetDragDropMode(SV_DRAGDROP_APP_COPY
);
943 for( i
= 0; i
< CONTENT_TYPE_MAX
; i
++)
945 aActiveContentArr
[i
] = 0;
946 aHiddenContentArr
[i
] = 0;
948 for( i
= 0; i
< CONTEXT_COUNT
; i
++ )
950 aContextStrings
[i
] = SW_RESSTR(i
+ST_CONTEXT_FIRST
);
952 nActiveBlock
= pConfig
->GetActiveBlock();
953 aUpdTimer
.SetTimeoutHdl(LINK(this, SwContentTree
, TimerUpdate
));
954 aUpdTimer
.SetTimeout(1000);
956 EnableContextMenuHandling();
959 /***************************************************************************
961 ***************************************************************************/
964 SwContentTree::~SwContentTree()
966 Clear(); // vorher gfs. Inhaltstypen loeschen
967 bIsInDrag
= sal_False
;
970 /***************************************************************************
972 ***************************************************************************/
973 void SwContentTree::StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
)
975 if( !bIsRoot
|| nRootType
!= CONTENT_TYPE_OUTLINE
)
979 TransferDataContainer
* pContainer
= new TransferDataContainer
;
981 datatransfer::XTransferable
> xRef( pContainer
);
983 sal_Int8 nDragMode
= DND_ACTION_COPYMOVE
| DND_ACTION_LINK
;
984 if( FillTransferData( *pContainer
, nDragMode
))
986 SwContentTree::SetInDrag(sal_True
);
987 pContainer
->StartDrag( this, nDragMode
, GetDragFinishedHdl() );
991 SvTreeListBox::StartDrag( nAction
, rPosPixel
);
994 void SwContentTree::DragFinished( sal_Int8 nAction
)
996 //to prevent the removing of the selected entry in external drag and drop
997 // the drag action mustn't be MOVE
998 SvTreeListBox::DragFinished( bIsInternalDrag
? nAction
: DND_ACTION_COPY
);
999 SwContentTree::SetInDrag(sal_False
);
1000 bIsInternalDrag
= sal_False
;
1003 /***************************************************************************
1004 Beschreibung: QueryDrop wird im Navigator ausgefuehrt
1005 ***************************************************************************/
1006 sal_Int8
SwContentTree::AcceptDrop( const AcceptDropEvent
& rEvt
)
1008 sal_Int8 nRet
= DND_ACTION_NONE
;
1011 if( bIsOutlineMoveable
)
1012 nRet
= SvTreeListBox::AcceptDrop( rEvt
);
1014 else if( !bIsInDrag
)
1015 nRet
= GetParentWindow()->AcceptDrop( rEvt
);
1019 /***************************************************************************
1020 Beschreibung: Drop wird im Navigator ausgefuehrt
1021 ***************************************************************************/
1022 void* lcl_GetOutlineKey( SwContentTree
* pTree
, SwOutlineContent
* pContent
)
1025 if( pTree
&& pContent
)
1027 SwWrtShell
* pShell
= pTree
->GetWrtShell();
1028 sal_Int32 nPos
= pContent
->GetYPos();
1031 key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1037 sal_Int8
SwContentTree::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
1039 SvLBoxEntry
* pEntry
= pTargetEntry
;
1040 if( pEntry
&& ( nRootType
== CONTENT_TYPE_OUTLINE
) && lcl_IsContent( pEntry
) )
1042 SwOutlineContent
* pOutlineContent
= ( SwOutlineContent
* )( pEntry
->GetUserData() );
1043 if( pOutlineContent
)
1045 void* key
= lcl_GetOutlineKey(this, pOutlineContent
);
1046 if( !mOutLineNodeMap
[key
] )
1048 while( pEntry
->HasChilds() )
1050 SvLBoxEntry
* pChildEntry
= FirstChild( pEntry
);
1051 while( pChildEntry
)
1053 pEntry
= pChildEntry
;
1054 pChildEntry
= NextSibling( pChildEntry
);
1057 pTargetEntry
= pEntry
;
1062 return SvTreeListBox::ExecuteDrop( rEvt
);
1063 return bIsInDrag
? DND_ACTION_NONE
: GetParentWindow()->ExecuteDrop(rEvt
);
1067 /***************************************************************************
1068 Beschreibung: Handler fuer Dragging und ContextMenu
1069 ***************************************************************************/
1070 PopupMenu
* SwContentTree::CreateContextMenu( void )
1072 PopupMenu
* pPop
= new PopupMenu
;
1073 PopupMenu
* pSubPop1
= new PopupMenu
;
1074 PopupMenu
* pSubPop2
= new PopupMenu
;
1075 PopupMenu
* pSubPop3
= new PopupMenu
;
1076 PopupMenu
* pSubPop4
= new PopupMenu
; // Edit
1079 for(i
= 1; i
<= MAXLEVEL
; i
++ )
1081 pSubPop1
->InsertItem( i
+ 100, String::CreateFromInt32(i
));
1083 pSubPop1
->CheckItem(100 + nOutlineLevel
);
1084 for(i
=0; i
< 3; i
++ )
1086 pSubPop2
->InsertItem( i
+ 201, aContextStrings
[
1087 ST_HYPERLINK
- ST_CONTEXT_FIRST
+ i
]);
1089 pSubPop2
->CheckItem( 201 +
1090 GetParentWindow()->GetRegionDropMode());
1091 //Liste der offenen Dateien einfuegen
1092 sal_uInt16 nId
= 301;
1093 const SwView
* pActiveView
= ::GetActiveView();
1094 SwView
*pView
= SwModule::GetFirstView();
1097 String sInsert
= pView
->GetDocShell()->GetTitle();
1098 if(pView
== pActiveView
)
1101 sInsert
+= aContextStrings
[ ST_ACTIVE
- ST_CONTEXT_FIRST
];
1104 pSubPop3
->InsertItem(nId
, sInsert
);
1105 if(bIsConstant
&& pActiveShell
== &pView
->GetWrtShell())
1106 pSubPop3
->CheckItem(nId
);
1107 pView
= SwModule::GetNextView(pView
);
1110 pSubPop3
->InsertItem(nId
++, aContextStrings
[ST_ACTIVE_VIEW
- ST_CONTEXT_FIRST
]);
1113 String sHiddenEntry
= pHiddenShell
->GetView().GetDocShell()->GetTitle();
1114 sHiddenEntry
+= C2S(" ( ");
1115 sHiddenEntry
+= aContextStrings
[ ST_HIDDEN
- ST_CONTEXT_FIRST
];
1116 sHiddenEntry
+= C2S(" )");
1117 pSubPop3
->InsertItem(nId
, sHiddenEntry
);
1121 pSubPop3
->CheckItem( --nId
);
1123 pSubPop3
->CheckItem( nId
);
1125 pPop
->InsertItem( 1, aContextStrings
[ST_OUTLINE_LEVEL
- ST_CONTEXT_FIRST
]);
1126 pPop
->InsertItem(2, aContextStrings
[ST_DRAGMODE
- ST_CONTEXT_FIRST
]);
1127 pPop
->InsertItem(3, aContextStrings
[ST_DISPLAY
- ST_CONTEXT_FIRST
]);
1128 //jetzt noch bearbeiten
1129 SvLBoxEntry
* pEntry
= 0;
1130 //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen
1131 if((bIsActive
|| pActiveShell
== pActiveView
->GetWrtShellPtr())
1132 && 0 != (pEntry
= FirstSelected()) && lcl_IsContent(pEntry
))
1134 const SwContentType
* pContType
= ((SwContent
*)pEntry
->GetUserData())->GetParent();
1135 const sal_uInt16 nContentType
= pContType
->GetType();
1136 sal_Bool bReadonly
= pActiveShell
->GetView().GetDocShell()->IsReadOnly();
1137 sal_Bool bVisible
= !((SwContent
*)pEntry
->GetUserData())->IsInvisible();
1138 sal_Bool bProtected
= ((SwContent
*)pEntry
->GetUserData())->IsProtect();
1139 sal_Bool bEditable
= pContType
->IsEditable() &&
1140 ((bVisible
&& !bProtected
) ||CONTENT_TYPE_REGION
== nContentType
);
1141 sal_Bool bDeletable
= pContType
->IsDeletable() &&
1142 ((bVisible
&& !bProtected
) ||CONTENT_TYPE_REGION
== nContentType
);
1143 sal_Bool bRenamable
= bEditable
&& !bReadonly
&&
1144 (CONTENT_TYPE_TABLE
== nContentType
||
1145 CONTENT_TYPE_FRAME
== nContentType
||
1146 CONTENT_TYPE_GRAPHIC
== nContentType
||
1147 CONTENT_TYPE_OLE
== nContentType
||
1148 CONTENT_TYPE_BOOKMARK
== nContentType
||
1149 CONTENT_TYPE_REGION
== nContentType
||
1150 CONTENT_TYPE_INDEX
== nContentType
);
1152 if(!bReadonly
&& (bEditable
|| bDeletable
))
1154 sal_Bool bSubPop4
= sal_False
;
1155 if(CONTENT_TYPE_INDEX
== nContentType
)
1157 bSubPop4
= sal_True
;
1158 pSubPop4
->InsertItem(401, sRemoveIdx
);
1159 pSubPop4
->InsertItem(402, sUpdateIdx
);
1161 const SwTOXBase
* pBase
= ((SwTOXBaseContent
*)pEntry
->GetUserData())->GetTOXBase();
1162 if(!pBase
->IsTOXBaseInReadonly())
1163 pSubPop4
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1164 pSubPop4
->InsertItem(405, sReadonlyIdx
);
1166 pSubPop4
->CheckItem( 405, pActiveShell
->IsTOXBaseReadonly(*pBase
));
1167 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1169 else if(CONTENT_TYPE_TABLE
== nContentType
&& !bReadonly
)
1171 bSubPop4
= sal_True
;
1172 pSubPop4
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1173 pSubPop4
->InsertItem(404, sUnprotTbl
);
1174 sal_Bool bFull
= sal_False
;
1175 String sTblName
= ((SwContent
*)pEntry
->GetUserData())->GetName();
1176 sal_Bool bProt
=pActiveShell
->HasTblAnyProtection( &sTblName
, &bFull
);
1177 pSubPop4
->EnableItem(403, !bFull
);
1178 pSubPop4
->EnableItem(404, bProt
);
1179 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1181 else if(bEditable
|| bDeletable
)
1184 if(bEditable
&& bDeletable
)
1186 pSubPop4
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1187 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1188 bSubPop4
= sal_True
;
1191 pPop
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1194 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1201 pSubPop4
->InsertItem(502, sRename
);
1203 pPop
->InsertItem(502, sRename
);
1208 pPop
->InsertItem(4, pContType
->GetSingleName());
1209 pPop
->SetPopupMenu(4, pSubPop4
);
1215 SwContentType
* pType
= (SwContentType
*)pEntry
->GetUserData();
1216 if ( (pType
->GetType() == CONTENT_TYPE_POSTIT
) && (!pActiveShell
->GetView().GetDocShell()->IsReadOnly()) && ( pType
->GetMemberCount() > 0) )
1218 pSubPop4
->InsertItem(600, sPostItShow
);
1219 pSubPop4
->InsertItem(601, sPostItHide
);
1220 pSubPop4
->InsertItem(602, sPostItDelete
);
1222 pSubPop4->InsertItem(603,rtl::OUString::createFromAscii("Sort"));
1223 PopupMenu* pMenuSort = new PopupMenu;
1224 pMenuSort->InsertItem(604,rtl::OUString::createFromAscii("By Position"));
1225 pMenuSort->InsertItem(605,rtl::OUString::createFromAscii("By Author"));
1226 pMenuSort->InsertItem(606,rtl::OUString::createFromAscii("By Date"));
1227 pSubPop4->SetPopupMenu(603, pMenuSort);
1229 pPop
->InsertItem(4, pType
->GetSingleName());
1230 pPop
->SetPopupMenu(4, pSubPop4
);
1234 pPop
->SetPopupMenu( 1, pSubPop1
);
1235 pPop
->SetPopupMenu( 2, pSubPop2
);
1236 pPop
->SetPopupMenu( 3, pSubPop3
);
1240 /***************************************************************************
1241 Beschreibung: Einrueckung fuer outlines (und sections)
1242 ***************************************************************************/
1245 long SwContentTree::GetTabPos( SvLBoxEntry
* pEntry
, SvLBoxTab
* pTab
)
1247 sal_uInt16 nLevel
= 0;
1248 if(lcl_IsContent(pEntry
))
1251 SwContent
* pCnt
= (SwContent
*) pEntry
->GetUserData();
1252 const SwContentType
* pParent
;
1253 if(pCnt
&& 0 != (pParent
= pCnt
->GetParent()))
1255 if(pParent
->GetType() == CONTENT_TYPE_OUTLINE
)
1256 nLevel
= nLevel
+ ((SwOutlineContent
*)pCnt
)->GetOutlineLevel();
1257 else if(pParent
->GetType() == CONTENT_TYPE_REGION
)
1258 nLevel
= nLevel
+ ((SwRegionContent
*)pCnt
)->GetRegionLevel();
1261 sal_uInt16 nBasis
= bIsRoot
? 0 : 5;
1262 return nLevel
* 10 + nBasis
+ pTab
->GetPos(); //empirisch ermittelt
1265 /***************************************************************************
1266 Beschreibung: Inhalte werden erst auf Anforderung in die Box eingefuegt
1267 ***************************************************************************/
1270 void SwContentTree::RequestingChilds( SvLBoxEntry
* pParent
)
1272 // ist es ein Inhaltstyp?
1273 if(lcl_IsContentType(pParent
))
1275 if(!pParent
->HasChilds())
1277 DBG_ASSERT(pParent
->GetUserData(), "keine UserData?");
1278 SwContentType
* pCntType
= (SwContentType
*)pParent
->GetUserData();
1280 sal_uInt16 nCount
= pCntType
->GetMemberCount();
1281 /**************************************************************
1282 Add for outline plus/minus
1283 ***************************************************************/
1284 if(pCntType
->GetType() == CONTENT_TYPE_OUTLINE
)
1286 SvLBoxEntry
* pChild
= 0;
1287 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
1289 const SwContent
* pCnt
= pCntType
->GetMember(i
);
1292 sal_uInt16 nLevel
= ((SwOutlineContent
*)pCnt
)->GetOutlineLevel();
1293 String sEntry
= pCnt
->GetName();
1296 if(!pChild
|| (nLevel
== 0))
1297 pChild
= InsertEntry(sEntry
, pParent
,
1298 sal_False
, LIST_APPEND
,(void*)pCnt
);
1301 //back search parent.
1302 if(((SwOutlineContent
*)pCntType
->GetMember(i
-1))->GetOutlineLevel() < nLevel
)
1303 pChild
= InsertEntry(sEntry
, pChild
,
1304 sal_False
, LIST_APPEND
, (void*)pCnt
);
1307 pChild
= Prev(pChild
);
1309 lcl_IsContent(pChild
) &&
1310 !(((SwOutlineContent
*)pChild
->GetUserData())->GetOutlineLevel() < nLevel
)
1313 pChild
= Prev(pChild
);
1316 pChild
= InsertEntry(sEntry
, pChild
,
1317 sal_False
, LIST_APPEND
, (void*)pCnt
);
1325 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
1327 const SwContent
* pCnt
= pCntType
->GetMember(i
);
1330 String sEntry
= pCnt
->GetName();
1333 InsertEntry(sEntry
, pParent
,
1334 sal_False
, LIST_APPEND
, (void*)pCnt
);
1342 /***************************************************************************
1343 Beschreibung: Expand - Zustand fuer Inhaltstypen merken
1344 ***************************************************************************/
1347 sal_Bool
SwContentTree::Expand( SvLBoxEntry
* pParent
)
1349 if(!bIsRoot
|| (((SwContentType
*)pParent
->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE
) ||
1350 (nRootType
== CONTENT_TYPE_OUTLINE
))
1352 if(lcl_IsContentType(pParent
))
1354 SwContentType
* pCntType
= (SwContentType
*)pParent
->GetUserData();
1355 sal_uInt16 nOr
= 1 << pCntType
->GetType(); //linear -> Bitposition
1356 if(bIsActive
|| bIsConstant
)
1358 nActiveBlock
|= nOr
;
1359 pConfig
->SetActiveBlock(nActiveBlock
);
1362 nHiddenBlock
|= nOr
;
1363 if((pCntType
->GetType() == CONTENT_TYPE_OUTLINE
))
1365 std::map
< void*, sal_Bool
> mCurrOutLineNodeMap
;
1367 SwWrtShell
* pShell
= GetWrtShell();
1368 sal_Bool bBool
= SvTreeListBox::Expand(pParent
);
1369 SvLBoxEntry
* pChild
= Next(pParent
);
1370 while(pChild
&& lcl_IsContent(pChild
) && pParent
->HasChilds())
1372 if(pChild
->HasChilds())
1374 sal_Int32 nPos
= ((SwContent
*)pChild
->GetUserData())->GetYPos();
1375 void* key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1376 mCurrOutLineNodeMap
.insert(std::map
<void*, sal_Bool
>::value_type( key
, sal_False
) );
1377 std::map
<void*,sal_Bool
>::iterator iter
= mOutLineNodeMap
.find( key
);
1378 if( iter
!= mOutLineNodeMap
.end() && mOutLineNodeMap
[key
])
1380 mCurrOutLineNodeMap
[key
] = sal_True
;
1381 SvTreeListBox::Expand(pChild
);
1384 pChild
= Next(pChild
);
1386 mOutLineNodeMap
= mCurrOutLineNodeMap
;
1391 else if( lcl_IsContent(pParent
) )
1393 SwWrtShell
* pShell
= GetWrtShell();
1394 sal_Int32 nPos
= ((SwContent
*)pParent
->GetUserData())->GetYPos();
1395 void* key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1396 mOutLineNodeMap
[key
] = sal_True
;
1399 return SvTreeListBox::Expand(pParent
);
1401 /***************************************************************************
1402 Beschreibung: Collapse - Zustand fuer Inhaltstypen merken
1403 ***************************************************************************/
1406 sal_Bool
SwContentTree::Collapse( SvLBoxEntry
* pParent
)
1409 if(!bIsRoot
|| (((SwContentType
*)pParent
->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE
) ||
1410 (nRootType
== CONTENT_TYPE_OUTLINE
))
1412 if(lcl_IsContentType(pParent
))
1415 return bRet
= sal_False
;
1416 SwContentType
* pCntType
= (SwContentType
*)pParent
->GetUserData();
1417 sal_uInt16 nAnd
= 1 << pCntType
->GetType();
1419 if(bIsActive
|| bIsConstant
)
1421 nActiveBlock
&= nAnd
;
1422 pConfig
->SetActiveBlock(nActiveBlock
);
1425 nHiddenBlock
&= nAnd
;
1427 else if( lcl_IsContent(pParent
) )
1429 SwWrtShell
* pShell
= GetWrtShell();
1430 sal_Int32 nPos
= ((SwContent
*)pParent
->GetUserData())->GetYPos();
1431 void* key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1432 mOutLineNodeMap
[key
] = sal_False
;
1434 bRet
= SvTreeListBox::Collapse(pParent
);
1437 // bRet = sal_False;
1438 bRet
= SvTreeListBox::Collapse(pParent
);
1443 /***************************************************************************
1444 Beschreibung: Auch auf Doppelclick wird zunaechst nur aufgeklappt
1445 ***************************************************************************/
1448 IMPL_LINK( SwContentTree
, ContentDoubleClickHdl
, SwContentTree
*, EMPTYARG
)
1450 SvLBoxEntry
* pEntry
= GetCurEntry();
1451 // ist es ein Inhaltstyp?
1452 DBG_ASSERT(pEntry
, "kein aktueller Eintrag!");
1455 if(lcl_IsContentType(pEntry
) && !pEntry
->HasChilds())
1456 RequestingChilds(pEntry
);
1457 else if(!lcl_IsContentType(pEntry
) && (bIsActive
|| bIsConstant
))
1461 pActiveShell
->GetView().GetViewFrame()->GetWindow().ToTop();
1463 //Inhaltstyp anspringen:
1464 SwContent
* pCnt
= (SwContent
*)pEntry
->GetUserData();
1465 DBG_ASSERT( pCnt
, "keine UserData");
1467 if(pCnt
->GetParent()->GetType() == CONTENT_TYPE_FRAME
)
1468 pActiveShell
->EnterStdMode();
1474 /***************************************************************************
1475 Beschreibung: Anzeigen der Datei
1476 ***************************************************************************/
1479 void SwContentTree::Display( sal_Bool bActive
)
1481 if(!bIsImageListInitialized
)
1483 USHORT nResId
= GetDisplayBackground().GetColor().IsDark() ? IMG_NAVI_ENTRYBMPH
: IMG_NAVI_ENTRYBMP
;
1484 aEntryImages
= ImageList(SW_RES(nResId
));
1485 bIsImageListInitialized
= sal_True
;
1487 // erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder
1488 // zu selektieren -> die UserDaten sind hier nicht mehr gueltig!
1489 SvLBoxEntry
* pOldSelEntry
= FirstSelected();
1490 String sEntryName
; // Name des Eintrags
1491 sal_uInt16 nEntryRelPos
= 0; // rel. Pos zu seinem Parent
1492 sal_uInt32 nOldEntryCount
= GetEntryCount();
1493 sal_Int32 nOldScrollPos
= 0;
1496 ScrollBar
* pVScroll
= GetVScroll();
1497 if(pVScroll
&& pVScroll
->IsVisible())
1498 nOldScrollPos
= pVScroll
->GetThumbPos();
1500 sEntryName
= GetEntryText(pOldSelEntry
);
1501 SvLBoxEntry
* pParantEntry
= pOldSelEntry
;
1502 while( GetParent(pParantEntry
))
1504 pParantEntry
= GetParent(pParantEntry
);
1506 if(GetParent(pOldSelEntry
))
1508 nEntryRelPos
= (sal_uInt16
)(GetModel()->GetAbsPos(pOldSelEntry
) - GetModel()->GetAbsPos(pParantEntry
));
1512 SetUpdateMode( sal_False
);
1513 if(bActive
&& !bIsConstant
&& !bIsActive
)
1514 bIsActive
= bActive
;
1515 bIsHidden
= !bActive
;
1516 SwWrtShell
* pShell
= GetWrtShell();
1517 sal_Bool bReadOnly
= pShell
? pShell
->GetView().GetDocShell()->IsReadOnly() : sal_True
;
1518 if(bReadOnly
!= bIsLastReadOnly
)
1520 bIsLastReadOnly
= bReadOnly
;
1521 sal_Bool bDisable
= pShell
== 0 || bReadOnly
;
1522 SwNavigationPI
* pNavi
= GetParentWindow();
1523 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_UP
, !bDisable
);
1524 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_DOWN
, !bDisable
);
1525 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_LEFT
, !bDisable
);
1526 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_RIGHT
, !bDisable
);
1527 pNavi
->aContentToolBox
.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK
, !bDisable
);
1531 SvLBoxEntry
* pSelEntry
= 0;
1532 if(nRootType
== USHRT_MAX
)
1534 for(sal_uInt16 nCntType
= CONTENT_TYPE_OUTLINE
;
1535 nCntType
<= CONTENT_TYPE_DRAWOBJECT
; nCntType
++ )
1537 SwContentType
** ppContentT
= bActive
?
1538 &aActiveContentArr
[nCntType
] :
1539 &aHiddenContentArr
[nCntType
];
1541 (*ppContentT
) = new SwContentType(pShell
, nCntType
, nOutlineLevel
);
1544 String sEntry
= (*ppContentT
)->GetName();
1545 SvLBoxEntry
* pEntry
;
1546 const Image
& rImage
= aEntryImages
.GetImage(SID_SW_START
+ nCntType
);
1547 sal_Bool bChOnDemand
= 0 != (*ppContentT
)->GetMemberCount();
1548 pEntry
= InsertEntry(sEntry
, rImage
, rImage
,
1549 0, bChOnDemand
, LIST_APPEND
, (*ppContentT
));
1550 if(nCntType
== nLastSelType
)
1552 sal_Int32 nExpandOptions
= bIsActive
|| bIsConstant
?
1555 if(nExpandOptions
& (1 << nCntType
))
1558 if(nEntryRelPos
&& nCntType
== nLastSelType
)
1560 // jetzt vielleicht noch ein Child selektieren
1561 SvLBoxEntry
* pChild
= pEntry
;
1562 SvLBoxEntry
* pTemp
= 0;
1563 sal_uInt16 nPos
= 1;
1564 while(0 != (pChild
= Next(pChild
)))
1566 // der alte Text wird leicht bevorzugt
1567 if(sEntryName
== GetEntryText(pChild
) ||
1568 nPos
== nEntryRelPos
)
1576 if(!pSelEntry
|| lcl_IsContentType(pSelEntry
))
1584 MakeVisible(pSelEntry
);
1592 SwContentType
** ppRootContentT
= bActive
?
1593 &aActiveContentArr
[nRootType
] :
1594 &aHiddenContentArr
[nRootType
];
1595 if(!(*ppRootContentT
))
1596 (*ppRootContentT
) = new SwContentType(pShell
, nRootType
, nOutlineLevel
);
1597 const Image
& rImage
= aEntryImages
.GetImage(20000 + nRootType
);
1598 SvLBoxEntry
* pParent
= InsertEntry(
1599 (*ppRootContentT
)->GetName(), rImage
, rImage
,
1600 0, sal_False
, LIST_APPEND
, *ppRootContentT
);
1602 if(nRootType
!= CONTENT_TYPE_OUTLINE
)
1604 SvLBoxEntry
* pEntry
;
1605 for(sal_uInt16 i
= 0; i
< (*ppRootContentT
)->GetMemberCount(); i
++ )
1607 const SwContent
* pCnt
= (*ppRootContentT
)->GetMember(i
);
1610 String sEntry
= pCnt
->GetName();
1613 InsertEntry( sEntry
, pParent
,
1614 sal_False
, LIST_APPEND
, (void*)pCnt
);
1619 RequestingChilds(pParent
);
1621 if( nRootType
== CONTENT_TYPE_OUTLINE
&& bIsActive
)
1623 //feststellen, wo der Cursor steht
1624 const sal_uInt16 nActPos
= pShell
->GetOutlinePos(MAXLEVEL
);
1625 SvLBoxEntry
* pEntry
= First();
1627 while( 0 != (pEntry
= Next(pEntry
)) )
1629 if(((SwOutlineContent
*)pEntry
->GetUserData())->GetPos() == nActPos
)
1631 MakeVisible(pEntry
);
1639 // jetzt vielleicht noch ein Child selektieren
1640 SvLBoxEntry
* pChild
= pParent
;
1641 SvLBoxEntry
* pTemp
= 0;
1642 sal_uInt16 nPos
= 1;
1643 while(0 != (pChild
= Next(pChild
)))
1645 // der alte Text wird leicht bevorzugt
1646 if(sEntryName
== GetEntryText(pChild
) ||
1647 nPos
== nEntryRelPos
)
1659 MakeVisible(pSelEntry
);
1665 SetUpdateMode( sal_True
);
1666 ScrollBar
* pVScroll
= GetVScroll();
1667 if(GetEntryCount() == nOldEntryCount
&&
1668 nOldScrollPos
&& pVScroll
&& pVScroll
->IsVisible()
1669 && pVScroll
->GetThumbPos() != nOldScrollPos
)
1671 sal_Int32 nDelta
= pVScroll
->GetThumbPos() - nOldScrollPos
;
1672 ScrollOutputArea( (short)nDelta
);
1677 /***************************************************************************
1678 Beschreibung: Im Clear muessen auch die ContentTypes geloescht werden
1679 ***************************************************************************/
1682 void SwContentTree::Clear()
1684 SetUpdateMode(sal_False
);
1685 SvTreeListBox::Clear();
1686 SetUpdateMode(sal_True
);
1689 /***************************************************************************
1691 ***************************************************************************/
1693 sal_Bool
SwContentTree::FillTransferData( TransferDataContainer
& rTransfer
,
1694 sal_Int8
& rDragMode
)
1696 SwWrtShell
* pWrtShell
= GetWrtShell();
1697 DBG_ASSERT(pWrtShell
, "keine Shell!");
1698 SvLBoxEntry
* pEntry
= GetCurEntry();
1699 if(!pEntry
|| lcl_IsContentType(pEntry
) || !pWrtShell
)
1702 SwContent
* pCnt
= ((SwContent
*)pEntry
->GetUserData());
1704 sal_uInt16 nActType
= pCnt
->GetParent()->GetType();
1706 sal_Bool bOutline
= sal_False
;
1707 String sOutlineText
;
1710 case CONTENT_TYPE_OUTLINE
:
1712 sal_uInt16 nPos
= ((SwOutlineContent
*)pCnt
)->GetPos();
1713 DBG_ASSERT(nPos
< pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(),
1714 "outlinecnt veraendert");
1716 // #100738# make sure outline may actually be copied
1717 if( pWrtShell
->IsOutlineCopyable( nPos
) )
1719 const SwNumRule
* pOutlRule
= pWrtShell
->GetOutlineNumRule();
1720 const SwTxtNode
* pTxtNd
=
1721 pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos
);
1722 if( pTxtNd
&& pOutlRule
&& pTxtNd
->IsNumbered())
1724 SwNumberTree::tNumberVector aNumVector
=
1725 pTxtNd
->GetNumberVector();
1726 for( sal_Int8 nLevel
= 0;
1727 nLevel
<= pTxtNd
->GetActualListLevel();
1730 sal_uInt16 nVal
= (sal_uInt16
)aNumVector
[nLevel
];
1732 nVal
= nVal
- pOutlRule
->Get(nLevel
).GetStart();
1733 sEntry
+= String::CreateFromInt32( nVal
);
1737 sEntry
+= pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineText(nPos
, false);
1738 sOutlineText
= pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineText(nPos
, true);
1739 bIsOutlineMoveable
= ((SwOutlineContent
*)pCnt
)->IsMoveable();
1740 bOutline
= sal_True
;
1744 case CONTENT_TYPE_POSTIT
:
1745 case CONTENT_TYPE_INDEX
:
1746 case CONTENT_TYPE_REFERENCE
:
1747 // koennen weder als URL noch als Bereich eingefuegt werden
1749 case CONTENT_TYPE_URLFIELD
:
1750 sUrl
= ((SwURLFieldContent
*)pCnt
)->GetURL();
1752 case CONTENT_TYPE_OLE
:
1753 case CONTENT_TYPE_GRAPHIC
:
1754 if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE
)
1757 rDragMode
&= ~( DND_ACTION_MOVE
| DND_ACTION_LINK
);
1759 sEntry
= GetEntryText(pEntry
);
1762 sal_Bool bRet
= sal_False
;
1765 const SwDocShell
* pDocShell
= pWrtShell
->GetView().GetDocShell();
1768 if(pDocShell
->HasName())
1770 SfxMedium
* pMedium
= pDocShell
->GetMedium();
1771 sUrl
= pMedium
->GetURLObject().GetURLNoMark();
1772 // nur, wenn primaer ein Link eingefuegt werden soll
1775 else if( nActType
== CONTENT_TYPE_REGION
||
1776 nActType
== CONTENT_TYPE_BOOKMARK
)
1778 // fuer Bereich und Textmarken ist ein Link auch ohne
1779 // Dateiname ins eigene Dokument erlaubt
1782 else if(bIsConstant
&&
1783 ( !::GetActiveView() ||
1784 pActiveShell
!= ::GetActiveView()->GetWrtShellPtr()))
1786 // Urls von inaktiven Views ohne Dateinamen koennen auch nicht
1792 bRet
= GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE
;
1793 rDragMode
= DND_ACTION_MOVE
;
1796 const String
& rToken
= pCnt
->GetParent()->GetTypeToken();
1801 sUrl
+= cMarkSeperator
;
1810 //fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer
1812 sEntry
= sOutlineText
;
1815 NaviContentBookmark
aBmk( sUrl
, sEntry
,
1816 GetParentWindow()->GetRegionDropMode(),
1818 aBmk
.Copy( rTransfer
);
1821 // fuer fremde DocShells muss eine INetBookmark
1822 // dazugeliefert werden
1823 if( pDocShell
->HasName() )
1825 INetBookmark
aBkmk( sUrl
, sEntry
);
1826 rTransfer
.CopyINetBookmark( aBkmk
);
1832 /***************************************************************************
1833 Beschreibung: Umschalten der Anzeige auf Root
1834 ***************************************************************************/
1837 sal_Bool
SwContentTree::ToggleToRoot()
1841 SvLBoxEntry
* pEntry
= GetCurEntry();
1842 const SwContentType
* pCntType
;
1845 if(lcl_IsContentType(pEntry
))
1846 pCntType
= (SwContentType
*)pEntry
->GetUserData();
1848 pCntType
= ((SwContent
*)pEntry
->GetUserData())->GetParent();
1849 nRootType
= pCntType
->GetType();
1851 Display(bIsActive
|| bIsConstant
);
1856 nRootType
= USHRT_MAX
;
1857 bIsRoot
= sal_False
;
1858 FindActiveTypeAndRemoveUserData();
1859 Display(bIsActive
|| bIsConstant
);
1861 pConfig
->SetRootType( nRootType
);
1862 GetParentWindow()->aContentToolBox
.CheckItem(FN_SHOW_ROOT
, bIsRoot
);
1866 /***************************************************************************
1867 Beschreibung: Angezeigten Inhalt auf Gueltigkeit pruefen
1868 ***************************************************************************/
1871 sal_Bool
SwContentTree::HasContentChanged()
1874 -Parallel durch das lokale Array und die Treelistbox laufen.
1875 -Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen
1876 und der Contenttype wird als UserData neu gesetzt.
1877 - ist der Root-Modus aktiv, wird nur dieser aktualisiert,
1878 fuer die nicht angezeigten Inhaltstypen gilt:
1879 die Memberliste wird geloescht und der Membercount aktualisiert
1880 Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden
1881 Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch
1882 gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt.
1886 sal_Bool bRepaint
= sal_False
;
1887 sal_Bool bInvalidate
= sal_False
;
1889 if(!bIsActive
&& ! bIsConstant
)
1891 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
1893 if(aActiveContentArr
[i
])
1894 aActiveContentArr
[i
]->Invalidate();
1899 sal_Bool bOutline
= sal_False
;
1900 SvLBoxEntry
* pEntry
= First();
1902 bRepaint
= sal_True
;
1905 sal_uInt16 nType
= ((SwContentType
*)pEntry
->GetUserData())->GetType();
1906 bOutline
= nRootType
== CONTENT_TYPE_OUTLINE
;
1907 SwContentType
* pArrType
= aActiveContentArr
[nType
];
1909 bRepaint
= sal_True
;
1912 sal_uInt16 nSelLevel
= USHRT_MAX
;
1914 SvLBoxEntry
* pFirstSel
;
1916 0 != ( pFirstSel
= FirstSelected()) &&
1917 lcl_IsContent(pFirstSel
))
1919 nSelLevel
= ((SwOutlineContent
*)pFirstSel
->GetUserData())->GetOutlineLevel();
1920 SwWrtShell
* pSh
= GetWrtShell();
1921 sal_uInt16 nOutlinePos
= pSh
->GetOutlinePos(MAXLEVEL
);
1922 bRepaint
|= nOutlinePos
!= USHRT_MAX
&&
1923 pSh
->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos
) != nSelLevel
;
1926 pArrType
->Init(&bInvalidate
);
1927 pArrType
->FillMemberList();
1928 pEntry
->SetUserData((void*)pArrType
);
1931 if(GetChildCount(pEntry
) != pArrType
->GetMemberCount())
1932 bRepaint
= sal_True
;
1935 sal_uInt16 nChildCount
= (sal_uInt16
)GetChildCount(pEntry
);
1936 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
1938 pEntry
= Next(pEntry
);
1939 const SwContent
* pCnt
= pArrType
->GetMember(j
);
1940 pEntry
->SetUserData((void*)pCnt
);
1941 String sEntryText
= GetEntryText(pEntry
);
1942 if( sEntryText
!= pCnt
->GetName() &&
1943 !(sEntryText
== sSpace
&& !pCnt
->GetName().Len()))
1944 bRepaint
= sal_True
;
1950 if( !bRepaint
&& bOutline
)
1952 //feststellen, wo der Cursor steht
1953 const sal_uInt16 nActPos
= GetWrtShell()->GetOutlinePos(MAXLEVEL
);
1954 SvLBoxEntry
* pFirstEntry
= First();
1956 while( 0 != (pFirstEntry
= Next(pFirstEntry
)) )
1958 if(((SwOutlineContent
*)pFirstEntry
->GetUserData())->GetPos() == nActPos
)
1960 if(FirstSelected() != pFirstEntry
)
1962 Select(pFirstEntry
);
1963 MakeVisible(pFirstEntry
);
1973 SvLBoxEntry
* pEntry
= First();
1976 sal_Bool bNext
= sal_True
; // mindestens ein Next muss sein
1977 SwContentType
* pTreeType
= (SwContentType
*)pEntry
->GetUserData();
1978 sal_uInt16 nType
= pTreeType
->GetType();
1979 sal_uInt16 nTreeCount
= pTreeType
->GetMemberCount();
1980 SwContentType
* pArrType
= aActiveContentArr
[nType
];
1982 bRepaint
= sal_True
;
1985 pArrType
->Init(&bInvalidate
);
1986 pEntry
->SetUserData((void*)pArrType
);
1987 if(IsExpanded(pEntry
))
1989 sal_Bool bLevelOrVisibiblityChanged
= sal_False
;
1990 // bLevelOrVisibiblityChanged is set if outlines have changed their level
1991 // or if the visibility of objects (frames, sections, tables) has changed
1992 // i.e. in header/footer
1993 pArrType
->FillMemberList(&bLevelOrVisibiblityChanged
);
1994 sal_uInt16 nChildCount
= (sal_uInt16
)GetChildCount(pEntry
);
1995 if((nType
== CONTENT_TYPE_OUTLINE
) && bLevelOrVisibiblityChanged
)
1996 bRepaint
= sal_True
;
1997 if(bLevelOrVisibiblityChanged
)
1998 bInvalidate
= sal_True
;
2000 if(nChildCount
!= pArrType
->GetMemberCount())
2001 bRepaint
= sal_True
;
2004 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
2006 pEntry
= Next(pEntry
);
2008 const SwContent
* pCnt
= pArrType
->GetMember(j
);
2009 pEntry
->SetUserData((void*)pCnt
);
2010 String sEntryText
= GetEntryText(pEntry
);
2011 if( sEntryText
!= pCnt
->GetName() &&
2012 !(sEntryText
== sSpace
&& !pCnt
->GetName().Len()))
2013 bRepaint
= sal_True
;
2018 else if(pEntry
->HasChilds())
2020 //war der Eintrag einmal aufgeklappt, dann muessen auch
2021 // die unsichtbaren Eintraege geprueft werden.
2022 // zumindest muessen die Userdaten aktualisiert werden
2023 sal_Bool bLevelOrVisibiblityChanged
= sal_False
;
2024 // bLevelOrVisibiblityChanged is set if outlines have changed their level
2025 // or if the visibility of objects (frames, sections, tables) has changed
2026 // i.e. in header/footer
2027 pArrType
->FillMemberList(&bLevelOrVisibiblityChanged
);
2028 sal_Bool bRemoveChildren
= sal_False
;
2029 sal_uInt16 nChildCount
= (sal_uInt16
)GetChildCount(pEntry
);
2030 if( nChildCount
!= pArrType
->GetMemberCount() )
2032 bRemoveChildren
= sal_True
;
2036 SvLBoxEntry
* pChild
= FirstChild(pEntry
);
2037 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
2039 const SwContent
* pCnt
= pArrType
->GetMember(j
);
2040 pChild
->SetUserData((void*)pCnt
);
2041 String sEntryText
= GetEntryText(pChild
);
2042 if( sEntryText
!= pCnt
->GetName() &&
2043 !(sEntryText
== sSpace
&& !pCnt
->GetName().Len()))
2044 bRemoveChildren
= sal_True
;
2045 pChild
= Next(pChild
);
2050 SvLBoxEntry
* pChild
= FirstChild(pEntry
);
2051 SvLBoxEntry
* pRemove
= pChild
;
2052 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
2054 pChild
= Next(pRemove
);
2055 GetModel()->Remove(pRemove
);
2061 pEntry
->EnableChildsOnDemand(sal_False
);
2062 InvalidateEntry(pEntry
);
2066 else if((nTreeCount
!= 0)
2067 != (pArrType
->GetMemberCount()!=0))
2069 bRepaint
= sal_True
;
2072 //hier muss noch der naechste Root-Entry gefunden werden
2073 while( pEntry
&& (bNext
|| GetParent(pEntry
) ))
2075 pEntry
= Next(pEntry
);
2080 if(!bRepaint
&& bInvalidate
)
2085 /***************************************************************************
2086 Beschreibung: Bevor alle Daten geloescht werden, soll noch der letzte
2087 * aktive Eintrag festgestellt werden. Dann werden die
2088 * UserData geloescht
2089 ***************************************************************************/
2090 void SwContentTree::FindActiveTypeAndRemoveUserData()
2092 SvLBoxEntry
* pEntry
= FirstSelected();
2095 // wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root
2096 // die Gueltigkeit der UserData garantiert werden
2097 SvLBoxEntry
* pParent
;
2098 while(0 != (pParent
= GetParent(pEntry
)))
2100 if(pEntry
->GetUserData() && lcl_IsContentType(pEntry
))
2101 nLastSelType
= ((SwContentType
*)pEntry
->GetUserData())->GetType();
2104 // nLastSelType = USHRT_MAX;
2108 pEntry
->SetUserData(0);
2109 pEntry
= Next(pEntry
);
2113 /***************************************************************************
2114 Beschreibung: Nachdem ein File auf den Navigator gedroppt wurde,
2115 wird die neue Shell gesetzt
2116 ***************************************************************************/
2119 void SwContentTree::SetHiddenShell(SwWrtShell
* pSh
)
2122 bIsHidden
= sal_True
;
2123 bIsActive
= bIsConstant
= sal_False
;
2124 FindActiveTypeAndRemoveUserData();
2125 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
2127 DELETEZ(aHiddenContentArr
[i
]);
2131 GetParentWindow()->UpdateListBox();
2133 /***************************************************************************
2134 Beschreibung: Dokumentwechsel - neue Shell setzen
2135 ***************************************************************************/
2138 void SwContentTree::SetActiveShell(SwWrtShell
* pSh
)
2141 bDocChgdInDragging
= sal_True
;
2142 sal_Bool bClear
= pActiveShell
!= pSh
;
2143 if(bIsActive
&& bClear
)
2146 FindActiveTypeAndRemoveUserData();
2149 else if(bIsConstant
)
2151 if(!lcl_FindShell(pActiveShell
))
2154 bIsActive
= sal_True
;
2155 bIsConstant
= sal_False
;
2159 // nur wenn es die aktive View ist, wird das Array geloescht und
2160 // die Anzeige neu gefuellt
2161 if(bIsActive
&& bClear
)
2163 FindActiveTypeAndRemoveUserData();
2164 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
2166 DELETEZ(aActiveContentArr
[i
]);
2172 /***************************************************************************
2173 Beschreibung: Eine offene View als aktiv festlegen
2174 ***************************************************************************/
2177 void SwContentTree::SetConstantShell(SwWrtShell
* pSh
)
2180 bIsActive
= sal_False
;
2181 bIsConstant
= sal_True
;
2182 FindActiveTypeAndRemoveUserData();
2183 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
2185 DELETEZ(aActiveContentArr
[i
]);
2189 /***************************************************************************
2190 Beschreibung: Kommandos des Navigators ausfuehren
2191 ***************************************************************************/
2194 void SwContentTree::ExecCommand(sal_uInt16 nCmd
, sal_Bool bModifier
)
2196 sal_Bool nMove
= sal_False
;
2200 case FN_ITEM_UP
: nMove
= sal_True
;
2203 if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
2205 (bIsConstant
&& pActiveShell
== GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
2207 SwWrtShell
* pShell
= GetWrtShell();
2208 sal_Int8 nActOutlineLevel
= nOutlineLevel
;
2209 sal_uInt16 nActPos
= pShell
->GetOutlinePos(nActOutlineLevel
);
2210 SvLBoxEntry
* pFirstEntry
= FirstSelected();
2211 if (pFirstEntry
&& lcl_IsContent(pFirstEntry
))
2213 if(bIsRoot
&& nRootType
== CONTENT_TYPE_OUTLINE
||
2214 ((SwContent
*)pFirstEntry
->GetUserData())->GetParent()->GetType()
2215 == CONTENT_TYPE_OUTLINE
)
2217 nActPos
= ((SwOutlineContent
*)pFirstEntry
->GetUserData())->GetPos();
2220 if ( nActPos
< USHRT_MAX
&&
2221 ( !nMove
|| pShell
->IsOutlineMovable( nActPos
)) )
2223 pShell
->StartAllAction();
2224 pShell
->GotoOutline( nActPos
); // Falls Textselektion != BoxSelektion
2226 pShell
->MakeOutlineSel( nActPos
, nActPos
,
2230 short nDir
= nCmd
== FN_ITEM_UP
? -1 : 1;
2231 if( !bModifier
&& (nDir
== -1 && nActPos
> 0 ||
2232 nDir
== 1 && nActPos
< GetEntryCount() - 2 ) )
2234 pShell
->MoveOutlinePara( nDir
);
2235 //Cursor wieder an die aktuelle Position setzen
2236 pShell
->GotoOutline( nActPos
+ nDir
);
2240 sal_uInt16 nActEndPos
= nActPos
;
2241 SvLBoxEntry
* pEntry
= pFirstEntry
;
2242 sal_uInt16 nActLevel
= ((SwOutlineContent
*)
2243 pFirstEntry
->GetUserData())->GetOutlineLevel();
2244 pEntry
= Next(pEntry
);
2245 while( pEntry
&& CONTENT_TYPE_OUTLINE
==
2246 ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId() )
2248 if(nActLevel
>= ((SwOutlineContent
*)
2249 pEntry
->GetUserData())->GetOutlineLevel())
2251 pEntry
= Next(pEntry
);
2257 //Wenn der letzte Eintrag bewegt werden soll
2259 if(pEntry
&& CONTENT_TYPE_OUTLINE
==
2260 ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId())
2262 // pEntry zeigt jetzt auf den
2263 // dem letzten sel. Eintrag folgenden E.
2266 //hier muss der uebernaechste Eintrag
2267 //gefunden werden. Die Selektion muss davor eingefuegt
2271 pEntry
= Next(pEntry
);
2272 // nDest++ darf nur ausgefuehrt werden,
2274 if(pEntry
&& nDest
++ &&
2275 ( nActLevel
>= ((SwOutlineContent
*)pEntry
->GetUserData())->GetOutlineLevel()||
2276 CONTENT_TYPE_OUTLINE
!= ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId()))
2282 nDir
= nDest
- nActEndPos
;
2283 //wenn kein Eintrag gefunden wurde, der der Bedingung
2284 //fuer das zuvor Einfuegen entspricht, muss etwas weniger
2293 pEntry
= pFirstEntry
;
2294 while(pEntry
&& nDest
)
2297 pEntry
= Prev(pEntry
);
2299 (nActLevel
>= ((SwOutlineContent
*)pEntry
->GetUserData())->GetOutlineLevel()||
2300 CONTENT_TYPE_OUTLINE
!=
2301 ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId()))
2306 nDir
= nDest
- nActPos
;
2310 pShell
->MoveOutlinePara( nDir
);
2311 //Cursor wieder an die aktuelle Position setzen
2312 pShell
->GotoOutline( nActPos
+ nDir
);
2318 if( pShell
->IsProtectedOutlinePara() )
2319 Sound::Beep(); //konnte nicht umgestuft werden
2321 pShell
->OutlineUpDown( nCmd
== FN_ITEM_LEFT
? -1 : 1 );
2324 pShell
->ClearMark();
2325 pShell
->Pop(sal_False
); //Cursor steht jetzt wieder an der akt. Ueberschrift
2326 pShell
->EndAllAction();
2327 if(aActiveContentArr
[CONTENT_TYPE_OUTLINE
])
2328 aActiveContentArr
[CONTENT_TYPE_OUTLINE
]->Invalidate();
2332 const sal_uInt16 nCurrPos
= pShell
->GetOutlinePos(MAXLEVEL
);
2333 SvLBoxEntry
* pFirst
= First();
2335 while( 0 != (pFirst
= Next(pFirst
)) && lcl_IsContent(pFirst
))
2337 if(((SwOutlineContent
*)pFirst
->GetUserData())->GetPos() == nCurrPos
)
2340 MakeVisible(pFirst
);
2346 Sound::Beep(); //konnte nicht verschoben werden
2350 /***************************************************************************
2352 ***************************************************************************/
2355 void SwContentTree::ShowTree()
2358 SvTreeListBox::Show();
2361 /***************************************************************************
2362 Beschreibung: zusammengefaltet wird nicht geidlet
2363 ***************************************************************************/
2366 void SwContentTree::HideTree()
2369 SvTreeListBox::Hide();
2372 /***************************************************************************
2373 Beschreibung: Kein Idle mit Focus oder waehrend des Dragging
2374 ***************************************************************************/
2377 IMPL_LINK( SwContentTree
, TimerUpdate
, Timer
*, EMPTYARG
)
2379 // kein Update waehrend D&D
2380 // Viewabfrage, da der Navigator zu spaet abgeraeumt wird
2381 SwView
* pView
= GetParentWindow()->GetCreateView();
2382 if( (!HasFocus() || bViewHasChanged
) &&
2383 !bIsInDrag
&& !bIsInternalDrag
&& pView
&&
2384 pView
->GetWrtShellPtr() && !pView
->GetWrtShellPtr()->ActionPend() )
2386 bViewHasChanged
= sal_False
;
2387 bIsIdleClear
= sal_False
;
2388 SwWrtShell
* pActShell
= pView
->GetWrtShellPtr();
2389 if( bIsConstant
&& !lcl_FindShell( pActiveShell
) )
2391 SetActiveShell(pActShell
);
2392 GetParentWindow()->UpdateListBox();
2395 if(bIsActive
&& pActShell
!= GetWrtShell())
2396 SetActiveShell(pActShell
);
2397 else if( (bIsActive
|| (bIsConstant
&& pActShell
== GetWrtShell())) &&
2398 HasContentChanged())
2400 FindActiveTypeAndRemoveUserData();
2404 else if(!pView
&& bIsActive
&& !bIsIdleClear
)
2409 bIsIdleClear
= sal_True
;
2414 /***************************************************************************
2416 ***************************************************************************/
2419 DragDropMode
SwContentTree::NotifyStartDrag(
2420 TransferDataContainer
& rContainer
,
2421 SvLBoxEntry
* pEntry
)
2423 DragDropMode eMode
= (DragDropMode
)0;
2424 if( bIsActive
&& nRootType
== CONTENT_TYPE_OUTLINE
&&
2425 GetModel()->GetAbsPos( pEntry
) > 0
2426 && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
2427 eMode
= GetDragDropMode();
2428 else if(!bIsActive
&& GetWrtShell()->GetView().GetDocShell()->HasName())
2429 eMode
= SV_DRAGDROP_APP_COPY
;
2432 FillTransferData( rContainer
, nDragMode
);
2433 bDocChgdInDragging
= sal_False
;
2434 bIsInternalDrag
= sal_True
;
2439 /***************************************************************************
2440 Beschreibung : Nach dem Drag wird der aktuelle Absatz m i t
2442 ***************************************************************************/
2445 sal_Bool
SwContentTree::NotifyMoving( SvLBoxEntry
* pTarget
,
2446 SvLBoxEntry
* pEntry
, SvLBoxEntry
*& , ULONG
& )
2448 if(!bDocChgdInDragging
)
2450 sal_uInt16 nTargetPos
= 0;
2451 sal_uInt16 nSourcePos
= (( SwOutlineContent
* )pEntry
->GetUserData())->GetPos();
2452 if(!lcl_IsContent(pTarget
))
2453 nTargetPos
= USHRT_MAX
;
2455 nTargetPos
= (( SwOutlineContent
* )pTarget
->GetUserData())->GetPos();
2456 if( MAXLEVEL
> nOutlineLevel
&& // werden nicht alle Ebenen angezeigt
2457 nTargetPos
!= USHRT_MAX
)
2459 SvLBoxEntry
* pNext
= Next(pTarget
);
2461 nTargetPos
= (( SwOutlineContent
* )pNext
->GetUserData())->GetPos() -1;
2463 nTargetPos
= static_cast<sal_uInt16
>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1;
2467 DBG_ASSERT( pEntry
&&
2468 lcl_IsContent(pEntry
),"Source == 0 oder Source hat keinen Content" );
2469 GetParentWindow()->MoveOutline( nSourcePos
,
2473 aActiveContentArr
[CONTENT_TYPE_OUTLINE
]->Invalidate();
2476 //TreeListBox wird aus dem Dokument neu geladen
2479 /***************************************************************************
2480 Beschreibung : Nach dem Drag wird der aktuelle Absatz o h n e
2482 ***************************************************************************/
2485 sal_Bool
SwContentTree::NotifyCopying( SvLBoxEntry
* pTarget
,
2486 SvLBoxEntry
* pEntry
, SvLBoxEntry
*& , ULONG
& )
2488 if(!bDocChgdInDragging
)
2490 sal_uInt16 nTargetPos
= 0;
2491 sal_uInt16 nSourcePos
= (( SwOutlineContent
* )pEntry
->GetUserData())->GetPos();
2492 if(!lcl_IsContent(pTarget
))
2493 nTargetPos
= USHRT_MAX
;
2495 nTargetPos
= (( SwOutlineContent
* )pTarget
->GetUserData())->GetPos();
2497 if( MAXLEVEL
> nOutlineLevel
&& // werden nicht alle Ebenen angezeigt
2498 nTargetPos
!= USHRT_MAX
)
2500 SvLBoxEntry
* pNext
= Next(pTarget
);
2502 nTargetPos
= (( SwOutlineContent
* )pNext
->GetUserData())->GetPos() - 1;
2504 nTargetPos
= static_cast<sal_uInt16
>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1;
2509 DBG_ASSERT( pEntry
&&
2510 lcl_IsContent(pEntry
),"Source == 0 oder Source hat keinen Content" );
2511 GetParentWindow()->MoveOutline( nSourcePos
, nTargetPos
, sal_False
);
2513 //TreeListBox wird aus dem Dokument neu geladen
2514 aActiveContentArr
[CONTENT_TYPE_OUTLINE
]->Invalidate();
2520 /***************************************************************************
2521 Beschreibung: Kein Drop vor den ersten Eintrag - es ist ein SwContentType
2522 ***************************************************************************/
2524 sal_Bool
SwContentTree::NotifyAcceptDrop( SvLBoxEntry
* pEntry
)
2530 /***************************************************************************
2531 Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
2532 * dann soll die Basisfunktion des Controls gerufen werden
2533 ***************************************************************************/
2534 void SwContentTree::MouseButtonDown( const MouseEvent
& rMEvt
)
2536 Point
aPos( rMEvt
.GetPosPixel());
2537 SvLBoxEntry
* pEntry
= GetEntry( aPos
, sal_True
);
2538 if( !pEntry
&& rMEvt
.IsLeft() && rMEvt
.IsMod1() && (rMEvt
.GetClicks() % 2) == 0)
2539 Control::MouseButtonDown( rMEvt
);
2541 SvTreeListBox::MouseButtonDown( rMEvt
);
2544 /***************************************************************************
2545 Beschreibung: sofort aktualisieren
2546 ***************************************************************************/
2549 void SwContentTree::GetFocus()
2551 SwView
* pActView
= GetParentWindow()->GetCreateView();
2554 SwWrtShell
* pActShell
= pActView
->GetWrtShellPtr();
2555 if(bIsConstant
&& !lcl_FindShell(pActiveShell
))
2557 SetActiveShell(pActShell
);
2560 if(bIsActive
&& pActShell
!= GetWrtShell())
2561 SetActiveShell(pActShell
);
2562 else if( (bIsActive
|| (bIsConstant
&& pActShell
== GetWrtShell())) &&
2563 HasContentChanged())
2570 SvTreeListBox::GetFocus();
2573 /***************************************************************************
2575 ***************************************************************************/
2578 void SwContentTree::KeyInput(const KeyEvent
& rEvent
)
2580 const KeyCode aCode
= rEvent
.GetKeyCode();
2581 if(aCode
.GetCode() == KEY_RETURN
)
2583 SvLBoxEntry
* pEntry
= FirstSelected();
2586 switch(aCode
.GetModifier())
2590 GetParentWindow()->ToggleTree();
2593 // RootModus umschalten
2597 if(lcl_IsContentType(pEntry
))
2599 IsExpanded(pEntry
) ?
2604 ContentDoubleClickHdl(0);
2609 else if(aCode
.GetCode() == KEY_DELETE
&& 0 == aCode
.GetModifier())
2611 SvLBoxEntry
* pEntry
= FirstSelected();
2613 lcl_IsContent(pEntry
) &&
2614 ((SwContent
*)pEntry
->GetUserData())->GetParent()->IsDeletable() &&
2615 !pActiveShell
->GetView().GetDocShell()->IsReadOnly())
2617 EditEntry(pEntry
, EDIT_MODE_DELETE
);
2618 bViewHasChanged
= TRUE
;
2619 GetParentWindow()->UpdateListBox();
2620 TimerUpdate(&aUpdTimer
);
2625 SvTreeListBox::KeyInput(rEvent
);
2629 /***************************************************************************
2631 ***************************************************************************/
2634 void SwContentTree::RequestHelp( const HelpEvent
& rHEvt
)
2636 BOOL bCallBase
= TRUE
;
2637 if( rHEvt
.GetMode() & HELPMODE_QUICK
)
2639 Point
aPos( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ));
2640 SvLBoxEntry
* pEntry
= GetEntry( aPos
);
2644 sal_Bool bBalloon
= sal_False
;
2645 sal_Bool bContent
= sal_False
;
2646 void* pUserData
= pEntry
->GetUserData();
2647 if(lcl_IsContentType(pEntry
))
2648 nType
= ((SwContentType
*)pUserData
)->GetType();
2651 nType
= ((SwContent
*)pUserData
)->GetParent()->GetType();
2652 bContent
= sal_True
;
2655 sal_Bool bRet
= sal_False
;
2660 case CONTENT_TYPE_URLFIELD
:
2661 sEntry
= ((SwURLFieldContent
*)pUserData
)->GetURL();
2665 case CONTENT_TYPE_POSTIT
:
2666 sEntry
= ((SwPostItContent
*)pUserData
)->GetName();
2668 if(Help::IsBalloonHelpEnabled())
2669 bBalloon
= sal_True
;
2671 case CONTENT_TYPE_OUTLINE
:
2672 sEntry
= ((SwOutlineContent
*)pUserData
)->GetName();
2675 case CONTENT_TYPE_GRAPHIC
:
2676 sEntry
= ((SwGraphicContent
*)pUserData
)->GetLink();
2677 #if OSL_DEBUG_LEVEL > 1
2679 sEntry
+= String::CreateFromInt32(
2680 ((SwGraphicContent
*)pUserData
)->GetYPos());
2684 #if OSL_DEBUG_LEVEL > 1
2685 case CONTENT_TYPE_TABLE
:
2686 case CONTENT_TYPE_FRAME
:
2687 sEntry
= String::CreateFromInt32(
2688 ((SwContent
*)pUserData
)->GetYPos() );
2693 if(((SwContent
*)pUserData
)->IsInvisible())
2696 sEntry
+= C2S(", ");
2697 sEntry
+= sInvisible
;
2703 sal_uInt16 nMemberCount
= ((SwContentType
*)pUserData
)->GetMemberCount();
2704 sEntry
= String::CreateFromInt32(nMemberCount
);
2706 sEntry
+= nMemberCount
== 1
2707 ? ((SwContentType
*)pUserData
)->GetSingleName()
2708 : ((SwContentType
*)pUserData
)->GetName();
2714 SvLBoxItem
* pItem
= GetItem( pEntry
, aPos
.X(), &pTab
);
2715 if( pItem
&& SV_ITEM_ID_LBOXSTRING
== pItem
->IsA())
2717 aPos
= GetEntryPosition( pEntry
);
2719 aPos
.X() = GetTabPos( pEntry
, pTab
);
2720 Size
aSize( pItem
->GetSize( this, pEntry
) );
2722 if((aPos
.X() + aSize
.Width()) > GetSizePixel().Width())
2723 aSize
.Width() = GetSizePixel().Width() - aPos
.X();
2725 aPos
= OutputToScreenPixel(aPos
);
2726 Rectangle
aItemRect( aPos
, aSize
);
2729 aPos
.X() += aSize
.Width();
2730 Help::ShowBalloon( this, aPos
, aItemRect
, sEntry
);
2733 Help::ShowQuickHelp( this, aItemRect
, sEntry
,
2734 QUICKHELP_LEFT
|QUICKHELP_VCENTER
);
2740 Help::ShowQuickHelp( this, Rectangle(), aEmptyStr
, 0 );
2746 Window::RequestHelp( rHEvt
);
2749 /***************************************************************************
2751 ***************************************************************************/
2754 void SwContentTree::ExcecuteContextMenuAction( USHORT nSelectedPopupEntry
)
2756 SvLBoxEntry
* pFirst
= FirstSelected();
2757 switch( nSelectedPopupEntry
)
2770 nSelectedPopupEntry
-= 100;
2771 if(nOutlineLevel
!= nSelectedPopupEntry
)
2772 SetOutlineLevel((sal_Int8
)nSelectedPopupEntry
);
2777 GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry
- 201);
2781 EditEntry(pFirst
, nSelectedPopupEntry
== 401 ? EDIT_MODE_RMV_IDX
: EDIT_MODE_UPD_IDX
);
2783 // Eintrag bearbeiten
2785 EditEntry(pFirst
, EDIT_MODE_EDIT
);
2788 EditEntry(pFirst
, EDIT_UNPROTECT_TABLE
);
2792 const SwTOXBase
* pBase
= ((SwTOXBaseContent
*)pFirst
->GetUserData())
2794 pActiveShell
->SetTOXBaseReadonly(*pBase
, !pActiveShell
->IsTOXBaseReadonly(*pBase
));
2800 EditEntry(pFirst
, EDIT_MODE_DELETE
);
2803 EditEntry(pFirst
, EDIT_MODE_RENAME
);
2806 pActiveShell
->GetView().GetPostItMgr()->Show();
2809 pActiveShell
->GetView().GetPostItMgr()->Hide();
2813 pActiveShell
->GetView().GetPostItMgr()->SetActivePostIt(0);
2814 pActiveShell
->GetView().GetPostItMgr()->Delete();
2818 default: // nSelectedPopupEntry > 300
2819 if(nSelectedPopupEntry
> 300 && nSelectedPopupEntry
< 400)
2821 nSelectedPopupEntry
-= 300;
2822 SwView
*pView
= SwModule::GetFirstView();
2825 nSelectedPopupEntry
--;
2826 if(nSelectedPopupEntry
== 0)
2828 SetConstantShell(&pView
->GetWrtShell());
2831 pView
= SwModule::GetNextView(pView
);
2833 if(nSelectedPopupEntry
)
2835 bViewHasChanged
= bIsActive
= nSelectedPopupEntry
== 1;
2836 bIsConstant
= sal_False
;
2837 Display(nSelectedPopupEntry
== 1);
2841 GetParentWindow()->UpdateListBox();
2844 /***************************************************************************
2846 ***************************************************************************/
2849 void SwContentTree::SetOutlineLevel(sal_uInt8 nSet
)
2851 nOutlineLevel
= nSet
;
2852 pConfig
->SetOutlineLevel( nOutlineLevel
);
2853 SwContentType
** ppContentT
= bIsActive
?
2854 &aActiveContentArr
[CONTENT_TYPE_OUTLINE
] :
2855 &aHiddenContentArr
[CONTENT_TYPE_OUTLINE
];
2858 (*ppContentT
)->SetOutlineLevel(nOutlineLevel
);
2859 (*ppContentT
)->Init();
2864 /***************************************************************************
2865 Beschreibung: Moduswechsel: gedropptes Doc anzeigen
2866 ***************************************************************************/
2869 void SwContentTree::ShowHiddenShell()
2873 bIsConstant
= sal_False
;
2874 bIsActive
= sal_False
;
2879 /***************************************************************************
2880 Beschreibung: Moduswechsel: aktive Sicht anzeigen
2881 ***************************************************************************/
2884 void SwContentTree::ShowActualView()
2886 bIsActive
= sal_True
;
2887 bIsConstant
= sal_False
;
2889 GetParentWindow()->UpdateListBox();
2892 /*-----------------20.11.96 13.34-------------------
2893 Beschreibung: Hier sollen die Buttons zum Verschieben von
2894 Outlines en-/disabled werden
2895 --------------------------------------------------*/
2897 sal_Bool
SwContentTree::Select( SvLBoxEntry
* pEntry
, sal_Bool bSelect
)
2901 sal_Bool bEnable
= sal_False
;
2902 SvLBoxEntry
* pParentEntry
= GetParent(pEntry
);
2903 while(pParentEntry
&& (!lcl_IsContentType(pParentEntry
)))
2905 pParentEntry
= GetParent(pParentEntry
);
2907 if(!bIsLastReadOnly
&& (!IsVisible() ||
2908 (bIsRoot
&& nRootType
== CONTENT_TYPE_OUTLINE
&& pParentEntry
||
2909 lcl_IsContent(pEntry
) && ((SwContentType
*)pParentEntry
->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE
)))
2911 SwNavigationPI
* pNavi
= GetParentWindow();
2912 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_UP
, bEnable
);
2913 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_DOWN
, bEnable
);
2914 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_LEFT
, bEnable
);
2915 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_RIGHT
,bEnable
);
2917 return SvTreeListBox::Select(pEntry
, bSelect
);
2920 /*-----------------27.11.96 12.56-------------------
2922 --------------------------------------------------*/
2924 void SwContentTree::SetRootType(sal_uInt16 nType
)
2928 pConfig
->SetRootType( nRootType
);
2931 /*-----------------10.01.97 12.19-------------------
2933 --------------------------------------------------*/
2935 void SwContentType::RemoveNewline(String
& rEntry
)
2937 sal_Unicode
* pStr
= rEntry
.GetBufferAccess();
2938 for(xub_StrLen i
= rEntry
.Len(); i
; --i
, ++pStr
)
2940 if( *pStr
== 10 || *pStr
== 13 )
2945 /*-----------------14.01.97 16.38-------------------
2947 --------------------------------------------------*/
2949 void SwContentTree::EditEntry(SvLBoxEntry
* pEntry
, sal_uInt8 nMode
)
2951 SwContent
* pCnt
= (SwContent
*)pEntry
->GetUserData();
2953 sal_uInt16 nType
= pCnt
->GetParent()->GetType();
2954 sal_uInt16 nSlot
= 0;
2956 uno::Reference
< container::XNameAccess
> xNameAccess
, xSecond
, xThird
;
2959 case CONTENT_TYPE_TABLE
:
2960 if(nMode
== EDIT_UNPROTECT_TABLE
)
2962 pActiveShell
->GetView().GetDocShell()->
2963 GetDoc()->UnProtectCells( pCnt
->GetName());
2965 else if(nMode
== EDIT_MODE_DELETE
)
2967 pActiveShell
->StartAction();
2968 String sTable
= SW_RES(STR_TABLE_NAME
);
2969 SwRewriter aRewriterTableName
;
2970 aRewriterTableName
.AddRule(UNDO_ARG1
, SW_RES(STR_START_QUOTE
));
2971 aRewriterTableName
.AddRule(UNDO_ARG2
, pCnt
->GetName());
2972 aRewriterTableName
.AddRule(UNDO_ARG3
, SW_RES(STR_END_QUOTE
));
2973 sTable
= aRewriterTableName
.Apply(sTable
);
2975 SwRewriter aRewriter
;
2976 aRewriter
.AddRule(UNDO_ARG1
, sTable
);
2977 pActiveShell
->StartUndo(UNDO_DELETE
, &aRewriter
);
2978 pActiveShell
->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL
);
2979 pActiveShell
->DeleteRow();
2980 pActiveShell
->EndUndo(UNDO_DELETE
);
2981 pActiveShell
->EndAction();
2983 else if(nMode
== EDIT_MODE_RENAME
)
2985 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
2986 uno::Reference
< text::XTextTablesSupplier
> xTables(xModel
, uno::UNO_QUERY
);
2987 xNameAccess
= xTables
->getTextTables();
2990 nSlot
= FN_FORMAT_TABLE_DLG
;
2993 case CONTENT_TYPE_GRAPHIC
:
2994 if(nMode
== EDIT_MODE_DELETE
)
2996 pActiveShell
->DelRight();
2998 else if(nMode
== EDIT_MODE_RENAME
)
3000 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3001 uno::Reference
< text::XTextGraphicObjectsSupplier
> xGraphics(xModel
, uno::UNO_QUERY
);
3002 xNameAccess
= xGraphics
->getGraphicObjects();
3003 uno::Reference
< text::XTextFramesSupplier
> xFrms(xModel
, uno::UNO_QUERY
);
3004 xSecond
= xFrms
->getTextFrames();
3005 uno::Reference
< text::XTextEmbeddedObjectsSupplier
> xObjs(xModel
, uno::UNO_QUERY
);
3006 xThird
= xObjs
->getEmbeddedObjects();
3009 nSlot
= FN_FORMAT_GRAFIC_DLG
;
3012 case CONTENT_TYPE_FRAME
:
3013 case CONTENT_TYPE_OLE
:
3014 if(nMode
== EDIT_MODE_DELETE
)
3016 pActiveShell
->DelRight();
3018 else if(nMode
== EDIT_MODE_RENAME
)
3020 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3021 uno::Reference
< text::XTextFramesSupplier
> xFrms(xModel
, uno::UNO_QUERY
);
3022 uno::Reference
< text::XTextEmbeddedObjectsSupplier
> xObjs(xModel
, uno::UNO_QUERY
);
3023 if(CONTENT_TYPE_FRAME
== nType
)
3025 xNameAccess
= xFrms
->getTextFrames();
3026 xSecond
= xObjs
->getEmbeddedObjects();
3030 xNameAccess
= xObjs
->getEmbeddedObjects();
3031 xSecond
= xFrms
->getTextFrames();
3033 uno::Reference
< text::XTextGraphicObjectsSupplier
> xGraphics(xModel
, uno::UNO_QUERY
);
3034 xThird
= xGraphics
->getGraphicObjects();
3037 nSlot
= FN_FORMAT_FRAME_DLG
;
3039 case CONTENT_TYPE_BOOKMARK
:
3040 if(nMode
== EDIT_MODE_DELETE
)
3042 IDocumentMarkAccess
* const pMarkAccess
= pActiveShell
->getIDocumentMarkAccess();
3043 pMarkAccess
->deleteMark( pMarkAccess
->findMark(pCnt
->GetName()) );
3045 else if(nMode
== EDIT_MODE_RENAME
)
3047 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3048 uno::Reference
< text::XBookmarksSupplier
> xBkms(xModel
, uno::UNO_QUERY
);
3049 xNameAccess
= xBkms
->getBookmarks();
3052 nSlot
= FN_INSERT_BOOKMARK
;
3055 case CONTENT_TYPE_REGION
:
3056 if(nMode
== EDIT_MODE_RENAME
)
3058 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3059 uno::Reference
< text::XTextSectionsSupplier
> xSects(xModel
, uno::UNO_QUERY
);
3060 xNameAccess
= xSects
->getTextSections();
3063 nSlot
= FN_EDIT_REGION
;
3066 case CONTENT_TYPE_URLFIELD
:
3067 nSlot
= FN_EDIT_HYPERLINK
;
3069 case CONTENT_TYPE_REFERENCE
:
3070 nSlot
= FN_EDIT_FIELD
;
3073 case CONTENT_TYPE_POSTIT
:
3074 if(nMode
== EDIT_MODE_DELETE
)
3076 if (((SwPostItContent
*)pCnt
)->IsPostIt())
3078 pActiveShell
->GetView().GetPostItMgr()->SetActivePostIt(0);
3079 pActiveShell
->DelRight();
3082 // this code can be used once we want redline comments in the margin
3085 SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline());
3093 if (((SwPostItContent
*)pCnt
)->IsPostIt())
3096 nSlot
= FN_REDLINE_COMMENT
;
3099 case CONTENT_TYPE_INDEX
:
3101 const SwTOXBase
* pBase
= ((SwTOXBaseContent
*)pCnt
)->GetTOXBase();
3104 case EDIT_MODE_EDIT
:
3107 SwPtrItem
aPtrItem( FN_INSERT_MULTI_TOX
, (void*)pBase
);
3108 pActiveShell
->GetView().GetViewFrame()->
3109 GetDispatcher()->Execute(FN_INSERT_MULTI_TOX
,
3110 SFX_CALLMODE_ASYNCHRON
, &aPtrItem
, 0L);
3114 case EDIT_MODE_RMV_IDX
:
3115 case EDIT_MODE_DELETE
:
3118 pActiveShell
->DeleteTOX(*pBase
, EDIT_MODE_DELETE
== nMode
);
3121 case EDIT_MODE_UPD_IDX
:
3122 case EDIT_MODE_RENAME
:
3124 Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3125 Reference
< XDocumentIndexesSupplier
> xIndexes(xModel
, UNO_QUERY
);
3126 Reference
< XIndexAccess
> xIdxAcc(xIndexes
->getDocumentIndexes());
3127 Reference
< XNameAccess
>xLocalNameAccess(xIdxAcc
, UNO_QUERY
);
3128 if(EDIT_MODE_RENAME
== nMode
)
3129 xNameAccess
= xLocalNameAccess
;
3130 else if(xLocalNameAccess
.is() && xLocalNameAccess
->hasByName(pBase
->GetTOXName()))
3132 Any aIdx
= xLocalNameAccess
->getByName(pBase
->GetTOXName());
3133 Reference
< XDocumentIndex
> xIdx
;
3142 case CONTENT_TYPE_DRAWOBJECT
:
3143 if(EDIT_MODE_DELETE
== nMode
)
3148 pActiveShell
->GetView().GetViewFrame()->
3149 GetDispatcher()->Execute(nSlot
, SFX_CALLMODE_ASYNCHRON
);
3150 else if(xNameAccess
.is())
3152 uno::Any aObj
= xNameAccess
->getByName(pCnt
->GetName());
3153 uno::Reference
< uno::XInterface
> xTmp
;
3155 uno::Reference
< container::XNamed
> xNamed(xTmp
, uno::UNO_QUERY
);
3156 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
3157 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
3159 AbstractSwRenameXNamedDlg
* pDlg
= pFact
->CreateSwRenameXNamedDlg( this, xNamed
, xNameAccess
, DLG_RENAME_XNAMED
);
3160 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
3162 pDlg
->SetAlternativeAccess( xSecond
, xThird
);
3164 String sForbiddenChars
;
3165 if(CONTENT_TYPE_BOOKMARK
== nType
)
3167 sForbiddenChars
= C2S("/\\@:*?\";,.#");
3169 else if(CONTENT_TYPE_TABLE
== nType
)
3171 sForbiddenChars
= C2S(" .<>");
3173 pDlg
->SetForbiddenChars(sForbiddenChars
);
3179 /*-----------------14.01.97 16.53-------------------
3181 --------------------------------------------------*/
3183 void SwContentTree::GotoContent(SwContent
* pCnt
)
3185 pActiveShell
->EnterStdMode();
3187 sal_Bool bSel
= sal_False
;
3188 sal_uInt16 nJumpType
= pCnt
->GetParent()->GetType();
3191 case CONTENT_TYPE_OUTLINE
:
3193 pActiveShell
->GotoOutline(((SwOutlineContent
*)pCnt
)->GetPos());
3196 case CONTENT_TYPE_TABLE
:
3198 pActiveShell
->GotoTable(pCnt
->GetName());
3201 case CONTENT_TYPE_FRAME
:
3202 case CONTENT_TYPE_GRAPHIC
:
3203 case CONTENT_TYPE_OLE
:
3205 if(pActiveShell
->GotoFly(pCnt
->GetName()))
3209 case CONTENT_TYPE_BOOKMARK
:
3211 pActiveShell
->GotoMark(pCnt
->GetName());
3214 case CONTENT_TYPE_REGION
:
3216 pActiveShell
->GotoRegion(pCnt
->GetName());
3219 case CONTENT_TYPE_URLFIELD
:
3221 if(pActiveShell
->GotoINetAttr(
3222 *((SwURLFieldContent
*)pCnt
)->GetINetAttr() ))
3224 pActiveShell
->Right( CRSR_SKIP_CHARS
, sal_True
, 1, sal_False
);
3225 pActiveShell
->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT
, sal_True
);
3230 case CONTENT_TYPE_REFERENCE
:
3232 pActiveShell
->GotoRefMark(pCnt
->GetName());
3235 case CONTENT_TYPE_INDEX
:
3237 if (!pActiveShell
->GotoNextTOXBase(&pCnt
->GetName()))
3238 pActiveShell
->GotoPrevTOXBase(&pCnt
->GetName());
3241 case CONTENT_TYPE_POSTIT
:
3242 if (((SwPostItContent
*)pCnt
)->IsPostIt())
3243 pActiveShell
->GotoFld(*((SwPostItContent
*)pCnt
)->GetPostIt());
3245 pActiveShell
->GetView().GetDocShell()->GetWrtShell()->GotoRedline(
3246 pActiveShell
->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent
*)pCnt
)->GetRedline()->GetRedlineData()));
3249 case CONTENT_TYPE_DRAWOBJECT
:
3251 SdrView
* pDrawView
= pActiveShell
->GetDrawView();
3254 pDrawView
->SdrEndTextEdit();
3255 pDrawView
->UnmarkAll();
3256 SdrModel
* _pModel
= pActiveShell
->getIDocumentDrawModelAccess()->GetDrawModel();
3257 SdrPage
* pPage
= _pModel
->GetPage(0);
3258 sal_uInt32 nCount
= pPage
->GetObjCount();
3259 for( sal_uInt32 i
=0; i
< nCount
; i
++ )
3261 SdrObject
* pTemp
= pPage
->GetObj(i
);
3262 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
3263 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName() == pCnt->GetName())
3264 if ( pTemp
->GetName() == pCnt
->GetName() )
3267 SdrPageView
* pPV
= pDrawView
->GetSdrPageView();
3270 pDrawView
->MarkObj( pTemp
, pPV
);
3280 pActiveShell
->HideCrsr();
3281 pActiveShell
->EnterSelFrmMode();
3283 SwView
& rView
= pActiveShell
->GetView();
3284 rView
.StopShellTimer();
3285 rView
.GetPostItMgr()->SetActivePostIt(0);
3286 rView
.GetEditWin().GrabFocus();
3288 /*-----------------06.02.97 19.14-------------------
3289 Jetzt nochtdie passende text::Bookmark
3290 --------------------------------------------------*/
3292 NaviContentBookmark::NaviContentBookmark()
3295 nDefDrag( REGION_MODE_NONE
)
3299 /*-----------------06.02.97 20.12-------------------
3301 --------------------------------------------------*/
3303 NaviContentBookmark::NaviContentBookmark( const String
&rUrl
,
3304 const String
& rDesc
,
3305 sal_uInt16 nDragType
,
3306 const SwDocShell
* pDocSh
) :
3309 nDocSh((long)pDocSh
),
3310 nDefDrag( nDragType
)
3314 void NaviContentBookmark::Copy( TransferDataContainer
& rData
) const
3316 rtl_TextEncoding eSysCSet
= gsl_getSystemTextEncoding();
3318 ByteString
sStr( aUrl
, eSysCSet
);
3319 sStr
+= static_cast< char >(NAVI_BOOKMARK_DELIM
);
3320 sStr
+= ByteString( aDescr
, eSysCSet
);
3321 sStr
+= static_cast< char >(NAVI_BOOKMARK_DELIM
);
3322 sStr
+= ByteString::CreateFromInt32( nDefDrag
);
3323 sStr
+= static_cast< char >(NAVI_BOOKMARK_DELIM
);
3324 sStr
+= ByteString::CreateFromInt32( nDocSh
);
3325 rData
.CopyByteString( SOT_FORMATSTR_ID_SONLK
, sStr
);
3328 sal_Bool
NaviContentBookmark::Paste( TransferableDataHelper
& rData
)
3331 sal_Bool bRet
= rData
.GetString( SOT_FORMATSTR_ID_SONLK
, sStr
);
3334 xub_StrLen nPos
= 0;
3335 aUrl
= sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
);
3336 aDescr
= sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
);
3337 nDefDrag
= (USHORT
)sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
).ToInt32();
3338 nDocSh
= sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
).ToInt32();
3344 /* -----------------------------09.12.99 13:50--------------------------------
3346 ---------------------------------------------------------------------------*/
3347 class SwContentLBoxString
: public SvLBoxString
3350 SwContentLBoxString( SvLBoxEntry
* pEntry
, sal_uInt16 nFlags
,
3351 const String
& rStr
) : SvLBoxString(pEntry
,nFlags
,rStr
) {}
3353 virtual void Paint( const Point
& rPos
, SvLBox
& rDev
, sal_uInt16 nFlags
,
3354 SvLBoxEntry
* pEntry
);
3357 /* -----------------------------09.12.99 13:49--------------------------------
3359 ---------------------------------------------------------------------------*/
3360 void SwContentTree::InitEntry(SvLBoxEntry
* pEntry
,
3361 const XubString
& rStr
,const Image
& rImg1
,const Image
& rImg2
,
3362 SvLBoxButtonKind eButtonKind
)
3364 sal_uInt16 nColToHilite
= 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
3365 SvTreeListBox::InitEntry( pEntry
, rStr
, rImg1
, rImg2
, eButtonKind
);
3366 SvLBoxString
* pCol
= (SvLBoxString
*)pEntry
->GetItem( nColToHilite
);
3367 SwContentLBoxString
* pStr
= new SwContentLBoxString( pEntry
, 0, pCol
->GetText() );
3368 pEntry
->ReplaceItem( pStr
, nColToHilite
);
3370 /* -----------------------------09.12.99 13:49--------------------------------
3372 ---------------------------------------------------------------------------*/
3373 void SwContentLBoxString::Paint( const Point
& rPos
, SvLBox
& rDev
, sal_uInt16 nFlags
,
3374 SvLBoxEntry
* pEntry
)
3376 if(lcl_IsContent(pEntry
) &&
3377 ((SwContent
*)pEntry
->GetUserData())->IsInvisible())
3379 //* pCont = (SwContent*)pEntry->GetUserData();
3380 Font
aOldFont( rDev
.GetFont());
3381 Font
aFont(aOldFont
);
3382 Color
aCol( COL_LIGHTGRAY
);
3383 aFont
.SetColor( aCol
);
3384 rDev
.SetFont( aFont
);
3385 rDev
.DrawText( rPos
, GetText() );
3386 rDev
.SetFont( aOldFont
);
3389 SvLBoxString::Paint( rPos
, rDev
, nFlags
, pEntry
);
3391 /* -----------------------------06.05.2002 10:20------------------------------
3393 ---------------------------------------------------------------------------*/
3394 void SwContentTree::DataChanged( const DataChangedEvent
& rDCEvt
)
3396 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
3397 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
3399 USHORT nResId
= GetDisplayBackground().GetColor().IsDark() ? IMG_NAVI_ENTRYBMPH
: IMG_NAVI_ENTRYBMP
;
3400 aEntryImages
= ImageList(SW_RES(nResId
));
3401 FindActiveTypeAndRemoveUserData();
3404 SvTreeListBox::DataChanged( rDCEvt
);