/* -*- 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 .
*/
void FuPage::DoExecute(SfxRequest& rReq)
{
mpDrawViewShell = dynamic_cast<DrawViewShell*>(&mrViewShell);
DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a current DrawViewShell!" );
if( !mpPage ) { return;
} const SfxItemSet *args = rReq.GetArgs(); if (!args || args->GetItemState(SID_SELECT_BACKGROUND) == SfxItemState::SET)
{ // No arguments given -> open the async dialog which may apply new arguments
mpView->SdrEndTextEdit();
ExecuteAsyncDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, rReq);
} else { // Have arguments -> apply them to current page in-thread
ApplyItemSet( args );
}
}
FuPage::~FuPage()
{
}
void FuPage::Activate()
{
}
void FuPage::Deactivate()
{
}
void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr)
{ if (bMasterPage)
{ if (pStyleSheet)
mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
} else
{ // Only this page, get attributes for background fill const SfxItemSet& rBackgroundAttributes = pPage->getSdrPageProperties().GetItemSet();
if(drawing::FillStyle_NONE != rBackgroundAttributes.Get(XATTR_FILLSTYLE).GetValue())
{ // page attributes are used, take them
rMergedAttr.Put(rBackgroundAttributes);
} else
{ if(pStyleSheet
&& drawing::FillStyle_NONE != pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE).GetValue())
{ // if the page has no fill style, use the settings from the // background stylesheet (if used)
mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
} else
{ // no fill style from page, start with no fill style
rMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
}
}
}
}
// MigrateItemSet makes sure the XFillBitmapItem will have a unique name
SfxItemSet aMigrateSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILLBITMAP, XATTR_FILLBITMAP>(mrDoc.GetPool()));
aMigrateSet.Put(XFillBitmapItem(u"background"_ustr, std::move(aGraphic)));
SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, mrDoc );
if( mbDisplayBackgroundTabPage )
{ // if some fillstyle-items are not set in the dialog, then // try to use the items before bool bChanges = false; for( sal_uInt16 i=XATTR_FILL_FIRST; i<XATTR_FILL_LAST; i++ )
{ if( mergedAttr->GetItemState( i ) != SfxItemState::DEFAULT )
{ if( tempSet.GetItemState( i ) == SfxItemState::DEFAULT )
tempSet.Put( mergedAttr->Get( i ) ); else { if( !SfxPoolItem::areSame(mergedAttr->GetItem( i ), tempSet.GetItem( i ) ) ) {
bChanges = true;
}
}
}
}
// if the background for this page was set to invisible, the background-object has to be deleted, too. const XFillStyleItem* pTempFillStyleItem = tempSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE);
assert(pTempFillStyleItem); if (pTempFillStyleItem->GetValue() == drawing::FillStyle_NONE)
mbPageBckgrdDeleted = true; else
{ if (tempSet.GetItemState(XATTR_FILLSTYLE) == SfxItemState::DEFAULT)
{ const XFillStyleItem* pMergedFillStyleItem = mergedAttr->GetItem<XFillStyleItem>(XATTR_FILLSTYLE);
assert(pMergedFillStyleItem); if (pMergedFillStyleItem->GetValue() == drawing::FillStyle_NONE)
mbPageBckgrdDeleted = true;
}
}
if(!mpPage->IsMasterPage())
{ // on normal pages, switch off fill attribute usage
SdrPageProperties& rPageProperties = mpPage->getSdrPageProperties();
rPageProperties.ClearItem( XATTR_FILLBITMAP );
rPageProperties.ClearItem( XATTR_FILLGRADIENT );
rPageProperties.ClearItem( XATTR_FILLHATCH );
rPageProperties.PutItem(XFillStyleItem(drawing::FillStyle_NONE));
}
}
/* Special treatment: reset the INVALIDS to NULL-Pointer (otherwise INVALIDs or pointer point to DefaultItems in the template; both would
prevent the attribute inheritance) */
tempSet.ClearInvalidItems();
// if background filling is set to master pages then clear from page set if( mbMasterPage )
{ for( sal_uInt16 nWhich = XATTR_FILL_FIRST; nWhich <= XATTR_FILL_LAST; nWhich++ )
{
tempSet.ClearItem( nWhich );
}
tempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
}
// if bMasterPage==sal_False then create a background-object for this page with the // properties set in the dialog before, but if mbPageBckgrdDeleted==sal_True then // the background of this page was set to invisible, so it would be a mistake // to create a new background-object for this page !
if( mbDisplayBackgroundTabPage )
{ if( !mbMasterPage && !mbPageBckgrdDeleted )
{ // Only this page
mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction(
mrDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) );
SfxItemSet aSet( *pArgs );
sdr::properties::CleanupFillProperties(aSet);
mpPage->getSdrPageProperties().ClearItem();
mpPage->getSdrPageProperties().PutItemSet(aSet);
}
}
// add undo action for background object if( mpBackgroundObjUndoAction )
{ // set merge flag, because a SdUndoGroupAction could have been inserted before
mpDocSh->GetUndoManager()->AddUndoAction( std::move(mpBackgroundObjUndoAction), true);
}
// Objects can not be bigger than ViewSize
Size aPageSize = mrDoc.GetSdPage(0, ePageKind)->GetSize();
Size aViewSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
mrDoc.SetMaxObjSize(aViewSize);
// if necessary, we tell Preview the new context
mpDrawViewShell->UpdatePreview( mpDrawViewShell->GetActualPage() );
}
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.