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

Generated by: LCOV version 1.11