/* -*- 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 .
*/
/************************************************************************* |* |* Sets: names of layout, master page links and templates for presentation |* objects |* |* Preconditions: - The page has to know the correct model! |* - The corresponding master page has to be in the model. |* - The corresponding style sheets have to be in the style sheet |* pool. |* |* bReplaceStyleSheets = sal_True : Named style sheets are replaced |* sal_False: All style sheets are reassigned |* |* bSetMasterPage = sal_True : search and assign master page |* |* bReverseOrder = sal_False: search master page from head to tail |* sal_True : search master page from tail to head |* (for undo operations) |*
\************************************************************************/
void SdPage::SetPresentationLayout(std::u16string_view rLayoutName, bool bReplaceStyleSheets, bool bSetMasterPage, bool bReverseOrder)
{ /********************************************************************* |* Name of the layout of the page
\********************************************************************/
OUString aOldLayoutName(maLayoutName); // memorize
maLayoutName = OUString::Concat(rLayoutName) + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE;
/********************************************************************* |* search and replace master page if necessary
\********************************************************************/ if (bSetMasterPage && !IsMasterPage())
{
SdPage* pMaster;
SdPage* pFoundMaster = nullptr;
sal_uInt16 nMaster = 0;
sal_uInt16 nMasterCount = getSdrModelFromSdrPage().GetMasterPageCount();
DBG_ASSERT(pFoundMaster, "Masterpage for presentation layout not found!");
// this should never happen, but we play failsafe here if( pFoundMaster == nullptr )
pFoundMaster = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPage( 0, mePageKind );
/********************************************************************* |* templates for presentation objects
\********************************************************************/ // list with: // - pointer to templates for outline text object (old and new templates) // - replace-data for OutlinerParaObject
std::vector<SfxStyleSheetBase*> aOutlineStyles;
std::vector<SfxStyleSheetBase*> aOldOutlineStyles;
std::vector<StyleReplaceData> aReplList; bool bListsFilled = false;
if (pSheet != pOldSheet)
{ if (pOldSheet)
pObj->EndListening(*pOldSheet);
if (pSheet && !pObj->IsListening(*pSheet))
pObj->StartListening(*pSheet);
}
++iterOldOut;
}
OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); if ( bReplaceStyleSheets && pOPO )
{ for (constauto& rRepl : aReplList)
{
pOPO->ChangeStyleSheets( rRepl.aName, rRepl.nFamily, rRepl.aNewName, rRepl.nNewFamily );
}
}
} elseif (pObj->GetObjInventor() == SdrInventor::Default &&
pObj->GetObjIdentifier() == SdrObjKind::TitleText)
{ // We do not get PresObjKind via GetPresObjKind() since there are // only PresObjListe considered. But we want to consider all "Title // objects" here (paste from clipboard etc.)
SfxStyleSheet* pSheet = GetStyleSheetForPresObj(PresObjKind::Title);
if (pSheet)
pObj->SetStyleSheet(pSheet, true);
}
}
}
/************************************************************************* |* |* disconnect outline text object from templates for outline levels |*
\************************************************************************/
/************************************************************************* |* |* Is this page read-only? |*
\************************************************************************/
bool SdPage::IsReadOnly() const
{ returnfalse;
}
/************************************************************************* |* |* Connect to sfx2::LinkManager |*
\************************************************************************/
/********************************************************************** * Connect * Only standard pages are allowed to be linked
**********************************************************************/
::sd::DrawDocShell* pDocSh = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocSh();
if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName)
{ // No links to document owned pages!
mpPageLink = new SdPageLink(this, maFileName, maBookmarkName);
OUString aFilterName(SdResId(STR_IMPRESS));
pLinkManager->InsertFileLink(*mpPageLink, sfx2::SvBaseLinkObjectType::ClientFile,
maFileName, &aFilterName, &maBookmarkName);
mpPageLink->Connect();
}
}
/************************************************************************* |* |* Disconnect from sfx2::LinkManager |*
\************************************************************************/
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.