/* -*- 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/.
*/
// If we want a new number then set it, otherwise reuse the existing one
sal_uInt16 nPgNo = 0; if (nNewNumber)
{ // -1: Allow special case to prevent inheriting re-numbering from the existing page.
nPgNo = nNewNumber == SAL_MAX_UINT16 ? 0 : nNewNumber;
} elseif (pPageFormatDesc)
{
::std::optional<sal_uInt16> oNumOffset = pPageFormatDesc->GetNumOffset(); if (oNumOffset)
nPgNo = *oNumOffset;
}
// If we want a new descriptor then set it, otherwise reuse the existing one if (pNewDesc || nPgNo)
{
SwFormatPageDesc aPageFormatDesc(pNewDesc ? pNewDesc : &rCurrentDesc); if (nPgNo) aPageFormatDesc.SetNumOffset(nPgNo);
rSh.SetAttrItem(aPageFormatDesc);
}
}
sal_uInt16 nCurrentPage = lcl_GetCurrentPage(rSh); // return false if at document end (unless that was the requested destination) if (nCurrentPage == rSh.GetPageCnt()) return nCurrentPage == nStartingPage + nOffset;
if (nCurrentPage != nStartingPage)
{
assert(nStartingPage != 1 && "Physical page 1 couldn't be found/moved to?"); // Probably there is an auto-inserted blank page to handle odd/even, which Goto doesn't understand.
rSh.GotoPage(nStartingPage + 1, /*bRecord=*/false);
nCurrentPage = lcl_GetCurrentPage(rSh);
assert(nCurrentPage == nStartingPage + 1 && "Impossible, since unknown goes to last page"); if (nCurrentPage != nStartingPage + 1) returnfalse;
} // Now that we have the correct starting point, move to the correct offset. while (nOffset--)
rSh.SttNxtPg(); returntrue;
}
} // namespace
/* * Only include the Index page in the list if the page count implies one * to reduce confusing things
*/ void SwTitlePageDlg::FillList()
{
sal_uInt16 nTitlePages = m_xPageCountNF->get_value();
m_xPagePropertiesLB->clear(); if (mpTitleDesc)
m_xPagePropertiesLB->append_text(mpTitleDesc->GetName().toString()); if (nTitlePages > 1 && mpIndexDesc)
m_xPagePropertiesLB->append_text(mpIndexDesc->GetName().toString()); if (mpNormalDesc)
m_xPagePropertiesLB->append_text(mpNormalDesc->GetName().toString());
m_xPagePropertiesLB->set_active(0);
}
if (m_xSetPageNumberCB->get_active())
aTitleDesc.SetNumOffset(m_xSetPageNumberNF->get_value()); elseif (mpPageFormatDesc)
aTitleDesc.SetNumOffset(mpPageFormatDesc->GetNumOffset());
sal_uInt16 nNumTitlePages = m_xPageCountNF->get_value(); if (!m_xUseExistingPagesRB->get_active())
{ // Assuming that a failure to GotoPage means the end of the document, // insert new pages after the last page. if (!lcl_GotoPage(rWrtShell, GetInsertPosition()))
{
rWrtShell.EndPg(); // Add one more page as a content page to follow the new title pages.
rWrtShell.InsertPageBreak();
}
rWrtShell.DoSpecialInsert(); // Alt-Enter: if needed, inserts empty para before table/TOC
for (sal_uInt16 nI = 0; nI < nNumTitlePages; ++nI)
rWrtShell.InsertPageBreak(); // In order to be able to access these new pages, the layout needs to be recalculated first.
rWrtShell.CalcLayout();
}
if (lcl_GotoPage(rWrtShell, GetInsertPosition()))
{
rWrtShell.SetAttrItem(aTitleDesc); for (sal_uInt16 nI = 1; nI < nNumTitlePages; ++nI)
{ if (rWrtShell.SttNxtPg())
lcl_ChangePage(rWrtShell, SAL_MAX_UINT16, mpIndexDesc);
}
}
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.