1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "fusumry.hxx" 33*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 34*cdf0e10cSrcweir #include <svx/svdotext.hxx> 35*cdf0e10cSrcweir #include <svx/svdundo.hxx> 36*cdf0e10cSrcweir #include <sfx2/printer.hxx> 37*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "strings.hrc" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include "pres.hxx" 42*cdf0e10cSrcweir #include "View.hxx" 43*cdf0e10cSrcweir #include "sdpage.hxx" 44*cdf0e10cSrcweir #include "Outliner.hxx" 45*cdf0e10cSrcweir #include "drawview.hxx" 46*cdf0e10cSrcweir #include "drawdoc.hxx" 47*cdf0e10cSrcweir #include "ViewShell.hxx" 48*cdf0e10cSrcweir #include "DrawDocShell.hxx" 49*cdf0e10cSrcweir #include "sdresid.hxx" 50*cdf0e10cSrcweir #include "optsitem.hxx" 51*cdf0e10cSrcweir #include "DrawViewShell.hxx" 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir namespace sd { 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir TYPEINIT1( FuSummaryPage, FuPoor ); 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir /************************************************************************* 58*cdf0e10cSrcweir |* 59*cdf0e10cSrcweir |* Konstruktor 60*cdf0e10cSrcweir |* 61*cdf0e10cSrcweir \************************************************************************/ 62*cdf0e10cSrcweir FuSummaryPage::FuSummaryPage ( 63*cdf0e10cSrcweir ViewShell* pViewSh, 64*cdf0e10cSrcweir ::sd::Window* pWin, 65*cdf0e10cSrcweir ::sd::View* pView, 66*cdf0e10cSrcweir SdDrawDocument* pDoc, 67*cdf0e10cSrcweir SfxRequest& rReq) 68*cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir FunctionReference FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir FunctionReference xFunc( new FuSummaryPage( pViewSh, pWin, pView, pDoc, rReq ) ); 75*cdf0e10cSrcweir xFunc->DoExecute(rReq); 76*cdf0e10cSrcweir return xFunc; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir void FuSummaryPage::DoExecute( SfxRequest& ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir ::sd::Outliner* pOutl = NULL; 82*cdf0e10cSrcweir SdPage* pSummaryPage = NULL; 83*cdf0e10cSrcweir sal_uInt16 i = 0; 84*cdf0e10cSrcweir sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND; 85*cdf0e10cSrcweir sal_uInt16 nSelectedPages = 0; 86*cdf0e10cSrcweir sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir while (i < nCount && nSelectedPages <= 1) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir /********************************************************************** 91*cdf0e10cSrcweir * Wieviele Seiten sind selektiert? 92*cdf0e10cSrcweir * Genau eine Seite selektiert: Ab dieser Seite alles zusammenfassen 93*cdf0e10cSrcweir * sonst: Nur die selektierten Seiten zusammenfassen 94*cdf0e10cSrcweir **********************************************************************/ 95*cdf0e10cSrcweir SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir if (pActualPage->IsSelected()) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir if (nFirstPage == SDRPAGE_NOTFOUND) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir nFirstPage = i; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir nSelectedPages++; 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir i++; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir bool bBegUndo = false; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir SfxStyleSheet* pStyle = NULL; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir for (i = nFirstPage; i < nCount; i++) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir if (nSelectedPages <= 1 || pActualPage->IsSelected()) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir SdPage* pActualNotesPage = mpDoc->GetSdPage(i, PK_NOTES); 121*cdf0e10cSrcweir SdrTextObj* pTextObj = (SdrTextObj*) pActualPage->GetPresObj(PRESOBJ_TITLE); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir if (pTextObj && !pTextObj->IsEmptyPresObj()) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir if (!pSummaryPage) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir /********************************************************** 128*cdf0e10cSrcweir * Inhaltsverzeichnis-Seite einfuegen und Outliner anlegen 129*cdf0e10cSrcweir **********************************************************/ 130*cdf0e10cSrcweir const bool bUndo = mpView->IsUndoEnabled(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir if( bUndo ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir mpView->BegUndo(String(SdResId(STR_UNDO_SUMMARY_PAGE))); 135*cdf0e10cSrcweir bBegUndo = true; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // Seite mit Titel & Gliederung! 141*cdf0e10cSrcweir pSummaryPage = (SdPage*) mpDoc->AllocPage(sal_False); 142*cdf0e10cSrcweir pSummaryPage->SetSize(pActualPage->GetSize() ); 143*cdf0e10cSrcweir pSummaryPage->SetBorder(pActualPage->GetLftBorder(), 144*cdf0e10cSrcweir pActualPage->GetUppBorder(), 145*cdf0e10cSrcweir pActualPage->GetRgtBorder(), 146*cdf0e10cSrcweir pActualPage->GetLwrBorder() ); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // Seite hinten einfuegen 149*cdf0e10cSrcweir mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1); 150*cdf0e10cSrcweir if( bUndo ) 151*cdf0e10cSrcweir mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage)); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // MasterPage der aktuellen Seite verwenden 154*cdf0e10cSrcweir pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage()); 155*cdf0e10cSrcweir pSummaryPage->SetLayoutName(pActualPage->GetLayoutName()); 156*cdf0e10cSrcweir pSummaryPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True); 157*cdf0e10cSrcweir pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 158*cdf0e10cSrcweir pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings()); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir // Notiz-Seite 161*cdf0e10cSrcweir SdPage* pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False); 162*cdf0e10cSrcweir pNotesPage->SetSize(pActualNotesPage->GetSize()); 163*cdf0e10cSrcweir pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(), 164*cdf0e10cSrcweir pActualNotesPage->GetUppBorder(), 165*cdf0e10cSrcweir pActualNotesPage->GetRgtBorder(), 166*cdf0e10cSrcweir pActualNotesPage->GetLwrBorder() ); 167*cdf0e10cSrcweir pNotesPage->SetPageKind(PK_NOTES); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir // Seite hinten einfuegen 170*cdf0e10cSrcweir mpDoc->InsertPage(pNotesPage, nCount * 2 + 2); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if( bUndo ) 173*cdf0e10cSrcweir mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage)); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir // MasterPage der aktuellen Seite verwenden 176*cdf0e10cSrcweir pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage()); 177*cdf0e10cSrcweir pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName()); 178*cdf0e10cSrcweir pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True); 179*cdf0e10cSrcweir pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 180*cdf0e10cSrcweir pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings()); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir pOutl = new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT ); 183*cdf0e10cSrcweir pOutl->SetUpdateMode(sal_False); 184*cdf0e10cSrcweir pOutl->EnableUndo(sal_False); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir if (mpDocSh) 187*cdf0e10cSrcweir pOutl->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh )); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir pOutl->SetDefTab( mpDoc->GetDefaultTabulator() ); 190*cdf0e10cSrcweir pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool()); 191*cdf0e10cSrcweir pStyle = pSummaryPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ); 192*cdf0e10cSrcweir pOutl->SetStyleSheet( 0, pStyle ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir /************************************************************** 196*cdf0e10cSrcweir * Text hinzufuegen 197*cdf0e10cSrcweir **************************************************************/ 198*cdf0e10cSrcweir OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject(); 199*cdf0e10cSrcweir pParaObj->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT ); 200*cdf0e10cSrcweir pOutl->AddText(*pParaObj); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir if (pSummaryPage) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir SdrTextObj* pTextObj = (SdrTextObj*) pSummaryPage->GetPresObj(PRESOBJ_OUTLINE); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir // Harte Absatz- und Zeichenattribute entfernen 210*cdf0e10cSrcweir SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END); 211*cdf0e10cSrcweir sal_uLong nParaCount = pOutl->GetParagraphCount(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir for (sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir pOutl->SetStyleSheet( nPara, pStyle ); 216*cdf0e10cSrcweir pOutl->QuickRemoveCharAttribs(nPara); 217*cdf0e10cSrcweir pOutl->SetParaAttribs(nPara, aEmptyEEAttr); 218*cdf0e10cSrcweir pOutl->SetDepth(pOutl->GetParagraph(nPara), 0); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); 222*cdf0e10cSrcweir pTextObj->SetEmptyPresObj(sal_False); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // Harte Attribute entfernen (Flag auf sal_True) 225*cdf0e10cSrcweir SfxItemSet aAttr(mpDoc->GetPool()); 226*cdf0e10cSrcweir aAttr.Put(XLineStyleItem(XLINE_NONE)); 227*cdf0e10cSrcweir aAttr.Put(XFillStyleItem(XFILL_NONE)); 228*cdf0e10cSrcweir pTextObj->SetMergedItemSet(aAttr); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir if( bBegUndo ) 231*cdf0e10cSrcweir mpView->EndUndo(); 232*cdf0e10cSrcweir delete pOutl; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell ); 235*cdf0e10cSrcweir if(pDrawViewShell) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir } // end of namespace sd 244