merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / utlui / content.cxx
blobcee01169782290bcff37127ebf46cb64dcc4636d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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"
34 #ifndef _SVSTDARR_HXX
35 #define _SVSTDARR_STRINGSDTOR
36 #include <svtools/svstdarr.hxx>
37 #endif
38 #include <svtools/urlbmk.hxx>
39 #include <tools/urlobj.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/dispatch.hxx>
42 #ifndef _HELP_HXX
43 #include <vcl/help.hxx>
44 #endif
45 #include <sot/formats.hxx>
46 #include <vcl/sound.hxx>
47 #include <uiitems.hxx>
48 #include <fmtinfmt.hxx>
49 #include <txtinet.hxx>
50 #include <fmtfld.hxx>
51 #include <swmodule.hxx>
52 #include <wrtsh.hxx>
53 #ifndef _VIEW_HXX
54 #include <view.hxx>
55 #endif
56 #include <errhdl.hxx>
57 #ifndef _DOCSH_HXX
58 #include <docsh.hxx>
59 #endif
60 #include <content.hxx>
61 #include <frmfmt.hxx>
62 #include <fldbas.hxx>
63 #include <txtatr.hxx>
64 #include <IMark.hxx>
65 #include <section.hxx>
66 #include <tox.hxx>
67 #define NAVIPI_CXX
68 #include <navipi.hxx>
69 #include <navicont.hxx>
70 #include <navicfg.hxx>
71 #include <edtwin.hxx>
72 #include <doc.hxx>
73 #include <unotools.hxx>
74 #include <crsskip.hxx>
75 #ifndef _CMDID_H
76 #include <cmdid.h>
77 #endif
78 #ifndef _HELPID_H
79 #include <helpid.h>
80 #endif
81 #ifndef _NAVIPI_HRC
82 #include <navipi.hrc>
83 #endif
84 #ifndef _UTLUI_HRC
85 #include <utlui.hrc>
86 #endif
87 #ifndef _MISC_HRC
88 #include <misc.hrc>
89 #endif
90 #ifndef _COMCORE_HRC
91 #include <comcore.hrc>
92 #endif
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>
110 #include <ndtxt.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"
119 #include <unomid.h>
122 #define CTYPE_CNT 0
123 #define CTYPE_CTT 1
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;
145 namespace
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();
163 while (pView)
165 if(pShell == &pView->GetWrtShell())
167 bFound = sal_True;
168 break;
170 pView = SwModule::GetNextView(pView);
172 return bFound;
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),
188 pParent(pCnt),
189 sContentName(rName),
190 nYPosition(nYPos),
191 bInvisible(sal_False)
196 sal_uInt8 SwTypeNumber::GetTypeId()
198 return nTypeId;
201 SwTypeNumber::~SwTypeNumber()
205 sal_Bool SwContent::IsProtect() const
207 return sal_False;
210 sal_Bool SwPostItContent::IsProtect() const
212 if (mbPostIt)
213 return pFld->IsProtect();
214 else
215 return false;
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),
237 pWrtShell(pShell),
238 pMember(0),
239 sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)),
240 sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)),
241 nMemberCount(0),
242 nContentType(nType),
243 nOutlineLevel(nLevel),
244 bMemberFilled(sal_False),
245 bDataValid(sal_False),
246 bEdit(sal_False),
247 bDelete(sal_True)
249 Init();
252 /***************************************************************************
253 Beschreibung: Initialisierung
254 ***************************************************************************/
257 void SwContentType::Init(sal_Bool* pbInvalidateWindow)
259 // wenn sich der MemberCount aendert ...
260 sal_uInt16 nOldMemberCount = nMemberCount;
261 nMemberCount = 0;
262 switch(nContentType)
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 )
274 nMemberCount --;
277 bDelete = sal_False;
279 break;
281 case CONTENT_TYPE_TABLE :
282 sTypeToken = C2S(pMarkToTable);
283 nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True);
284 bEdit = sal_True;
285 break;
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);
304 bEdit = sal_True;
306 break;
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;
315 bEdit = sal_True;
317 break;
318 case CONTENT_TYPE_REGION :
320 SwContentArr* pOldMember = 0;
321 sal_uInt16 nOldRegionCount = 0;
322 sal_Bool bInvalidate = sal_False;
323 if(!pMember)
324 pMember = new SwContentArr;
325 else if(pMember->Count())
327 pOldMember = pMember;
328 nOldRegionCount = pOldMember->Count();
329 pMember = new SwContentArr;
331 const Point aNullPt;
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();
342 BYTE nLevel = 0;
343 SwSectionFmt* pParentFmt = pFmt->GetParent();
344 while(pParentFmt)
346 nLevel++;
347 pParentFmt = pParentFmt->GetParent();
350 SwContent* pCnt = new SwRegionContent(this, rSectionName,
351 nLevel,
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);
369 bEdit = sal_True;
370 bDelete = sal_False;
371 if(pOldMember)
373 pOldMember->DeleteAndDestroy(0, pOldMember->Count());
374 delete pOldMember;
375 if(pbInvalidateWindow && bInvalidate)
376 *pbInvalidateWindow = sal_True;
379 break;
380 case CONTENT_TYPE_INDEX:
382 nMemberCount = pWrtShell->GetTOXCount();
383 bEdit = sal_True;
384 bDelete = sal_False;
386 break;
387 case CONTENT_TYPE_REFERENCE:
389 nMemberCount = pWrtShell->GetRefMarks( 0 );
390 bDelete = sal_False;
392 break;
393 case CONTENT_TYPE_URLFIELD:
395 nMemberCount = 0;
396 if(!pMember)
397 pMember = new SwContentArr;
398 else if(pMember->Count())
399 pMember->DeleteAndDestroy(0, pMember->Count());
401 SwGetINetAttrs aArr;
402 nMemberCount = pWrtShell->GetINetAttrs( aArr );
403 for( sal_uInt16 n = 0; n < nMemberCount; ++n )
405 SwGetINetAttr* p = aArr[ n ];
406 SwURLFieldContent* pCnt = new SwURLFieldContent(
407 this,
408 p->sText,
409 INetURLObject::decode(
410 p->rINetAttr.GetINetFmt().GetValue(),
411 INET_HEX_ESCAPE,
412 INetURLObject::DECODE_UNAMBIGUOUS,
413 RTL_TEXTENCODING_UTF8 ),
414 &p->rINetAttr,
415 n );
416 pMember->Insert( pCnt );//, n );
418 bEdit = sal_True;
419 nOldMemberCount = nMemberCount;
420 bDelete = sal_False;
422 break;
423 case CONTENT_TYPE_POSTIT:
425 nMemberCount = 0;
426 if(!pMember)
427 pMember = new SwContentArr;
428 else if(pMember->Count())
429 pMember->DeleteAndDestroy(0, pMember->Count());
431 SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
432 if (aMgr)
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(
445 this,
446 sEntry,
447 (const SwFmtFld*)aFmtFld,
448 nMemberCount);
449 pMember->Insert(pCnt);
450 nMemberCount++;
454 // this code can be used once we want redline comments in the margin
455 else // redcomment
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(
463 this,
464 sEntry, // hier steht der Text
465 pRedline,
466 nMemberCount);
467 pMember->Insert(pCnt);
468 nMemberCount++;
475 sTypeToken = aEmptyStr;
476 bEdit = sal_True;
477 nOldMemberCount = nMemberCount;
479 break;
480 case CONTENT_TYPE_DRAWOBJECT:
482 sTypeToken = aEmptyStr;
483 nMemberCount = 0;
484 SdrModel* pModel = pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel();
485 if(pModel)
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() )
495 // <--
496 nMemberCount++;
500 break;
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 /***************************************************************************
510 Beschreibung:
511 ***************************************************************************/
514 SwContentType::~SwContentType()
516 delete pMember;
519 /***************************************************************************
520 Beschreibung: Inhalt liefern, dazu gfs. die Liste fuellen
521 ***************************************************************************/
524 const SwContent* SwContentType::GetMember(sal_uInt16 nIndex)
526 if(!bDataValid || !pMember)
528 FillMemberList();
530 if(nIndex < pMember->Count())
531 return pMember->GetObject(nIndex);
532 else
533 return 0;
538 /***************************************************************************
539 Beschreibung:
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;
565 else if(!pMember)
566 pMember = new SwContentArr;
567 else if(pMember->Count())
568 pMember->DeleteAndDestroy(0, pMember->Count());
569 switch(nContentType)
571 case CONTENT_TYPE_OUTLINE :
573 sal_uInt16 nOutlineCount = nMemberCount =
574 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
576 sal_uInt16 nPos = 0;
577 for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
579 const sal_Int8 nLevel = (sal_Int8)pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i);
580 if(nLevel >= nOutlineLevel )
581 nMemberCount--;
582 else
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
592 // cast fuer Win16
593 if(nOldMemberCount > (int)nPos &&
594 ((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel)
595 *pbLevelOrVisibiblityChanged = sal_True;
597 nPos++;
602 break;
604 case CONTENT_TYPE_TABLE :
606 DBG_ASSERT(nMemberCount ==
607 pWrtShell->GetTblFrmFmtCount(sal_True),
608 "MemberCount differiert");
609 Point aNullPt;
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;
629 break;
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");
641 Point aNullPt;
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();
648 SwContent* pCnt;
649 if(CONTENT_TYPE_GRAPHIC == nContentType)
651 String sLink;
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());
659 else
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;
673 break;
674 case CONTENT_TYPE_BOOKMARK:
676 IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
677 for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin();
678 ppBookmark != pMarkAccess->getBookmarksEnd();
679 ppBookmark++)
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());
690 break;
691 case CONTENT_TYPE_REGION :
693 const Point aNullPt;
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();
705 BYTE nLevel = 0;
706 SwSectionFmt* pParentFmt = pFmt->GetParent();
707 while(pParentFmt)
709 nLevel++;
710 pParentFmt = pParentFmt->GetParent();
713 SwContent* pCnt = new SwRegionContent(this, sSectionName,
714 nLevel,
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();
730 break;
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);
744 break;
745 case CONTENT_TYPE_URLFIELD:
747 SwGetINetAttrs aArr;
748 nMemberCount = pWrtShell->GetINetAttrs( aArr );
749 for( sal_uInt16 n = 0; n < nMemberCount; ++n )
751 SwGetINetAttr* p = aArr[ n ];
752 SwURLFieldContent* pCnt = new SwURLFieldContent(
753 this,
754 p->sText,
755 INetURLObject::decode(
756 p->rINetAttr.GetINetFmt().GetValue(),
757 INET_HEX_ESCAPE,
758 INetURLObject::DECODE_UNAMBIGUOUS,
759 RTL_TEXTENCODING_UTF8 ),
760 &p->rINetAttr,
761 n );
762 pMember->Insert( pCnt );//, n );
765 break;
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;
790 break;
791 case CONTENT_TYPE_POSTIT:
793 nMemberCount = 0;
794 if(!pMember)
795 pMember = new SwContentArr;
796 else if(pMember->Count())
797 pMember->DeleteAndDestroy(0, pMember->Count());
798 SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
799 if (aMgr)
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(
812 this,
813 sEntry,
814 (const SwFmtFld*)aFmtFld,
815 nMemberCount);
816 pMember->Insert(pCnt);
817 nMemberCount++;
820 /* this code can be used once we want redline comments in the margin
821 else // redcomment
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(
829 this,
830 sEntry,
831 pRedline,
832 nMemberCount);
833 pMember->Insert(pCnt);
834 nMemberCount++;
842 break;
843 case CONTENT_TYPE_DRAWOBJECT:
845 nMemberCount = 0;
846 if(!pMember)
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();
853 if(pModel)
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() )
863 // <--
865 SwContact* pContact = (SwContact*)pTemp->GetUserCall();
866 long nYPos = 0;
867 const Point aNullPt;
868 if(pContact && pContact->GetFmt())
869 nYPos = pContact->GetFmt()->FindLayoutRect(sal_False, &aNullPt).Top();
870 SwContent* pCnt = new SwContent(
871 this,
872 pTemp->GetName(),
873 nYPos);
874 if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer()))
875 pCnt->SetInvisible();
876 pMember->Insert(pCnt);
877 nMemberCount++;
878 if(nOldMemberCount > (int)i &&
879 (pOldMember->GetObject((USHORT)i))->IsInvisible() != pCnt->IsInvisible())
880 *pbLevelOrVisibiblityChanged = sal_True;
885 break;
887 bDataValid = sal_True;
888 if(pOldMember)
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 ),
901 sSpace(C2S(" ")),
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)),
914 pHiddenShell(0),
915 pActiveShell(0),
916 pConfig(SW_MOD()->GetNavigationConfig()),
918 nActiveBlock(0),
919 nHiddenBlock(0),
921 nRootType(USHRT_MAX),
922 nLastSelType(USHRT_MAX),
923 nOutlineLevel(MAXLEVEL),
925 bIsActive(sal_True),
926 bIsConstant(sal_False),
927 bIsHidden(sal_False),
928 bDocChgdInDragging(sal_False),
929 bIsInternalDrag(sal_False),
930 bIsRoot(sal_False),
931 bIsIdleClear(sal_False),
932 bIsLastReadOnly(sal_False),
933 bIsOutlineMoveable(sal_True),
934 bViewHasChanged(sal_False),
935 bIsImageListInitialized(sal_False)
937 sal_uInt16 i;
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);
956 Clear();
957 EnableContextMenuHandling();
960 /***************************************************************************
961 Beschreibung:
962 ***************************************************************************/
965 SwContentTree::~SwContentTree()
967 Clear(); // vorher gfs. Inhaltstypen loeschen
968 bIsInDrag = sal_False;
971 /***************************************************************************
972 Drag&Drop methods
973 ***************************************************************************/
974 void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
976 if( !bIsRoot || nRootType != CONTENT_TYPE_OUTLINE )
978 ReleaseMouse();
980 TransferDataContainer* pContainer = new TransferDataContainer;
981 uno::Reference<
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() );
991 else
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;
1010 if( bIsRoot )
1012 if( bIsOutlineMoveable )
1013 nRet = SvTreeListBox::AcceptDrop( rEvt );
1015 else if( !bIsInDrag )
1016 nRet = GetParentWindow()->AcceptDrop( rEvt );
1017 return nRet;
1020 /***************************************************************************
1021 Beschreibung: Drop wird im Navigator ausgefuehrt
1022 ***************************************************************************/
1023 void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent* pContent)
1025 void* key = 0;
1026 if( pTree && pContent )
1028 SwWrtShell* pShell = pTree->GetWrtShell();
1029 sal_Int32 nPos = pContent->GetYPos();
1030 if( nPos )
1032 key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos );
1035 return key;
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;
1062 if( bIsRoot )
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
1079 sal_uInt16 i;
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();
1096 while (pView)
1098 String sInsert = pView->GetDocShell()->GetTitle();
1099 if(pView == pActiveView)
1101 sInsert += '(';
1102 sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST];
1103 sInsert += ')';
1105 pSubPop3->InsertItem(nId, sInsert);
1106 if(bIsConstant && pActiveShell == &pView->GetWrtShell())
1107 pSubPop3->CheckItem(nId);
1108 pView = SwModule::GetNextView(pView);
1109 nId++;
1111 pSubPop3->InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]);
1112 if(pHiddenShell)
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);
1121 if(bIsActive)
1122 pSubPop3->CheckItem( --nId );
1123 else if(bIsHidden)
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;
1191 else if(bEditable)
1192 pPop->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1193 else if(bDeletable)
1195 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1198 //Rename object
1199 if(bRenamable)
1201 if(bSubPop4)
1202 pSubPop4->InsertItem(502, sRename);
1203 else
1204 pPop->InsertItem(502, sRename);
1207 if(bSubPop4)
1209 pPop->InsertItem(4, pContType->GetSingleName());
1210 pPop->SetPopupMenu(4, pSubPop4);
1214 else if( pEntry )
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 );
1238 return pPop;
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))
1251 nLevel++;
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);
1291 if(pCnt)
1293 sal_uInt16 nLevel = ((SwOutlineContent*)pCnt)->GetOutlineLevel();
1294 String sEntry = pCnt->GetName();
1295 if(!sEntry.Len())
1296 sEntry = sSpace;
1297 if(!pChild || (nLevel == 0))
1298 pChild = InsertEntry(sEntry, pParent,
1299 sal_False, LIST_APPEND,(void*)pCnt);
1300 else
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);
1306 else
1308 pChild = Prev(pChild);
1309 while(pChild &&
1310 lcl_IsContent(pChild) &&
1311 !(((SwOutlineContent*)pChild->GetUserData())->GetOutlineLevel() < nLevel)
1314 pChild = Prev(pChild);
1316 if(pChild)
1317 pChild = InsertEntry(sEntry, pChild,
1318 sal_False, LIST_APPEND, (void*)pCnt);
1324 else
1326 for(sal_uInt16 i = 0; i < nCount; i++)
1328 const SwContent* pCnt = pCntType->GetMember(i);
1329 if(pCnt)
1331 String sEntry = pCnt->GetName();
1332 if(!sEntry.Len())
1333 sEntry = sSpace;
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);
1362 else
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;
1388 return bBool;
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 )
1409 sal_Bool bRet;
1410 if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) ||
1411 (nRootType == CONTENT_TYPE_OUTLINE))
1413 if(lcl_IsContentType(pParent))
1415 if(bIsRoot)
1416 return bRet = sal_False;
1417 SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1418 sal_uInt16 nAnd = 1 << pCntType->GetType();
1419 nAnd = ~nAnd;
1420 if(bIsActive || bIsConstant)
1422 nActiveBlock &= nAnd;
1423 pConfig->SetActiveBlock(nActiveBlock);
1425 else
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);
1437 else
1438 // bRet = sal_False;
1439 bRet = SvTreeListBox::Collapse(pParent);
1440 return bRet;
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!");
1454 if(pEntry)
1456 if(lcl_IsContentType(pEntry) && !pEntry->HasChilds())
1457 RequestingChilds(pEntry);
1458 else if(!lcl_IsContentType(pEntry) && (bIsActive || bIsConstant))
1460 if(bIsConstant)
1462 pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
1464 //Inhaltstyp anspringen:
1465 SwContent* pCnt = (SwContent*)pEntry->GetUserData();
1466 DBG_ASSERT( pCnt, "keine UserData");
1467 GotoContent(pCnt);
1468 if(pCnt->GetParent()->GetType() == CONTENT_TYPE_FRAME)
1469 pActiveShell->EnterStdMode();
1472 return 0;
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;
1495 if(pOldSelEntry)
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));
1512 Clear();
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);
1530 if(pShell)
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];
1541 if(!*ppContentT)
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)
1552 pSelEntry = pEntry;
1553 sal_Int32 nExpandOptions = bIsActive || bIsConstant ?
1554 nActiveBlock :
1555 nHiddenBlock;
1556 if(nExpandOptions & (1 << nCntType))
1558 Expand(pEntry);
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 )
1571 pSelEntry = pChild;
1572 break;
1574 pTemp = pChild;
1575 nPos++;
1577 if(!pSelEntry || lcl_IsContentType(pSelEntry))
1578 pSelEntry = pTemp;
1583 if(pSelEntry)
1585 MakeVisible(pSelEntry);
1586 Select(pSelEntry);
1588 else
1589 nOldScrollPos = 0;
1591 else
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);
1609 if(pCnt)
1611 String sEntry = pCnt->GetName();
1612 if(!sEntry.Len())
1613 sEntry = sSpace;
1614 InsertEntry( sEntry, pParent,
1615 sal_False, LIST_APPEND, (void*)pCnt);
1619 else
1620 RequestingChilds(pParent);
1621 Expand(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);
1633 Select(pEntry);
1638 else
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 )
1650 pSelEntry = pChild;
1651 break;
1653 pTemp = pChild;
1654 nPos++;
1656 if(!pSelEntry)
1657 pSelEntry = pTemp;
1658 if(pSelEntry)
1660 MakeVisible(pSelEntry);
1661 Select(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 /***************************************************************************
1691 Beschreibung:
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)
1701 return sal_False;
1702 String sEntry;
1703 SwContent* pCnt = ((SwContent*)pEntry->GetUserData());
1705 sal_uInt16 nActType = pCnt->GetParent()->GetType();
1706 String sUrl;
1707 sal_Bool bOutline = sal_False;
1708 String sOutlineText;
1709 switch( nActType )
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();
1729 nLevel++ )
1731 sal_uInt16 nVal = (sal_uInt16)aNumVector[nLevel];
1732 nVal ++;
1733 nVal = nVal - pOutlRule->Get(nLevel).GetStart();
1734 sEntry += String::CreateFromInt32( nVal );
1735 sEntry += '.';
1738 sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false);
1739 sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true);
1740 bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable();
1741 bOutline = sal_True;
1744 break;
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
1749 break;
1750 case CONTENT_TYPE_URLFIELD:
1751 sUrl = ((SwURLFieldContent*)pCnt)->GetURL();
1752 // kein break;
1753 case CONTENT_TYPE_OLE:
1754 case CONTENT_TYPE_GRAPHIC:
1755 if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE)
1756 break;
1757 else
1758 rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
1759 default:
1760 sEntry = GetEntryText(pEntry);
1763 sal_Bool bRet = sal_False;
1764 if(sEntry.Len())
1766 const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
1767 if(!sUrl.Len())
1769 if(pDocShell->HasName())
1771 SfxMedium* pMedium = pDocShell->GetMedium();
1772 sUrl = pMedium->GetURLObject().GetURLNoMark();
1773 // nur, wenn primaer ein Link eingefuegt werden soll
1774 bRet = sal_True;
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
1781 bRet = sal_True;
1783 else if(bIsConstant &&
1784 ( !::GetActiveView() ||
1785 pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
1787 // Urls von inaktiven Views ohne Dateinamen koennen auch nicht
1788 // gedraggt werden
1789 bRet = sal_False;
1791 else
1793 bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE;
1794 rDragMode = DND_ACTION_MOVE;
1797 const String& rToken = pCnt->GetParent()->GetTypeToken();
1798 sUrl += '#';
1799 sUrl += sEntry;
1800 if(rToken.Len())
1802 sUrl += cMarkSeperator;
1803 sUrl += rToken;
1806 else
1807 bRet = sal_True;
1809 if( bRet )
1811 //fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer
1812 if(bOutline)
1813 sEntry = sOutlineText;
1816 NaviContentBookmark aBmk( sUrl, sEntry,
1817 GetParentWindow()->GetRegionDropMode(),
1818 pDocShell);
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 );
1831 return bRet;
1833 /***************************************************************************
1834 Beschreibung: Umschalten der Anzeige auf Root
1835 ***************************************************************************/
1838 sal_Bool SwContentTree::ToggleToRoot()
1840 if(!bIsRoot)
1842 SvLBoxEntry* pEntry = GetCurEntry();
1843 const SwContentType* pCntType;
1844 if(pEntry)
1846 if(lcl_IsContentType(pEntry))
1847 pCntType = (SwContentType*)pEntry->GetUserData();
1848 else
1849 pCntType = ((SwContent*)pEntry->GetUserData())->GetParent();
1850 nRootType = pCntType->GetType();
1851 bIsRoot = sal_True;
1852 Display(bIsActive || bIsConstant);
1855 else
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);
1864 return 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();
1898 else if(bIsRoot)
1900 sal_Bool bOutline = sal_False;
1901 SvLBoxEntry* pEntry = First();
1902 if(!pEntry)
1903 bRepaint = sal_True;
1904 else
1906 sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType();
1907 bOutline = nRootType == CONTENT_TYPE_OUTLINE;
1908 SwContentType* pArrType = aActiveContentArr[nType];
1909 if(!pArrType)
1910 bRepaint = sal_True;
1911 else
1913 sal_uInt16 nSelLevel = USHRT_MAX;
1915 SvLBoxEntry* pFirstSel;
1916 if(bOutline &&
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);
1930 if(!bRepaint)
1932 if(GetChildCount(pEntry) != pArrType->GetMemberCount())
1933 bRepaint = sal_True;
1934 else
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);
1972 else
1974 SvLBoxEntry* pEntry = First();
1975 while ( pEntry )
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];
1982 if(!pArrType)
1983 bRepaint = sal_True;
1984 else
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;
2003 else
2005 for(sal_uInt16 j = 0; j < nChildCount; j++)
2007 pEntry = Next(pEntry);
2008 bNext = sal_False;
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;
2035 else
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);
2049 if(bRemoveChildren)
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);
2057 pRemove = pChild;
2060 if(!nChildCount)
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);
2077 bNext = sal_False;
2081 if(!bRepaint && bInvalidate)
2082 Invalidate();
2083 return bRepaint;
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();
2094 if(pEntry)
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)))
2100 pEntry = pParent;
2101 if(pEntry->GetUserData() && lcl_IsContentType(pEntry))
2102 nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType();
2104 // else
2105 // nLastSelType = USHRT_MAX;
2106 pEntry = First();
2107 while(pEntry)
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)
2122 pHiddenShell = 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]);
2130 Display(bIsActive);
2132 GetParentWindow()->UpdateListBox();
2134 /***************************************************************************
2135 Beschreibung: Dokumentwechsel - neue Shell setzen
2136 ***************************************************************************/
2139 void SwContentTree::SetActiveShell(SwWrtShell* pSh)
2141 if(bIsInternalDrag)
2142 bDocChgdInDragging = sal_True;
2143 sal_Bool bClear = pActiveShell != pSh;
2144 if(bIsActive && bClear)
2146 pActiveShell = pSh;
2147 FindActiveTypeAndRemoveUserData();
2148 Clear();
2150 else if(bIsConstant)
2152 if(!lcl_FindShell(pActiveShell))
2154 pActiveShell = pSh;
2155 bIsActive = sal_True;
2156 bIsConstant = sal_False;
2157 bClear = sal_True;
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]);
2169 Display(sal_True);
2173 /***************************************************************************
2174 Beschreibung: Eine offene View als aktiv festlegen
2175 ***************************************************************************/
2178 void SwContentTree::SetConstantShell(SwWrtShell* pSh)
2180 pActiveShell = 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]);
2188 Display(sal_True);
2190 /***************************************************************************
2191 Beschreibung: Kommandos des Navigators ausfuehren
2192 ***************************************************************************/
2195 void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier)
2197 sal_Bool nMove = sal_False;
2198 switch( nCmd )
2200 case FN_ITEM_DOWN:
2201 case FN_ITEM_UP: nMove = sal_True;
2202 case FN_ITEM_LEFT:
2203 case FN_ITEM_RIGHT:
2204 if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
2205 (bIsActive ||
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
2226 pShell->Push();
2227 pShell->MakeOutlineSel( nActPos, nActPos,
2228 bModifier);
2229 if( nMove )
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);
2239 else if(bModifier)
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())
2251 break;
2252 pEntry = Next(pEntry);
2253 nActEndPos++;
2255 sal_uInt16 nDest;
2256 if(nDir == 1)
2258 //Wenn der letzte Eintrag bewegt werden soll
2259 //ist Schluss
2260 if(pEntry && CONTENT_TYPE_OUTLINE ==
2261 ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())
2263 // pEntry zeigt jetzt auf den
2264 // dem letzten sel. Eintrag folgenden E.
2265 nDest = nActEndPos;
2266 nDest++;
2267 //hier muss der uebernaechste Eintrag
2268 //gefunden werden. Die Selektion muss davor eingefuegt
2269 //werden
2270 while(pEntry )
2272 pEntry = Next(pEntry);
2273 // nDest++ darf nur ausgefuehrt werden,
2274 // wenn pEntry != 0
2275 if(pEntry && nDest++ &&
2276 ( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
2277 CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
2279 nDest--;
2280 break;
2283 nDir = nDest - nActEndPos;
2284 //wenn kein Eintrag gefunden wurde, der der Bedingung
2285 //fuer das zuvor Einfuegen entspricht, muss etwas weniger
2286 //geschoben werden
2288 else
2289 nDir = 0;
2291 else
2293 nDest = nActPos;
2294 pEntry = pFirstEntry;
2295 while(pEntry && nDest )
2297 nDest--;
2298 pEntry = Prev(pEntry);
2299 if(pEntry &&
2300 (nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
2301 CONTENT_TYPE_OUTLINE !=
2302 ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
2304 break;
2307 nDir = nDest - nActPos;
2309 if(nDir)
2311 pShell->MoveOutlinePara( nDir );
2312 //Cursor wieder an die aktuelle Position setzen
2313 pShell->GotoOutline( nActPos + nDir);
2317 else
2319 if( pShell->IsProtectedOutlinePara() )
2320 Sound::Beep(); //konnte nicht umgestuft werden
2321 else
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();
2330 Display(sal_True);
2331 if(!bIsRoot)
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)
2340 Select(pFirst);
2341 MakeVisible(pFirst);
2346 else
2347 Sound::Beep(); //konnte nicht verschoben werden
2351 /***************************************************************************
2352 Beschreibung:
2353 ***************************************************************************/
2356 void SwContentTree::ShowTree()
2358 aUpdTimer.Start();
2359 SvTreeListBox::Show();
2362 /***************************************************************************
2363 Beschreibung: zusammengefaltet wird nicht geidlet
2364 ***************************************************************************/
2367 void SwContentTree::HideTree()
2369 aUpdTimer.Stop();
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();
2402 Display(sal_True);
2405 else if(!pView && bIsActive && !bIsIdleClear)
2407 if(pActiveShell)
2408 SetActiveShell(0);
2409 Clear();
2410 bIsIdleClear = sal_True;
2412 return 0;
2415 /***************************************************************************
2416 Beschreibung:
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;
2432 sal_Int8 nDragMode;
2433 FillTransferData( rContainer, nDragMode );
2434 bDocChgdInDragging = sal_False;
2435 bIsInternalDrag = sal_True;
2436 return eMode;
2440 /***************************************************************************
2441 Beschreibung : Nach dem Drag wird der aktuelle Absatz m i t
2442 Childs verschoben
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;
2455 else
2456 nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
2457 if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
2458 nTargetPos != USHRT_MAX)
2460 SvLBoxEntry* pNext = Next(pTarget);
2461 if(pNext)
2462 nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1;
2463 else
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,
2471 nTargetPos,
2472 sal_True);
2474 aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2475 Display(sal_True);
2477 //TreeListBox wird aus dem Dokument neu geladen
2478 return sal_False;
2480 /***************************************************************************
2481 Beschreibung : Nach dem Drag wird der aktuelle Absatz o h n e
2482 Childs verschoben
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;
2495 else
2496 nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
2498 if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
2499 nTargetPos != USHRT_MAX)
2501 SvLBoxEntry* pNext = Next(pTarget);
2502 if(pNext)
2503 nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1;
2504 else
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();
2516 Display(sal_True);
2518 return sal_False;
2521 /***************************************************************************
2522 Beschreibung: Kein Drop vor den ersten Eintrag - es ist ein SwContentType
2523 ***************************************************************************/
2525 sal_Bool SwContentTree::NotifyAcceptDrop( SvLBoxEntry* pEntry)
2527 return pEntry != 0;
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 );
2541 else
2542 SvTreeListBox::MouseButtonDown( rMEvt );
2545 /***************************************************************************
2546 Beschreibung: sofort aktualisieren
2547 ***************************************************************************/
2550 void SwContentTree::GetFocus()
2552 SwView* pActView = GetParentWindow()->GetCreateView();
2553 if(pActView)
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())
2566 Display(sal_True);
2569 else if(bIsActive)
2570 Clear();
2571 SvTreeListBox::GetFocus();
2574 /***************************************************************************
2575 Beschreibung:
2576 ***************************************************************************/
2579 void SwContentTree::KeyInput(const KeyEvent& rEvent)
2581 const KeyCode aCode = rEvent.GetKeyCode();
2582 if(aCode.GetCode() == KEY_RETURN)
2584 SvLBoxEntry* pEntry = FirstSelected();
2585 if ( pEntry )
2587 switch(aCode.GetModifier())
2589 case KEY_MOD2:
2590 // Boxen umschalten
2591 GetParentWindow()->ToggleTree();
2592 break;
2593 case KEY_MOD1:
2594 // RootModus umschalten
2595 ToggleToRoot();
2596 break;
2597 case 0:
2598 if(lcl_IsContentType(pEntry))
2600 IsExpanded(pEntry) ?
2601 Collapse(pEntry) :
2602 Expand(pEntry);
2604 else
2605 ContentDoubleClickHdl(0);
2606 break;
2610 else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
2612 SvLBoxEntry* pEntry = FirstSelected();
2613 if(pEntry &&
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);
2622 GrabFocus();
2625 else
2626 SvTreeListBox::KeyInput(rEvent);
2630 /***************************************************************************
2631 Beschreibung:
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 );
2642 if( pEntry )
2644 sal_uInt16 nType;
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();
2650 else
2652 nType = ((SwContent*)pUserData)->GetParent()->GetType();
2653 bContent = sal_True;
2655 String sEntry;
2656 sal_Bool bRet = sal_False;
2657 if(bContent)
2659 switch( nType )
2661 case CONTENT_TYPE_URLFIELD:
2662 sEntry = ((SwURLFieldContent*)pUserData)->GetURL();
2663 bRet = sal_True;
2664 break;
2666 case CONTENT_TYPE_POSTIT:
2667 sEntry = ((SwPostItContent*)pUserData)->GetName();
2668 bRet = sal_True;
2669 if(Help::IsBalloonHelpEnabled())
2670 bBalloon = sal_True;
2671 break;
2672 case CONTENT_TYPE_OUTLINE:
2673 sEntry = ((SwOutlineContent*)pUserData)->GetName();
2674 bRet = sal_True;
2675 break;
2676 case CONTENT_TYPE_GRAPHIC:
2677 sEntry = ((SwGraphicContent*)pUserData)->GetLink();
2678 #if OSL_DEBUG_LEVEL > 1
2679 sEntry += ' ';
2680 sEntry += String::CreateFromInt32(
2681 ((SwGraphicContent*)pUserData)->GetYPos());
2682 #endif
2683 bRet = sal_True;
2684 break;
2685 #if OSL_DEBUG_LEVEL > 1
2686 case CONTENT_TYPE_TABLE:
2687 case CONTENT_TYPE_FRAME:
2688 sEntry = String::CreateFromInt32(
2689 ((SwContent*)pUserData)->GetYPos() );
2690 bRet = sal_True;
2691 break;
2692 #endif
2694 if(((SwContent*)pUserData)->IsInvisible())
2696 if(sEntry.Len())
2697 sEntry += C2S(", ");
2698 sEntry += sInvisible;
2699 bRet = sal_True;
2702 else
2704 sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount();
2705 sEntry = String::CreateFromInt32(nMemberCount);
2706 sEntry += ' ';
2707 sEntry += nMemberCount == 1
2708 ? ((SwContentType*)pUserData)->GetSingleName()
2709 : ((SwContentType*)pUserData)->GetName();
2710 bRet = sal_True;
2712 if(bRet)
2714 SvLBoxTab* pTab;
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 );
2728 if(bBalloon)
2730 aPos.X() += aSize.Width();
2731 Help::ShowBalloon( this, aPos, aItemRect, sEntry );
2733 else
2734 Help::ShowQuickHelp( this, aItemRect, sEntry,
2735 QUICKHELP_LEFT|QUICKHELP_VCENTER );
2736 bCallBase = FALSE;
2739 else
2741 Help::ShowQuickHelp( this, Rectangle(), aEmptyStr, 0 );
2742 bCallBase = FALSE;
2746 if( bCallBase )
2747 Window::RequestHelp( rHEvt );
2750 /***************************************************************************
2751 Beschreibung:
2752 ***************************************************************************/
2755 void SwContentTree::ExcecuteContextMenuAction( USHORT nSelectedPopupEntry )
2757 SvLBoxEntry* pFirst = FirstSelected();
2758 switch( nSelectedPopupEntry )
2760 //Outlinelevel
2761 case 101:
2762 case 102:
2763 case 103:
2764 case 104:
2765 case 105:
2766 case 106:
2767 case 107:
2768 case 108:
2769 case 109:
2770 case 110:
2771 nSelectedPopupEntry -= 100;
2772 if(nOutlineLevel != nSelectedPopupEntry )
2773 SetOutlineLevel((sal_Int8)nSelectedPopupEntry);
2774 break;
2775 case 201:
2776 case 202:
2777 case 203:
2778 GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201);
2779 break;
2780 case 401:
2781 case 402:
2782 EditEntry(pFirst, nSelectedPopupEntry == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX);
2783 break;
2784 // Eintrag bearbeiten
2785 case 403:
2786 EditEntry(pFirst, EDIT_MODE_EDIT);
2787 break;
2788 case 404:
2789 EditEntry(pFirst, EDIT_UNPROTECT_TABLE);
2790 break;
2791 case 405 :
2793 const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData())
2794 ->GetTOXBase();
2795 pActiveShell->SetTOXBaseReadonly(*pBase, !pActiveShell->IsTOXBaseReadonly(*pBase));
2797 break;
2798 case 4:
2799 break;
2800 case 501:
2801 EditEntry(pFirst, EDIT_MODE_DELETE);
2802 break;
2803 case 502 :
2804 EditEntry(pFirst, EDIT_MODE_RENAME);
2805 break;
2806 case 600:
2807 pActiveShell->GetView().GetPostItMgr()->Show();
2808 break;
2809 case 601:
2810 pActiveShell->GetView().GetPostItMgr()->Hide();
2811 break;
2812 case 602:
2814 pActiveShell->GetView().GetPostItMgr()->SetActivePostIt(0);
2815 pActiveShell->GetView().GetPostItMgr()->Delete();
2816 break;
2818 //Anzeige
2819 default: // nSelectedPopupEntry > 300
2820 if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
2822 nSelectedPopupEntry -= 300;
2823 SwView *pView = SwModule::GetFirstView();
2824 while (pView)
2826 nSelectedPopupEntry --;
2827 if(nSelectedPopupEntry == 0)
2829 SetConstantShell(&pView->GetWrtShell());
2830 break;
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 /***************************************************************************
2846 Beschreibung:
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];
2857 if(*ppContentT)
2859 (*ppContentT)->SetOutlineLevel(nOutlineLevel);
2860 (*ppContentT)->Init();
2862 Display(bIsActive);
2865 /***************************************************************************
2866 Beschreibung: Moduswechsel: gedropptes Doc anzeigen
2867 ***************************************************************************/
2870 void SwContentTree::ShowHiddenShell()
2872 if(pHiddenShell)
2874 bIsConstant = sal_False;
2875 bIsActive = sal_False;
2876 Display(sal_False);
2880 /***************************************************************************
2881 Beschreibung: Moduswechsel: aktive Sicht anzeigen
2882 ***************************************************************************/
2885 void SwContentTree::ShowActualView()
2887 bIsActive = sal_True;
2888 bIsConstant = sal_False;
2889 Display(sal_True);
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 )
2900 if(!pEntry)
2901 return sal_False;
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)))
2911 bEnable = sal_True;
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)
2927 nRootType = nType;
2928 bIsRoot = sal_True;
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 )
2942 *pStr = 0x20;
2946 /*-----------------14.01.97 16.38-------------------
2948 --------------------------------------------------*/
2950 void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode)
2952 SwContent* pCnt = (SwContent*)pEntry->GetUserData();
2953 GotoContent(pCnt);
2954 sal_uInt16 nType = pCnt->GetParent()->GetType();
2955 sal_uInt16 nSlot = 0;
2957 uno::Reference< container::XNameAccess > xNameAccess, xSecond, xThird;
2958 switch(nType)
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();
2990 else
2991 nSlot = FN_FORMAT_TABLE_DLG;
2992 break;
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();
3009 else
3010 nSlot = FN_FORMAT_GRAFIC_DLG;
3011 break;
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();
3029 else
3031 xNameAccess = xObjs->getEmbeddedObjects();
3032 xSecond = xFrms->getTextFrames();
3034 uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY);
3035 xThird = xGraphics->getGraphicObjects();
3037 else
3038 nSlot = FN_FORMAT_FRAME_DLG;
3039 break;
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();
3052 else
3053 nSlot = FN_INSERT_BOOKMARK;
3054 break;
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();
3063 else
3064 nSlot = FN_EDIT_REGION;
3065 break;
3067 case CONTENT_TYPE_URLFIELD:
3068 nSlot = FN_EDIT_HYPERLINK;
3069 break;
3070 case CONTENT_TYPE_REFERENCE:
3071 nSlot = FN_EDIT_FIELD;
3072 break;
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
3085 else
3087 SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline());
3088 if (pComment)
3089 pComment->Delete();
3093 else
3095 if (((SwPostItContent*)pCnt)->IsPostIt())
3096 nSlot = FN_POSTIT;
3097 else
3098 nSlot = FN_REDLINE_COMMENT;
3100 break;
3101 case CONTENT_TYPE_INDEX:
3103 const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase();
3104 switch(nMode)
3106 case EDIT_MODE_EDIT:
3107 if(pBase)
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);
3115 break;
3116 case EDIT_MODE_RMV_IDX:
3117 case EDIT_MODE_DELETE:
3119 if( pBase )
3120 pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode);
3122 break;
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;
3136 if(aIdx >>= xIdx)
3137 xIdx->update();
3140 break;
3143 break;
3144 case CONTENT_TYPE_DRAWOBJECT :
3145 if(EDIT_MODE_DELETE == nMode)
3146 nSlot = SID_DELETE;
3147 break;
3149 if(nSlot)
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;
3156 aObj >>= 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!");
3163 if(xSecond.is())
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);
3176 pDlg->Execute();
3177 delete pDlg;
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();
3191 switch(nJumpType)
3193 case CONTENT_TYPE_OUTLINE :
3195 pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos());
3197 break;
3198 case CONTENT_TYPE_TABLE :
3200 pActiveShell->GotoTable(pCnt->GetName());
3202 break;
3203 case CONTENT_TYPE_FRAME :
3204 case CONTENT_TYPE_GRAPHIC :
3205 case CONTENT_TYPE_OLE :
3207 if(pActiveShell->GotoFly(pCnt->GetName()))
3208 bSel = sal_True;
3210 break;
3211 case CONTENT_TYPE_BOOKMARK:
3213 pActiveShell->GotoMark(pCnt->GetName());
3215 break;
3216 case CONTENT_TYPE_REGION :
3218 pActiveShell->GotoRegion(pCnt->GetName());
3220 break;
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 );
3231 break;
3232 case CONTENT_TYPE_REFERENCE:
3234 pActiveShell->GotoRefMark(pCnt->GetName());
3236 break;
3237 case CONTENT_TYPE_INDEX:
3239 if (!pActiveShell->GotoNextTOXBase(&pCnt->GetName()))
3240 pActiveShell->GotoPrevTOXBase(&pCnt->GetName());
3242 break;
3243 case CONTENT_TYPE_POSTIT:
3244 pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
3245 if (((SwPostItContent*)pCnt)->IsPostIt())
3246 pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt());
3247 else
3248 pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline(
3249 pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData()));
3251 break;
3252 case CONTENT_TYPE_DRAWOBJECT:
3254 SdrView* pDrawView = pActiveShell->GetDrawView();
3255 if (pDrawView)
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() )
3268 // <--
3270 SdrPageView* pPV = pDrawView->GetSdrPageView();
3271 if( pPV )
3273 pDrawView->MarkObj( pTemp, pPV );
3279 break;
3281 if(bSel)
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()
3297 nDocSh(0),
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 ) :
3310 aUrl( rUrl ),
3311 aDescr(rDesc),
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 )
3333 String sStr;
3334 sal_Bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr );
3335 if( bRet )
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();
3343 return bRet;
3347 /* -----------------------------09.12.99 13:50--------------------------------
3349 ---------------------------------------------------------------------------*/
3350 class SwContentLBoxString : public SvLBoxString
3352 public:
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 );
3391 else
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();
3405 Display(sal_True);
3407 SvTreeListBox::DataChanged( rDCEvt );