LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - outlview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 892 0.1 %
Date: 2013-07-09 Functions: 2 79 2.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10