tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sd / source / ui / func / fupage.cxx
blobdc3d4ea66faa59e3adbc1f508a19e1d536ff9fbb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <fupage.hxx>
21 #include <sal/types.h>
23 // arrange Tab-Page
25 #include <sfx2/sfxdlg.hxx>
26 #include <svx/pageitem.hxx>
27 #include <svx/svxids.hrc>
28 #include <svl/itempool.hxx>
29 #include <svl/grabbagitem.hxx>
30 #include <sfx2/request.hxx>
31 #include <vcl/prntypes.hxx>
32 #include <vcl/graphicfilter.hxx>
33 #include <stlsheet.hxx>
34 #include <editeng/eeitem.hxx>
35 #include <editeng/frmdiritem.hxx>
36 #include <svx/graphichelper.hxx>
37 #include <svx/xfillit0.hxx>
38 #include <svx/xbtmpit.hxx>
39 #include <svx/xflbstit.hxx>
40 #include <svx/xflbmtit.hxx>
41 #include <svx/xflgrit.hxx>
42 #include <svx/xflhtit.hxx>
43 #include <editeng/ulspitem.hxx>
44 #include <editeng/lrspitem.hxx>
45 #include <svx/sdr/properties/properties.hxx>
46 #include <editeng/shaditem.hxx>
47 #include <editeng/boxitem.hxx>
48 #include <editeng/sizeitem.hxx>
49 #include <editeng/pbinitem.hxx>
50 #include <sfx2/opengrf.hxx>
51 #include <sal/log.hxx>
52 #include <docmodel/theme/Theme.hxx>
54 #include <strings.hrc>
55 #include <sdpage.hxx>
56 #include <View.hxx>
57 #include <Window.hxx>
58 #include <pres.hxx>
59 #include <drawdoc.hxx>
60 #include <DrawDocShell.hxx>
61 #include <ViewShell.hxx>
62 #include <DrawViewShell.hxx>
63 #include <app.hrc>
64 #include <unchss.hxx>
65 #include <undoback.hxx>
66 #include <sdabstdlg.hxx>
67 #include <sdresid.hxx>
69 #include <memory>
71 using namespace com::sun::star;
73 namespace sd {
75 // 50 cm 28350
76 // adapted from writer
77 #define MAXHEIGHT 28350
78 #define MAXWIDTH 28350
81 static void mergeItemSetsImpl( SfxItemSet& rTarget, const SfxItemSet& rSource )
83 const WhichRangesContainer& rRanges = rSource.GetRanges();
84 sal_uInt16 p1, p2;
85 for (sal_Int32 i = 0; i < rRanges.size(); ++i)
87 p1 = rRanges[i].first;
88 p2 = rRanges[i].second;
90 // make ranges discrete
91 while(i < rRanges.size()-1 && (rRanges[i+1].first - p2 == 1))
93 p2 = rRanges[i+1].second;
94 ++i;
96 rTarget.MergeRange( p1, p2 );
99 rTarget.Put(rSource);
102 FuPage::FuPage( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
103 SdDrawDocument* pDoc, SfxRequest& rReq )
104 : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
105 mbPageBckgrdDeleted( false ),
106 mbMasterPage( false ),
107 mbDisplayBackgroundTabPage( true ),
108 mpPage(nullptr),
109 mpDrawViewShell(nullptr)
113 rtl::Reference<FuPoor> FuPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
115 rtl::Reference<FuPoor> xFunc( new FuPage( pViewSh, pWin, pView, pDoc, rReq ) );
116 xFunc->DoExecute(rReq);
117 return xFunc;
120 void FuPage::DoExecute(SfxRequest& rReq)
122 mpDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
123 DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a current DrawViewShell!" );
125 if( mpDrawViewShell )
127 mbMasterPage = mpDrawViewShell->GetEditMode() == EditMode::MasterPage;
128 // we don't really want to format page background with SID_ATTR_PAGE[_SIZE] slots
129 mbDisplayBackgroundTabPage = ( mpDrawViewShell->GetPageKind() == PageKind::Standard) &&
130 ( nSlotId != SID_ATTR_PAGE_SIZE) && ( nSlotId != SID_ATTR_PAGE );
131 mpPage = mpDrawViewShell->getCurrentPage();
134 if( !mpPage ) {
135 return;
137 const SfxItemSet *args = rReq.GetArgs();
138 if (!args || args->GetItemState(SID_SELECT_BACKGROUND) == SfxItemState::SET)
140 // No arguments given -> open the async dialog which may apply new arguments
141 mpView->SdrEndTextEdit();
142 ExecuteAsyncDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, rReq);
143 } else {
144 // Have arguments -> apply them to current page in-thread
145 ApplyItemSet( args );
149 FuPage::~FuPage()
153 void FuPage::Activate()
157 void FuPage::Deactivate()
161 void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr)
163 if (bMasterPage)
165 if (pStyleSheet)
166 mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
168 else
170 // Only this page, get attributes for background fill
171 const SfxItemSet& rBackgroundAttributes = pPage->getSdrPageProperties().GetItemSet();
173 if(drawing::FillStyle_NONE != rBackgroundAttributes.Get(XATTR_FILLSTYLE).GetValue())
175 // page attributes are used, take them
176 rMergedAttr.Put(rBackgroundAttributes);
178 else
180 if(pStyleSheet
181 && drawing::FillStyle_NONE != pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE).GetValue())
183 // if the page has no fill style, use the settings from the
184 // background stylesheet (if used)
185 mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
187 else
189 // no fill style from page, start with no fill style
190 rMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
196 void FuPage::ExecuteAsyncDialog(weld::Window* pParent, const SfxRequest& rReq)
198 if (!mpDrawViewShell) {
199 return;
202 std::shared_ptr<SfxItemSet> aNewAttr = std::make_shared<
203 SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST,
204 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
205 SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_OUTER,
206 SID_ATTR_BORDER_SHADOW, SID_ATTR_BORDER_SHADOW,
207 SID_ATTR_PAGE, SID_ATTR_PAGE_SHARED,
208 SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG,
209 SID_ATTR_PAGE_COLOR, SID_ATTR_PAGE_FILLSTYLE>>(mpDoc->GetPool());
210 // Keep it sorted
211 aNewAttr->MergeRange(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE),
212 mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
214 // Retrieve additional data for dialog
216 SvxShadowItem aShadowItem(SID_ATTR_BORDER_SHADOW);
217 aNewAttr->Put( aShadowItem );
218 SvxBoxItem aBoxItem( SID_ATTR_BORDER_OUTER );
219 aNewAttr->Put( aBoxItem );
221 aNewAttr->Put( SvxFrameDirectionItem(
222 mpDoc->GetDefaultWritingMode() == css::text::WritingMode_RL_TB ? SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB,
223 EE_PARA_WRITINGDIR ) );
225 // Retrieve page-data for dialog
227 SvxPageItem aPageItem( SID_ATTR_PAGE );
228 aPageItem.SetDescName( mpPage->GetName() );
229 aPageItem.SetPageUsage( SvxPageUsage::All );
230 aPageItem.SetLandscape( mpPage->GetOrientation() == Orientation::Landscape );
231 aPageItem.SetNumType( mpDoc->GetPageNumType() );
232 aNewAttr->Put( aPageItem );
234 // size
235 maSize = mpPage->GetSize();
236 SvxSizeItem aSizeItem( SID_ATTR_PAGE_SIZE, maSize );
237 aNewAttr->Put( aSizeItem );
239 // Max size
240 SvxSizeItem aMaxSizeItem( SID_ATTR_PAGE_MAXSIZE, Size( MAXWIDTH, MAXHEIGHT ) );
241 aNewAttr->Put( aMaxSizeItem );
243 // paperbin
244 SvxPaperBinItem aPaperBinItem( SID_ATTR_PAGE_PAPERBIN, static_cast<sal_uInt8>(mpPage->GetPaperBin()) );
245 aNewAttr->Put( aPaperBinItem );
247 SvxLRSpaceItem aLRSpaceItem(SvxIndentValue::twips(mpPage->GetLeftBorder()),
248 SvxIndentValue::twips(mpPage->GetRightBorder()),
249 SvxIndentValue::zero(),
250 mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE));
251 aNewAttr->Put( aLRSpaceItem );
253 SvxULSpaceItem aULSpaceItem( static_cast<sal_uInt16>(mpPage->GetUpperBorder()), static_cast<sal_uInt16>(mpPage->GetLowerBorder()), mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
254 aNewAttr->Put( aULSpaceItem );
256 // Application
257 bool bScale = mpDoc->GetDocumentType() != DocumentType::Draw;
258 aNewAttr->Put( SfxBoolItem( SID_ATTR_PAGE_EXT1, bScale ) );
260 bool bFullSize = mpPage->IsMasterPage() ?
261 mpPage->IsBackgroundFullSize() : static_cast<SdPage&>(mpPage->TRG_GetMasterPage()).IsBackgroundFullSize();
263 SfxGrabBagItem grabBag(SID_ATTR_CHAR_GRABBAG,
264 std::map<OUString, css::uno::Any>{{u"BackgroundFullSize"_ustr, uno::Any(bFullSize)}});
266 aNewAttr->Put(grabBag);
268 // Merge ItemSet for dialog
270 const WhichRangesContainer& rRanges = aNewAttr->GetRanges();
271 sal_uInt16 p1 = rRanges[0].first, p2 = rRanges[0].second;
272 sal_Int32 idx = 1;
273 while(idx < rRanges.size() && (rRanges[idx].first - p2 == 1))
275 p2 = rRanges[idx].second;
276 ++idx;
278 std::shared_ptr<SfxItemSet> aMergedAttr = std::make_shared<SfxItemSet>( *aNewAttr->GetPool(), p1, p2 );
280 mergeItemSetsImpl( *aMergedAttr, *aNewAttr );
282 SdStyleSheet* pStyleSheet = mpPage->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND);
284 // merge page background filling to the dialogs input set
285 if( mbDisplayBackgroundTabPage )
287 MergePageBackgroundFilling(mpPage, pStyleSheet, mbMasterPage, *aMergedAttr);
290 const sal_uInt16 nId = GetSlotID();
291 if (nId == SID_SAVE_BACKGROUND)
293 const XFillStyleItem& rStyleItem = aMergedAttr->Get(XATTR_FILLSTYLE);
294 if (drawing::FillStyle_BITMAP == rStyleItem.GetValue())
296 const XFillBitmapItem& rBitmap = aMergedAttr->Get(XATTR_FILLBITMAP);
297 const GraphicObject& rGraphicObj = rBitmap.GetGraphicObject();
298 GraphicHelper::ExportGraphic(pParent, rGraphicObj.GetGraphic(), u""_ustr);
301 else if (nId == SID_SELECT_BACKGROUND)
303 Graphic aGraphic;
304 ErrCode nError = ERRCODE_GRFILTER_OPENERROR;
306 const SfxItemSet* pArgs = rReq.GetArgs();
307 const SfxPoolItem* pItem;
309 if (pArgs && pArgs->GetItemState(SID_SELECT_BACKGROUND, true, &pItem) == SfxItemState::SET)
311 OUString aFileName(static_cast<const SfxStringItem*>(pItem)->GetValue());
312 OUString aFilterName;
314 if (const SfxStringItem* pFilterItem = pArgs->GetItemIfSet(FN_PARAM_FILTER))
315 aFilterName = pFilterItem->GetValue();
317 nError = GraphicFilter::LoadGraphic(aFileName, aFilterName, aGraphic,
318 &GraphicFilter::GetGraphicFilter());
320 else
322 SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), pParent);
324 nError = aDlg.Execute();
325 if (nError == ERRCODE_NONE)
327 nError = aDlg.GetGraphic(aGraphic);
331 if (nError == ERRCODE_NONE)
333 SfxItemSet tempSet( mpDoc->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST> );
335 tempSet.Put( XFillStyleItem( drawing::FillStyle_BITMAP ) );
337 // MigrateItemSet makes sure the XFillBitmapItem will have a unique name
338 SfxItemSetFixed<XATTR_FILLBITMAP, XATTR_FILLBITMAP> aMigrateSet( mpDoc->GetPool() );
339 aMigrateSet.Put(XFillBitmapItem(u"background"_ustr, std::move(aGraphic)));
340 SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, *mpDoc );
342 tempSet.Put( XFillBmpStretchItem( true ));
343 tempSet.Put( XFillBmpTileItem( false ));
344 if( pStyleSheet ) {
345 ApplyItemSet(*pStyleSheet, aNewAttr, tempSet, aMergedAttr);
348 } else {
349 bool bIsImpressDoc = mpDrawViewShell->GetDoc()->GetDocumentType() == DocumentType::Impress;
351 // create the dialog and start async execution
352 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
353 VclPtr<SfxAbstractTabDialog> xDlg( pFact->CreateSdTabPageDialog(mpViewShell->GetFrameWeld(),
354 aMergedAttr.get(), mpDocSh, mbDisplayBackgroundTabPage, bIsImpressDoc) );
355 rtl::Reference<FuPage> xThis( this ); // avoid destruction within async processing
356 xDlg->StartExecuteAsync([xDlg, xThis, pStyleSheet, aNewAttr=std::move(aNewAttr),
357 aMergedAttr=std::move(aMergedAttr)](sal_Int32 nResult) {
358 if (nResult == RET_OK && pStyleSheet) {
359 SfxItemSet tempSet(*xDlg->GetOutputItemSet());
360 xThis->ApplyItemSet(*pStyleSheet, aNewAttr, tempSet, aMergedAttr);
362 xDlg->disposeOnce();
363 // Final release of xThis (post async use, RIAA)
368 void FuPage::ApplyItemSet(SdStyleSheet& styleSheet, const std::shared_ptr<SfxItemSet>& newAttr,
369 SfxItemSet& tempSet, const std::shared_ptr<SfxItemSet>& mergedAttr) {
370 styleSheet.AdjustToFontHeight(tempSet);
372 if( mbDisplayBackgroundTabPage )
374 // if some fillstyle-items are not set in the dialog, then
375 // try to use the items before
376 bool bChanges = false;
377 for( sal_uInt16 i=XATTR_FILL_FIRST; i<XATTR_FILL_LAST; i++ )
379 if( mergedAttr->GetItemState( i ) != SfxItemState::DEFAULT )
381 if( tempSet.GetItemState( i ) == SfxItemState::DEFAULT )
382 tempSet.Put( mergedAttr->Get( i ) );
383 else {
384 if( !SfxPoolItem::areSame(mergedAttr->GetItem( i ), tempSet.GetItem( i ) ) ) {
385 bChanges = true;
391 // if the background for this page was set to invisible, the background-object has to be deleted, too.
392 const XFillStyleItem* pTempFillStyleItem = tempSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE);
393 assert(pTempFillStyleItem);
394 if (pTempFillStyleItem->GetValue() == drawing::FillStyle_NONE)
395 mbPageBckgrdDeleted = true;
396 else
398 if (tempSet.GetItemState(XATTR_FILLSTYLE) == SfxItemState::DEFAULT)
400 const XFillStyleItem* pMergedFillStyleItem = mergedAttr->GetItem<XFillStyleItem>(XATTR_FILLSTYLE);
401 assert(pMergedFillStyleItem);
402 if (pMergedFillStyleItem->GetValue() == drawing::FillStyle_NONE)
403 mbPageBckgrdDeleted = true;
407 const XFillGradientItem* pTempGradItem = tempSet.GetItem<XFillGradientItem>(XATTR_FILLGRADIENT);
408 if (pTempGradItem && pTempGradItem->GetName().isEmpty())
410 // MigrateItemSet guarantees unique gradient names
411 SfxItemSetFixed<XATTR_FILLGRADIENT, XATTR_FILLGRADIENT> aMigrateSet( mpDoc->GetPool() );
412 aMigrateSet.Put( XFillGradientItem(u"gradient"_ustr, pTempGradItem->GetGradientValue()) );
413 SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, *mpDoc);
416 const XFillHatchItem* pTempHatchItem = tempSet.GetItem<XFillHatchItem>(XATTR_FILLHATCH);
417 if (pTempHatchItem && pTempHatchItem->GetName().isEmpty())
419 // MigrateItemSet guarantees unique hatch names
420 SfxItemSetFixed<XATTR_FILLHATCH, XATTR_FILLHATCH> aMigrateSet( mpDoc->GetPool() );
421 aMigrateSet.Put( XFillHatchItem(u"hatch"_ustr, pTempHatchItem->GetHatchValue()) );
422 SdrModel::MigrateItemSet( &aMigrateSet, &tempSet, *mpDoc);
425 if( !mbMasterPage && bChanges && mbPageBckgrdDeleted )
427 mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction(
428 *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) );
430 if(!mpPage->IsMasterPage())
432 // on normal pages, switch off fill attribute usage
433 SdrPageProperties& rPageProperties = mpPage->getSdrPageProperties();
434 rPageProperties.ClearItem( XATTR_FILLBITMAP );
435 rPageProperties.ClearItem( XATTR_FILLGRADIENT );
436 rPageProperties.ClearItem( XATTR_FILLHATCH );
437 rPageProperties.PutItem(XFillStyleItem(drawing::FillStyle_NONE));
442 /* Special treatment: reset the INVALIDS to
443 NULL-Pointer (otherwise INVALIDs or pointer point
444 to DefaultItems in the template; both would
445 prevent the attribute inheritance) */
446 tempSet.ClearInvalidItems();
448 if( mbMasterPage )
450 mpDocSh->GetUndoManager()->AddUndoAction(std::make_unique<StyleSheetUndoAction>(
451 mpDoc, *static_cast<SfxStyleSheet*>(&styleSheet), &tempSet));
452 styleSheet.GetItemSet().Put( tempSet );
453 sdr::properties::CleanupFillProperties( styleSheet.GetItemSet() );
454 styleSheet.Broadcast(SfxHint(SfxHintId::DataChanged));
457 // if background filling is set to master pages then clear from page set
458 if( mbMasterPage )
460 for( sal_uInt16 nWhich = XATTR_FILL_FIRST; nWhich <= XATTR_FILL_LAST; nWhich++ )
462 tempSet.ClearItem( nWhich );
464 tempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
467 if( const SvxFrameDirectionItem* pItem = tempSet.GetItemIfSet( EE_PARA_WRITINGDIR, false ) )
469 SvxFrameDirection nVal = pItem->GetValue();
470 mpDoc->SetDefaultWritingMode( nVal == SvxFrameDirection::Horizontal_RL_TB ? css::text::WritingMode_RL_TB : css::text::WritingMode_LR_TB );
473 mpDoc->SetChanged();
475 // BackgroundFill of Masterpage: no hard attributes allowed
476 SdrPage& rUsedMasterPage = mpPage->IsMasterPage() ? *mpPage : mpPage->TRG_GetMasterPage();
477 OSL_ENSURE(rUsedMasterPage.IsMasterPage(), "No MasterPage (!)");
478 rUsedMasterPage.getSdrPageProperties().ClearItem();
479 OSL_ENSURE(nullptr != rUsedMasterPage.getSdrPageProperties().GetStyleSheet(),
480 "MasterPage without StyleSheet detected (!)");
483 newAttr->Put( tempSet );
484 ApplyItemSet( newAttr.get() );
487 void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
489 if (!pArgs || !mpDrawViewShell) {
490 return;
493 // Set new page-attributes
494 PageKind ePageKind = mpDrawViewShell->GetPageKind();
495 const SfxPoolItem* pPoolItem;
496 bool bSetPageSizeAndBorder = false;
497 Size aNewSize(maSize);
498 sal_Int32 nLeft = -1, nRight = -1, nUpper = -1, nLower = -1;
499 bool bScaleAll = true;
500 Orientation eOrientation = mpPage->GetOrientation();
501 SdPage* pMasterPage = mpPage->IsMasterPage() ? mpPage : &static_cast<SdPage&>(mpPage->TRG_GetMasterPage());
502 bool bFullSize = pMasterPage->IsBackgroundFullSize();
503 sal_uInt16 nPaperBin = mpPage->GetPaperBin();
505 if( pArgs->GetItemState(SID_ATTR_PAGE, true, &pPoolItem) == SfxItemState::SET )
507 mpDoc->SetPageNumType(static_cast<const SvxPageItem*>(pPoolItem)->GetNumType());
509 eOrientation = static_cast<const SvxPageItem*>(pPoolItem)->IsLandscape() ?
510 Orientation::Landscape : Orientation::Portrait;
512 if( mpPage->GetOrientation() != eOrientation )
513 bSetPageSizeAndBorder = true;
515 mpDrawViewShell->ResetActualPage();
518 if( pArgs->GetItemState(SID_ATTR_PAGE_SIZE, true, &pPoolItem) == SfxItemState::SET )
520 aNewSize = static_cast<const SvxSizeItem*>(pPoolItem)->GetSize();
522 if( mpPage->GetSize() != aNewSize )
523 bSetPageSizeAndBorder = true;
526 if( pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE),
527 true, &pPoolItem) == SfxItemState::SET )
529 nLeft = static_cast<const SvxLRSpaceItem*>(pPoolItem)->ResolveLeft({});
530 nRight = static_cast<const SvxLRSpaceItem*>(pPoolItem)->ResolveRight({});
532 if( mpPage->GetLeftBorder() != nLeft || mpPage->GetRightBorder() != nRight )
533 bSetPageSizeAndBorder = true;
537 if( pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE),
538 true, &pPoolItem) == SfxItemState::SET )
540 nUpper = static_cast<const SvxULSpaceItem*>(pPoolItem)->GetUpper();
541 nLower = static_cast<const SvxULSpaceItem*>(pPoolItem)->GetLower();
543 if( mpPage->GetUpperBorder() != nUpper || mpPage->GetLowerBorder() != nLower )
544 bSetPageSizeAndBorder = true;
547 if( pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_EXT1), true, &pPoolItem) == SfxItemState::SET )
549 bScaleAll = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
552 if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_CHAR_GRABBAG, true, &pPoolItem))
554 SfxGrabBagItem const*const pGrabBag(static_cast<SfxGrabBagItem const*>(pPoolItem));
555 const auto& rGrabBagInner = pGrabBag->GetGrabBag();
556 const auto iter = rGrabBagInner.find(u"BackgroundFullSize"_ustr);
557 assert(iter != rGrabBagInner.end());
558 if (iter->second >>= bFullSize)
560 if (pMasterPage->IsBackgroundFullSize() != bFullSize)
562 bSetPageSizeAndBorder = true;
567 // Paper Bin
568 if( pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_PAPERBIN), true, &pPoolItem) == SfxItemState::SET )
570 nPaperBin = static_cast<const SvxPaperBinItem*>(pPoolItem)->GetValue();
572 if( mpPage->GetPaperBin() != nPaperBin )
573 bSetPageSizeAndBorder = true;
576 if (nLeft == -1 && nUpper != -1)
578 bSetPageSizeAndBorder = true;
579 nLeft = mpPage->GetLeftBorder();
580 nRight = mpPage->GetRightBorder();
582 else if (nLeft != -1 && nUpper == -1)
584 bSetPageSizeAndBorder = true;
585 nUpper = mpPage->GetUpperBorder();
586 nLower = mpPage->GetLowerBorder();
589 if( bSetPageSizeAndBorder || !mbMasterPage )
590 mpDrawViewShell->SetPageSizeAndBorder(ePageKind, aNewSize, nLeft, nRight, nUpper, nLower, bScaleAll, eOrientation, nPaperBin, bFullSize );
592 // if bMasterPage==sal_False then create a background-object for this page with the
593 // properties set in the dialog before, but if mbPageBckgrdDeleted==sal_True then
594 // the background of this page was set to invisible, so it would be a mistake
595 // to create a new background-object for this page !
597 if( mbDisplayBackgroundTabPage )
599 if( !mbMasterPage && !mbPageBckgrdDeleted )
601 // Only this page
602 mpBackgroundObjUndoAction.reset( new SdBackgroundObjUndoAction(
603 *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet()) );
604 SfxItemSet aSet( *pArgs );
605 sdr::properties::CleanupFillProperties(aSet);
606 mpPage->getSdrPageProperties().ClearItem();
607 mpPage->getSdrPageProperties().PutItemSet(aSet);
611 // add undo action for background object
612 if( mpBackgroundObjUndoAction )
614 // set merge flag, because a SdUndoGroupAction could have been inserted before
615 mpDocSh->GetUndoManager()->AddUndoAction( std::move(mpBackgroundObjUndoAction), true );
618 // Objects can not be bigger than ViewSize
619 Size aPageSize = mpDoc->GetSdPage(0, ePageKind)->GetSize();
620 Size aViewSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
621 mpDoc->SetMaxObjSize(aViewSize);
623 // if necessary, we tell Preview the new context
624 mpDrawViewShell->UpdatePreview( mpDrawViewShell->GetActualPage() );
627 } // end of namespace sd
629 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */