/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * 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/. * * This file incorporates work covered by the following license notice: * * 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 .
*/
// Adapt the page numbers that are registered in the page objects of the notes // pages void SdDrawDocument::UpdatePageObjectsInNotes(sal_uInt16 nStartPos)
{
sal_uInt16 nPageCount = GetPageCount();
SdPage* pPage = nullptr;
// If this is a notes page, find its page object and correct the page // number if (pPage && pPage->GetPageKind() == PageKind::Notes)
{ for (const rtl::Reference<SdrObject>& pObj : *pPage)
{ if (pObj->GetObjIdentifier() == SdrObjKind::Page &&
pObj->GetObjInventor() == SdrInventor::Default)
{ // The page object is the preceding page (drawing page)
SAL_WARN_IF(!nStartPos, "sd", "Position of notes page must not be 0.");
SAL_WARN_IF(nPage <= 1, "sd", "Page object must not be a handout.");
// Override SfxBaseModel::getUnoModel and return a more concrete type
SdXImpressDocument* SdDrawDocument::getUnoModel()
{ return comphelper::getFromUnoTunnel<SdXImpressDocument>(FmFormModel::getUnoModel());
}
// Warning: This is not called for new master pages created from SdrModel::Merge, // you also have to modify code in SdDrawDocument::Merge! void SdDrawDocument::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos )
{
FmFormModel::InsertMasterPage( pPage, nPos ); if( pPage->IsMasterPage() && (static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard) )
{ // new master page created, add its style family
SdStyleSheetPool* pStylePool = static_cast<SdStyleSheetPool*>( GetStyleSheetPool() ); if( pStylePool )
pStylePool->AddStyleFamily( static_cast<SdPage*>(pPage) );
}
}
if (pStandardPage && pStandardPage->GetPageKind() == PageKind::Standard)
pStandardPage->SetSelected(bSelect);
}
}
// If no pages exist yet, create them now void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = 0 */ )
{ // If no page exists yet in the model, (File -> New), insert a page
sal_uInt16 nPageCount = GetPageCount();
if (nPageCount > 1) return;
// #i57181# Paper size depends on Language, like in Writer
Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
// Insert master page and register this with the handout page
rtl::Reference<SdPage> pHandoutMPage = AllocSdPage(true);
pHandoutMPage->SetSize( pHandoutPage->GetSize() );
pHandoutMPage->SetPageKind(PageKind::Handout);
pHandoutMPage->SetBorder( pHandoutPage->GetLeftBorder(),
pHandoutPage->GetUpperBorder(),
pHandoutPage->GetRightBorder(),
pHandoutPage->GetLowerBorder() );
InsertMasterPage(pHandoutMPage.get(), 0);
pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
// Insert page // If nPageCount==1 is, the model for the clipboard was created, thus a // default page must already exist
rtl::Reference<SdPage> pPage; bool bClipboard = false;
pPage->SetBorder(nLeft, nTop, nRight, nBottom);
} else
{ // The printer is not available. Use a border of 10mm // on each side instead. // This has to be kept synchronized with the border // width set in the // SvxPageDescPage::PaperSizeSelect_Impl callback.
pPage->SetBorder(1000, 1000, 1000, 1000);
}
} else
{ // Impress: always use screen format, landscape.
Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, MapUnit::Map100thMM) );
pPage->SetSize( Size( aSz.Height(), aSz.Width() ) );
pPage->SetBorder(0, 0, 0, 0);
}
for (sal_uInt16 i = 1; i < nPageCount; i = i + 2)
{
SdPage* pPage = static_cast<SdPage*>( GetPage(i) );
if(!pPage->TRG_HasMasterPage())
{ // No master page set -> use first default master page // (If there was no default page in the PPT)
pPage->TRG_SetMasterPage(*GetMasterPage(1));
}
if (pPage->IsSelected())
{
aPageList.push_back(pPage);
}
} return MovePages(nTargetPage, aPageList);
}
// + Move selected pages after said page // (nTargetPage = (sal_uInt16)-1 --> move before first page) // + Returns sal_True when the page has been moved bool SdDrawDocument::MovePages(sal_uInt16 nTargetPage, const std::vector<SdPage*>& rSelectedPages)
{
SdPage* pPage = nullptr;
sal_uInt16 nPage; bool bSomethingHappened = false;
constbool bUndo = IsUndoEnabled();
if( bUndo )
BegUndo(SdResId(STR_UNDO_MOVEPAGES));
// If necessary, look backwards, until we find a page that wasn't selected
nPage = nTargetPage;
if (pNotesPage->GetAutoLayout() == AUTOLAYOUT_NONE)
{ // No AutoLayout yet -> initialize
pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
}
SetChanged(bChanged);
if( mpDocSh )
mpDocSh->SetWaitCursor( false );
}
// When the WorkStartupTimer has been created (this only happens in // SdDrawViewShell::Construct() ), the timer may be stopped and the WorkStartup // may be initiated. void SdDrawDocument::StopWorkStartupDelay()
{ if (mpWorkStartupTimer)
{ if ( mpWorkStartupTimer->IsActive() )
{ // Timer not yet expired -> initiate WorkStartup
mpWorkStartupTimer->Stop();
WorkStartupHdl(nullptr);
}
mpWorkStartupTimer.reset();
}
}
// When the WorkStartupTimer has been created (this only happens in // SdDrawViewShell::Construct() ), the timer may be stopped and the WorkStartup // may be initiated.
SdAnimationInfo* SdDrawDocument::GetAnimationInfo(SdrObject* pObject)
{
DBG_ASSERT(pObject, "sd::SdDrawDocument::GetAnimationInfo(), invalid argument!"); if( pObject ) return GetShapeUserData( *pObject ); else return nullptr;
}
// Can we find animation information within the user data? for (nUD = 0; nUD < nUDCount; nUD++)
{
SdrObjUserData* pUD = rObject.GetUserData(nUD); if((pUD->GetInventor() == SdrInventor::StarDrawUserData) && (pUD->GetId() == SD_ANIMATIONINFO_ID))
{
pRet = dynamic_cast<SdAnimationInfo*>(pUD); break;
}
}
if( (pRet == nullptr) && bCreate )
{
pRet = new SdAnimationInfo( rObject );
rObject.AppendUserData( std::unique_ptr<SdrObjUserData>(pRet) );
}
return pRet;
}
/** this method enforces that the masterpages are in the correct order, that is at position 1 is a PageKind::Standard masterpage followed by a PageKind::Notes masterpage and so on. #
*/ void SdDrawDocument::CheckMasterPages()
{
sal_uInt16 nMaxPages = GetMasterPageCount();
// we need at least a handout master and one master page if( nMaxPages < 2 )
{ return;
}
SdPage* pPage = nullptr;
sal_uInt16 nPage;
// first see if the page order is correct for( nPage = 1; nPage < nMaxPages; nPage++ )
{
pPage = static_cast<SdPage*> (GetMasterPage( nPage )); // if an odd page is not a standard page or an even page is not a notes page if( ((1 == (nPage & 1)) && (pPage->GetPageKind() != PageKind::Standard) ) ||
((0 == (nPage & 1)) && (pPage->GetPageKind() != PageKind::Notes) ) ) break; // then we have a fatal error
}
if( nPage >= nMaxPages ) return;
SdPage* pNotesPage = nullptr;
// there is a fatal error in the master page order, // we need to repair the document bool bChanged = false;
// From the given page determine the standard page and notes page of which // to take the layout and the position where to insert the new pages. if (ePageKind == PageKind::Notes)
{
pPreviousNotesPage = pActualPage;
sal_uInt16 nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
pPreviousStandardPage = static_cast<SdPage*>( GetPage(nNotesPageNum - 3) );
eStandardLayout = pPreviousStandardPage->GetAutoLayout();
} else
{
pPreviousStandardPage = pActualPage;
sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
pPreviousNotesPage = static_cast<SdPage*>( GetPage(nStandardPageNum - 1) );
eNotesLayout = pPreviousNotesPage->GetAutoLayout();
}
// Create new standard page and set it up
pStandardPage = AllocSdPage(false);
// Set the size here since else the presobj autolayout // will be wrong.
pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
pStandardPage->SetBorder( pPreviousStandardPage->GetLeftBorder(),
pPreviousStandardPage->GetUpperBorder(),
pPreviousStandardPage->GetRightBorder(),
pPreviousStandardPage->GetLowerBorder() );
// Use master page of current page.
pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
// User layout of current standard page
pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
pStandardPage->SetAutoLayout(eStandardLayout, true);
pStandardPage->setHeaderFooterSettings( pPreviousStandardPage->getHeaderFooterSettings() );
// Create new notes page and set it up
pNotesPage = AllocSdPage(false);
pNotesPage->SetPageKind(PageKind::Notes);
// Use master page of current page
pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
// Use layout of current notes page
pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
pNotesPage->SetAutoLayout(eNotesLayout, true);
pNotesPage->setHeaderFooterSettings( pPreviousNotesPage->getHeaderFooterSettings() );
return DuplicatePage (
pActualPage, ePageKind, // No names for the new slides
OUString(), OUString(),
aVisibleLayers.IsSet(aBckgrnd),
aVisibleLayers.IsSet(aBckgrndObj), -1);
}
// From the given page determine the standard page and the notes page // of which to make copies. if (ePageKind == PageKind::Notes)
{
pPreviousNotesPage = pActualPage;
sal_uInt16 nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
pPreviousStandardPage = static_cast<SdPage*>( GetPage(nNotesPageNum - 3) );
} else
{
pPreviousStandardPage = pActualPage;
sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
pPreviousNotesPage = static_cast<SdPage*>( GetPage(nStandardPageNum - 1) );
}
// Create duplicates of a standard page and the associated notes page
pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*this).get() );
pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*this).get() );
// Gather some information about the standard page and the notes page // that are to be inserted. This makes sure that there is always one // standard page followed by one notes page. if (ePageKind == PageKind::Notes)
{
pPreviousNotesPage = pActualPage;
nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
pPreviousStandardPage = static_cast<SdPage*>( GetPage(nNotesPageNum - 3) );
nStandardPageNum = nNotesPageNum - 1;
} else
{
pPreviousStandardPage = pActualPage;
nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
pPreviousNotesPage = static_cast<SdPage*>( GetPage(nStandardPageNum - 1) );
nNotesPageNum = nStandardPageNum + 1;
aNotesPageName = sStandardPageName;
}
OSL_ASSERT(nNotesPageNum==nStandardPageNum+1); if (nInsertPosition < 0)
nInsertPosition = nStandardPageNum;
// Set up and insert the standard page
SetupNewPage (
pPreviousStandardPage,
pStandardPage,
sStandardPageName,
nInsertPosition,
bIsPageBack,
bIsPageObj);
// Set up and insert the notes page
pNotesPage->SetPageKind(PageKind::Notes);
SetupNewPage (
pPreviousNotesPage,
pNotesPage,
aNotesPageName,
nInsertPosition+1,
bIsPageBack,
bIsPageObj);
// Return an index that allows the caller to access the newly inserted // pages by using GetSdPage() return pStandardPage->GetPageNum() / 2;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.