LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fuexpand.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 118 0.8 %
Date: 2013-07-09 Functions: 2 10 20.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             : #include "fuexpand.hxx"
      21             : 
      22             : #include <sfx2/viewfrm.hxx>
      23             : #include <svx/svdotext.hxx>
      24             : #include <svx/xlineit0.hxx>
      25             : #include <svx/svdundo.hxx>
      26             : #include <sfx2/printer.hxx>
      27             : #include <editeng/outlobj.hxx>
      28             : #include <svx/svdetc.hxx>
      29             : 
      30             : #include "app.hrc"
      31             : #include "strings.hrc"
      32             : #include "pres.hxx"
      33             : #include "View.hxx"
      34             : #include "sdpage.hxx"
      35             : #include "Outliner.hxx"
      36             : #include "drawview.hxx"
      37             : #include "drawdoc.hxx"
      38             : #include "ViewShell.hxx"
      39             : #include "DrawDocShell.hxx"
      40             : #include "sdresid.hxx"
      41             : #include "optsitem.hxx"
      42             : #include "sdmod.hxx"
      43             : #include <sfx2/dispatch.hxx>
      44             : #include <editeng/eeitem.hxx>
      45             : 
      46             : namespace sd {
      47             : 
      48           0 : TYPEINIT1( FuExpandPage, FuPoor );
      49             : 
      50             : 
      51           0 : FuExpandPage::FuExpandPage (
      52             :     ViewShell* pViewSh,
      53             :     ::sd::Window* pWin,
      54             :     ::sd::View* pView,
      55             :     SdDrawDocument* pDoc,
      56             :     SfxRequest& rReq)
      57           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      58             : {
      59           0 : }
      60             : 
      61           0 : FunctionReference FuExpandPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      62             : {
      63           0 :     FunctionReference xFunc( new FuExpandPage( pViewSh, pWin, pView, pDoc, rReq ) );
      64           0 :     xFunc->DoExecute(rReq);
      65           0 :     return xFunc;
      66             : }
      67             : 
      68           0 : void FuExpandPage::DoExecute( SfxRequest& )
      69             : {
      70           0 :     if ( mpView && mpView->IsTextEdit() )
      71           0 :         mpView->SdrEndTextEdit();
      72             : 
      73             :     // find selected page (only standard pages)
      74           0 :     SdPage* pActualPage = NULL;
      75           0 :     sal_uInt16 i = 0;
      76           0 :     sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD);
      77             : 
      78           0 :     while (!pActualPage && i < nCount)
      79             :     {
      80           0 :         if (mpDoc->GetSdPage(i, PK_STANDARD)->IsSelected())
      81             :         {
      82           0 :             pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
      83             :         }
      84             : 
      85           0 :         i++;
      86             :     }
      87             : 
      88           0 :     if (pActualPage)
      89             :     {
      90             :         ::sd::Outliner* pOutl =
      91           0 :               new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
      92           0 :         pOutl->SetUpdateMode(sal_False);
      93           0 :         pOutl->EnableUndo(sal_False);
      94             : 
      95           0 :         if (mpDocSh)
      96           0 :             pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
      97             : 
      98           0 :         pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
      99           0 :         pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
     100             : 
     101           0 :         SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
     102           0 :         sal_uInt16 nActualPageNum = pActualPage->GetPageNum();
     103           0 :         SdPage* pActualNotesPage = (SdPage*) mpDoc->GetPage(nActualPageNum + 1);
     104           0 :         SdrTextObj* pActualOutline = (SdrTextObj*) pActualPage->GetPresObj(PRESOBJ_OUTLINE);
     105             : 
     106           0 :         if (pActualOutline)
     107             :         {
     108           0 :             const bool bUndo = mpView->IsUndoEnabled();
     109             : 
     110           0 :             if( bUndo )
     111           0 :                 mpView->BegUndo(String(SdResId(STR_UNDO_EXPAND_PAGE)));
     112             : 
     113             :             // set current structuring-object into outliner
     114           0 :             OutlinerParaObject* pParaObj = pActualOutline->GetOutlinerParaObject();
     115           0 :             pOutl->SetText(*pParaObj);
     116             : 
     117             :             // remove hard paragraph- and character attributes
     118           0 :             SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END);
     119           0 :             sal_Int32 nParaCount1 = pOutl->GetParagraphCount();
     120             : 
     121           0 :             for (sal_Int32 nPara = 0; nPara < nParaCount1; nPara++)
     122             :             {
     123           0 :                 pOutl->QuickRemoveCharAttribs(nPara);
     124           0 :                 pOutl->SetParaAttribs(nPara, aEmptyEEAttr);
     125             :             }
     126             : 
     127           0 :             sal_uInt16 nPos = 2;
     128           0 :             Paragraph* pPara = pOutl->GetParagraph( 0 );
     129             : 
     130           0 :             while (pPara)
     131             :             {
     132           0 :                 sal_Int32 nParaPos = pOutl->GetAbsPos( pPara );
     133           0 :                 sal_Int16 nDepth = pOutl->GetDepth( nParaPos );
     134           0 :                 if ( nDepth == 0 )
     135             :                 {
     136             :                     // page with title & structuring!
     137           0 :                     SdPage* pPage = (SdPage*) mpDoc->AllocPage(sal_False);
     138           0 :                     pPage->SetSize(pActualPage->GetSize() );
     139           0 :                     pPage->SetBorder(pActualPage->GetLftBorder(),
     140           0 :                                      pActualPage->GetUppBorder(),
     141           0 :                                      pActualPage->GetRgtBorder(),
     142           0 :                                      pActualPage->GetLwrBorder() );
     143           0 :                     pPage->SetName(String());
     144             : 
     145             :                     // insert page after current page
     146           0 :                     mpDoc->InsertPage(pPage, nActualPageNum + nPos);
     147           0 :                     nPos++;
     148             : 
     149           0 :                     if( bUndo )
     150           0 :                         mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
     151             : 
     152             :                     // use MasterPage of the current page
     153           0 :                     pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
     154           0 :                     pPage->SetLayoutName(pActualPage->GetLayoutName());
     155           0 :                     pPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
     156           0 :                     pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     157             : 
     158             :                     // notes-page
     159           0 :                     SdPage* pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False);
     160           0 :                     pNotesPage->SetSize(pActualNotesPage->GetSize());
     161           0 :                     pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(),
     162           0 :                                           pActualNotesPage->GetUppBorder(),
     163           0 :                                           pActualNotesPage->GetRgtBorder(),
     164           0 :                                           pActualNotesPage->GetLwrBorder() );
     165           0 :                     pNotesPage->SetPageKind(PK_NOTES);
     166           0 :                     pNotesPage->SetName(String());
     167             : 
     168             :                     // insert page after current page
     169           0 :                     mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos);
     170           0 :                     nPos++;
     171             : 
     172           0 :                     if( bUndo )
     173           0 :                         mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
     174             : 
     175             :                     // use MasterPage of the current page
     176           0 :                     pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
     177           0 :                     pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
     178           0 :                     pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True);
     179           0 :                     pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     180             : 
     181             :                     // create title text objects
     182           0 :                     SdrTextObj* pTextObj = (SdrTextObj*) pPage->GetPresObj(PRESOBJ_TITLE);
     183             : 
     184           0 :                     OutlinerParaObject* pOutlinerParaObject = pOutl->CreateParaObject( nParaPos, 1);
     185           0 :                     pOutlinerParaObject->SetOutlinerMode(OUTLINERMODE_TITLEOBJECT);
     186             : 
     187           0 :                     if( pOutlinerParaObject->GetDepth(0) != -1 )
     188             :                     {
     189           0 :                         SdrOutliner* pTempOutl = SdrMakeOutliner( OUTLINERMODE_TITLEOBJECT, mpDoc );
     190             : 
     191           0 :                         pTempOutl->SetText( *pOutlinerParaObject );
     192             : 
     193           0 :                         delete pOutlinerParaObject;
     194             : 
     195           0 :                         pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 );
     196             : 
     197           0 :                         pOutlinerParaObject = pTempOutl->CreateParaObject();
     198           0 :                         delete pTempOutl;
     199             :                     }
     200             : 
     201           0 :                     pTextObj->SetOutlinerParaObject(pOutlinerParaObject);
     202             : 
     203           0 :                     pTextObj->SetEmptyPresObj(sal_False);
     204             : 
     205           0 :                     SfxStyleSheet* pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
     206           0 :                     pTextObj->NbcSetStyleSheet(pSheet, sal_False);
     207             : 
     208           0 :                     sal_Int32 nChildCount = pOutl->GetChildCount(pPara);
     209             : 
     210           0 :                     if (nChildCount > 0)
     211             :                     {
     212             :                         // create structuring text objects
     213           0 :                         SdrTextObj* pOutlineObj = (SdrTextObj*) pPage->GetPresObj(PRESOBJ_OUTLINE);
     214           0 :                         pPara = pOutl->GetParagraph( ++nParaPos );
     215             : 
     216           0 :                         OutlinerParaObject* pOPO = pOutl->CreateParaObject( nParaPos, nChildCount);
     217             : 
     218           0 :                         SdrOutliner* pTempOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
     219           0 :                         pTempOutl->SetText( *pOPO );
     220             : 
     221           0 :                         sal_Int32 nParaCount2 = pTempOutl->GetParagraphCount();
     222             :                         sal_Int32 nPara;
     223           0 :                         for( nPara = 0; nPara < nParaCount2; nPara++ )
     224             :                         {
     225             :                             pTempOutl->SetDepth (
     226             :                                 pTempOutl->GetParagraph( nPara ),
     227           0 :                                 pTempOutl->GetDepth( nPara ) - 1);
     228             :                         }
     229             : 
     230           0 :                         delete pOPO;
     231           0 :                         pOPO = pTempOutl->CreateParaObject();
     232           0 :                         delete pTempOutl;
     233             : 
     234           0 :                         pOutlineObj->SetOutlinerParaObject( pOPO );
     235           0 :                         pOutlineObj->SetEmptyPresObj(sal_False);
     236             : 
     237             :                         // remove hard attributes (Flag to sal_True)
     238           0 :                         SfxItemSet aAttr(mpDoc->GetPool());
     239           0 :                         aAttr.Put(XLineStyleItem(XLINE_NONE));
     240           0 :                         aAttr.Put(XFillStyleItem(XFILL_NONE));
     241           0 :                         pOutlineObj->SetMergedItemSet(aAttr);
     242             :                     }
     243             :                 }
     244             : 
     245           0 :                 pPara = pOutl->GetParagraph( ++nParaPos );
     246             :             }
     247             : 
     248           0 :             if( bUndo )
     249           0 :                 mpView->EndUndo();
     250             :         }
     251             : 
     252           0 :         delete pOutl;
     253             : 
     254           0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
     255             :     }
     256           0 : }
     257             : 
     258          33 : } // end of namespace sd
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10