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