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