xref: /aoo42x/main/sw/source/ui/utlui/content.cxx (revision 149befa7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #ifndef _SVSTDARR_HXX
28 #define _SVSTDARR_STRINGSDTOR
29 #include <svl/svstdarr.hxx>
30 #endif
31 #include <svl/urlbmk.hxx>
32 #include <tools/urlobj.hxx>
33 #include <sfx2/docfile.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <vcl/help.hxx>
36 #include <sot/formats.hxx>
37 #include <vcl/sound.hxx>
38 #include <uiitems.hxx>
39 #include <fmtinfmt.hxx>
40 #include <txtinet.hxx>
41 #include <fmtfld.hxx>
42 #include <swmodule.hxx>
43 #include <wrtsh.hxx>
44 #include <view.hxx>
45 #include <errhdl.hxx>
46 #include <docsh.hxx>
47 #include <content.hxx>
48 #include <frmfmt.hxx>
49 #include <fldbas.hxx>
50 #include <txtatr.hxx>
51 #include <IMark.hxx>
52 #include <section.hxx>
53 #include <tox.hxx>
54 #define NAVIPI_CXX
55 #include <navipi.hxx>
56 #include <navicont.hxx>
57 #include <navicfg.hxx>
58 #include <edtwin.hxx>
59 #include <doc.hxx>
60 #include <unotools.hxx>
61 #include <crsskip.hxx>
62 #include <cmdid.h>
63 #include <helpid.h>
64 #include <navipi.hrc>
65 #include <utlui.hrc>
66 #include <misc.hrc>
67 #include <comcore.hrc>
68 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
69 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
70 #include <com/sun/star/text/XTextTablesSupplier.hpp>
71 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
72 #include <com/sun/star/text/XDocumentIndex.hpp>
73 #include <com/sun/star/text/XBookmarksSupplier.hpp>
74 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
75 #include <com/sun/star/text/XTextFramesSupplier.hpp>
76 #include <dcontact.hxx>
77 #include <svx/svdogrp.hxx>
78 #include <svx/svdmodel.hxx>
79 #include <svx/svdpage.hxx>
80 #include <svx/svdview.hxx>
81 #include <vcl/scrbar.hxx>
82 #include <comcore.hrc>
83 #include <SwRewriter.hxx>
84 #include <hints.hxx>
85 #include <numrule.hxx>
86 #include <swundo.hxx>
87 #include <ndtxt.hxx>
88 #include <fmtcntnt.hxx>
89 #include <PostItMgr.hxx>
90 #include <postithelper.hxx>
91 #include <redline.hxx>
92 #include <docary.hxx>
93 #include "swabstdlg.hxx"
94 #include "globals.hrc"
95 #include <unomid.h>
96 #include <drawdoc.hxx>
97 
98 #define CTYPE_CNT	0
99 #define CTYPE_CTT	1
100 
101 using namespace ::std;
102 using namespace ::com::sun::star;
103 using namespace ::com::sun::star::text;
104 using namespace ::com::sun::star::uno;
105 using namespace ::com::sun::star::container;
106 
107 
108 #define NAVI_BOOKMARK_DELIM		(sal_Unicode)1
109 
110 /***************************************************************************
111 
112 ***************************************************************************/
113 
114 typedef SwContent* SwContentPtr;
115 SV_DECL_PTRARR_SORT_DEL( SwContentArr, SwContentPtr, 0,4)
116 SV_IMPL_OP_PTRARR_SORT(SwContentArr, SwContentPtr)
117 
118 sal_Bool SwContentTree::bIsInDrag = sal_False;
119 
120 
121 namespace
122 {
lcl_IsContent(SvLBoxEntry * pEntry)123     static sal_Bool lcl_IsContent(SvLBoxEntry* pEntry)
124     {
125         return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT;
126     }
127 
128 
lcl_IsContentType(SvLBoxEntry * pEntry)129     static sal_Bool lcl_IsContentType(SvLBoxEntry* pEntry)
130     {
131         return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT;
132     }
133 
134 
lcl_FindShell(SwWrtShell * pShell)135     static sal_Bool lcl_FindShell(SwWrtShell* pShell)
136     {
137         sal_Bool bFound = sal_False;
138         SwView *pView = SwModule::GetFirstView();
139         while (pView)
140         {
141             if(pShell == &pView->GetWrtShell())
142             {
143                 bFound = sal_True;
144                 break;
145             }
146             pView = SwModule::GetNextView(pView);
147         }
148         return bFound;
149     }
150 
lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t & rpMark)151     static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark)
152     {
153         return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::BOOKMARK;
154     }
155 }
156 
157 /***************************************************************************
158 	Beschreibung: Inhalt, enthaelt Namen und Verweis auf den Inhaltstyp
159 ***************************************************************************/
160 
161 
SwContent(const SwContentType * pCnt,const String & rName,long nYPos)162 SwContent::SwContent(const SwContentType* pCnt, const String& rName, long nYPos) :
163 	SwTypeNumber(CTYPE_CNT),
164 	pParent(pCnt),
165 	sContentName(rName),
166 	nYPosition(nYPos),
167 	bInvisible(sal_False)
168 {
169 }
170 
171 
GetTypeId()172 sal_uInt8	SwTypeNumber::GetTypeId()
173 {
174 	return nTypeId;
175 }
176 
~SwTypeNumber()177 SwTypeNumber::~SwTypeNumber()
178 {
179 }
180 
IsProtect() const181 sal_Bool SwContent::IsProtect() const
182 {
183 	return sal_False;
184 }
185 
IsProtect() const186 sal_Bool SwPostItContent::IsProtect() const
187 {
188 	if (mbPostIt)
189 		return pFld->IsProtect();
190 	else
191 		return false;
192 }
193 
IsProtect() const194 sal_Bool SwURLFieldContent::IsProtect() const
195 {
196 	return pINetAttr->IsProtect();
197 }
198 
~SwGraphicContent()199 SwGraphicContent::~SwGraphicContent()
200 {
201 }
~SwTOXBaseContent()202 SwTOXBaseContent::~SwTOXBaseContent()
203 {
204 }
205 
206 /***************************************************************************
207 	Beschreibung: 	Inhaltstyp, kennt seine Inhalte und die WrtShell
208 ***************************************************************************/
209 
210 
SwContentType(SwWrtShell * pShell,sal_uInt16 nType,sal_uInt8 nLevel)211 SwContentType::SwContentType(SwWrtShell* pShell, sal_uInt16 nType, sal_uInt8 nLevel) :
212 	SwTypeNumber(CTYPE_CTT),
213 	pWrtShell(pShell),
214 	pMember(0),
215 	sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)),
216 	sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)),
217 	nMemberCount(0),
218 	nContentType(nType),
219 	nOutlineLevel(nLevel),
220 	bMemberFilled(sal_False),
221 	bDataValid(sal_False),
222 	bEdit(sal_False),
223 	bDelete(sal_True)
224 {
225 	Init();
226 }
227 
228 /***************************************************************************
229 	Beschreibung: 	Initialisierung
230 ***************************************************************************/
231 
232 
Init(sal_Bool * pbInvalidateWindow)233 void SwContentType::Init(sal_Bool* pbInvalidateWindow)
234 {
235 	// wenn sich der MemberCount aendert ...
236 	sal_uInt16 nOldMemberCount = nMemberCount;
237 	nMemberCount = 0;
238 	switch(nContentType)
239 	{
240 		case CONTENT_TYPE_OUTLINE	:
241 		{
242 			sTypeToken = C2S(pMarkToOutline);
243             sal_uInt16 nOutlineCount = nMemberCount =
244                 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
245 			if(nOutlineLevel < MAXLEVEL)
246 			{
247 				for(sal_uInt16 j = 0; j < nOutlineCount; j++)
248 				{
249                     if(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(j) > nOutlineLevel )
250 						nMemberCount --;
251 				}
252 			}
253 			bDelete = sal_False;
254 		}
255 		break;
256 
257 		case CONTENT_TYPE_TABLE 	:
258 			sTypeToken = C2S(pMarkToTable);
259 			nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True);
260 			bEdit = sal_True;
261 		break;
262 
263 		case CONTENT_TYPE_FRAME     :
264 		case CONTENT_TYPE_GRAPHIC   :
265 		case CONTENT_TYPE_OLE       :
266 		{
267 			FlyCntType eType = FLYCNTTYPE_FRM;
268 			sTypeToken = C2S(pMarkToFrame);
269 			if(nContentType == CONTENT_TYPE_OLE)
270 			{
271 				eType = FLYCNTTYPE_OLE;
272 				sTypeToken = C2S(pMarkToOLE);
273 			}
274 			else if(nContentType == CONTENT_TYPE_GRAPHIC)
275 			{
276 				eType = FLYCNTTYPE_GRF;
277 				sTypeToken = C2S(pMarkToGraphic);
278 			}
279 			nMemberCount = pWrtShell->GetFlyCount(eType);
280 			bEdit = sal_True;
281 		}
282 		break;
283         case CONTENT_TYPE_BOOKMARK:
284         {
285             IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
286             nMemberCount = static_cast<sal_uInt16>(count_if(
287                 pMarkAccess->getBookmarksBegin(),
288                 pMarkAccess->getBookmarksEnd(),
289                 &lcl_IsUiVisibleBookmark));
290             sTypeToken = aEmptyStr;
291             bEdit = sal_True;
292         }
293         break;
294 		case CONTENT_TYPE_REGION :
295 		{
296 			SwContentArr* 	pOldMember = 0;
297 			sal_uInt16 nOldRegionCount = 0;
298 			sal_Bool bInvalidate = sal_False;
299 			if(!pMember)
300 				pMember = new SwContentArr;
301 			else if(pMember->Count())
302 			{
303 				pOldMember = pMember;
304 				nOldRegionCount = pOldMember->Count();
305 				pMember = new SwContentArr;
306 			}
307 			const Point aNullPt;
308 			nMemberCount = pWrtShell->GetSectionFmtCount();
309 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
310 			{
311 				const SwSectionFmt* pFmt;
312 				SectionType eTmpType;
313 				if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
314 				(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
315 				&& TOX_HEADER_SECTION != eTmpType )
316 				{
317                     const String& rSectionName =
318                         pFmt->GetSection()->GetSectionName();
319                     sal_uInt8 nLevel = 0;
320 					SwSectionFmt* pParentFmt = pFmt->GetParent();
321 					while(pParentFmt)
322 					{
323 						nLevel++;
324 						pParentFmt = pParentFmt->GetParent();
325 					}
326 
327 					SwContent* pCnt = new SwRegionContent(this, rSectionName,
328 							nLevel,
329 							pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
330 
331 					SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
332 					if( !pFmt->GetInfo( aAskItem ) &&
333 						!aAskItem.pObject )		// not visible
334 						pCnt->SetInvisible();
335 					pMember->Insert(pCnt);//, pMember->Count());
336 
337 					sal_uInt16 nPos = pMember->Count() - 1;
338 					if(nOldRegionCount > nPos &&
339 						(pOldMember->GetObject(nPos))->IsInvisible()
340 								!= pCnt->IsInvisible())
341 							bInvalidate = sal_True;
342 				}
343 			}
344 			nMemberCount = pMember->Count();
345 			sTypeToken = C2S(pMarkToRegion);
346 			bEdit = sal_True;
347 			bDelete = sal_False;
348 			if(pOldMember)
349 			{
350 				pOldMember->DeleteAndDestroy(0, pOldMember->Count());
351 				delete pOldMember;
352 				if(pbInvalidateWindow && bInvalidate)
353 					*pbInvalidateWindow = sal_True;
354 			}
355 		}
356 		break;
357 		case CONTENT_TYPE_INDEX:
358 		{
359 			nMemberCount = pWrtShell->GetTOXCount();
360 			bEdit = sal_True;
361 			bDelete = sal_False;
362 		}
363 		break;
364 		case CONTENT_TYPE_REFERENCE:
365 		{
366 			nMemberCount = pWrtShell->GetRefMarks( 0 );
367 			bDelete = sal_False;
368 		}
369 		break;
370 		case CONTENT_TYPE_URLFIELD:
371 		{
372 			nMemberCount = 0;
373 			if(!pMember)
374 				pMember = new SwContentArr;
375 			else if(pMember->Count())
376 				pMember->DeleteAndDestroy(0, pMember->Count());
377 
378 			SwGetINetAttrs aArr;
379 			nMemberCount = pWrtShell->GetINetAttrs( aArr );
380 			for( sal_uInt16 n = 0; n < nMemberCount; ++n )
381 			{
382 				SwGetINetAttr* p = aArr[ n ];
383 				SwURLFieldContent* pCnt = new SwURLFieldContent(
384 									this,
385 									p->sText,
386 									INetURLObject::decode(
387 										p->rINetAttr.GetINetFmt().GetValue(),
388 										INET_HEX_ESCAPE,
389 										INetURLObject::DECODE_UNAMBIGUOUS,
390 										RTL_TEXTENCODING_UTF8 ),
391 									&p->rINetAttr,
392 									n );
393 				pMember->Insert( pCnt );//, n );
394 			}
395 			bEdit = sal_True;
396 			nOldMemberCount = nMemberCount;
397 			bDelete = sal_False;
398 		}
399 		break;
400 		case CONTENT_TYPE_POSTIT:
401 		{
402 			nMemberCount = 0;
403 			if(!pMember)
404 				pMember = new SwContentArr;
405 			else if(pMember->Count())
406 				pMember->DeleteAndDestroy(0, pMember->Count());
407 
408 			SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
409 			if (aMgr)
410 			{
411 				for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
412 				{
413 					if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit
414 					{
415 						const SwFmtFld* aFmtFld = static_cast<const SwFmtFld*>((*i)->GetBroadCaster());
416 						if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
417 							(*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
418 						{
419 							String sEntry = aFmtFld->GetField()->GetPar2();
420 							RemoveNewline(sEntry);
421 							SwPostItContent* pCnt = new SwPostItContent(
422 												this,
423 												sEntry,
424 												aFmtFld,
425 												nMemberCount);
426 							pMember->Insert(pCnt);
427 							nMemberCount++;
428 						}
429 					}
430 				}
431 			}
432 			//
433 			sTypeToken = aEmptyStr;
434 			bEdit = sal_True;
435 			nOldMemberCount = nMemberCount;
436 		}
437 		break;
438 		case CONTENT_TYPE_DRAWOBJECT:
439         {
440             sTypeToken = aEmptyStr;
441             nMemberCount = 0;
442             SwDrawModel* pModel = pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel();
443             if(pModel)
444             {
445                 SdrPage* pPage = pModel->GetPage(0);
446                 sal_uInt32 nCount = pPage->GetObjCount();
447                 for( sal_uInt32 i=0; i< nCount; i++ )
448                 {
449                     SdrObject* pTemp = pPage->GetObj(i);
450                     // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
451 //                    if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len())
452                     if ( pTemp->GetName().Len() )
453                     // <--
454                         nMemberCount++;
455                 }
456             }
457         }
458 		break;
459 	}
460 	// ... dann koennen die Daten auch nicht mehr gueltig sein
461 	// abgesehen von denen, die schon korrigiert wurden, dann ist
462 	// nOldMemberCount doch nicht so old
463 	if(	nOldMemberCount != nMemberCount )
464 		bDataValid = sal_False;
465 }
466 
467 /***************************************************************************
468 	Beschreibung:
469 ***************************************************************************/
470 
471 
~SwContentType()472 SwContentType::~SwContentType()
473 {
474 	delete pMember;
475 }
476 
477 /***************************************************************************
478 	Beschreibung:	 Inhalt liefern, dazu ggf. die Liste fuellen
479 ***************************************************************************/
480 
481 
GetMember(sal_uInt16 nIndex)482 const SwContent* SwContentType::GetMember(sal_uInt16 nIndex)
483 {
484 	if(!bDataValid || !pMember)
485 	{
486 		FillMemberList();
487 	}
488 	if(nIndex < pMember->Count())
489 		return pMember->GetObject(nIndex);
490 	else
491 		return 0;
492 
493 }
494 
495 
496 /***************************************************************************
497 	Beschreibung:
498 ***************************************************************************/
499 
500 
Invalidate()501 void	SwContentType::Invalidate()
502 {
503 	bDataValid = sal_False;
504 }
505 
506 /***************************************************************************
507 	Beschreibung: Liste der Inhalte fuellen
508 ***************************************************************************/
509 
510 
FillMemberList(sal_Bool * pbLevelOrVisibiblityChanged)511 void	SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibiblityChanged)
512 {
513 	SwContentArr* 	pOldMember = 0;
514 	int nOldMemberCount = -1;
515 	SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
516 	if(pMember && pbLevelOrVisibiblityChanged)
517 	{
518 		pOldMember = pMember;
519 		nOldMemberCount = pOldMember->Count();
520 		pMember = new SwContentArr;
521 		*pbLevelOrVisibiblityChanged = sal_False;
522 	}
523 	else if(!pMember)
524 		pMember = new SwContentArr;
525 	else if(pMember->Count())
526 		pMember->DeleteAndDestroy(0, pMember->Count());
527 	switch(nContentType)
528 	{
529 		case CONTENT_TYPE_OUTLINE	:
530 		{
531             sal_uInt16 nOutlineCount = nMemberCount =
532                 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
533 
534 			sal_uInt16 nPos = 0;
535 			for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
536 			{
537                 const sal_Int8 nLevel = (sal_Int8)pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i);
538 				if(nLevel >= nOutlineLevel )
539 					nMemberCount--;
540 				else
541 				{
542                     String aEntry(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i));
543 					aEntry.EraseLeadingChars();
544 					SwNavigationPI::CleanEntry( aEntry );
545 					SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel,
546 														pWrtShell->IsOutlineMovable( i ), nPos );
547 					pMember->Insert(pCnt);//, nPos);
548 					// bei gleicher Anzahl und vorhandenem pOldMember wird die
549 					// alte mit der neuen OutlinePos verglichen
550 					// cast fuer Win16
551 					if(nOldMemberCount > (int)nPos &&
552 						((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel)
553 						*pbLevelOrVisibiblityChanged = sal_True;
554 
555 					nPos++;
556 				}
557 			}
558 
559 		}
560 		break;
561 
562 		case CONTENT_TYPE_TABLE 	:
563 		{
564 			DBG_ASSERT(nMemberCount ==
565 					pWrtShell->GetTblFrmFmtCount(sal_True),
566 					"MemberCount differiert");
567 			Point aNullPt;
568 			nMemberCount =	pWrtShell->GetTblFrmFmtCount(sal_True);
569 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
570 			{
571 				const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, sal_True);
572 				String sTblName( rTblFmt.GetName() );
573 
574 				SwContent* pCnt = new SwContent(this, sTblName,
575 						rTblFmt.FindLayoutRect(sal_False, &aNullPt).Top() );
576 				if( !rTblFmt.GetInfo( aAskItem ) &&
577 					!aAskItem.pObject )		// not visible
578 					pCnt->SetInvisible();
579 
580 				pMember->Insert(pCnt);//, i);
581 
582 				if(nOldMemberCount > (int)i &&
583 					(pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
584 						*pbLevelOrVisibiblityChanged = sal_True;
585 			}
586 		}
587 		break;
588 		case CONTENT_TYPE_OLE       :
589 		case CONTENT_TYPE_FRAME     :
590 		case CONTENT_TYPE_GRAPHIC   :
591 		{
592 			FlyCntType eType = FLYCNTTYPE_FRM;
593 			if(nContentType == CONTENT_TYPE_OLE)
594 				eType = FLYCNTTYPE_OLE;
595 			else if(nContentType == CONTENT_TYPE_GRAPHIC)
596 				eType = FLYCNTTYPE_GRF;
597 			DBG_ASSERT(nMemberCount == 	pWrtShell->GetFlyCount(eType),
598 					"MemberCount differiert");
599 			Point aNullPt;
600 			nMemberCount = pWrtShell->GetFlyCount(eType);
601 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
602 			{
603 				const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType);
604 				String sFrmName = pFrmFmt->GetName();
605 
606 				SwContent* pCnt;
607 				if(CONTENT_TYPE_GRAPHIC == nContentType)
608 				{
609 					String sLink;
610 					pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt);
611 					pCnt = new SwGraphicContent(this, sFrmName,
612 								INetURLObject::decode( sLink, INET_HEX_ESCAPE,
613 										INetURLObject::DECODE_UNAMBIGUOUS,
614 										RTL_TEXTENCODING_UTF8 ),
615 								pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top());
616 				}
617 				else
618 				{
619 					pCnt = new SwContent(this, sFrmName,
620 							pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top() );
621 				}
622 				if( !pFrmFmt->GetInfo( aAskItem ) &&
623 					!aAskItem.pObject )		// not visible
624 					pCnt->SetInvisible();
625 				pMember->Insert(pCnt);//, i);
626 				if(nOldMemberCount > (int)i &&
627 					(pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
628 						*pbLevelOrVisibiblityChanged = sal_True;
629 			}
630 		}
631 		break;
632         case CONTENT_TYPE_BOOKMARK:
633         {
634             IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
635             for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin();
636                 ppBookmark != pMarkAccess->getBookmarksEnd();
637                 ppBookmark++)
638             {
639                 if(lcl_IsUiVisibleBookmark(*ppBookmark))
640                 {
641                     const String& rBkmName = ppBookmark->get()->GetName();
642                     //nYPos von 0 -> text::Bookmarks werden nach Alphabet sortiert
643                     SwContent* pCnt = new SwContent(this, rBkmName, 0);
644                     pMember->Insert(pCnt);//, pMember->Count());
645                 }
646             }
647         }
648 		break;
649 		case CONTENT_TYPE_REGION    :
650 		{
651 			const Point aNullPt;
652 			nMemberCount = pWrtShell->GetSectionFmtCount();
653 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
654 			{
655 				const SwSectionFmt* pFmt;
656 				SectionType eTmpType;
657 				if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
658 				(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
659 				&& TOX_HEADER_SECTION != eTmpType )
660 				{
661                     String sSectionName = pFmt->GetSection()->GetSectionName();
662 
663                     sal_uInt8 nLevel = 0;
664 					SwSectionFmt* pParentFmt = pFmt->GetParent();
665 					while(pParentFmt)
666 					{
667 						nLevel++;
668 						pParentFmt = pParentFmt->GetParent();
669 					}
670 
671 					SwContent* pCnt = new SwRegionContent(this, sSectionName,
672 							nLevel,
673 							pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
674 					if( !pFmt->GetInfo( aAskItem ) &&
675 						!aAskItem.pObject )		// not visible
676 						pCnt->SetInvisible();
677 					pMember->Insert(pCnt);//, pMember->Count());
678 
679 					sal_uInt16 nPos = pMember->Count() - 1;
680 					if(nOldMemberCount > nPos &&
681 						(pOldMember->GetObject(nPos))->IsInvisible()
682 								!= pCnt->IsInvisible())
683 							*pbLevelOrVisibiblityChanged = sal_True;
684 				}
685 			}
686 			nMemberCount = pMember->Count();
687 		}
688 		break;
689 		case CONTENT_TYPE_REFERENCE:
690 		{
691 			SvStringsDtor aRefMarks;
692 			nMemberCount = pWrtShell->GetRefMarks( &aRefMarks );
693 
694 			for(sal_uInt16 i=0; i<nMemberCount; i++)
695 			{
696 				//Referenzen nach Alphabet sortiert
697 				SwContent* pCnt = new SwContent(
698 							this, *aRefMarks.GetObject(i), 0);
699 				pMember->Insert(pCnt);//, i);
700 			}
701 		}
702 		break;
703 		case CONTENT_TYPE_URLFIELD:
704 		{
705 			SwGetINetAttrs aArr;
706 			nMemberCount = pWrtShell->GetINetAttrs( aArr );
707 			for( sal_uInt16 n = 0; n < nMemberCount; ++n )
708 			{
709 				SwGetINetAttr* p = aArr[ n ];
710 				SwURLFieldContent* pCnt = new SwURLFieldContent(
711 									this,
712 									p->sText,
713 									INetURLObject::decode(
714 										p->rINetAttr.GetINetFmt().GetValue(),
715 										INET_HEX_ESCAPE,
716 										INetURLObject::DECODE_UNAMBIGUOUS,
717 										RTL_TEXTENCODING_UTF8 ),
718 									&p->rINetAttr,
719 									n );
720 				pMember->Insert( pCnt );//, n );
721 			}
722 		}
723 		break;
724 		case CONTENT_TYPE_INDEX:
725 		{
726 
727 			sal_uInt16 nCount = nMemberCount = pWrtShell->GetTOXCount();
728 			for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ )
729 			{
730 				const SwTOXBase* pBase = pWrtShell->GetTOX( nTox );
731 				String sTOXNm( pBase->GetTOXName() );
732 
733 				SwContent* pCnt = new SwTOXBaseContent(
734 						this, sTOXNm, nTox, *pBase);
735 
736 				if( !pBase->GetInfo( aAskItem ) &&
737 					!aAskItem.pObject )		// not visible
738 					pCnt->SetInvisible();
739 
740 				pMember->Insert( pCnt );//, nTox );
741 				sal_uInt16 nPos = pMember->Count() - 1;
742 				if(nOldMemberCount > nPos &&
743 					(pOldMember->GetObject(nPos))->IsInvisible()
744 							!= pCnt->IsInvisible())
745 						*pbLevelOrVisibiblityChanged = sal_True;
746 			}
747 		}
748 		break;
749 		case CONTENT_TYPE_POSTIT:
750 		{
751 			nMemberCount = 0;
752 			if(!pMember)
753 				pMember = new SwContentArr;
754 			else if(pMember->Count())
755 				pMember->DeleteAndDestroy(0, pMember->Count());
756 			SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
757 			if (aMgr)
758 			{
759 				for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
760 				{
761 					if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit
762 					{
763 						const SwFmtFld* aFmtFld = static_cast<const SwFmtFld*>((*i)->GetBroadCaster());
764 						if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
765 							(*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
766 						{
767 							String sEntry = aFmtFld->GetField()->GetPar2();
768 							RemoveNewline(sEntry);
769 							SwPostItContent* pCnt = new SwPostItContent(
770 												this,
771 												sEntry,
772 												aFmtFld,
773 												nMemberCount);
774 							pMember->Insert(pCnt);
775 							nMemberCount++;
776 						}
777 					}
778 					/*	this code can be used once we want redline comments in the margin
779 					else	// redcomment
780 					{
781 						SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster());
782 						if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) )
783 						{
784 							String sEntry = pRedline->GetComment();
785 							RemoveNewline(sEntry);
786 							SwPostItContent* pCnt = new SwPostItContent(
787 												this,
788 												sEntry,
789 												pRedline,
790 												nMemberCount);
791 							pMember->Insert(pCnt);
792 							nMemberCount++;
793 						}
794 					}
795 					*/
796 				}
797 			}
798 			//
799 		}
800 		break;
801 		case CONTENT_TYPE_DRAWOBJECT:
802         {
803             nMemberCount = 0;
804 			if(!pMember)
805 				pMember = new SwContentArr;
806 			else if(pMember->Count())
807 				pMember->DeleteAndDestroy(0, pMember->Count());
808 
809             IDocumentDrawModelAccess* pIDDMA = pWrtShell->getIDocumentDrawModelAccess();
810             SwDrawModel* pModel = pIDDMA->GetDrawModel();
811             if(pModel)
812             {
813                 SdrPage* pPage = pModel->GetPage(0);
814                 sal_uInt32 nCount = pPage->GetObjCount();
815                 for( sal_uInt32 i=0; i< nCount; i++ )
816                 {
817                     SdrObject* pTemp = pPage->GetObj(i);
818                     // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
819 //                    if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len())
820                     if ( pTemp->GetName().Len() )
821                     // <--
822                     {
823                         SwContact* pContact = (SwContact*)pTemp->GetUserCall();
824                         long nYPos = 0;
825                         const Point aNullPt;
826                         if(pContact && pContact->GetFmt())
827                             nYPos = pContact->GetFmt()->FindLayoutRect(sal_False, &aNullPt).Top();
828                         SwContent* pCnt = new SwContent(
829                                             this,
830                                             pTemp->GetName(),
831                                             nYPos);
832                         if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer()))
833                             pCnt->SetInvisible();
834                         pMember->Insert(pCnt);
835                         nMemberCount++;
836                         if(nOldMemberCount > (int)i &&
837                             (pOldMember->GetObject((sal_uInt16)i))->IsInvisible() != pCnt->IsInvisible())
838                                 *pbLevelOrVisibiblityChanged = sal_True;
839                     }
840                 }
841             }
842         }
843         break;
844 	}
845 	bDataValid = sal_True;
846 	if(pOldMember)
847 		pOldMember->DeleteAndDestroy(0, pOldMember->Count());
848 
849 }
850 
851 /***************************************************************************
852 	Beschreibung: TreeListBox fuer Inhaltsanzeige
853 ***************************************************************************/
854 
855 
SwContentTree(Window * pParent,const ResId & rResId)856 SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) :
857 		SvTreeListBox( pParent, rResId ),
858 
859         sSpace(C2S("                    ")),
860 
861         sRemoveIdx(SW_RES(ST_REMOVE_INDEX)),
862         sUpdateIdx(SW_RES(ST_UPDATE)),
863         sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION)),
864         sRename(SW_RES(ST_RENAME)),
865         sReadonlyIdx(SW_RES(ST_READONLY_IDX)),
866         sInvisible(SW_RES(ST_INVISIBLE)),
867 
868 	sPostItShow(SW_RES(ST_POSTIT_SHOW)),
869 	sPostItHide(SW_RES(ST_POSTIT_HIDE)),
870 	sPostItDelete(SW_RES(ST_POSTIT_DELETE)),
871 
872         pHiddenShell(0),
873 	pActiveShell(0),
874 	pConfig(SW_MOD()->GetNavigationConfig()),
875 
876         nActiveBlock(0),
877 	nHiddenBlock(0),
878 
879         nRootType(USHRT_MAX),
880         nLastSelType(USHRT_MAX),
881         nOutlineLevel(MAXLEVEL),
882 
883         bIsActive(sal_True),
884 		bIsConstant(sal_False),
885 		bIsHidden(sal_False),
886         bDocChgdInDragging(sal_False),
887 		bIsInternalDrag(sal_False),
888 		bIsRoot(sal_False),
889 		bIsIdleClear(sal_False),
890 		bIsLastReadOnly(sal_False),
891 		bIsOutlineMoveable(sal_True),
892 		bViewHasChanged(sal_False),
893 		bIsImageListInitialized(sal_False),
894 		bIsKeySpace(sal_False)
895 {
896 	sal_uInt16 i;
897 
898 	SetHelpId(HID_NAVIGATOR_TREELIST);
899 
900 	SetNodeDefaultImages();
901 	SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl));
902 	SetDragDropMode(SV_DRAGDROP_APP_COPY);
903 	for( i = 0; i < CONTENT_TYPE_MAX; i++ )
904 	{
905 		aActiveContentArr[i] 	= 0;
906 		aHiddenContentArr[i] 	= 0;
907 	}
908 	for( i = 0; i < CONTEXT_COUNT; i++ )
909 	{
910 		aContextStrings[i] = SW_RESSTR(i+ST_CONTEXT_FIRST);
911 	}
912 	nActiveBlock = pConfig->GetActiveBlock();
913 	aUpdTimer.SetTimeoutHdl(LINK(this, SwContentTree, TimerUpdate));
914 	aUpdTimer.SetTimeout(1000);
915 	Clear();
916 	EnableContextMenuHandling();
917 	SetStyle( GetStyle() | WB_QUICK_SEARCH );
918 }
919 
920 /***************************************************************************
921 	Beschreibung:
922 ***************************************************************************/
923 
924 
~SwContentTree()925 SwContentTree::~SwContentTree()
926 {
927 	Clear(); // vorher ggf. Inhaltstypen loeschen
928 	bIsInDrag = sal_False;
929 }
930 
GetEntryAltText(SvLBoxEntry * pEntry) const931 String SwContentTree::GetEntryAltText( SvLBoxEntry* pEntry ) const
932 {
933 	if( pEntry == NULL)
934 		return String();
935 
936 	SwContent* pCnt = (SwContent*)pEntry->GetUserData();
937 	if( pCnt == NULL || pCnt->GetParent() == NULL)
938 		return String();
939 
940 	sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
941 	SdrObject* pTemp;
942 
943 	switch(nJumpType)
944 	{
945 		case CONTENT_TYPE_DRAWOBJECT:
946 			{
947 				SdrView* pDrawView = pActiveShell->GetDrawView();
948 				if (pDrawView)
949 				{
950                     SwDrawModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
951                     SdrPage* pPage = pDrawModel->GetPage(0);
952                     const sal_uInt32 nCount = pPage->GetObjCount();
953 					for( sal_uInt32 i=0; i< nCount; i++ )
954 					{
955 						pTemp = pPage->GetObj(i);
956 						sal_uInt16 nCmpId;
957 						switch( pTemp->GetObjIdentifier() )
958 						{
959 						case OBJ_GRUP:
960 						case OBJ_TEXT:
961 						case OBJ_TEXTEXT:
962 						case OBJ_wegFITTEXT:
963 						case OBJ_LINE:
964 						case OBJ_RECT:
965 							//caoxueqin added custom shape
966 						case OBJ_CUSTOMSHAPE:
967 							//end 2005/08/05
968 						case OBJ_CIRC:
969 						case OBJ_SECT:
970 						case OBJ_CARC:
971 						case OBJ_CCUT:
972 						case OBJ_POLY:
973 						case OBJ_PLIN:
974 						case OBJ_PATHLINE:
975 						case OBJ_PATHFILL:
976 						case OBJ_FREELINE:
977 						case OBJ_FREEFILL:
978 						case OBJ_PATHPOLY:
979 						case OBJ_PATHPLIN:
980 						case OBJ_CAPTION:
981 							nCmpId = OBJ_GRUP;
982 							break;
983 						default:
984 							nCmpId = pTemp->GetObjIdentifier();
985 						}
986 						if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName())
987 						{
988 							return pTemp->GetTitle();
989 						}
990 						//Commented End
991 					}
992 				}
993 			}
994 			break;
995 		case CONTENT_TYPE_GRAPHIC   :
996 			{
997 				if( pActiveShell && pActiveShell->GetDoc() )
998 				{
999 					const SwFlyFrmFmt* pFrmFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0);
1000 					if( pFrmFmt )
1001 					{
1002 //                        SwNodeIndex aIdx( *(pFrmFmt->GetCntnt().GetCntntIdx()), 1 );
1003 //                        const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode();
1004 //                        if( pGrfNd )
1005 //                            return pGrfNd->GetAlternateText();
1006                         return pFrmFmt->GetObjTitle();
1007 					}
1008 				}
1009 			}
1010 			break;
1011 		case CONTENT_TYPE_OLE       :
1012 		case CONTENT_TYPE_FRAME     :
1013 			{
1014 				//Can't find the GetAlternateText function. Need to verify again.
1015 				const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0);
1016 				if( pFlyFmt )
1017 					return pFlyFmt->/*GetAlternateText*/GetName();
1018 			}
1019 			break;
1020 	}
1021 	return String();
1022 }
1023 
GetEntryLongDescription(SvLBoxEntry * pEntry) const1024 String SwContentTree::GetEntryLongDescription( SvLBoxEntry* pEntry ) const
1025 {
1026 	if( pEntry == NULL)
1027 		return String();
1028 
1029 	SwContent* pCnt = (SwContent*)pEntry->GetUserData();
1030 	if( pCnt == NULL || pCnt->GetParent() == NULL)
1031 		return String();
1032 
1033 	sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
1034 	SdrObject* pTemp;
1035 
1036 	switch(nJumpType)
1037 	{
1038 		case CONTENT_TYPE_DRAWOBJECT:
1039 			{
1040 				SdrView* pDrawView = pActiveShell->GetDrawView();
1041 				if (pDrawView)
1042 				{
1043                     SwDrawModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
1044                     SdrPage* pPage = pDrawModel->GetPage(0);
1045 					sal_uInt32 nCount = pPage->GetObjCount();
1046 					for( sal_uInt32 i=0; i< nCount; i++ )
1047 					{
1048 						pTemp = pPage->GetObj(i);
1049 						sal_uInt16 nCmpId;
1050 						switch( pTemp->GetObjIdentifier() )
1051 						{
1052 						case OBJ_GRUP:
1053 						case OBJ_TEXT:
1054 						case OBJ_TEXTEXT:
1055 						case OBJ_wegFITTEXT:
1056 						case OBJ_LINE:
1057 						case OBJ_RECT:
1058 							//caoxueqin added custom shape
1059 						case OBJ_CUSTOMSHAPE:
1060 							//end 2005/08/05
1061 						case OBJ_CIRC:
1062 						case OBJ_SECT:
1063 						case OBJ_CARC:
1064 						case OBJ_CCUT:
1065 						case OBJ_POLY:
1066 						case OBJ_PLIN:
1067 						case OBJ_PATHLINE:
1068 						case OBJ_PATHFILL:
1069 						case OBJ_FREELINE:
1070 						case OBJ_FREEFILL:
1071 						case OBJ_PATHPOLY:
1072 						case OBJ_PATHPLIN:
1073 						case OBJ_CAPTION:
1074 							nCmpId = OBJ_GRUP;
1075 							break;
1076 						default:
1077 							nCmpId = pTemp->GetObjIdentifier();
1078 						}
1079 						if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName())
1080 						{
1081 							return pTemp->GetDescription();
1082 						}
1083 						//Commented End
1084 					}
1085 				}
1086 			}
1087 			break;
1088 		case CONTENT_TYPE_GRAPHIC   :
1089 		case CONTENT_TYPE_OLE       :
1090 		case CONTENT_TYPE_FRAME     :
1091 			{
1092 				//Can't find the function "GetLongDescription". Need to verify again.
1093 				const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0);
1094 				if( pFlyFmt )
1095 					return pFlyFmt->GetDescription();
1096 			}
1097 			break;
1098 	}
1099 	return String();
1100 }
1101 
1102 /***************************************************************************
1103 	Drag&Drop methods
1104 ***************************************************************************/
1105 
StartDrag(sal_Int8 nAction,const Point & rPosPixel)1106 void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
1107 {
1108 	if( !bIsRoot || nRootType != CONTENT_TYPE_OUTLINE )
1109 	{
1110 		ReleaseMouse();
1111 
1112 		TransferDataContainer* pContainer = new TransferDataContainer;
1113         uno::Reference<
1114             datatransfer::XTransferable > xRef( pContainer );
1115 
1116 		sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
1117 		if( FillTransferData( *pContainer, nDragMode ))
1118 		{
1119 			SwContentTree::SetInDrag(sal_True);
1120 			pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() );
1121 		}
1122 	}
1123 	else
1124 		SvTreeListBox::StartDrag( nAction, rPosPixel );
1125 }
1126 
DragFinished(sal_Int8 nAction)1127 void SwContentTree::DragFinished( sal_Int8 nAction )
1128 {
1129     //to prevent the removing of the selected entry in external drag and drop
1130     // the drag action mustn't be MOVE
1131     SvTreeListBox::DragFinished( bIsInternalDrag ? nAction : DND_ACTION_COPY );
1132 	SwContentTree::SetInDrag(sal_False);
1133 	bIsInternalDrag = sal_False;
1134 }
1135 
1136 /***************************************************************************
1137 	Beschreibung:   QueryDrop wird im Navigator ausgefuehrt
1138 ***************************************************************************/
AcceptDrop(const AcceptDropEvent & rEvt)1139 sal_Int8 SwContentTree::AcceptDrop( const AcceptDropEvent& rEvt )
1140 {
1141 	sal_Int8 nRet = DND_ACTION_NONE;
1142 	if( bIsRoot )
1143 	{
1144 		if( bIsOutlineMoveable )
1145 			nRet = SvTreeListBox::AcceptDrop( rEvt );
1146 	}
1147 	else if( !bIsInDrag )
1148 		nRet = GetParentWindow()->AcceptDrop( rEvt );
1149 	return nRet;
1150 }
1151 
1152 /***************************************************************************
1153 	Beschreibung:	Drop wird im Navigator ausgefuehrt
1154 ***************************************************************************/
ExecuteDrop(const ExecuteDropEvent & rEvt)1155 sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
1156 {
1157 	if( bIsRoot )
1158 		return SvTreeListBox::ExecuteDrop( rEvt );
1159 	return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt);
1160 }
1161 
1162 
1163 /***************************************************************************
1164 	Beschreibung:	Handler fuer Dragging und ContextMenu
1165 ***************************************************************************/
CreateContextMenu(void)1166 PopupMenu* SwContentTree::CreateContextMenu( void )
1167 {
1168     PopupMenu* pPop = new PopupMenu;
1169     PopupMenu* pSubPop1 = new PopupMenu;
1170     PopupMenu* pSubPop2 = new PopupMenu;
1171     PopupMenu* pSubPop3 = new PopupMenu;
1172     PopupMenu* pSubPop4 = new PopupMenu; // Edit
1173 
1174     sal_uInt16 i;
1175     for(i = 1; i <= MAXLEVEL; i++ )
1176     {
1177         pSubPop1->InsertItem( i + 100, String::CreateFromInt32(i));
1178     }
1179     pSubPop1->CheckItem(100 + nOutlineLevel);
1180     for(i=0; i < 3; i++ )
1181     {
1182         pSubPop2->InsertItem( i + 201, aContextStrings[
1183                 ST_HYPERLINK - ST_CONTEXT_FIRST + i]);
1184     }
1185     pSubPop2->CheckItem( 201 +
1186                     GetParentWindow()->GetRegionDropMode());
1187 	// Insert list of open files (filter out help pages)
1188 	sal_uInt16 nId = 301;
1189 	const SwView* pActiveView = ::GetActiveView();
1190 	SwView *pView = SwModule::GetFirstView();
1191 	while (pView)
1192 	{
1193 		if (!pView->GetDocShell()->IsHelpDocument())
1194 		{
1195 			String sInsert = pView->GetDocShell()->GetTitle();
1196 			sInsert += C2S(" (");
1197 			if(pView == pActiveView)
1198 			{
1199 				sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST];
1200 			}
1201 			else
1202 			{
1203 				sInsert += aContextStrings[ ST_INACTIVE - ST_CONTEXT_FIRST];
1204 			}
1205 			sInsert += ')';
1206 			pSubPop3->InsertItem(nId, sInsert);
1207 			if(bIsConstant && pActiveShell == &pView->GetWrtShell())
1208 				pSubPop3->CheckItem(nId);
1209 		}
1210 	pView = SwModule::GetNextView(pView);
1211 	nId++;
1212 	}
1213     pSubPop3->InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]);
1214     if(pHiddenShell)
1215     {
1216         String sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle();
1217         sHiddenEntry += C2S(" (");
1218         sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST];
1219         sHiddenEntry += ')';
1220         pSubPop3->InsertItem(nId, sHiddenEntry);
1221     }
1222 
1223     if(bIsActive)
1224         pSubPop3->CheckItem( --nId );
1225     else if(bIsHidden)
1226         pSubPop3->CheckItem( nId );
1227 
1228     pPop->InsertItem( 1, aContextStrings[ST_OUTLINE_LEVEL - ST_CONTEXT_FIRST]);
1229     pPop->InsertItem(2, aContextStrings[ST_DRAGMODE - ST_CONTEXT_FIRST]);
1230     pPop->InsertItem(3, aContextStrings[ST_DISPLAY - ST_CONTEXT_FIRST]);
1231     //jetzt noch bearbeiten
1232     SvLBoxEntry* pEntry = 0;
1233     //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen
1234     if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr())
1235             && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry))
1236     {
1237         const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent();
1238         const sal_uInt16 nContentType = pContType->GetType();
1239         sal_Bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly();
1240         sal_Bool bVisible = !((SwContent*)pEntry->GetUserData())->IsInvisible();
1241         sal_Bool bProtected = ((SwContent*)pEntry->GetUserData())->IsProtect();
1242         sal_Bool bEditable = pContType->IsEditable() &&
1243             ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType);
1244         sal_Bool bDeletable = pContType->IsDeletable() &&
1245             ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType);
1246         sal_Bool bRenamable = bEditable && !bReadonly &&
1247             (CONTENT_TYPE_TABLE == nContentType ||
1248                 CONTENT_TYPE_FRAME == nContentType ||
1249                 CONTENT_TYPE_GRAPHIC == nContentType ||
1250                 CONTENT_TYPE_OLE == nContentType ||
1251                 CONTENT_TYPE_BOOKMARK == nContentType ||
1252                 CONTENT_TYPE_REGION == nContentType||
1253                 CONTENT_TYPE_INDEX == nContentType);
1254 
1255         if(!bReadonly && (bEditable || bDeletable))
1256         {
1257             sal_Bool bSubPop4 = sal_False;
1258             if(CONTENT_TYPE_INDEX == nContentType)
1259             {
1260                 bSubPop4 = sal_True;
1261                 pSubPop4->InsertItem(401, sRemoveIdx);
1262                 pSubPop4->InsertItem(402, sUpdateIdx);
1263 
1264                 const SwTOXBase* pBase = ((SwTOXBaseContent*)pEntry->GetUserData())->GetTOXBase();
1265                 if(!pBase->IsTOXBaseInReadonly())
1266                     pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1267                 pSubPop4->InsertItem(405, sReadonlyIdx);
1268 
1269                 pSubPop4->CheckItem( 405, pActiveShell->IsTOXBaseReadonly(*pBase));
1270                 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1271             }
1272             else if(CONTENT_TYPE_TABLE == nContentType && !bReadonly)
1273             {
1274                 bSubPop4 = sal_True;
1275                 pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1276                 pSubPop4->InsertItem(404, sUnprotTbl);
1277                 sal_Bool bFull = sal_False;
1278                 String sTblName = ((SwContent*)pEntry->GetUserData())->GetName();
1279                 sal_Bool bProt =pActiveShell->HasTblAnyProtection( &sTblName, &bFull );
1280                 pSubPop4->EnableItem(403, !bFull );
1281                 pSubPop4->EnableItem(404, bProt );
1282                 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1283             }
1284             else if(bEditable || bDeletable)
1285             {
1286 
1287 				if(bEditable && bDeletable)
1288                 {
1289                     pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1290                     pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1291                     bSubPop4 = sal_True;
1292                 }
1293                 else if(bEditable)
1294                     pPop->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1295                 else if(bDeletable)
1296 				{
1297                     pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1298 				}
1299             }
1300             //Rename object
1301             if(bRenamable)
1302             {
1303                 if(bSubPop4)
1304                     pSubPop4->InsertItem(502, sRename);
1305                 else
1306                     pPop->InsertItem(502, sRename);
1307             }
1308 
1309             if(bSubPop4)
1310             {
1311                 pPop->InsertItem(4, pContType->GetSingleName());
1312                 pPop->SetPopupMenu(4, pSubPop4);
1313             }
1314         }
1315     }
1316     else if( pEntry )
1317 	{
1318 		SwContentType* pType = (SwContentType*)pEntry->GetUserData();
1319 		if ( (pType->GetType() == CONTENT_TYPE_POSTIT) && (!pActiveShell->GetView().GetDocShell()->IsReadOnly()) && ( pType->GetMemberCount() > 0) )
1320 		{
1321 				pSubPop4->InsertItem(600, sPostItShow );
1322 				pSubPop4->InsertItem(601, sPostItHide );
1323 				pSubPop4->InsertItem(602, sPostItDelete );
1324 				/*
1325 				pSubPop4->InsertItem(603,rtl::OUString::createFromAscii("Sort"));
1326 				PopupMenu* pMenuSort = new PopupMenu;
1327 				pMenuSort->InsertItem(604,rtl::OUString::createFromAscii("By Position"));
1328 				pMenuSort->InsertItem(605,rtl::OUString::createFromAscii("By Author"));
1329 				pMenuSort->InsertItem(606,rtl::OUString::createFromAscii("By Date"));
1330 				pSubPop4->SetPopupMenu(603, pMenuSort);
1331 				*/
1332 			    pPop->InsertItem(4, pType->GetSingleName());
1333                 pPop->SetPopupMenu(4, pSubPop4);
1334 		}
1335 	}
1336 
1337     pPop->SetPopupMenu( 1, pSubPop1 );
1338     pPop->SetPopupMenu( 2, pSubPop2 );
1339     pPop->SetPopupMenu( 3, pSubPop3 );
1340     return pPop;
1341 
1342 }
1343 /***************************************************************************
1344 	Beschreibung:	Einrueckung fuer outlines (und sections)
1345 ***************************************************************************/
1346 
1347 
GetTabPos(SvLBoxEntry * pEntry,SvLBoxTab * pTab)1348 long	SwContentTree::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
1349 {
1350 	sal_uInt16 nLevel = 0;
1351 	if(lcl_IsContent(pEntry))
1352 	{
1353 		nLevel++;
1354 		SwContent* pCnt = (SwContent *) pEntry->GetUserData();
1355 		const SwContentType*	pParent;
1356 		if(pCnt &&	0 != (pParent = pCnt->GetParent()))
1357 		{
1358 			if(pParent->GetType() == CONTENT_TYPE_OUTLINE)
1359                 nLevel = nLevel + ((SwOutlineContent*)pCnt)->GetOutlineLevel();
1360 			else if(pParent->GetType() == CONTENT_TYPE_REGION)
1361                 nLevel = nLevel + ((SwRegionContent*)pCnt)->GetRegionLevel();
1362 		}
1363 	}
1364 	sal_uInt16 nBasis = bIsRoot ? 0 : 5;
1365 	return nLevel * 10 + nBasis + pTab->GetPos();  //empirisch ermittelt
1366 }
1367 
1368 /***************************************************************************
1369 	Beschreibung:	Inhalte werden erst auf Anforderung in die Box eingefuegt
1370 ***************************************************************************/
1371 
1372 
RequestingChilds(SvLBoxEntry * pParent)1373 void SwContentTree::RequestingChilds( SvLBoxEntry* pParent )
1374 {
1375 	// ist es ein Inhaltstyp?
1376 	if(lcl_IsContentType(pParent))
1377 	{
1378 		if(!pParent->HasChilds())
1379 		{
1380 			DBG_ASSERT(pParent->GetUserData(), "keine UserData?");
1381 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1382 
1383 			sal_uInt16 nCount = pCntType->GetMemberCount();
1384 			for(sal_uInt16 i = 0; i < nCount; i++)
1385 			{
1386 				const SwContent* pCnt = pCntType->GetMember(i);
1387 				if(pCnt)
1388 				{
1389 					String sEntry = pCnt->GetName();
1390 					if(!sEntry.Len())
1391 						sEntry = sSpace;
1392 					SvLBoxEntry* pChild = InsertEntry(sEntry, pParent,
1393 							sal_False, LIST_APPEND, (void*)pCnt);
1394 					//Solution: If object is marked , the corresponding entry is set true ,
1395 					//else the corresponding entry is set false .
1396 					//==================================================
1397 					SdrObject * pObj = GetDrawingObjectsByContent(pCnt);
1398 					if(pChild)
1399 					      pChild->SetMarked(sal_False);
1400 					if(pObj)
1401 					{
1402 						SdrView* pDrawView = pActiveShell->GetDrawView();
1403 						SdrPageView* pPV = pDrawView->/*GetPageViewPvNum*/GetSdrPageView(/*0*/);
1404 						if( pPV )
1405 						{
1406 							sal_Bool Marked = pDrawView->IsObjMarked(pObj);
1407 							if(Marked)
1408 							{
1409 								//sEntry += String::CreateFromAscii(" *");
1410 								pChild->SetMarked(sal_True);
1411 							}
1412 
1413 						}
1414 					}
1415 				}
1416 			}
1417 		}
1418 	}
1419 }
1420 /***************************************************************************
1421 	Beschreibung:	Expand - Zustand fuer Inhaltstypen merken
1422 ***************************************************************************/
1423 
1424 //Solution: Get drawing Objects by content .
GetDrawingObjectsByContent(const SwContent * pCnt)1425 SdrObject* SwContentTree::GetDrawingObjectsByContent(const SwContent *pCnt)
1426 {
1427 	SdrObject *pRetObj = NULL;
1428 	sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
1429 	switch(nJumpType)
1430 	{
1431 		case CONTENT_TYPE_DRAWOBJECT:
1432 		{
1433 			SdrView* pDrawView = pActiveShell->GetDrawView();
1434 			if (pDrawView)
1435 			{
1436                 SwDrawModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
1437                 SdrPage* pPage = pDrawModel->GetPage(0);
1438 				sal_uInt32 nCount = pPage->GetObjCount();
1439 
1440 				for( sal_uInt32 i=0; i< nCount; i++ )
1441 				{
1442 					SdrObject* pTemp = pPage->GetObj(i);
1443 					if( pTemp->GetName() == pCnt->GetName())
1444 					{
1445 						pRetObj = pTemp;
1446 						break;
1447 					}
1448 				}
1449 			}
1450 			break;
1451 		}
1452 		default:
1453 			pRetObj = NULL;
1454 	}
1455 	return pRetObj;
1456 }
1457 
Expand(SvLBoxEntry * pParent)1458 sal_Bool SwContentTree::Expand( SvLBoxEntry* pParent )
1459 {
1460 	if(!bIsRoot)
1461 	{
1462 		if(lcl_IsContentType(pParent))
1463 		{
1464 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1465 			sal_uInt16 nOr = 1 << pCntType->GetType(); //linear -> Bitposition
1466 			if(bIsActive || bIsConstant)
1467 			{
1468 				nActiveBlock |= nOr;
1469 				pConfig->SetActiveBlock(nActiveBlock);
1470 			}
1471 			else
1472 				nHiddenBlock |= nOr;
1473 		}
1474 	}
1475 	return SvTreeListBox::Expand(pParent);
1476 }
1477 /***************************************************************************
1478 	Beschreibung:	Collapse - Zustand fuer Inhaltstypen merken
1479 ***************************************************************************/
1480 
1481 
Collapse(SvLBoxEntry * pParent)1482 sal_Bool SwContentTree::Collapse( SvLBoxEntry* pParent )
1483 {
1484 	sal_Bool bRet;
1485 	if(!bIsRoot)
1486 	{
1487 		if(lcl_IsContentType(pParent))
1488 		{
1489 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1490 			sal_uInt16 nAnd = 1 << pCntType->GetType();
1491 			nAnd = ~nAnd;
1492 			if(bIsActive || bIsConstant)
1493 			{
1494 				nActiveBlock &= nAnd;
1495 				pConfig->SetActiveBlock(nActiveBlock);
1496 			}
1497 			else
1498 				nHiddenBlock &= nAnd;
1499 		}
1500 			bRet = SvTreeListBox::Collapse(pParent);
1501 	}
1502 	else
1503 		bRet = sal_False;
1504 	return bRet;
1505 }
1506 
1507 
1508 /***************************************************************************
1509 	Beschreibung:	Auch auf Doppelclick wird zunaechst nur aufgeklappt
1510 ***************************************************************************/
1511 
1512 
IMPL_LINK(SwContentTree,ContentDoubleClickHdl,SwContentTree *,EMPTYARG)1513 IMPL_LINK( SwContentTree, ContentDoubleClickHdl, SwContentTree *, EMPTYARG )
1514 {
1515 	SvLBoxEntry* pEntry = GetCurEntry();
1516 	// ist es ein Inhaltstyp?
1517 	DBG_ASSERT(pEntry, "kein aktueller Eintrag!");
1518 	if(pEntry)
1519 	{
1520 		if(lcl_IsContentType(pEntry))
1521 			RequestingChilds(pEntry);
1522 		else if(bIsActive || bIsConstant)
1523 		{
1524 			if(bIsConstant)
1525 			{
1526 				pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
1527 			}
1528 			//Inhaltstyp anspringen:
1529 			SwContent* pCnt = (SwContent*)pEntry->GetUserData();
1530 			DBG_ASSERT( pCnt, "keine UserData");
1531 			GotoContent(pCnt);
1532 			if(pCnt->GetParent()->GetType()	== CONTENT_TYPE_FRAME)
1533 				pActiveShell->EnterStdMode();
1534 		}
1535 	}
1536 	return 0;
1537 }
1538 
1539 /***************************************************************************
1540 	Beschreibung:	Anzeigen der Datei
1541 ***************************************************************************/
1542 
1543 
Display(sal_Bool bActive)1544 void SwContentTree::Display( sal_Bool bActive )
1545 {
1546 	if(!bIsImageListInitialized)
1547 	{
1548         sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP;
1549         aEntryImages = ImageList(SW_RES(nResId));
1550 		bIsImageListInitialized = sal_True;
1551 	}
1552 	// erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder
1553 	// zu selektieren -> die UserDaten sind hier nicht mehr gueltig!
1554 	SvLBoxEntry* pOldSelEntry = FirstSelected();
1555 	String sEntryName;	// Name des Eintrags
1556 	sal_uInt16 nEntryRelPos = 0; // rel. Pos zu seinem Parent
1557     sal_uInt32 nOldEntryCount = GetEntryCount();
1558     sal_Int32 nOldScrollPos = 0;
1559 	if(pOldSelEntry)
1560 	{
1561         ScrollBar* pVScroll = GetVScroll();
1562         if(pVScroll && pVScroll->IsVisible())
1563             nOldScrollPos = pVScroll->GetThumbPos();
1564 
1565         sEntryName = GetEntryText(pOldSelEntry);
1566 		if(GetParent(pOldSelEntry))
1567 		{
1568 			nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(GetParent(pOldSelEntry)));
1569 		}
1570 	}
1571 	Clear();
1572 	SetUpdateMode( sal_False );
1573 	if(bActive && !bIsConstant && !bIsActive)
1574 		bIsActive = bActive;
1575 	bIsHidden = !bActive;
1576 	SwWrtShell* pShell = GetWrtShell();
1577 	sal_Bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True;
1578 	if(bReadOnly != bIsLastReadOnly)
1579 	{
1580 		bIsLastReadOnly = bReadOnly;
1581 		sal_Bool bDisable = pShell == 0 || bReadOnly;
1582 		SwNavigationPI* pNavi = GetParentWindow();
1583 		pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , !bDisable);
1584 		pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, !bDisable);
1585 		pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, !bDisable);
1586 		pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT, !bDisable);
1587 		pNavi->aContentToolBox.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable);
1588 	}
1589 	if(pShell)
1590 	{
1591 		SvLBoxEntry* pSelEntry = 0;
1592 		if(nRootType == USHRT_MAX)
1593 		{
1594 			for(sal_uInt16 nCntType = CONTENT_TYPE_OUTLINE;
1595                         nCntType <= CONTENT_TYPE_DRAWOBJECT; nCntType++ )
1596 			{
1597 				SwContentType** ppContentT = bActive ?
1598 								&aActiveContentArr[nCntType] :
1599 									&aHiddenContentArr[nCntType];
1600 				if(!*ppContentT)
1601 					(*ppContentT) = new SwContentType(pShell, nCntType, nOutlineLevel );
1602 
1603 
1604 				String sEntry = (*ppContentT)->GetName();
1605 				SvLBoxEntry* pEntry;
1606 				const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType);
1607 				sal_Bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount();
1608 				pEntry = InsertEntry(sEntry, rImage, rImage,
1609 								0, bChOnDemand, LIST_APPEND, (*ppContentT));
1610 				if(nCntType == nLastSelType)
1611 					pSelEntry = pEntry;
1612                 sal_Int32 nExpandOptions = bIsActive || bIsConstant ?
1613 											nActiveBlock :
1614 												nHiddenBlock;
1615 				if(nExpandOptions & (1 << nCntType))
1616 				{
1617 					Expand(pEntry);
1618 					if(nEntryRelPos && nCntType == nLastSelType)
1619 					{
1620 						// jetzt vielleicht noch ein Child selektieren
1621 						SvLBoxEntry* pChild = pEntry;
1622 						SvLBoxEntry* pTemp = 0;
1623 						sal_uInt16 nPos = 1;
1624 						while(0 != (pChild = Next(pChild)))
1625 						{
1626 							// der alte Text wird leicht bevorzugt
1627 							if(sEntryName == GetEntryText(pChild) ||
1628 								nPos == nEntryRelPos )
1629 							{
1630 								pSelEntry = pChild;
1631 								break;
1632 							}
1633 							pTemp = pChild;
1634 							nPos++;
1635 						}
1636 						if(!pSelEntry || lcl_IsContentType(pSelEntry))
1637 							pSelEntry = pTemp;
1638 					}
1639 
1640 				}
1641 			}
1642 			if(pSelEntry)
1643 			{
1644 				MakeVisible(pSelEntry);
1645 				Select(pSelEntry);
1646             }
1647             else
1648                 nOldScrollPos = 0;
1649 		}
1650 		else
1651 		{
1652 			SwContentType** ppRootContentT = bActive ?
1653 								&aActiveContentArr[nRootType] :
1654 									&aHiddenContentArr[nRootType];
1655 			if(!(*ppRootContentT))
1656 				(*ppRootContentT) = new SwContentType(pShell, nRootType, nOutlineLevel );
1657 			const Image& rImage = aEntryImages.GetImage(20000 + nRootType);
1658 			SvLBoxEntry* pParent = InsertEntry(
1659 					(*ppRootContentT)->GetName(), rImage, rImage,
1660 						0, sal_False, LIST_APPEND, *ppRootContentT);
1661 
1662 			for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ )
1663 			{
1664 				const SwContent* pCnt = (*ppRootContentT)->GetMember(i);
1665 				if(pCnt)
1666 				{
1667 					String sEntry = pCnt->GetName();
1668 					if(!sEntry.Len())
1669 						sEntry = sSpace;
1670                     InsertEntry( sEntry, pParent,
1671 								sal_False, LIST_APPEND, (void*)pCnt);
1672 				}
1673 			}
1674 			Expand(pParent);
1675 			if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive )
1676 			{
1677 				//feststellen, wo der Cursor steht
1678 				const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL);
1679 				SvLBoxEntry* pEntry = First();
1680 
1681 				while( 0 != (pEntry = Next(pEntry)) )
1682 				{
1683 					if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos)
1684 					{
1685 						MakeVisible(pEntry);
1686 						Select(pEntry);
1687 					}
1688 				}
1689 
1690 			}
1691 			else
1692 			{
1693 				// jetzt vielleicht noch ein Child selektieren
1694 				SvLBoxEntry* pChild = pParent;
1695 				SvLBoxEntry* pTemp = 0;
1696 				sal_uInt16 nPos = 1;
1697 				while(0 != (pChild = Next(pChild)))
1698 				{
1699 					// der alte Text wird leicht bevorzugt
1700 					if(sEntryName == GetEntryText(pChild) ||
1701 						nPos == nEntryRelPos )
1702 					{
1703 						pSelEntry = pChild;
1704 						break;
1705 					}
1706 					pTemp = pChild;
1707 					nPos++;
1708 				}
1709 				if(!pSelEntry)
1710 					pSelEntry = pTemp;
1711 				if(pSelEntry)
1712 				{
1713 					MakeVisible(pSelEntry);
1714 					Select(pSelEntry);
1715 				}
1716 			}
1717 		}
1718 	}
1719 	SetUpdateMode( sal_True );
1720     ScrollBar* pVScroll = GetVScroll();
1721     if(GetEntryCount() == nOldEntryCount &&
1722         nOldScrollPos && pVScroll && pVScroll->IsVisible()
1723         && pVScroll->GetThumbPos() != nOldScrollPos)
1724     {
1725         sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos;
1726         ScrollOutputArea( (short)nDelta );
1727     }
1728 
1729 }
1730 
1731 /***************************************************************************
1732 	Beschreibung:	Im Clear muessen auch die ContentTypes geloescht werden
1733 ***************************************************************************/
1734 
1735 
Clear()1736 void SwContentTree::Clear()
1737 {
1738 	SetUpdateMode(sal_False);
1739 	SvTreeListBox::Clear();
1740 	SetUpdateMode(sal_True);
1741 }
1742 
1743 /***************************************************************************
1744 	Beschreibung:
1745 ***************************************************************************/
1746 
FillTransferData(TransferDataContainer & rTransfer,sal_Int8 & rDragMode)1747 sal_Bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer,
1748 											sal_Int8& rDragMode )
1749 {
1750 	SwWrtShell* pWrtShell = GetWrtShell();
1751 	DBG_ASSERT(pWrtShell, "keine Shell!");
1752 	SvLBoxEntry* pEntry = GetCurEntry();
1753 	if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell)
1754 		return sal_False;
1755 	String sEntry;
1756 	SwContent* pCnt = ((SwContent*)pEntry->GetUserData());
1757 
1758 	sal_uInt16 nActType = pCnt->GetParent()->GetType();
1759 	String sUrl;
1760 	sal_Bool bOutline = sal_False;
1761 	String sOutlineText;
1762 	switch( nActType )
1763 	{
1764 		case CONTENT_TYPE_OUTLINE:
1765 		{
1766 			sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos();
1767             DBG_ASSERT(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(),
1768                        "outlinecnt veraendert");
1769 
1770             // #100738# make sure outline may actually be copied
1771             if( pWrtShell->IsOutlineCopyable( nPos ) )
1772             {
1773                 const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule();
1774                 const SwTxtNode* pTxtNd =
1775                         pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos);
1776                 if( pTxtNd && pOutlRule && pTxtNd->IsNumbered())
1777                 {
1778                     SwNumberTree::tNumberVector aNumVector =
1779                         pTxtNd->GetNumberVector();
1780                     for( sal_Int8 nLevel = 0;
1781                          nLevel <= pTxtNd->GetActualListLevel();
1782                          nLevel++ )
1783                     {
1784                         sal_uInt16 nVal = (sal_uInt16)aNumVector[nLevel];
1785                         nVal ++;
1786                         nVal = nVal - pOutlRule->Get(nLevel).GetStart();
1787                         sEntry += String::CreateFromInt32( nVal );
1788                         sEntry += '.';
1789                     }
1790                 }
1791                 sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false);
1792                 sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true);
1793                 bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable();
1794                 bOutline = sal_True;
1795             }
1796 		}
1797 		break;
1798 		case CONTENT_TYPE_POSTIT:
1799 		case CONTENT_TYPE_INDEX:
1800 		case CONTENT_TYPE_REFERENCE :
1801 			// koennen weder als URL noch als Bereich eingefuegt werden
1802 		break;
1803 		case CONTENT_TYPE_URLFIELD:
1804 			sUrl = ((SwURLFieldContent*)pCnt)->GetURL();
1805 		// kein break;
1806 		case CONTENT_TYPE_OLE:
1807 		case CONTENT_TYPE_GRAPHIC:
1808 			if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE)
1809 				break;
1810 			else
1811 				rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
1812 		default:
1813 			sEntry = GetEntryText(pEntry);
1814 	}
1815 
1816 	sal_Bool bRet = sal_False;
1817 	if(sEntry.Len())
1818 	{
1819 		const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
1820 		if(!sUrl.Len())
1821 		{
1822 			if(pDocShell->HasName())
1823 			{
1824 				SfxMedium* pMedium = pDocShell->GetMedium();
1825 				sUrl = pMedium->GetURLObject().GetURLNoMark();
1826 				// nur, wenn primaer ein Link eingefuegt werden soll
1827 				bRet = sal_True;
1828 			}
1829 			else if(	nActType == CONTENT_TYPE_REGION ||
1830 						nActType == CONTENT_TYPE_BOOKMARK )
1831 			{
1832 				// fuer Bereich und Textmarken ist ein Link auch ohne
1833 				// Dateiname ins eigene Dokument erlaubt
1834 				bRet = sal_True;
1835 			}
1836 			else if(bIsConstant &&
1837 					( !::GetActiveView() ||
1838 						pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
1839 			{
1840 				// Urls von inaktiven Views ohne Dateinamen koennen auch nicht
1841 				// gedraggt werden
1842 				bRet = sal_False;
1843 			}
1844 			else
1845 			{
1846 				bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE;
1847 				rDragMode = DND_ACTION_MOVE;
1848 			}
1849 
1850 			const String& rToken = pCnt->GetParent()->GetTypeToken();
1851 			sUrl += '#';
1852 			sUrl += sEntry;
1853 			if(rToken.Len())
1854 			{
1855 				sUrl += cMarkSeperator;
1856 				sUrl += rToken;
1857 			}
1858 		}
1859 		else
1860 			bRet = sal_True;
1861 
1862 		if( bRet )
1863 		{
1864 			//fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer
1865 			if(bOutline)
1866 				sEntry = sOutlineText;
1867 
1868 			{
1869 				NaviContentBookmark aBmk( sUrl, sEntry,
1870 									GetParentWindow()->GetRegionDropMode(),
1871 									pDocShell);
1872 				aBmk.Copy( rTransfer );
1873 			}
1874 
1875 			// fuer fremde DocShells muss eine INetBookmark
1876 			// dazugeliefert werden
1877 			if( pDocShell->HasName() )
1878 			{
1879 				INetBookmark aBkmk( sUrl, sEntry );
1880 				rTransfer.CopyINetBookmark( aBkmk );
1881 			}
1882 		}
1883 	}
1884 	return bRet;
1885 }
1886 /***************************************************************************
1887 	Beschreibung:	Umschalten der Anzeige auf Root
1888 ***************************************************************************/
1889 
1890 
ToggleToRoot()1891 sal_Bool SwContentTree::ToggleToRoot()
1892 {
1893 	if(!bIsRoot)
1894 	{
1895 		SvLBoxEntry* pEntry = GetCurEntry();
1896 		const SwContentType* pCntType;
1897 		if(pEntry)
1898 		{
1899 			if(lcl_IsContentType(pEntry))
1900 				pCntType = (SwContentType*)pEntry->GetUserData();
1901 			else
1902 				pCntType = ((SwContent*)pEntry->GetUserData())->GetParent();
1903 			nRootType = pCntType->GetType();
1904 			bIsRoot = sal_True;
1905 			Display(bIsActive || bIsConstant);
1906 		}
1907 	}
1908 	else
1909 	{
1910 		nRootType = USHRT_MAX;
1911 		bIsRoot = sal_False;
1912 		FindActiveTypeAndRemoveUserData();
1913 		Display(bIsActive || bIsConstant);
1914 	}
1915 	pConfig->SetRootType( nRootType );
1916 	GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot);
1917 	return bIsRoot;
1918 }
1919 
1920 /***************************************************************************
1921 	Beschreibung:	Angezeigten Inhalt auf Gueltigkeit pruefen
1922 ***************************************************************************/
1923 
1924 
HasContentChanged()1925 sal_Bool SwContentTree::HasContentChanged()
1926 {
1927 /*
1928 	-Parallel durch das lokale Array und die Treelistbox laufen.
1929 	-Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen
1930 	und der Contenttype wird als UserData neu gesetzt.
1931 	- ist der Root-Modus aktiv, wird nur dieser aktualisiert,
1932 	fuer die nicht angezeigten Inhaltstypen gilt:
1933 		die Memberliste wird geloescht und der Membercount aktualisiert
1934 	Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden
1935 	Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch
1936 	gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt.
1937 
1938 */
1939 
1940 	sal_Bool bRepaint = sal_False;
1941 	sal_Bool bInvalidate = sal_False;
1942 
1943 	if(!bIsActive && ! bIsConstant)
1944 	{
1945 		for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
1946 		{
1947 			if(aActiveContentArr[i])
1948 				aActiveContentArr[i]->Invalidate();
1949 		}
1950 	}
1951 	else if(bIsRoot)
1952 	{
1953 		sal_Bool bOutline = sal_False;
1954 		SvLBoxEntry* pEntry = First();
1955 		if(!pEntry)
1956 			bRepaint = sal_True;
1957 		else
1958 		{
1959 			sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType();
1960 			bOutline = nRootType == CONTENT_TYPE_OUTLINE;
1961 			SwContentType* pArrType = aActiveContentArr[nType];
1962 			if(!pArrType)
1963 				bRepaint = sal_True;
1964 			else
1965 			{
1966 				sal_uInt16 nSelLevel = USHRT_MAX;
1967 
1968 				SvLBoxEntry* pFirstSel;
1969 				if(bOutline &&
1970 						0 != ( pFirstSel = FirstSelected()) &&
1971 							lcl_IsContent(pFirstSel))
1972 				{
1973 					nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel();
1974 					SwWrtShell* pSh = GetWrtShell();
1975 					sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
1976                     bRepaint |= nOutlinePos != USHRT_MAX &&
1977                                 pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel;
1978 				}
1979 
1980 				pArrType->Init(&bInvalidate);
1981 				pArrType->FillMemberList();
1982 				pEntry->SetUserData((void*)pArrType);
1983 				if(!bRepaint)
1984 				{
1985 					if(GetChildCount(pEntry) != pArrType->GetMemberCount())
1986 							bRepaint = sal_True;
1987 					else
1988 					{
1989 						sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
1990 						for(sal_uInt16 j = 0; j < nChildCount; j++)
1991 						{
1992 							pEntry = Next(pEntry);
1993 							const SwContent* pCnt = pArrType->GetMember(j);
1994 							pEntry->SetUserData((void*)pCnt);
1995 							String sEntryText = GetEntryText(pEntry);
1996 							if( sEntryText != pCnt->GetName() &&
1997 								!(sEntryText == sSpace && !pCnt->GetName().Len()))
1998 								bRepaint = sal_True;
1999 						}
2000 					}
2001 				}
2002 			}
2003 		}
2004 		if( !bRepaint && bOutline )
2005 		{
2006 			//feststellen, wo der Cursor steht
2007 			const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL);
2008             SvLBoxEntry* pFirstEntry = First();
2009 
2010             while( 0 != (pFirstEntry = Next(pFirstEntry)) )
2011 			{
2012                 if(((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos() == nActPos)
2013 				{
2014                     if(FirstSelected() != pFirstEntry)
2015 					{
2016                         Select(pFirstEntry);
2017                         MakeVisible(pFirstEntry);
2018 					}
2019 				}
2020 			}
2021 
2022 		}
2023 
2024 	}
2025 	else
2026 	{
2027 		SvLBoxEntry* pEntry = First();
2028 		while ( pEntry )
2029 		{
2030 			sal_Bool bNext = sal_True; // mindestens ein Next muss sein
2031 			SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData();
2032 			sal_uInt16 nType = pTreeType->GetType();
2033 			sal_uInt16 nTreeCount = pTreeType->GetMemberCount();
2034 			SwContentType* pArrType = aActiveContentArr[nType];
2035 			if(!pArrType)
2036 				bRepaint = sal_True;
2037 			else
2038 			{
2039 				pArrType->Init(&bInvalidate);
2040 				pEntry->SetUserData((void*)pArrType);
2041 				if(IsExpanded(pEntry))
2042 				{
2043 					sal_Bool bLevelOrVisibiblityChanged = sal_False;
2044 					// bLevelOrVisibiblityChanged is set if outlines have changed their level
2045 					// or if the visibility of objects (frames, sections, tables) has changed
2046 					// i.e. in header/footer
2047 					pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
2048 					if(bLevelOrVisibiblityChanged)
2049 						bInvalidate = sal_True;
2050 					sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
2051 					if(bLevelOrVisibiblityChanged)
2052 						bInvalidate = sal_True;
2053 
2054 					if(nChildCount != pArrType->GetMemberCount())
2055 						bRepaint = sal_True;
2056 					else
2057 					{
2058 						for(sal_uInt16 j = 0; j < nChildCount; j++)
2059 						{
2060 							pEntry = Next(pEntry);
2061 							bNext = sal_False;
2062 							const SwContent* pCnt = pArrType->GetMember(j);
2063 							pEntry->SetUserData((void*)pCnt);
2064 							String sEntryText = GetEntryText(pEntry);
2065 							if( sEntryText != pCnt->GetName() &&
2066 								!(sEntryText == sSpace && !pCnt->GetName().Len()))
2067 								bRepaint = sal_True;
2068 						}
2069 					}
2070 
2071 				}
2072 				else if(pEntry->HasChilds())
2073 				{
2074 					//war der Eintrag einmal aufgeklappt, dann muessen auch
2075 					// die unsichtbaren Eintraege geprueft werden.
2076 					// zumindest muessen die Userdaten aktualisiert werden
2077 					sal_Bool bLevelOrVisibiblityChanged = sal_False;
2078 					// bLevelOrVisibiblityChanged is set if outlines have changed their level
2079 					// or if the visibility of objects (frames, sections, tables) has changed
2080 					// i.e. in header/footer
2081 					pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
2082 					sal_Bool bRemoveChildren = sal_False;
2083 					sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
2084 					if( nChildCount != pArrType->GetMemberCount() )
2085 					{
2086 						bRemoveChildren = sal_True;
2087 					}
2088 					else
2089 					{
2090 						SvLBoxEntry* pChild = FirstChild(pEntry);
2091 						for(sal_uInt16 j = 0; j < nChildCount; j++)
2092 						{
2093 							const SwContent* pCnt = pArrType->GetMember(j);
2094 							pChild->SetUserData((void*)pCnt);
2095 							String sEntryText = GetEntryText(pChild);
2096 							if( sEntryText != pCnt->GetName() &&
2097 								!(sEntryText == sSpace && !pCnt->GetName().Len()))
2098 								bRemoveChildren = sal_True;
2099 							pChild = Next(pChild);
2100 						}
2101 					}
2102 					if(bRemoveChildren)
2103 					{
2104 						SvLBoxEntry* pChild = FirstChild(pEntry);
2105 						SvLBoxEntry* pRemove = pChild;
2106 						for(sal_uInt16 j = 0; j < nChildCount; j++)
2107 						{
2108 							pChild = Next(pRemove);
2109 							GetModel()->Remove(pRemove);
2110 							pRemove = pChild;
2111 						}
2112 					}
2113 					if(!nChildCount)
2114 					{
2115 						pEntry->EnableChildsOnDemand(sal_False);
2116 						InvalidateEntry(pEntry);
2117 					}
2118 
2119 				}
2120 				else if((nTreeCount != 0)
2121 							!= (pArrType->GetMemberCount()!=0))
2122 				{
2123 					bRepaint = sal_True;
2124 				}
2125 			}
2126 			//hier muss noch der naechste Root-Entry gefunden werden
2127 			while( pEntry && (bNext || GetParent(pEntry ) ))
2128 			{
2129 				pEntry = Next(pEntry);
2130 				bNext = sal_False;
2131 			}
2132 		}
2133 	}
2134 	if(!bRepaint && bInvalidate)
2135 		Invalidate();
2136 	return bRepaint;
2137 }
2138 
2139 /***************************************************************************
2140 	Beschreibung: 	Bevor alle Daten geloescht werden, soll noch der letzte
2141  * 					aktive Eintrag festgestellt werden. Dann werden die
2142  * 					UserData geloescht
2143 ***************************************************************************/
FindActiveTypeAndRemoveUserData()2144 void SwContentTree::FindActiveTypeAndRemoveUserData()
2145 {
2146 	SvLBoxEntry* pEntry = FirstSelected();
2147 	if(pEntry)
2148 	{
2149 		// wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root
2150 		// die Gueltigkeit der UserData garantiert werden
2151 		SvLBoxEntry* pParent;
2152 		while(0 != (pParent = GetParent(pEntry)))
2153 			pEntry = pParent;
2154 		if(pEntry->GetUserData() && lcl_IsContentType(pEntry))
2155 			nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType();
2156 	}
2157 //	else
2158 //		nLastSelType = USHRT_MAX;
2159 	pEntry = First();
2160 	while(pEntry)
2161 	{
2162 		pEntry->SetUserData(0);
2163 		pEntry = Next(pEntry);
2164 	}
2165 }
2166 
2167 /***************************************************************************
2168 	Beschreibung: 	Nachdem ein File auf den Navigator gedroppt wurde,
2169 					wird die neue Shell gesetzt
2170 ***************************************************************************/
2171 
2172 
SetHiddenShell(SwWrtShell * pSh)2173 void SwContentTree::SetHiddenShell(SwWrtShell* pSh)
2174 {
2175 	pHiddenShell = pSh;
2176 	bIsHidden = sal_True;
2177 	bIsActive = bIsConstant = sal_False;
2178 	FindActiveTypeAndRemoveUserData();
2179 	for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
2180 	{
2181 		DELETEZ(aHiddenContentArr[i]);
2182 	}
2183 	Display(bIsActive);
2184 
2185 	GetParentWindow()->UpdateListBox();
2186 }
2187 /***************************************************************************
2188 	Beschreibung:	Dokumentwechsel - neue Shell setzen
2189 ***************************************************************************/
2190 
2191 
SetActiveShell(SwWrtShell * pSh)2192 void SwContentTree::SetActiveShell(SwWrtShell* pSh)
2193 {
2194 	if(bIsInternalDrag)
2195 		bDocChgdInDragging = sal_True;
2196 	sal_Bool bClear = pActiveShell != pSh;
2197 	if(bIsActive && bClear)
2198 	{
2199 		pActiveShell = pSh;
2200 		FindActiveTypeAndRemoveUserData();
2201 		Clear();
2202 	}
2203 	else if(bIsConstant)
2204 	{
2205 		if(!lcl_FindShell(pActiveShell))
2206 		{
2207 			pActiveShell = pSh;
2208 			bIsActive = sal_True;
2209 			bIsConstant = sal_False;
2210 			bClear = sal_True;
2211 		}
2212 	}
2213 	// nur wenn es die aktive View ist, wird das Array geloescht und
2214 	// die Anzeige neu gefuellt
2215 	if(bIsActive && bClear)
2216 	{
2217 		FindActiveTypeAndRemoveUserData();
2218 		for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
2219 		{
2220 			DELETEZ(aActiveContentArr[i]);
2221 		}
2222 		Display(sal_True);
2223 	}
2224 }
2225 
2226 /***************************************************************************
2227 	Beschreibung: 	Eine offene View als aktiv festlegen
2228 ***************************************************************************/
2229 
2230 
SetConstantShell(SwWrtShell * pSh)2231 void SwContentTree::SetConstantShell(SwWrtShell* pSh)
2232 {
2233 	pActiveShell = pSh;
2234 	bIsActive 		= sal_False;
2235 	bIsConstant 	= sal_True;
2236 	FindActiveTypeAndRemoveUserData();
2237 	for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
2238 	{
2239 		DELETEZ(aActiveContentArr[i]);
2240 	}
2241 	Display(sal_True);
2242 }
2243 /***************************************************************************
2244 	Beschreibung:	Kommandos des Navigators ausfuehren
2245 ***************************************************************************/
2246 
2247 
ExecCommand(sal_uInt16 nCmd,sal_Bool bModifier)2248 void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier)
2249 {
2250 	sal_Bool nMove = sal_False;
2251 	switch( nCmd )
2252 	{
2253 		case FN_ITEM_DOWN:
2254 		case FN_ITEM_UP:   nMove = sal_True;
2255 		case FN_ITEM_LEFT:
2256 		case FN_ITEM_RIGHT:
2257 		if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
2258 				(bIsActive ||
2259                     (bIsConstant && pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
2260 		{
2261 			SwWrtShell* pShell = GetWrtShell();
2262 			sal_Int8 nActOutlineLevel = nOutlineLevel;
2263 			sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel);
2264 			SvLBoxEntry* pFirstEntry = FirstSelected();
2265 			if (pFirstEntry && lcl_IsContent(pFirstEntry))
2266 			{
2267 				if((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE) ||
2268 					((SwContent*)pFirstEntry->GetUserData())->GetParent()->GetType()
2269 												== 	CONTENT_TYPE_OUTLINE)
2270 				{
2271 					nActPos = ((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos();
2272 				}
2273 			}
2274 			if ( nActPos < USHRT_MAX &&
2275 					( !nMove || pShell->IsOutlineMovable( nActPos )) )
2276 			{
2277 				pShell->StartAllAction();
2278 				pShell->GotoOutline( nActPos); // Falls Textselektion != BoxSelektion
2279 				pShell->Push();
2280 				pShell->MakeOutlineSel( nActPos, nActPos,
2281 									bModifier);
2282 				if( nMove )
2283 				{
2284 					short nDir = nCmd == FN_ITEM_UP ? -1 : 1;
2285 					if( !bModifier && ((nDir == -1 && nActPos > 0) ||
2286 						(nDir == 1 && nActPos < GetEntryCount() - 2 )) )
2287 					{
2288 						pShell->MoveOutlinePara( nDir );
2289 						//Cursor wieder an die aktuelle Position setzen
2290 						pShell->GotoOutline( nActPos + nDir);
2291 					}
2292 					else if(bModifier)
2293 					{
2294 						sal_uInt16 nActEndPos = nActPos;
2295 						SvLBoxEntry* pEntry = pFirstEntry;
2296 						sal_uInt16 nActLevel = ((SwOutlineContent*)
2297 								pFirstEntry->GetUserData())->GetOutlineLevel();
2298 						pEntry = Next(pEntry);
2299 						while( pEntry && CONTENT_TYPE_OUTLINE ==
2300 							((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() )
2301 						{
2302 							if(nActLevel >= ((SwOutlineContent*)
2303 								pEntry->GetUserData())->GetOutlineLevel())
2304 								break;
2305 							pEntry = Next(pEntry);
2306 							nActEndPos++;
2307 						}
2308 						sal_uInt16 nDest;
2309 						if(nDir == 1)
2310 						{
2311 							//Wenn der letzte Eintrag bewegt werden soll
2312 							//ist Schluss
2313 							if(pEntry && CONTENT_TYPE_OUTLINE ==
2314 								((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())
2315 							{
2316 								// pEntry zeigt jetzt auf den
2317 								// dem letzten sel. Eintrag folgenden E.
2318 								nDest = nActEndPos;
2319 								nDest++;
2320 								//hier muss der uebernaechste Eintrag
2321 								//gefunden werden. Die Selektion muss davor eingefuegt
2322 								//werden
2323 								while(pEntry )
2324 								{
2325 									pEntry = Next(pEntry);
2326 									// nDest++ darf nur ausgefuehrt werden,
2327 									// wenn pEntry != 0
2328 									if(pEntry && nDest++ &&
2329 									( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
2330 									 CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
2331 									{
2332 										nDest--;
2333 										break;
2334 									}
2335 								}
2336 								nDir = nDest - nActEndPos;
2337 								//wenn kein Eintrag gefunden wurde, der der Bedingung
2338 								//fuer das zuvor Einfuegen entspricht, muss etwas weniger
2339 								//geschoben werden
2340 							}
2341 							else
2342 								nDir = 0;
2343 						}
2344 						else
2345 						{
2346 							nDest = nActPos;
2347 							pEntry = pFirstEntry;
2348 							while(pEntry && nDest )
2349 							{
2350 								nDest--;
2351 								pEntry = Prev(pEntry);
2352 								if(pEntry &&
2353 									(nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
2354 									CONTENT_TYPE_OUTLINE !=
2355 								((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
2356 								{
2357 									break;
2358 								}
2359 							}
2360 							nDir = nDest - nActPos;
2361 						}
2362 						if(nDir)
2363 						{
2364 							pShell->MoveOutlinePara( nDir );
2365 							//Cursor wieder an die aktuelle Position setzen
2366 							pShell->GotoOutline( nActPos + nDir);
2367 						}
2368 					}
2369 				}
2370 				else
2371 				{
2372 					if( pShell->IsProtectedOutlinePara() )
2373 						Sound::Beep(); //konnte nicht umgestuft werden
2374 					else
2375 						pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 );
2376 				}
2377 
2378 				pShell->ClearMark();
2379 				pShell->Pop(sal_False); //Cursor steht jetzt wieder an der akt. Ueberschrift
2380 				pShell->EndAllAction();
2381 				if(aActiveContentArr[CONTENT_TYPE_OUTLINE])
2382 					aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2383 				Display(sal_True);
2384 				if(!bIsRoot)
2385 				{
2386                     const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL);
2387                     SvLBoxEntry* pFirst = First();
2388 
2389                     while( 0 != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst))
2390 					{
2391                         if(((SwOutlineContent*)pFirst->GetUserData())->GetPos() == nCurrPos)
2392 						{
2393                             Select(pFirst);
2394                             MakeVisible(pFirst);
2395 						}
2396 					}
2397 				}
2398 			}
2399 			else
2400 				Sound::Beep(); //konnte nicht verschoben werden
2401 		}
2402 	}
2403 }
2404 /***************************************************************************
2405 	Beschreibung:
2406 ***************************************************************************/
2407 
2408 
ShowTree()2409 void	SwContentTree::ShowTree()
2410 {
2411 	aUpdTimer.Start();
2412 	SvTreeListBox::Show();
2413 }
2414 
2415 /***************************************************************************
2416 	Beschreibung:	zusammengefaltet wird nicht geidlet
2417 ***************************************************************************/
2418 
2419 
HideTree()2420 void	SwContentTree::HideTree()
2421 {
2422 	aUpdTimer.Stop();
2423 	SvTreeListBox::Hide();
2424 }
2425 
2426 /***************************************************************************
2427 	Beschreibung:	Kein Idle mit Focus oder waehrend des Dragging
2428 ***************************************************************************/
2429 
2430 
IMPL_LINK(SwContentTree,TimerUpdate,Timer *,EMPTYARG)2431 IMPL_LINK( SwContentTree, TimerUpdate, Timer*, EMPTYARG)
2432 {
2433 	// kein Update waehrend D&D
2434 	// Viewabfrage, da der Navigator zu spaet abgeraeumt wird
2435     SwView* pView = GetParentWindow()->GetCreateView();
2436 	if( (!HasFocus() || bViewHasChanged) &&
2437 		 !bIsInDrag && !bIsInternalDrag && pView &&
2438 		 pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() )
2439 	{
2440 		bViewHasChanged = sal_False;
2441 		bIsIdleClear = sal_False;
2442 		SwWrtShell* pActShell = pView->GetWrtShellPtr();
2443 		if( bIsConstant && !lcl_FindShell( pActiveShell ) )
2444 		{
2445 			SetActiveShell(pActShell);
2446 			GetParentWindow()->UpdateListBox();
2447 		}
2448 
2449 		if(bIsActive && pActShell != GetWrtShell())
2450 			SetActiveShell(pActShell);
2451 		else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
2452 					HasContentChanged())
2453 		{
2454 			FindActiveTypeAndRemoveUserData();
2455 			Display(sal_True);
2456 			//Solution: Set focus
2457 			if( bIsKeySpace )
2458 			{
2459 				HideFocus();
2460 				ShowFocus( oldRectangle);
2461 				bIsKeySpace = sal_False;
2462 			}
2463 		}
2464 	}
2465 	else if(!pView && bIsActive && !bIsIdleClear)
2466 	{
2467 		if(pActiveShell)
2468 			SetActiveShell(0);
2469 		Clear();
2470 		bIsIdleClear = sal_True;
2471 	}
2472 	return 0;
2473 }
2474 
2475 /***************************************************************************
2476 	Beschreibung:
2477 ***************************************************************************/
2478 
2479 
NotifyStartDrag(TransferDataContainer & rContainer,SvLBoxEntry * pEntry)2480 DragDropMode SwContentTree::NotifyStartDrag(
2481 				TransferDataContainer& rContainer,
2482 				SvLBoxEntry* pEntry )
2483 {
2484 	DragDropMode eMode = (DragDropMode)0;
2485 	if( bIsActive && nRootType == CONTENT_TYPE_OUTLINE &&
2486 		GetModel()->GetAbsPos( pEntry ) > 0
2487 		&& !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
2488 		eMode = GetDragDropMode();
2489 	else if(!bIsActive && GetWrtShell()->GetView().GetDocShell()->HasName())
2490 		eMode = SV_DRAGDROP_APP_COPY;
2491 
2492 	sal_Int8 nDragMode;
2493 	FillTransferData( rContainer, nDragMode );
2494 	bDocChgdInDragging = sal_False;
2495 	bIsInternalDrag = sal_True;
2496 	return eMode;
2497 }
2498 
2499 
2500 /***************************************************************************
2501 	Beschreibung :	Nach dem Drag wird der aktuelle Absatz m i t
2502 					Childs verschoben
2503 ***************************************************************************/
2504 
2505 
NotifyMoving(SvLBoxEntry * pTarget,SvLBoxEntry * pEntry,SvLBoxEntry * &,sal_uLong &)2506 sal_Bool  SwContentTree::NotifyMoving( SvLBoxEntry*  pTarget,
2507 		SvLBoxEntry*  pEntry, SvLBoxEntry*& , sal_uLong& )
2508 {
2509 	if(!bDocChgdInDragging)
2510 	{
2511 		sal_uInt16 nTargetPos = 0;
2512 		sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
2513 		if(!lcl_IsContent(pTarget))
2514 			nTargetPos = USHRT_MAX;
2515 		else
2516 			nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
2517 		if(	MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
2518 						nTargetPos != USHRT_MAX)
2519 		{
2520 			SvLBoxEntry* pNext = Next(pTarget);
2521 			if(pNext)
2522 				nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1;
2523 			else
2524                 nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1;
2525 
2526 		}
2527 
2528 		DBG_ASSERT( pEntry &&
2529 			lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" );
2530 		GetParentWindow()->MoveOutline( nSourcePos,
2531 									nTargetPos,
2532 									sal_True);
2533 
2534 		aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2535 		Display(sal_True);
2536 	}
2537 	//TreeListBox wird aus dem Dokument neu geladen
2538 	return sal_False;
2539 }
2540 /***************************************************************************
2541 	Beschreibung : 	Nach dem Drag wird der aktuelle Absatz o h n e
2542 					Childs verschoben
2543 ***************************************************************************/
2544 
2545 
NotifyCopying(SvLBoxEntry * pTarget,SvLBoxEntry * pEntry,SvLBoxEntry * &,sal_uLong &)2546 sal_Bool  SwContentTree::NotifyCopying( SvLBoxEntry*  pTarget,
2547 		SvLBoxEntry*  pEntry, SvLBoxEntry*& , sal_uLong& )
2548 {
2549 	if(!bDocChgdInDragging)
2550 	{
2551 		sal_uInt16 nTargetPos = 0;
2552 		sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
2553 		if(!lcl_IsContent(pTarget))
2554 			nTargetPos = USHRT_MAX;
2555 		else
2556 			nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
2557 
2558 		if(	MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
2559 						nTargetPos != USHRT_MAX)
2560 		{
2561 			SvLBoxEntry* pNext = Next(pTarget);
2562 			if(pNext)
2563 				nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1;
2564 			else
2565                 nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1;
2566 
2567 		}
2568 
2569 
2570 		DBG_ASSERT( pEntry &&
2571 			lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" );
2572 		GetParentWindow()->MoveOutline( nSourcePos,	nTargetPos, sal_False);
2573 
2574 		//TreeListBox wird aus dem Dokument neu geladen
2575 		aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2576 		Display(sal_True);
2577 	}
2578 	return sal_False;
2579 }
2580 
2581 /***************************************************************************
2582 	Beschreibung:	Kein Drop vor den ersten Eintrag - es ist ein SwContentType
2583 ***************************************************************************/
2584 
NotifyAcceptDrop(SvLBoxEntry * pEntry)2585 sal_Bool SwContentTree::NotifyAcceptDrop( SvLBoxEntry* pEntry)
2586 {
2587 	return pEntry != 0;
2588 }
2589 
2590 
2591 /***************************************************************************
2592 	Beschreibung: 	Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
2593  * 					dann soll die Basisfunktion des Controls gerufen werden
2594 ***************************************************************************/
MouseButtonDown(const MouseEvent & rMEvt)2595 void SwContentTree::MouseButtonDown( const MouseEvent& rMEvt )
2596 {
2597 	Point aPos( rMEvt.GetPosPixel());
2598 	SvLBoxEntry* pEntry = GetEntry( aPos, sal_True );
2599 	if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
2600 		Control::MouseButtonDown( rMEvt );
2601 	else
2602 		SvTreeListBox::MouseButtonDown( rMEvt );
2603 }
2604 
2605 /***************************************************************************
2606 	Beschreibung:	sofort aktualisieren
2607 ***************************************************************************/
2608 
2609 
GetFocus()2610 void SwContentTree::GetFocus()
2611 {
2612 	SwView* pActView = GetParentWindow()->GetCreateView();
2613 	if(pActView)
2614 	{
2615 		SwWrtShell* pActShell = pActView->GetWrtShellPtr();
2616 		if(bIsConstant && !lcl_FindShell(pActiveShell))
2617 		{
2618 			SetActiveShell(pActShell);
2619 		}
2620 
2621 		if(bIsActive && pActShell != GetWrtShell())
2622 			SetActiveShell(pActShell);
2623 		else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
2624 					HasContentChanged())
2625 		{
2626 			Display(sal_True);
2627 		}
2628 	}
2629 	else if(bIsActive)
2630 		Clear();
2631 	SvTreeListBox::GetFocus();
2632 }
2633 
2634 /***************************************************************************
2635 	Beschreibung:
2636 ***************************************************************************/
2637 
2638 
KeyInput(const KeyEvent & rEvent)2639 void SwContentTree::KeyInput(const KeyEvent& rEvent)
2640 {
2641 	const KeyCode aCode = rEvent.GetKeyCode();
2642 	if(aCode.GetCode() == KEY_RETURN)
2643 	{
2644 		SvLBoxEntry* pEntry = FirstSelected();
2645 		if ( pEntry )
2646 		{
2647 			switch(aCode.GetModifier())
2648 			{
2649 				case KEY_MOD2:
2650 					// Boxen umschalten
2651 					GetParentWindow()->ToggleTree();
2652 				break;
2653 				case KEY_MOD1:
2654 					// RootModus umschalten
2655 					ToggleToRoot();
2656 				break;
2657 				case 0:
2658 					if(lcl_IsContentType(pEntry))
2659 					{
2660 						IsExpanded(pEntry) ?
2661 							Collapse(pEntry) :
2662 								Expand(pEntry);
2663 					}
2664 					else
2665 						ContentDoubleClickHdl(0);
2666 				break;
2667 			}
2668 		}
2669 	}
2670 	else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
2671 	{
2672 		SvLBoxEntry* pEntry = FirstSelected();
2673 		if(pEntry &&
2674 			lcl_IsContent(pEntry) &&
2675 				((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() &&
2676 					!pActiveShell->GetView().GetDocShell()->IsReadOnly())
2677 		{
2678 			EditEntry(pEntry, EDIT_MODE_DELETE);
2679             bViewHasChanged = sal_True;
2680             GetParentWindow()->UpdateListBox();
2681             TimerUpdate(&aUpdTimer);
2682             GrabFocus();
2683         }
2684 	}
2685 	//Solution: Make KEY_SPACE has same function as DoubleClick ,
2686 	//and realize multi-selection .
2687 	else if(aCode.GetCode() == KEY_SPACE && 0 == aCode.GetModifier())
2688 	{
2689 
2690 		SvLBoxEntry* pEntry = GetCurEntry();
2691 		if( GetChildCount( pEntry ) == 0 )
2692 			bIsKeySpace = sal_True;
2693 		Point tempPoint = GetEntryPosition( pEntry );//Change from "GetEntryPos" to "GetEntryPosition" for acc migration
2694 		oldRectangle = GetFocusRect( pEntry,tempPoint.Y() );
2695 
2696 		if(pEntry)
2697 		{
2698 			if(bIsActive || bIsConstant)
2699 			{
2700 				if(bIsConstant)
2701 				{
2702 					pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
2703 				}
2704 
2705 				SwContent* pCnt = (SwContent*)pEntry->GetUserData();
2706 
2707 				sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
2708 				switch(nJumpType)
2709 				{
2710 					case CONTENT_TYPE_DRAWOBJECT:
2711 					{
2712 						SdrView* pDrawView = pActiveShell->GetDrawView();
2713 						if (pDrawView)
2714 						{
2715 							pDrawView->SdrEndTextEdit();//Change from "EndTextEdit" to "SdrEndTextEdit" for acc migration
2716 
2717                             SwDrawModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel();
2718                             SdrPage* pPage = pDrawModel->GetPage(0);
2719 							sal_uInt32 nCount = pPage->GetObjCount();
2720 							sal_Bool hasObjectMarked = sal_False;
2721 
2722 							SdrObject* pObject = NULL;
2723 							pObject = GetDrawingObjectsByContent( pCnt );
2724 							if( pObject )
2725 							{
2726 								SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
2727 								if( pPV )
2728 								{
2729 									sal_Bool bUnMark = pDrawView->IsObjMarked(pObject);
2730 									pDrawView->MarkObj( pObject, pPV, bUnMark);
2731 
2732 								}
2733 							}
2734 							for( sal_uInt32 i=0; i< nCount; i++ )
2735 							{
2736 								SdrObject* pTemp = pPage->GetObj(i);
2737 								sal_uInt16 nCmpId;
2738 								sal_Bool bMark = pDrawView->IsObjMarked(pTemp);
2739 								switch( pTemp->GetObjIdentifier() )
2740 								{
2741 									case OBJ_GRUP:
2742 									case OBJ_TEXT:
2743 									case OBJ_TEXTEXT:
2744 									case OBJ_wegFITTEXT:
2745 									case OBJ_LINE:
2746 									case OBJ_RECT:
2747 									case OBJ_CIRC:
2748 									case OBJ_SECT:
2749 									case OBJ_CARC:
2750 									case OBJ_CCUT:
2751 									case OBJ_POLY:
2752 									case OBJ_PLIN:
2753 									case OBJ_PATHLINE:
2754 									case OBJ_PATHFILL:
2755 									case OBJ_FREELINE:
2756 									case OBJ_FREEFILL:
2757 									case OBJ_PATHPOLY:
2758 									case OBJ_PATHPLIN:
2759 									case OBJ_CAPTION:
2760 									case OBJ_CUSTOMSHAPE:
2761 										nCmpId = OBJ_GRUP;
2762 										if( bMark )
2763 											hasObjectMarked = sal_True;
2764 										break;
2765 									default:
2766 										nCmpId = pTemp->GetObjIdentifier();
2767 										if ( bMark )
2768 										{
2769 											SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
2770 											if (pPV)
2771 											{
2772 												pDrawView->MarkObj(pTemp, pPV, sal_True);
2773 											}
2774 										}
2775 								}
2776 								//mod end
2777 							}
2778 							if ( pActiveShell && !hasObjectMarked )
2779 							{
2780 								SwEditWin& pEditWindow =
2781 									pActiveShell->GetView().GetEditWin();
2782 								if( &pEditWindow )
2783 								{
2784 									KeyCode tempKeycode( KEY_ESCAPE );
2785 									KeyEvent rKEvt( 0 , tempKeycode );
2786 									((Window*)&pEditWindow)->KeyInput( rKEvt );
2787 
2788 								}
2789 								//rView.GetEditWin().GrabFocus();
2790 							}
2791 						}
2792 					}
2793 					break;
2794 				}
2795 
2796 
2797 				bViewHasChanged = sal_True;
2798 			}
2799 		}
2800 
2801 	}
2802 	else
2803 		SvTreeListBox::KeyInput(rEvent);
2804 
2805 }
2806 
2807 /***************************************************************************
2808 	Beschreibung:
2809 ***************************************************************************/
2810 
2811 
RequestHelp(const HelpEvent & rHEvt)2812 void SwContentTree::RequestHelp( const HelpEvent& rHEvt )
2813 {
2814 	sal_Bool bCallBase = sal_True;
2815 	if( rHEvt.GetMode() & HELPMODE_QUICK )
2816 	{
2817 		Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
2818 		SvLBoxEntry* pEntry = GetEntry( aPos );
2819 		if( pEntry )
2820 		{
2821 			sal_uInt16 nType;
2822 			sal_Bool bBalloon = sal_False;
2823 			sal_Bool bContent = sal_False;
2824 			void* pUserData = pEntry->GetUserData();
2825 			if(lcl_IsContentType(pEntry))
2826 				nType = ((SwContentType*)pUserData)->GetType();
2827 			else
2828 			{
2829 				nType = ((SwContent*)pUserData)->GetParent()->GetType();
2830 				bContent = sal_True;
2831 			}
2832 			String sEntry;
2833 			sal_Bool bRet = sal_False;
2834 			if(bContent)
2835 			{
2836 				switch( nType )
2837 				{
2838 					case CONTENT_TYPE_URLFIELD:
2839 						sEntry = ((SwURLFieldContent*)pUserData)->GetURL();
2840 						bRet = sal_True;
2841 					break;
2842 
2843 					case CONTENT_TYPE_POSTIT:
2844 						sEntry = ((SwPostItContent*)pUserData)->GetName();
2845 						bRet = sal_True;
2846 						if(Help::IsBalloonHelpEnabled())
2847 							bBalloon = sal_True;
2848 					break;
2849 					case CONTENT_TYPE_OUTLINE:
2850 						sEntry = ((SwOutlineContent*)pUserData)->GetName();
2851 						bRet = sal_True;
2852 					break;
2853 					case CONTENT_TYPE_GRAPHIC:
2854 						sEntry = ((SwGraphicContent*)pUserData)->GetLink();
2855 #if OSL_DEBUG_LEVEL > 1
2856 						sEntry += ' ';
2857 						sEntry += String::CreateFromInt32(
2858 									((SwGraphicContent*)pUserData)->GetYPos());
2859 #endif
2860 						bRet = sal_True;
2861 					break;
2862 #if OSL_DEBUG_LEVEL > 1
2863 					case CONTENT_TYPE_TABLE:
2864 					case CONTENT_TYPE_FRAME:
2865 						sEntry = String::CreateFromInt32(
2866 										((SwContent*)pUserData)->GetYPos() );
2867 						bRet = sal_True;
2868 					break;
2869 #endif
2870 				}
2871 				if(((SwContent*)pUserData)->IsInvisible())
2872 				{
2873 					if(sEntry.Len())
2874 						sEntry += C2S(", ");
2875 					sEntry += sInvisible;
2876 					bRet = sal_True;
2877 				}
2878 			}
2879 			else
2880 			{
2881 				sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount();
2882 				sEntry = String::CreateFromInt32(nMemberCount);
2883 				sEntry += ' ';
2884 				sEntry += nMemberCount == 1
2885 							? ((SwContentType*)pUserData)->GetSingleName()
2886 							: ((SwContentType*)pUserData)->GetName();
2887 				bRet = sal_True;
2888 			}
2889 			if(bRet)
2890 			{
2891 				SvLBoxTab* pTab;
2892 				SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
2893 				if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
2894 				{
2895 					aPos = GetEntryPosition( pEntry );
2896 
2897 					aPos.X() = GetTabPos( pEntry, pTab );
2898 					Size aSize( pItem->GetSize( this, pEntry ) );
2899 
2900 					if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
2901 						aSize.Width() = GetSizePixel().Width() - aPos.X();
2902 
2903 					aPos = OutputToScreenPixel(aPos);
2904 					Rectangle aItemRect( aPos, aSize );
2905 					if(bBalloon)
2906 					{
2907 						aPos.X() += aSize.Width();
2908 						Help::ShowBalloon( this, aPos, aItemRect, sEntry );
2909 					}
2910 					else
2911 						Help::ShowQuickHelp( this, aItemRect, sEntry,
2912 							QUICKHELP_LEFT|QUICKHELP_VCENTER );
2913 					bCallBase = sal_False;
2914 				}
2915 			}
2916 			else
2917 			{
2918 				Help::ShowQuickHelp( this, Rectangle(), aEmptyStr, 0 );
2919 				bCallBase = sal_False;
2920 			}
2921 		}
2922 	}
2923 	if( bCallBase )
2924 		Window::RequestHelp( rHEvt );
2925 }
2926 
2927 /***************************************************************************
2928 	Beschreibung:
2929 ***************************************************************************/
2930 
2931 
ExcecuteContextMenuAction(sal_uInt16 nSelectedPopupEntry)2932 void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
2933 {
2934 	SvLBoxEntry* pFirst = FirstSelected();
2935 	switch( nSelectedPopupEntry )
2936 	{
2937 		//Outlinelevel
2938 		case 101:
2939 		case 102:
2940 		case 103:
2941 		case 104:
2942 		case 105:
2943 		case 106:
2944 		case 107:
2945 		case 108:
2946 		case 109:
2947 		case 110:
2948             nSelectedPopupEntry -= 100;
2949             if(nOutlineLevel != nSelectedPopupEntry )
2950                 SetOutlineLevel((sal_Int8)nSelectedPopupEntry);
2951 		break;
2952 		case 201:
2953 		case 202:
2954 		case 203:
2955             GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201);
2956 		break;
2957 		case 401:
2958 		case 402:
2959             EditEntry(pFirst, nSelectedPopupEntry == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX);
2960 		break;
2961 		// Eintrag bearbeiten
2962 		case 403:
2963 			EditEntry(pFirst, EDIT_MODE_EDIT);
2964 		break;
2965 		case 404:
2966 			EditEntry(pFirst, EDIT_UNPROTECT_TABLE);
2967 		break;
2968 		case 405 :
2969 		{
2970 			const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData())
2971 																->GetTOXBase();
2972             pActiveShell->SetTOXBaseReadonly(*pBase, !pActiveShell->IsTOXBaseReadonly(*pBase));
2973 		}
2974 		break;
2975 		case 4:
2976 		break;
2977 		case 501:
2978 			EditEntry(pFirst, EDIT_MODE_DELETE);
2979 		break;
2980 		case 502 :
2981 			EditEntry(pFirst, EDIT_MODE_RENAME);
2982 		break;
2983 		case 600:
2984 			pActiveShell->GetView().GetPostItMgr()->Show();
2985 			break;
2986 		case 601:
2987 			pActiveShell->GetView().GetPostItMgr()->Hide();
2988 			break;
2989 		case 602:
2990 			{
2991                 pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0);
2992 				pActiveShell->GetView().GetPostItMgr()->Delete();
2993 				break;
2994 			}
2995 		//Anzeige
2996         default: // nSelectedPopupEntry > 300
2997         if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
2998 		{
2999             nSelectedPopupEntry -= 300;
3000 			SwView *pView = SwModule::GetFirstView();
3001 			while (pView)
3002 			{
3003                 nSelectedPopupEntry --;
3004                 if(nSelectedPopupEntry == 0)
3005 				{
3006 					SetConstantShell(&pView->GetWrtShell());
3007 					break;
3008 				}
3009 				pView = SwModule::GetNextView(pView);
3010 			}
3011             if(nSelectedPopupEntry)
3012 			{
3013                 bViewHasChanged = bIsActive = nSelectedPopupEntry == 1;
3014 				bIsConstant = sal_False;
3015                 Display(nSelectedPopupEntry == 1);
3016 			}
3017 		}
3018 	}
3019 	GetParentWindow()->UpdateListBox();
3020 }
3021 
3022 /***************************************************************************
3023 	Beschreibung:
3024 ***************************************************************************/
3025 
3026 
SetOutlineLevel(sal_uInt8 nSet)3027 void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
3028 {
3029 	nOutlineLevel = nSet;
3030 	pConfig->SetOutlineLevel( nOutlineLevel );
3031 	SwContentType** ppContentT = bIsActive ?
3032 					&aActiveContentArr[CONTENT_TYPE_OUTLINE] :
3033 						&aHiddenContentArr[CONTENT_TYPE_OUTLINE];
3034 	if(*ppContentT)
3035 	{
3036 		(*ppContentT)->SetOutlineLevel(nOutlineLevel);
3037 		(*ppContentT)->Init();
3038 	}
3039 	Display(bIsActive);
3040 }
3041 
3042 /***************************************************************************
3043 	Beschreibung:	Moduswechsel: gedropptes Doc anzeigen
3044 ***************************************************************************/
3045 
3046 
ShowHiddenShell()3047 void SwContentTree::ShowHiddenShell()
3048 {
3049 	if(pHiddenShell)
3050 	{
3051 		bIsConstant = sal_False;
3052 		bIsActive = sal_False;
3053 		Display(sal_False);
3054 	}
3055 }
3056 
3057 /***************************************************************************
3058 	Beschreibung:	Moduswechsel: aktive Sicht anzeigen
3059 ***************************************************************************/
3060 
3061 
ShowActualView()3062 void SwContentTree::ShowActualView()
3063 {
3064 	bIsActive = sal_True;
3065 	bIsConstant = sal_False;
3066 	Display(sal_True);
3067 	GetParentWindow()->UpdateListBox();
3068 }
3069 
3070 /*-----------------20.11.96 13.34-------------------
3071 	Beschreibung: Hier sollen die Buttons zum Verschieben von
3072 				  Outlines en-/disabled werden
3073 --------------------------------------------------*/
3074 
Select(SvLBoxEntry * pEntry,sal_Bool bSelect)3075 sal_Bool  SwContentTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
3076 {
3077 	if(!pEntry)
3078 		return sal_False;
3079 	sal_Bool bEnable = sal_False;
3080 	SvLBoxEntry* pParentEntry = GetParent(pEntry);
3081 	if(!bIsLastReadOnly && (!IsVisible() ||
3082 		((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE && pParentEntry) ||
3083 			(lcl_IsContent(pEntry) && ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE))))
3084 		bEnable = sal_True;
3085 	SwNavigationPI* pNavi = GetParentWindow();
3086 	pNavi->aContentToolBox.EnableItem(FN_ITEM_UP ,  bEnable);
3087 	pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, bEnable);
3088 	pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, bEnable);
3089 	pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT,bEnable);
3090 
3091 	return SvTreeListBox::Select(pEntry, bSelect);
3092 }
3093 
3094 /*-----------------27.11.96 12.56-------------------
3095 
3096 --------------------------------------------------*/
3097 
SetRootType(sal_uInt16 nType)3098 void SwContentTree::SetRootType(sal_uInt16 nType)
3099 {
3100 	nRootType = nType;
3101 	bIsRoot = sal_True;
3102 	pConfig->SetRootType( nRootType );
3103 }
3104 
3105 /*-----------------10.01.97 12.19-------------------
3106 
3107 --------------------------------------------------*/
3108 
RemoveNewline(String & rEntry)3109 void SwContentType::RemoveNewline(String& rEntry)
3110 {
3111 	sal_Unicode* pStr = rEntry.GetBufferAccess();
3112 	for(xub_StrLen i = rEntry.Len(); i; --i, ++pStr )
3113 	{
3114 		if( *pStr == 10 || *pStr == 13 )
3115 			*pStr = 0x20;
3116 	}
3117 }
3118 
3119 /*-----------------14.01.97 16.38-------------------
3120 
3121 --------------------------------------------------*/
3122 
EditEntry(SvLBoxEntry * pEntry,sal_uInt8 nMode)3123 void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode)
3124 {
3125 	SwContent* pCnt = (SwContent*)pEntry->GetUserData();
3126 	GotoContent(pCnt);
3127 	sal_uInt16 nType = pCnt->GetParent()->GetType();
3128 	sal_uInt16 nSlot = 0;
3129 
3130 	uno::Reference< container::XNameAccess >  xNameAccess, xSecond, xThird;
3131 	switch(nType)
3132 	{
3133 		case CONTENT_TYPE_TABLE 	:
3134 			if(nMode == EDIT_UNPROTECT_TABLE)
3135 			{
3136 				pActiveShell->GetView().GetDocShell()->
3137 						GetDoc()->UnProtectCells( pCnt->GetName());
3138 			}
3139 			else if(nMode == EDIT_MODE_DELETE)
3140 			{
3141 				pActiveShell->StartAction();
3142                 String sTable = SW_RES(STR_TABLE_NAME);
3143                 SwRewriter aRewriterTableName;
3144                 aRewriterTableName.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE));
3145                 aRewriterTableName.AddRule(UNDO_ARG2, pCnt->GetName());
3146                 aRewriterTableName.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE));
3147                 sTable = aRewriterTableName.Apply(sTable);
3148 
3149                 SwRewriter aRewriter;
3150                 aRewriter.AddRule(UNDO_ARG1, sTable);
3151 				pActiveShell->StartUndo(UNDO_DELETE, &aRewriter);
3152 				pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
3153 				pActiveShell->DeleteRow();
3154                 pActiveShell->EndUndo();
3155 				pActiveShell->EndAction();
3156 			}
3157 			else if(nMode == EDIT_MODE_RENAME)
3158 			{
3159 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
3160 				uno::Reference< text::XTextTablesSupplier >  xTables(xModel, uno::UNO_QUERY);
3161 				xNameAccess = xTables->getTextTables();
3162 			}
3163 			else
3164 				nSlot = FN_FORMAT_TABLE_DLG;
3165 		break;
3166 
3167 		case CONTENT_TYPE_GRAPHIC   :
3168 			if(nMode == EDIT_MODE_DELETE)
3169 			{
3170 				pActiveShell->DelRight();
3171 			}
3172 			else if(nMode == EDIT_MODE_RENAME)
3173 			{
3174 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
3175 				uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
3176 				xNameAccess = xGraphics->getGraphicObjects();
3177 				uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
3178 				xSecond = xFrms->getTextFrames();
3179 				uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
3180 				xThird = xObjs->getEmbeddedObjects();
3181 			}
3182 			else
3183 				nSlot = FN_FORMAT_GRAFIC_DLG;
3184 		break;
3185 
3186 		case CONTENT_TYPE_FRAME     :
3187 		case CONTENT_TYPE_OLE       :
3188 			if(nMode == EDIT_MODE_DELETE)
3189 			{
3190 				pActiveShell->DelRight();
3191 			}
3192 			else if(nMode == EDIT_MODE_RENAME)
3193 			{
3194 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
3195 				uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
3196 				uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
3197 				if(CONTENT_TYPE_FRAME == nType)
3198 				{
3199 					xNameAccess = xFrms->getTextFrames();
3200 					xSecond = xObjs->getEmbeddedObjects();
3201 				}
3202 				else
3203 				{
3204 					xNameAccess = xObjs->getEmbeddedObjects();
3205 					xSecond = xFrms->getTextFrames();
3206 				}
3207 				uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
3208 				xThird = xGraphics->getGraphicObjects();
3209 			}
3210 			else
3211 				nSlot = FN_FORMAT_FRAME_DLG;
3212 		break;
3213         case CONTENT_TYPE_BOOKMARK  :
3214             if(nMode == EDIT_MODE_DELETE)
3215             {
3216                 IDocumentMarkAccess* const pMarkAccess = pActiveShell->getIDocumentMarkAccess();
3217                 pMarkAccess->deleteMark( pMarkAccess->findMark(pCnt->GetName()) );
3218             }
3219             else if(nMode == EDIT_MODE_RENAME)
3220             {
3221                 uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
3222                 uno::Reference< text::XBookmarksSupplier >  xBkms(xModel, uno::UNO_QUERY);
3223                 xNameAccess = xBkms->getBookmarks();
3224             }
3225             else
3226                 nSlot = FN_INSERT_BOOKMARK;
3227         break;
3228 
3229 		case CONTENT_TYPE_REGION    :
3230 			if(nMode == EDIT_MODE_RENAME)
3231 			{
3232 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
3233 				uno::Reference< text::XTextSectionsSupplier >  xSects(xModel, uno::UNO_QUERY);
3234 				xNameAccess = xSects->getTextSections();
3235 			}
3236 			else
3237 				nSlot = FN_EDIT_REGION;
3238 		break;
3239 
3240 		case CONTENT_TYPE_URLFIELD:
3241 			nSlot = FN_EDIT_HYPERLINK;
3242 		break;
3243 		case CONTENT_TYPE_REFERENCE:
3244 			nSlot = FN_EDIT_FIELD;
3245 		break;
3246 
3247 		case CONTENT_TYPE_POSTIT:
3248 			pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
3249 			if(nMode == EDIT_MODE_DELETE)
3250 			{
3251 				if (((SwPostItContent*)pCnt)->IsPostIt())
3252 				{
3253                     pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0);
3254 					pActiveShell->DelRight();
3255 				}
3256 				/*
3257 				//	this code can be used once we want redline comments in the margin
3258 				else
3259 				{
3260 					SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline());
3261 					if (pComment)
3262 						pComment->Delete();
3263 				}
3264 				*/
3265 			}
3266 			else
3267 			{
3268 				if (((SwPostItContent*)pCnt)->IsPostIt())
3269 					nSlot = FN_POSTIT;
3270 				else
3271 					nSlot = FN_REDLINE_COMMENT;
3272 			}
3273 		break;
3274 		case CONTENT_TYPE_INDEX:
3275 		{
3276 			const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase();
3277 			switch(nMode)
3278 			{
3279 				case EDIT_MODE_EDIT:
3280 					if(pBase)
3281 					{
3282 						SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, (void*)pBase);
3283 						pActiveShell->GetView().GetViewFrame()->
3284 							GetDispatcher()->Execute(FN_INSERT_MULTI_TOX,
3285 											SFX_CALLMODE_ASYNCHRON, &aPtrItem, 0L);
3286 
3287 					}
3288 				break;
3289 				case EDIT_MODE_RMV_IDX:
3290 				case EDIT_MODE_DELETE:
3291 				{
3292 					if( pBase )
3293 						pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode);
3294 				}
3295 				break;
3296 				case EDIT_MODE_UPD_IDX:
3297 				case EDIT_MODE_RENAME:
3298 				{
3299 					Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
3300 					Reference< XDocumentIndexesSupplier >  xIndexes(xModel, UNO_QUERY);
3301 					Reference< XIndexAccess> xIdxAcc(xIndexes->getDocumentIndexes());
3302 					Reference< XNameAccess >xLocalNameAccess(xIdxAcc, UNO_QUERY);
3303 					if(EDIT_MODE_RENAME == nMode)
3304 						xNameAccess = xLocalNameAccess;
3305 					else if(xLocalNameAccess.is() && xLocalNameAccess->hasByName(pBase->GetTOXName()))
3306 					{
3307 						Any aIdx = xLocalNameAccess->getByName(pBase->GetTOXName());
3308 						Reference< XDocumentIndex> xIdx;
3309 						if(aIdx >>= xIdx)
3310 							xIdx->update();
3311 					}
3312 				}
3313 				break;
3314 			}
3315 		}
3316 		break;
3317         case CONTENT_TYPE_DRAWOBJECT :
3318             if(EDIT_MODE_DELETE == nMode)
3319                 nSlot = SID_DELETE;
3320         break;
3321 	}
3322 	if(nSlot)
3323 		pActiveShell->GetView().GetViewFrame()->
3324 					GetDispatcher()->Execute(nSlot, SFX_CALLMODE_ASYNCHRON);
3325 	else if(xNameAccess.is())
3326 	{
3327 		uno::Any aObj = xNameAccess->getByName(pCnt->GetName());
3328         uno::Reference< uno::XInterface >  xTmp;
3329         aObj >>= xTmp;
3330 		uno::Reference< container::XNamed >  xNamed(xTmp, uno::UNO_QUERY);
3331         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
3332         DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
3333 
3334         AbstractSwRenameXNamedDlg* pDlg = pFact->CreateSwRenameXNamedDlg( this, xNamed, xNameAccess, DLG_RENAME_XNAMED );
3335         DBG_ASSERT(pDlg, "Dialogdiet fail!");
3336 		if(xSecond.is())
3337             pDlg->SetAlternativeAccess( xSecond, xThird);
3338 
3339 		String sForbiddenChars;
3340 		if(CONTENT_TYPE_BOOKMARK == nType)
3341 		{
3342             sForbiddenChars = C2S("/\\@:*?\";,.#");
3343 		}
3344 		else if(CONTENT_TYPE_TABLE == nType)
3345 		{
3346 			sForbiddenChars = C2S(" .<>");
3347 		}
3348         pDlg->SetForbiddenChars(sForbiddenChars);
3349         pDlg->Execute();
3350         delete pDlg;
3351 	}
3352 }
3353 
3354 /*-----------------14.01.97 16.53-------------------
3355 
3356 --------------------------------------------------*/
3357 
GotoContent(SwContent * pCnt)3358 void SwContentTree::GotoContent(SwContent* pCnt)
3359 {
3360 	pActiveShell->EnterStdMode();
3361 
3362 	sal_Bool bSel = sal_False;
3363 	sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
3364 	switch(nJumpType)
3365 	{
3366 		case CONTENT_TYPE_OUTLINE	:
3367 		{
3368 			pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos());
3369 		}
3370 		break;
3371 		case CONTENT_TYPE_TABLE 	:
3372 		{
3373 			pActiveShell->GotoTable(pCnt->GetName());
3374 		}
3375 		break;
3376 		case CONTENT_TYPE_FRAME     :
3377 		case CONTENT_TYPE_GRAPHIC   :
3378 		case CONTENT_TYPE_OLE       :
3379 		{
3380 			if(pActiveShell->GotoFly(pCnt->GetName()))
3381 				bSel = sal_True;
3382 		}
3383 		break;
3384         case CONTENT_TYPE_BOOKMARK:
3385         {
3386             pActiveShell->GotoMark(pCnt->GetName());
3387         }
3388 		break;
3389 		case CONTENT_TYPE_REGION    :
3390 		{
3391 			pActiveShell->GotoRegion(pCnt->GetName());
3392 		}
3393 		break;
3394 		case CONTENT_TYPE_URLFIELD:
3395 		{
3396 			if(pActiveShell->GotoINetAttr(
3397 							*((SwURLFieldContent*)pCnt)->GetINetAttr() ))
3398 			{
3399 				pActiveShell->Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False);
3400 				pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, sal_True );
3401 			}
3402 
3403 		}
3404 		break;
3405 		case CONTENT_TYPE_REFERENCE:
3406 		{
3407 			pActiveShell->GotoRefMark(pCnt->GetName());
3408 		}
3409 		break;
3410 		case CONTENT_TYPE_INDEX:
3411 		{
3412 			if (!pActiveShell->GotoNextTOXBase(&pCnt->GetName()))
3413 				pActiveShell->GotoPrevTOXBase(&pCnt->GetName());
3414 		}
3415 		break;
3416 		case CONTENT_TYPE_POSTIT:
3417 			pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
3418 			if (((SwPostItContent*)pCnt)->IsPostIt())
3419 				pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt());
3420 			else
3421 				pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline(
3422 						pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData()));
3423 
3424 		break;
3425 		case CONTENT_TYPE_DRAWOBJECT:
3426         {
3427             SdrView* pDrawView = pActiveShell->GetDrawView();
3428 			if (pDrawView)
3429 			{
3430 				pDrawView->SdrEndTextEdit();
3431 				pDrawView->UnmarkAll();
3432                 SwDrawModel* _pModel = pActiveShell->getIDocumentDrawModelAccess()->GetDrawModel();
3433                 SdrPage* pPage = _pModel->GetPage(0);
3434                 sal_uInt32 nCount = pPage->GetObjCount();
3435                 for( sal_uInt32 i=0; i< nCount; i++ )
3436                 {
3437                     SdrObject* pTemp = pPage->GetObj(i);
3438                     // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
3439 //                    if(pTemp->ISA(SdrObjGroup) && pTemp->GetName() == pCnt->GetName())
3440                     if ( pTemp->GetName() == pCnt->GetName() )
3441                     // <--
3442                     {
3443                         SdrPageView* pPV = pDrawView->GetSdrPageView();
3444                         if( pPV )
3445                         {
3446                             pDrawView->MarkObj( pTemp, pPV );
3447                         }
3448                     }
3449                 }
3450             }
3451         }
3452 		break;
3453 	}
3454 	if(bSel)
3455 	{
3456 		pActiveShell->HideCrsr();
3457 		pActiveShell->EnterSelFrmMode();
3458 	}
3459 	SwView& rView = pActiveShell->GetView();
3460 	rView.StopShellTimer();
3461     rView.GetPostItMgr()->SetActiveSidebarWin(0);
3462 	rView.GetEditWin().GrabFocus();
3463 }
3464 /*-----------------06.02.97 19.14-------------------
3465     Jetzt noch die passende text::Bookmark
3466 --------------------------------------------------*/
3467 
NaviContentBookmark()3468 NaviContentBookmark::NaviContentBookmark()
3469     :
3470     nDocSh(0),
3471     nDefDrag( REGION_MODE_NONE )
3472 {
3473 }
3474 
3475 /*-----------------06.02.97 20.12-------------------
3476 
3477 --------------------------------------------------*/
3478 
NaviContentBookmark(const String & rUrl,const String & rDesc,sal_uInt16 nDragType,const SwDocShell * pDocSh)3479 NaviContentBookmark::NaviContentBookmark( const String &rUrl,
3480 					const String& rDesc,
3481 					sal_uInt16 nDragType,
3482 					const SwDocShell* pDocSh ) :
3483 	aUrl( rUrl ),
3484 	aDescr(rDesc),
3485     nDocSh((long)pDocSh),
3486     nDefDrag( nDragType )
3487 {
3488 }
3489 
Copy(TransferDataContainer & rData) const3490 void NaviContentBookmark::Copy( TransferDataContainer& rData ) const
3491 {
3492 	rtl_TextEncoding eSysCSet = gsl_getSystemTextEncoding();
3493 
3494 	ByteString sStr( aUrl, eSysCSet );
3495 	sStr += static_cast< char >(NAVI_BOOKMARK_DELIM);
3496 	sStr += ByteString( aDescr, eSysCSet );
3497 	sStr += static_cast< char >(NAVI_BOOKMARK_DELIM);
3498 	sStr += ByteString::CreateFromInt32( nDefDrag );
3499 	sStr += static_cast< char >(NAVI_BOOKMARK_DELIM);
3500 	sStr += ByteString::CreateFromInt32( nDocSh );
3501 	rData.CopyByteString( SOT_FORMATSTR_ID_SONLK, sStr );
3502 }
3503 
Paste(TransferableDataHelper & rData)3504 sal_Bool NaviContentBookmark::Paste( TransferableDataHelper& rData )
3505 {
3506 	String sStr;
3507 	sal_Bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr );
3508 	if( bRet )
3509 	{
3510 		xub_StrLen nPos = 0;
3511 		aUrl	= sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos );
3512 		aDescr	= sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos );
3513         nDefDrag= (sal_uInt16)sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32();
3514 		nDocSh	= sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32();
3515 	}
3516 	return bRet;
3517 }
3518 
3519 
3520 /* -----------------------------09.12.99 13:50--------------------------------
3521 
3522  ---------------------------------------------------------------------------*/
3523 class SwContentLBoxString : public SvLBoxString
3524 {
3525 public:
SwContentLBoxString(SvLBoxEntry * pEntry,sal_uInt16 nFlags,const String & rStr)3526 	SwContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
3527 		const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr)	{}
3528 
3529 	virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
3530 		SvLBoxEntry* pEntry);
3531 };
3532 
3533 /* -----------------------------09.12.99 13:49--------------------------------
3534 
3535  ---------------------------------------------------------------------------*/
InitEntry(SvLBoxEntry * pEntry,const XubString & rStr,const Image & rImg1,const Image & rImg2,SvLBoxButtonKind eButtonKind)3536 void SwContentTree::InitEntry(SvLBoxEntry* pEntry,
3537 		const XubString& rStr ,const Image& rImg1,const Image& rImg2,
3538         SvLBoxButtonKind eButtonKind)
3539 {
3540 	sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
3541 	SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
3542 	SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
3543 	SwContentLBoxString* pStr = new SwContentLBoxString( pEntry, 0, pCol->GetText() );
3544 	pEntry->ReplaceItem( pStr, nColToHilite );
3545 }
3546 /* -----------------------------09.12.99 13:49--------------------------------
3547 
3548  ---------------------------------------------------------------------------*/
Paint(const Point & rPos,SvLBox & rDev,sal_uInt16 nFlags,SvLBoxEntry * pEntry)3549 void SwContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
3550 	SvLBoxEntry* pEntry )
3551 {
3552 	if(lcl_IsContent(pEntry) &&
3553 			((SwContent *)pEntry->GetUserData())->IsInvisible())
3554 	{
3555 		//* pCont = (SwContent*)pEntry->GetUserData();
3556 		Font aOldFont( rDev.GetFont());
3557 		Font aFont(aOldFont);
3558 		Color aCol( COL_LIGHTGRAY );
3559 		aFont.SetColor( aCol );
3560 		rDev.SetFont( aFont );
3561 		rDev.DrawText( rPos, GetText() );
3562 		rDev.SetFont( aOldFont );
3563 	}
3564 	// IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this
3565 	/*
3566 	else if (pEntry->IsMarked())
3567 	{
3568 			rDev.DrawText( rPos, GetText() );
3569 			XubString str;
3570 			str = XubString::CreateFromAscii("*");
3571 			Point rPosStar(rPos.X()-6,rPos.Y());
3572 			Font aOldFont( rDev.GetFont());
3573 			Font aFont(aOldFont);
3574 			Color aCol( aOldFont.GetColor() );
3575 			aCol.DecreaseLuminance( 200 );
3576 			aFont.SetColor( aCol );
3577 			rDev.SetFont( aFont );
3578 			rDev.DrawText( rPosStar, str);
3579 			rDev.SetFont( aOldFont );
3580 	}
3581 	*/
3582 	else
3583 		SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
3584 }
3585 /* -----------------------------06.05.2002 10:20------------------------------
3586 
3587  ---------------------------------------------------------------------------*/
DataChanged(const DataChangedEvent & rDCEvt)3588 void SwContentTree::DataChanged( const DataChangedEvent& rDCEvt )
3589 {
3590   if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
3591          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
3592     {
3593         sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP;
3594         aEntryImages = ImageList(SW_RES(nResId));
3595         FindActiveTypeAndRemoveUserData();
3596         Display(sal_True);
3597     }
3598     SvTreeListBox::DataChanged( rDCEvt );
3599 }
3600 
3601 
GetEntryRealChildsNum(SvLBoxEntry * pParent) const3602 sal_Int32  SwContentTree::GetEntryRealChildsNum( SvLBoxEntry* pParent ) const
3603 {
3604 	// ist es ein Inhaltstyp?
3605 	if(lcl_IsContentType(pParent))
3606 	{
3607 		if(!pParent->HasChilds())
3608 		{
3609 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
3610 			return pCntType->GetMemberCount();
3611 		}
3612 	}
3613 	return 0;
3614 }
3615