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
)),
910 sPostItShow(SW_RES(ST_POSTIT_SHOW
)),
911 sPostItHide(SW_RES(ST_POSTIT_HIDE
)),
912 sPostItDelete(SW_RES(ST_POSTIT_DELETE
)),
916 pConfig(SW_MOD()->GetNavigationConfig()),
921 nRootType(USHRT_MAX
),
922 nLastSelType(USHRT_MAX
),
923 nOutlineLevel(MAXLEVEL
),
926 bIsConstant(sal_False
),
927 bIsHidden(sal_False
),
928 bDocChgdInDragging(sal_False
),
929 bIsInternalDrag(sal_False
),
931 bIsIdleClear(sal_False
),
932 bIsLastReadOnly(sal_False
),
933 bIsOutlineMoveable(sal_True
),
934 bViewHasChanged(sal_False
),
935 bIsImageListInitialized(sal_False
)
939 SetHelpId(HID_NAVIGATOR_TREELIST
);
941 SetNodeDefaultImages();
942 SetDoubleClickHdl(LINK(this, SwContentTree
, ContentDoubleClickHdl
));
943 SetDragDropMode(SV_DRAGDROP_APP_COPY
);
944 for( i
= 0; i
< CONTENT_TYPE_MAX
; i
++)
946 aActiveContentArr
[i
] = 0;
947 aHiddenContentArr
[i
] = 0;
949 for( i
= 0; i
< CONTEXT_COUNT
; i
++ )
951 aContextStrings
[i
] = SW_RESSTR(i
+ST_CONTEXT_FIRST
);
953 nActiveBlock
= pConfig
->GetActiveBlock();
954 aUpdTimer
.SetTimeoutHdl(LINK(this, SwContentTree
, TimerUpdate
));
955 aUpdTimer
.SetTimeout(1000);
957 EnableContextMenuHandling();
960 /***************************************************************************
962 ***************************************************************************/
965 SwContentTree::~SwContentTree()
967 Clear(); // vorher gfs. Inhaltstypen loeschen
968 bIsInDrag
= sal_False
;
971 /***************************************************************************
973 ***************************************************************************/
974 void SwContentTree::StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
)
976 if( !bIsRoot
|| nRootType
!= CONTENT_TYPE_OUTLINE
)
980 TransferDataContainer
* pContainer
= new TransferDataContainer
;
982 datatransfer::XTransferable
> xRef( pContainer
);
984 sal_Int8 nDragMode
= DND_ACTION_COPYMOVE
| DND_ACTION_LINK
;
985 if( FillTransferData( *pContainer
, nDragMode
))
987 SwContentTree::SetInDrag(sal_True
);
988 pContainer
->StartDrag( this, nDragMode
, GetDragFinishedHdl() );
992 SvTreeListBox::StartDrag( nAction
, rPosPixel
);
995 void SwContentTree::DragFinished( sal_Int8 nAction
)
997 //to prevent the removing of the selected entry in external drag and drop
998 // the drag action mustn't be MOVE
999 SvTreeListBox::DragFinished( bIsInternalDrag
? nAction
: DND_ACTION_COPY
);
1000 SwContentTree::SetInDrag(sal_False
);
1001 bIsInternalDrag
= sal_False
;
1004 /***************************************************************************
1005 Beschreibung: QueryDrop wird im Navigator ausgefuehrt
1006 ***************************************************************************/
1007 sal_Int8
SwContentTree::AcceptDrop( const AcceptDropEvent
& rEvt
)
1009 sal_Int8 nRet
= DND_ACTION_NONE
;
1012 if( bIsOutlineMoveable
)
1013 nRet
= SvTreeListBox::AcceptDrop( rEvt
);
1015 else if( !bIsInDrag
)
1016 nRet
= GetParentWindow()->AcceptDrop( rEvt
);
1020 /***************************************************************************
1021 Beschreibung: Drop wird im Navigator ausgefuehrt
1022 ***************************************************************************/
1023 void* lcl_GetOutlineKey( SwContentTree
* pTree
, SwOutlineContent
* pContent
)
1026 if( pTree
&& pContent
)
1028 SwWrtShell
* pShell
= pTree
->GetWrtShell();
1029 sal_Int32 nPos
= pContent
->GetYPos();
1032 key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1038 sal_Int8
SwContentTree::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
1040 SvLBoxEntry
* pEntry
= pTargetEntry
;
1041 if( pEntry
&& ( nRootType
== CONTENT_TYPE_OUTLINE
) && lcl_IsContent( pEntry
) )
1043 SwOutlineContent
* pOutlineContent
= ( SwOutlineContent
* )( pEntry
->GetUserData() );
1044 if( pOutlineContent
)
1046 void* key
= lcl_GetOutlineKey(this, pOutlineContent
);
1047 if( !mOutLineNodeMap
[key
] )
1049 while( pEntry
->HasChilds() )
1051 SvLBoxEntry
* pChildEntry
= FirstChild( pEntry
);
1052 while( pChildEntry
)
1054 pEntry
= pChildEntry
;
1055 pChildEntry
= NextSibling( pChildEntry
);
1058 pTargetEntry
= pEntry
;
1063 return SvTreeListBox::ExecuteDrop( rEvt
);
1064 return bIsInDrag
? DND_ACTION_NONE
: GetParentWindow()->ExecuteDrop(rEvt
);
1068 /***************************************************************************
1069 Beschreibung: Handler fuer Dragging und ContextMenu
1070 ***************************************************************************/
1071 PopupMenu
* SwContentTree::CreateContextMenu( void )
1073 PopupMenu
* pPop
= new PopupMenu
;
1074 PopupMenu
* pSubPop1
= new PopupMenu
;
1075 PopupMenu
* pSubPop2
= new PopupMenu
;
1076 PopupMenu
* pSubPop3
= new PopupMenu
;
1077 PopupMenu
* pSubPop4
= new PopupMenu
; // Edit
1080 for(i
= 1; i
<= MAXLEVEL
; i
++ )
1082 pSubPop1
->InsertItem( i
+ 100, String::CreateFromInt32(i
));
1084 pSubPop1
->CheckItem(100 + nOutlineLevel
);
1085 for(i
=0; i
< 3; i
++ )
1087 pSubPop2
->InsertItem( i
+ 201, aContextStrings
[
1088 ST_HYPERLINK
- ST_CONTEXT_FIRST
+ i
]);
1090 pSubPop2
->CheckItem( 201 +
1091 GetParentWindow()->GetRegionDropMode());
1092 //Liste der offenen Dateien einfuegen
1093 sal_uInt16 nId
= 301;
1094 const SwView
* pActiveView
= ::GetActiveView();
1095 SwView
*pView
= SwModule::GetFirstView();
1098 String sInsert
= pView
->GetDocShell()->GetTitle();
1099 if(pView
== pActiveView
)
1102 sInsert
+= aContextStrings
[ ST_ACTIVE
- ST_CONTEXT_FIRST
];
1105 pSubPop3
->InsertItem(nId
, sInsert
);
1106 if(bIsConstant
&& pActiveShell
== &pView
->GetWrtShell())
1107 pSubPop3
->CheckItem(nId
);
1108 pView
= SwModule::GetNextView(pView
);
1111 pSubPop3
->InsertItem(nId
++, aContextStrings
[ST_ACTIVE_VIEW
- ST_CONTEXT_FIRST
]);
1114 String sHiddenEntry
= pHiddenShell
->GetView().GetDocShell()->GetTitle();
1115 sHiddenEntry
+= C2S(" ( ");
1116 sHiddenEntry
+= aContextStrings
[ ST_HIDDEN
- ST_CONTEXT_FIRST
];
1117 sHiddenEntry
+= C2S(" )");
1118 pSubPop3
->InsertItem(nId
, sHiddenEntry
);
1122 pSubPop3
->CheckItem( --nId
);
1124 pSubPop3
->CheckItem( nId
);
1126 pPop
->InsertItem( 1, aContextStrings
[ST_OUTLINE_LEVEL
- ST_CONTEXT_FIRST
]);
1127 pPop
->InsertItem(2, aContextStrings
[ST_DRAGMODE
- ST_CONTEXT_FIRST
]);
1128 pPop
->InsertItem(3, aContextStrings
[ST_DISPLAY
- ST_CONTEXT_FIRST
]);
1129 //jetzt noch bearbeiten
1130 SvLBoxEntry
* pEntry
= 0;
1131 //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen
1132 if((bIsActive
|| pActiveShell
== pActiveView
->GetWrtShellPtr())
1133 && 0 != (pEntry
= FirstSelected()) && lcl_IsContent(pEntry
))
1135 const SwContentType
* pContType
= ((SwContent
*)pEntry
->GetUserData())->GetParent();
1136 const sal_uInt16 nContentType
= pContType
->GetType();
1137 sal_Bool bReadonly
= pActiveShell
->GetView().GetDocShell()->IsReadOnly();
1138 sal_Bool bVisible
= !((SwContent
*)pEntry
->GetUserData())->IsInvisible();
1139 sal_Bool bProtected
= ((SwContent
*)pEntry
->GetUserData())->IsProtect();
1140 sal_Bool bEditable
= pContType
->IsEditable() &&
1141 ((bVisible
&& !bProtected
) ||CONTENT_TYPE_REGION
== nContentType
);
1142 sal_Bool bDeletable
= pContType
->IsDeletable() &&
1143 ((bVisible
&& !bProtected
) ||CONTENT_TYPE_REGION
== nContentType
);
1144 sal_Bool bRenamable
= bEditable
&& !bReadonly
&&
1145 (CONTENT_TYPE_TABLE
== nContentType
||
1146 CONTENT_TYPE_FRAME
== nContentType
||
1147 CONTENT_TYPE_GRAPHIC
== nContentType
||
1148 CONTENT_TYPE_OLE
== nContentType
||
1149 CONTENT_TYPE_BOOKMARK
== nContentType
||
1150 CONTENT_TYPE_REGION
== nContentType
||
1151 CONTENT_TYPE_INDEX
== nContentType
);
1153 if(!bReadonly
&& (bEditable
|| bDeletable
))
1155 sal_Bool bSubPop4
= sal_False
;
1156 if(CONTENT_TYPE_INDEX
== nContentType
)
1158 bSubPop4
= sal_True
;
1159 pSubPop4
->InsertItem(401, sRemoveIdx
);
1160 pSubPop4
->InsertItem(402, sUpdateIdx
);
1162 const SwTOXBase
* pBase
= ((SwTOXBaseContent
*)pEntry
->GetUserData())->GetTOXBase();
1163 if(!pBase
->IsTOXBaseInReadonly())
1164 pSubPop4
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1165 pSubPop4
->InsertItem(405, sReadonlyIdx
);
1167 pSubPop4
->CheckItem( 405, pActiveShell
->IsTOXBaseReadonly(*pBase
));
1168 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1170 else if(CONTENT_TYPE_TABLE
== nContentType
&& !bReadonly
)
1172 bSubPop4
= sal_True
;
1173 pSubPop4
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1174 pSubPop4
->InsertItem(404, sUnprotTbl
);
1175 sal_Bool bFull
= sal_False
;
1176 String sTblName
= ((SwContent
*)pEntry
->GetUserData())->GetName();
1177 sal_Bool bProt
=pActiveShell
->HasTblAnyProtection( &sTblName
, &bFull
);
1178 pSubPop4
->EnableItem(403, !bFull
);
1179 pSubPop4
->EnableItem(404, bProt
);
1180 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1182 else if(bEditable
|| bDeletable
)
1185 if(bEditable
&& bDeletable
)
1187 pSubPop4
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1188 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1189 bSubPop4
= sal_True
;
1192 pPop
->InsertItem(403, aContextStrings
[ST_EDIT_ENTRY
- ST_CONTEXT_FIRST
]);
1195 pSubPop4
->InsertItem(501, aContextStrings
[ST_DELETE_ENTRY
- ST_CONTEXT_FIRST
]);
1202 pSubPop4
->InsertItem(502, sRename
);
1204 pPop
->InsertItem(502, sRename
);
1209 pPop
->InsertItem(4, pContType
->GetSingleName());
1210 pPop
->SetPopupMenu(4, pSubPop4
);
1216 SwContentType
* pType
= (SwContentType
*)pEntry
->GetUserData();
1217 if ( (pType
->GetType() == CONTENT_TYPE_POSTIT
) && (!pActiveShell
->GetView().GetDocShell()->IsReadOnly()) && ( pType
->GetMemberCount() > 0) )
1219 pSubPop4
->InsertItem(600, sPostItShow
);
1220 pSubPop4
->InsertItem(601, sPostItHide
);
1221 pSubPop4
->InsertItem(602, sPostItDelete
);
1223 pSubPop4->InsertItem(603,rtl::OUString::createFromAscii("Sort"));
1224 PopupMenu* pMenuSort = new PopupMenu;
1225 pMenuSort->InsertItem(604,rtl::OUString::createFromAscii("By Position"));
1226 pMenuSort->InsertItem(605,rtl::OUString::createFromAscii("By Author"));
1227 pMenuSort->InsertItem(606,rtl::OUString::createFromAscii("By Date"));
1228 pSubPop4->SetPopupMenu(603, pMenuSort);
1230 pPop
->InsertItem(4, pType
->GetSingleName());
1231 pPop
->SetPopupMenu(4, pSubPop4
);
1235 pPop
->SetPopupMenu( 1, pSubPop1
);
1236 pPop
->SetPopupMenu( 2, pSubPop2
);
1237 pPop
->SetPopupMenu( 3, pSubPop3
);
1241 /***************************************************************************
1242 Beschreibung: Einrueckung fuer outlines (und sections)
1243 ***************************************************************************/
1246 long SwContentTree::GetTabPos( SvLBoxEntry
* pEntry
, SvLBoxTab
* pTab
)
1248 sal_uInt16 nLevel
= 0;
1249 if(lcl_IsContent(pEntry
))
1252 SwContent
* pCnt
= (SwContent
*) pEntry
->GetUserData();
1253 const SwContentType
* pParent
;
1254 if(pCnt
&& 0 != (pParent
= pCnt
->GetParent()))
1256 if(pParent
->GetType() == CONTENT_TYPE_OUTLINE
)
1257 nLevel
= nLevel
+ ((SwOutlineContent
*)pCnt
)->GetOutlineLevel();
1258 else if(pParent
->GetType() == CONTENT_TYPE_REGION
)
1259 nLevel
= nLevel
+ ((SwRegionContent
*)pCnt
)->GetRegionLevel();
1262 sal_uInt16 nBasis
= bIsRoot
? 0 : 5;
1263 return nLevel
* 10 + nBasis
+ pTab
->GetPos(); //empirisch ermittelt
1266 /***************************************************************************
1267 Beschreibung: Inhalte werden erst auf Anforderung in die Box eingefuegt
1268 ***************************************************************************/
1271 void SwContentTree::RequestingChilds( SvLBoxEntry
* pParent
)
1273 // ist es ein Inhaltstyp?
1274 if(lcl_IsContentType(pParent
))
1276 if(!pParent
->HasChilds())
1278 DBG_ASSERT(pParent
->GetUserData(), "keine UserData?");
1279 SwContentType
* pCntType
= (SwContentType
*)pParent
->GetUserData();
1281 sal_uInt16 nCount
= pCntType
->GetMemberCount();
1282 /**************************************************************
1283 Add for outline plus/minus
1284 ***************************************************************/
1285 if(pCntType
->GetType() == CONTENT_TYPE_OUTLINE
)
1287 SvLBoxEntry
* pChild
= 0;
1288 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
1290 const SwContent
* pCnt
= pCntType
->GetMember(i
);
1293 sal_uInt16 nLevel
= ((SwOutlineContent
*)pCnt
)->GetOutlineLevel();
1294 String sEntry
= pCnt
->GetName();
1297 if(!pChild
|| (nLevel
== 0))
1298 pChild
= InsertEntry(sEntry
, pParent
,
1299 sal_False
, LIST_APPEND
,(void*)pCnt
);
1302 //back search parent.
1303 if(((SwOutlineContent
*)pCntType
->GetMember(i
-1))->GetOutlineLevel() < nLevel
)
1304 pChild
= InsertEntry(sEntry
, pChild
,
1305 sal_False
, LIST_APPEND
, (void*)pCnt
);
1308 pChild
= Prev(pChild
);
1310 lcl_IsContent(pChild
) &&
1311 !(((SwOutlineContent
*)pChild
->GetUserData())->GetOutlineLevel() < nLevel
)
1314 pChild
= Prev(pChild
);
1317 pChild
= InsertEntry(sEntry
, pChild
,
1318 sal_False
, LIST_APPEND
, (void*)pCnt
);
1326 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
1328 const SwContent
* pCnt
= pCntType
->GetMember(i
);
1331 String sEntry
= pCnt
->GetName();
1334 InsertEntry(sEntry
, pParent
,
1335 sal_False
, LIST_APPEND
, (void*)pCnt
);
1343 /***************************************************************************
1344 Beschreibung: Expand - Zustand fuer Inhaltstypen merken
1345 ***************************************************************************/
1348 sal_Bool
SwContentTree::Expand( SvLBoxEntry
* pParent
)
1350 if(!bIsRoot
|| (((SwContentType
*)pParent
->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE
) ||
1351 (nRootType
== CONTENT_TYPE_OUTLINE
))
1353 if(lcl_IsContentType(pParent
))
1355 SwContentType
* pCntType
= (SwContentType
*)pParent
->GetUserData();
1356 sal_uInt16 nOr
= 1 << pCntType
->GetType(); //linear -> Bitposition
1357 if(bIsActive
|| bIsConstant
)
1359 nActiveBlock
|= nOr
;
1360 pConfig
->SetActiveBlock(nActiveBlock
);
1363 nHiddenBlock
|= nOr
;
1364 if((pCntType
->GetType() == CONTENT_TYPE_OUTLINE
))
1366 std::map
< void*, sal_Bool
> mCurrOutLineNodeMap
;
1368 SwWrtShell
* pShell
= GetWrtShell();
1369 sal_Bool bBool
= SvTreeListBox::Expand(pParent
);
1370 SvLBoxEntry
* pChild
= Next(pParent
);
1371 while(pChild
&& lcl_IsContent(pChild
) && pParent
->HasChilds())
1373 if(pChild
->HasChilds())
1375 sal_Int32 nPos
= ((SwContent
*)pChild
->GetUserData())->GetYPos();
1376 void* key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1377 mCurrOutLineNodeMap
.insert(std::map
<void*, sal_Bool
>::value_type( key
, sal_False
) );
1378 std::map
<void*,sal_Bool
>::iterator iter
= mOutLineNodeMap
.find( key
);
1379 if( iter
!= mOutLineNodeMap
.end() && mOutLineNodeMap
[key
])
1381 mCurrOutLineNodeMap
[key
] = sal_True
;
1382 SvTreeListBox::Expand(pChild
);
1385 pChild
= Next(pChild
);
1387 mOutLineNodeMap
= mCurrOutLineNodeMap
;
1392 else if( lcl_IsContent(pParent
) )
1394 SwWrtShell
* pShell
= GetWrtShell();
1395 sal_Int32 nPos
= ((SwContent
*)pParent
->GetUserData())->GetYPos();
1396 void* key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1397 mOutLineNodeMap
[key
] = sal_True
;
1400 return SvTreeListBox::Expand(pParent
);
1402 /***************************************************************************
1403 Beschreibung: Collapse - Zustand fuer Inhaltstypen merken
1404 ***************************************************************************/
1407 sal_Bool
SwContentTree::Collapse( SvLBoxEntry
* pParent
)
1410 if(!bIsRoot
|| (((SwContentType
*)pParent
->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE
) ||
1411 (nRootType
== CONTENT_TYPE_OUTLINE
))
1413 if(lcl_IsContentType(pParent
))
1416 return bRet
= sal_False
;
1417 SwContentType
* pCntType
= (SwContentType
*)pParent
->GetUserData();
1418 sal_uInt16 nAnd
= 1 << pCntType
->GetType();
1420 if(bIsActive
|| bIsConstant
)
1422 nActiveBlock
&= nAnd
;
1423 pConfig
->SetActiveBlock(nActiveBlock
);
1426 nHiddenBlock
&= nAnd
;
1428 else if( lcl_IsContent(pParent
) )
1430 SwWrtShell
* pShell
= GetWrtShell();
1431 sal_Int32 nPos
= ((SwContent
*)pParent
->GetUserData())->GetYPos();
1432 void* key
= (void*)pShell
->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos
);
1433 mOutLineNodeMap
[key
] = sal_False
;
1435 bRet
= SvTreeListBox::Collapse(pParent
);
1438 // bRet = sal_False;
1439 bRet
= SvTreeListBox::Collapse(pParent
);
1444 /***************************************************************************
1445 Beschreibung: Auch auf Doppelclick wird zunaechst nur aufgeklappt
1446 ***************************************************************************/
1449 IMPL_LINK( SwContentTree
, ContentDoubleClickHdl
, SwContentTree
*, EMPTYARG
)
1451 SvLBoxEntry
* pEntry
= GetCurEntry();
1452 // ist es ein Inhaltstyp?
1453 DBG_ASSERT(pEntry
, "kein aktueller Eintrag!");
1456 if(lcl_IsContentType(pEntry
) && !pEntry
->HasChilds())
1457 RequestingChilds(pEntry
);
1458 else if(!lcl_IsContentType(pEntry
) && (bIsActive
|| bIsConstant
))
1462 pActiveShell
->GetView().GetViewFrame()->GetWindow().ToTop();
1464 //Inhaltstyp anspringen:
1465 SwContent
* pCnt
= (SwContent
*)pEntry
->GetUserData();
1466 DBG_ASSERT( pCnt
, "keine UserData");
1468 if(pCnt
->GetParent()->GetType() == CONTENT_TYPE_FRAME
)
1469 pActiveShell
->EnterStdMode();
1475 /***************************************************************************
1476 Beschreibung: Anzeigen der Datei
1477 ***************************************************************************/
1480 void SwContentTree::Display( sal_Bool bActive
)
1482 if(!bIsImageListInitialized
)
1484 USHORT nResId
= GetDisplayBackground().GetColor().IsDark() ? IMG_NAVI_ENTRYBMPH
: IMG_NAVI_ENTRYBMP
;
1485 aEntryImages
= ImageList(SW_RES(nResId
));
1486 bIsImageListInitialized
= sal_True
;
1488 // erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder
1489 // zu selektieren -> die UserDaten sind hier nicht mehr gueltig!
1490 SvLBoxEntry
* pOldSelEntry
= FirstSelected();
1491 String sEntryName
; // Name des Eintrags
1492 sal_uInt16 nEntryRelPos
= 0; // rel. Pos zu seinem Parent
1493 sal_uInt32 nOldEntryCount
= GetEntryCount();
1494 sal_Int32 nOldScrollPos
= 0;
1497 ScrollBar
* pVScroll
= GetVScroll();
1498 if(pVScroll
&& pVScroll
->IsVisible())
1499 nOldScrollPos
= pVScroll
->GetThumbPos();
1501 sEntryName
= GetEntryText(pOldSelEntry
);
1502 SvLBoxEntry
* pParantEntry
= pOldSelEntry
;
1503 while( GetParent(pParantEntry
))
1505 pParantEntry
= GetParent(pParantEntry
);
1507 if(GetParent(pOldSelEntry
))
1509 nEntryRelPos
= (sal_uInt16
)(GetModel()->GetAbsPos(pOldSelEntry
) - GetModel()->GetAbsPos(pParantEntry
));
1513 SetUpdateMode( sal_False
);
1514 if(bActive
&& !bIsConstant
&& !bIsActive
)
1515 bIsActive
= bActive
;
1516 bIsHidden
= !bActive
;
1517 SwWrtShell
* pShell
= GetWrtShell();
1518 sal_Bool bReadOnly
= pShell
? pShell
->GetView().GetDocShell()->IsReadOnly() : sal_True
;
1519 if(bReadOnly
!= bIsLastReadOnly
)
1521 bIsLastReadOnly
= bReadOnly
;
1522 sal_Bool bDisable
= pShell
== 0 || bReadOnly
;
1523 SwNavigationPI
* pNavi
= GetParentWindow();
1524 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_UP
, !bDisable
);
1525 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_DOWN
, !bDisable
);
1526 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_LEFT
, !bDisable
);
1527 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_RIGHT
, !bDisable
);
1528 pNavi
->aContentToolBox
.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK
, !bDisable
);
1532 SvLBoxEntry
* pSelEntry
= 0;
1533 if(nRootType
== USHRT_MAX
)
1535 for(sal_uInt16 nCntType
= CONTENT_TYPE_OUTLINE
;
1536 nCntType
<= CONTENT_TYPE_DRAWOBJECT
; nCntType
++ )
1538 SwContentType
** ppContentT
= bActive
?
1539 &aActiveContentArr
[nCntType
] :
1540 &aHiddenContentArr
[nCntType
];
1542 (*ppContentT
) = new SwContentType(pShell
, nCntType
, nOutlineLevel
);
1545 String sEntry
= (*ppContentT
)->GetName();
1546 SvLBoxEntry
* pEntry
;
1547 const Image
& rImage
= aEntryImages
.GetImage(SID_SW_START
+ nCntType
);
1548 sal_Bool bChOnDemand
= 0 != (*ppContentT
)->GetMemberCount();
1549 pEntry
= InsertEntry(sEntry
, rImage
, rImage
,
1550 0, bChOnDemand
, LIST_APPEND
, (*ppContentT
));
1551 if(nCntType
== nLastSelType
)
1553 sal_Int32 nExpandOptions
= bIsActive
|| bIsConstant
?
1556 if(nExpandOptions
& (1 << nCntType
))
1559 if(nEntryRelPos
&& nCntType
== nLastSelType
)
1561 // jetzt vielleicht noch ein Child selektieren
1562 SvLBoxEntry
* pChild
= pEntry
;
1563 SvLBoxEntry
* pTemp
= 0;
1564 sal_uInt16 nPos
= 1;
1565 while(0 != (pChild
= Next(pChild
)))
1567 // der alte Text wird leicht bevorzugt
1568 if(sEntryName
== GetEntryText(pChild
) ||
1569 nPos
== nEntryRelPos
)
1577 if(!pSelEntry
|| lcl_IsContentType(pSelEntry
))
1585 MakeVisible(pSelEntry
);
1593 SwContentType
** ppRootContentT
= bActive
?
1594 &aActiveContentArr
[nRootType
] :
1595 &aHiddenContentArr
[nRootType
];
1596 if(!(*ppRootContentT
))
1597 (*ppRootContentT
) = new SwContentType(pShell
, nRootType
, nOutlineLevel
);
1598 const Image
& rImage
= aEntryImages
.GetImage(20000 + nRootType
);
1599 SvLBoxEntry
* pParent
= InsertEntry(
1600 (*ppRootContentT
)->GetName(), rImage
, rImage
,
1601 0, sal_False
, LIST_APPEND
, *ppRootContentT
);
1603 if(nRootType
!= CONTENT_TYPE_OUTLINE
)
1605 SvLBoxEntry
* pEntry
;
1606 for(sal_uInt16 i
= 0; i
< (*ppRootContentT
)->GetMemberCount(); i
++ )
1608 const SwContent
* pCnt
= (*ppRootContentT
)->GetMember(i
);
1611 String sEntry
= pCnt
->GetName();
1614 InsertEntry( sEntry
, pParent
,
1615 sal_False
, LIST_APPEND
, (void*)pCnt
);
1620 RequestingChilds(pParent
);
1622 if( nRootType
== CONTENT_TYPE_OUTLINE
&& bIsActive
)
1624 //feststellen, wo der Cursor steht
1625 const sal_uInt16 nActPos
= pShell
->GetOutlinePos(MAXLEVEL
);
1626 SvLBoxEntry
* pEntry
= First();
1628 while( 0 != (pEntry
= Next(pEntry
)) )
1630 if(((SwOutlineContent
*)pEntry
->GetUserData())->GetPos() == nActPos
)
1632 MakeVisible(pEntry
);
1640 // jetzt vielleicht noch ein Child selektieren
1641 SvLBoxEntry
* pChild
= pParent
;
1642 SvLBoxEntry
* pTemp
= 0;
1643 sal_uInt16 nPos
= 1;
1644 while(0 != (pChild
= Next(pChild
)))
1646 // der alte Text wird leicht bevorzugt
1647 if(sEntryName
== GetEntryText(pChild
) ||
1648 nPos
== nEntryRelPos
)
1660 MakeVisible(pSelEntry
);
1666 SetUpdateMode( sal_True
);
1667 ScrollBar
* pVScroll
= GetVScroll();
1668 if(GetEntryCount() == nOldEntryCount
&&
1669 nOldScrollPos
&& pVScroll
&& pVScroll
->IsVisible()
1670 && pVScroll
->GetThumbPos() != nOldScrollPos
)
1672 sal_Int32 nDelta
= pVScroll
->GetThumbPos() - nOldScrollPos
;
1673 ScrollOutputArea( (short)nDelta
);
1678 /***************************************************************************
1679 Beschreibung: Im Clear muessen auch die ContentTypes geloescht werden
1680 ***************************************************************************/
1683 void SwContentTree::Clear()
1685 SetUpdateMode(sal_False
);
1686 SvTreeListBox::Clear();
1687 SetUpdateMode(sal_True
);
1690 /***************************************************************************
1692 ***************************************************************************/
1694 sal_Bool
SwContentTree::FillTransferData( TransferDataContainer
& rTransfer
,
1695 sal_Int8
& rDragMode
)
1697 SwWrtShell
* pWrtShell
= GetWrtShell();
1698 DBG_ASSERT(pWrtShell
, "keine Shell!");
1699 SvLBoxEntry
* pEntry
= GetCurEntry();
1700 if(!pEntry
|| lcl_IsContentType(pEntry
) || !pWrtShell
)
1703 SwContent
* pCnt
= ((SwContent
*)pEntry
->GetUserData());
1705 sal_uInt16 nActType
= pCnt
->GetParent()->GetType();
1707 sal_Bool bOutline
= sal_False
;
1708 String sOutlineText
;
1711 case CONTENT_TYPE_OUTLINE
:
1713 sal_uInt16 nPos
= ((SwOutlineContent
*)pCnt
)->GetPos();
1714 DBG_ASSERT(nPos
< pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(),
1715 "outlinecnt veraendert");
1717 // #100738# make sure outline may actually be copied
1718 if( pWrtShell
->IsOutlineCopyable( nPos
) )
1720 const SwNumRule
* pOutlRule
= pWrtShell
->GetOutlineNumRule();
1721 const SwTxtNode
* pTxtNd
=
1722 pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos
);
1723 if( pTxtNd
&& pOutlRule
&& pTxtNd
->IsNumbered())
1725 SwNumberTree::tNumberVector aNumVector
=
1726 pTxtNd
->GetNumberVector();
1727 for( sal_Int8 nLevel
= 0;
1728 nLevel
<= pTxtNd
->GetActualListLevel();
1731 sal_uInt16 nVal
= (sal_uInt16
)aNumVector
[nLevel
];
1733 nVal
= nVal
- pOutlRule
->Get(nLevel
).GetStart();
1734 sEntry
+= String::CreateFromInt32( nVal
);
1738 sEntry
+= pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineText(nPos
, false);
1739 sOutlineText
= pWrtShell
->getIDocumentOutlineNodesAccess()->getOutlineText(nPos
, true);
1740 bIsOutlineMoveable
= ((SwOutlineContent
*)pCnt
)->IsMoveable();
1741 bOutline
= sal_True
;
1745 case CONTENT_TYPE_POSTIT
:
1746 case CONTENT_TYPE_INDEX
:
1747 case CONTENT_TYPE_REFERENCE
:
1748 // koennen weder als URL noch als Bereich eingefuegt werden
1750 case CONTENT_TYPE_URLFIELD
:
1751 sUrl
= ((SwURLFieldContent
*)pCnt
)->GetURL();
1753 case CONTENT_TYPE_OLE
:
1754 case CONTENT_TYPE_GRAPHIC
:
1755 if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE
)
1758 rDragMode
&= ~( DND_ACTION_MOVE
| DND_ACTION_LINK
);
1760 sEntry
= GetEntryText(pEntry
);
1763 sal_Bool bRet
= sal_False
;
1766 const SwDocShell
* pDocShell
= pWrtShell
->GetView().GetDocShell();
1769 if(pDocShell
->HasName())
1771 SfxMedium
* pMedium
= pDocShell
->GetMedium();
1772 sUrl
= pMedium
->GetURLObject().GetURLNoMark();
1773 // nur, wenn primaer ein Link eingefuegt werden soll
1776 else if( nActType
== CONTENT_TYPE_REGION
||
1777 nActType
== CONTENT_TYPE_BOOKMARK
)
1779 // fuer Bereich und Textmarken ist ein Link auch ohne
1780 // Dateiname ins eigene Dokument erlaubt
1783 else if(bIsConstant
&&
1784 ( !::GetActiveView() ||
1785 pActiveShell
!= ::GetActiveView()->GetWrtShellPtr()))
1787 // Urls von inaktiven Views ohne Dateinamen koennen auch nicht
1793 bRet
= GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE
;
1794 rDragMode
= DND_ACTION_MOVE
;
1797 const String
& rToken
= pCnt
->GetParent()->GetTypeToken();
1802 sUrl
+= cMarkSeperator
;
1811 //fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer
1813 sEntry
= sOutlineText
;
1816 NaviContentBookmark
aBmk( sUrl
, sEntry
,
1817 GetParentWindow()->GetRegionDropMode(),
1819 aBmk
.Copy( rTransfer
);
1822 // fuer fremde DocShells muss eine INetBookmark
1823 // dazugeliefert werden
1824 if( pDocShell
->HasName() )
1826 INetBookmark
aBkmk( sUrl
, sEntry
);
1827 rTransfer
.CopyINetBookmark( aBkmk
);
1833 /***************************************************************************
1834 Beschreibung: Umschalten der Anzeige auf Root
1835 ***************************************************************************/
1838 sal_Bool
SwContentTree::ToggleToRoot()
1842 SvLBoxEntry
* pEntry
= GetCurEntry();
1843 const SwContentType
* pCntType
;
1846 if(lcl_IsContentType(pEntry
))
1847 pCntType
= (SwContentType
*)pEntry
->GetUserData();
1849 pCntType
= ((SwContent
*)pEntry
->GetUserData())->GetParent();
1850 nRootType
= pCntType
->GetType();
1852 Display(bIsActive
|| bIsConstant
);
1857 nRootType
= USHRT_MAX
;
1858 bIsRoot
= sal_False
;
1859 FindActiveTypeAndRemoveUserData();
1860 Display(bIsActive
|| bIsConstant
);
1862 pConfig
->SetRootType( nRootType
);
1863 GetParentWindow()->aContentToolBox
.CheckItem(FN_SHOW_ROOT
, bIsRoot
);
1867 /***************************************************************************
1868 Beschreibung: Angezeigten Inhalt auf Gueltigkeit pruefen
1869 ***************************************************************************/
1872 sal_Bool
SwContentTree::HasContentChanged()
1875 -Parallel durch das lokale Array und die Treelistbox laufen.
1876 -Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen
1877 und der Contenttype wird als UserData neu gesetzt.
1878 - ist der Root-Modus aktiv, wird nur dieser aktualisiert,
1879 fuer die nicht angezeigten Inhaltstypen gilt:
1880 die Memberliste wird geloescht und der Membercount aktualisiert
1881 Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden
1882 Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch
1883 gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt.
1887 sal_Bool bRepaint
= sal_False
;
1888 sal_Bool bInvalidate
= sal_False
;
1890 if(!bIsActive
&& ! bIsConstant
)
1892 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
1894 if(aActiveContentArr
[i
])
1895 aActiveContentArr
[i
]->Invalidate();
1900 sal_Bool bOutline
= sal_False
;
1901 SvLBoxEntry
* pEntry
= First();
1903 bRepaint
= sal_True
;
1906 sal_uInt16 nType
= ((SwContentType
*)pEntry
->GetUserData())->GetType();
1907 bOutline
= nRootType
== CONTENT_TYPE_OUTLINE
;
1908 SwContentType
* pArrType
= aActiveContentArr
[nType
];
1910 bRepaint
= sal_True
;
1913 sal_uInt16 nSelLevel
= USHRT_MAX
;
1915 SvLBoxEntry
* pFirstSel
;
1917 0 != ( pFirstSel
= FirstSelected()) &&
1918 lcl_IsContent(pFirstSel
))
1920 nSelLevel
= ((SwOutlineContent
*)pFirstSel
->GetUserData())->GetOutlineLevel();
1921 SwWrtShell
* pSh
= GetWrtShell();
1922 sal_uInt16 nOutlinePos
= pSh
->GetOutlinePos(MAXLEVEL
);
1923 bRepaint
|= nOutlinePos
!= USHRT_MAX
&&
1924 pSh
->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos
) != nSelLevel
;
1927 pArrType
->Init(&bInvalidate
);
1928 pArrType
->FillMemberList();
1929 pEntry
->SetUserData((void*)pArrType
);
1932 if(GetChildCount(pEntry
) != pArrType
->GetMemberCount())
1933 bRepaint
= sal_True
;
1936 sal_uInt16 nChildCount
= (sal_uInt16
)GetChildCount(pEntry
);
1937 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
1939 pEntry
= Next(pEntry
);
1940 const SwContent
* pCnt
= pArrType
->GetMember(j
);
1941 pEntry
->SetUserData((void*)pCnt
);
1942 String sEntryText
= GetEntryText(pEntry
);
1943 if( sEntryText
!= pCnt
->GetName() &&
1944 !(sEntryText
== sSpace
&& !pCnt
->GetName().Len()))
1945 bRepaint
= sal_True
;
1951 if( !bRepaint
&& bOutline
)
1953 //feststellen, wo der Cursor steht
1954 const sal_uInt16 nActPos
= GetWrtShell()->GetOutlinePos(MAXLEVEL
);
1955 SvLBoxEntry
* pFirstEntry
= First();
1957 while( 0 != (pFirstEntry
= Next(pFirstEntry
)) )
1959 if(((SwOutlineContent
*)pFirstEntry
->GetUserData())->GetPos() == nActPos
)
1961 if(FirstSelected() != pFirstEntry
)
1963 Select(pFirstEntry
);
1964 MakeVisible(pFirstEntry
);
1974 SvLBoxEntry
* pEntry
= First();
1977 sal_Bool bNext
= sal_True
; // mindestens ein Next muss sein
1978 SwContentType
* pTreeType
= (SwContentType
*)pEntry
->GetUserData();
1979 sal_uInt16 nType
= pTreeType
->GetType();
1980 sal_uInt16 nTreeCount
= pTreeType
->GetMemberCount();
1981 SwContentType
* pArrType
= aActiveContentArr
[nType
];
1983 bRepaint
= sal_True
;
1986 pArrType
->Init(&bInvalidate
);
1987 pEntry
->SetUserData((void*)pArrType
);
1988 if(IsExpanded(pEntry
))
1990 sal_Bool bLevelOrVisibiblityChanged
= sal_False
;
1991 // bLevelOrVisibiblityChanged is set if outlines have changed their level
1992 // or if the visibility of objects (frames, sections, tables) has changed
1993 // i.e. in header/footer
1994 pArrType
->FillMemberList(&bLevelOrVisibiblityChanged
);
1995 sal_uInt16 nChildCount
= (sal_uInt16
)GetChildCount(pEntry
);
1996 if((nType
== CONTENT_TYPE_OUTLINE
) && bLevelOrVisibiblityChanged
)
1997 bRepaint
= sal_True
;
1998 if(bLevelOrVisibiblityChanged
)
1999 bInvalidate
= sal_True
;
2001 if(nChildCount
!= pArrType
->GetMemberCount())
2002 bRepaint
= sal_True
;
2005 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
2007 pEntry
= Next(pEntry
);
2009 const SwContent
* pCnt
= pArrType
->GetMember(j
);
2010 pEntry
->SetUserData((void*)pCnt
);
2011 String sEntryText
= GetEntryText(pEntry
);
2012 if( sEntryText
!= pCnt
->GetName() &&
2013 !(sEntryText
== sSpace
&& !pCnt
->GetName().Len()))
2014 bRepaint
= sal_True
;
2019 else if(pEntry
->HasChilds())
2021 //war der Eintrag einmal aufgeklappt, dann muessen auch
2022 // die unsichtbaren Eintraege geprueft werden.
2023 // zumindest muessen die Userdaten aktualisiert werden
2024 sal_Bool bLevelOrVisibiblityChanged
= sal_False
;
2025 // bLevelOrVisibiblityChanged is set if outlines have changed their level
2026 // or if the visibility of objects (frames, sections, tables) has changed
2027 // i.e. in header/footer
2028 pArrType
->FillMemberList(&bLevelOrVisibiblityChanged
);
2029 sal_Bool bRemoveChildren
= sal_False
;
2030 sal_uInt16 nChildCount
= (sal_uInt16
)GetChildCount(pEntry
);
2031 if( nChildCount
!= pArrType
->GetMemberCount() )
2033 bRemoveChildren
= sal_True
;
2037 SvLBoxEntry
* pChild
= FirstChild(pEntry
);
2038 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
2040 const SwContent
* pCnt
= pArrType
->GetMember(j
);
2041 pChild
->SetUserData((void*)pCnt
);
2042 String sEntryText
= GetEntryText(pChild
);
2043 if( sEntryText
!= pCnt
->GetName() &&
2044 !(sEntryText
== sSpace
&& !pCnt
->GetName().Len()))
2045 bRemoveChildren
= sal_True
;
2046 pChild
= Next(pChild
);
2051 SvLBoxEntry
* pChild
= FirstChild(pEntry
);
2052 SvLBoxEntry
* pRemove
= pChild
;
2053 for(sal_uInt16 j
= 0; j
< nChildCount
; j
++)
2055 pChild
= Next(pRemove
);
2056 GetModel()->Remove(pRemove
);
2062 pEntry
->EnableChildsOnDemand(sal_False
);
2063 InvalidateEntry(pEntry
);
2067 else if((nTreeCount
!= 0)
2068 != (pArrType
->GetMemberCount()!=0))
2070 bRepaint
= sal_True
;
2073 //hier muss noch der naechste Root-Entry gefunden werden
2074 while( pEntry
&& (bNext
|| GetParent(pEntry
) ))
2076 pEntry
= Next(pEntry
);
2081 if(!bRepaint
&& bInvalidate
)
2086 /***************************************************************************
2087 Beschreibung: Bevor alle Daten geloescht werden, soll noch der letzte
2088 * aktive Eintrag festgestellt werden. Dann werden die
2089 * UserData geloescht
2090 ***************************************************************************/
2091 void SwContentTree::FindActiveTypeAndRemoveUserData()
2093 SvLBoxEntry
* pEntry
= FirstSelected();
2096 // wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root
2097 // die Gueltigkeit der UserData garantiert werden
2098 SvLBoxEntry
* pParent
;
2099 while(0 != (pParent
= GetParent(pEntry
)))
2101 if(pEntry
->GetUserData() && lcl_IsContentType(pEntry
))
2102 nLastSelType
= ((SwContentType
*)pEntry
->GetUserData())->GetType();
2105 // nLastSelType = USHRT_MAX;
2109 pEntry
->SetUserData(0);
2110 pEntry
= Next(pEntry
);
2114 /***************************************************************************
2115 Beschreibung: Nachdem ein File auf den Navigator gedroppt wurde,
2116 wird die neue Shell gesetzt
2117 ***************************************************************************/
2120 void SwContentTree::SetHiddenShell(SwWrtShell
* pSh
)
2123 bIsHidden
= sal_True
;
2124 bIsActive
= bIsConstant
= sal_False
;
2125 FindActiveTypeAndRemoveUserData();
2126 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
2128 DELETEZ(aHiddenContentArr
[i
]);
2132 GetParentWindow()->UpdateListBox();
2134 /***************************************************************************
2135 Beschreibung: Dokumentwechsel - neue Shell setzen
2136 ***************************************************************************/
2139 void SwContentTree::SetActiveShell(SwWrtShell
* pSh
)
2142 bDocChgdInDragging
= sal_True
;
2143 sal_Bool bClear
= pActiveShell
!= pSh
;
2144 if(bIsActive
&& bClear
)
2147 FindActiveTypeAndRemoveUserData();
2150 else if(bIsConstant
)
2152 if(!lcl_FindShell(pActiveShell
))
2155 bIsActive
= sal_True
;
2156 bIsConstant
= sal_False
;
2160 // nur wenn es die aktive View ist, wird das Array geloescht und
2161 // die Anzeige neu gefuellt
2162 if(bIsActive
&& bClear
)
2164 FindActiveTypeAndRemoveUserData();
2165 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
2167 DELETEZ(aActiveContentArr
[i
]);
2173 /***************************************************************************
2174 Beschreibung: Eine offene View als aktiv festlegen
2175 ***************************************************************************/
2178 void SwContentTree::SetConstantShell(SwWrtShell
* pSh
)
2181 bIsActive
= sal_False
;
2182 bIsConstant
= sal_True
;
2183 FindActiveTypeAndRemoveUserData();
2184 for(sal_uInt16 i
=0; i
< CONTENT_TYPE_MAX
; i
++)
2186 DELETEZ(aActiveContentArr
[i
]);
2190 /***************************************************************************
2191 Beschreibung: Kommandos des Navigators ausfuehren
2192 ***************************************************************************/
2195 void SwContentTree::ExecCommand(sal_uInt16 nCmd
, sal_Bool bModifier
)
2197 sal_Bool nMove
= sal_False
;
2201 case FN_ITEM_UP
: nMove
= sal_True
;
2204 if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
2206 (bIsConstant
&& pActiveShell
== GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
2208 SwWrtShell
* pShell
= GetWrtShell();
2209 sal_Int8 nActOutlineLevel
= nOutlineLevel
;
2210 sal_uInt16 nActPos
= pShell
->GetOutlinePos(nActOutlineLevel
);
2211 SvLBoxEntry
* pFirstEntry
= FirstSelected();
2212 if (pFirstEntry
&& lcl_IsContent(pFirstEntry
))
2214 if(bIsRoot
&& nRootType
== CONTENT_TYPE_OUTLINE
||
2215 ((SwContent
*)pFirstEntry
->GetUserData())->GetParent()->GetType()
2216 == CONTENT_TYPE_OUTLINE
)
2218 nActPos
= ((SwOutlineContent
*)pFirstEntry
->GetUserData())->GetPos();
2221 if ( nActPos
< USHRT_MAX
&&
2222 ( !nMove
|| pShell
->IsOutlineMovable( nActPos
)) )
2224 pShell
->StartAllAction();
2225 pShell
->GotoOutline( nActPos
); // Falls Textselektion != BoxSelektion
2227 pShell
->MakeOutlineSel( nActPos
, nActPos
,
2231 short nDir
= nCmd
== FN_ITEM_UP
? -1 : 1;
2232 if( !bModifier
&& (nDir
== -1 && nActPos
> 0 ||
2233 nDir
== 1 && nActPos
< GetEntryCount() - 2 ) )
2235 pShell
->MoveOutlinePara( nDir
);
2236 //Cursor wieder an die aktuelle Position setzen
2237 pShell
->GotoOutline( nActPos
+ nDir
);
2241 sal_uInt16 nActEndPos
= nActPos
;
2242 SvLBoxEntry
* pEntry
= pFirstEntry
;
2243 sal_uInt16 nActLevel
= ((SwOutlineContent
*)
2244 pFirstEntry
->GetUserData())->GetOutlineLevel();
2245 pEntry
= Next(pEntry
);
2246 while( pEntry
&& CONTENT_TYPE_OUTLINE
==
2247 ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId() )
2249 if(nActLevel
>= ((SwOutlineContent
*)
2250 pEntry
->GetUserData())->GetOutlineLevel())
2252 pEntry
= Next(pEntry
);
2258 //Wenn der letzte Eintrag bewegt werden soll
2260 if(pEntry
&& CONTENT_TYPE_OUTLINE
==
2261 ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId())
2263 // pEntry zeigt jetzt auf den
2264 // dem letzten sel. Eintrag folgenden E.
2267 //hier muss der uebernaechste Eintrag
2268 //gefunden werden. Die Selektion muss davor eingefuegt
2272 pEntry
= Next(pEntry
);
2273 // nDest++ darf nur ausgefuehrt werden,
2275 if(pEntry
&& nDest
++ &&
2276 ( nActLevel
>= ((SwOutlineContent
*)pEntry
->GetUserData())->GetOutlineLevel()||
2277 CONTENT_TYPE_OUTLINE
!= ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId()))
2283 nDir
= nDest
- nActEndPos
;
2284 //wenn kein Eintrag gefunden wurde, der der Bedingung
2285 //fuer das zuvor Einfuegen entspricht, muss etwas weniger
2294 pEntry
= pFirstEntry
;
2295 while(pEntry
&& nDest
)
2298 pEntry
= Prev(pEntry
);
2300 (nActLevel
>= ((SwOutlineContent
*)pEntry
->GetUserData())->GetOutlineLevel()||
2301 CONTENT_TYPE_OUTLINE
!=
2302 ((SwTypeNumber
*)pEntry
->GetUserData())->GetTypeId()))
2307 nDir
= nDest
- nActPos
;
2311 pShell
->MoveOutlinePara( nDir
);
2312 //Cursor wieder an die aktuelle Position setzen
2313 pShell
->GotoOutline( nActPos
+ nDir
);
2319 if( pShell
->IsProtectedOutlinePara() )
2320 Sound::Beep(); //konnte nicht umgestuft werden
2322 pShell
->OutlineUpDown( nCmd
== FN_ITEM_LEFT
? -1 : 1 );
2325 pShell
->ClearMark();
2326 pShell
->Pop(sal_False
); //Cursor steht jetzt wieder an der akt. Ueberschrift
2327 pShell
->EndAllAction();
2328 if(aActiveContentArr
[CONTENT_TYPE_OUTLINE
])
2329 aActiveContentArr
[CONTENT_TYPE_OUTLINE
]->Invalidate();
2333 const sal_uInt16 nCurrPos
= pShell
->GetOutlinePos(MAXLEVEL
);
2334 SvLBoxEntry
* pFirst
= First();
2336 while( 0 != (pFirst
= Next(pFirst
)) && lcl_IsContent(pFirst
))
2338 if(((SwOutlineContent
*)pFirst
->GetUserData())->GetPos() == nCurrPos
)
2341 MakeVisible(pFirst
);
2347 Sound::Beep(); //konnte nicht verschoben werden
2351 /***************************************************************************
2353 ***************************************************************************/
2356 void SwContentTree::ShowTree()
2359 SvTreeListBox::Show();
2362 /***************************************************************************
2363 Beschreibung: zusammengefaltet wird nicht geidlet
2364 ***************************************************************************/
2367 void SwContentTree::HideTree()
2370 SvTreeListBox::Hide();
2373 /***************************************************************************
2374 Beschreibung: Kein Idle mit Focus oder waehrend des Dragging
2375 ***************************************************************************/
2378 IMPL_LINK( SwContentTree
, TimerUpdate
, Timer
*, EMPTYARG
)
2380 // kein Update waehrend D&D
2381 // Viewabfrage, da der Navigator zu spaet abgeraeumt wird
2382 SwView
* pView
= GetParentWindow()->GetCreateView();
2383 if( (!HasFocus() || bViewHasChanged
) &&
2384 !bIsInDrag
&& !bIsInternalDrag
&& pView
&&
2385 pView
->GetWrtShellPtr() && !pView
->GetWrtShellPtr()->ActionPend() )
2387 bViewHasChanged
= sal_False
;
2388 bIsIdleClear
= sal_False
;
2389 SwWrtShell
* pActShell
= pView
->GetWrtShellPtr();
2390 if( bIsConstant
&& !lcl_FindShell( pActiveShell
) )
2392 SetActiveShell(pActShell
);
2393 GetParentWindow()->UpdateListBox();
2396 if(bIsActive
&& pActShell
!= GetWrtShell())
2397 SetActiveShell(pActShell
);
2398 else if( (bIsActive
|| (bIsConstant
&& pActShell
== GetWrtShell())) &&
2399 HasContentChanged())
2401 FindActiveTypeAndRemoveUserData();
2405 else if(!pView
&& bIsActive
&& !bIsIdleClear
)
2410 bIsIdleClear
= sal_True
;
2415 /***************************************************************************
2417 ***************************************************************************/
2420 DragDropMode
SwContentTree::NotifyStartDrag(
2421 TransferDataContainer
& rContainer
,
2422 SvLBoxEntry
* pEntry
)
2424 DragDropMode eMode
= (DragDropMode
)0;
2425 if( bIsActive
&& nRootType
== CONTENT_TYPE_OUTLINE
&&
2426 GetModel()->GetAbsPos( pEntry
) > 0
2427 && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
2428 eMode
= GetDragDropMode();
2429 else if(!bIsActive
&& GetWrtShell()->GetView().GetDocShell()->HasName())
2430 eMode
= SV_DRAGDROP_APP_COPY
;
2433 FillTransferData( rContainer
, nDragMode
);
2434 bDocChgdInDragging
= sal_False
;
2435 bIsInternalDrag
= sal_True
;
2440 /***************************************************************************
2441 Beschreibung : Nach dem Drag wird der aktuelle Absatz m i t
2443 ***************************************************************************/
2446 sal_Bool
SwContentTree::NotifyMoving( SvLBoxEntry
* pTarget
,
2447 SvLBoxEntry
* pEntry
, SvLBoxEntry
*& , ULONG
& )
2449 if(!bDocChgdInDragging
)
2451 sal_uInt16 nTargetPos
= 0;
2452 sal_uInt16 nSourcePos
= (( SwOutlineContent
* )pEntry
->GetUserData())->GetPos();
2453 if(!lcl_IsContent(pTarget
))
2454 nTargetPos
= USHRT_MAX
;
2456 nTargetPos
= (( SwOutlineContent
* )pTarget
->GetUserData())->GetPos();
2457 if( MAXLEVEL
> nOutlineLevel
&& // werden nicht alle Ebenen angezeigt
2458 nTargetPos
!= USHRT_MAX
)
2460 SvLBoxEntry
* pNext
= Next(pTarget
);
2462 nTargetPos
= (( SwOutlineContent
* )pNext
->GetUserData())->GetPos() -1;
2464 nTargetPos
= static_cast<sal_uInt16
>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1;
2468 DBG_ASSERT( pEntry
&&
2469 lcl_IsContent(pEntry
),"Source == 0 oder Source hat keinen Content" );
2470 GetParentWindow()->MoveOutline( nSourcePos
,
2474 aActiveContentArr
[CONTENT_TYPE_OUTLINE
]->Invalidate();
2477 //TreeListBox wird aus dem Dokument neu geladen
2480 /***************************************************************************
2481 Beschreibung : Nach dem Drag wird der aktuelle Absatz o h n e
2483 ***************************************************************************/
2486 sal_Bool
SwContentTree::NotifyCopying( SvLBoxEntry
* pTarget
,
2487 SvLBoxEntry
* pEntry
, SvLBoxEntry
*& , ULONG
& )
2489 if(!bDocChgdInDragging
)
2491 sal_uInt16 nTargetPos
= 0;
2492 sal_uInt16 nSourcePos
= (( SwOutlineContent
* )pEntry
->GetUserData())->GetPos();
2493 if(!lcl_IsContent(pTarget
))
2494 nTargetPos
= USHRT_MAX
;
2496 nTargetPos
= (( SwOutlineContent
* )pTarget
->GetUserData())->GetPos();
2498 if( MAXLEVEL
> nOutlineLevel
&& // werden nicht alle Ebenen angezeigt
2499 nTargetPos
!= USHRT_MAX
)
2501 SvLBoxEntry
* pNext
= Next(pTarget
);
2503 nTargetPos
= (( SwOutlineContent
* )pNext
->GetUserData())->GetPos() - 1;
2505 nTargetPos
= static_cast<sal_uInt16
>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1;
2510 DBG_ASSERT( pEntry
&&
2511 lcl_IsContent(pEntry
),"Source == 0 oder Source hat keinen Content" );
2512 GetParentWindow()->MoveOutline( nSourcePos
, nTargetPos
, sal_False
);
2514 //TreeListBox wird aus dem Dokument neu geladen
2515 aActiveContentArr
[CONTENT_TYPE_OUTLINE
]->Invalidate();
2521 /***************************************************************************
2522 Beschreibung: Kein Drop vor den ersten Eintrag - es ist ein SwContentType
2523 ***************************************************************************/
2525 sal_Bool
SwContentTree::NotifyAcceptDrop( SvLBoxEntry
* pEntry
)
2531 /***************************************************************************
2532 Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
2533 * dann soll die Basisfunktion des Controls gerufen werden
2534 ***************************************************************************/
2535 void SwContentTree::MouseButtonDown( const MouseEvent
& rMEvt
)
2537 Point
aPos( rMEvt
.GetPosPixel());
2538 SvLBoxEntry
* pEntry
= GetEntry( aPos
, sal_True
);
2539 if( !pEntry
&& rMEvt
.IsLeft() && rMEvt
.IsMod1() && (rMEvt
.GetClicks() % 2) == 0)
2540 Control::MouseButtonDown( rMEvt
);
2542 SvTreeListBox::MouseButtonDown( rMEvt
);
2545 /***************************************************************************
2546 Beschreibung: sofort aktualisieren
2547 ***************************************************************************/
2550 void SwContentTree::GetFocus()
2552 SwView
* pActView
= GetParentWindow()->GetCreateView();
2555 SwWrtShell
* pActShell
= pActView
->GetWrtShellPtr();
2556 if(bIsConstant
&& !lcl_FindShell(pActiveShell
))
2558 SetActiveShell(pActShell
);
2561 if(bIsActive
&& pActShell
!= GetWrtShell())
2562 SetActiveShell(pActShell
);
2563 else if( (bIsActive
|| (bIsConstant
&& pActShell
== GetWrtShell())) &&
2564 HasContentChanged())
2571 SvTreeListBox::GetFocus();
2574 /***************************************************************************
2576 ***************************************************************************/
2579 void SwContentTree::KeyInput(const KeyEvent
& rEvent
)
2581 const KeyCode aCode
= rEvent
.GetKeyCode();
2582 if(aCode
.GetCode() == KEY_RETURN
)
2584 SvLBoxEntry
* pEntry
= FirstSelected();
2587 switch(aCode
.GetModifier())
2591 GetParentWindow()->ToggleTree();
2594 // RootModus umschalten
2598 if(lcl_IsContentType(pEntry
))
2600 IsExpanded(pEntry
) ?
2605 ContentDoubleClickHdl(0);
2610 else if(aCode
.GetCode() == KEY_DELETE
&& 0 == aCode
.GetModifier())
2612 SvLBoxEntry
* pEntry
= FirstSelected();
2614 lcl_IsContent(pEntry
) &&
2615 ((SwContent
*)pEntry
->GetUserData())->GetParent()->IsDeletable() &&
2616 !pActiveShell
->GetView().GetDocShell()->IsReadOnly())
2618 EditEntry(pEntry
, EDIT_MODE_DELETE
);
2619 bViewHasChanged
= TRUE
;
2620 GetParentWindow()->UpdateListBox();
2621 TimerUpdate(&aUpdTimer
);
2626 SvTreeListBox::KeyInput(rEvent
);
2630 /***************************************************************************
2632 ***************************************************************************/
2635 void SwContentTree::RequestHelp( const HelpEvent
& rHEvt
)
2637 BOOL bCallBase
= TRUE
;
2638 if( rHEvt
.GetMode() & HELPMODE_QUICK
)
2640 Point
aPos( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ));
2641 SvLBoxEntry
* pEntry
= GetEntry( aPos
);
2645 sal_Bool bBalloon
= sal_False
;
2646 sal_Bool bContent
= sal_False
;
2647 void* pUserData
= pEntry
->GetUserData();
2648 if(lcl_IsContentType(pEntry
))
2649 nType
= ((SwContentType
*)pUserData
)->GetType();
2652 nType
= ((SwContent
*)pUserData
)->GetParent()->GetType();
2653 bContent
= sal_True
;
2656 sal_Bool bRet
= sal_False
;
2661 case CONTENT_TYPE_URLFIELD
:
2662 sEntry
= ((SwURLFieldContent
*)pUserData
)->GetURL();
2666 case CONTENT_TYPE_POSTIT
:
2667 sEntry
= ((SwPostItContent
*)pUserData
)->GetName();
2669 if(Help::IsBalloonHelpEnabled())
2670 bBalloon
= sal_True
;
2672 case CONTENT_TYPE_OUTLINE
:
2673 sEntry
= ((SwOutlineContent
*)pUserData
)->GetName();
2676 case CONTENT_TYPE_GRAPHIC
:
2677 sEntry
= ((SwGraphicContent
*)pUserData
)->GetLink();
2678 #if OSL_DEBUG_LEVEL > 1
2680 sEntry
+= String::CreateFromInt32(
2681 ((SwGraphicContent
*)pUserData
)->GetYPos());
2685 #if OSL_DEBUG_LEVEL > 1
2686 case CONTENT_TYPE_TABLE
:
2687 case CONTENT_TYPE_FRAME
:
2688 sEntry
= String::CreateFromInt32(
2689 ((SwContent
*)pUserData
)->GetYPos() );
2694 if(((SwContent
*)pUserData
)->IsInvisible())
2697 sEntry
+= C2S(", ");
2698 sEntry
+= sInvisible
;
2704 sal_uInt16 nMemberCount
= ((SwContentType
*)pUserData
)->GetMemberCount();
2705 sEntry
= String::CreateFromInt32(nMemberCount
);
2707 sEntry
+= nMemberCount
== 1
2708 ? ((SwContentType
*)pUserData
)->GetSingleName()
2709 : ((SwContentType
*)pUserData
)->GetName();
2715 SvLBoxItem
* pItem
= GetItem( pEntry
, aPos
.X(), &pTab
);
2716 if( pItem
&& SV_ITEM_ID_LBOXSTRING
== pItem
->IsA())
2718 aPos
= GetEntryPosition( pEntry
);
2720 aPos
.X() = GetTabPos( pEntry
, pTab
);
2721 Size
aSize( pItem
->GetSize( this, pEntry
) );
2723 if((aPos
.X() + aSize
.Width()) > GetSizePixel().Width())
2724 aSize
.Width() = GetSizePixel().Width() - aPos
.X();
2726 aPos
= OutputToScreenPixel(aPos
);
2727 Rectangle
aItemRect( aPos
, aSize
);
2730 aPos
.X() += aSize
.Width();
2731 Help::ShowBalloon( this, aPos
, aItemRect
, sEntry
);
2734 Help::ShowQuickHelp( this, aItemRect
, sEntry
,
2735 QUICKHELP_LEFT
|QUICKHELP_VCENTER
);
2741 Help::ShowQuickHelp( this, Rectangle(), aEmptyStr
, 0 );
2747 Window::RequestHelp( rHEvt
);
2750 /***************************************************************************
2752 ***************************************************************************/
2755 void SwContentTree::ExcecuteContextMenuAction( USHORT nSelectedPopupEntry
)
2757 SvLBoxEntry
* pFirst
= FirstSelected();
2758 switch( nSelectedPopupEntry
)
2771 nSelectedPopupEntry
-= 100;
2772 if(nOutlineLevel
!= nSelectedPopupEntry
)
2773 SetOutlineLevel((sal_Int8
)nSelectedPopupEntry
);
2778 GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry
- 201);
2782 EditEntry(pFirst
, nSelectedPopupEntry
== 401 ? EDIT_MODE_RMV_IDX
: EDIT_MODE_UPD_IDX
);
2784 // Eintrag bearbeiten
2786 EditEntry(pFirst
, EDIT_MODE_EDIT
);
2789 EditEntry(pFirst
, EDIT_UNPROTECT_TABLE
);
2793 const SwTOXBase
* pBase
= ((SwTOXBaseContent
*)pFirst
->GetUserData())
2795 pActiveShell
->SetTOXBaseReadonly(*pBase
, !pActiveShell
->IsTOXBaseReadonly(*pBase
));
2801 EditEntry(pFirst
, EDIT_MODE_DELETE
);
2804 EditEntry(pFirst
, EDIT_MODE_RENAME
);
2807 pActiveShell
->GetView().GetPostItMgr()->Show();
2810 pActiveShell
->GetView().GetPostItMgr()->Hide();
2814 pActiveShell
->GetView().GetPostItMgr()->SetActivePostIt(0);
2815 pActiveShell
->GetView().GetPostItMgr()->Delete();
2819 default: // nSelectedPopupEntry > 300
2820 if(nSelectedPopupEntry
> 300 && nSelectedPopupEntry
< 400)
2822 nSelectedPopupEntry
-= 300;
2823 SwView
*pView
= SwModule::GetFirstView();
2826 nSelectedPopupEntry
--;
2827 if(nSelectedPopupEntry
== 0)
2829 SetConstantShell(&pView
->GetWrtShell());
2832 pView
= SwModule::GetNextView(pView
);
2834 if(nSelectedPopupEntry
)
2836 bViewHasChanged
= bIsActive
= nSelectedPopupEntry
== 1;
2837 bIsConstant
= sal_False
;
2838 Display(nSelectedPopupEntry
== 1);
2842 GetParentWindow()->UpdateListBox();
2845 /***************************************************************************
2847 ***************************************************************************/
2850 void SwContentTree::SetOutlineLevel(sal_uInt8 nSet
)
2852 nOutlineLevel
= nSet
;
2853 pConfig
->SetOutlineLevel( nOutlineLevel
);
2854 SwContentType
** ppContentT
= bIsActive
?
2855 &aActiveContentArr
[CONTENT_TYPE_OUTLINE
] :
2856 &aHiddenContentArr
[CONTENT_TYPE_OUTLINE
];
2859 (*ppContentT
)->SetOutlineLevel(nOutlineLevel
);
2860 (*ppContentT
)->Init();
2865 /***************************************************************************
2866 Beschreibung: Moduswechsel: gedropptes Doc anzeigen
2867 ***************************************************************************/
2870 void SwContentTree::ShowHiddenShell()
2874 bIsConstant
= sal_False
;
2875 bIsActive
= sal_False
;
2880 /***************************************************************************
2881 Beschreibung: Moduswechsel: aktive Sicht anzeigen
2882 ***************************************************************************/
2885 void SwContentTree::ShowActualView()
2887 bIsActive
= sal_True
;
2888 bIsConstant
= sal_False
;
2890 GetParentWindow()->UpdateListBox();
2893 /*-----------------20.11.96 13.34-------------------
2894 Beschreibung: Hier sollen die Buttons zum Verschieben von
2895 Outlines en-/disabled werden
2896 --------------------------------------------------*/
2898 sal_Bool
SwContentTree::Select( SvLBoxEntry
* pEntry
, sal_Bool bSelect
)
2902 sal_Bool bEnable
= sal_False
;
2903 SvLBoxEntry
* pParentEntry
= GetParent(pEntry
);
2904 while(pParentEntry
&& (!lcl_IsContentType(pParentEntry
)))
2906 pParentEntry
= GetParent(pParentEntry
);
2908 if(!bIsLastReadOnly
&& (!IsVisible() ||
2909 (bIsRoot
&& nRootType
== CONTENT_TYPE_OUTLINE
&& pParentEntry
||
2910 lcl_IsContent(pEntry
) && ((SwContentType
*)pParentEntry
->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE
)))
2912 SwNavigationPI
* pNavi
= GetParentWindow();
2913 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_UP
, bEnable
);
2914 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_DOWN
, bEnable
);
2915 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_LEFT
, bEnable
);
2916 pNavi
->aContentToolBox
.EnableItem(FN_ITEM_RIGHT
,bEnable
);
2918 return SvTreeListBox::Select(pEntry
, bSelect
);
2921 /*-----------------27.11.96 12.56-------------------
2923 --------------------------------------------------*/
2925 void SwContentTree::SetRootType(sal_uInt16 nType
)
2929 pConfig
->SetRootType( nRootType
);
2932 /*-----------------10.01.97 12.19-------------------
2934 --------------------------------------------------*/
2936 void SwContentType::RemoveNewline(String
& rEntry
)
2938 sal_Unicode
* pStr
= rEntry
.GetBufferAccess();
2939 for(xub_StrLen i
= rEntry
.Len(); i
; --i
, ++pStr
)
2941 if( *pStr
== 10 || *pStr
== 13 )
2946 /*-----------------14.01.97 16.38-------------------
2948 --------------------------------------------------*/
2950 void SwContentTree::EditEntry(SvLBoxEntry
* pEntry
, sal_uInt8 nMode
)
2952 SwContent
* pCnt
= (SwContent
*)pEntry
->GetUserData();
2954 sal_uInt16 nType
= pCnt
->GetParent()->GetType();
2955 sal_uInt16 nSlot
= 0;
2957 uno::Reference
< container::XNameAccess
> xNameAccess
, xSecond
, xThird
;
2960 case CONTENT_TYPE_TABLE
:
2961 if(nMode
== EDIT_UNPROTECT_TABLE
)
2963 pActiveShell
->GetView().GetDocShell()->
2964 GetDoc()->UnProtectCells( pCnt
->GetName());
2966 else if(nMode
== EDIT_MODE_DELETE
)
2968 pActiveShell
->StartAction();
2969 String sTable
= SW_RES(STR_TABLE_NAME
);
2970 SwRewriter aRewriterTableName
;
2971 aRewriterTableName
.AddRule(UNDO_ARG1
, SW_RES(STR_START_QUOTE
));
2972 aRewriterTableName
.AddRule(UNDO_ARG2
, pCnt
->GetName());
2973 aRewriterTableName
.AddRule(UNDO_ARG3
, SW_RES(STR_END_QUOTE
));
2974 sTable
= aRewriterTableName
.Apply(sTable
);
2976 SwRewriter aRewriter
;
2977 aRewriter
.AddRule(UNDO_ARG1
, sTable
);
2978 pActiveShell
->StartUndo(UNDO_DELETE
, &aRewriter
);
2979 pActiveShell
->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL
);
2980 pActiveShell
->DeleteRow();
2981 pActiveShell
->EndUndo(UNDO_DELETE
);
2982 pActiveShell
->EndAction();
2984 else if(nMode
== EDIT_MODE_RENAME
)
2986 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
2987 uno::Reference
< text::XTextTablesSupplier
> xTables(xModel
, uno::UNO_QUERY
);
2988 xNameAccess
= xTables
->getTextTables();
2991 nSlot
= FN_FORMAT_TABLE_DLG
;
2994 case CONTENT_TYPE_GRAPHIC
:
2995 if(nMode
== EDIT_MODE_DELETE
)
2997 pActiveShell
->DelRight();
2999 else if(nMode
== EDIT_MODE_RENAME
)
3001 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3002 uno::Reference
< text::XTextGraphicObjectsSupplier
> xGraphics(xModel
, uno::UNO_QUERY
);
3003 xNameAccess
= xGraphics
->getGraphicObjects();
3004 uno::Reference
< text::XTextFramesSupplier
> xFrms(xModel
, uno::UNO_QUERY
);
3005 xSecond
= xFrms
->getTextFrames();
3006 uno::Reference
< text::XTextEmbeddedObjectsSupplier
> xObjs(xModel
, uno::UNO_QUERY
);
3007 xThird
= xObjs
->getEmbeddedObjects();
3010 nSlot
= FN_FORMAT_GRAFIC_DLG
;
3013 case CONTENT_TYPE_FRAME
:
3014 case CONTENT_TYPE_OLE
:
3015 if(nMode
== EDIT_MODE_DELETE
)
3017 pActiveShell
->DelRight();
3019 else if(nMode
== EDIT_MODE_RENAME
)
3021 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3022 uno::Reference
< text::XTextFramesSupplier
> xFrms(xModel
, uno::UNO_QUERY
);
3023 uno::Reference
< text::XTextEmbeddedObjectsSupplier
> xObjs(xModel
, uno::UNO_QUERY
);
3024 if(CONTENT_TYPE_FRAME
== nType
)
3026 xNameAccess
= xFrms
->getTextFrames();
3027 xSecond
= xObjs
->getEmbeddedObjects();
3031 xNameAccess
= xObjs
->getEmbeddedObjects();
3032 xSecond
= xFrms
->getTextFrames();
3034 uno::Reference
< text::XTextGraphicObjectsSupplier
> xGraphics(xModel
, uno::UNO_QUERY
);
3035 xThird
= xGraphics
->getGraphicObjects();
3038 nSlot
= FN_FORMAT_FRAME_DLG
;
3040 case CONTENT_TYPE_BOOKMARK
:
3041 if(nMode
== EDIT_MODE_DELETE
)
3043 IDocumentMarkAccess
* const pMarkAccess
= pActiveShell
->getIDocumentMarkAccess();
3044 pMarkAccess
->deleteMark( pMarkAccess
->findMark(pCnt
->GetName()) );
3046 else if(nMode
== EDIT_MODE_RENAME
)
3048 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3049 uno::Reference
< text::XBookmarksSupplier
> xBkms(xModel
, uno::UNO_QUERY
);
3050 xNameAccess
= xBkms
->getBookmarks();
3053 nSlot
= FN_INSERT_BOOKMARK
;
3056 case CONTENT_TYPE_REGION
:
3057 if(nMode
== EDIT_MODE_RENAME
)
3059 uno::Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3060 uno::Reference
< text::XTextSectionsSupplier
> xSects(xModel
, uno::UNO_QUERY
);
3061 xNameAccess
= xSects
->getTextSections();
3064 nSlot
= FN_EDIT_REGION
;
3067 case CONTENT_TYPE_URLFIELD
:
3068 nSlot
= FN_EDIT_HYPERLINK
;
3070 case CONTENT_TYPE_REFERENCE
:
3071 nSlot
= FN_EDIT_FIELD
;
3074 case CONTENT_TYPE_POSTIT
:
3075 pActiveShell
->GetView().GetPostItMgr()->AssureStdModeAtShell();
3076 if(nMode
== EDIT_MODE_DELETE
)
3078 if (((SwPostItContent
*)pCnt
)->IsPostIt())
3080 pActiveShell
->GetView().GetPostItMgr()->SetActivePostIt(0);
3081 pActiveShell
->DelRight();
3084 // this code can be used once we want redline comments in the margin
3087 SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline());
3095 if (((SwPostItContent
*)pCnt
)->IsPostIt())
3098 nSlot
= FN_REDLINE_COMMENT
;
3101 case CONTENT_TYPE_INDEX
:
3103 const SwTOXBase
* pBase
= ((SwTOXBaseContent
*)pCnt
)->GetTOXBase();
3106 case EDIT_MODE_EDIT
:
3109 SwPtrItem
aPtrItem( FN_INSERT_MULTI_TOX
, (void*)pBase
);
3110 pActiveShell
->GetView().GetViewFrame()->
3111 GetDispatcher()->Execute(FN_INSERT_MULTI_TOX
,
3112 SFX_CALLMODE_ASYNCHRON
, &aPtrItem
, 0L);
3116 case EDIT_MODE_RMV_IDX
:
3117 case EDIT_MODE_DELETE
:
3120 pActiveShell
->DeleteTOX(*pBase
, EDIT_MODE_DELETE
== nMode
);
3123 case EDIT_MODE_UPD_IDX
:
3124 case EDIT_MODE_RENAME
:
3126 Reference
< frame::XModel
> xModel
= pActiveShell
->GetView().GetDocShell()->GetBaseModel();
3127 Reference
< XDocumentIndexesSupplier
> xIndexes(xModel
, UNO_QUERY
);
3128 Reference
< XIndexAccess
> xIdxAcc(xIndexes
->getDocumentIndexes());
3129 Reference
< XNameAccess
>xLocalNameAccess(xIdxAcc
, UNO_QUERY
);
3130 if(EDIT_MODE_RENAME
== nMode
)
3131 xNameAccess
= xLocalNameAccess
;
3132 else if(xLocalNameAccess
.is() && xLocalNameAccess
->hasByName(pBase
->GetTOXName()))
3134 Any aIdx
= xLocalNameAccess
->getByName(pBase
->GetTOXName());
3135 Reference
< XDocumentIndex
> xIdx
;
3144 case CONTENT_TYPE_DRAWOBJECT
:
3145 if(EDIT_MODE_DELETE
== nMode
)
3150 pActiveShell
->GetView().GetViewFrame()->
3151 GetDispatcher()->Execute(nSlot
, SFX_CALLMODE_ASYNCHRON
);
3152 else if(xNameAccess
.is())
3154 uno::Any aObj
= xNameAccess
->getByName(pCnt
->GetName());
3155 uno::Reference
< uno::XInterface
> xTmp
;
3157 uno::Reference
< container::XNamed
> xNamed(xTmp
, uno::UNO_QUERY
);
3158 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
3159 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
3161 AbstractSwRenameXNamedDlg
* pDlg
= pFact
->CreateSwRenameXNamedDlg( this, xNamed
, xNameAccess
, DLG_RENAME_XNAMED
);
3162 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
3164 pDlg
->SetAlternativeAccess( xSecond
, xThird
);
3166 String sForbiddenChars
;
3167 if(CONTENT_TYPE_BOOKMARK
== nType
)
3169 sForbiddenChars
= C2S("/\\@:*?\";,.#");
3171 else if(CONTENT_TYPE_TABLE
== nType
)
3173 sForbiddenChars
= C2S(" .<>");
3175 pDlg
->SetForbiddenChars(sForbiddenChars
);
3181 /*-----------------14.01.97 16.53-------------------
3183 --------------------------------------------------*/
3185 void SwContentTree::GotoContent(SwContent
* pCnt
)
3187 pActiveShell
->EnterStdMode();
3189 sal_Bool bSel
= sal_False
;
3190 sal_uInt16 nJumpType
= pCnt
->GetParent()->GetType();
3193 case CONTENT_TYPE_OUTLINE
:
3195 pActiveShell
->GotoOutline(((SwOutlineContent
*)pCnt
)->GetPos());
3198 case CONTENT_TYPE_TABLE
:
3200 pActiveShell
->GotoTable(pCnt
->GetName());
3203 case CONTENT_TYPE_FRAME
:
3204 case CONTENT_TYPE_GRAPHIC
:
3205 case CONTENT_TYPE_OLE
:
3207 if(pActiveShell
->GotoFly(pCnt
->GetName()))
3211 case CONTENT_TYPE_BOOKMARK
:
3213 pActiveShell
->GotoMark(pCnt
->GetName());
3216 case CONTENT_TYPE_REGION
:
3218 pActiveShell
->GotoRegion(pCnt
->GetName());
3221 case CONTENT_TYPE_URLFIELD
:
3223 if(pActiveShell
->GotoINetAttr(
3224 *((SwURLFieldContent
*)pCnt
)->GetINetAttr() ))
3226 pActiveShell
->Right( CRSR_SKIP_CHARS
, sal_True
, 1, sal_False
);
3227 pActiveShell
->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT
, sal_True
);
3232 case CONTENT_TYPE_REFERENCE
:
3234 pActiveShell
->GotoRefMark(pCnt
->GetName());
3237 case CONTENT_TYPE_INDEX
:
3239 if (!pActiveShell
->GotoNextTOXBase(&pCnt
->GetName()))
3240 pActiveShell
->GotoPrevTOXBase(&pCnt
->GetName());
3243 case CONTENT_TYPE_POSTIT
:
3244 pActiveShell
->GetView().GetPostItMgr()->AssureStdModeAtShell();
3245 if (((SwPostItContent
*)pCnt
)->IsPostIt())
3246 pActiveShell
->GotoFld(*((SwPostItContent
*)pCnt
)->GetPostIt());
3248 pActiveShell
->GetView().GetDocShell()->GetWrtShell()->GotoRedline(
3249 pActiveShell
->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent
*)pCnt
)->GetRedline()->GetRedlineData()));
3252 case CONTENT_TYPE_DRAWOBJECT
:
3254 SdrView
* pDrawView
= pActiveShell
->GetDrawView();
3257 pDrawView
->SdrEndTextEdit();
3258 pDrawView
->UnmarkAll();
3259 SdrModel
* _pModel
= pActiveShell
->getIDocumentDrawModelAccess()->GetDrawModel();
3260 SdrPage
* pPage
= _pModel
->GetPage(0);
3261 sal_uInt32 nCount
= pPage
->GetObjCount();
3262 for( sal_uInt32 i
=0; i
< nCount
; i
++ )
3264 SdrObject
* pTemp
= pPage
->GetObj(i
);
3265 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
3266 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName() == pCnt->GetName())
3267 if ( pTemp
->GetName() == pCnt
->GetName() )
3270 SdrPageView
* pPV
= pDrawView
->GetSdrPageView();
3273 pDrawView
->MarkObj( pTemp
, pPV
);
3283 pActiveShell
->HideCrsr();
3284 pActiveShell
->EnterSelFrmMode();
3286 SwView
& rView
= pActiveShell
->GetView();
3287 rView
.StopShellTimer();
3288 rView
.GetPostItMgr()->SetActivePostIt(0);
3289 rView
.GetEditWin().GrabFocus();
3291 /*-----------------06.02.97 19.14-------------------
3292 Jetzt nochtdie passende text::Bookmark
3293 --------------------------------------------------*/
3295 NaviContentBookmark::NaviContentBookmark()
3298 nDefDrag( REGION_MODE_NONE
)
3302 /*-----------------06.02.97 20.12-------------------
3304 --------------------------------------------------*/
3306 NaviContentBookmark::NaviContentBookmark( const String
&rUrl
,
3307 const String
& rDesc
,
3308 sal_uInt16 nDragType
,
3309 const SwDocShell
* pDocSh
) :
3312 nDocSh((long)pDocSh
),
3313 nDefDrag( nDragType
)
3317 void NaviContentBookmark::Copy( TransferDataContainer
& rData
) const
3319 rtl_TextEncoding eSysCSet
= gsl_getSystemTextEncoding();
3321 ByteString
sStr( aUrl
, eSysCSet
);
3322 sStr
+= static_cast< char >(NAVI_BOOKMARK_DELIM
);
3323 sStr
+= ByteString( aDescr
, eSysCSet
);
3324 sStr
+= static_cast< char >(NAVI_BOOKMARK_DELIM
);
3325 sStr
+= ByteString::CreateFromInt32( nDefDrag
);
3326 sStr
+= static_cast< char >(NAVI_BOOKMARK_DELIM
);
3327 sStr
+= ByteString::CreateFromInt32( nDocSh
);
3328 rData
.CopyByteString( SOT_FORMATSTR_ID_SONLK
, sStr
);
3331 sal_Bool
NaviContentBookmark::Paste( TransferableDataHelper
& rData
)
3334 sal_Bool bRet
= rData
.GetString( SOT_FORMATSTR_ID_SONLK
, sStr
);
3337 xub_StrLen nPos
= 0;
3338 aUrl
= sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
);
3339 aDescr
= sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
);
3340 nDefDrag
= (USHORT
)sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
).ToInt32();
3341 nDocSh
= sStr
.GetToken(0, NAVI_BOOKMARK_DELIM
, nPos
).ToInt32();
3347 /* -----------------------------09.12.99 13:50--------------------------------
3349 ---------------------------------------------------------------------------*/
3350 class SwContentLBoxString
: public SvLBoxString
3353 SwContentLBoxString( SvLBoxEntry
* pEntry
, sal_uInt16 nFlags
,
3354 const String
& rStr
) : SvLBoxString(pEntry
,nFlags
,rStr
) {}
3356 virtual void Paint( const Point
& rPos
, SvLBox
& rDev
, sal_uInt16 nFlags
,
3357 SvLBoxEntry
* pEntry
);
3360 /* -----------------------------09.12.99 13:49--------------------------------
3362 ---------------------------------------------------------------------------*/
3363 void SwContentTree::InitEntry(SvLBoxEntry
* pEntry
,
3364 const XubString
& rStr
,const Image
& rImg1
,const Image
& rImg2
,
3365 SvLBoxButtonKind eButtonKind
)
3367 sal_uInt16 nColToHilite
= 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
3368 SvTreeListBox::InitEntry( pEntry
, rStr
, rImg1
, rImg2
, eButtonKind
);
3369 SvLBoxString
* pCol
= (SvLBoxString
*)pEntry
->GetItem( nColToHilite
);
3370 SwContentLBoxString
* pStr
= new SwContentLBoxString( pEntry
, 0, pCol
->GetText() );
3371 pEntry
->ReplaceItem( pStr
, nColToHilite
);
3373 /* -----------------------------09.12.99 13:49--------------------------------
3375 ---------------------------------------------------------------------------*/
3376 void SwContentLBoxString::Paint( const Point
& rPos
, SvLBox
& rDev
, sal_uInt16 nFlags
,
3377 SvLBoxEntry
* pEntry
)
3379 if(lcl_IsContent(pEntry
) &&
3380 ((SwContent
*)pEntry
->GetUserData())->IsInvisible())
3382 //* pCont = (SwContent*)pEntry->GetUserData();
3383 Font
aOldFont( rDev
.GetFont());
3384 Font
aFont(aOldFont
);
3385 Color
aCol( COL_LIGHTGRAY
);
3386 aFont
.SetColor( aCol
);
3387 rDev
.SetFont( aFont
);
3388 rDev
.DrawText( rPos
, GetText() );
3389 rDev
.SetFont( aOldFont
);
3392 SvLBoxString::Paint( rPos
, rDev
, nFlags
, pEntry
);
3394 /* -----------------------------06.05.2002 10:20------------------------------
3396 ---------------------------------------------------------------------------*/
3397 void SwContentTree::DataChanged( const DataChangedEvent
& rDCEvt
)
3399 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
3400 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
3402 USHORT nResId
= GetDisplayBackground().GetColor().IsDark() ? IMG_NAVI_ENTRYBMPH
: IMG_NAVI_ENTRYBMP
;
3403 aEntryImages
= ImageList(SW_RES(nResId
));
3404 FindActiveTypeAndRemoveUserData();
3407 SvTreeListBox::DataChanged( rDCEvt
);