Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "OutlineView.hxx"
21 : #include <editeng/forbiddencharacterstable.hxx>
22 : #include <sfx2/progress.hxx>
23 : #include <vcl/wrkwin.hxx>
24 : #include <svx/svxids.hrc>
25 : #include <editeng/outliner.hxx>
26 : #include <editeng/eeitem.hxx>
27 : #include <editeng/editstat.hxx>
28 : #include <editeng/lrspitem.hxx>
29 : #include <svx/svdotext.hxx>
30 : #include <sfx2/printer.hxx>
31 : #include <sfx2/imagemgr.hxx>
32 : #include <sfx2/app.hxx>
33 : #include <sfx2/bindings.hxx>
34 : #include <svl/itempool.hxx>
35 : #include <svl/style.hxx>
36 : #include <svx/svdorect.hxx>
37 : #include <svx/svdundo.hxx>
38 : #include <vcl/msgbox.hxx>
39 : #include <editeng/adjustitem.hxx>
40 : #include <editeng/tstpitem.hxx>
41 : #include <editeng/lspcitem.hxx>
42 : #include <editeng/numitem.hxx>
43 : #include <editeng/outlobj.hxx>
44 : #include <editeng/editeng.hxx>
45 :
46 : #include <editeng/editobj.hxx>
47 : #include <editeng/editund2.hxx>
48 :
49 : #include <editeng/editview.hxx>
50 : #include <editeng/svxfont.hxx>
51 : #include <editeng/fhgtitem.hxx>
52 :
53 : #include "DrawDocShell.hxx"
54 : #include "drawdoc.hxx"
55 : #include "Window.hxx"
56 : #include "sdpage.hxx"
57 : #include "pres.hxx"
58 : #include "OutlineViewShell.hxx"
59 : #include "app.hrc"
60 : #include "glob.hrc"
61 : #include "sdresid.hxx"
62 : #include "Outliner.hxx"
63 : #include "strings.hrc"
64 : #include "EventMultiplexer.hxx"
65 : #include "ViewShellBase.hxx"
66 : #include "undo/undoobjects.hxx"
67 : #include "undo/undomanager.hxx"
68 : #include "stlsheet.hxx"
69 :
70 : using namespace ::com::sun::star::uno;
71 : using namespace ::com::sun::star::frame;
72 :
73 : namespace sd {
74 :
75 : // a progress bar gets displayed when more than
76 : // PROCESS_WITH_PROGRESS_THRESHOLD pages are concerned
77 : #define PROCESS_WITH_PROGRESS_THRESHOLD 5
78 :
79 : struct SdParaAndPos
80 : {
81 : Paragraph* pPara;
82 : sal_uInt16 nPos;
83 : };
84 :
85 : // - OutlineView -
86 :
87 0 : TYPEINIT1( OutlineView, ::sd::View );
88 :
89 0 : OutlineView::OutlineView( DrawDocShell& rDocSh, vcl::Window* pWindow, OutlineViewShell& rOutlineViewShell)
90 0 : : ::sd::View(*rDocSh.GetDoc(), pWindow, &rOutlineViewShell)
91 : , mrOutlineViewShell(rOutlineViewShell)
92 0 : , mrOutliner(*mrDoc.GetOutliner(true))
93 : , mnPagesToProcess(0)
94 : , mnPagesProcessed(0)
95 : , mbFirstPaint(true)
96 : , mpProgress(NULL)
97 : , maDocColor( COL_WHITE )
98 0 : , maLRSpaceItem( 0, 0, 2000, 0, EE_PARA_OUTLLRSPACE )
99 : {
100 0 : bool bInitOutliner = false;
101 :
102 0 : if (mrOutliner.GetViewCount() == 0)
103 : {
104 : // initialize Outliner: set Reference Device
105 0 : bInitOutliner = true;
106 0 : mrOutliner.Init( OUTLINERMODE_OUTLINEVIEW );
107 0 : mrOutliner.SetRefDevice( SD_MOD()->GetRefDevice( rDocSh ) );
108 : //viewsize without the width of the image and number in front
109 0 : mnPaperWidth = (mrOutlineViewShell.GetActiveWindow()->GetViewSize().Width() - 4000);
110 0 : mrOutliner.SetPaperSize(Size(mnPaperWidth, 400000000));
111 : }
112 :
113 : // insert View into Outliner
114 0 : for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
115 : {
116 0 : mpOutlinerView[nView] = NULL;
117 : }
118 :
119 0 : mpOutlinerView[0] = new OutlinerView(&mrOutliner, pWindow);
120 0 : Rectangle aNullRect;
121 0 : mpOutlinerView[0]->SetOutputArea(aNullRect);
122 0 : mrOutliner.SetUpdateMode(false);
123 0 : mrOutliner.InsertView(mpOutlinerView[0], EE_APPEND);
124 :
125 0 : onUpdateStyleSettings( true );
126 :
127 0 : if (bInitOutliner)
128 : {
129 : // fill Outliner with contents
130 0 : FillOutliner();
131 : }
132 :
133 0 : Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
134 0 : mrOutlineViewShell.GetViewShellBase().GetEventMultiplexer()->AddEventListener(
135 : aLink,
136 : tools::EventMultiplexerEvent::EID_CURRENT_PAGE
137 0 : | tools::EventMultiplexerEvent::EID_PAGE_ORDER);
138 :
139 0 : LanguageType eLang = mrOutliner.GetDefaultLanguage();
140 0 : maPageNumberFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE, eLang, 0 );
141 0 : maPageNumberFont.SetHeight( 500 );
142 :
143 0 : maBulletFont.SetColor( COL_AUTO );
144 0 : maBulletFont.SetHeight( 1000 );
145 0 : maBulletFont.SetCharSet(RTL_TEXTENCODING_MS_1252); // and replacing other values by standard
146 0 : maBulletFont.SetName( OUString( "StarSymbol" ) );
147 0 : maBulletFont.SetWeight(WEIGHT_NORMAL);
148 0 : maBulletFont.SetUnderline(UNDERLINE_NONE);
149 0 : maBulletFont.SetStrikeout(STRIKEOUT_NONE);
150 0 : maBulletFont.SetItalic(ITALIC_NONE);
151 0 : maBulletFont.SetOutline(false);
152 0 : maBulletFont.SetShadow(false);
153 :
154 0 : Reference<XFrame> xFrame (mrOutlineViewShell.GetViewShellBase().GetFrame()->GetTopFrame().GetFrameInterface(), UNO_QUERY);
155 :
156 0 : const OUString aSlotURL( ".uno:ShowSlide" );
157 0 : maSlideImage = GetImage( xFrame, aSlotURL, true );
158 :
159 : // Tell undo manager of the document about the undo manager of the
160 : // outliner, so that the former can synchronize with the later.
161 0 : sd::UndoManager* pDocUndoMgr = dynamic_cast<sd::UndoManager*>(mpDocSh->GetUndoManager());
162 0 : if (pDocUndoMgr != NULL)
163 0 : pDocUndoMgr->SetLinkedUndoManager(&mrOutliner.GetUndoManager());
164 0 : }
165 :
166 : /**
167 : * Destructor, restore Links, clear Oultiner
168 : */
169 0 : OutlineView::~OutlineView()
170 : {
171 : DBG_ASSERT(maDragAndDropModelGuard.get() == 0, "sd::OutlineView::~OutlineView(), prior drag operation not finished correctly!" );
172 :
173 0 : Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
174 0 : mrOutlineViewShell.GetViewShellBase().GetEventMultiplexer()->RemoveEventListener( aLink );
175 0 : DisconnectFromApplication();
176 :
177 0 : if( mpProgress )
178 0 : delete mpProgress;
179 :
180 : // unregister OutlinerViews and destroy them
181 0 : for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
182 : {
183 0 : if (mpOutlinerView[nView] != NULL)
184 : {
185 0 : mrOutliner.RemoveView( mpOutlinerView[nView] );
186 0 : delete mpOutlinerView[nView];
187 0 : mpOutlinerView[nView] = NULL;
188 : }
189 : }
190 :
191 0 : if (mrOutliner.GetViewCount() == 0)
192 : {
193 : // uninitialize Outliner: enable color display
194 0 : ResetLinks();
195 0 : sal_uLong nCntrl = mrOutliner.GetControlWord();
196 0 : mrOutliner.SetUpdateMode(false); // otherwise there will be drawn on SetControlWord
197 0 : mrOutliner.SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS);
198 0 : SvtAccessibilityOptions aOptions;
199 0 : mrOutliner.ForceAutoColor( aOptions.GetIsAutomaticFontColor() );
200 0 : mrOutliner.Clear();
201 : }
202 0 : }
203 :
204 0 : void OutlineView::ConnectToApplication (void)
205 : {
206 0 : mrOutlineViewShell.GetActiveWindow()->GrabFocus();
207 0 : Application::AddEventListener(LINK(this, OutlineView, AppEventListenerHdl));
208 0 : }
209 :
210 0 : void OutlineView::DisconnectFromApplication (void)
211 : {
212 0 : Application::RemoveEventListener(LINK(this, OutlineView, AppEventListenerHdl));
213 0 : }
214 :
215 0 : void OutlineView::Paint(const Rectangle& rRect, ::sd::Window* pWin)
216 : {
217 0 : OutlinerView* pOlView = GetViewByWindow(pWin);
218 :
219 0 : if (pOlView)
220 : {
221 0 : pOlView->HideCursor();
222 0 : pOlView->Paint(rRect);
223 :
224 0 : pOlView->ShowCursor(mbFirstPaint);
225 :
226 0 : mbFirstPaint = false;
227 : }
228 0 : }
229 :
230 0 : void OutlineView::InvalidateSlideNumberArea()
231 : {
232 0 : }
233 :
234 : /**
235 : * Window size was changed
236 : */
237 0 : void OutlineView::AdjustPosSizePixel(const Point &,const Size &,::sd::Window*)
238 : {
239 0 : }
240 :
241 0 : void OutlineView::AddWindowToPaintView(OutputDevice* pWin)
242 : {
243 0 : bool bAdded = false;
244 0 : bool bValidArea = false;
245 0 : Rectangle aOutputArea;
246 0 : const Color aWhiteColor( COL_WHITE );
247 0 : sal_uInt16 nView = 0;
248 :
249 0 : while (nView < MAX_OUTLINERVIEWS && !bAdded)
250 : {
251 0 : if (mpOutlinerView[nView] == NULL)
252 : {
253 0 : mpOutlinerView[nView] = new OutlinerView(&mrOutliner, dynamic_cast< ::sd::Window* >(pWin));
254 0 : mpOutlinerView[nView]->SetBackgroundColor( aWhiteColor );
255 0 : mrOutliner.InsertView(mpOutlinerView[nView], EE_APPEND);
256 0 : bAdded = true;
257 :
258 0 : if (bValidArea)
259 : {
260 0 : mpOutlinerView[nView]->SetOutputArea(aOutputArea);
261 : }
262 : }
263 0 : else if (!bValidArea)
264 : {
265 0 : aOutputArea = mpOutlinerView[nView]->GetOutputArea();
266 0 : bValidArea = true;
267 : }
268 :
269 0 : nView++;
270 : }
271 :
272 : // white background in Outliner
273 0 : pWin->SetBackground( Wallpaper( aWhiteColor ) );
274 :
275 0 : ::sd::View::AddWindowToPaintView(pWin);
276 0 : }
277 :
278 0 : void OutlineView::DeleteWindowFromPaintView(OutputDevice* pWin)
279 : {
280 0 : bool bRemoved = false;
281 0 : sal_uInt16 nView = 0;
282 : vcl::Window* pWindow;
283 :
284 0 : while (nView < MAX_OUTLINERVIEWS && !bRemoved)
285 : {
286 0 : if (mpOutlinerView[nView] != NULL)
287 : {
288 0 : pWindow = mpOutlinerView[nView]->GetWindow();
289 :
290 0 : if (pWindow == pWin)
291 : {
292 0 : mrOutliner.RemoveView( mpOutlinerView[nView] );
293 0 : delete mpOutlinerView[nView];
294 0 : mpOutlinerView[nView] = NULL;
295 0 : bRemoved = true;
296 : }
297 : }
298 :
299 0 : nView++;
300 : }
301 :
302 0 : ::sd::View::DeleteWindowFromPaintView(pWin);
303 0 : }
304 :
305 : /**
306 : * Return a pointer to the OutlinerView corresponding to the window
307 : */
308 0 : OutlinerView* OutlineView::GetViewByWindow (vcl::Window* pWin) const
309 : {
310 0 : OutlinerView* pOlView = NULL;
311 0 : for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
312 : {
313 0 : if (mpOutlinerView[nView] != NULL)
314 : {
315 0 : if ( pWin == mpOutlinerView[nView]->GetWindow() )
316 : {
317 0 : pOlView = mpOutlinerView[nView];
318 : }
319 : }
320 : }
321 0 : return (pOlView);
322 : }
323 :
324 : /**
325 : * Return the title before a random paragraph
326 : */
327 0 : Paragraph* OutlineView::GetPrevTitle(const Paragraph* pPara)
328 : {
329 0 : sal_Int32 nPos = mrOutliner.GetAbsPos(const_cast<Paragraph*>(pPara));
330 :
331 0 : if (nPos > 0)
332 : {
333 0 : while(nPos)
334 : {
335 0 : pPara = mrOutliner.GetParagraph(--nPos);
336 0 : if( mrOutliner.HasParaFlag(pPara, PARAFLAG_ISPAGE) )
337 : {
338 0 : return const_cast< Paragraph* >( pPara );
339 : }
340 : }
341 :
342 : }
343 0 : return NULL;
344 : }
345 :
346 : /**
347 : * Return the title after a random paragraph
348 : */
349 0 : Paragraph* OutlineView::GetNextTitle(const Paragraph* pPara)
350 : {
351 0 : Paragraph* pResult = const_cast< Paragraph* >( pPara );
352 :
353 0 : sal_Int32 nPos = mrOutliner.GetAbsPos(pResult);
354 :
355 0 : do
356 : {
357 0 : pResult = mrOutliner.GetParagraph(++nPos);
358 0 : if( pResult && mrOutliner.HasParaFlag(pResult, PARAFLAG_ISPAGE) )
359 0 : return pResult;
360 : }
361 : while( pResult );
362 :
363 0 : return NULL;
364 : }
365 :
366 : /**
367 : * Handler for inserting pages (paragraphs)
368 : */
369 0 : IMPL_LINK( OutlineView, ParagraphInsertedHdl, ::Outliner *, pOutliner )
370 : {
371 : // we get calls to this handler during binary insert of drag and drop contents but
372 : // we ignore it here and handle it later in OnEndPasteOrDrop()
373 0 : if( maDragAndDropModelGuard.get() == 0 )
374 : {
375 0 : OutlineViewPageChangesGuard aGuard(this);
376 :
377 0 : Paragraph* pPara = pOutliner->GetHdlParagraph();
378 :
379 0 : sal_Int32 nAbsPos = mrOutliner.GetAbsPos( pPara );
380 :
381 0 : UpdateParagraph( nAbsPos );
382 :
383 0 : if( (nAbsPos == 0) || mrOutliner.HasParaFlag(pPara,PARAFLAG_ISPAGE) || mrOutliner.HasParaFlag(mrOutliner.GetParagraph( nAbsPos-1 ), PARAFLAG_ISPAGE) )
384 : {
385 0 : InsertSlideForParagraph( pPara );
386 0 : InvalidateSlideNumberArea();
387 0 : }
388 : }
389 :
390 0 : return 0;
391 : }
392 :
393 : /** creates and inserts an empty slide for the given paragraph */
394 0 : SdPage* OutlineView::InsertSlideForParagraph( Paragraph* pPara )
395 : {
396 : DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::InsertSlideForParagraph(), model change without undo?!" );
397 :
398 0 : OutlineViewPageChangesGuard aGuard(this);
399 :
400 0 : mrOutliner.SetParaFlag( pPara, PARAFLAG_ISPAGE );
401 : // how many titles are there before the new title paragraph?
402 0 : sal_uLong nExample = 0L; // position of the "example" page
403 0 : sal_uLong nTarget = 0L; // position of insertion
404 0 : while(pPara)
405 : {
406 0 : pPara = GetPrevTitle(pPara);
407 0 : if (pPara)
408 0 : nTarget++;
409 : }
410 :
411 : // if a new paragraph is created via RETURN before the first paragraph, the
412 : // Outliner reports the old paragraph (which was moved down) as a new
413 : // paragraph
414 0 : if (nTarget == 1)
415 : {
416 0 : OUString aTest = mrOutliner.GetText(mrOutliner.GetParagraph(0));
417 0 : if (aTest.isEmpty())
418 : {
419 0 : nTarget = 0;
420 0 : }
421 : }
422 :
423 : // the "example" page is the previous page - if it is available
424 0 : if (nTarget > 0)
425 : {
426 0 : nExample = nTarget - 1;
427 :
428 0 : sal_uInt16 nPageCount = mrDoc.GetSdPageCount( PK_STANDARD );
429 0 : if( nExample >= nPageCount )
430 0 : nExample = nPageCount - 1;
431 : }
432 :
433 : /**********************************************************************
434 : * All the time, a standard page is created before a notes page.
435 : * It is ensured that after each standard page the corresponding notes page
436 : * follows. A handout page is exactly one handout page.
437 : **********************************************************************/
438 :
439 : // this page is exemplary
440 0 : SdPage* pExample = (SdPage*)mrDoc.GetSdPage((sal_uInt16)nExample, PK_STANDARD);
441 0 : SdPage* pPage = mrDoc.AllocSdPage(false);
442 :
443 0 : pPage->SetLayoutName(pExample->GetLayoutName());
444 :
445 : // insert (page)
446 0 : mrDoc.InsertPage(pPage, (sal_uInt16)(nTarget) * 2 + 1);
447 0 : if( isRecordingUndo() )
448 0 : AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pPage));
449 :
450 : // assign a master page to the standard page
451 0 : pPage->TRG_SetMasterPage(pExample->TRG_GetMasterPage());
452 :
453 : // set page size
454 0 : pPage->SetSize(pExample->GetSize());
455 0 : pPage->SetBorder( pExample->GetLftBorder(),
456 0 : pExample->GetUppBorder(),
457 0 : pExample->GetRgtBorder(),
458 0 : pExample->GetLwrBorder() );
459 :
460 : // create new presentation objects (after <Title> or <Title with subtitle>
461 : // follows <Title with outline>, otherwise apply the layout of the previous
462 : // page
463 0 : AutoLayout eAutoLayout = pExample->GetAutoLayout();
464 0 : if (eAutoLayout == AUTOLAYOUT_TITLE ||
465 : eAutoLayout == AUTOLAYOUT_ONLY_TITLE)
466 : {
467 0 : pPage->SetAutoLayout(AUTOLAYOUT_ENUM, true);
468 : }
469 : else
470 : {
471 0 : pPage->SetAutoLayout(pExample->GetAutoLayout(), true);
472 : }
473 :
474 : /**********************************************************************
475 : |* now the notes page
476 : \*********************************************************************/
477 0 : pExample = (SdPage*)mrDoc.GetSdPage((sal_uInt16)nExample, PK_NOTES);
478 0 : SdPage* pNotesPage = mrDoc.AllocSdPage(false);
479 :
480 0 : pNotesPage->SetLayoutName(pExample->GetLayoutName());
481 :
482 0 : pNotesPage->SetPageKind(PK_NOTES);
483 :
484 : // insert (notes page)
485 0 : mrDoc.InsertPage(pNotesPage, (sal_uInt16)(nTarget) * 2 + 2);
486 0 : if( isRecordingUndo() )
487 0 : AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
488 :
489 : // assign a master page to the notes page
490 0 : pNotesPage->TRG_SetMasterPage(pExample->TRG_GetMasterPage());
491 :
492 : // set page size, there must be already one page available
493 0 : pNotesPage->SetSize(pExample->GetSize());
494 0 : pNotesPage->SetBorder( pExample->GetLftBorder(),
495 0 : pExample->GetUppBorder(),
496 0 : pExample->GetRgtBorder(),
497 0 : pExample->GetLwrBorder() );
498 :
499 : // create presentation objects
500 0 : pNotesPage->SetAutoLayout(pExample->GetAutoLayout(), true);
501 :
502 0 : mrOutliner.UpdateFields();
503 :
504 0 : return pPage;
505 : }
506 :
507 : /**
508 : * Handler for deleting pages (paragraphs)
509 : */
510 0 : IMPL_LINK( OutlineView, ParagraphRemovingHdl, ::Outliner *, pOutliner )
511 : {
512 : DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::ParagraphRemovingHdl(), model change without undo?!" );
513 :
514 0 : OutlineViewPageChangesGuard aGuard(this);
515 :
516 0 : Paragraph* pPara = pOutliner->GetHdlParagraph();
517 0 : if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
518 : {
519 : // how many titles are in front of the title paragraph in question?
520 0 : sal_uLong nPos = 0L;
521 0 : while(pPara)
522 : {
523 0 : pPara = GetPrevTitle(pPara);
524 0 : if (pPara) nPos++;
525 : }
526 :
527 : // delete page and notes page
528 0 : sal_uInt16 nAbsPos = (sal_uInt16)nPos * 2 + 1;
529 0 : SdrPage* pPage = mrDoc.GetPage(nAbsPos);
530 0 : if( isRecordingUndo() )
531 0 : AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
532 0 : mrDoc.RemovePage(nAbsPos);
533 :
534 0 : nAbsPos = (sal_uInt16)nPos * 2 + 1;
535 0 : pPage = mrDoc.GetPage(nAbsPos);
536 0 : if( isRecordingUndo() )
537 0 : AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
538 0 : mrDoc.RemovePage(nAbsPos);
539 :
540 : // progress display if necessary
541 0 : if (mnPagesToProcess)
542 : {
543 0 : mnPagesProcessed++;
544 :
545 0 : if(mpProgress)
546 0 : mpProgress->SetState(mnPagesProcessed);
547 :
548 0 : if (mnPagesProcessed == mnPagesToProcess)
549 : {
550 0 : if(mpProgress)
551 : {
552 0 : delete mpProgress;
553 0 : mpProgress = NULL;
554 : }
555 0 : mnPagesToProcess = 0;
556 0 : mnPagesProcessed = 0;
557 : }
558 : }
559 0 : pOutliner->UpdateFields();
560 : }
561 :
562 0 : InvalidateSlideNumberArea();
563 :
564 0 : return 0;
565 : }
566 :
567 : /**
568 : * Handler for changing the indentation depth of paragraphs (requires inserting
569 : * or deleting of pages in some cases)
570 : */
571 0 : IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner *, pOutliner )
572 : {
573 : DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::DepthChangedHdl(), no undo for model change?!" );
574 :
575 0 : OutlineViewPageChangesGuard aGuard(this);
576 :
577 0 : Paragraph* pPara = pOutliner->GetHdlParagraph();
578 0 : if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && ((pOutliner->GetPrevFlags() & PARAFLAG_ISPAGE) == 0) )
579 : {
580 : // the current paragraph is transformed into a slide
581 :
582 0 : mrOutliner.SetDepth( pPara, -1 );
583 :
584 : // are multiple level 1 paragraphs being brought to level 0 and we
585 : // should start a progress view or a timer and didn't already?
586 0 : if (mnPagesToProcess == 0)
587 : {
588 0 : Window* pActWin = mrOutlineViewShell.GetActiveWindow();
589 0 : OutlinerView* pOlView = GetViewByWindow(pActWin);
590 :
591 0 : std::vector<Paragraph*> aSelList;
592 0 : pOlView->CreateSelectionList(aSelList);
593 :
594 0 : Paragraph *pParagraph = NULL;
595 0 : for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter)
596 : {
597 0 : pParagraph = *iter;
598 :
599 0 : if( !pOutliner->HasParaFlag( pParagraph, PARAFLAG_ISPAGE ) &&
600 0 : (pOutliner->GetDepth( pOutliner->GetAbsPos( pParagraph ) ) <= 0) )
601 0 : mnPagesToProcess++;
602 : }
603 :
604 0 : mnPagesToProcess++; // the paragraph being in level 0 already
605 : // should be included
606 0 : mnPagesProcessed = 0;
607 :
608 0 : if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD)
609 : {
610 0 : if( mpProgress )
611 0 : delete mpProgress;
612 :
613 0 : mpProgress = new SfxProgress( GetDocSh(), SD_RESSTR(STR_CREATE_PAGES), mnPagesToProcess );
614 : }
615 : else
616 : {
617 0 : mpDocSh->SetWaitCursor( true );
618 0 : }
619 : }
620 :
621 0 : ParagraphInsertedHdl(pOutliner);
622 :
623 0 : mnPagesProcessed++;
624 :
625 : // should there be a progress display?
626 0 : if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD)
627 : {
628 0 : if (mpProgress)
629 0 : mpProgress->SetState(mnPagesProcessed);
630 : }
631 :
632 : // was this the last page?
633 0 : if (mnPagesProcessed == mnPagesToProcess)
634 : {
635 0 : if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD && mpProgress)
636 : {
637 0 : delete mpProgress;
638 0 : mpProgress = NULL;
639 : }
640 : else
641 0 : mpDocSh->SetWaitCursor( false );
642 :
643 0 : mnPagesToProcess = 0;
644 0 : mnPagesProcessed = 0;
645 : }
646 0 : pOutliner->UpdateFields();
647 : }
648 0 : else if( !pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && ((pOutliner->GetPrevFlags() & PARAFLAG_ISPAGE) != 0) )
649 : {
650 : // the paragraph was a page but now becomes a normal paragraph
651 :
652 : // how many titles are before the title paragraph in question?
653 0 : sal_uLong nPos = 0L;
654 0 : Paragraph* pParagraph = pPara;
655 0 : while(pParagraph)
656 : {
657 0 : pParagraph = GetPrevTitle(pParagraph);
658 0 : if (pParagraph)
659 0 : nPos++;
660 : }
661 : // delete page and notes page
662 :
663 0 : sal_uInt16 nAbsPos = (sal_uInt16)nPos * 2 + 1;
664 0 : SdrPage* pPage = mrDoc.GetPage(nAbsPos);
665 0 : if( isRecordingUndo() )
666 0 : AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
667 0 : mrDoc.RemovePage(nAbsPos);
668 :
669 0 : nAbsPos = (sal_uInt16)nPos * 2 + 1;
670 0 : pPage = mrDoc.GetPage(nAbsPos);
671 0 : if( isRecordingUndo() )
672 0 : AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
673 0 : mrDoc.RemovePage(nAbsPos);
674 :
675 0 : pPage = GetPageForParagraph( pPara );
676 :
677 0 : mrOutliner.SetDepth( pPara, (pPage && (static_cast<SdPage*>(pPage)->GetAutoLayout() == AUTOLAYOUT_TITLE)) ? -1 : 0 );
678 :
679 : // progress display if necessary
680 0 : if (mnPagesToProcess)
681 : {
682 0 : mnPagesProcessed++;
683 0 : if (mpProgress)
684 0 : mpProgress->SetState(mnPagesProcessed);
685 :
686 0 : if (mnPagesProcessed == mnPagesToProcess)
687 : {
688 0 : if(mpProgress)
689 : {
690 0 : delete mpProgress;
691 0 : mpProgress = NULL;
692 : }
693 0 : mnPagesToProcess = 0;
694 0 : mnPagesProcessed = 0;
695 : }
696 : }
697 0 : pOutliner->UpdateFields();
698 : }
699 0 : else if ( (pOutliner->GetPrevDepth() == 1) && ( pOutliner->GetDepth( pOutliner->GetAbsPos( pPara ) ) == 2 ) )
700 : {
701 : // how many titles are in front of the title paragraph in question?
702 0 : sal_Int32 nPos = -1L;
703 :
704 0 : Paragraph* pParagraph = pPara;
705 0 : while(pParagraph)
706 : {
707 0 : pParagraph = GetPrevTitle(pParagraph);
708 0 : if (pParagraph)
709 0 : nPos++;
710 : }
711 :
712 0 : if(nPos >= 0)
713 : {
714 0 : SdPage*pPage = (SdPage*)mrDoc.GetSdPage( (sal_uInt16) nPos, PK_STANDARD);
715 :
716 0 : if(pPage && pPage->GetPresObj(PRESOBJ_TEXT))
717 0 : pOutliner->SetDepth( pPara, 0 );
718 : }
719 :
720 : }
721 : // how many titles are in front of the title paragraph in question?
722 0 : sal_Int32 nPos = -1L;
723 :
724 0 : Paragraph* pTempPara = pPara;
725 0 : while(pTempPara)
726 : {
727 0 : pTempPara = GetPrevTitle(pTempPara);
728 0 : if (pTempPara)
729 0 : nPos++;
730 : }
731 :
732 0 : if( nPos >= 0 )
733 : {
734 0 : SdPage* pPage = (SdPage*) mrDoc.GetSdPage( (sal_uInt16) nPos, PK_STANDARD );
735 :
736 0 : if( pPage )
737 : {
738 0 : SfxStyleSheet* pStyleSheet = NULL;
739 0 : sal_Int32 nPara = pOutliner->GetAbsPos( pPara );
740 0 : sal_Int16 nDepth = pOutliner->GetDepth( nPara );
741 0 : bool bSubTitle = pPage->GetPresObj(PRESOBJ_TEXT) != NULL;
742 :
743 0 : if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
744 : {
745 0 : pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
746 : }
747 0 : else if( bSubTitle )
748 : {
749 0 : pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT );
750 : }
751 : else
752 : {
753 0 : pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
754 :
755 0 : if( nDepth > 0 )
756 : {
757 0 : OUString aNewStyleSheetName = pStyleSheet->GetName();
758 0 : if (!aNewStyleSheetName.isEmpty())
759 0 : aNewStyleSheetName = aNewStyleSheetName.copy(0, aNewStyleSheetName.getLength() - 1);
760 0 : aNewStyleSheetName += OUString::number( nDepth+1 );
761 0 : SfxStyleSheetBasePool* pStylePool = mrDoc.GetStyleSheetPool();
762 0 : pStyleSheet = (SfxStyleSheet*) pStylePool->Find( aNewStyleSheetName, pStyleSheet->GetFamily() );
763 : }
764 : }
765 :
766 : // before we set the style sheet we need to preserve the bullet item
767 : // since all items will be deleted while setting a new style sheet
768 0 : SfxItemSet aOldAttrs( pOutliner->GetParaAttribs( nPara ) );
769 :
770 0 : pOutliner->SetStyleSheet( nPara, pStyleSheet );
771 :
772 : // restore the old bullet item but not if the style changed
773 0 : if ( pOutliner->GetPrevDepth() != -1 && nDepth != -1 &&
774 0 : aOldAttrs.GetItemState( EE_PARA_NUMBULLET ) == SfxItemState::SET )
775 : {
776 0 : SfxItemSet aAttrs( pOutliner->GetParaAttribs( nPara ) );
777 0 : aAttrs.Put( *aOldAttrs.GetItem( EE_PARA_NUMBULLET ) );
778 0 : pOutliner->SetParaAttribs( nPara, aAttrs );
779 0 : }
780 : }
781 : }
782 :
783 0 : InvalidateSlideNumberArea();
784 :
785 0 : return 0;
786 : }
787 :
788 : /**
789 : * Handler for StatusEvents
790 : */
791 0 : IMPL_LINK_NOARG(OutlineView, StatusEventHdl)
792 : {
793 0 : ::sd::Window* pWin = mrOutlineViewShell.GetActiveWindow();
794 0 : OutlinerView* pOutlinerView = GetViewByWindow(pWin);
795 0 : Rectangle aVis = pOutlinerView->GetVisArea();
796 : Rectangle aText = Rectangle(Point(0,0),
797 : Size(mnPaperWidth,
798 0 : mrOutliner.GetTextHeight()));
799 0 : Rectangle aWin(Point(0,0), pWin->GetOutputSizePixel());
800 0 : aWin = pWin->PixelToLogic(aWin);
801 :
802 0 : if (!aVis.IsEmpty()) // not when opening
803 : {
804 0 : if (aWin.GetHeight() > aText.Bottom())
805 0 : aText.Bottom() = aWin.GetHeight();
806 :
807 : mrOutlineViewShell.InitWindows(Point(0,0), aText.GetSize(),
808 0 : Point(aVis.TopLeft()));
809 0 : mrOutlineViewShell.UpdateScrollBars();
810 : }
811 :
812 0 : InvalidateSlideNumberArea();
813 0 : return 0;
814 : }
815 :
816 0 : IMPL_LINK_NOARG(OutlineView, BeginDropHdl)
817 : {
818 : DBG_ASSERT(maDragAndDropModelGuard.get() == 0, "sd::OutlineView::BeginDropHdl(), prior drag operation not finished correctly!" );
819 :
820 0 : maDragAndDropModelGuard.reset( new OutlineViewModelChangeGuard( *this ) );
821 0 : return 0;
822 : }
823 :
824 0 : IMPL_LINK_NOARG(OutlineView, EndDropHdl)
825 : {
826 0 : maDragAndDropModelGuard.reset(0);
827 0 : InvalidateSlideNumberArea();
828 0 : return 0;
829 : }
830 :
831 : /**
832 : * Handler for the start of a paragraph movement
833 : */
834 0 : IMPL_LINK( OutlineView, BeginMovingHdl, ::Outliner *, pOutliner )
835 : {
836 0 : OutlineViewPageChangesGuard aGuard(this);
837 :
838 : // list of selected title paragraphs
839 0 : mpOutlinerView[0]->CreateSelectionList(maSelectedParas);
840 :
841 0 : for (std::vector<Paragraph*>::iterator it = maSelectedParas.begin(); it != maSelectedParas.end();)
842 : {
843 0 : if (!pOutliner->HasParaFlag(*it, PARAFLAG_ISPAGE))
844 0 : it = maSelectedParas.erase(it);
845 : else
846 0 : ++it;
847 : }
848 :
849 : // select the pages belonging to the paragraphs on level 0 to select
850 0 : sal_uInt16 nPos = 0;
851 0 : sal_Int32 nParaPos = 0;
852 0 : Paragraph* pPara = pOutliner->GetParagraph( 0 );
853 0 : std::vector<Paragraph*>::const_iterator fiter;
854 :
855 0 : while(pPara)
856 : {
857 0 : if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) ) // one page?
858 : {
859 0 : maOldParaOrder.push_back(pPara);
860 0 : SdPage* pPage = mrDoc.GetSdPage(nPos, PK_STANDARD);
861 :
862 0 : fiter = std::find(maSelectedParas.begin(),maSelectedParas.end(),pPara);
863 :
864 0 : pPage->SetSelected(fiter != maSelectedParas.end());
865 :
866 0 : ++nPos;
867 : }
868 0 : pPara = pOutliner->GetParagraph( ++nParaPos );
869 : }
870 :
871 0 : return 0;
872 : }
873 :
874 : /**
875 : * Handler for the end of a paragraph movement
876 : */
877 0 : IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner )
878 : {
879 0 : OutlineViewPageChangesGuard aGuard(this);
880 :
881 : DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::EndMovingHdl(), model change without undo?!" );
882 :
883 : // look for insertion position via the first paragraph
884 0 : Paragraph* pSearchIt = maSelectedParas.empty() ? NULL : *(maSelectedParas.begin());
885 :
886 : // look for the first of the selected paragraphs in the new ordering
887 0 : sal_uInt16 nPosNewOrder = 0;
888 0 : sal_Int32 nParaPos = 0;
889 0 : Paragraph* pPara = pOutliner->GetParagraph( 0 );
890 0 : Paragraph* pPrev = NULL;
891 0 : while (pPara && pPara != pSearchIt)
892 : {
893 0 : if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
894 : {
895 0 : nPosNewOrder++;
896 0 : pPrev = pPara;
897 : }
898 0 : pPara = pOutliner->GetParagraph( ++nParaPos );
899 : }
900 :
901 0 : sal_uInt16 nPos = nPosNewOrder; // don't change nPosNewOrder
902 0 : if (nPos == 0)
903 : {
904 0 : nPos = (sal_uInt16)-1; // insert before the first page
905 : }
906 : else
907 : {
908 : // look for the predecessor in the old ordering
909 : std::vector<Paragraph*>::const_iterator it = std::find(maOldParaOrder.begin(),
910 : maOldParaOrder.end(),
911 0 : pPrev);
912 :
913 0 : if (it != maOldParaOrder.end())
914 0 : nPos = static_cast<sal_uInt16>(it-maOldParaOrder.begin());
915 : else
916 0 : nPos = 0xffff;
917 :
918 : DBG_ASSERT(nPos != 0xffff, "Paragraph not found");
919 : }
920 :
921 0 : mrDoc.MovePages(nPos);
922 :
923 : // deselect the pages again
924 0 : sal_uInt16 nPageCount = (sal_uInt16)maSelectedParas.size();
925 0 : while (nPageCount)
926 : {
927 0 : SdPage* pPage = mrDoc.GetSdPage(nPosNewOrder, PK_STANDARD);
928 0 : pPage->SetSelected(false);
929 0 : nPosNewOrder++;
930 0 : nPageCount--;
931 : }
932 :
933 0 : pOutliner->UpdateFields();
934 :
935 0 : maSelectedParas.clear();
936 0 : maOldParaOrder.clear();
937 :
938 0 : InvalidateSlideNumberArea();
939 :
940 0 : return 0;
941 : }
942 :
943 : /**
944 : * Look for the title text object in one page of the model
945 : */
946 0 : SdrTextObj* OutlineView::GetTitleTextObject(SdrPage* pPage)
947 : {
948 0 : const size_t nObjectCount = pPage->GetObjCount();
949 0 : SdrObject* pObject = NULL;
950 0 : SdrTextObj* pResult = NULL;
951 :
952 0 : for (size_t nObject = 0; nObject < nObjectCount; ++nObject)
953 : {
954 0 : pObject = pPage->GetObj(nObject);
955 0 : if (pObject->GetObjInventor() == SdrInventor &&
956 0 : pObject->GetObjIdentifier() == OBJ_TITLETEXT)
957 : {
958 0 : pResult = (SdrTextObj*)pObject;
959 0 : break;
960 : }
961 : }
962 0 : return pResult;
963 : }
964 :
965 : /**
966 : * Look for the outline text object in one page of the model
967 : */
968 0 : SdrTextObj* OutlineView::GetOutlineTextObject(SdrPage* pPage)
969 : {
970 0 : const size_t nObjectCount = pPage->GetObjCount();
971 0 : SdrObject* pObject = NULL;
972 0 : SdrTextObj* pResult = NULL;
973 :
974 0 : for (size_t nObject = 0; nObject < nObjectCount; ++nObject)
975 : {
976 0 : pObject = pPage->GetObj(nObject);
977 0 : if (pObject->GetObjInventor() == SdrInventor &&
978 0 : pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
979 : {
980 0 : pResult = (SdrTextObj*)pObject;
981 0 : break;
982 : }
983 : }
984 0 : return pResult;
985 : }
986 :
987 0 : SdrTextObj* OutlineView::CreateTitleTextObject(SdPage* pPage)
988 : {
989 : DBG_ASSERT( GetTitleTextObject(pPage) == 0, "sd::OutlineView::CreateTitleTextObject(), there is already a title text object!" );
990 :
991 0 : if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
992 : {
993 : // simple case
994 0 : pPage->SetAutoLayout( AUTOLAYOUT_ONLY_TITLE, true );
995 : }
996 : else
997 : {
998 : // we already have a layout with a title but the title
999 : // object was deleted, create a new one
1000 0 : pPage->InsertAutoLayoutShape( 0, PRESOBJ_TITLE, false, pPage->GetTitleRect(), true );
1001 : }
1002 :
1003 0 : return GetTitleTextObject(pPage);
1004 : }
1005 :
1006 0 : SdrTextObj* OutlineView::CreateOutlineTextObject(SdPage* pPage)
1007 : {
1008 : DBG_ASSERT( GetOutlineTextObject(pPage) == 0, "sd::OutlineView::CreateOutlineTextObject(), there is already a layout text object!" );
1009 :
1010 0 : AutoLayout eNewLayout = pPage->GetAutoLayout();
1011 0 : switch( eNewLayout )
1012 : {
1013 : case AUTOLAYOUT_NONE:
1014 : case AUTOLAYOUT_ONLY_TITLE:
1015 0 : case AUTOLAYOUT_TITLE: eNewLayout = AUTOLAYOUT_ENUM; break;
1016 :
1017 0 : case AUTOLAYOUT_CHART: eNewLayout = AUTOLAYOUT_CHARTTEXT; break;
1018 :
1019 : case AUTOLAYOUT_ORG:
1020 : case AUTOLAYOUT_TAB:
1021 0 : case AUTOLAYOUT_OBJ: eNewLayout = AUTOLAYOUT_OBJTEXT; break;
1022 : default:
1023 0 : break;
1024 : }
1025 :
1026 0 : if( eNewLayout != pPage->GetAutoLayout() )
1027 : {
1028 0 : pPage->SetAutoLayout( eNewLayout, true );
1029 : }
1030 : else
1031 : {
1032 : // we already have a layout with a text but the text
1033 : // object was deleted, create a new one
1034 : pPage->InsertAutoLayoutShape( 0,
1035 : PRESOBJ_OUTLINE,
1036 0 : false, pPage->GetLayoutRect(), true );
1037 : }
1038 :
1039 0 : return GetOutlineTextObject(pPage);
1040 : }
1041 :
1042 : /** updates draw model with all changes from outliner model */
1043 0 : bool OutlineView::PrepareClose(bool)
1044 : {
1045 0 : ::sd::UndoManager* pDocUndoMgr = dynamic_cast<sd::UndoManager*>(mpDocSh->GetUndoManager());
1046 0 : if (pDocUndoMgr != NULL)
1047 0 : pDocUndoMgr->SetLinkedUndoManager(NULL);
1048 :
1049 0 : mrOutliner.GetUndoManager().Clear();
1050 :
1051 0 : BegUndo(SD_RESSTR(STR_UNDO_CHANGE_TITLE_AND_LAYOUT));
1052 0 : UpdateDocument();
1053 0 : EndUndo();
1054 0 : mrDoc.SetSelected(GetActualPage(), true);
1055 0 : return true;
1056 : }
1057 :
1058 : /**
1059 : * Set attributes of the selected text
1060 : */
1061 0 : bool OutlineView::SetAttributes(const SfxItemSet& rSet, bool )
1062 : {
1063 0 : bool bOk = false;
1064 :
1065 0 : OutlinerView* pOlView = GetViewByWindow(mrOutlineViewShell.GetActiveWindow());
1066 :
1067 0 : if (pOlView)
1068 : {
1069 0 : pOlView->SetAttribs(rSet);
1070 0 : bOk = true;
1071 : }
1072 :
1073 0 : mrOutlineViewShell.Invalidate (SID_PREVIEW_STATE);
1074 :
1075 0 : return (bOk);
1076 : }
1077 :
1078 : /**
1079 : * Get attributes of the selected text
1080 : */
1081 0 : bool OutlineView::GetAttributes( SfxItemSet& rTargetSet, bool ) const
1082 : {
1083 : OutlinerView* pOlView = GetViewByWindow(
1084 0 : mrOutlineViewShell.GetActiveWindow());
1085 : assert(pOlView && "keine OutlinerView gefunden");
1086 :
1087 0 : rTargetSet.Put( pOlView->GetAttribs(), false );
1088 0 : return true;
1089 : }
1090 :
1091 : /** creates outliner model from draw model */
1092 0 : void OutlineView::FillOutliner()
1093 : {
1094 0 : mrOutliner.GetUndoManager().Clear();
1095 0 : mrOutliner.EnableUndo(false);
1096 0 : ResetLinks();
1097 0 : mrOutliner.SetUpdateMode(false);
1098 :
1099 0 : Paragraph* pTitleToSelect = NULL;
1100 0 : sal_uLong nPageCount = mrDoc.GetSdPageCount(PK_STANDARD);
1101 :
1102 : // fill outliner with paragraphs from slides title & (outlines|subtitles)
1103 0 : for (sal_uInt16 nPage = 0; nPage < nPageCount; nPage++)
1104 : {
1105 0 : SdPage* pPage = (SdPage*)mrDoc.GetSdPage(nPage, PK_STANDARD);
1106 0 : Paragraph * pPara = NULL;
1107 :
1108 : // take text from title shape
1109 0 : SdrTextObj* pTO = GetTitleTextObject(pPage);
1110 0 : if(pTO && !(pTO->IsEmptyPresObj()))
1111 : {
1112 0 : OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
1113 0 : if (pOPO)
1114 : {
1115 0 : bool bVertical = pOPO->IsVertical();
1116 0 : pOPO->SetVertical( false );
1117 0 : mrOutliner.AddText(*pOPO);
1118 0 : pOPO->SetVertical( bVertical );
1119 0 : pPara = mrOutliner.GetParagraph( mrOutliner.GetParagraphCount()-1 );
1120 : }
1121 : }
1122 :
1123 0 : if( pPara == 0 ) // no title, insert an empty paragraph
1124 : {
1125 0 : pPara = mrOutliner.Insert(OUString());
1126 0 : mrOutliner.SetDepth(pPara, -1);
1127 :
1128 : // do not apply hard attributes from the previous paragraph
1129 : mrOutliner.SetParaAttribs( mrOutliner.GetAbsPos(pPara),
1130 0 : mrOutliner.GetEmptyItemSet() );
1131 :
1132 0 : mrOutliner.SetStyleSheet( mrOutliner.GetAbsPos( pPara ), pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ) );
1133 : }
1134 :
1135 0 : mrOutliner.SetParaFlag( pPara, PARAFLAG_ISPAGE );
1136 :
1137 0 : sal_Int32 nPara = mrOutliner.GetAbsPos( pPara );
1138 :
1139 0 : UpdateParagraph( nPara );
1140 :
1141 : // remember paragraph of currently selected page
1142 0 : if (pPage->IsSelected())
1143 0 : pTitleToSelect = pPara;
1144 :
1145 : // take text from subtitle or outline
1146 0 : pTO = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT));
1147 0 : const bool bSubTitle = pTO != 0;
1148 :
1149 0 : if (!pTO) // if no subtile found, try outline
1150 0 : pTO = GetOutlineTextObject(pPage);
1151 :
1152 0 : if(pTO && !(pTO->IsEmptyPresObj())) // found some text
1153 : {
1154 0 : OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
1155 0 : if (pOPO)
1156 : {
1157 0 : sal_Int32 nParaCount1 = mrOutliner.GetParagraphCount();
1158 0 : bool bVertical = pOPO->IsVertical();
1159 0 : pOPO->SetVertical( false );
1160 0 : mrOutliner.AddText(*pOPO);
1161 0 : pOPO->SetVertical( bVertical );
1162 :
1163 0 : sal_Int32 nParaCount2 = mrOutliner.GetParagraphCount();
1164 0 : for (sal_Int32 n = nParaCount1; n < nParaCount2; n++)
1165 : {
1166 0 : if( bSubTitle )
1167 : {
1168 0 : Paragraph* p = mrOutliner.GetParagraph(n);
1169 0 : if(p && mrOutliner.GetDepth( n ) > 0 )
1170 0 : mrOutliner.SetDepth(p, 0);
1171 : }
1172 :
1173 0 : UpdateParagraph( n );
1174 : }
1175 : }
1176 : }
1177 : }
1178 :
1179 : // place cursor at the start
1180 0 : Paragraph* pFirstPara = mrOutliner.GetParagraph( 0 );
1181 0 : mpOutlinerView[0]->Select( pFirstPara, true, false );
1182 0 : mpOutlinerView[0]->Select( pFirstPara, false, false );
1183 :
1184 : // select title of slide that was selected
1185 0 : if (pTitleToSelect)
1186 0 : mpOutlinerView[0]->Select(pTitleToSelect, true, false);
1187 :
1188 0 : SetLinks();
1189 :
1190 0 : mrOutliner.EnableUndo(true);
1191 :
1192 0 : mrOutliner.SetUpdateMode(true);
1193 0 : }
1194 :
1195 : /**
1196 : * Handler for deleting of level 0 paragraphs (pages): Warning
1197 : */
1198 0 : IMPL_LINK_NOARG(OutlineView, RemovingPagesHdl)
1199 : {
1200 0 : sal_Int32 nNumOfPages = mrOutliner.GetSelPageCount();
1201 :
1202 0 : if (nNumOfPages > PROCESS_WITH_PROGRESS_THRESHOLD)
1203 : {
1204 0 : mnPagesToProcess = nNumOfPages;
1205 0 : mnPagesProcessed = 0;
1206 : }
1207 :
1208 0 : if (mnPagesToProcess)
1209 : {
1210 0 : if( mpProgress )
1211 0 : delete mpProgress;
1212 :
1213 0 : mpProgress = new SfxProgress( GetDocSh(), SD_RESSTR(STR_DELETE_PAGES), mnPagesToProcess );
1214 : }
1215 0 : mrOutliner.UpdateFields();
1216 :
1217 0 : InvalidateSlideNumberArea();
1218 :
1219 0 : return 1;
1220 : }
1221 :
1222 : /**
1223 : * Handler for indenting level 0 paragraphs (pages): Warning
1224 : */
1225 0 : IMPL_LINK_INLINE_START( OutlineView, IndentingPagesHdl, OutlinerView *, pOutlinerView )
1226 : {
1227 0 : return RemovingPagesHdl(pOutlinerView);
1228 : }
1229 0 : IMPL_LINK_INLINE_END( OutlineView, IndentingPagesHdl, OutlinerView *, pOutlinerView )
1230 :
1231 : /** returns the first slide that is selected in the outliner or where
1232 : the cursor is located */
1233 0 : SdPage* OutlineView::GetActualPage()
1234 : {
1235 0 : ::sd::Window* pWin = mrOutlineViewShell.GetActiveWindow();
1236 0 : OutlinerView* pActiveView = GetViewByWindow(pWin);
1237 :
1238 0 : std::vector<Paragraph*> aSelList;
1239 0 : pActiveView->CreateSelectionList(aSelList);
1240 :
1241 0 : Paragraph *pPar = aSelList.empty() ? NULL : *(aSelList.begin());
1242 0 : SdPage* pCurrent = GetPageForParagraph(pPar);
1243 :
1244 : DBG_ASSERT( pCurrent ||
1245 : (mpDocSh->GetUndoManager() && static_cast< sd::UndoManager *>(mpDocSh->GetUndoManager())->IsDoing()) ||
1246 : maDragAndDropModelGuard.get(),
1247 : "sd::OutlineView::GetActualPage(), no current page?" );
1248 :
1249 0 : if( pCurrent )
1250 0 : return pCurrent;
1251 :
1252 0 : return mrDoc.GetSdPage( 0, PK_STANDARD );
1253 : }
1254 :
1255 0 : SdPage* OutlineView::GetPageForParagraph( Paragraph* pPara )
1256 : {
1257 0 : if( !mrOutliner.HasParaFlag(pPara,PARAFLAG_ISPAGE) )
1258 0 : pPara = GetPrevTitle(pPara);
1259 :
1260 0 : sal_uInt32 nPageToSelect = 0;
1261 0 : while(pPara)
1262 : {
1263 0 : pPara = GetPrevTitle(pPara);
1264 0 : if(pPara)
1265 0 : nPageToSelect++;
1266 : }
1267 :
1268 0 : if( nPageToSelect < (sal_uInt32)mrDoc.GetSdPageCount( PK_STANDARD ) )
1269 0 : return static_cast< SdPage* >( mrDoc.GetSdPage( (sal_uInt16)nPageToSelect, PK_STANDARD) );
1270 :
1271 0 : return 0;
1272 : }
1273 :
1274 0 : Paragraph* OutlineView::GetParagraphForPage( ::Outliner& rOutl, SdPage* pPage )
1275 : {
1276 : // get the number of paragraphs with ident 0 we need to skip before
1277 : // we finde the actual page
1278 0 : sal_uInt32 nPagesToSkip = (pPage->GetPageNum() - 1) >> 1;
1279 :
1280 0 : sal_Int32 nParaPos = 0;
1281 0 : Paragraph* pPara = rOutl.GetParagraph( 0 );
1282 0 : while( pPara )
1283 : {
1284 : // if this paragraph is a page ...
1285 0 : if( mrOutliner.HasParaFlag(pPara,PARAFLAG_ISPAGE) )
1286 : {
1287 : // see if we already skiped enough pages
1288 0 : if( 0 == nPagesToSkip )
1289 0 : break; // and if so, end the loop
1290 :
1291 : // we skiped another page
1292 0 : nPagesToSkip--;
1293 : }
1294 :
1295 : // get next paragraph
1296 0 : pPara = mrOutliner.GetParagraph( ++nParaPos );
1297 : }
1298 :
1299 0 : return pPara;
1300 : }
1301 :
1302 : /** selects the paragraph for the given page at the outliner view*/
1303 0 : void OutlineView::SetActualPage( SdPage* pActual )
1304 : {
1305 0 : if( pActual && dynamic_cast<Outliner&>(mrOutliner).GetIgnoreCurrentPageChangesLevel()==0 && !mbFirstPaint)
1306 : {
1307 : // if we found a paragraph, select its text at the outliner view
1308 0 : Paragraph* pPara = GetParagraphForPage( mrOutliner, pActual );
1309 0 : if( pPara )
1310 0 : mpOutlinerView[0]->Select( pPara, true, false );
1311 : }
1312 0 : }
1313 :
1314 : /**
1315 : * Get StyleSheet from the selection
1316 : */
1317 0 : SfxStyleSheet* OutlineView::GetStyleSheet() const
1318 : {
1319 0 : ::sd::Window* pActWin = mrOutlineViewShell.GetActiveWindow();
1320 0 : OutlinerView* pOlView = GetViewByWindow(pActWin);
1321 0 : SfxStyleSheet* pResult = pOlView->GetStyleSheet();
1322 0 : return pResult;
1323 : }
1324 :
1325 : /**
1326 : * Mark pages as selected / not selected
1327 : */
1328 0 : void OutlineView::SetSelectedPages()
1329 : {
1330 : // list of selected title paragraphs
1331 0 : std::vector<Paragraph*> aSelParas;
1332 0 : mpOutlinerView[0]->CreateSelectionList(aSelParas);
1333 :
1334 0 : for (std::vector<Paragraph*>::iterator it = aSelParas.begin(); it != aSelParas.end();)
1335 : {
1336 0 : if (!mrOutliner.HasParaFlag(*it, PARAFLAG_ISPAGE))
1337 0 : it = aSelParas.erase(it);
1338 : else
1339 0 : ++it;
1340 : }
1341 :
1342 : // select the pages belonging to the paragraphs on level 0 to select
1343 0 : sal_uInt16 nPos = 0;
1344 0 : sal_Int32 nParaPos = 0;
1345 0 : Paragraph *pPara = mrOutliner.GetParagraph( 0 );
1346 0 : std::vector<Paragraph*>::const_iterator fiter;
1347 :
1348 0 : while(pPara)
1349 : {
1350 0 : if( mrOutliner.HasParaFlag(pPara, PARAFLAG_ISPAGE) ) // one page
1351 : {
1352 0 : SdPage* pPage = mrDoc.GetSdPage(nPos, PK_STANDARD);
1353 : DBG_ASSERT(pPage!=NULL,
1354 : "Trying to select non-existing page OutlineView::SetSelectedPages()");
1355 :
1356 0 : if (pPage)
1357 : {
1358 0 : fiter = std::find(aSelParas.begin(),aSelParas.end(),pPara);
1359 0 : pPage->SetSelected(fiter != aSelParas.end());
1360 : }
1361 :
1362 0 : nPos++;
1363 : }
1364 :
1365 0 : pPara = mrOutliner.GetParagraph( ++nParaPos );
1366 0 : }
1367 0 : }
1368 :
1369 : /**
1370 : * Set new links
1371 : */
1372 0 : void OutlineView::SetLinks()
1373 : {
1374 : // set notification links
1375 0 : mrOutliner.SetParaInsertedHdl(LINK(this, OutlineView, ParagraphInsertedHdl));
1376 0 : mrOutliner.SetParaRemovingHdl(LINK(this, OutlineView, ParagraphRemovingHdl));
1377 0 : mrOutliner.SetDepthChangedHdl(LINK(this, OutlineView, DepthChangedHdl));
1378 0 : mrOutliner.SetBeginMovingHdl(LINK(this, OutlineView, BeginMovingHdl));
1379 0 : mrOutliner.SetEndMovingHdl(LINK(this, OutlineView, EndMovingHdl));
1380 0 : mrOutliner.SetRemovingPagesHdl(LINK(this, OutlineView, RemovingPagesHdl));
1381 0 : mrOutliner.SetIndentingPagesHdl(LINK(this, OutlineView, IndentingPagesHdl));
1382 0 : mrOutliner.SetStatusEventHdl(LINK(this, OutlineView, StatusEventHdl));
1383 0 : mrOutliner.SetBeginDropHdl(LINK(this,OutlineView, BeginDropHdl));
1384 0 : mrOutliner.SetEndDropHdl(LINK(this,OutlineView, EndDropHdl));
1385 0 : mrOutliner.SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
1386 0 : mrOutliner.SetBeginPasteOrDropHdl(LINK(this,OutlineView, BeginPasteOrDropHdl));
1387 0 : mrOutliner.SetEndPasteOrDropHdl(LINK(this,OutlineView, EndPasteOrDropHdl));
1388 0 : }
1389 :
1390 : /**
1391 : * Restore old links
1392 : */
1393 0 : void OutlineView::ResetLinks() const
1394 : {
1395 0 : Link aEmptyLink;
1396 0 : mrOutliner.SetParaInsertedHdl(aEmptyLink);
1397 0 : mrOutliner.SetParaRemovingHdl(aEmptyLink);
1398 0 : mrOutliner.SetDepthChangedHdl(aEmptyLink);
1399 0 : mrOutliner.SetBeginMovingHdl(aEmptyLink);
1400 0 : mrOutliner.SetEndMovingHdl(aEmptyLink);
1401 0 : mrOutliner.SetStatusEventHdl(aEmptyLink);
1402 0 : mrOutliner.SetRemovingPagesHdl(aEmptyLink);
1403 0 : mrOutliner.SetIndentingPagesHdl(aEmptyLink);
1404 0 : mrOutliner.SetDrawPortionHdl(aEmptyLink);
1405 0 : mrOutliner.SetBeginPasteOrDropHdl(aEmptyLink);
1406 0 : mrOutliner.SetEndPasteOrDropHdl(aEmptyLink);
1407 0 : }
1408 :
1409 0 : sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, sal_uInt16)
1410 : {
1411 0 : return DND_ACTION_NONE;
1412 : }
1413 :
1414 0 : sal_Int8 OutlineView::ExecuteDrop( const ExecuteDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, sal_uInt16)
1415 : {
1416 0 : return DND_ACTION_NONE;
1417 : }
1418 :
1419 : // Re-implement GetScriptType for this view to get correct results
1420 0 : sal_uInt16 OutlineView::GetScriptType() const
1421 : {
1422 0 : sal_uInt16 nScriptType = ::sd::View::GetScriptType();
1423 :
1424 0 : OutlinerParaObject* pTempOPObj = mrOutliner.CreateParaObject();
1425 0 : if(pTempOPObj)
1426 : {
1427 0 : nScriptType = pTempOPObj->GetTextObject().GetScriptType();
1428 0 : delete pTempOPObj;
1429 : }
1430 :
1431 0 : return nScriptType;
1432 : }
1433 :
1434 0 : void OutlineView::onUpdateStyleSettings( bool bForceUpdate /* = false */ )
1435 : {
1436 0 : svtools::ColorConfig aColorConfig;
1437 0 : const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
1438 0 : if( bForceUpdate || (maDocColor != aDocColor) )
1439 : {
1440 : sal_uInt16 nView;
1441 0 : for( nView = 0; nView < MAX_OUTLINERVIEWS; nView++ )
1442 : {
1443 0 : if (mpOutlinerView[nView] != NULL)
1444 : {
1445 0 : mpOutlinerView[nView]->SetBackgroundColor( aDocColor );
1446 :
1447 0 : vcl::Window* pWindow = mpOutlinerView[nView]->GetWindow();
1448 :
1449 0 : if( pWindow )
1450 0 : pWindow->SetBackground( Wallpaper( aDocColor ) );
1451 :
1452 : }
1453 : }
1454 :
1455 0 : mrOutliner.SetBackgroundColor( aDocColor );
1456 :
1457 0 : maDocColor = aDocColor;
1458 0 : }
1459 0 : }
1460 :
1461 0 : IMPL_LINK_NOARG(OutlineView, AppEventListenerHdl)
1462 : {
1463 0 : onUpdateStyleSettings();
1464 0 : return 0;
1465 : }
1466 :
1467 0 : IMPL_LINK(OutlineView, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent)
1468 : {
1469 0 : if (pEvent != NULL)
1470 : {
1471 0 : switch (pEvent->meEventId)
1472 : {
1473 : case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
1474 0 : SetActualPage(mrOutlineViewShell.GetActualPage());
1475 0 : InvalidateSlideNumberArea();
1476 0 : break;
1477 :
1478 : case tools::EventMultiplexerEvent::EID_PAGE_ORDER:
1479 0 : if (dynamic_cast<Outliner&>(mrOutliner).GetIgnoreCurrentPageChangesLevel()==0)
1480 : {
1481 0 : if (((mrDoc.GetPageCount()-1)%2) == 0)
1482 : {
1483 0 : mrOutliner.Clear();
1484 0 : FillOutliner();
1485 0 : ::sd::Window* pWindow = mrOutlineViewShell.GetActiveWindow();
1486 0 : if (pWindow != NULL)
1487 0 : pWindow->Invalidate();
1488 : }
1489 : }
1490 0 : break;
1491 : }
1492 : }
1493 0 : return 0;
1494 : }
1495 :
1496 0 : void OutlineView::IgnoreCurrentPageChanges (bool bIgnoreChanges)
1497 : {
1498 0 : if (bIgnoreChanges)
1499 0 : dynamic_cast<Outliner&>(mrOutliner).IncreIgnoreCurrentPageChangesLevel();
1500 : else
1501 0 : dynamic_cast<Outliner&>(mrOutliner).DecreIgnoreCurrentPageChangesLevel();
1502 0 : }
1503 :
1504 : /** call this method before you do anything that can modify the outliner
1505 : and or the drawing document model. It will create needed undo actions */
1506 0 : void OutlineView::BeginModelChange()
1507 : {
1508 0 : mrOutliner.GetUndoManager().EnterListAction("", "");
1509 0 : BegUndo(SD_RESSTR(STR_UNDO_CHANGE_TITLE_AND_LAYOUT));
1510 0 : }
1511 :
1512 : /** call this method after BeginModelChange(), when all possible model
1513 : changes are done. */
1514 0 : void OutlineView::EndModelChange()
1515 : {
1516 0 : UpdateDocument();
1517 :
1518 0 : ::svl::IUndoManager* pDocUndoMgr = mpDocSh->GetUndoManager();
1519 :
1520 0 : bool bHasUndoActions = pDocUndoMgr->GetUndoActionCount() != 0;
1521 :
1522 0 : EndUndo();
1523 :
1524 : DBG_ASSERT( bHasUndoActions == (mrOutliner.GetUndoManager().GetUndoActionCount() != 0), "sd::OutlineView::EndModelChange(), undo actions not in sync!" );
1525 :
1526 0 : mrOutliner.GetUndoManager().LeaveListAction();
1527 :
1528 0 : if( bHasUndoActions && mrOutliner.GetEditEngine().HasTriedMergeOnLastAddUndo() )
1529 0 : TryToMergeUndoActions();
1530 :
1531 0 : mrOutlineViewShell.Invalidate( SID_UNDO );
1532 0 : mrOutlineViewShell.Invalidate( SID_REDO );
1533 0 : }
1534 :
1535 : /** updates all changes in the outliner model to the draw model */
1536 0 : void OutlineView::UpdateDocument()
1537 : {
1538 0 : OutlineViewPageChangesGuard aGuard(this);
1539 :
1540 0 : const sal_uInt32 nPageCount = mrDoc.GetSdPageCount(PK_STANDARD);
1541 0 : Paragraph* pPara = mrOutliner.GetParagraph( 0 );
1542 : sal_uInt32 nPage;
1543 0 : for (nPage = 0; nPage < nPageCount; nPage++)
1544 : {
1545 0 : SdPage* pPage = mrDoc.GetSdPage( (sal_uInt16)nPage, PK_STANDARD);
1546 0 : mrDoc.SetSelected(pPage, false);
1547 :
1548 0 : mrOutlineViewShell.UpdateTitleObject( pPage, pPara );
1549 0 : mrOutlineViewShell.UpdateOutlineObject( pPage, pPara );
1550 :
1551 0 : if( pPara )
1552 0 : pPara = GetNextTitle(pPara);
1553 : }
1554 :
1555 : DBG_ASSERT( pPara == 0, "sd::OutlineView::UpdateDocument(), slides are out of sync, creating missing ones" );
1556 0 : while( pPara )
1557 : {
1558 0 : SdPage* pPage = InsertSlideForParagraph( pPara );
1559 0 : mrDoc.SetSelected(pPage, false);
1560 :
1561 0 : mrOutlineViewShell.UpdateTitleObject( pPage, pPara );
1562 0 : mrOutlineViewShell.UpdateOutlineObject( pPage, pPara );
1563 :
1564 0 : if( pPara )
1565 0 : pPara = GetNextTitle(pPara);
1566 0 : }
1567 0 : }
1568 :
1569 : /** merge edit engine undo actions if possible */
1570 0 : void OutlineView::TryToMergeUndoActions()
1571 : {
1572 0 : ::svl::IUndoManager& rOutlineUndo = mrOutliner.GetUndoManager();
1573 0 : if( rOutlineUndo.GetUndoActionCount() > 1 )
1574 : {
1575 0 : SfxListUndoAction* pListAction = dynamic_cast< SfxListUndoAction* >( rOutlineUndo.GetUndoAction(0) );
1576 0 : SfxListUndoAction* pPrevListAction = dynamic_cast< SfxListUndoAction* >( rOutlineUndo.GetUndoAction(1) );
1577 0 : if( pListAction && pPrevListAction )
1578 : {
1579 : // find the top EditUndo action in the top undo action list
1580 0 : size_t nAction = pListAction->aUndoActions.size();
1581 0 : EditUndo* pEditUndo = 0;
1582 0 : while( !pEditUndo && nAction )
1583 : {
1584 0 : pEditUndo = dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction].pAction);
1585 : }
1586 :
1587 0 : sal_uInt16 nEditPos = nAction; // we need this later to remove the merged undo actions
1588 :
1589 : // make sure it is the only EditUndo action in the top undo list
1590 0 : while( pEditUndo && nAction )
1591 : {
1592 0 : if( dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction].pAction) )
1593 0 : pEditUndo = 0;
1594 : }
1595 :
1596 : // do we have one and only one EditUndo action in the top undo list?
1597 0 : if( pEditUndo )
1598 : {
1599 : // yes, see if we can merge it with the prev undo list
1600 :
1601 0 : nAction = pPrevListAction->aUndoActions.size();
1602 0 : EditUndo* pPrevEditUndo = 0;
1603 0 : while( !pPrevEditUndo && nAction )
1604 0 : pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->aUndoActions[--nAction].pAction);
1605 :
1606 0 : if( pPrevEditUndo && pPrevEditUndo->Merge( pEditUndo ) )
1607 : {
1608 : // ok we merged the only EditUndo of the top undo list with
1609 : // the top EditUndo of the previous undo list
1610 :
1611 : // first remove the merged undo action
1612 : DBG_ASSERT( pListAction->aUndoActions[nEditPos].pAction == pEditUndo,
1613 : "sd::OutlineView::TryToMergeUndoActions(), wrong edit pos!" );
1614 0 : pListAction->aUndoActions.Remove(nEditPos);
1615 0 : delete pEditUndo;
1616 :
1617 : // now check if we also can merge the draw undo actions
1618 0 : ::svl::IUndoManager* pDocUndoManager = mpDocSh->GetUndoManager();
1619 0 : if( pDocUndoManager && ( pListAction->aUndoActions.size() == 1 ))
1620 : {
1621 0 : SfxLinkUndoAction* pLinkAction = dynamic_cast< SfxLinkUndoAction* >( pListAction->aUndoActions[0].pAction );
1622 0 : SfxLinkUndoAction* pPrevLinkAction = 0;
1623 :
1624 0 : if( pLinkAction )
1625 : {
1626 0 : nAction = pPrevListAction->aUndoActions.size();
1627 0 : while( !pPrevLinkAction && nAction )
1628 0 : pPrevLinkAction = dynamic_cast< SfxLinkUndoAction* >(pPrevListAction->aUndoActions[--nAction].pAction);
1629 : }
1630 :
1631 0 : if( pLinkAction && pPrevLinkAction &&
1632 0 : ( pLinkAction->GetAction() == pDocUndoManager->GetUndoAction(0) ) &&
1633 0 : ( pPrevLinkAction->GetAction() == pDocUndoManager->GetUndoAction(1) ) )
1634 : {
1635 0 : SfxListUndoAction* pSourceList = dynamic_cast< SfxListUndoAction* >(pLinkAction->GetAction());
1636 0 : SfxListUndoAction* pDestinationList = dynamic_cast< SfxListUndoAction* >(pPrevLinkAction->GetAction());
1637 :
1638 0 : if( pSourceList && pDestinationList )
1639 : {
1640 0 : sal_uInt16 nCount = pSourceList->aUndoActions.size();
1641 0 : sal_uInt16 nDestAction = pDestinationList->aUndoActions.size();
1642 0 : while( nCount-- )
1643 : {
1644 0 : SfxUndoAction* pTemp = pSourceList->aUndoActions[0].pAction;
1645 0 : pSourceList->aUndoActions.Remove(0);
1646 0 : pDestinationList->aUndoActions.Insert( pTemp, nDestAction++ );
1647 : }
1648 0 : pDestinationList->nCurUndoAction = pDestinationList->aUndoActions.size();
1649 :
1650 0 : pListAction->aUndoActions.Remove(0);
1651 0 : delete pLinkAction;
1652 :
1653 0 : pDocUndoManager->RemoveLastUndoAction();
1654 : }
1655 : }
1656 : }
1657 :
1658 0 : if ( !pListAction->aUndoActions.empty() )
1659 : {
1660 : // now we have to move all remaining doc undo actions from the top undo
1661 : // list to the previous undo list and remove the top undo list
1662 :
1663 0 : size_t nCount = pListAction->aUndoActions.size();
1664 0 : size_t nDestAction = pPrevListAction->aUndoActions.size();
1665 0 : while( nCount-- )
1666 : {
1667 0 : SfxUndoAction* pTemp = pListAction->aUndoActions[0].pAction;
1668 0 : pListAction->aUndoActions.Remove(0);
1669 0 : if( pTemp )
1670 0 : pPrevListAction->aUndoActions.Insert( pTemp, nDestAction++ );
1671 : }
1672 0 : pPrevListAction->nCurUndoAction = pPrevListAction->aUndoActions.size();
1673 : }
1674 :
1675 0 : rOutlineUndo.RemoveLastUndoAction();
1676 : }
1677 : }
1678 : }
1679 : }
1680 0 : }
1681 :
1682 0 : IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
1683 : {
1684 0 : if( pInfo )
1685 : {
1686 0 : Paragraph* pPara = mrOutliner.GetParagraph( pInfo->mnPara );
1687 0 : EditEngine& rEditEngine = const_cast< EditEngine& >( mrOutliner.GetEditEngine() );
1688 :
1689 0 : Size aImageSize( pInfo->mpOutDev->PixelToLogic( maSlideImage.GetSizePixel() ) );
1690 0 : Size aOffset( 100, 100 );
1691 :
1692 : // paint slide number
1693 0 : if( pPara && mrOutliner.HasParaFlag(pPara,PARAFLAG_ISPAGE) )
1694 : {
1695 0 : long nPage = 0; // todo, printing??
1696 0 : for ( sal_Int32 n = 0; n <= pInfo->mnPara; n++ )
1697 : {
1698 0 : Paragraph* p = mrOutliner.GetParagraph( n );
1699 0 : if ( mrOutliner.HasParaFlag(p,PARAFLAG_ISPAGE) )
1700 0 : nPage++;
1701 : }
1702 :
1703 0 : long nBulletHeight = (long)mrOutliner.GetLineHeight( pInfo->mnPara );
1704 0 : long nFontHeight = 0;
1705 0 : if ( !rEditEngine.IsFlatMode() )
1706 : {
1707 0 : nFontHeight = nBulletHeight / 5;
1708 : }
1709 : else
1710 : {
1711 0 : nFontHeight = (nBulletHeight * 10) / 25;
1712 : }
1713 :
1714 0 : Size aFontSz( 0, nFontHeight );
1715 :
1716 0 : Size aOutSize( 2000, nBulletHeight );
1717 :
1718 0 : const float fImageHeight = ((float)aOutSize.Height() * (float)4) / (float)7;
1719 0 : const float fImageRatio = (float)aImageSize.Height() / (float)aImageSize.Width();
1720 0 : aImageSize.Width() = (long)( fImageRatio * fImageHeight );
1721 0 : aImageSize.Height() = (long)( fImageHeight );
1722 :
1723 0 : Point aImagePos( pInfo->mrStartPos );
1724 0 : aImagePos.X() += aOutSize.Width() - aImageSize.Width() - aOffset.Width() ;
1725 0 : aImagePos.Y() += (aOutSize.Height() - aImageSize.Height()) / 2;
1726 :
1727 0 : pInfo->mpOutDev->DrawImage( aImagePos, aImageSize, maSlideImage );
1728 :
1729 0 : const bool bVertical = mrOutliner.IsVertical();
1730 0 : const bool bRightToLeftPara = rEditEngine.IsRightToLeft( pInfo->mnPara );
1731 :
1732 0 : LanguageType eLang = rEditEngine.GetDefaultLanguage();
1733 :
1734 0 : Point aTextPos( aImagePos.X() - aOffset.Width(), pInfo->mrStartPos.Y() );
1735 0 : vcl::Font aNewFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE, eLang, 0 ) );
1736 0 : aNewFont.SetSize( aFontSz );
1737 0 : aNewFont.SetVertical( bVertical );
1738 0 : aNewFont.SetOrientation( bVertical ? 2700 : 0 );
1739 0 : aNewFont.SetColor( COL_AUTO );
1740 0 : pInfo->mpOutDev->SetFont( aNewFont );
1741 0 : OUString aPageText = OUString::number( nPage );
1742 0 : Size aTextSz;
1743 0 : aTextSz.Width() = pInfo->mpOutDev->GetTextWidth( aPageText );
1744 0 : aTextSz.Height() = pInfo->mpOutDev->GetTextHeight();
1745 0 : if ( !bVertical )
1746 : {
1747 0 : aTextPos.Y() += (aOutSize.Height() - aTextSz.Height()) / 2;
1748 0 : if ( !bRightToLeftPara )
1749 : {
1750 0 : aTextPos.X() -= aTextSz.Width();
1751 : }
1752 : else
1753 : {
1754 0 : aTextPos.X() += aTextSz.Width();
1755 : }
1756 : }
1757 : else
1758 : {
1759 0 : aTextPos.Y() -= aTextSz.Width();
1760 0 : aTextPos.X() += nBulletHeight / 2;
1761 : }
1762 0 : pInfo->mpOutDev->DrawText( aTextPos, aPageText );
1763 : }
1764 : }
1765 :
1766 0 : return 0;
1767 : }
1768 :
1769 0 : void OutlineView::UpdateParagraph( sal_Int32 nPara )
1770 : {
1771 0 : SfxItemSet aNewAttrs2( mrOutliner.GetParaAttribs( nPara ) );
1772 0 : aNewAttrs2.Put( maLRSpaceItem );
1773 0 : mrOutliner.SetParaAttribs( nPara, aNewAttrs2 );
1774 0 : }
1775 :
1776 0 : void OutlineView::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
1777 : {
1778 0 : }
1779 :
1780 : /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
1781 : get the correct style sheet and new slides are inserted. */
1782 0 : void OutlineView::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
1783 : {
1784 0 : SdPage* pPage = 0;
1785 0 : SfxStyleSheetBasePool* pStylePool = GetDoc().GetStyleSheetPool();
1786 :
1787 0 : for( sal_Int32 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1788 : {
1789 0 : Paragraph* pPara = mrOutliner.GetParagraph( nPara );
1790 :
1791 0 : bool bPage = mrOutliner.HasParaFlag( pPara, PARAFLAG_ISPAGE );
1792 :
1793 0 : if( !bPage )
1794 : {
1795 0 : SdStyleSheet* pStyleSheet = dynamic_cast< SdStyleSheet* >( mrOutliner.GetStyleSheet( nPara ) );
1796 0 : if( pStyleSheet )
1797 : {
1798 0 : const OUString aName( pStyleSheet->GetApiName() );
1799 0 : if ( aName == "title" )
1800 0 : bPage = true;
1801 : }
1802 : }
1803 :
1804 0 : if( !pPara )
1805 0 : continue; // fatality!?
1806 :
1807 0 : if( bPage && (nPara != pInfos->nStartPara) )
1808 : {
1809 : // insert new slide for this paragraph
1810 0 : pPage = InsertSlideForParagraph( pPara );
1811 : }
1812 : else
1813 : {
1814 : // newly inserted non page paragraphs get the outline style
1815 0 : if( !pPage )
1816 0 : pPage = GetPageForParagraph( pPara );
1817 :
1818 0 : if( pPage )
1819 : {
1820 0 : SfxStyleSheet* pStyle = pPage->GetStyleSheetForPresObj( bPage ? PRESOBJ_TITLE : PRESOBJ_OUTLINE );
1821 :
1822 0 : if( !bPage )
1823 : {
1824 0 : const sal_Int16 nDepth = mrOutliner.GetDepth( nPara );
1825 0 : if( nDepth > 0 )
1826 : {
1827 0 : OUString aStyleSheetName = pStyle->GetName();
1828 0 : if (!aStyleSheetName.isEmpty())
1829 0 : aStyleSheetName = aStyleSheetName.copy(0, aStyleSheetName.getLength() - 1);
1830 0 : aStyleSheetName += OUString::number( nDepth );
1831 0 : pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyle->GetFamily() ) );
1832 0 : DBG_ASSERT( pStyle, "sd::OutlineView::OnEndPasteOrDrop(), Style not found!" );
1833 : }
1834 : }
1835 :
1836 0 : mrOutliner.SetStyleSheet( nPara, pStyle );
1837 : }
1838 :
1839 0 : UpdateParagraph( nPara );
1840 : }
1841 : }
1842 0 : }
1843 :
1844 : // - OutlineViewModelChangeGuard -
1845 :
1846 0 : OutlineViewModelChangeGuard::OutlineViewModelChangeGuard( OutlineView& rView )
1847 0 : : mrView( rView )
1848 : {
1849 0 : mrView.BeginModelChange();
1850 0 : }
1851 :
1852 0 : OutlineViewModelChangeGuard::~OutlineViewModelChangeGuard()
1853 : {
1854 0 : mrView.EndModelChange();
1855 0 : }
1856 :
1857 : // - OutlineViewPageChangesGuard -
1858 :
1859 0 : OutlineViewPageChangesGuard::OutlineViewPageChangesGuard( OutlineView* pView )
1860 0 : : mpView( pView )
1861 : {
1862 0 : if( mpView )
1863 0 : mpView->IgnoreCurrentPageChanges( true );
1864 0 : }
1865 :
1866 0 : OutlineViewPageChangesGuard::~OutlineViewPageChangesGuard()
1867 : {
1868 0 : if( mpView )
1869 0 : mpView->IgnoreCurrentPageChanges( false );
1870 0 : }
1871 :
1872 114 : } // end of namespace sd
1873 :
1874 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|