1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
24 #include <sfx2/sfxdlg.hxx>
25 #include <svx/pageitem.hxx>
26 #include <svx/svxids.hrc>
27 #include <svl/itempool.hxx>
28 #include <svl/grabbagitem.hxx>
29 #include <sfx2/request.hxx>
30 #include <vcl/prntypes.hxx>
31 #include <vcl/graphicfilter.hxx>
32 #include <stlsheet.hxx>
33 #include <editeng/eeitem.hxx>
34 #include <editeng/frmdiritem.hxx>
35 #include <svx/graphichelper.hxx>
36 #include <svx/xfillit0.hxx>
37 #include <svx/xbtmpit.hxx>
38 #include <svx/xflbstit.hxx>
39 #include <svx/xflbmtit.hxx>
40 #include <svx/xflgrit.hxx>
41 #include <svx/xflhtit.hxx>
42 #include <editeng/ulspitem.hxx>
43 #include <editeng/lrspitem.hxx>
44 #include <svx/sdr/properties/properties.hxx>
45 #include <editeng/shaditem.hxx>
46 #include <editeng/boxitem.hxx>
47 #include <editeng/sizeitem.hxx>
48 #include <editeng/pbinitem.hxx>
49 #include <sfx2/opengrf.hxx>
50 #include <sal/log.hxx>
51 #include <docmodel/theme/Theme.hxx>
53 #include <strings.hrc>
58 #include <drawdoc.hxx>
59 #include <DrawDocShell.hxx>
60 #include <ViewShell.hxx>
61 #include <DrawViewShell.hxx>
64 #include <undoback.hxx>
65 #include <sdabstdlg.hxx>
66 #include <sdresid.hxx>
70 using namespace com::sun::star
;
75 // adapted from writer
76 #define MAXHEIGHT 28350
77 #define MAXWIDTH 28350
80 static void mergeItemSetsImpl( SfxItemSet
& rTarget
, const SfxItemSet
& rSource
)
82 const WhichRangesContainer
& rRanges
= rSource
.GetRanges();
84 for (sal_Int32 i
= 0; i
< rRanges
.size(); ++i
)
86 p1
= rRanges
[i
].first
;
87 p2
= rRanges
[i
].second
;
89 // make ranges discrete
90 while(i
< rRanges
.size()-1 && (rRanges
[i
+1].first
- p2
== 1))
92 p2
= rRanges
[i
+1].second
;
95 rTarget
.MergeRange( p1
, p2
);
101 FuPage::FuPage( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
,
102 SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
103 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
105 mpArgs( rReq
.GetArgs() ),
106 mbPageBckgrdDeleted( false ),
107 mbMasterPage( false ),
108 mbDisplayBackgroundTabPage( true ),
110 mpDrawViewShell(nullptr)
114 rtl::Reference
<FuPoor
> FuPage::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
116 rtl::Reference
<FuPoor
> xFunc( new FuPage( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
117 xFunc
->DoExecute(rReq
);
121 void FuPage::DoExecute(SfxRequest
& rReq
)
123 mpDrawViewShell
= dynamic_cast<DrawViewShell
*>(mpViewShell
);
124 DBG_ASSERT( mpDrawViewShell
, "sd::FuPage::FuPage(), called without a current DrawViewShell!" );
126 if( mpDrawViewShell
)
128 mbMasterPage
= mpDrawViewShell
->GetEditMode() == EditMode::MasterPage
;
129 // we don't really want to format page background with SID_ATTR_PAGE[_SIZE] slots
130 mbDisplayBackgroundTabPage
= ( mpDrawViewShell
->GetPageKind() == PageKind::Standard
) &&
131 ( nSlotId
!= SID_ATTR_PAGE_SIZE
) && ( nSlotId
!= SID_ATTR_PAGE
);
132 mpPage
= mpDrawViewShell
->getCurrentPage();
138 // if there are no arguments given, open the dialog
139 if (!mpArgs
|| mpArgs
->GetItemState(SID_SELECT_BACKGROUND
) == SfxItemState::SET
)
141 mpView
->SdrEndTextEdit();
142 mpArgs
= ExecuteDialog(mpWindow
? mpWindow
->GetFrameWeld() : nullptr, rReq
);
145 // if we now have arguments, apply them to current page
148 ApplyItemSet( mpArgs
);
156 void FuPage::Activate()
160 void FuPage::Deactivate()
164 void MergePageBackgroundFilling(SdPage
*pPage
, SdStyleSheet
*pStyleSheet
, bool bMasterPage
, SfxItemSet
& rMergedAttr
)
169 mergeItemSetsImpl(rMergedAttr
, pStyleSheet
->GetItemSet());
173 // Only this page, get attributes for background fill
174 const SfxItemSet
& rBackgroundAttributes
= pPage
->getSdrPageProperties().GetItemSet();
176 if(drawing::FillStyle_NONE
!= rBackgroundAttributes
.Get(XATTR_FILLSTYLE
).GetValue())
178 // page attributes are used, take them
179 rMergedAttr
.Put(rBackgroundAttributes
);
184 && drawing::FillStyle_NONE
!= pStyleSheet
->GetItemSet().Get(XATTR_FILLSTYLE
).GetValue())
186 // if the page has no fill style, use the settings from the
187 // background stylesheet (if used)
188 mergeItemSetsImpl(rMergedAttr
, pStyleSheet
->GetItemSet());
192 // no fill style from page, start with no fill style
193 rMergedAttr
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
199 const SfxItemSet
* FuPage::ExecuteDialog(weld::Window
* pParent
, const SfxRequest
& rReq
)
201 if (!mpDrawViewShell
)
205 XATTR_FILL_FIRST
, XATTR_FILL_LAST
,
206 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
207 SID_ATTR_BORDER_OUTER
, SID_ATTR_BORDER_OUTER
,
208 SID_ATTR_BORDER_SHADOW
, SID_ATTR_BORDER_SHADOW
,
209 SID_ATTR_PAGE
, SID_ATTR_PAGE_SHARED
,
210 SID_ATTR_CHAR_GRABBAG
, SID_ATTR_CHAR_GRABBAG
,
211 SID_ATTR_PAGE_COLOR
, SID_ATTR_PAGE_FILLSTYLE
212 > aNewAttr(mpDoc
->GetPool());
214 aNewAttr
.MergeRange(mpDoc
->GetPool().GetWhich(SID_ATTR_LRSPACE
),
215 mpDoc
->GetPool().GetWhich(SID_ATTR_ULSPACE
));
217 // Retrieve additional data for dialog
219 SvxShadowItem
aShadowItem(SID_ATTR_BORDER_SHADOW
);
220 aNewAttr
.Put( aShadowItem
);
221 SvxBoxItem
aBoxItem( SID_ATTR_BORDER_OUTER
);
222 aNewAttr
.Put( aBoxItem
);
224 aNewAttr
.Put( SvxFrameDirectionItem(
225 mpDoc
->GetDefaultWritingMode() == css::text::WritingMode_RL_TB
? SvxFrameDirection::Horizontal_RL_TB
: SvxFrameDirection::Horizontal_LR_TB
,
226 EE_PARA_WRITINGDIR
) );
228 // Retrieve page-data for dialog
230 SvxPageItem
aPageItem( SID_ATTR_PAGE
);
231 aPageItem
.SetDescName( mpPage
->GetName() );
232 aPageItem
.SetPageUsage( SvxPageUsage::All
);
233 aPageItem
.SetLandscape( mpPage
->GetOrientation() == Orientation::Landscape
);
234 aPageItem
.SetNumType( mpDoc
->GetPageNumType() );
235 aNewAttr
.Put( aPageItem
);
238 maSize
= mpPage
->GetSize();
239 SvxSizeItem
aSizeItem( SID_ATTR_PAGE_SIZE
, maSize
);
240 aNewAttr
.Put( aSizeItem
);
243 SvxSizeItem
aMaxSizeItem( SID_ATTR_PAGE_MAXSIZE
, Size( MAXWIDTH
, MAXHEIGHT
) );
244 aNewAttr
.Put( aMaxSizeItem
);
247 SvxPaperBinItem
aPaperBinItem( SID_ATTR_PAGE_PAPERBIN
, static_cast<sal_uInt8
>(mpPage
->GetPaperBin()) );
248 aNewAttr
.Put( aPaperBinItem
);
250 SvxLRSpaceItem
aLRSpaceItem( static_cast<sal_uInt16
>(mpPage
->GetLeftBorder()), static_cast<sal_uInt16
>(mpPage
->GetRightBorder()), 0, mpDoc
->GetPool().GetWhich(SID_ATTR_LRSPACE
));
251 aNewAttr
.Put( aLRSpaceItem
);
253 SvxULSpaceItem
aULSpaceItem( static_cast<sal_uInt16
>(mpPage
->GetUpperBorder()), static_cast<sal_uInt16
>(mpPage
->GetLowerBorder()), mpDoc
->GetPool().GetWhich(SID_ATTR_ULSPACE
));
254 aNewAttr
.Put( aULSpaceItem
);
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 grabBag
.GetGrabBag()["BackgroundFullSize"] <<= bFullSize
;
266 if (mpDoc
->GetDocumentType() == DocumentType::Impress
&& mpPage
->IsMasterPage())
268 // A master slide may have a theme.
269 auto const& pTheme
= mpPage
->getSdrPageProperties().GetTheme();
273 pTheme
->ToAny(aTheme
);
274 grabBag
.GetGrabBag()["Theme"] = aTheme
;
278 aNewAttr
.Put(grabBag
);
280 // Merge ItemSet for dialog
282 const WhichRangesContainer
& rRanges
= aNewAttr
.GetRanges();
283 sal_uInt16 p1
= rRanges
[0].first
, p2
= rRanges
[0].second
;
285 while(idx
< rRanges
.size() && (rRanges
[idx
].first
- p2
== 1))
287 p2
= rRanges
[idx
].second
;
290 SfxItemSet
aMergedAttr( *aNewAttr
.GetPool(), p1
, p2
);
292 mergeItemSetsImpl( aMergedAttr
, aNewAttr
);
294 SdStyleSheet
* pStyleSheet
= mpPage
->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND
);
296 // merge page background filling to the dialogs input set
297 if( mbDisplayBackgroundTabPage
)
299 MergePageBackgroundFilling(mpPage
, pStyleSheet
, mbMasterPage
, aMergedAttr
);
302 std::optional
< SfxItemSet
> pTempSet
;
304 const sal_uInt16 nId
= GetSlotID();
305 if (nId
== SID_SAVE_BACKGROUND
)
307 const XFillStyleItem
& rStyleItem
= aMergedAttr
.Get(XATTR_FILLSTYLE
);
308 if (drawing::FillStyle_BITMAP
== rStyleItem
.GetValue())
310 const XFillBitmapItem
& rBitmap
= aMergedAttr
.Get(XATTR_FILLBITMAP
);
311 const GraphicObject
& rGraphicObj
= rBitmap
.GetGraphicObject();
312 GraphicHelper::ExportGraphic(pParent
, rGraphicObj
.GetGraphic(), "");
315 else if (nId
== SID_SELECT_BACKGROUND
)
318 ErrCode nError
= ERRCODE_GRFILTER_OPENERROR
;
320 const SfxItemSet
* pArgs
= rReq
.GetArgs();
321 const SfxPoolItem
* pItem
;
323 if (pArgs
&& pArgs
->GetItemState(SID_SELECT_BACKGROUND
, true, &pItem
) == SfxItemState::SET
)
325 OUString
aFileName(static_cast<const SfxStringItem
*>(pItem
)->GetValue());
326 OUString aFilterName
;
328 if (const SfxStringItem
* pFilterItem
= pArgs
->GetItemIfSet(FN_PARAM_FILTER
))
329 aFilterName
= pFilterItem
->GetValue();
331 nError
= GraphicFilter::LoadGraphic(aFileName
, aFilterName
, aGraphic
,
332 &GraphicFilter::GetGraphicFilter());
336 SvxOpenGraphicDialog
aDlg(SdResId(STR_SET_BACKGROUND_PICTURE
), pParent
);
338 nError
= aDlg
.Execute();
339 if (nError
== ERRCODE_NONE
)
341 nError
= aDlg
.GetGraphic(aGraphic
);
345 if (nError
== ERRCODE_NONE
)
347 pTempSet
.emplace( mpDoc
->GetPool(), svl::Items
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> );
349 pTempSet
->Put( XFillStyleItem( drawing::FillStyle_BITMAP
) );
351 // MigrateItemSet makes sure the XFillBitmapItem will have a unique name
352 SfxItemSetFixed
<XATTR_FILLBITMAP
, XATTR_FILLBITMAP
> aMigrateSet( mpDoc
->GetPool() );
353 aMigrateSet
.Put(XFillBitmapItem("background", std::move(aGraphic
)));
354 SdrModel::MigrateItemSet( &aMigrateSet
, &*pTempSet
, mpDoc
);
356 pTempSet
->Put( XFillBmpStretchItem( true ));
357 pTempSet
->Put( XFillBmpTileItem( false ));
363 bool bIsImpressDoc
= mpDrawViewShell
->GetDoc()->GetDocumentType() == DocumentType::Impress
;
366 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
367 ScopedVclPtr
<SfxAbstractTabDialog
> pDlg( pFact
->CreateSdTabPageDialog(mpViewShell
->GetFrameWeld(), &aMergedAttr
, mpDocSh
, mbDisplayBackgroundTabPage
, bIsImpressDoc
, mbMasterPage
) );
368 if( pDlg
->Execute() == RET_OK
)
369 pTempSet
.emplace( *pDlg
->GetOutputItemSet() );
372 if (pTempSet
&& pStyleSheet
)
374 pStyleSheet
->AdjustToFontHeight(*pTempSet
);
376 if( mbDisplayBackgroundTabPage
)
378 // if some fillstyle-items are not set in the dialog, then
379 // try to use the items before
380 bool bChanges
= false;
381 for( sal_uInt16 i
=XATTR_FILL_FIRST
; i
<XATTR_FILL_LAST
; i
++ )
383 if( aMergedAttr
.GetItemState( i
) != SfxItemState::DEFAULT
)
385 if( pTempSet
->GetItemState( i
) == SfxItemState::DEFAULT
)
386 pTempSet
->Put( aMergedAttr
.Get( i
) );
388 if( aMergedAttr
.GetItem( i
) != pTempSet
->GetItem( i
) )
393 // if the background for this page was set to invisible, the background-object has to be deleted, too.
394 const XFillStyleItem
* pTempFillStyleItem
= pTempSet
->GetItem
<XFillStyleItem
>(XATTR_FILLSTYLE
);
395 assert(pTempFillStyleItem
);
396 if (pTempFillStyleItem
->GetValue() == drawing::FillStyle_NONE
)
397 mbPageBckgrdDeleted
= true;
400 if (pTempSet
->GetItemState(XATTR_FILLSTYLE
) == SfxItemState::DEFAULT
)
402 const XFillStyleItem
* pMergedFillStyleItem
= aMergedAttr
.GetItem
<XFillStyleItem
>(XATTR_FILLSTYLE
);
403 assert(pMergedFillStyleItem
);
404 if (pMergedFillStyleItem
->GetValue() == drawing::FillStyle_NONE
)
405 mbPageBckgrdDeleted
= true;
409 const XFillGradientItem
* pTempGradItem
= pTempSet
->GetItem
<XFillGradientItem
>(XATTR_FILLGRADIENT
);
410 if (pTempGradItem
&& pTempGradItem
->GetName().isEmpty())
412 // MigrateItemSet guarantees unique gradient names
413 SfxItemSetFixed
<XATTR_FILLGRADIENT
, XATTR_FILLGRADIENT
> aMigrateSet( mpDoc
->GetPool() );
414 aMigrateSet
.Put( XFillGradientItem("gradient", pTempGradItem
->GetGradientValue()) );
415 SdrModel::MigrateItemSet( &aMigrateSet
, &*pTempSet
, mpDoc
);
418 const XFillHatchItem
* pTempHatchItem
= pTempSet
->GetItem
<XFillHatchItem
>(XATTR_FILLHATCH
);
419 if (pTempHatchItem
&& pTempHatchItem
->GetName().isEmpty())
421 // MigrateItemSet guarantees unique hatch names
422 SfxItemSetFixed
<XATTR_FILLHATCH
, XATTR_FILLHATCH
> aMigrateSet( mpDoc
->GetPool() );
423 aMigrateSet
.Put( XFillHatchItem("hatch", pTempHatchItem
->GetHatchValue()) );
424 SdrModel::MigrateItemSet( &aMigrateSet
, &*pTempSet
, mpDoc
);
427 if( !mbMasterPage
&& bChanges
&& mbPageBckgrdDeleted
)
429 mpBackgroundObjUndoAction
.reset( new SdBackgroundObjUndoAction(
430 *mpDoc
, *mpPage
, mpPage
->getSdrPageProperties().GetItemSet()) );
432 if(!mpPage
->IsMasterPage())
434 // on normal pages, switch off fill attribute usage
435 SdrPageProperties
& rPageProperties
= mpPage
->getSdrPageProperties();
436 rPageProperties
.ClearItem( XATTR_FILLBITMAP
);
437 rPageProperties
.ClearItem( XATTR_FILLGRADIENT
);
438 rPageProperties
.ClearItem( XATTR_FILLHATCH
);
439 rPageProperties
.PutItem(XFillStyleItem(drawing::FillStyle_NONE
));
444 /* Special treatment: reset the INVALIDS to
445 NULL-Pointer (otherwise INVALIDs or pointer point
446 to DefaultItems in the template; both would
447 prevent the attribute inheritance) */
448 pTempSet
->ClearInvalidItems();
452 mpDocSh
->GetUndoManager()->AddUndoAction(std::make_unique
<StyleSheetUndoAction
>(
453 mpDoc
, static_cast<SfxStyleSheet
*>(pStyleSheet
), &(*pTempSet
)));
454 pStyleSheet
->GetItemSet().Put( *pTempSet
);
455 sdr::properties::CleanupFillProperties( pStyleSheet
->GetItemSet() );
456 pStyleSheet
->Broadcast(SfxHint(SfxHintId::DataChanged
));
459 // if background filling is set to master pages then clear from page set
462 for( sal_uInt16 nWhich
= XATTR_FILL_FIRST
; nWhich
<= XATTR_FILL_LAST
; nWhich
++ )
464 pTempSet
->ClearItem( nWhich
);
466 pTempSet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
469 if( const SvxFrameDirectionItem
* pItem
= pTempSet
->GetItemIfSet( EE_PARA_WRITINGDIR
, false ) )
471 SvxFrameDirection nVal
= pItem
->GetValue();
472 mpDoc
->SetDefaultWritingMode( nVal
== SvxFrameDirection::Horizontal_RL_TB
? css::text::WritingMode_RL_TB
: css::text::WritingMode_LR_TB
);
477 // BackgroundFill of Masterpage: no hard attributes allowed
478 SdrPage
& rUsedMasterPage
= mpPage
->IsMasterPage() ? *mpPage
: mpPage
->TRG_GetMasterPage();
479 OSL_ENSURE(rUsedMasterPage
.IsMasterPage(), "No MasterPage (!)");
480 rUsedMasterPage
.getSdrPageProperties().ClearItem();
481 OSL_ENSURE(nullptr != rUsedMasterPage
.getSdrPageProperties().GetStyleSheet(),
482 "MasterPage without StyleSheet detected (!)");
485 aNewAttr
.Put(*pTempSet
);
486 mrReq
.Done( aNewAttr
);
488 return mrReq
.GetArgs();
496 void FuPage::ApplyItemSet( const SfxItemSet
* pArgs
)
498 if (!pArgs
|| !mpDrawViewShell
)
501 // Set new page-attributes
502 PageKind ePageKind
= mpDrawViewShell
->GetPageKind();
503 const SfxPoolItem
* pPoolItem
;
504 bool bSetPageSizeAndBorder
= false;
505 Size
aNewSize(maSize
);
506 sal_Int32 nLeft
= -1, nRight
= -1, nUpper
= -1, nLower
= -1;
507 bool bScaleAll
= true;
508 Orientation eOrientation
= mpPage
->GetOrientation();
509 SdPage
* pMasterPage
= mpPage
->IsMasterPage() ? mpPage
: &static_cast<SdPage
&>(mpPage
->TRG_GetMasterPage());
510 bool bFullSize
= pMasterPage
->IsBackgroundFullSize();
511 sal_uInt16 nPaperBin
= mpPage
->GetPaperBin();
513 if( pArgs
->GetItemState(SID_ATTR_PAGE
, true, &pPoolItem
) == SfxItemState::SET
)
515 mpDoc
->SetPageNumType(static_cast<const SvxPageItem
*>(pPoolItem
)->GetNumType());
517 eOrientation
= static_cast<const SvxPageItem
*>(pPoolItem
)->IsLandscape() ?
518 Orientation::Landscape
: Orientation::Portrait
;
520 if( mpPage
->GetOrientation() != eOrientation
)
521 bSetPageSizeAndBorder
= true;
523 mpDrawViewShell
->ResetActualPage();
526 if( pArgs
->GetItemState(SID_ATTR_PAGE_SIZE
, true, &pPoolItem
) == SfxItemState::SET
)
528 aNewSize
= static_cast<const SvxSizeItem
*>(pPoolItem
)->GetSize();
530 if( mpPage
->GetSize() != aNewSize
)
531 bSetPageSizeAndBorder
= true;
534 if( pArgs
->GetItemState(mpDoc
->GetPool().GetWhich(SID_ATTR_LRSPACE
),
535 true, &pPoolItem
) == SfxItemState::SET
)
537 nLeft
= static_cast<const SvxLRSpaceItem
*>(pPoolItem
)->GetLeft();
538 nRight
= static_cast<const SvxLRSpaceItem
*>(pPoolItem
)->GetRight();
540 if( mpPage
->GetLeftBorder() != nLeft
|| mpPage
->GetRightBorder() != nRight
)
541 bSetPageSizeAndBorder
= true;
545 if( pArgs
->GetItemState(mpDoc
->GetPool().GetWhich(SID_ATTR_ULSPACE
),
546 true, &pPoolItem
) == SfxItemState::SET
)
548 nUpper
= static_cast<const SvxULSpaceItem
*>(pPoolItem
)->GetUpper();
549 nLower
= static_cast<const SvxULSpaceItem
*>(pPoolItem
)->GetLower();
551 if( mpPage
->GetUpperBorder() != nUpper
|| mpPage
->GetLowerBorder() != nLower
)
552 bSetPageSizeAndBorder
= true;
555 if( pArgs
->GetItemState(mpDoc
->GetPool().GetWhich(SID_ATTR_PAGE_EXT1
), true, &pPoolItem
) == SfxItemState::SET
)
557 bScaleAll
= static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue();
560 if (SfxItemState::SET
== pArgs
->GetItemState(SID_ATTR_CHAR_GRABBAG
, true, &pPoolItem
))
562 SfxGrabBagItem
const*const pGrabBag(static_cast<SfxGrabBagItem
const*>(pPoolItem
));
563 if (pGrabBag
->GetGrabBag().find("BackgroundFullSize")->second
>>= bFullSize
)
565 if (pMasterPage
->IsBackgroundFullSize() != bFullSize
)
567 bSetPageSizeAndBorder
= true;
571 if (mpDoc
->GetDocumentType() == DocumentType::Impress
&& mpPage
->IsMasterPage())
573 // The item set may have a theme.
574 auto it
= pGrabBag
->GetGrabBag().find("Theme");
575 if (it
!= pGrabBag
->GetGrabBag().end())
577 std::shared_ptr
<model::Theme
> pTheme
= model::Theme::FromAny(it
->second
);
578 pMasterPage
->getSdrPageProperties().SetTheme(pTheme
);
582 SAL_WARN("sd.ui", "FuPage::ApplyItemSet: got no theme");
588 if( pArgs
->GetItemState(mpDoc
->GetPool().GetWhich(SID_ATTR_PAGE_PAPERBIN
), true, &pPoolItem
) == SfxItemState::SET
)
590 nPaperBin
= static_cast<const SvxPaperBinItem
*>(pPoolItem
)->GetValue();
592 if( mpPage
->GetPaperBin() != nPaperBin
)
593 bSetPageSizeAndBorder
= true;
596 if (nLeft
== -1 && nUpper
!= -1)
598 bSetPageSizeAndBorder
= true;
599 nLeft
= mpPage
->GetLeftBorder();
600 nRight
= mpPage
->GetRightBorder();
602 else if (nLeft
!= -1 && nUpper
== -1)
604 bSetPageSizeAndBorder
= true;
605 nUpper
= mpPage
->GetUpperBorder();
606 nLower
= mpPage
->GetLowerBorder();
609 if( bSetPageSizeAndBorder
|| !mbMasterPage
)
610 mpDrawViewShell
->SetPageSizeAndBorder(ePageKind
, aNewSize
, nLeft
, nRight
, nUpper
, nLower
, bScaleAll
, eOrientation
, nPaperBin
, bFullSize
);
612 // if bMasterPage==sal_False then create a background-object for this page with the
613 // properties set in the dialog before, but if mbPageBckgrdDeleted==sal_True then
614 // the background of this page was set to invisible, so it would be a mistake
615 // to create a new background-object for this page !
617 if( mbDisplayBackgroundTabPage
)
619 if( !mbMasterPage
&& !mbPageBckgrdDeleted
)
622 mpBackgroundObjUndoAction
.reset( new SdBackgroundObjUndoAction(
623 *mpDoc
, *mpPage
, mpPage
->getSdrPageProperties().GetItemSet()) );
624 SfxItemSet
aSet( *pArgs
);
625 sdr::properties::CleanupFillProperties(aSet
);
626 mpPage
->getSdrPageProperties().ClearItem();
627 mpPage
->getSdrPageProperties().PutItemSet(aSet
);
631 // add undo action for background object
632 if( mpBackgroundObjUndoAction
)
634 // set merge flag, because a SdUndoGroupAction could have been inserted before
635 mpDocSh
->GetUndoManager()->AddUndoAction( std::move(mpBackgroundObjUndoAction
), true );
638 // Objects can not be bigger than ViewSize
639 Size aPageSize
= mpDoc
->GetSdPage(0, ePageKind
)->GetSize();
640 Size
aViewSize(aPageSize
.Width() * 3, aPageSize
.Height() * 2);
641 mpDoc
->SetMaxObjSize(aViewSize
);
643 // if necessary, we tell Preview the new context
644 mpDrawViewShell
->UpdatePreview( mpDrawViewShell
->GetActualPage() );
647 } // end of namespace sd
649 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */