Files
libreoffice/sd/source/ui/func/fusumry.cxx

230 lines
8.2 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
2000-09-18 16:07:07 +00:00
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2000-09-18 16:07:07 +00:00
*
* This file incorporates work covered by the following license notice:
2000-09-18 16:07:07 +00:00
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include "fusumry.hxx"
#include <editeng/eeitem.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/svdotext.hxx>
#include <svx/svdundo.hxx>
#include <sfx2/printer.hxx>
#include <editeng/outlobj.hxx>
2000-09-18 16:07:07 +00:00
#include "strings.hrc"
#include "pres.hxx"
#include "View.hxx"
2000-09-18 16:07:07 +00:00
#include "sdpage.hxx"
#include "Outliner.hxx"
2000-09-18 16:07:07 +00:00
#include "drawview.hxx"
#include "drawdoc.hxx"
#include "ViewShell.hxx"
#include "DrawDocShell.hxx"
2000-09-18 16:07:07 +00:00
#include "sdresid.hxx"
#include "optsitem.hxx"
#include "DrawViewShell.hxx"
namespace sd {
2000-09-18 16:07:07 +00:00
TYPEINIT1( FuSummaryPage, FuPoor );
FuSummaryPage::FuSummaryPage (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}
rtl::Reference<FuPoor> FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
rtl::Reference<FuPoor> xFunc( new FuSummaryPage( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
return xFunc;
}
void FuSummaryPage::DoExecute( SfxRequest& )
2000-09-18 16:07:07 +00:00
{
::sd::Outliner* pOutl = NULL;
2000-09-18 16:07:07 +00:00
SdPage* pSummaryPage = NULL;
sal_uInt16 i = 0;
sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND;
sal_uInt16 nSelectedPages = 0;
sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD);
2000-09-18 16:07:07 +00:00
while (i < nCount && nSelectedPages <= 1)
{
/* How many pages are selected?
exactly one: pool everything from this page
otherwise: only pool the selected pages */
SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
2000-09-18 16:07:07 +00:00
if (pActualPage->IsSelected())
{
if (nFirstPage == SDRPAGE_NOTFOUND)
{
nFirstPage = i;
}
nSelectedPages++;
}
i++;
}
bool bBegUndo = false;
2000-09-18 16:07:07 +00:00
SfxStyleSheet* pStyle = NULL;
for (i = nFirstPage; i < nCount; i++)
{
SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
2000-09-18 16:07:07 +00:00
if (nSelectedPages <= 1 || pActualPage->IsSelected())
{
SdPage* pActualNotesPage = mpDoc->GetSdPage(i, PK_NOTES);
2000-09-18 16:07:07 +00:00
SdrTextObj* pTextObj = (SdrTextObj*) pActualPage->GetPresObj(PRESOBJ_TITLE);
if (pTextObj && !pTextObj->IsEmptyPresObj())
{
if (!pSummaryPage)
{
// insert "table of content"-page and create outliner
const bool bUndo = mpView->IsUndoEnabled();
if( bUndo )
{
mpView->BegUndo(SD_RESSTR(STR_UNDO_SUMMARY_PAGE));
bBegUndo = true;
}
SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
2000-09-18 16:07:07 +00:00
// page with title & structuring!
pSummaryPage = (SdPage*) mpDoc->AllocPage(false);
2000-09-18 16:07:07 +00:00
pSummaryPage->SetSize(pActualPage->GetSize() );
pSummaryPage->SetBorder(pActualPage->GetLftBorder(),
pActualPage->GetUppBorder(),
pActualPage->GetRgtBorder(),
pActualPage->GetLwrBorder() );
// insert page at the back
mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
if( bUndo )
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
2000-09-18 16:07:07 +00:00
// use MasterPage of the current page
pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
2000-09-18 16:07:07 +00:00
pSummaryPage->SetLayoutName(pActualPage->GetLayoutName());
pSummaryPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings());
2000-09-18 16:07:07 +00:00
// notes-page
SdPage* pNotesPage = (SdPage*) mpDoc->AllocPage(false);
2000-09-18 16:07:07 +00:00
pNotesPage->SetSize(pActualNotesPage->GetSize());
pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(),
pActualNotesPage->GetUppBorder(),
pActualNotesPage->GetRgtBorder(),
pActualNotesPage->GetLwrBorder() );
pNotesPage->SetPageKind(PK_NOTES);
// insert page at the back
mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
if( bUndo )
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
2000-09-18 16:07:07 +00:00
// use MasterPage of the current page
pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
2000-09-18 16:07:07 +00:00
pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True);
pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings());
2000-09-18 16:07:07 +00:00
pOutl = new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
pOutl->SetUpdateMode(false);
pOutl->EnableUndo(false);
2000-09-18 16:07:07 +00:00
if (mpDocSh)
pOutl->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh ));
2000-09-18 16:07:07 +00:00
pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
2000-09-18 16:07:07 +00:00
pStyle = pSummaryPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
pOutl->SetStyleSheet( 0, pStyle );
}
// add text
2000-09-18 16:07:07 +00:00
OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
// #118876#, check if the OutlinerParaObject is created successfully
if( pParaObj )
{
pParaObj->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
pOutl->AddText(*pParaObj);
}
2000-09-18 16:07:07 +00:00
}
}
}
if (!pSummaryPage)
return;
2000-09-18 16:07:07 +00:00
SdrTextObj* pTextObj = (SdrTextObj*) pSummaryPage->GetPresObj(PRESOBJ_OUTLINE);
2000-09-18 16:07:07 +00:00
if (!pTextObj)
return;
// remove hard break- and character attributes
SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END);
sal_Int32 nParaCount = pOutl->GetParagraphCount();
for (sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
{
pOutl->SetStyleSheet( nPara, pStyle );
pOutl->QuickRemoveCharAttribs(nPara);
pOutl->SetParaAttribs(nPara, aEmptyEEAttr);
pOutl->SetDepth(pOutl->GetParagraph(nPara), 0);
}
2000-09-18 16:07:07 +00:00
pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
pTextObj->SetEmptyPresObj(false);
2000-09-18 16:07:07 +00:00
// remove hard attributes (Flag to sal_True)
SfxItemSet aAttr(mpDoc->GetPool());
aAttr.Put(XLineStyleItem(XLINE_NONE));
aAttr.Put(XFillStyleItem(XFILL_NONE));
pTextObj->SetMergedItemSet(aAttr);
2000-09-18 16:07:07 +00:00
if( bBegUndo )
mpView->EndUndo();
delete pOutl;
2000-09-18 16:07:07 +00:00
DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );
if(pDrawViewShell)
{
pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2);
2000-09-18 16:07:07 +00:00
}
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */