update dev300-m58
[ooovba.git] / sd / source / ui / view / outlview.cxx
blob79419148b77fc25040c9b66c7cea8739f0876018
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outlview.cxx,v $
10 * $Revision: 1.52 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "OutlineView.hxx"
35 #include <memory>
36 #include <svx/forbiddencharacterstable.hxx>
37 #include <sfx2/progress.hxx>
38 #include <vcl/wrkwin.hxx>
39 #include <svx/svxids.hrc>
40 #include "eetext.hxx"
41 #include <svx/eeitem.hxx>
42 #include <svx/editstat.hxx>
43 #include <svx/lrspitem.hxx>
44 #include <svx/svdotext.hxx>
45 #include <sfx2/printer.hxx>
46 #include <sfx2/imagemgr.hxx>
47 #include <sfx2/app.hxx>
48 #include <sfx2/bindings.hxx>
49 #include <svtools/itempool.hxx>
50 #include <svtools/style.hxx>
51 #include <svx/svdorect.hxx>
52 #include <svx/svdundo.hxx>
53 #include <svtools/brdcst.hxx>
54 #include <vcl/msgbox.hxx>
55 #include <svx/adjitem.hxx>
56 #include <svx/tstpitem.hxx>
57 #include <svx/lspcitem.hxx>
58 #include <svx/numitem.hxx>
59 #include <svx/outlobj.hxx>
60 #include <svx/numitem.hxx>
61 #include <svx/editeng.hxx>
63 // #97766#
64 #include <svx/editobj.hxx>
65 #include <svx/editund2.hxx>
67 #include <svx/editview.hxx>
68 #include <svx/svxfont.hxx>
69 #include <svx/fhgtitem.hxx>
71 #include "DrawDocShell.hxx"
72 #include "drawdoc.hxx"
73 #include "Window.hxx"
74 #include "sdpage.hxx"
75 #include "pres.hxx"
76 #include "OutlineViewShell.hxx"
77 #include "app.hrc"
78 #include "glob.hrc"
79 #include "sdresid.hxx"
80 #include "Outliner.hxx"
81 #include "strings.hrc"
82 #include "EventMultiplexer.hxx"
83 #include "ViewShellBase.hxx"
84 #include "undo/undoobjects.hxx"
85 #include "undo/undomanager.hxx"
86 #include "stlsheet.hxx"
88 using ::rtl::OUString;
89 using namespace ::com::sun::star::uno;
90 using namespace ::com::sun::star::frame;
92 namespace sd {
94 // Breite: DIN A 4, zwei Raender zu je 1 cm
95 #define OUTLINE_PAPERWIDTH 19000
97 // beim Seitenmanipulation Fortschrittsanzeige, wenn mehr Seiten betroffen
98 // sind als:
99 #define PROCESS_WITH_PROGRESS_THRESHOLD 5
101 struct SdParaAndPos
103 Paragraph* pPara;
104 USHORT nPos;
107 TYPEINIT1( OutlineView, ::sd::View );
109 /*************************************************************************
111 |* Konstruktor
113 \************************************************************************/
115 OutlineView::OutlineView( DrawDocShell* pDocSh, ::Window* pWindow, OutlineViewShell* pOutlineViewSh)
116 : ::sd::View(pDocSh->GetDoc(), pWindow, pOutlineViewSh)
117 , mpOutlineViewShell(pOutlineViewSh)
118 , mpOutliner( mpDoc->GetOutliner(TRUE) )
119 , mpOldParaOrder(NULL)
120 , mpSelectedParas(NULL)
121 , mnPagesToProcess(0)
122 , mnPagesProcessed(0)
123 , mbFirstPaint(TRUE)
124 , mpProgress(NULL)
125 , mbHighContrastMode( false )
126 , maDocColor( COL_WHITE )
127 , mnPageNumberWidthPixel( 0 )
128 , maLRSpaceItem( 0, 0, 2000, 0, EE_PARA_OUTLLRSPACE )
130 BOOL bInitOutliner = FALSE;
132 if (mpOutliner->GetViewCount() == 0)
134 // Outliner initialisieren: Referenz-Device setzen
135 bInitOutliner = TRUE;
136 mpOutliner->Init( OUTLINERMODE_OUTLINEVIEW );
138 SfxStyleSheet* pTitleSheet = mpDoc->GetSdPage( 0, PK_STANDARD )->GetStyleSheetForPresObj( PRESOBJ_TITLE );
140 if ( pTitleSheet )
142 // set title symbol (level 0)
143 SvxNumBulletItem aNumBulletItem( (const SvxNumBulletItem&) pTitleSheet->GetItemSet().Get(EE_PARA_NUMBULLET) );
144 SvxNumRule aNumRule(* aNumBulletItem.GetNumRule());
145 SvxNumberFormat aFormat( aNumRule.GetLevel(0));
146 Font aBulletFont;
147 const Font* pFont = aFormat.GetBulletFont();
148 if ( pFont ) // if available take font size and color from style
149 aBulletFont = *pFont;
150 else
152 aBulletFont.SetColor( COL_AUTO );
153 aBulletFont.SetHeight( 1552 );
155 aBulletFont.SetCharSet(RTL_TEXTENCODING_MS_1252); // and replacing other values by standard
156 aBulletFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" )) );
157 aBulletFont.SetWeight(WEIGHT_NORMAL);
158 aBulletFont.SetUnderline(UNDERLINE_NONE);
159 aBulletFont.SetStrikeout(STRIKEOUT_NONE);
160 aBulletFont.SetItalic(ITALIC_NONE);
161 aBulletFont.SetOutline(FALSE);
162 aBulletFont.SetShadow(FALSE);
163 aFormat.SetBulletFont( &aBulletFont );
164 aFormat.SetBulletChar( 0xE011 ); // StarBats: 0xF000 + 114
165 mpOutliner->OverwriteLevel0Bullet( aFormat );
168 mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *pDocSh ) );
169 ULONG nWidth = OUTLINE_PAPERWIDTH;
170 mpOutliner->SetPaperSize(Size(nWidth, 400000000));
173 // View in Outliner einfuegen
174 for (USHORT nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
176 mpOutlinerView[nView] = NULL;
179 mpOutlinerView[0] = new OutlinerView(mpOutliner, pWindow);
180 Rectangle aNullRect;
181 mpOutlinerView[0]->SetOutputArea(aNullRect);
182 mpOutliner->SetUpdateMode(FALSE);
183 mpOutliner->InsertView(mpOutlinerView[0], LIST_APPEND);
185 onUpdateStyleSettings( true );
187 if (bInitOutliner)
189 // Outliner mit Inhalt fuellen
190 FillOutliner();
193 Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
194 mpOutlineViewShell->GetViewShellBase().GetEventMultiplexer()->AddEventListener(
195 aLink,
196 tools::EventMultiplexerEvent::EID_CURRENT_PAGE
197 | tools::EventMultiplexerEvent::EID_PAGE_ORDER);
199 LanguageType eLang = mpOutliner->GetDefaultLanguage();
200 maPageNumberFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE, eLang, 0 );
201 maPageNumberFont.SetHeight( 500 );
203 maBulletFont.SetColor( COL_AUTO );
204 maBulletFont.SetHeight( 1000 );
205 maBulletFont.SetCharSet(RTL_TEXTENCODING_MS_1252); // and replacing other values by standard
206 maBulletFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" )) );
207 maBulletFont.SetWeight(WEIGHT_NORMAL);
208 maBulletFont.SetUnderline(UNDERLINE_NONE);
209 maBulletFont.SetStrikeout(STRIKEOUT_NONE);
210 maBulletFont.SetItalic(ITALIC_NONE);
211 maBulletFont.SetOutline(FALSE);
212 maBulletFont.SetShadow(FALSE);
215 Reference<XFrame> xFrame (mpOutlineViewShell->GetViewShellBase().GetFrame()->GetTopFrame()->GetFrameInterface(), UNO_QUERY);
217 const OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( ".uno:ShowSlide" ));
218 maSlideImage = GetImage( xFrame, aSlotURL, true, false /* todo, hc mode */ );
220 // Tell undo manager of the document about the undo manager of the
221 // outliner, so that the former can synchronize with the later.
222 sd::UndoManager* pDocUndoMgr = dynamic_cast<sd::UndoManager*>(mpDocSh->GetUndoManager());
223 if (pDocUndoMgr != NULL)
224 pDocUndoMgr->SetLinkedUndoManager(&mpOutliner->GetUndoManager());
227 /*************************************************************************
229 |* Destruktor, Links restaurieren, Outliner leeren
231 \************************************************************************/
233 OutlineView::~OutlineView()
235 DBG_ASSERT(maDragAndDropModelGuard.get() == 0, "sd::OutlineView::~OutlineView(), prior drag operation not finished correctly!" );
237 Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
238 mpOutlineViewShell->GetViewShellBase().GetEventMultiplexer()->RemoveEventListener( aLink );
239 DisconnectFromApplication();
241 if( mpProgress )
242 delete mpProgress;
244 // OutlinerViews abmelden und zerstoeren
245 for (USHORT nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
247 if (mpOutlinerView[nView] != NULL)
249 mpOutliner->RemoveView( mpOutlinerView[nView] );
250 delete mpOutlinerView[nView];
251 mpOutlinerView[nView] = NULL;
255 if (mpOutliner->GetViewCount() == 0)
257 // Outliner deinitialisieren: Farbdarstellung einschalten
258 ResetLinks();
259 ULONG nCntrl = mpOutliner->GetControlWord();
260 mpOutliner->SetUpdateMode(FALSE); // sonst wird bei SetControlWord gezeichnet
261 mpOutliner->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS);
262 SvtAccessibilityOptions aOptions;
263 mpOutliner->ForceAutoColor( aOptions.GetIsAutomaticFontColor() );
264 mpOutliner->Clear();
267 DBG_ASSERT(!mpSelectedParas, "Absatzliste nicht geloescht");
268 DBG_ASSERT(!mpOldParaOrder, "Absatzliste nicht geloescht");
274 void OutlineView::ConnectToApplication (void)
276 mpOutlineViewShell->GetActiveWindow()->GrabFocus();
277 Application::AddEventListener(LINK(this, OutlineView, AppEventListenerHdl));
283 void OutlineView::DisconnectFromApplication (void)
285 Application::RemoveEventListener(LINK(this, OutlineView, AppEventListenerHdl));
291 /*************************************************************************
293 |* Paint-Methode
295 \************************************************************************/
297 void OutlineView::Paint(const Rectangle& rRect, ::sd::Window* pWin)
299 OutlinerView* pOlView = GetViewByWindow(pWin);
301 if (pOlView)
303 pOlView->HideCursor();
304 pOlView->Paint(rRect);
306 pOlView->ShowCursor(mbFirstPaint);
309 if( mnPageNumberWidthPixel == 0 )
310 GetPageNumberWidthPixel();
312 const ULONG nParaCount = pOlView->GetOutliner()->GetParagraphCount();
313 EditView& rEditView = pOlView->GetEditView();
315 Font aOldFont( pWin->GetFont() );
317 const String aBulletStr( sal_Unicode( 0xE011 ) );
318 pWin->SetFont( maBulletFont);
319 sal_Int32 nBulletWidth = pWin->GetTextWidth(aBulletStr);
321 sal_Int32 nPage = 1;
322 for( ULONG nPara = 0; nPara < nParaCount; nPara++ )
324 Paragraph* pPara = pOlView->GetOutliner()->GetParagraph( nPara );
325 if( pPara->HasFlag( PARAFLAG_ISPAGE ) )
327 pWin->SetFont( maPageNumberFont );
328 const String aStr( String::CreateFromInt32( nPage++ ) );
329 Point aPos( rEditView.GetWindowPosTopLeft( (USHORT)nPara ) );
331 sal_Int32 nNumberOffset = pWin->PixelToLogic( Point(mnPageNumberWidthPixel, 0) ).X() - nBulletWidth;
332 sal_Int32 nLineHeight = pOlView->GetOutliner()->GetLineHeight( nPara, 0 );
334 aPos.X() = nNumberOffset;
336 Point aPoint( aPos.X() - pWin->GetTextWidth( aStr ), aPos.Y() + ( nLineHeight - maPageNumberFont.GetHeight()) / 2 );
337 pWin->DrawText( aPoint, aStr );
339 aPoint.X() = aPos.X();
340 aPoint.Y() = aPos.Y() +( nLineHeight - maBulletFont.GetHeight()) / 2;
341 pWin->SetFont( maBulletFont );
342 pWin->DrawText( aPoint, aBulletStr );
346 pWin->SetFont( aOldFont );
348 mbFirstPaint = FALSE;
352 void OutlineView::InvalidateSlideNumberArea()
355 for( sal_Int16 nView = 0; nView < MAX_OUTLINERVIEWS; ++nView )
357 if (mpOutlinerView[nView] != NULL)
359 ::Window* pWindow = mpOutlinerView[nView]->GetWindow();
360 if( pWindow )
362 Rectangle aRect( Point(0,0), pWindow->GetOutputSize() );
363 aRect.nRight = aRect.nLeft + pWindow->PixelToLogic( Point( mnPageNumberWidthPixel, 0 ) ).X() * 2;
365 pWindow->Invalidate(aRect);
372 /*************************************************************************
374 |* Fenster-Groesse hat sich geaendert
376 \************************************************************************/
378 void OutlineView::AdjustPosSizePixel(const Point &,const Size &,::sd::Window*)
382 /*************************************************************************
384 |* ein Fenster hinzufuegen
386 \************************************************************************/
388 void OutlineView::AddWindowToPaintView(OutputDevice* pWin)
390 BOOL bAdded = FALSE;
391 BOOL bValidArea = FALSE;
392 Rectangle aOutputArea;
393 const Color aWhiteColor( COL_WHITE );
394 USHORT nView = 0;
396 while (nView < MAX_OUTLINERVIEWS && !bAdded)
398 if (mpOutlinerView[nView] == NULL)
400 mpOutlinerView[nView] = new OutlinerView(mpOutliner, dynamic_cast< ::sd::Window* >(pWin));
401 mpOutlinerView[nView]->SetBackgroundColor( aWhiteColor );
402 mpOutliner->InsertView(mpOutlinerView[nView], LIST_APPEND);
403 bAdded = TRUE;
405 if (bValidArea)
407 mpOutlinerView[nView]->SetOutputArea(aOutputArea);
410 else if (!bValidArea)
412 aOutputArea = mpOutlinerView[nView]->GetOutputArea();
413 bValidArea = TRUE;
416 nView++;
419 // weisser Hintergrund im Outliner
420 pWin->SetBackground( Wallpaper( aWhiteColor ) );
422 ::sd::View::AddWindowToPaintView(pWin);
425 /*************************************************************************
427 |* ein Fenster entfernen
429 \************************************************************************/
431 void OutlineView::DeleteWindowFromPaintView(OutputDevice* pWin)
433 BOOL bRemoved = FALSE;
434 USHORT nView = 0;
435 ::Window* pWindow;
437 while (nView < MAX_OUTLINERVIEWS && !bRemoved)
439 if (mpOutlinerView[nView] != NULL)
441 pWindow = mpOutlinerView[nView]->GetWindow();
443 if (pWindow == pWin)
445 mpOutliner->RemoveView( mpOutlinerView[nView] );
446 delete mpOutlinerView[nView];
447 mpOutlinerView[nView] = NULL;
448 bRemoved = TRUE;
452 nView++;
455 ::sd::View::DeleteWindowFromPaintView(pWin);
458 /*************************************************************************
460 |* Zeiger der dem Fenster entsprechenden OutlinerView zurueckgeben.
462 \************************************************************************/
464 OutlinerView* OutlineView::GetViewByWindow (::Window* pWin) const
466 OutlinerView* pOlView = NULL;
467 for (USHORT nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
469 if (mpOutlinerView[nView] != NULL)
471 if ( pWin == mpOutlinerView[nView]->GetWindow() )
473 pOlView = mpOutlinerView[nView];
477 return (pOlView);
481 /*************************************************************************
483 |* Ermittelt den Titel vor einem beliebigen Absatz.
485 \************************************************************************/
487 Paragraph* OutlineView::GetPrevTitle(const Paragraph* pPara)
489 sal_Int32 nPos = mpOutliner->GetAbsPos(const_cast<Paragraph*>(pPara));
491 if (nPos > 0)
493 while(nPos)
495 pPara = mpOutliner->GetParagraph(--nPos);
496 if( mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
498 return const_cast< Paragraph* >( pPara );
503 return NULL;
506 /*************************************************************************
508 |* Ermittelt den Titel nach einem beliebigen Absatz.
510 \************************************************************************/
512 Paragraph* OutlineView::GetNextTitle(const Paragraph* pPara)
514 Paragraph* pResult = const_cast< Paragraph* >( pPara );
516 sal_Int32 nPos = mpOutliner->GetAbsPos(pResult);
520 pResult = mpOutliner->GetParagraph(++nPos);
521 if( pResult && mpOutliner->HasParaFlag(pResult, PARAFLAG_ISPAGE) )
522 return pResult;
524 while( pResult );
526 return NULL;
529 /*************************************************************************
531 |* Handler fuer das Einfuegen von Seiten (Absaetzen)
533 \************************************************************************/
535 IMPL_LINK( OutlineView, ParagraphInsertedHdl, ::Outliner *, pOutliner )
537 // DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::ParagraphInsertedHdl(), model change without undo?!" );
539 // we get calls to this handler during binary insert of drag and drop contents but
540 // we ignore it here and handle it later in OnEndPasteOrDrop()
541 if( maDragAndDropModelGuard.get() == 0 )
543 OutlineViewPageChangesGuard aGuard(this);
545 Paragraph* pPara = pOutliner->GetHdlParagraph();
547 USHORT nAbsPos = (USHORT)mpOutliner->GetAbsPos( pPara );
549 UpdateParagraph( nAbsPos );
551 if( (nAbsPos == 0) || mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) || mpOutliner->HasParaFlag(mpOutliner->GetParagraph( nAbsPos-1 ), PARAFLAG_ISPAGE) )
553 InsertSlideForParagraph( pPara );
554 InvalidateSlideNumberArea();
558 return 0;
561 /** creates and inserts an empty slide for the given paragraph */
562 SdPage* OutlineView::InsertSlideForParagraph( Paragraph* pPara )
564 DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::InsertSlideForParagraph(), model change without undo?!" );
566 OutlineViewPageChangesGuard aGuard(this);
568 mpOutliner->SetParaFlag( pPara, PARAFLAG_ISPAGE );
569 // wieviele Titel sind vor dem neuen Titelabsatz?
570 ULONG nExample = 0L; // Position der "Vorbild"seite
571 ULONG nTarget = 0L; // Einfuegeposition
572 while(pPara)
574 pPara = GetPrevTitle(pPara);
575 if (pPara)
576 nTarget++;
580 // was der Outliner nicht kann, muss hier wieder wettgemacht werden:
581 // wenn VOR dem ersten Absatz ein neuer Absatz mit RETURN erzeugt wird,
582 // meldet der Outliner den bereits bestehenden (jetzt nach unten
583 // gerutschten) Absatz als neuen Absatz; nicht darauf reinfallen!
584 if (nTarget == 1)
586 String aTest(mpOutliner->GetText( mpOutliner->GetParagraph( 0 ) ));
587 if (aTest.Len() == 0)
589 nTarget = 0;
594 // "Vorbild"seite ist - wenn vorhanden - die Vorgaengerseite
595 if (nTarget > 0)
597 nExample = nTarget - 1;
599 USHORT nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
600 if( nExample >= nPageCount )
601 nExample = nPageCount - 1;
604 /**********************************************************************
605 * Es wird stets zuerst eine Standardseite und dann eine
606 * Notizseite erzeugt. Es ist sichergestellt, dass auf eine
607 * Standardseite stets die zugehoerige Notizseite folgt.
608 * Vorangestellt ist genau eine Handzettelseite
609 **********************************************************************/
611 // diese Seite hat Vorbildfunktion
612 SdPage* pExample = (SdPage*)mpDoc->GetSdPage((USHORT)nExample, PK_STANDARD);
613 SdPage* pPage = (SdPage*)mpDoc->AllocPage(FALSE);
615 pPage->SetLayoutName(pExample->GetLayoutName());
617 // einfuegen (Seite)
618 mpDoc->InsertPage(pPage, (USHORT)(nTarget) * 2 + 1);
619 if( isRecordingUndo() )
620 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
622 // der Standardseite eine Masterpage zuweisen
623 pPage->TRG_SetMasterPage(pExample->TRG_GetMasterPage());
625 // Seitengroesse setzen
626 pPage->SetSize(pExample->GetSize());
627 pPage->SetBorder( pExample->GetLftBorder(),
628 pExample->GetUppBorder(),
629 pExample->GetRgtBorder(),
630 pExample->GetLwrBorder() );
632 // neue Praesentationsobjekte anlegen (auf <Titel> oder
633 // <Titel mit Untertitel> folgt <Titel mit Gliederung>, ansonsten
634 // wird das Layout von der Vorgaengerseite uebernommen)
635 AutoLayout eAutoLayout = pExample->GetAutoLayout();
636 if (eAutoLayout == AUTOLAYOUT_TITLE ||
637 eAutoLayout == AUTOLAYOUT_ONLY_TITLE)
639 pPage->SetAutoLayout(AUTOLAYOUT_ENUM, TRUE);
641 else
643 pPage->SetAutoLayout(pExample->GetAutoLayout(), TRUE);
646 /**********************************************************************
647 |* jetzt die Notizseite
648 \*********************************************************************/
649 pExample = (SdPage*)mpDoc->GetSdPage((USHORT)nExample, PK_NOTES);
650 SdPage* pNotesPage = (SdPage*)mpDoc->AllocPage(FALSE);
652 pNotesPage->SetLayoutName(pExample->GetLayoutName());
654 pNotesPage->SetPageKind(PK_NOTES);
656 // einfuegen (Notizseite)
657 mpDoc->InsertPage(pNotesPage, (USHORT)(nTarget) * 2 + 2);
658 if( isRecordingUndo() )
659 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
661 // der Notizseite eine Masterpage zuweisen
662 pNotesPage->TRG_SetMasterPage(pExample->TRG_GetMasterPage());
664 // Seitengroesse setzen, es muss bereits eine Seite vorhanden sein
665 pNotesPage->SetSize(pExample->GetSize());
666 pNotesPage->SetBorder( pExample->GetLftBorder(),
667 pExample->GetUppBorder(),
668 pExample->GetRgtBorder(),
669 pExample->GetLwrBorder() );
671 // neue Praesentationsobjekte anlegen
672 pNotesPage->SetAutoLayout(pExample->GetAutoLayout(), TRUE);
674 mpOutliner->UpdateFields();
676 return pPage;
679 /*************************************************************************
681 |* Handler fuer das Loeschen von Seiten (Absaetzen)
683 \************************************************************************/
685 IMPL_LINK( OutlineView, ParagraphRemovingHdl, ::Outliner *, pOutliner )
687 DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::ParagraphRemovingHdl(), model change without undo?!" );
689 OutlineViewPageChangesGuard aGuard(this);
691 Paragraph* pPara = pOutliner->GetHdlParagraph();
692 if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
694 // wieviele Titel sind vor dem fraglichen Titelabsatz?
695 ULONG nPos = 0L;
696 while(pPara)
698 pPara = GetPrevTitle(pPara);
699 if (pPara) nPos++;
702 // Seite und Notizseite loeschen
703 USHORT nAbsPos = (USHORT)nPos * 2 + 1;
704 SdrPage* pPage = mpDoc->GetPage(nAbsPos);
705 if( isRecordingUndo() )
706 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
707 mpDoc->RemovePage(nAbsPos);
709 nAbsPos = (USHORT)nPos * 2 + 1;
710 pPage = mpDoc->GetPage(nAbsPos);
711 if( isRecordingUndo() )
712 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
713 mpDoc->RemovePage(nAbsPos);
715 // ggfs. Fortschrittsanzeige
716 if (mnPagesToProcess)
718 mnPagesProcessed++;
720 if(mpProgress)
721 mpProgress->SetState(mnPagesProcessed);
723 if (mnPagesProcessed == mnPagesToProcess)
725 if(mpProgress)
727 delete mpProgress;
728 mpProgress = NULL;
730 mnPagesToProcess = 0;
731 mnPagesProcessed = 0;
734 pOutliner->UpdateFields();
737 InvalidateSlideNumberArea();
739 return 0;
742 /*************************************************************************
744 |* Handler fuer das Aendern der Einruecktiefe von Absaetzen (macht ggfs.
745 |* das Einfuegen oder Loeschen von Seiten notwendig)
747 \************************************************************************/
749 IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner *, pOutliner )
751 DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::DepthChangedHdl(), no undo for model change?!" );
753 OutlineViewPageChangesGuard aGuard(this);
755 Paragraph* pPara = pOutliner->GetHdlParagraph();
756 if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && ((pOutliner->GetPrevFlags() & PARAFLAG_ISPAGE) == 0) )
758 // the current paragraph is transformed into a slide
760 mpOutliner->SetDepth( pPara, -1 );
762 // werden da etwa mehrere Level-1-Absaetze auf Level 0 gebracht und
763 // wir sollten eine Fortschrittsanzeige oder Eieruhr aufsetzen und
764 // haben es noch nicht getan?
765 if (mnPagesToProcess == 0)
767 Window* pActWin = mpOutlineViewShell->GetActiveWindow();
768 OutlinerView* pOlView = GetViewByWindow(pActWin);
769 List* pList = pOlView->CreateSelectionList();
771 Paragraph* pParagraph = (Paragraph*)pList->First();
772 while (pParagraph)
774 if( !pOutliner->HasParaFlag( pParagraph, PARAFLAG_ISPAGE ) && (pOutliner->GetDepth( (USHORT) pOutliner->GetAbsPos( pParagraph ) ) <= 0) )
775 mnPagesToProcess++;
776 pParagraph = (Paragraph*)pList->Next();
779 mnPagesToProcess++; // der Absatz, der jetzt schon auf Level 0
780 // steht, gehoert auch dazu
781 mnPagesProcessed = 0;
783 if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD)
785 if( mpProgress )
786 delete mpProgress;
788 const String aStr(SdResId(STR_CREATE_PAGES));
789 mpProgress = new SfxProgress( GetDocSh(), aStr, mnPagesToProcess );
791 else
793 mpDocSh->SetWaitCursor( TRUE );
795 delete pList;
798 ParagraphInsertedHdl(pOutliner);
800 mnPagesProcessed++;
802 // muss eine Fortschrittsanzeige gepflegt werden?
803 if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD)
805 if (mpProgress)
806 mpProgress->SetState(mnPagesProcessed);
809 // war das die letzte Seite?
810 if (mnPagesProcessed == mnPagesToProcess)
812 if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD && mpProgress)
814 delete mpProgress;
815 mpProgress = NULL;
817 else
818 mpDocSh->SetWaitCursor( FALSE );
820 mnPagesToProcess = 0;
821 mnPagesProcessed = 0;
823 pOutliner->UpdateFields();
825 else if( !pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && ((pOutliner->GetPrevFlags() & PARAFLAG_ISPAGE) != 0) )
827 // the paragraph was a page but now becomes a normal paragraph
829 // how many titles are before the title paragraph in question?
830 ULONG nPos = 0L;
831 Paragraph* pParagraph = pPara;
832 while(pParagraph)
834 pParagraph = GetPrevTitle(pParagraph);
835 if (pParagraph)
836 nPos++;
838 // Seite und Notizseite loeschen
840 USHORT nAbsPos = (USHORT)nPos * 2 + 1;
841 SdrPage* pPage = mpDoc->GetPage(nAbsPos);
842 if( isRecordingUndo() )
843 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
844 mpDoc->RemovePage(nAbsPos);
846 nAbsPos = (USHORT)nPos * 2 + 1;
847 pPage = mpDoc->GetPage(nAbsPos);
848 if( isRecordingUndo() )
849 AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
850 mpDoc->RemovePage(nAbsPos);
852 pPage = GetPageForParagraph( pPara );
854 mpOutliner->SetDepth( pPara, (pPage && (static_cast<SdPage*>(pPage)->GetAutoLayout() == AUTOLAYOUT_TITLE)) ? -1 : 0 );
856 // ggfs. Fortschrittsanzeige
857 if (mnPagesToProcess)
859 mnPagesProcessed++;
860 if (mpProgress)
861 mpProgress->SetState(mnPagesProcessed);
863 if (mnPagesProcessed == mnPagesToProcess)
865 if(mpProgress)
867 delete mpProgress;
868 mpProgress = NULL;
870 mnPagesToProcess = 0;
871 mnPagesProcessed = 0;
874 pOutliner->UpdateFields();
876 else if ( (pOutliner->GetPrevDepth() == 1) && ( pOutliner->GetDepth( (USHORT) pOutliner->GetAbsPos( pPara ) ) == 2 ) )
878 // wieviele Titel sind vor dem fraglichen Titelabsatz?
879 sal_Int32 nPos = -1L;
881 Paragraph* pParagraph = pPara;
882 while(pParagraph)
884 pParagraph = GetPrevTitle(pParagraph);
885 if (pParagraph)
886 nPos++;
889 if(nPos >= 0)
891 SdPage*pPage = (SdPage*)mpDoc->GetSdPage( (USHORT) nPos, PK_STANDARD);
893 if(pPage && pPage->GetPresObj(PRESOBJ_TEXT))
894 pOutliner->SetDepth( pPara, 0 );
898 // wieviele Titel sind vor dem fraglichen Titelabsatz?
899 sal_Int32 nPos = -1L;
901 Paragraph* pTempPara = pPara;
902 while(pTempPara)
904 pTempPara = GetPrevTitle(pTempPara);
905 if (pTempPara)
906 nPos++;
909 if( nPos >= 0 )
911 SdPage* pPage = (SdPage*) mpDoc->GetSdPage( (USHORT) nPos, PK_STANDARD );
913 if( pPage )
915 SfxStyleSheet* pStyleSheet = NULL;
916 ULONG nPara = pOutliner->GetAbsPos( pPara );
917 sal_Int16 nDepth = pOutliner->GetDepth( (USHORT) nPara );
918 bool bSubTitle = pPage->GetPresObj(PRESOBJ_TEXT) != NULL;
920 if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
922 pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
924 else if( bSubTitle )
926 pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT );
928 else
930 pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
932 if( nDepth > 0 )
934 String aNewStyleSheetName( pStyleSheet->GetName() );
935 aNewStyleSheetName.Erase( aNewStyleSheetName.Len()-1, 1 );
936 aNewStyleSheetName += String::CreateFromInt32( nDepth+1 );
937 SfxStyleSheetBasePool* pStylePool = mpDoc->GetStyleSheetPool();
938 pStyleSheet = (SfxStyleSheet*) pStylePool->Find( aNewStyleSheetName, pStyleSheet->GetFamily() );
942 // before we set the style sheet we need to preserve the bullet item
943 // since all items will be deleted while setting a new style sheet
944 SfxItemSet aOldAttrs( pOutliner->GetParaAttribs( (USHORT)nPara ) );
946 pOutliner->SetStyleSheet( nPara, pStyleSheet );
948 // restore the old bullet item but not if the style changed
949 if ( pOutliner->GetPrevDepth() != -1 && nDepth != -1 &&
950 aOldAttrs.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON )
952 SfxItemSet aAttrs( pOutliner->GetParaAttribs( (USHORT)nPara ) );
953 aAttrs.Put( *aOldAttrs.GetItem( EE_PARA_NUMBULLET ) );
954 pOutliner->SetParaAttribs( (USHORT)nPara, aAttrs );
959 InvalidateSlideNumberArea();
961 return 0;
964 /*************************************************************************
966 |* Handler fuer StatusEvents
968 \************************************************************************/
970 IMPL_LINK( OutlineView, StatusEventHdl, EditStatus *, EMPTYARG )
972 ::sd::Window* pWin = mpOutlineViewShell->GetActiveWindow();
973 OutlinerView* pOutlinerView = GetViewByWindow(pWin);
974 Rectangle aVis = pOutlinerView->GetVisArea();
976 // ULONG nWidth = ((SdPage*)mpDoc->GetSdPage(0, PK_STANDARD))->GetSize().Width();
977 ULONG nWidth = OUTLINE_PAPERWIDTH;
978 Rectangle aText = Rectangle(Point(0,0),
979 Size(nWidth,
980 mpOutliner->GetTextHeight()));
981 Rectangle aWin(Point(0,0), pWin->GetOutputSizePixel());
982 aWin = pWin->PixelToLogic(aWin);
984 if (!aVis.IsEmpty()) // nicht beim Oeffnen
986 aText.Bottom() += aWin.GetHeight();
988 mpOutlineViewShell->InitWindows(Point(0,0), aText.GetSize(),
989 Point(aVis.TopLeft()));
990 mpOutlineViewShell->UpdateScrollBars();
993 InvalidateSlideNumberArea();
994 return 0;
997 IMPL_LINK( OutlineView, BeginDropHdl, void *, EMPTYARG )
999 DBG_ASSERT(maDragAndDropModelGuard.get() == 0, "sd::OutlineView::BeginDropHdl(), prior drag operation not finished correctly!" );
1001 maDragAndDropModelGuard.reset( new OutlineViewModelChangeGuard( *this ) );
1002 return 0;
1005 IMPL_LINK( OutlineView, EndDropHdl, void *, EMPTYARG )
1007 maDragAndDropModelGuard.reset(0);
1008 InvalidateSlideNumberArea();
1009 return 0;
1012 /*************************************************************************
1014 |* Handler fuer den Beginn einer Absatzverschiebung
1016 \************************************************************************/
1018 IMPL_LINK( OutlineView, BeginMovingHdl, ::Outliner *, pOutliner )
1020 DBG_ASSERT(!mpSelectedParas, "Absatzliste nicht geloescht");
1021 DBG_ASSERT(!mpOldParaOrder, "Absatzliste nicht geloescht");
1023 OutlineViewPageChangesGuard aGuard(this);
1025 mpOldParaOrder = new List;
1027 // Liste der selektierten Titelabsaetze
1028 mpSelectedParas = mpOutlinerView[0]->CreateSelectionList();
1029 Paragraph* pPara = static_cast<Paragraph*>(mpSelectedParas->First());
1030 while (pPara)
1032 if( !pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
1034 mpSelectedParas->Remove();
1035 pPara = static_cast<Paragraph*>(mpSelectedParas->GetCurObject());
1037 else
1039 pPara = static_cast<Paragraph*>(mpSelectedParas->Next());
1043 // Die zu den selektierten Absaetzen auf Ebene 0 gehoerenden Seiten
1044 // selektieren
1045 USHORT nPos = 0;
1046 ULONG nParaPos = 0;
1047 pPara = pOutliner->GetParagraph( 0 );
1049 while(pPara)
1051 if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) ) // eine Seite?
1053 mpOldParaOrder->Insert(pPara, LIST_APPEND);
1054 SdPage* pPage = mpDoc->GetSdPage(nPos, PK_STANDARD);
1055 pPage->SetSelected(FALSE);
1056 if (mpSelectedParas->Seek(pPara)) // selektiert?
1058 pPage->SetSelected(TRUE);
1060 nPos++;
1062 pPara = pOutliner->GetParagraph( ++nParaPos );
1065 return 0;
1068 /*************************************************************************
1070 |* Handler fuer das Ende einer Absatzverschiebung
1072 \************************************************************************/
1074 IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner )
1076 OutlineViewPageChangesGuard aGuard(this);
1078 DBG_ASSERT(mpSelectedParas, "keine Absatzliste");
1079 DBG_ASSERT(mpOldParaOrder, "keine Absatzliste");
1080 DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::EndMovingHdl(), model change without undo?!" );
1082 // Einfuegeposition anhand des ersten Absatzes suchen
1083 Paragraph* pSearchIt = (Paragraph*)mpSelectedParas->First();
1085 // den ersten der selektierten Paragraphen in der neuen Ordnung suchen
1086 USHORT nPosNewOrder = 0;
1087 ULONG nParaPos = 0;
1088 Paragraph* pPara = pOutliner->GetParagraph( 0 );
1089 Paragraph* pPrev = NULL;
1090 while (pPara && pPara != pSearchIt)
1092 if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
1094 nPosNewOrder++;
1095 pPrev = pPara;
1097 pPara = pOutliner->GetParagraph( ++nParaPos );
1100 USHORT nPos = nPosNewOrder; // nPosNewOrder nicht veraendern
1101 if (nPos == 0)
1103 nPos = (USHORT)-1; // vor der ersten Seite einfuegen
1105 else
1107 // den Vorgaenger in der alten Ordnung suchen
1108 nPos = (USHORT)mpOldParaOrder->GetPos(pPrev);
1109 DBG_ASSERT(nPos != 0xffff, "Absatz nicht gefunden");
1112 mpDoc->MovePages(nPos);
1114 // die Seiten wieder deselektieren
1115 USHORT nPageCount = (USHORT)mpSelectedParas->Count();
1116 while (nPageCount)
1118 SdPage* pPage = mpDoc->GetSdPage(nPosNewOrder, PK_STANDARD);
1119 pPage->SetSelected(FALSE);
1120 nPosNewOrder++;
1121 nPageCount--;
1124 pOutliner->UpdateFields();
1126 delete mpSelectedParas;
1127 mpSelectedParas = NULL;
1128 delete mpOldParaOrder;
1129 mpOldParaOrder = NULL;
1131 InvalidateSlideNumberArea();
1133 return 0;
1136 /*************************************************************************
1138 |* Eine Seite des Models nach dem Titeltextobjekt durchsuchen
1140 \************************************************************************/
1142 SdrTextObj* OutlineView::GetTitleTextObject(SdrPage* pPage)
1144 ULONG nObjectCount = pPage->GetObjCount();
1145 SdrObject* pObject = NULL;
1146 SdrTextObj* pResult = NULL;
1148 for (ULONG nObject = 0; nObject < nObjectCount; nObject++)
1150 pObject = pPage->GetObj(nObject);
1151 if (pObject->GetObjInventor() == SdrInventor &&
1152 pObject->GetObjIdentifier() == OBJ_TITLETEXT)
1154 pResult = (SdrTextObj*)pObject;
1155 break;
1158 return pResult;
1162 /*************************************************************************
1164 |* Eine Seite des Models nach dem Gliederungstextobjekt durchsuchen
1166 \************************************************************************/
1168 SdrTextObj* OutlineView::GetOutlineTextObject(SdrPage* pPage)
1170 ULONG nObjectCount = pPage->GetObjCount();
1171 SdrObject* pObject = NULL;
1172 SdrTextObj* pResult = NULL;
1174 for (ULONG nObject = 0; nObject < nObjectCount; nObject++)
1176 pObject = pPage->GetObj(nObject);
1177 if (pObject->GetObjInventor() == SdrInventor &&
1178 pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
1180 pResult = (SdrTextObj*)pObject;
1181 break;
1184 return pResult;
1187 SdrTextObj* OutlineView::CreateTitleTextObject(SdPage* pPage)
1189 DBG_ASSERT( GetTitleTextObject(pPage) == 0, "sd::OutlineView::CreateTitleTextObject(), there is already a title text object!" );
1191 if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
1193 // simple case
1194 pPage->SetAutoLayout( AUTOLAYOUT_ONLY_TITLE, true );
1196 else
1198 // we already have a layout with a title but the title
1199 // object was deleted, create a new one
1200 pPage->InsertAutoLayoutShape( 0, PRESOBJ_TITLE, false, pPage->GetTitleRect(), true );
1203 return GetTitleTextObject(pPage);
1206 SdrTextObj* OutlineView::CreateOutlineTextObject(SdPage* pPage)
1208 DBG_ASSERT( GetOutlineTextObject(pPage) == 0, "sd::OutlineView::CreateOutlineTextObject(), there is already a layout text object!" );
1210 AutoLayout eNewLayout = pPage->GetAutoLayout();
1211 switch( eNewLayout )
1213 case AUTOLAYOUT_NONE:
1214 case AUTOLAYOUT_ONLY_TITLE:
1215 case AUTOLAYOUT_TITLE: eNewLayout = AUTOLAYOUT_ENUM; break;
1217 case AUTOLAYOUT_CHART: eNewLayout = AUTOLAYOUT_CHARTTEXT; break;
1219 case AUTOLAYOUT_ORG:
1220 case AUTOLAYOUT_TAB:
1221 case AUTOLAYOUT_OBJ: eNewLayout = AUTOLAYOUT_OBJTEXT; break;
1222 default:
1223 break;
1226 if( eNewLayout != pPage->GetAutoLayout() )
1228 pPage->SetAutoLayout( eNewLayout, true );
1230 else
1232 // we already have a layout with a text but the text
1233 // object was deleted, create a new one
1234 pPage->InsertAutoLayoutShape( 0,
1235 (eNewLayout == AUTOLAYOUT_TITLE) ? PRESOBJ_TEXT : PRESOBJ_OUTLINE,
1236 false, pPage->GetLayoutRect(), true );
1239 return GetOutlineTextObject(pPage);
1242 /** updates draw model with all changes from outliner model */
1243 BOOL OutlineView::PrepareClose(BOOL)
1245 ::sd::UndoManager* pDocUndoMgr = dynamic_cast<sd::UndoManager*>(mpDocSh->GetUndoManager());
1246 if (pDocUndoMgr != NULL)
1247 pDocUndoMgr->SetLinkedUndoManager(NULL);
1249 mpOutliner->GetUndoManager().Clear();
1251 const String aUndoStr(SdResId(STR_UNDO_CHANGE_TITLE_AND_LAYOUT));
1252 BegUndo(aUndoStr);
1253 UpdateDocument();
1254 EndUndo();
1255 mpDoc->SetSelected(GetActualPage(), TRUE);
1256 return TRUE;
1260 /*************************************************************************
1262 |* Attribute des selektierten Textes setzen
1264 \************************************************************************/
1266 BOOL OutlineView::SetAttributes(const SfxItemSet& rSet, BOOL )
1268 BOOL bOk = FALSE;
1270 OutlinerView* pOlView = GetViewByWindow(mpOutlineViewShell->GetActiveWindow());
1272 if (pOlView)
1274 pOlView->SetAttribs(rSet);
1275 bOk = TRUE;
1278 mpOutlineViewShell->Invalidate (SID_PREVIEW_STATE);
1280 return (bOk);
1283 /*************************************************************************
1285 |* Attribute des selektierten Textes erfragen
1287 \************************************************************************/
1289 BOOL OutlineView::GetAttributes( SfxItemSet& rTargetSet, BOOL ) const
1291 OutlinerView* pOlView = GetViewByWindow(
1292 mpOutlineViewShell->GetActiveWindow());
1293 DBG_ASSERT(pOlView, "keine OutlinerView gefunden");
1295 rTargetSet.Put( pOlView->GetAttribs(), FALSE );
1296 return TRUE;
1299 /** creates outliner model from draw model */
1300 void OutlineView::FillOutliner()
1302 mpOutliner->GetUndoManager().Clear();
1303 mpOutliner->EnableUndo(FALSE);
1304 ResetLinks();
1305 mpOutliner->SetUpdateMode(false);
1307 Paragraph* pTitleToSelect = NULL;
1308 ULONG nPageCount = mpDoc->GetSdPageCount(PK_STANDARD);
1310 // fill outliner with paragraphs from slides title & (outlines|subtitles)
1311 for (USHORT nPage = 0; nPage < nPageCount; nPage++)
1313 SdPage* pPage = (SdPage*)mpDoc->GetSdPage(nPage, PK_STANDARD);
1314 Paragraph * pPara = NULL;
1316 // take text from title shape
1317 SdrTextObj* pTO = GetTitleTextObject(pPage);
1318 if(pTO && !(pTO->IsEmptyPresObj()))
1320 OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
1321 if (pOPO)
1323 BOOL bVertical = pOPO->IsVertical();
1324 pOPO->SetVertical( FALSE );
1325 mpOutliner->AddText(*pOPO);
1326 pOPO->SetVertical( bVertical );
1327 pPara = mpOutliner->GetParagraph( mpOutliner->GetParagraphCount()-1 );
1331 if( pPara == 0 ) // no title, insert an empty paragraph
1333 pPara = mpOutliner->Insert(String());
1334 mpOutliner->SetDepth(pPara, -1);
1336 // Keine harten Attribute vom vorherigen Absatz uebernehmen
1337 mpOutliner->SetParaAttribs( (USHORT)mpOutliner->GetAbsPos(pPara),
1338 mpOutliner->GetEmptyItemSet() );
1340 mpOutliner->SetStyleSheet( mpOutliner->GetAbsPos( pPara ), pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ) );
1343 mpOutliner->SetParaFlag( pPara, PARAFLAG_ISPAGE );
1345 ULONG nPara = mpOutliner->GetAbsPos( pPara );
1347 UpdateParagraph( (USHORT)nPara );
1349 // remember paragraph of currently selected page
1350 if (pPage->IsSelected())
1351 pTitleToSelect = pPara;
1353 // take text from subtitle or outline
1354 pTO = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT));
1355 const bool bSubTitle = pTO != 0;
1357 if (!pTO) // if no subtile found, try outline
1358 pTO = GetOutlineTextObject(pPage);
1360 if(pTO && !(pTO->IsEmptyPresObj())) // found some text
1362 OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
1363 if (pOPO)
1365 USHORT nParaCount1 = (USHORT)mpOutliner->GetParagraphCount();
1366 BOOL bVertical = pOPO->IsVertical();
1367 pOPO->SetVertical( FALSE );
1368 mpOutliner->AddText(*pOPO);
1369 pOPO->SetVertical( bVertical );
1371 USHORT nParaCount2 = (USHORT)mpOutliner->GetParagraphCount();
1372 for (USHORT n = nParaCount1; n < nParaCount2; n++)
1374 if( bSubTitle )
1376 Paragraph* p = mpOutliner->GetParagraph(n);
1377 if(p && mpOutliner->GetDepth( n ) > 0 )
1378 mpOutliner->SetDepth(p, 0);
1381 UpdateParagraph( n );
1387 // place cursor at the start
1388 Paragraph* pFirstPara = mpOutliner->GetParagraph( 0 );
1389 mpOutlinerView[0]->Select( pFirstPara, TRUE, FALSE );
1390 mpOutlinerView[0]->Select( pFirstPara, FALSE, FALSE );
1392 // select title of slide that was selected
1393 if (pTitleToSelect)
1394 mpOutlinerView[0]->Select(pTitleToSelect, TRUE, FALSE);
1396 SetLinks();
1398 mpOutliner->EnableUndo(TRUE);
1400 mpOutliner->SetUpdateMode(true);
1403 /*************************************************************************
1405 |* Handler fuer das Loeschen von Level-0-Absaetzen (Seiten): Warnung
1407 \************************************************************************/
1409 IMPL_LINK( OutlineView, RemovingPagesHdl, OutlinerView *, EMPTYARG )
1411 USHORT nNumOfPages = mpOutliner->GetSelPageCount();
1413 if (nNumOfPages > PROCESS_WITH_PROGRESS_THRESHOLD)
1415 mnPagesToProcess = nNumOfPages;
1416 mnPagesProcessed = 0;
1419 if (mnPagesToProcess)
1421 if( mpProgress )
1422 delete mpProgress;
1424 String aStr(SdResId(STR_DELETE_PAGES));
1425 mpProgress = new SfxProgress( GetDocSh(), aStr, mnPagesToProcess );
1427 mpOutliner->UpdateFields();
1429 InvalidateSlideNumberArea();
1431 return 1;
1434 /*************************************************************************
1436 |* Handler fuer das Einruecken von Level-0-Absaetzen (Seiten): Warnung
1438 \************************************************************************/
1440 IMPL_LINK_INLINE_START( OutlineView, IndentingPagesHdl, OutlinerView *, pOutlinerView )
1442 return RemovingPagesHdl(pOutlinerView);
1444 IMPL_LINK_INLINE_END( OutlineView, IndentingPagesHdl, OutlinerView *, pOutlinerView )
1447 /** returns the first slide that is selected in the outliner or where
1448 the cursor is located */
1449 SdPage* OutlineView::GetActualPage()
1451 ::sd::Window* pWin = mpOutlineViewShell->GetActiveWindow();
1452 OutlinerView* pActiveView = GetViewByWindow(pWin);
1453 std::auto_ptr<List> pSelList( static_cast< List* >(pActiveView->CreateSelectionList()) );
1455 SdPage* pCurrent = GetPageForParagraph(static_cast<Paragraph*>(pSelList->First()) );
1456 DBG_ASSERT( pCurrent ||
1457 (mpDocSh->GetUndoManager() && static_cast< sd::UndoManager *>(mpDocSh->GetUndoManager())->isInUndo()) ||
1458 maDragAndDropModelGuard.get(),
1459 "sd::OutlineView::GetActualPage(), no current page?" );
1460 if( pCurrent )
1461 return pCurrent;
1462 else
1463 return mpDoc->GetSdPage( 0, PK_STANDARD );
1466 SdPage* OutlineView::GetPageForParagraph( Paragraph* pPara )
1468 if( !mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) )
1469 pPara = GetPrevTitle(pPara);
1471 sal_uInt32 nPageToSelect = 0;
1472 while(pPara)
1474 pPara = GetPrevTitle(pPara);
1475 if(pPara)
1476 nPageToSelect++;
1479 if( nPageToSelect < (sal_uInt32)mpDoc->GetSdPageCount( PK_STANDARD ) )
1480 return static_cast< SdPage* >( mpDoc->GetSdPage( (USHORT)nPageToSelect, PK_STANDARD) );
1481 else
1482 return 0;
1485 Paragraph* OutlineView::GetParagraphForPage( ::Outliner* pOutl, SdPage* pPage )
1487 // get the number of paragraphs with ident 0 we need to skip before
1488 // we finde the actual page
1489 sal_uInt32 nPagesToSkip = (pPage->GetPageNum() - 1) >> 1;
1491 sal_uInt32 nParaPos = 0;
1492 Paragraph* pPara = pOutl->GetParagraph( 0 );
1493 while( pPara )
1495 // if this paragraph is a page ...
1496 if( mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) )
1498 // see if we already skiped enough pages
1499 if( 0 == nPagesToSkip )
1500 break; // and if so, end the loop
1502 // we skiped another page
1503 nPagesToSkip--;
1506 // get next paragraph
1507 pPara = mpOutliner->GetParagraph( ++nParaPos );
1510 return pPara;
1513 /** selects the paragraph for the given page at the outliner view*/
1514 void OutlineView::SetActualPage( SdPage* pActual )
1516 if( pActual && mpOutliner && dynamic_cast<Outliner*> ( mpOutliner )->GetIgnoreCurrentPageChangesLevel()==0 && !mbFirstPaint)
1518 // if we found a paragraph, select its text at the outliner view
1519 Paragraph* pPara = GetParagraphForPage( mpOutliner, pActual );
1520 if( pPara )
1521 mpOutlinerView[0]->Select( pPara, TRUE, FALSE );
1525 /*************************************************************************
1527 |* StyleSheet aus der Selektion besorgen
1529 \************************************************************************/
1531 SfxStyleSheet* OutlineView::GetStyleSheet() const
1533 ::sd::Window* pActWin = mpOutlineViewShell->GetActiveWindow();
1534 OutlinerView* pOlView = GetViewByWindow(pActWin);
1535 SfxStyleSheet* pResult = pOlView->GetStyleSheet();
1536 return pResult;
1541 /*************************************************************************
1543 |* Seiten als selektiert / nicht selektiert setzen
1545 \************************************************************************/
1547 void OutlineView::SetSelectedPages()
1549 // Liste der selektierten Titelabsaetze
1550 List* pSelParas = mpOutlinerView[0]->CreateSelectionList();
1551 Paragraph* pPara = (Paragraph*) pSelParas->First();
1553 while(pPara)
1555 if( !mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
1557 pSelParas->Remove();
1558 pPara = (Paragraph*) pSelParas->GetCurObject();
1560 else
1562 pPara = (Paragraph*) pSelParas->Next();
1566 // Die zu den selektierten Absaetzen auf Ebene 0 gehoerenden Seiten
1567 // selektieren
1568 USHORT nPos = 0;
1569 ULONG nParaPos = 0;
1570 pPara = mpOutliner->GetParagraph( 0 );
1572 while(pPara)
1574 if( mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) ) // eine Seite?
1576 SdPage* pPage = mpDoc->GetSdPage(nPos, PK_STANDARD);
1577 DBG_ASSERT(pPage!=NULL,
1578 "Trying to select non-existing page OutlineView::SetSelectedPages()");
1579 if (pPage != NULL)
1581 pPage->SetSelected(FALSE);
1583 if (pSelParas->Seek(pPara)) // selektiert?
1584 pPage->SetSelected(TRUE);
1587 nPos++;
1590 pPara = mpOutliner->GetParagraph( ++nParaPos );
1595 /*************************************************************************
1597 |* Neue Links setzen
1599 \************************************************************************/
1601 void OutlineView::SetLinks()
1603 // Benachrichtigungs-Links setzen
1604 mpOutliner->SetParaInsertedHdl(LINK(this, OutlineView, ParagraphInsertedHdl));
1605 mpOutliner->SetParaRemovingHdl(LINK(this, OutlineView, ParagraphRemovingHdl));
1606 mpOutliner->SetDepthChangedHdl(LINK(this, OutlineView, DepthChangedHdl));
1607 mpOutliner->SetBeginMovingHdl(LINK(this, OutlineView, BeginMovingHdl));
1608 mpOutliner->SetEndMovingHdl(LINK(this, OutlineView, EndMovingHdl));
1609 mpOutliner->SetRemovingPagesHdl(LINK(this, OutlineView, RemovingPagesHdl));
1610 mpOutliner->SetIndentingPagesHdl(LINK(this, OutlineView, IndentingPagesHdl));
1611 mpOutliner->SetStatusEventHdl(LINK(this, OutlineView, StatusEventHdl));
1612 mpOutliner->SetBeginDropHdl(LINK(this,OutlineView, BeginDropHdl));
1613 mpOutliner->SetEndDropHdl(LINK(this,OutlineView, EndDropHdl));
1614 mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
1615 mpOutliner->SetBeginPasteOrDropHdl(LINK(this,OutlineView, BeginPasteOrDropHdl));
1616 mpOutliner->SetEndPasteOrDropHdl(LINK(this,OutlineView, EndPasteOrDropHdl));
1621 /*************************************************************************
1623 |* Alte Links restaurieren
1625 \************************************************************************/
1627 void OutlineView::ResetLinks() const
1629 // alte Links restaurieren
1630 Link aEmptyLink;
1631 mpOutliner->SetParaInsertedHdl(aEmptyLink);
1632 mpOutliner->SetParaRemovingHdl(aEmptyLink);
1633 mpOutliner->SetDepthChangedHdl(aEmptyLink);
1634 mpOutliner->SetBeginMovingHdl(aEmptyLink);
1635 mpOutliner->SetEndMovingHdl(aEmptyLink);
1636 mpOutliner->SetStatusEventHdl(aEmptyLink);
1637 mpOutliner->SetRemovingPagesHdl(aEmptyLink);
1638 mpOutliner->SetIndentingPagesHdl(aEmptyLink);
1639 mpOutliner->SetDrawPortionHdl(aEmptyLink);
1640 mpOutliner->SetBeginPasteOrDropHdl(aEmptyLink);
1641 mpOutliner->SetEndPasteOrDropHdl(aEmptyLink);
1644 /*************************************************************************
1646 |* AcceptDrop
1648 \************************************************************************/
1650 sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, ::sd::Window*, USHORT, USHORT)
1652 return DND_ACTION_NONE;
1655 /*************************************************************************
1657 |* ExecuteDrop
1659 \************************************************************************/
1661 sal_Int8 OutlineView::ExecuteDrop( const ExecuteDropEvent&, DropTargetHelper&, ::sd::Window*, USHORT, USHORT)
1663 return DND_ACTION_NONE;
1666 // #97766# Re-implement GetScriptType for this view to get correct results
1667 sal_uInt16 OutlineView::GetScriptType() const
1669 sal_uInt16 nScriptType = ::sd::View::GetScriptType();
1671 if(mpOutliner)
1673 OutlinerParaObject* pTempOPObj = mpOutliner->CreateParaObject();
1675 if(pTempOPObj)
1677 nScriptType = pTempOPObj->GetTextObject().GetScriptType();
1678 delete pTempOPObj;
1682 return nScriptType;
1685 void OutlineView::onUpdateStyleSettings( bool bForceUpdate /* = false */ )
1687 const bool bHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode() != 0;
1688 if( bForceUpdate || (mbHighContrastMode != bHighContrastMode) )
1690 if( mpOutliner )
1692 mpOutliner->ForceAutoColor( bHighContrastMode );
1694 mbHighContrastMode = bHighContrastMode;
1698 svtools::ColorConfig aColorConfig;
1699 const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
1700 if( bForceUpdate || (maDocColor != aDocColor) )
1702 sal_uInt16 nView;
1703 for( nView = 0; nView < MAX_OUTLINERVIEWS; nView++ )
1705 if (mpOutlinerView[nView] != NULL)
1707 mpOutlinerView[nView]->SetBackgroundColor( aDocColor );
1709 ::Window* pWindow = mpOutlinerView[nView]->GetWindow();
1711 if( pWindow )
1712 pWindow->SetBackground( Wallpaper( aDocColor ) );
1717 if( mpOutliner )
1718 mpOutliner->SetBackgroundColor( aDocColor );
1720 maDocColor = aDocColor;
1724 IMPL_LINK( OutlineView, AppEventListenerHdl, void *, EMPTYARG )
1726 onUpdateStyleSettings();
1727 return 0;
1733 IMPL_LINK(OutlineView, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent)
1735 if (pEvent != NULL)
1737 switch (pEvent->meEventId)
1739 case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
1740 SetActualPage(mpOutlineViewShell->GetActualPage());
1741 InvalidateSlideNumberArea();
1742 break;
1744 case tools::EventMultiplexerEvent::EID_PAGE_ORDER:
1745 if (mpOutliner != NULL && mpDoc!=NULL && mpOutliner != NULL && dynamic_cast<Outliner*> ( mpOutliner )->GetIgnoreCurrentPageChangesLevel()==0)
1747 if (((mpDoc->GetPageCount()-1)%2) == 0)
1749 mpOutliner->Clear();
1750 FillOutliner();
1751 ::sd::Window* pWindow = mpOutlineViewShell->GetActiveWindow();
1752 if (pWindow != NULL)
1753 pWindow->Invalidate();
1756 break;
1759 return 0;
1762 void OutlineView::IgnoreCurrentPageChanges (bool bIgnoreChanges)
1764 if ( mpOutliner )
1766 if (bIgnoreChanges)
1767 dynamic_cast<Outliner*> ( mpOutliner )->IncreIgnoreCurrentPageChangesLevel();
1768 else
1769 dynamic_cast<Outliner*> ( mpOutliner )->DecreIgnoreCurrentPageChangesLevel();
1773 /** call this method before you do anything that can modify the outliner
1774 and or the drawing document model. It will create needed undo actions */
1775 void OutlineView::BeginModelChange()
1777 const String aEmpty;
1778 mpOutliner->GetUndoManager().EnterListAction(aEmpty,aEmpty);
1779 const String aUndoStr(SdResId(STR_UNDO_CHANGE_TITLE_AND_LAYOUT));
1780 BegUndo(aUndoStr);
1783 /** call this method after BeginModelChange(), when all possible model
1784 changes are done. */
1785 void OutlineView::EndModelChange()
1787 UpdateDocument();
1789 SfxUndoManager* pDocUndoMgr = mpDocSh->GetUndoManager();
1791 bool bHasUndoActions = pDocUndoMgr->GetUndoActionCount() != 0;
1793 EndUndo();
1795 DBG_ASSERT( bHasUndoActions == (mpOutliner->GetUndoManager().GetUndoActionCount() != 0), "sd::OutlineView::EndModelChange(), undo actions not in sync!" );
1797 if( bHasUndoActions )
1799 SfxLinkUndoAction* pLink = new SfxLinkUndoAction(pDocUndoMgr);
1800 mpOutliner->GetUndoManager().AddUndoAction(pLink);
1803 mpOutliner->GetUndoManager().LeaveListAction();
1805 if( bHasUndoActions && mpOutliner->GetEditEngine().HasTriedMergeOnLastAddUndo() )
1806 TryToMergeUndoActions();
1809 /** updates all changes in the outliner model to the draw model */
1810 void OutlineView::UpdateDocument()
1812 const sal_uInt32 nPageCount = mpDoc->GetSdPageCount(PK_STANDARD);
1813 Paragraph* pPara = mpOutliner->GetParagraph( 0 );
1814 sal_uInt32 nPage;
1815 for (nPage = 0; nPage < nPageCount; nPage++)
1817 SdPage* pPage = mpDoc->GetSdPage( (USHORT)nPage, PK_STANDARD);
1818 mpDoc->SetSelected(pPage, FALSE);
1820 mpOutlineViewShell->UpdateTitleObject( pPage, pPara );
1821 mpOutlineViewShell->UpdateOutlineObject( pPage, pPara );
1823 if( pPara )
1824 pPara = GetNextTitle(pPara);
1827 DBG_ASSERT( pPara == 0, "sd::OutlineView::UpdateDocument(), slides are out of sync, creating missing ones" );
1828 while( pPara )
1830 SdPage* pPage = InsertSlideForParagraph( pPara );
1831 mpDoc->SetSelected(pPage, FALSE);
1833 mpOutlineViewShell->UpdateTitleObject( pPage, pPara );
1834 mpOutlineViewShell->UpdateOutlineObject( pPage, pPara );
1836 if( pPara )
1837 pPara = GetNextTitle(pPara);
1841 /** merge edit engine undo actions if possible */
1842 void OutlineView::TryToMergeUndoActions()
1844 SfxUndoManager& rOutlineUndo = mpOutliner->GetUndoManager();
1845 if( rOutlineUndo.GetUndoActionCount() > 1 )
1847 SfxListUndoAction* pListAction = dynamic_cast< SfxListUndoAction* >( rOutlineUndo.GetUndoAction(0) );
1848 SfxListUndoAction* pPrevListAction = dynamic_cast< SfxListUndoAction* >( rOutlineUndo.GetUndoAction(1) );
1849 if( pListAction && pPrevListAction )
1851 // find the top EditUndo action in the top undo action list
1852 USHORT nAction = pListAction->aUndoActions.Count();
1853 EditUndo* pEditUndo = 0;
1854 while( !pEditUndo && nAction )
1856 pEditUndo = dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction]);
1859 USHORT nEditPos = nAction; // we need this later to remove the merged undo actions
1861 // make sure it is the only EditUndo action in the top undo list
1862 while( pEditUndo && nAction )
1864 if( dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction]) )
1865 pEditUndo = 0;
1868 // do we have one and only one EditUndo action in the top undo list?
1869 if( pEditUndo )
1871 // yes, see if we can merge it with the prev undo list
1873 nAction = pPrevListAction->aUndoActions.Count();
1874 EditUndo* pPrevEditUndo = 0;
1875 while( !pPrevEditUndo && nAction )
1876 pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->aUndoActions[--nAction]);
1878 if( pPrevEditUndo && pPrevEditUndo->Merge( pEditUndo ) )
1880 // ok we merged the only EditUndo of the top undo list with
1881 // the top EditUndo of the previous undo list
1883 // first remove the merged undo action
1884 DBG_ASSERT( pListAction->aUndoActions[nEditPos] == pEditUndo, "sd::OutlineView::TryToMergeUndoActions(), wrong edit pos!" );
1885 pListAction->aUndoActions.Remove(nEditPos);
1886 delete pEditUndo;
1888 // now check if we also can merge the draw undo actions
1889 SfxUndoManager* pDocUndoManager = mpDocSh->GetUndoManager();
1890 if( pDocUndoManager && ( pListAction->aUndoActions.Count() == 1 ))
1892 SfxLinkUndoAction* pLinkAction = dynamic_cast< SfxLinkUndoAction* >( pListAction->aUndoActions[0] );
1893 SfxLinkUndoAction* pPrevLinkAction = 0;
1895 if( pLinkAction )
1897 nAction = pPrevListAction->aUndoActions.Count();
1898 while( !pPrevLinkAction && nAction )
1899 pPrevLinkAction = dynamic_cast< SfxLinkUndoAction* >(pPrevListAction->aUndoActions[--nAction]);
1902 if( pLinkAction && pPrevLinkAction &&
1903 ( pLinkAction->GetAction() == pDocUndoManager->GetUndoAction(0) ) &&
1904 ( pPrevLinkAction->GetAction() == pDocUndoManager->GetUndoAction(1) ) )
1906 SfxListUndoAction* pSourceList = dynamic_cast< SfxListUndoAction* >(pLinkAction->GetAction());
1907 SfxListUndoAction* pDestinationList = dynamic_cast< SfxListUndoAction* >(pPrevLinkAction->GetAction());
1909 if( pSourceList && pDestinationList )
1911 USHORT nCount = pSourceList->aUndoActions.Count();
1912 USHORT nDestAction = pDestinationList->aUndoActions.Count();
1913 while( nCount-- )
1915 const SfxUndoAction* pTemp = pSourceList->aUndoActions.GetObject(0);
1916 pSourceList->aUndoActions.Remove(0);
1917 pDestinationList->aUndoActions.Insert( pTemp, nDestAction++ );
1919 pDestinationList->nCurUndoAction = pDestinationList->aUndoActions.Count();
1921 pListAction->aUndoActions.Remove(0);
1922 delete pLinkAction;
1924 pDocUndoManager->RemoveLastUndoAction();
1929 if( pListAction->aUndoActions.Count() )
1931 // now we have to move all remaining doc undo actions from the top undo
1932 // list to the previous undo list and remove the top undo list
1934 USHORT nCount = pListAction->aUndoActions.Count();
1935 USHORT nDestAction = pPrevListAction->aUndoActions.Count();
1936 while( nCount-- )
1938 const SfxUndoAction* pTemp = pListAction->aUndoActions.GetObject(0);
1939 pListAction->aUndoActions.Remove(0);
1940 if( pTemp )
1941 pPrevListAction->aUndoActions.Insert( pTemp, nDestAction++ );
1943 pPrevListAction->nCurUndoAction = pPrevListAction->aUndoActions.Count();
1946 rOutlineUndo.RemoveLastUndoAction();
1953 IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
1955 if( pInfo && mpOutliner )
1957 Paragraph* pPara = mpOutliner->GetParagraph( pInfo->mnPara );
1958 EditEngine& rEditEngine = const_cast< EditEngine& >( mpOutliner->GetEditEngine() );
1960 Size aImageSize( pInfo->mpOutDev->PixelToLogic( maSlideImage.GetSizePixel() ) );
1961 Size aOffset( 100, 100 );
1963 // paint slide number
1964 if( pPara && mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) )
1966 long nPage = 0; // todo, printing??
1967 for ( USHORT n = 0; n <= pInfo->mnPara; n++ )
1969 Paragraph* p = mpOutliner->GetParagraph( n );
1970 if ( mpOutliner->HasParaFlag(p,PARAFLAG_ISPAGE) )
1971 nPage++;
1974 long nBulletHeight = (long)mpOutliner->GetLineHeight( pInfo->mnPara );
1975 long nFontHeight = 0;
1976 if ( !rEditEngine.IsFlatMode() )
1978 // const SvxFontHeightItem& rFH = (const SvxFontHeightItem&)rEditEngine.GetParaAttrib( pInfo->mnPara, EE_CHAR_FONTHEIGHT );
1979 // nBulletHeight = rFH.GetHeight();
1980 nFontHeight = nBulletHeight / 5;
1982 else
1984 // const SvxFontHeightItem& rFH = (const SvxFontHeightItem&)rEditEngine.GetEmptyItemSet().Get( EE_CHAR_FONTHEIGHT );
1985 // nBulletHeight = rFH.GetHeight();
1986 nFontHeight = (nBulletHeight * 10) / 25;
1989 Size aFontSz( 0, nFontHeight );
1991 Size aOutSize( 2000, nBulletHeight );
1993 const float fImageHeight = ((float)aOutSize.Height() * (float)4) / (float)7;
1994 const float fImageRatio = (float)aImageSize.Height() / (float)aImageSize.Width();
1995 aImageSize.Width() = (long)( fImageRatio * fImageHeight );
1996 aImageSize.Height() = (long)( fImageHeight );
1998 Point aImagePos( pInfo->mrStartPos );
1999 aImagePos.X() += aOutSize.Width() - aImageSize.Width() - aOffset.Width() ;
2000 aImagePos.Y() += (aOutSize.Height() - aImageSize.Height()) / 2;
2002 pInfo->mpOutDev->DrawImage( aImagePos, aImageSize, maSlideImage );
2004 const bool bVertical = mpOutliner->IsVertical();
2005 const bool bRightToLeftPara = rEditEngine.IsRightToLeft( pInfo->mnPara );
2007 LanguageType eLang = rEditEngine.GetDefaultLanguage();
2009 Point aTextPos( aImagePos.X() - aOffset.Width(), pInfo->mrStartPos.Y() );
2010 Font aNewFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE, eLang, 0 ) );
2011 aNewFont.SetSize( aFontSz );
2012 // aNewFont.SetAlign( aBulletFont.GetAlign() );
2013 aNewFont.SetVertical( bVertical );
2014 aNewFont.SetOrientation( bVertical ? 2700 : 0 );
2015 aNewFont.SetColor( COL_AUTO );
2016 pInfo->mpOutDev->SetFont( aNewFont );
2017 String aPageText = String::CreateFromInt32( nPage );
2018 Size aTextSz;
2019 aTextSz.Width() = pInfo->mpOutDev->GetTextWidth( aPageText );
2020 aTextSz.Height() = pInfo->mpOutDev->GetTextHeight();
2021 // long nBulletHeight = !bVertical ? aBulletArea.GetHeight() : aBulletArea.GetWidth();
2022 if ( !bVertical )
2024 aTextPos.Y() += (aOutSize.Height() - aTextSz.Height()) / 2;
2025 if ( !bRightToLeftPara )
2027 aTextPos.X() -= aTextSz.Width();
2029 else
2031 aTextPos.X() += aTextSz.Width();
2034 else
2036 aTextPos.Y() -= aTextSz.Width();
2037 aTextPos.X() += nBulletHeight / 2;
2039 pInfo->mpOutDev->DrawText( aTextPos, aPageText );
2043 return 0;
2046 sal_Int32 OutlineView::GetPageNumberWidthPixel()
2048 Window* pActWin = mpOutlineViewShell->GetActiveWindow();
2049 if( pActWin )
2051 Font aOldFont( pActWin->GetFont() );
2052 pActWin->SetFont( maPageNumberFont );
2053 Size aSize( pActWin->GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM("X" ) ) ), 0 );
2054 sal_Int32 nWidth = pActWin->LogicToPixel( aSize ).Width() * 5;
2056 const String aBulletStr( sal_Unicode( 0xE011 ) );
2057 pActWin->SetFont( maBulletFont);
2059 aSize.Width() = pActWin->GetTextWidth(aBulletStr);
2060 nWidth += pActWin->LogicToPixel( aSize ).Width();
2062 pActWin->SetFont( aOldFont );
2064 mnPageNumberWidthPixel = nWidth;
2066 return mnPageNumberWidthPixel;
2069 // --------------------------------------------------------------------
2071 void OutlineView::UpdateParagraph( USHORT nPara )
2073 if( mpOutliner )
2075 SfxItemSet aNewAttrs2( mpOutliner->GetParaAttribs( nPara ) );
2076 aNewAttrs2.Put( maLRSpaceItem );
2077 mpOutliner->SetParaAttribs( nPara, aNewAttrs2 );
2081 // --------------------------------------------------------------------
2083 void OutlineView::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
2087 /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
2088 get the correct style sheet and new slides are inserted. */
2089 void OutlineView::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
2091 SdPage* pPage = 0;
2092 SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
2094 for( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
2096 Paragraph* pPara = mpOutliner->GetParagraph( nPara );
2098 bool bPage = mpOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE );
2100 if( !bPage )
2102 SdStyleSheet* pStyleSheet = dynamic_cast< SdStyleSheet* >( mpOutliner->GetStyleSheet( nPara ) );
2103 if( pStyleSheet )
2105 const OUString aName( pStyleSheet->GetApiName() );
2106 if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("title" ) ) )
2107 bPage = true;
2111 if( !pPara )
2112 continue; // fatality!?
2114 if( bPage && (nPara != pInfos->nStartPara) )
2116 // insert new slide for this paragraph
2117 pPage = InsertSlideForParagraph( pPara );
2119 else
2121 // newly inserted non page paragraphs get the outline style
2122 if( !pPage )
2123 pPage = GetPageForParagraph( pPara );
2125 if( pPage )
2127 SfxStyleSheet* pStyle = pPage->GetStyleSheetForPresObj( bPage ? PRESOBJ_TITLE : PRESOBJ_OUTLINE );
2129 if( !bPage )
2131 const sal_Int16 nDepth = mpOutliner->GetDepth( nPara );
2132 if( nDepth > 0 )
2134 String aStyleSheetName( pStyle->GetName() );
2135 aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
2136 aStyleSheetName += String::CreateFromInt32( nDepth );
2137 pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyle->GetFamily() ) );
2138 DBG_ASSERT( pStyle, "sd::OutlineView::OnEndPasteOrDrop(), Style not found!" );
2142 mpOutliner->SetStyleSheet( nPara, pStyle );
2145 UpdateParagraph( nPara );
2150 // ====================================================================
2153 OutlineViewModelChangeGuard::OutlineViewModelChangeGuard( OutlineView& rView )
2154 : mrView( rView )
2156 mrView.BeginModelChange();
2159 OutlineViewModelChangeGuard::~OutlineViewModelChangeGuard()
2161 mrView.EndModelChange();
2164 OutlineViewPageChangesGuard::OutlineViewPageChangesGuard( OutlineView* pView )
2165 : mpView( pView )
2167 if( mpView )
2168 mpView->IgnoreCurrentPageChanges( true );
2171 OutlineViewPageChangesGuard::~OutlineViewPageChangesGuard()
2173 if( mpView )
2174 mpView->IgnoreCurrentPageChanges( false );
2178 } // end of namespace sd