2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2012-11-27 16:10:40 +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
|
|
|
*
|
2012-11-27 16:10:40 +00:00
|
|
|
* This file incorporates work covered by the following license notice:
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2012-11-27 16:10:40 +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
|
|
|
|
2004-01-20 10:19:06 +00:00
|
|
|
#include "fusumry.hxx"
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/eeitem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/svdotext.hxx>
|
|
|
|
#include <svx/svdundo.hxx>
|
|
|
|
#include <sfx2/printer.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/outlobj.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "strings.hrc"
|
|
|
|
|
|
|
|
#include "pres.hxx"
|
2004-01-20 10:19:06 +00:00
|
|
|
#include "View.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "sdpage.hxx"
|
2004-01-20 10:19:06 +00:00
|
|
|
#include "Outliner.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "drawview.hxx"
|
|
|
|
#include "drawdoc.hxx"
|
2004-01-20 10:19:06 +00:00
|
|
|
#include "ViewShell.hxx"
|
|
|
|
#include "DrawDocShell.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "optsitem.hxx"
|
2004-01-20 10:19:06 +00:00
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
|
|
|
|
namespace sd {
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
TYPEINIT1( FuSummaryPage, FuPoor );
|
|
|
|
|
2004-01-20 10:19:06 +00:00
|
|
|
FuSummaryPage::FuSummaryPage (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2005-12-14 16:04:50 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
2005-12-14 16:04:50 +00:00
|
|
|
{
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> xFunc( new FuSummaryPage( pViewSh, pWin, pView, pDoc, rReq ) );
|
2005-12-14 16:04:50 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
2006-12-12 16:24:47 +00:00
|
|
|
void FuSummaryPage::DoExecute( SfxRequest& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-01-20 10:19:06 +00:00
|
|
|
::sd::Outliner* pOutl = NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
SdPage* pSummaryPage = NULL;
|
2011-01-17 11:41:00 +01:00
|
|
|
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)
|
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
/* How many pages are selected?
|
|
|
|
exactly one: pool everything from this page
|
|
|
|
otherwise: only pool the selected pages */
|
2006-12-12 16:24:47 +00:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
|
2009-06-04 16:21:29 +00:00
|
|
|
bool bBegUndo = false;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStyleSheet* pStyle = NULL;
|
|
|
|
|
|
|
|
for (i = nFirstPage; i < nCount; i++)
|
|
|
|
{
|
2006-12-12 16:24:47 +00:00
|
|
|
SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nSelectedPages <= 1 || pActualPage->IsSelected())
|
|
|
|
{
|
2006-12-12 16:24:47 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// insert "table of content"-page and create outliner
|
2009-06-04 16:21:29 +00:00
|
|
|
const bool bUndo = mpView->IsUndoEnabled();
|
|
|
|
|
|
|
|
if( bUndo )
|
|
|
|
{
|
2013-08-24 13:15:47 +04:00
|
|
|
mpView->BegUndo(SD_RESSTR(STR_UNDO_SUMMARY_PAGE));
|
2009-06-04 16:21:29 +00:00
|
|
|
bBegUndo = true;
|
|
|
|
}
|
|
|
|
|
2004-07-12 14:07:58 +00:00
|
|
|
SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// page with title & structuring!
|
2014-01-28 20:00:21 +01:00
|
|
|
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() );
|
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// insert page at the back
|
2006-12-12 16:24:47 +00:00
|
|
|
mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
|
2009-06-04 16:21:29 +00:00
|
|
|
if( bUndo )
|
|
|
|
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// use MasterPage of the current page
|
2004-07-12 14:07:58 +00:00
|
|
|
pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
|
2000-09-18 16:07:07 +00:00
|
|
|
pSummaryPage->SetLayoutName(pActualPage->GetLayoutName());
|
2011-01-17 11:41:00 +01:00
|
|
|
pSummaryPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
|
2004-07-12 14:07:58 +00:00
|
|
|
pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
|
2006-12-12 14:53:51 +00:00
|
|
|
pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// notes-page
|
2014-01-28 20:00:21 +01:00
|
|
|
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);
|
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// insert page at the back
|
2006-12-12 16:24:47 +00:00
|
|
|
mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
|
2009-06-04 16:21:29 +00:00
|
|
|
|
|
|
|
if( bUndo )
|
|
|
|
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// use MasterPage of the current page
|
2004-07-12 14:07:58 +00:00
|
|
|
pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
|
2000-09-18 16:07:07 +00:00
|
|
|
pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
|
2011-01-17 11:41:00 +01:00
|
|
|
pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True);
|
2004-07-12 14:07:58 +00:00
|
|
|
pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
|
2006-12-12 14:53:51 +00:00
|
|
|
pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-12-12 16:24:47 +00:00
|
|
|
pOutl = new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
|
2014-02-25 14:19:24 +02:00
|
|
|
pOutl->SetUpdateMode(false);
|
|
|
|
pOutl->EnableUndo(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-12-12 16:24:47 +00:00
|
|
|
if (mpDocSh)
|
|
|
|
pOutl->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh ));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-12-12 16:24:47 +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 );
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// add text
|
2000-09-18 16:07:07 +00:00
|
|
|
OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
|
2012-11-27 16:10:40 +00:00
|
|
|
// #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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-28 10:30:30 +00:00
|
|
|
if (!pSummaryPage)
|
|
|
|
return;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-28 10:30:30 +00:00
|
|
|
SdrTextObj* pTextObj = (SdrTextObj*) pSummaryPage->GetPresObj(PRESOBJ_OUTLINE);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-28 10:30:30 +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
|
|
|
|
2014-03-28 10:30:30 +00:00
|
|
|
pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
|
|
|
|
pTextObj->SetEmptyPresObj(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-28 10:30:30 +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
|
|
|
|
2014-03-28 10:30:30 +00:00
|
|
|
if( bBegUndo )
|
|
|
|
mpView->EndUndo();
|
|
|
|
delete pOutl;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-28 10:30:30 +00:00
|
|
|
DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );
|
|
|
|
if(pDrawViewShell)
|
|
|
|
{
|
|
|
|
pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-20 10:19:06 +00:00
|
|
|
} // end of namespace sd
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|