LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fusumry.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 102 1.0 %
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 "fusumry.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : #include <svx/svdotext.hxx>
      23             : #include <svx/svdundo.hxx>
      24             : #include <sfx2/printer.hxx>
      25             : #include <editeng/outlobj.hxx>
      26             : 
      27             : #include "strings.hrc"
      28             : 
      29             : #include "pres.hxx"
      30             : #include "View.hxx"
      31             : #include "sdpage.hxx"
      32             : #include "Outliner.hxx"
      33             : #include "drawview.hxx"
      34             : #include "drawdoc.hxx"
      35             : #include "ViewShell.hxx"
      36             : #include "DrawDocShell.hxx"
      37             : #include "sdresid.hxx"
      38             : #include "optsitem.hxx"
      39             : #include "DrawViewShell.hxx"
      40             : 
      41             : namespace sd {
      42             : 
      43           0 : TYPEINIT1( FuSummaryPage, FuPoor );
      44             : 
      45           0 : FuSummaryPage::FuSummaryPage (
      46             :     ViewShell* pViewSh,
      47             :     ::sd::Window* pWin,
      48             :     ::sd::View* pView,
      49             :     SdDrawDocument* pDoc,
      50             :     SfxRequest& rReq)
      51           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      52             : {
      53           0 : }
      54             : 
      55           0 : FunctionReference FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      56             : {
      57           0 :     FunctionReference xFunc( new FuSummaryPage( pViewSh, pWin, pView, pDoc, rReq ) );
      58           0 :     xFunc->DoExecute(rReq);
      59           0 :     return xFunc;
      60             : }
      61             : 
      62           0 : void FuSummaryPage::DoExecute( SfxRequest& )
      63             : {
      64           0 :     ::sd::Outliner* pOutl = NULL;
      65           0 :     SdPage* pSummaryPage = NULL;
      66           0 :     sal_uInt16 i = 0;
      67           0 :     sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND;
      68           0 :     sal_uInt16 nSelectedPages = 0;
      69           0 :     sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD);
      70             : 
      71           0 :     while (i < nCount && nSelectedPages <= 1)
      72             :     {
      73             :         /* How many pages are selected?
      74             :              exactly one: pool everything from this page
      75             :              otherwise:   only pool the selected pages  */
      76           0 :         SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
      77             : 
      78           0 :         if (pActualPage->IsSelected())
      79             :         {
      80           0 :             if (nFirstPage == SDRPAGE_NOTFOUND)
      81             :             {
      82           0 :                 nFirstPage = i;
      83             :             }
      84             : 
      85           0 :             nSelectedPages++;
      86             :         }
      87             : 
      88           0 :         i++;
      89             :     }
      90             : 
      91           0 :     bool bBegUndo = false;
      92             : 
      93           0 :     SfxStyleSheet* pStyle = NULL;
      94             : 
      95           0 :     for (i = nFirstPage; i < nCount; i++)
      96             :     {
      97           0 :         SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
      98             : 
      99           0 :         if (nSelectedPages <= 1 || pActualPage->IsSelected())
     100             :         {
     101           0 :             SdPage* pActualNotesPage = mpDoc->GetSdPage(i, PK_NOTES);
     102           0 :             SdrTextObj* pTextObj = (SdrTextObj*) pActualPage->GetPresObj(PRESOBJ_TITLE);
     103             : 
     104           0 :             if (pTextObj && !pTextObj->IsEmptyPresObj())
     105             :             {
     106           0 :                 if (!pSummaryPage)
     107             :                 {
     108             :                     // insert "table of content"-page and create outliner
     109           0 :                     const bool bUndo = mpView->IsUndoEnabled();
     110             : 
     111           0 :                     if( bUndo )
     112             :                     {
     113           0 :                         mpView->BegUndo(String(SdResId(STR_UNDO_SUMMARY_PAGE)));
     114           0 :                         bBegUndo = true;
     115             :                     }
     116             : 
     117           0 :                     SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
     118             : 
     119             :                     // page with title & structuring!
     120           0 :                     pSummaryPage = (SdPage*) mpDoc->AllocPage(sal_False);
     121           0 :                     pSummaryPage->SetSize(pActualPage->GetSize() );
     122           0 :                     pSummaryPage->SetBorder(pActualPage->GetLftBorder(),
     123           0 :                                      pActualPage->GetUppBorder(),
     124           0 :                                      pActualPage->GetRgtBorder(),
     125           0 :                                      pActualPage->GetLwrBorder() );
     126             : 
     127             :                     // insert page at the back
     128           0 :                     mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
     129           0 :                     if( bUndo )
     130           0 :                         mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
     131             : 
     132             :                     // use MasterPage of the current page
     133           0 :                     pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
     134           0 :                     pSummaryPage->SetLayoutName(pActualPage->GetLayoutName());
     135           0 :                     pSummaryPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
     136           0 :                     pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     137           0 :                     pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings());
     138             : 
     139             :                     // notes-page
     140           0 :                     SdPage* pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False);
     141           0 :                     pNotesPage->SetSize(pActualNotesPage->GetSize());
     142           0 :                     pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(),
     143           0 :                                           pActualNotesPage->GetUppBorder(),
     144           0 :                                           pActualNotesPage->GetRgtBorder(),
     145           0 :                                           pActualNotesPage->GetLwrBorder() );
     146           0 :                     pNotesPage->SetPageKind(PK_NOTES);
     147             : 
     148             :                     // insert page at the back
     149           0 :                     mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
     150             : 
     151           0 :                     if( bUndo )
     152           0 :                         mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
     153             : 
     154             :                     // use MasterPage of the current page
     155           0 :                     pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
     156           0 :                     pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
     157           0 :                     pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True);
     158           0 :                     pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     159           0 :                     pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings());
     160             : 
     161           0 :                     pOutl = new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
     162           0 :                     pOutl->SetUpdateMode(sal_False);
     163           0 :                     pOutl->EnableUndo(sal_False);
     164             : 
     165           0 :                     if (mpDocSh)
     166           0 :                         pOutl->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh ));
     167             : 
     168           0 :                     pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
     169           0 :                     pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
     170           0 :                     pStyle = pSummaryPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
     171           0 :                     pOutl->SetStyleSheet( 0, pStyle );
     172             :                 }
     173             : 
     174             :                 // add text
     175           0 :                 OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
     176             :                 // #118876#, check if the OutlinerParaObject is created successfully
     177           0 :                 if( pParaObj )
     178             :                 {
     179           0 :                     pParaObj->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
     180           0 :                     pOutl->AddText(*pParaObj);
     181             :                 }
     182             :             }
     183             :         }
     184             :     }
     185             : 
     186           0 :     if (pSummaryPage)
     187             :     {
     188           0 :         SdrTextObj* pTextObj = (SdrTextObj*) pSummaryPage->GetPresObj(PRESOBJ_OUTLINE);
     189             : 
     190             :         // remove hard break- and character attributes
     191           0 :         SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END);
     192           0 :         sal_Int32 nParaCount = pOutl->GetParagraphCount();
     193             : 
     194           0 :         for (sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
     195             :         {
     196           0 :             pOutl->SetStyleSheet( nPara, pStyle );
     197           0 :             pOutl->QuickRemoveCharAttribs(nPara);
     198           0 :             pOutl->SetParaAttribs(nPara, aEmptyEEAttr);
     199           0 :             pOutl->SetDepth(pOutl->GetParagraph(nPara), 0);
     200             :         }
     201             : 
     202           0 :         pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
     203           0 :         pTextObj->SetEmptyPresObj(sal_False);
     204             : 
     205             :         // remove hard attributes (Flag to sal_True)
     206           0 :         SfxItemSet aAttr(mpDoc->GetPool());
     207           0 :         aAttr.Put(XLineStyleItem(XLINE_NONE));
     208           0 :         aAttr.Put(XFillStyleItem(XFILL_NONE));
     209           0 :         pTextObj->SetMergedItemSet(aAttr);
     210             : 
     211           0 :         if( bBegUndo )
     212           0 :             mpView->EndUndo();
     213           0 :         delete pOutl;
     214             : 
     215           0 :         DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );
     216           0 :         if(pDrawViewShell)
     217             :         {
     218           0 :             pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2);
     219           0 :         }
     220             :     }
     221           0 : }
     222             : 
     223             : 
     224          33 : } // end of namespace sd
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10