1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <com/sun/star/ui/XDeck.hpp>
21 #include <com/sun/star/ui/XPanel.hpp>
22 #include <com/sun/star/frame/XController2.hpp>
23 #include "SlideBackground.hxx"
24 #include <sdresid.hxx>
25 #include <ViewShellBase.hxx>
26 #include <FrameView.hxx>
27 #include <DrawDocShell.hxx>
28 #include <drawdoc.hxx>
29 #include <sdpage.hxx>
30 #include <sdmod.hxx>
31 #include <optsitem.hxx>
32 #include "PageMarginUtils.hxx"
33 #include <strings.hrc>
34 #include <pageformatpanel.hrc>
35 #include <DrawViewShell.hxx>
36 #include <svx/colorbox.hxx>
37 #include <svx/drawitem.hxx>
38 #include <svx/pageitem.hxx>
39 #include <tools/urlobj.hxx>
40 #include <app.hrc>
41 #include <editeng/paperinf.hxx>
42 #include <svx/xflgrit.hxx>
43 #include <svx/rulritem.hxx>
44 #include <svx/svxids.hrc>
45 #include <svx/xfillit0.hxx>
46 #include <svx/xflclit.hxx>
47 #include <svx/xgrad.hxx>
48 #include <svx/xbtmpit.hxx>
49 #include <svx/xflhtit.hxx>
50 #include <svx/svdpage.hxx>
51 #include <sfx2/bindings.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <sfx2/sidebar/Panel.hxx>
54 #include <EventMultiplexer.hxx>
55 #include <unotools/localedatawrapper.hxx>
56 #include <vcl/EnumContext.hxx>
57 
58 #include <editeng/sizeitem.hxx>
59 #include <comphelper/lok.hxx>
60 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
61 #include <unomodel.hxx>
62 #include <sfx2/lokhelper.hxx>
63 #include <boost/property_tree/ptree.hpp>
64 
65 using namespace ::com::sun::star;
66 
67 using ::com::sun::star::uno::Reference;
68 
69 namespace sd { namespace sidebar {
70 
71 enum eFillStyle
72 {
73     NONE,
74     SOLID,
75     GRADIENT,
76     HATCH,
77     BITMAP,
78     PATTERN
79 };
80 
SlideBackground(Window * pParent,ViewShellBase & rBase,const css::uno::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)81 SlideBackground::SlideBackground(
82     Window * pParent,
83     ViewShellBase& rBase,
84     const css::uno::Reference<css::frame::XFrame>& rxFrame,
85     SfxBindings* pBindings
86      ) :
87     PanelLayout( pParent, "SlideBackgroundPanel", "modules/simpress/ui/sidebarslidebackground.ui", rxFrame ),
88     mrBase( rBase ),
89     maPaperSizeController(SID_ATTR_PAGE_SIZE, *pBindings, *this),
90     maPaperOrientationController(SID_ATTR_PAGE, *pBindings, *this),
91     maPaperMarginLRController(SID_ATTR_PAGE_LRSPACE, *pBindings, *this),
92     maPaperMarginULController(SID_ATTR_PAGE_ULSPACE, *pBindings, *this),
93     maBckColorController(SID_ATTR_PAGE_COLOR, *pBindings, *this),
94     maBckGradientController(SID_ATTR_PAGE_GRADIENT, *pBindings, *this),
95     maBckHatchController(SID_ATTR_PAGE_HATCH, *pBindings, *this),
96     maBckBitmapController(SID_ATTR_PAGE_BITMAP, *pBindings, *this),
97     maBckFillStyleController(SID_ATTR_PAGE_FILLSTYLE, *pBindings, *this),
98     maBckImageController(SID_SELECT_BACKGROUND, *pBindings, *this),
99     maDspBckController(SID_DISPLAY_MASTER_BACKGROUND, *pBindings, *this),
100     maDspObjController(SID_DISPLAY_MASTER_OBJECTS, *pBindings, *this),
101     maMetricController(SID_ATTR_METRIC, *pBindings, *this),
102     maCloseMasterController(SID_CLOSE_MASTER_VIEW, *pBindings, *this),
103     mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ),
104     mpColorItem(),
105     mpGradientItem(),
106     mpHatchItem(),
107     mpBitmapItem(),
108     mbSwitchModeToNormal(false),
109     mbSwitchModeToMaster(false),
110     mxFrame(rxFrame),
111     maContext(),
112     maDrawOtherContext(vcl::EnumContext::Application::Draw, vcl::EnumContext::Context::DrawPage),
113     maDrawMasterContext(vcl::EnumContext::Application::Draw, vcl::EnumContext::Context::MasterPage),
114     maImpressOtherContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::DrawPage),
115     maImpressMasterContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::MasterPage),
116     maImpressHandoutContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::HandoutPage),
117     maImpressNotesContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::NotesPage),
118     mbTitle(false),
119     mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) ),
120     mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) ),
121     m_nPageLeftMargin(0),
122     m_nPageRightMargin(0),
123     m_nPageTopMargin(0),
124     m_nPageBottomMargin(0),
125     meFUnit(GetModuleFieldUnit()),
126     maCustomEntry(),
127     mpBindings(pBindings)
128 {
129     get(mpPaperSizeBox,"paperformat");
130     get(mpPaperOrientation, "orientation");
131     get(mpMasterSlide, "masterslide");
132     //let the listbox shrink to any size so the sidebar isn't forced to grow to
133     //the size of the longest master slide name in the document
134     mpMasterSlide->set_width_request(0);
135     get(mpBackgroundLabel, "label3");
136     get(mpFillAttr, "fillattr1");
137     get(mpFillGrad, "fillattr2");
138     get(mpFillStyle, "fillstyle");
139     get(mpFillLB, "fillattr");
140     get(mpInsertImage, "button2");
141     get(mpDspMasterBackground, "displaymasterbackground");
142     get(mpDspMasterObjects, "displaymasterobjects");
143     get(mpCloseMaster, "closemasterslide");
144     get(mpEditMaster, "masterslidebutton");
145     get(mpMasterLabel, "masterlabel");
146     get(mpMarginSelectBox, "marginLB");
147 
148     maCustomEntry = get<FixedText>("customlabel")->GetText();
149 
150     addListener();
151     Initialize();
152 }
153 
~SlideBackground()154 SlideBackground::~SlideBackground()
155 {
156     disposeOnce();
157 }
158 
IsDraw()159 bool SlideBackground::IsDraw()
160 {
161     return ( maContext == maDrawMasterContext ||
162              maContext == maDrawOtherContext );
163 }
164 
IsImpress()165 bool SlideBackground::IsImpress()
166 {
167     return ( maContext == maImpressMasterContext ||
168              maContext == maImpressOtherContext ||
169              maContext == maImpressHandoutContext ||
170              maContext == maImpressNotesContext );
171 }
172 
GetCurrentUnit(SfxItemState eState,const SfxPoolItem * pState)173 FieldUnit SlideBackground::GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState)
174 {
175     FieldUnit eUnit;
176 
177     if (pState && eState >= SfxItemState::DEFAULT)
178         eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pState)->GetValue());
179     else
180         eUnit = GetModuleFieldUnit();
181 
182     return eUnit;
183 }
184 
SetMarginsFieldUnit()185 void SlideBackground::SetMarginsFieldUnit()
186 {
187     auto nSelected = mpMarginSelectBox->GetSelectedEntryPos();
188     mpMarginSelectBox->Clear();
189 
190     const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper();
191 
192     if (IsInch(meFUnit))
193     {
194         OUString sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
195         for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i)
196         {
197             OUString sMeasurement = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_INCH[i].second, 2, true, false) + sSuffix;
198             mpMarginSelectBox->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i].first).replaceFirst("%1", sMeasurement));
199         }
200     }
201     else
202     {
203         OUString sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
204         for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i)
205         {
206             OUString sMeasurement = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_CM[i].second, 2, true, false) + sSuffix;
207             mpMarginSelectBox->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_CM[i].first).replaceFirst("%1", sMeasurement));
208         }
209     }
210 
211     mpMarginSelectBox->SelectEntryPos(nSelected);
212 }
213 
Initialize()214 void SlideBackground::Initialize()
215 {
216     SetMarginsFieldUnit();
217 
218     mpPaperSizeBox->FillPaperSizeEntries( PaperSizeApp::Draw );
219     mpPaperSizeBox->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl));
220     mpPaperOrientation->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl));
221     mpCloseMaster->SetClickHdl(LINK(this, SlideBackground, CloseMasterHdl));
222     meUnit = maPaperSizeController.GetCoreMetric();
223 
224     mpMasterSlide->SetSelectHdl(LINK(this, SlideBackground, AssignMasterPage));
225 
226     mpFillStyle->SetSelectHdl(LINK(this, SlideBackground, FillStyleModifyHdl));
227     mpFillLB->SetSelectHdl(LINK(this, SlideBackground, FillColorHdl));
228     mpFillGrad->SetSelectHdl(LINK(this, SlideBackground, FillColorHdl));
229     mpFillAttr->SetSelectHdl(LINK(this, SlideBackground, FillBackgroundHdl));
230 
231     ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
232     if (pMainViewShell)
233     {
234         FrameView *pFrameView = pMainViewShell->GetFrameView();
235 
236         if ( pFrameView->GetViewShEditMode() ==  EditMode::Page )
237         {
238             SdPage* mpPage = pMainViewShell->getCurrentPage();
239             populateMasterSlideDropdown();
240 
241             OUString aLayoutName( mpPage->GetLayoutName() );
242             aLayoutName = aLayoutName.copy(0,aLayoutName.indexOf(SD_LT_SEPARATOR));
243             mpMasterSlide->SelectEntry(aLayoutName);
244         }
245     }
246 
247     mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(NONE));
248 
249     mpDspMasterBackground->SetClickHdl(LINK(this, SlideBackground, DspBackground));
250     mpDspMasterObjects->SetClickHdl(LINK(this,SlideBackground, DspObjects));
251 
252     //margins
253     mpMarginSelectBox->SetSelectHdl(LINK(this, SlideBackground,ModifyMarginHdl));
254 
255     Update();
256     UpdateMarginBox();
257 }
258 
DumpAsPropertyTree()259 boost::property_tree::ptree SlideBackground::DumpAsPropertyTree()
260 {
261     if (mpPaperSizeBox->GetSelectedEntryCount() == 0)
262     {
263         mpBindings->Update(SID_ATTR_PAGE_SIZE);
264     }
265 
266     return Control::DumpAsPropertyTree();
267 }
268 
HandleContextChange(const vcl::EnumContext & rContext)269 void SlideBackground::HandleContextChange(
270     const vcl::EnumContext& rContext)
271 {
272     if (maContext == rContext)
273         return;
274     maContext = rContext;
275 
276     if ( IsImpress() )
277     {
278         mpMasterLabel->SetText(SdResId(STR_MASTERSLIDE_LABEL));
279 
280         // margin selector is only for Draw
281         mpMarginSelectBox->Hide();
282         VclPtr<FixedText> pMarginLabel;
283         get(pMarginLabel, "labelmargin");
284         if ( pMarginLabel )
285             pMarginLabel->Hide();
286 
287         if ( maContext == maImpressMasterContext )
288         {
289             mpCloseMaster->Show();
290             mpEditMaster->Hide();
291             mpMasterSlide->Disable();
292             mpDspMasterBackground->Disable();
293             mpDspMasterObjects->Disable();
294             mpFillStyle->Hide();
295             mpBackgroundLabel->Hide();
296             mpInsertImage->Show();
297         }
298         else if ( maContext == maImpressHandoutContext  || maContext == maImpressNotesContext )
299         {
300             mpCloseMaster->Hide();
301             mpEditMaster->Hide();
302             mpMasterSlide->Disable();
303             mpDspMasterBackground->Disable();
304             mpDspMasterObjects->Disable();
305             mpFillStyle->Hide();
306             mpBackgroundLabel->Hide();
307             mpInsertImage->Hide();
308         }
309         else if (maContext == maImpressOtherContext)
310         {
311             mpCloseMaster->Hide();
312             mpEditMaster->Show();
313             mpMasterSlide->Enable();
314             mpDspMasterBackground->Enable();
315             mpDspMasterObjects->Enable();
316             mpFillStyle->Show();
317             mpBackgroundLabel->Show();
318             mpInsertImage->Show();
319         }
320 
321         // The Insert Image button in the sidebar issues .uno:SelectBackground,
322         // which when invoked without arguments will open the file-open-dialog
323         // to prompt the user to select a file. This is useless in LOOL.
324         // Hide for now so the user will only be able to use the menu to insert
325         // background image, which prompts the user for file selection in the browser.
326         if (comphelper::LibreOfficeKit::isActive())
327             mpInsertImage->Hide();
328 
329         // Need to do a relayouting, otherwise the panel size is not updated after show / hide controls
330         sfx2::sidebar::Panel* pPanel = dynamic_cast<sfx2::sidebar::Panel*>(GetParent());
331         if(pPanel)
332             pPanel->TriggerDeckLayouting();
333     }
334     else if ( IsDraw() )
335     {
336         mpMasterLabel->SetText(SdResId(STR_MASTERPAGE_LABEL));
337 
338         if (maContext == maDrawOtherContext)
339         {
340             mpEditMaster->Hide();
341             mpFillStyle->Show();
342             mpBackgroundLabel->Show();
343         }
344         else if (maContext == maDrawMasterContext)
345         {
346             mpFillStyle->Hide();
347             mpBackgroundLabel->Hide();
348         }
349     }
350 }
351 
Update()352 void SlideBackground::Update()
353 {
354     eFillStyle nPos = static_cast<eFillStyle>(mpFillStyle->GetSelectedEntryPos());
355 
356     if(maContext != maImpressOtherContext && maContext != maDrawOtherContext)
357         nPos = NONE;
358 
359     SfxObjectShell* pSh = SfxObjectShell::Current();
360     if (!pSh)
361         return;
362 
363     switch(nPos)
364     {
365         case NONE:
366         {
367             mpFillLB->Hide();
368             mpFillAttr->Hide();
369             mpFillGrad->Hide();
370         }
371         break;
372         case SOLID:
373         {
374             mpFillAttr->Hide();
375             mpFillGrad->Hide();
376             mpFillLB->Show();
377             const Color aColor = GetColorSetOrDefault();
378             mpFillLB->SelectEntry(aColor);
379         }
380         break;
381         case GRADIENT:
382         {
383             mpFillLB->Show();
384             mpFillAttr->Hide();
385             mpFillGrad->Show();
386 
387             const XGradient xGradient = GetGradientSetOrDefault();
388             const Color aStartColor = xGradient.GetStartColor();
389             mpFillLB->SelectEntry(aStartColor);
390             const Color aEndColor = xGradient.GetEndColor();
391             mpFillGrad->SelectEntry(aEndColor);
392         }
393         break;
394 
395         case HATCH:
396         {
397             mpFillLB->Hide();
398             mpFillAttr->Show();
399             mpFillAttr->Clear();
400             mpFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList());
401             mpFillGrad->Hide();
402 
403             const OUString aHatchName = GetHatchingSetOrDefault();
404             mpFillAttr->SelectEntry( aHatchName );
405         }
406         break;
407 
408         case BITMAP:
409         case PATTERN:
410         {
411             mpFillLB->Hide();
412             mpFillAttr->Show();
413             mpFillAttr->Clear();
414             mpFillGrad->Hide();
415             OUString aName;
416             if(nPos == BITMAP)
417             {
418                 mpFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList());
419                 aName = GetBitmapSetOrDefault();
420             }
421             else if(nPos == PATTERN)
422             {
423                 mpFillAttr->Fill(pSh->GetItem(SID_PATTERN_LIST)->GetPatternList());
424                 aName = GetPatternSetOrDefault();
425             }
426             mpFillAttr->SelectEntry( aName );
427         }
428         break;
429         default:
430             break;
431     }
432 }
433 
UpdateMarginBox()434 void SlideBackground::UpdateMarginBox()
435 {
436     m_nPageLeftMargin = mpPageLRMarginItem->GetLeft();
437     m_nPageRightMargin = mpPageLRMarginItem->GetRight();
438     m_nPageTopMargin = mpPageULMarginItem->GetUpper();
439     m_nPageBottomMargin = mpPageULMarginItem->GetLower();
440 
441     if( IsNone(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
442     {
443         mpMarginSelectBox->SelectEntryPos(0);
444         mpMarginSelectBox->RemoveEntry(maCustomEntry);
445     }
446     else if( IsNarrow(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
447     {
448         mpMarginSelectBox->SelectEntryPos(1);
449         mpMarginSelectBox->RemoveEntry(maCustomEntry);
450     }
451     else if( IsModerate(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
452     {
453         mpMarginSelectBox->SelectEntryPos(2);
454         mpMarginSelectBox->RemoveEntry(maCustomEntry);
455     }
456     else if( IsNormal075(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
457     {
458         mpMarginSelectBox->SelectEntryPos(3);
459         mpMarginSelectBox->RemoveEntry(maCustomEntry);
460     }
461     else if( IsNormal100(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
462     {
463         mpMarginSelectBox->SelectEntryPos(4);
464         mpMarginSelectBox->RemoveEntry(maCustomEntry);
465     }
466     else if( IsNormal125(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
467     {
468         mpMarginSelectBox->SelectEntryPos(5);
469         mpMarginSelectBox->RemoveEntry(maCustomEntry);
470     }
471     else if( IsWide(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
472     {
473         mpMarginSelectBox->SelectEntryPos(6);
474         mpMarginSelectBox->RemoveEntry(maCustomEntry);
475     }
476     else
477     {
478         if(mpMarginSelectBox->GetEntryPos(maCustomEntry) == LISTBOX_ENTRY_NOTFOUND)
479             mpMarginSelectBox->InsertEntry(maCustomEntry);
480         mpMarginSelectBox->SelectEntry(maCustomEntry);
481     }
482 }
483 
SetPanelTitle(const OUString & rTitle)484 void SlideBackground::SetPanelTitle( const OUString& rTitle )
485 {
486     Reference<frame::XController2> xController( mxFrame->getController(), uno::UNO_QUERY);
487     if ( !xController.is() )
488         return;
489 
490     Reference<ui::XSidebarProvider> xSidebarProvider = xController->getSidebar();
491     if ( !xSidebarProvider.is() )
492         return;
493 
494     Reference<ui::XDecks> xDecks = xSidebarProvider->getDecks();
495     if ( !xDecks.is() )
496         return;
497 
498     Reference<ui::XDeck> xDeck ( xDecks->getByName("PropertyDeck"), uno::UNO_QUERY);
499     if ( !xDeck.is() )
500         return;
501 
502     Reference<ui::XPanels> xPanels = xDeck->getPanels();
503     if ( !xPanels.is() )
504         return;
505 
506     if (xPanels->hasByName("SlideBackgroundPanel"))
507     {
508         Reference<ui::XPanel> xPanel ( xPanels->getByName("SlideBackgroundPanel"), uno::UNO_QUERY);
509         if ( !xPanel.is() )
510             return;
511 
512         xPanel->setTitle( rTitle );
513     }
514 }
515 
addListener()516 void SlideBackground::addListener()
517 {
518     Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this, SlideBackground, EventMultiplexerListener) );
519     mrBase.GetEventMultiplexer()->AddEventListener( aLink );
520 }
521 
removeListener()522 void SlideBackground::removeListener()
523 {
524     Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this, SlideBackground, EventMultiplexerListener) );
525     mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
526 }
527 
IMPL_LINK(SlideBackground,EventMultiplexerListener,tools::EventMultiplexerEvent &,rEvent,void)528 IMPL_LINK(SlideBackground, EventMultiplexerListener,
529                 tools::EventMultiplexerEvent&, rEvent, void)
530 {
531     switch (rEvent.meEventId)
532     {
533         // add more events as per requirement
534         // Master Page change triggers a shape change event. Solves sync problem.
535         case EventMultiplexerEventId::ShapeChanged:
536             populateMasterSlideDropdown();
537             break;
538         case EventMultiplexerEventId::EditModeNormal:
539             mbSwitchModeToNormal = true;
540             break;
541         case EventMultiplexerEventId::EditModeMaster:
542             mbSwitchModeToMaster = true;
543             break;
544         case EventMultiplexerEventId::EditViewSelection:
545         case EventMultiplexerEventId::EndTextEdit:
546         {
547             if ( mbSwitchModeToMaster )
548             {
549                 if( IsImpress() )
550                     SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME));
551                 else
552                     SetPanelTitle(SdResId(STR_MASTERPAGE_NAME));
553                 mbSwitchModeToMaster = false;
554             }
555             else if ( mbSwitchModeToNormal )
556             {
557                 if( IsImpress() )
558                     SetPanelTitle(SdResId(STR_SLIDE_NAME));
559                 else
560                     SetPanelTitle(SdResId(STR_PAGE_NAME));
561                 mbSwitchModeToNormal = false;
562             }
563 
564         }
565         break;
566         case EventMultiplexerEventId::CurrentPageChanged:
567         {
568             static const sal_uInt16 SidArray[] = {
569                 SID_ATTR_PAGE_COLOR,
570                 SID_ATTR_PAGE_GRADIENT,
571                 SID_ATTR_PAGE_HATCH,
572                 SID_ATTR_PAGE_BITMAP,
573                 SID_ATTR_PAGE_FILLSTYLE,
574                 SID_DISPLAY_MASTER_BACKGROUND,
575                 SID_DISPLAY_MASTER_OBJECTS,
576                 0 };
577             updateMasterSlideSelection();
578             GetBindings()->Invalidate( SidArray );
579         }
580         break;
581         case EventMultiplexerEventId::ViewAdded:
582         {
583             if(!mbTitle)
584             {
585                 if( IsDraw() )
586                 {
587                     mpCloseMaster->Hide();
588                     mpEditMaster->Hide();
589                     if( maContext == maDrawMasterContext)
590                         SetPanelTitle(SdResId(STR_MASTERPAGE_NAME));
591                     else
592                         SetPanelTitle(SdResId(STR_PAGE_NAME));
593                 }
594                 else if ( maContext == maImpressOtherContext || maContext == maImpressMasterContext )
595                 {
596                     if( maContext == maImpressMasterContext )
597                         SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME));
598                     else
599                         SetPanelTitle(SdResId(STR_SLIDE_NAME));
600                 }
601                 else if ( maContext == maImpressNotesContext )
602                 {
603                     mpMasterLabel->SetText(SdResId(STR_MASTERSLIDE_LABEL));
604                     ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
605 
606                     if (pMainViewShell)
607                     {
608                         DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
609                         if ( pDrawViewShell->GetEditMode() == EditMode::MasterPage)
610                             SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME));
611                         else // EditMode::Page
612                             SetPanelTitle(SdResId(STR_SLIDE_NAME));
613                     }
614                 }
615                 mbTitle = true;
616             }
617         }
618         break;
619         default:
620             break;
621     }
622 }
623 
populateMasterSlideDropdown()624 void SlideBackground::populateMasterSlideDropdown()
625 {
626     mpMasterSlide->Clear();
627     ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() );
628     SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr;
629     sal_uInt16 nCount = pDoc ? pDoc->GetMasterPageCount() : 0;
630     for( sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++ )
631     {
632         SdPage* pMaster = static_cast<SdPage*>(pDoc->GetMasterPage(nLayout));
633         if( pMaster->GetPageKind() == PageKind::Standard)
634         {
635             OUString aLayoutName(pMaster->GetLayoutName());
636             aLayoutName = aLayoutName.copy(0,aLayoutName.indexOf(SD_LT_SEPARATOR));
637             mpMasterSlide->InsertEntry(aLayoutName);
638         }
639     }
640     updateMasterSlideSelection();
641 }
642 
updateMasterSlideSelection()643 void SlideBackground::updateMasterSlideSelection()
644 {
645     ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
646     SdPage* pPage = pMainViewShell ? pMainViewShell->getCurrentPage() : nullptr;
647     if (pPage != nullptr && pPage->TRG_HasMasterPage())
648     {
649         SdrPage& rMasterPage (pPage->TRG_GetMasterPage());
650         SdPage* pMasterPage = static_cast<SdPage*>(&rMasterPage);
651         mpMasterSlide->SelectEntry(pMasterPage->GetName());
652     }
653 }
654 
dispose()655 void SlideBackground::dispose()
656 {
657     removeListener();
658 
659     mpPaperSizeBox.clear();
660     mpPaperOrientation.clear();
661     mpMasterSlide.clear();
662     mpBackgroundLabel.clear();
663     mpFillAttr.clear();
664     mpFillGrad.clear();
665     mpFillStyle.clear();
666     mpFillLB.clear();
667     mpInsertImage.clear();
668     mpMarginSelectBox.disposeAndClear();
669     mpDspMasterBackground.clear();
670     mpDspMasterObjects.clear();
671     mpMasterLabel.clear();
672     mpEditMaster.clear();
673     mpCloseMaster.clear();
674 
675     m_pContainer.clear();
676 
677     maPaperSizeController.dispose();
678     maPaperOrientationController.dispose();
679     maPaperMarginLRController.dispose();
680     maPaperMarginULController.dispose();
681     maBckColorController.dispose();
682     maBckGradientController.dispose();
683     maBckHatchController.dispose();
684     maBckBitmapController.dispose();
685     maBckFillStyleController.dispose();
686     maBckImageController.dispose();
687     maDspBckController.dispose();
688     maDspObjController.dispose();
689     maMetricController.dispose();
690     maCloseMasterController.dispose();
691 
692     mpPageItem.reset();
693     mpColorItem.reset();
694     mpHatchItem.reset();
695     mpBitmapItem.reset();
696     mpPageLRMarginItem.reset();
697     mpPageULMarginItem.reset();
698     PanelLayout::dispose();
699 }
700 
ExecuteMarginLRChange(const long mnPageLeftMargin,const long mnPageRightMargin)701 void SlideBackground::ExecuteMarginLRChange(const long mnPageLeftMargin, const long mnPageRightMargin)
702 {
703     mpPageLRMarginItem->SetLeft(mnPageLeftMargin);
704     mpPageLRMarginItem->SetRight(mnPageRightMargin);
705     GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE, SfxCallMode::RECORD, { mpPageLRMarginItem.get() } );
706 }
707 
ExecuteMarginULChange(const long mnPageTopMargin,const long mnPageBottomMargin)708 void SlideBackground::ExecuteMarginULChange(const long mnPageTopMargin, const long mnPageBottomMargin)
709 {
710     mpPageULMarginItem->SetUpper(mnPageTopMargin);
711     mpPageULMarginItem->SetLower(mnPageBottomMargin);
712     GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE, SfxCallMode::RECORD, { mpPageULMarginItem.get() } );
713 }
714 
GetColorSetOrDefault()715 Color const & SlideBackground::GetColorSetOrDefault()
716 {
717    // Tango Sky Blue 1, to be consistent w/ area fill panel (b/c COL_AUTO for slides is transparent)
718    if ( !mpColorItem )
719         mpColorItem.reset( new XFillColorItem( OUString(), Color(0x72, 0x9f, 0xcf) ) );
720 
721    return mpColorItem->GetColorValue();
722 }
723 
GetGradientSetOrDefault()724 XGradient const & SlideBackground::GetGradientSetOrDefault()
725 {
726     if( !mpGradientItem )
727     {
728         SfxObjectShell* pSh = SfxObjectShell::Current();
729         const SvxGradientListItem * pGradListItem = pSh->GetItem(SID_GRADIENT_LIST);
730         const XGradient aGradient = pGradListItem->GetGradientList()->GetGradient(0)->GetGradient();
731         const OUString aGradientName = pGradListItem->GetGradientList()->GetGradient(0)->GetName();
732 
733         mpGradientItem.reset( new XFillGradientItem( aGradientName, aGradient ) );
734     }
735 
736     return mpGradientItem->GetGradientValue();
737 }
738 
GetHatchingSetOrDefault()739 OUString const & SlideBackground::GetHatchingSetOrDefault()
740 {
741     if( !mpHatchItem )
742     {
743         SfxObjectShell* pSh = SfxObjectShell::Current();
744         const SvxHatchListItem * pHatchListItem = pSh->GetItem(SID_HATCH_LIST);
745         const XHatch aHatch = pHatchListItem->GetHatchList()->GetHatch(0)->GetHatch();
746         const OUString aHatchName = pHatchListItem->GetHatchList()->GetHatch(0)->GetName();
747 
748         mpHatchItem.reset( new XFillHatchItem( aHatchName, aHatch ) );
749     }
750 
751     return mpHatchItem->GetName();
752 }
753 
GetBitmapSetOrDefault()754 OUString const & SlideBackground::GetBitmapSetOrDefault()
755 {
756     if( !mpBitmapItem || mpBitmapItem->isPattern())
757     {
758         SfxObjectShell* pSh = SfxObjectShell::Current();
759         const SvxBitmapListItem * pBmpListItem = pSh->GetItem(SID_BITMAP_LIST);
760         const GraphicObject aGraphObj = pBmpListItem->GetBitmapList()->GetBitmap(0)->GetGraphicObject();
761         const OUString aBmpName = pBmpListItem->GetBitmapList()->GetBitmap(0)->GetName();
762 
763         mpBitmapItem.reset( new XFillBitmapItem( aBmpName, aGraphObj ) );
764     }
765 
766     return mpBitmapItem->GetName();
767 }
768 
GetPatternSetOrDefault()769 OUString const & SlideBackground::GetPatternSetOrDefault()
770 {
771     if( !mpBitmapItem || !(mpBitmapItem->isPattern()))
772     {
773         SfxObjectShell* pSh = SfxObjectShell::Current();
774         const SvxPatternListItem * pPtrnListItem = pSh->GetItem(SID_PATTERN_LIST);
775         const GraphicObject aGraphObj = pPtrnListItem->GetPatternList()->GetBitmap(0)->GetGraphicObject();
776         const OUString aPtrnName = pPtrnListItem->GetPatternList()->GetBitmap(0)->GetName();
777 
778         mpBitmapItem.reset( new XFillBitmapItem( aPtrnName, aGraphObj ) );
779     }
780 
781     return mpBitmapItem->GetName();
782 }
783 
DataChanged(const DataChangedEvent &)784 void SlideBackground::DataChanged (const DataChangedEvent& /*rEvent*/)
785 {
786 
787 }
788 
NotifyItemUpdate(const sal_uInt16 nSID,const SfxItemState eState,const SfxPoolItem * pState)789 void SlideBackground::NotifyItemUpdate(
790     const sal_uInt16 nSID,
791     const SfxItemState eState,
792     const SfxPoolItem* pState)
793 {
794     switch(nSID)
795     {
796 
797         case SID_ATTR_PAGE_COLOR:
798         {
799             if(eState >= SfxItemState::DEFAULT)
800             {
801                 mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(SOLID));
802                 mpColorItem.reset(pState ? static_cast< XFillColorItem* >(pState->Clone()) : nullptr);
803                 Update();
804             }
805         }
806         break;
807 
808         case SID_ATTR_PAGE_HATCH:
809         {
810             if(eState >= SfxItemState::DEFAULT)
811             {
812                 mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(HATCH));
813                 mpHatchItem.reset(pState ? static_cast < XFillHatchItem* >(pState->Clone()) : nullptr);
814                 Update();
815             }
816         }
817         break;
818 
819         case SID_ATTR_PAGE_GRADIENT:
820         {
821             if(eState >= SfxItemState::DEFAULT)
822             {
823                 mpFillStyle->SelectEntryPos(static_cast< sal_Int32>(GRADIENT));
824                 mpGradientItem.reset(pState ? static_cast< XFillGradientItem* >(pState->Clone()) : nullptr);
825                 Update();
826             }
827         }
828         break;
829         case SID_ATTR_PAGE_BITMAP:
830         {
831             if(eState >= SfxItemState::DEFAULT)
832             {
833                 mpBitmapItem.reset(pState ? static_cast< XFillBitmapItem* >(pState->Clone()) : nullptr);
834                 if(mpBitmapItem)
835                 {
836                     if(mpBitmapItem->isPattern())
837                         mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(PATTERN));
838                     else
839                         mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(BITMAP));
840                 }
841                 else
842                     mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(BITMAP));
843                 Update();
844             }
845         }
846         break;
847 
848         case SID_ATTR_PAGE_FILLSTYLE:
849         {
850             const XFillStyleItem* pFillStyleItem = nullptr;
851             if (eState >= SfxItemState::DEFAULT)
852                 pFillStyleItem = dynamic_cast< const XFillStyleItem* >(pState);
853             if (pFillStyleItem)
854             {
855                 css::drawing::FillStyle eXFS = pFillStyleItem->GetValue();
856                 switch(eXFS)
857                 {
858                     case drawing::FillStyle_NONE:
859                         mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(NONE));
860                         break;
861                     case drawing::FillStyle_SOLID:
862                         mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(SOLID));
863                         break;
864                     case drawing::FillStyle_GRADIENT:
865                         mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(GRADIENT));
866                         break;
867                     case drawing::FillStyle_HATCH:
868                         mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(HATCH));
869                         break;
870                     case drawing::FillStyle_BITMAP:
871                     {
872                         if(mpBitmapItem->isPattern())
873                             mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(PATTERN));
874                         else
875                             mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(BITMAP));
876                     }
877                     break;
878                     default:
879                         break;
880                 }
881                 Update();
882             }
883         }
884         break;
885 
886         case SID_ATTR_PAGE_SIZE:
887         {
888             const SvxSizeItem* pSizeItem = nullptr;
889             if (eState >= SfxItemState::DEFAULT)
890                 pSizeItem = dynamic_cast<const SvxSizeItem*>(pState);
891             if (pSizeItem)
892             {
893                 Size aPaperSize = pSizeItem->GetSize();
894                 if (mpPaperOrientation->GetSelectedEntryPos() == 0)
895                    Swap(aPaperSize);
896 
897                 Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, meUnit);
898                 mpPaperSizeBox->SetSelection( ePaper );
899             }
900         }
901         break;
902 
903         case SID_ATTR_PAGE:
904         {
905             const SvxPageItem* pPageItem = nullptr;
906             if (eState >= SfxItemState::DEFAULT)
907                 pPageItem = dynamic_cast<const SvxPageItem*>(pState);
908             if (pPageItem)
909             {
910                 mpPageItem.reset(static_cast<SvxPageItem*>(pPageItem->Clone()));
911                 bool bIsLandscape = mpPageItem->IsLandscape();
912                 mpPaperOrientation->SelectEntryPos( bIsLandscape ? 0 : 1 );
913             }
914         }
915         break;
916 
917         case SID_ATTR_PAGE_LRSPACE:
918         {
919             const SvxLongLRSpaceItem* pLRItem = nullptr;
920             if (eState >= SfxItemState::DEFAULT)
921                 pLRItem = dynamic_cast<const SvxLongLRSpaceItem*>(pState);
922             if (pLRItem)
923             {
924                 mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) );
925                 UpdateMarginBox();
926             }
927         }
928         break;
929 
930         case SID_ATTR_PAGE_ULSPACE:
931         {
932             const SvxLongULSpaceItem* pULItem = nullptr;
933             if (eState >= SfxItemState::DEFAULT)
934                 pULItem = dynamic_cast<const SvxLongULSpaceItem*>(pState);
935             if (pULItem)
936             {
937                 mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pState->Clone()) );
938                 UpdateMarginBox();
939             }
940         }
941         break;
942 
943         case SID_DISPLAY_MASTER_BACKGROUND:
944         {
945             const SfxBoolItem* pBoolItem = nullptr;
946             if (eState >= SfxItemState::DEFAULT)
947                 pBoolItem = dynamic_cast< const SfxBoolItem* >(pState);
948             if (pBoolItem)
949                 mpDspMasterBackground->Check(pBoolItem->GetValue());
950         }
951         break;
952         case SID_DISPLAY_MASTER_OBJECTS:
953         {
954             const SfxBoolItem* pBoolItem = nullptr;
955             if (eState >= SfxItemState::DEFAULT)
956                 pBoolItem = dynamic_cast< const SfxBoolItem* >(pState);
957             if (pBoolItem)
958                 mpDspMasterObjects->Check(pBoolItem->GetValue());
959         }
960         break;
961         case SID_SELECT_BACKGROUND:
962         {
963             if(eState >= SfxItemState::DEFAULT)
964             {
965                 mpFillStyle->SelectEntryPos(static_cast< sal_Int32 >(BITMAP));
966                 Update();
967             }
968         }
969         break;
970         case SID_ATTR_METRIC:
971         {
972             FieldUnit eFUnit = GetCurrentUnit(eState, pState);
973             if (meFUnit != eFUnit)
974             {
975                 meFUnit = eFUnit;
976                 SetMarginsFieldUnit();
977                 UpdateMarginBox();
978             }
979         }
980         break;
981         default:
982             break;
983     }
984 }
985 
IMPL_LINK_NOARG(SlideBackground,FillStyleModifyHdl,ListBox &,void)986 IMPL_LINK_NOARG(SlideBackground, FillStyleModifyHdl, ListBox&, void)
987 {
988     const eFillStyle nPos = static_cast<eFillStyle>(mpFillStyle->GetSelectedEntryPos());
989     Update();
990 
991     switch (nPos)
992     {
993         case NONE:
994         {
995             const XFillStyleItem aXFillStyleItem(drawing::FillStyle_NONE);
996             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_FILLSTYLE, SfxCallMode::RECORD, { &aXFillStyleItem });
997         }
998         break;
999 
1000         case SOLID:
1001         {
1002             const XFillColorItem aItem( OUString(), mpColorItem->GetColorValue() );
1003             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, SfxCallMode::RECORD, { &aItem });
1004         }
1005         break;
1006 
1007         case GRADIENT:
1008         {
1009             const XFillGradientItem aItem( mpGradientItem->GetName(), mpGradientItem->GetGradientValue() );
1010             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, SfxCallMode::RECORD, { &aItem });
1011         }
1012         break;
1013 
1014         case HATCH:
1015         {
1016             const XFillHatchItem aItem( mpHatchItem->GetName(), mpHatchItem->GetHatchValue() );
1017             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, SfxCallMode::RECORD, { &aItem });
1018         }
1019         break;
1020 
1021         case BITMAP:
1022         case PATTERN:
1023         {
1024             const XFillBitmapItem aItem( mpBitmapItem->GetName(), mpBitmapItem->GetGraphicObject() );
1025             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, SfxCallMode::RECORD, { &aItem });
1026         }
1027         break;
1028 
1029         default:
1030         break;
1031     }
1032     mpFillStyle->Selected();
1033 }
1034 
IMPL_LINK_NOARG(SlideBackground,PaperSizeModifyHdl,ListBox &,void)1035 IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, ListBox&, void)
1036 {
1037     const Paper ePaper = mpPaperSizeBox->GetSelection();
1038     Size aSize(SvxPaperInfo::GetPaperSize(ePaper, meUnit));
1039 
1040     if (mpPaperOrientation->GetSelectedEntryPos() == 0)
1041         Swap(aSize);
1042 
1043     mpPageItem->SetLandscape(mpPaperOrientation->GetSelectedEntryPos() == 0);
1044     const SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, aSize);
1045     // Page/slide properties dialog (FuPage::ExecuteDialog and ::ApplyItemSet) misuses
1046     // SID_ATTR_PAGE_EXT1 to distinguish between Impress and Draw, as for whether to fit
1047     // objects to paper size. Until that is handled somehow better, we do the same here
1048     const SfxBoolItem aFitObjs(SID_ATTR_PAGE_EXT1, IsImpress());
1049 
1050     GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD,
1051                                                 { &aSizeItem, mpPageItem.get(), &aFitObjs });
1052 
1053     // Notify LOK clients of the page size change.
1054     if (comphelper::LibreOfficeKit::isActive())
1055     {
1056         SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1057         if (pViewShell)
1058         {
1059             SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(pViewShell->GetCurrentDocument());
1060             SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
1061         }
1062     }
1063 }
1064 
IMPL_LINK_NOARG(SlideBackground,FillColorHdl,SvxColorListBox &,void)1065 IMPL_LINK_NOARG(SlideBackground, FillColorHdl, SvxColorListBox&, void)
1066 {
1067     const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpFillStyle->GetSelectedEntryPos());
1068     switch(eXFS)
1069     {
1070         case drawing::FillStyle_SOLID:
1071         {
1072             XFillColorItem aItem(OUString(), mpFillLB->GetSelectEntryColor());
1073             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, SfxCallMode::RECORD, { &aItem });
1074         }
1075         break;
1076         case drawing::FillStyle_GRADIENT:
1077         {
1078             XGradient aGradient;
1079             aGradient.SetStartColor(mpFillLB->GetSelectEntryColor());
1080             aGradient.SetEndColor(mpFillGrad->GetSelectEntryColor());
1081 
1082             // the name doesn't really matter, it'll be converted to unique one eventually,
1083             // but it has to be non-empty
1084             XFillGradientItem aItem("gradient", aGradient);
1085             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, SfxCallMode::RECORD, { &aItem });
1086         }
1087         break;
1088         default:
1089             break;
1090     }
1091 }
1092 
IMPL_LINK_NOARG(SlideBackground,FillBackgroundHdl,ListBox &,void)1093 IMPL_LINK_NOARG(SlideBackground, FillBackgroundHdl, ListBox&, void)
1094 {
1095     const eFillStyle nFillPos = static_cast<eFillStyle>(mpFillStyle->GetSelectedEntryPos());
1096     SfxObjectShell* pSh = SfxObjectShell::Current();
1097     switch(nFillPos)
1098     {
1099 
1100         case HATCH:
1101         {
1102             const SvxHatchListItem * pHatchListItem = pSh->GetItem(SID_HATCH_LIST);
1103             sal_uInt16 nPos = mpFillAttr->GetSelectedEntryPos();
1104             XHatch aHatch = pHatchListItem->GetHatchList()->GetHatch(nPos)->GetHatch();
1105             const OUString aHatchName = pHatchListItem->GetHatchList()->GetHatch(nPos)->GetName();
1106 
1107             XFillHatchItem aItem(aHatchName, aHatch);
1108             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, SfxCallMode::RECORD, { &aItem });
1109         }
1110         break;
1111 
1112         case BITMAP:
1113         case PATTERN:
1114         {
1115             sal_Int16 nPos = mpFillAttr->GetSelectedEntryPos();
1116             GraphicObject aBitmap;
1117             OUString aName;
1118             if( nFillPos == BITMAP )
1119             {
1120                 SvxBitmapListItem const * pBitmapListItem = pSh->GetItem(SID_BITMAP_LIST);
1121                 aBitmap = pBitmapListItem->GetBitmapList()->GetBitmap(nPos)->GetGraphicObject();
1122                 aName = pBitmapListItem->GetBitmapList()->GetBitmap(nPos)->GetName();
1123             }
1124             else if( nFillPos == PATTERN )
1125             {
1126                 SvxPatternListItem const * pPatternListItem = pSh->GetItem(SID_PATTERN_LIST);
1127                 aBitmap = pPatternListItem->GetPatternList()->GetBitmap(nPos)->GetGraphicObject();
1128                 aName = pPatternListItem->GetPatternList()->GetBitmap(nPos)->GetName();
1129             }
1130             XFillBitmapItem aItem(aName, aBitmap);
1131             GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, SfxCallMode::RECORD, { &aItem });
1132         }
1133         break;
1134 
1135         default:
1136             break;
1137     }
1138 }
1139 
IMPL_LINK_NOARG(SlideBackground,AssignMasterPage,ListBox &,void)1140 IMPL_LINK_NOARG(SlideBackground, AssignMasterPage, ListBox&, void)
1141 {
1142     ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() );
1143     SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr;
1144     if (!pDoc)
1145         return;
1146     sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND;
1147     for( sal_uInt16 nPage = 0; nPage < pDoc->GetSdPageCount(PageKind::Standard); nPage++ )
1148     {
1149         if (pDoc->GetSdPage(nPage,PageKind::Standard)->IsSelected())
1150         {
1151             nSelectedPage = nPage;
1152             break;
1153         }
1154     }
1155     OUString aLayoutName(mpMasterSlide->GetSelectedEntry());
1156     pDoc->SetMasterPage(nSelectedPage, aLayoutName, pDoc, false, false);
1157 }
1158 
IMPL_LINK_NOARG(SlideBackground,CloseMasterHdl,Button *,void)1159 IMPL_LINK_NOARG(SlideBackground, CloseMasterHdl, Button*, void)
1160 {
1161     GetBindings()->GetDispatcher()->Execute( SID_CLOSE_MASTER_VIEW, SfxCallMode::RECORD );
1162 }
1163 
IMPL_LINK_NOARG(SlideBackground,DspBackground,Button *,void)1164 IMPL_LINK_NOARG(SlideBackground, DspBackground, Button*, void)
1165 {
1166     bool IsChecked = mpDspMasterBackground->IsChecked();
1167     const SfxBoolItem aBoolItem(SID_DISPLAY_MASTER_BACKGROUND, IsChecked);
1168     GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_BACKGROUND, SfxCallMode::RECORD, { &aBoolItem });
1169 }
1170 
IMPL_LINK_NOARG(SlideBackground,DspObjects,Button *,void)1171 IMPL_LINK_NOARG(SlideBackground, DspObjects, Button*, void)
1172 {
1173     bool IsChecked = mpDspMasterObjects->IsChecked();
1174     const SfxBoolItem aBoolItem(SID_DISPLAY_MASTER_OBJECTS,IsChecked);
1175     GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_OBJECTS, SfxCallMode::RECORD, { &aBoolItem, &aBoolItem });
1176 }
1177 
IMPL_LINK_NOARG(SlideBackground,ModifyMarginHdl,ListBox &,void)1178 IMPL_LINK_NOARG( SlideBackground, ModifyMarginHdl, ListBox&, void )
1179 {
1180     bool bApplyNewPageMargins = true;
1181     switch ( mpMarginSelectBox->GetSelectedEntryPos() )
1182     {
1183         case 0:
1184             SetNone(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1185             break;
1186         case 1:
1187             SetNarrow(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1188             break;
1189         case 2:
1190             SetModerate(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1191             break;
1192         case 3:
1193             SetNormal075(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1194             break;
1195         case 4:
1196             SetNormal100(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1197             break;
1198         case 5:
1199             SetNormal125(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1200             break;
1201         case 6:
1202             SetWide(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1203             break;
1204         default:
1205             bApplyNewPageMargins = false;
1206             break;
1207     }
1208 
1209     if(bApplyNewPageMargins)
1210     {
1211         ExecuteMarginLRChange(m_nPageLeftMargin, m_nPageRightMargin);
1212         ExecuteMarginULChange(m_nPageTopMargin, m_nPageBottomMargin);
1213     }
1214 }
1215 
1216 }}
1217 
1218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1219