/* -*- 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 .
*/
/** menu entry that is executed as default action when the left mouse button is clicked over a master page.
*/
constexpr OUStringLiteral gsDefaultClickAction = u"applyselect";
// In here we first lock the master pages in the given list and then // release the locks acquired in a previous call to this method. When // this were done the other way round the lock count of some master // pages might drop temporarily to 0 and would lead to unnecessary // deletion and re-creation of MasterPageDescriptor objects.
// Lock the master pages in the given list. for (constauto& rItem : rItemList)
{
mpContainer->AcquireToken(rItem);
aNewLockList.push_back(rItem);
}
// Release the previously locked master pages. for (constauto& rPage : maLockedMasterPages)
mpContainer->ReleaseToken(rPage);
maLockedMasterPages.swap(aNewLockList);
}
void MasterPagesSelector::Fill()
{
::std::unique_ptr<ItemList> pItemList (new ItemList);
/** Assemble a list of all slides of the document and pass it to AssignMasterPageToPageList().
*/ void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage)
{ if (pMasterPage == nullptr) return;
sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PageKind::Standard); if (nPageCount == 0) return;
// Get a list of all pages. As a little optimization we only // include pages that do not already have the given master page // assigned.
OUString sFullLayoutName(pMasterPage->GetLayoutName());
::sd::slidesorter::SharedPageSelection pPageList =
std::make_shared<::sd::slidesorter::SlideSorterViewShell::PageSelection>(); for (sal_uInt16 nPageIndex=0; nPageIndex<nPageCount; nPageIndex++)
{
SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PageKind::Standard); if (pPage != nullptr && pPage->GetLayoutName() != sFullLayoutName)
{
pPageList->push_back (pPage);
}
}
/** Assemble a list of the currently selected slides (selected in a visible slide sorter) and pass it to AssignMasterPageToPageList().
*/ void MasterPagesSelector::AssignMasterPageToSelectedSlides (
SdPage* pMasterPage)
{ usingnamespace ::sd::slidesorter; usingnamespace ::sd::slidesorter::controller;
if (pMasterPage == nullptr) return;
// Find a visible slide sorter.
SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); if (pSlideSorter == nullptr) return;
// Get a list of selected pages.
SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection(); if (pPageSelection->empty()) return;
switch (rEvent.meEventType)
{ case MasterPageContainerChangeEvent::EventType::SIZE_CHANGED:
UpdateAllPreviews(); break;
case MasterPageContainerChangeEvent::EventType::PREVIEW_CHANGED:
{ int nIndex (GetIndexForToken(rEvent.maChildToken)); if (nIndex >= 0)
{
Image aPreview(mpContainer->GetPreviewForToken(rEvent.maChildToken)); if (aPreview.GetSizePixel().Width() > 0)
{
VclPtr<VirtualDevice> pVDev = GetVirtualDevice(aPreview);
mxPreviewIconView->set_image(nIndex, *pVDev);
}
}
} break;
case MasterPageContainerChangeEvent::EventType::DATA_CHANGED:
{
InvalidateItem(rEvent.maChildToken);
Fill();
} break;
case MasterPageContainerChangeEvent::EventType::CHILD_REMOVED:
{ int nIndex (GetIndexForToken(rEvent.maChildToken));
SetItem(nIndex, MasterPageContainer::NIL_TOKEN); break;
}
std::unique_ptr<UserData> pData = GetUserData(nIndex); if (pData != nullptr)
{ // Get the token that the index pointed to previously.
MasterPageContainer::Token aOldToken (pData->second);
css::ui::LayoutSize MasterPagesSelector::GetHeightForWidth(const sal_Int32 nWidth)
{ // there is no way to get margin of item programmatically, we use value provided in ui file. constint nMargin = 6; const Size& previewSize = mpContainer->GetPreviewSizePixel();
sal_Int32 nColumnCount = nWidth / (previewSize.Width() + (2 * nMargin)); if (nColumnCount < 1)
nColumnCount = 1;
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.