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

Generated by: LCOV version 1.10