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