Get the style color and number just once
[LibreOffice.git] / sd / source / ui / sidebar / SlideBackground.cxx
blobd44b6502c6a1358b775e926d55af1995f41190c6
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 <com/sun/star/ui/XDeck.hpp>
21 #include <com/sun/star/ui/XPanel.hpp>
22 #include <com/sun/star/frame/XController2.hpp>
23 #include <SlideSorter.hxx>
24 #include <SlideSorterViewShell.hxx>
25 #include <controller/SlideSorterController.hxx>
26 #include <controller/SlsPageSelector.hxx>
27 #include "SlideBackground.hxx"
28 #include <sdresid.hxx>
29 #include <ViewShellBase.hxx>
30 #include <FrameView.hxx>
31 #include <DrawDocShell.hxx>
32 #include <drawdoc.hxx>
33 #include <sdpage.hxx>
34 #include "PageMarginUtils.hxx"
35 #include <strings.hrc>
36 #include <pageformatpanel.hrc>
37 #include <DrawViewShell.hxx>
38 #include <svl/intitem.hxx>
39 #include <svx/colorbox.hxx>
40 #include <svx/dlgutil.hxx>
41 #include <svx/drawitem.hxx>
42 #include <svx/itemwin.hxx>
43 #include <svx/pageitem.hxx>
44 #include <app.hrc>
45 #include <editeng/paperinf.hxx>
46 #include <svx/xflgrit.hxx>
47 #include <svx/rulritem.hxx>
48 #include <svx/svxids.hrc>
49 #include <svx/xfillit0.hxx>
50 #include <svx/xflclit.hxx>
51 #include <svx/xbtmpit.hxx>
52 #include <svx/xflhtit.hxx>
53 #include <svx/svdpage.hxx>
54 #include <sfx2/bindings.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <sfx2/sidebar/Panel.hxx>
57 #include <EventMultiplexer.hxx>
58 #include <unotools/localedatawrapper.hxx>
59 #include <utility>
60 #include <vcl/EnumContext.hxx>
61 #include <vcl/svapp.hxx>
63 #include <editeng/sizeitem.hxx>
64 #include <comphelper/lok.hxx>
65 #include <unomodel.hxx>
66 #include <sfx2/lokhelper.hxx>
68 using namespace ::com::sun::star;
70 using ::com::sun::star::uno::Reference;
72 namespace sd::sidebar {
74 namespace {
76 enum eFillStyle
78 NONE,
79 SOLID,
80 GRADIENT,
81 HATCH,
82 BITMAP,
83 PATTERN
88 SlideBackground::SlideBackground(
89 weld::Widget* pParent,
90 ViewShellBase& rBase,
91 css::uno::Reference<css::frame::XFrame> xFrame,
92 SfxBindings* pBindings) :
93 PanelLayout( pParent, u"SlideBackgroundPanel"_ustr, u"modules/simpress/ui/sidebarslidebackground.ui"_ustr ),
94 mrBase( rBase ),
95 mxPaperSizeBox(new SvxPaperSizeListBox(m_xBuilder->weld_combo_box(u"paperformat"_ustr))),
96 mxPaperOrientation(m_xBuilder->weld_combo_box(u"orientation"_ustr)),
97 mxMasterSlide(m_xBuilder->weld_combo_box(u"masterslide"_ustr)),
98 mxBackgroundLabel(m_xBuilder->weld_label(u"label3"_ustr)),
99 mxFillStyle(m_xBuilder->weld_combo_box(u"fillstyle"_ustr)),
100 mxFillLB(new ColorListBox(m_xBuilder->weld_menu_button(u"fillattr"_ustr), [this]{ return GetFrameWeld(); })),
101 mxFillAttr(m_xBuilder->weld_combo_box(u"fillattr1"_ustr)),
102 mxFillGrad1(new ColorListBox(m_xBuilder->weld_menu_button(u"fillattr2"_ustr), [this]{ return GetFrameWeld(); })),
103 mxFillGrad2(new ColorListBox(m_xBuilder->weld_menu_button(u"fillattr3"_ustr), [this]{ return GetFrameWeld(); })),
104 mxInsertImage(m_xBuilder->weld_button(u"button2"_ustr)),
105 mxDspMasterBackground(m_xBuilder->weld_check_button(u"displaymasterbackground"_ustr)),
106 mxDspMasterObjects(m_xBuilder->weld_check_button(u"displaymasterobjects"_ustr)),
107 mxCloseMaster(m_xBuilder->weld_button(u"closemasterslide"_ustr)),
108 mxEditMaster(m_xBuilder->weld_button(u"masterslidebutton"_ustr)),
109 mxMasterLabel(m_xBuilder->weld_label(u"masterlabel"_ustr)),
110 mxMarginSelectBox(m_xBuilder->weld_combo_box(u"marginLB"_ustr)),
111 mxCustomEntry(m_xBuilder->weld_label(u"customlabel"_ustr)),
112 mxMarginLabel(m_xBuilder->weld_label(u"labelmargin"_ustr)),
113 maPaperSizeController(SID_ATTR_PAGE_SIZE, *pBindings, *this),
114 maPaperOrientationController(SID_ATTR_PAGE, *pBindings, *this),
115 maPaperMarginLRController(SID_ATTR_PAGE_LRSPACE, *pBindings, *this),
116 maPaperMarginULController(SID_ATTR_PAGE_ULSPACE, *pBindings, *this),
117 maBckColorController(SID_ATTR_PAGE_COLOR, *pBindings, *this),
118 maBckGradientController(SID_ATTR_PAGE_GRADIENT, *pBindings, *this),
119 maBckHatchController(SID_ATTR_PAGE_HATCH, *pBindings, *this),
120 maBckBitmapController(SID_ATTR_PAGE_BITMAP, *pBindings, *this),
121 maBckFillStyleController(SID_ATTR_PAGE_FILLSTYLE, *pBindings, *this),
122 maBckImageController(SID_SELECT_BACKGROUND, *pBindings, *this),
123 maDspBckController(SID_DISPLAY_MASTER_BACKGROUND, *pBindings, *this),
124 maDspObjController(SID_DISPLAY_MASTER_OBJECTS, *pBindings, *this),
125 maMetricController(SID_ATTR_METRIC, *pBindings, *this),
126 maCloseMasterController(SID_CLOSE_MASTER_VIEW, *pBindings, *this),
127 mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ),
128 mbSwitchModeToNormal(false),
129 mbSwitchModeToMaster(false),
130 mxFrame(std::move(xFrame)),
131 maDrawOtherContext(vcl::EnumContext::Application::Draw, vcl::EnumContext::Context::DrawPage),
132 maDrawMasterContext(vcl::EnumContext::Application::Draw, vcl::EnumContext::Context::MasterPage),
133 maImpressOtherContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::DrawPage),
134 maImpressMasterContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::MasterPage),
135 maImpressHandoutContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::HandoutPage),
136 maImpressNotesContext(vcl::EnumContext::Application::Impress, vcl::EnumContext::Context::NotesPage),
137 mbTitle(false),
138 mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) ),
139 mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) ),
140 m_nPageLeftMargin(0),
141 m_nPageRightMargin(0),
142 m_nPageTopMargin(0),
143 m_nPageBottomMargin(0),
144 meFUnit(GetModuleFieldUnit()),
145 mpBindings(pBindings)
147 //let the listbox shrink to any size so the sidebar isn't forced to grow to
148 //the size of the longest master slide name in the document
149 mxMasterSlide->set_size_request(42, -1);
151 maCustomEntry = mxCustomEntry->get_label();
153 addListener();
154 Initialize();
157 bool SlideBackground::IsDraw()
159 return ( maContext == maDrawMasterContext ||
160 maContext == maDrawOtherContext );
163 bool SlideBackground::IsImpress()
165 return ( maContext == maImpressMasterContext ||
166 maContext == maImpressOtherContext ||
167 maContext == maImpressHandoutContext ||
168 maContext == maImpressNotesContext );
171 FieldUnit SlideBackground::GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState)
173 FieldUnit eUnit;
175 if (pState && eState >= SfxItemState::DEFAULT)
176 eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pState)->GetValue());
177 else
178 eUnit = GetModuleFieldUnit();
180 return eUnit;
183 void SlideBackground::SetMarginsFieldUnit()
185 auto nSelected = mxMarginSelectBox->get_active();
186 mxMarginSelectBox->clear();
188 const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper();
190 if (IsInch(meFUnit))
192 OUString sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
193 for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i)
195 OUString sMeasurement = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_INCH[i].second, 2, true, false) + sSuffix;
196 mxMarginSelectBox->append_text(SdResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i].first).replaceFirst("%1", sMeasurement));
199 else
201 OUString sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
202 for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i)
204 OUString sMeasurement = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_CM[i].second, 2, true, false) + sSuffix;
205 mxMarginSelectBox->append_text(SdResId(RID_PAGEFORMATPANEL_MARGINS_CM[i].first).replaceFirst("%1", sMeasurement));
209 mxMarginSelectBox->set_active(nSelected);
212 void SlideBackground::Initialize()
214 SvxFillTypeBox::Fill(*mxFillStyle);
216 SetMarginsFieldUnit();
218 mxPaperSizeBox->FillPaperSizeEntries( PaperSizeApp::Draw );
219 mxPaperSizeBox->connect_changed(LINK(this,SlideBackground,PaperSizeModifyHdl));
220 mxPaperOrientation->connect_changed(LINK(this,SlideBackground,PaperSizeModifyHdl));
221 mxEditMaster->connect_clicked(LINK(this, SlideBackground, EditMasterHdl));
222 mxCloseMaster->connect_clicked(LINK(this, SlideBackground, CloseMasterHdl));
223 mxInsertImage->connect_clicked(LINK(this, SlideBackground, SelectBgHdl));
224 meUnit = maPaperSizeController.GetCoreMetric();
226 mxMasterSlide->connect_changed(LINK(this, SlideBackground, AssignMasterPage));
228 mxFillStyle->connect_changed(LINK(this, SlideBackground, FillStyleModifyHdl));
229 mxFillLB->SetSelectHdl(LINK(this, SlideBackground, FillColorHdl));
230 mxFillGrad1->SetSelectHdl(LINK(this, SlideBackground, FillColorHdl));
231 mxFillGrad2->SetSelectHdl(LINK(this, SlideBackground, FillColorHdl));
232 mxFillAttr->connect_changed(LINK(this, SlideBackground, FillBackgroundHdl));
234 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
235 if (pMainViewShell)
237 FrameView *pFrameView = pMainViewShell->GetFrameView();
239 if ( pFrameView->GetViewShEditMode() == EditMode::Page )
241 SdPage* mpPage = pMainViewShell->getCurrentPage();
242 populateMasterSlideDropdown();
244 OUString aLayoutName( mpPage->GetLayoutName() );
245 aLayoutName = aLayoutName.copy(0,aLayoutName.indexOf(SD_LT_SEPARATOR));
246 mxMasterSlide->set_active_text(aLayoutName);
250 mxFillStyle->set_active(static_cast< sal_Int32 >(NONE));
252 mxDspMasterBackground->connect_toggled(LINK(this, SlideBackground, DspBackground));
253 mxDspMasterObjects->connect_toggled(LINK(this, SlideBackground, DspObjects));
255 //margins
256 mxMarginSelectBox->connect_changed(LINK(this, SlideBackground, ModifyMarginHdl));
258 Update();
259 UpdateMarginBox();
262 void SlideBackground::DumpAsPropertyTree(::tools::JsonWriter& rJsonWriter)
264 if (mxPaperSizeBox->get_active() == -1)
266 mpBindings->Update(SID_ATTR_PAGE_SIZE);
269 PanelLayout::DumpAsPropertyTree(rJsonWriter);
272 void SlideBackground::HandleContextChange(
273 const vcl::EnumContext& rContext)
275 if (maContext == rContext)
276 return;
277 maContext = rContext;
279 if ( IsImpress() )
281 mxMasterLabel->set_label(SdResId(STR_MASTERSLIDE_LABEL));
283 // margin selector is only for Draw
284 mxMarginSelectBox->hide();
285 mxMarginLabel->hide();
287 if ( maContext == maImpressMasterContext )
289 mxCloseMaster->show();
290 mxEditMaster->hide();
291 mxMasterSlide->set_sensitive(false);
292 mxMasterSlide->clear();
293 mxDspMasterBackground->set_sensitive(false);
294 mxDspMasterObjects->set_sensitive(false);
295 mxFillStyle->hide();
296 mxBackgroundLabel->hide();
297 mxInsertImage->show();
299 mxFillLB->hide();
300 mxFillAttr->hide();
301 mxFillGrad1->hide();
302 mxFillGrad2->hide();
304 else if ( maContext == maImpressHandoutContext || maContext == maImpressNotesContext )
306 mxCloseMaster->hide();
307 mxEditMaster->hide();
308 mxMasterSlide->set_sensitive(false);
309 mxMasterSlide->clear();
310 mxDspMasterBackground->set_sensitive(false);
311 mxDspMasterObjects->set_sensitive(false);
312 mxFillStyle->hide();
313 mxBackgroundLabel->hide();
314 mxInsertImage->hide();
316 else if (maContext == maImpressOtherContext)
318 mxCloseMaster->hide();
319 mxEditMaster->show();
320 mxMasterSlide->set_sensitive(true);
321 populateMasterSlideDropdown();
322 mxDspMasterBackground->set_sensitive(true);
323 mxDspMasterObjects->set_sensitive(true);
324 mxFillStyle->show();
325 mxBackgroundLabel->show();
326 mxInsertImage->show();
329 // Need to do a relayouting, otherwise the panel size is not updated after show / hide controls
330 if (m_pPanel)
331 m_pPanel->TriggerDeckLayouting();
334 else if ( IsDraw() )
336 mxMasterLabel->set_label(SdResId(STR_MASTERPAGE_LABEL));
337 mxDspMasterBackground->hide();
338 mxDspMasterObjects->hide();
340 if (maContext == maDrawOtherContext)
342 mxEditMaster->hide();
343 mxFillStyle->show();
344 mxBackgroundLabel->show();
346 else if (maContext == maDrawMasterContext)
348 mxFillStyle->hide();
349 mxBackgroundLabel->hide();
353 // The Insert Image button in the sidebar issues .uno:SelectBackground,
354 // which when invoked without arguments will open the file-open-dialog
355 // to prompt the user to select a file. This is useless in LOOL.
356 // Hide for now so the user will only be able to use the menu to insert
357 // background image, which prompts the user for file selection in the browser.
358 if (comphelper::LibreOfficeKit::isActive())
359 mxInsertImage->hide();
362 void SlideBackground::Update()
364 eFillStyle nPos = static_cast<eFillStyle>(mxFillStyle->get_active());
366 if(maContext != maImpressOtherContext && maContext != maDrawOtherContext)
367 nPos = NONE;
369 SfxObjectShell* pSh = SfxObjectShell::Current();
370 if (!pSh)
371 return;
373 switch(nPos)
375 case NONE:
377 mxFillLB->hide();
378 mxFillAttr->hide();
379 mxFillGrad1->hide();
380 mxFillGrad2->hide();
382 break;
383 case SOLID:
385 mxFillAttr->hide();
386 mxFillGrad1->hide();
387 mxFillGrad2->hide();
388 mxFillLB->show();
389 const Color aColor = GetColorSetOrDefault();
390 mxFillLB->SelectEntry(aColor);
392 break;
393 case GRADIENT:
395 mxFillLB->hide();
396 mxFillAttr->hide();
397 mxFillGrad1->show();
398 mxFillGrad2->show();
400 const basegfx::BGradient aBGradient = GetGradientSetOrDefault();
401 const Color aStartColor(aBGradient.GetColorStops().front().getStopColor());
402 mxFillGrad1->SelectEntry(aStartColor);
403 const Color aEndColor(aBGradient.GetColorStops().back().getStopColor());
404 mxFillGrad2->SelectEntry(aEndColor);
406 // MCGR: preserve ColorStops if given.
407 // tdf#155901 We need offset of first and last stop, so include them.
408 if (aBGradient.GetColorStops().size() >= 2)
409 maColorStops = aBGradient.GetColorStops();
410 else
411 maColorStops.clear();
413 break;
415 case HATCH:
417 mxFillLB->hide();
418 mxFillAttr->show();
419 mxFillAttr->clear();
420 SvxFillAttrBox::Fill(*mxFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList());
421 mxFillGrad1->hide();
422 mxFillGrad2->hide();
424 const OUString aHatchName = GetHatchingSetOrDefault();
425 mxFillAttr->set_active_text( aHatchName );
427 break;
429 case BITMAP:
430 case PATTERN:
432 mxFillLB->hide();
433 mxFillAttr->show();
434 mxFillAttr->clear();
435 mxFillGrad1->hide();
436 mxFillGrad2->hide();
437 OUString aName;
438 if(nPos == BITMAP)
440 SvxFillAttrBox::Fill(*mxFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList());
441 aName = GetBitmapSetOrDefault();
443 else if(nPos == PATTERN)
445 SvxFillAttrBox::Fill(*mxFillAttr, pSh->GetItem(SID_PATTERN_LIST)->GetPatternList());
446 aName = GetPatternSetOrDefault();
448 mxFillAttr->set_active_text( aName );
450 break;
451 default:
452 break;
455 // Need to do a relayouting, otherwise the panel size is not updated after show / hide controls
456 if (m_pPanel)
457 m_pPanel->TriggerDeckLayouting();
460 void SlideBackground::UpdateMarginBox()
462 m_nPageLeftMargin = mpPageLRMarginItem->GetLeft();
463 m_nPageRightMargin = mpPageLRMarginItem->GetRight();
464 m_nPageTopMargin = mpPageULMarginItem->GetUpper();
465 m_nPageBottomMargin = mpPageULMarginItem->GetLower();
467 int nCustomIndex = mxMarginSelectBox->find_text(maCustomEntry);
469 if( IsNone(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
471 mxMarginSelectBox->set_active(0);
472 if (nCustomIndex != -1)
473 mxMarginSelectBox->remove(nCustomIndex);
475 else if( IsNarrow(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
477 mxMarginSelectBox->set_active(1);
478 if (nCustomIndex != -1)
479 mxMarginSelectBox->remove(nCustomIndex);
481 else if( IsModerate(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
483 mxMarginSelectBox->set_active(2);
484 if (nCustomIndex != -1)
485 mxMarginSelectBox->remove(nCustomIndex);
487 else if( IsNormal075(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
489 mxMarginSelectBox->set_active(3);
490 if (nCustomIndex != -1)
491 mxMarginSelectBox->remove(nCustomIndex);
493 else if( IsNormal100(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
495 mxMarginSelectBox->set_active(4);
496 if (nCustomIndex != -1)
497 mxMarginSelectBox->remove(nCustomIndex);
499 else if( IsNormal125(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
501 mxMarginSelectBox->set_active(5);
502 if (nCustomIndex != -1)
503 mxMarginSelectBox->remove(nCustomIndex);
505 else if( IsWide(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin) )
507 mxMarginSelectBox->set_active(6);
508 if (nCustomIndex != -1)
509 mxMarginSelectBox->remove(nCustomIndex);
511 else
513 if (nCustomIndex == -1)
514 mxMarginSelectBox->append_text(maCustomEntry);
515 mxMarginSelectBox->set_active_text(maCustomEntry);
519 void SlideBackground::SetPanelTitle( const OUString& rTitle )
521 Reference<frame::XController2> xController( mxFrame->getController(), uno::UNO_QUERY);
522 if ( !xController.is() )
523 return;
525 Reference<ui::XSidebarProvider> xSidebarProvider = xController->getSidebar();
526 if ( !xSidebarProvider.is() )
527 return;
529 Reference<ui::XDecks> xDecks = xSidebarProvider->getDecks();
530 if ( !xDecks.is() )
531 return;
533 Reference<ui::XDeck> xDeck ( xDecks->getByName(u"PropertyDeck"_ustr), uno::UNO_QUERY);
534 if ( !xDeck.is() )
535 return;
537 Reference<ui::XPanels> xPanels = xDeck->getPanels();
538 if ( !xPanels.is() )
539 return;
541 if (xPanels->hasByName(u"SlideBackgroundPanel"_ustr))
543 Reference<ui::XPanel> xPanel ( xPanels->getByName(u"SlideBackgroundPanel"_ustr), uno::UNO_QUERY);
544 if ( !xPanel.is() )
545 return;
547 xPanel->setTitle( rTitle );
551 void SlideBackground::addListener()
553 Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this, SlideBackground, EventMultiplexerListener) );
554 mrBase.GetEventMultiplexer()->AddEventListener( aLink );
557 void SlideBackground::removeListener()
559 Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this, SlideBackground, EventMultiplexerListener) );
560 mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
563 IMPL_LINK(SlideBackground, EventMultiplexerListener,
564 tools::EventMultiplexerEvent&, rEvent, void)
566 switch (rEvent.meEventId)
568 // add more events as per requirement
569 // Master Page change triggers a shape change event. Solves sync problem.
570 case EventMultiplexerEventId::ShapeChanged:
571 populateMasterSlideDropdown();
572 break;
573 case EventMultiplexerEventId::EditModeNormal:
574 mbSwitchModeToNormal = true;
575 break;
576 case EventMultiplexerEventId::EditModeMaster:
577 mbSwitchModeToMaster = true;
578 break;
579 case EventMultiplexerEventId::EditViewSelection:
580 case EventMultiplexerEventId::EndTextEdit:
582 if ( mbSwitchModeToMaster )
584 if( IsImpress() )
585 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME));
586 else
587 SetPanelTitle(SdResId(STR_MASTERPAGE_NAME));
588 mbSwitchModeToMaster = false;
590 else if ( mbSwitchModeToNormal )
592 if( IsImpress() )
593 SetPanelTitle(SdResId(STR_SLIDE_NAME));
594 else
595 SetPanelTitle(SdResId(STR_PAGE_NAME));
596 mbSwitchModeToNormal = false;
600 break;
601 case EventMultiplexerEventId::CurrentPageChanged:
603 static const sal_uInt16 SidArray[] = {
604 SID_ATTR_PAGE_COLOR,
605 SID_ATTR_PAGE_GRADIENT,
606 SID_ATTR_PAGE_HATCH,
607 SID_ATTR_PAGE_BITMAP,
608 SID_ATTR_PAGE_FILLSTYLE,
609 SID_DISPLAY_MASTER_BACKGROUND,
610 SID_DISPLAY_MASTER_OBJECTS,
611 0 };
612 updateMasterSlideSelection();
613 GetBindings()->Invalidate( SidArray );
615 break;
616 case EventMultiplexerEventId::ViewAdded:
618 if(!mbTitle)
620 if( IsDraw() )
622 mxCloseMaster->hide();
623 mxEditMaster->hide();
624 if( maContext == maDrawMasterContext)
625 SetPanelTitle(SdResId(STR_MASTERPAGE_NAME));
626 else
627 SetPanelTitle(SdResId(STR_PAGE_NAME));
629 else if ( maContext == maImpressOtherContext || maContext == maImpressMasterContext )
631 if( maContext == maImpressMasterContext )
632 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME));
633 else
634 SetPanelTitle(SdResId(STR_SLIDE_NAME));
636 else if ( maContext == maImpressNotesContext )
638 mxMasterLabel->set_label(SdResId(STR_MASTERSLIDE_LABEL));
639 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
641 if (pMainViewShell)
643 DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
644 if ( pDrawViewShell->GetEditMode() == EditMode::MasterPage)
645 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME));
646 else // EditMode::Page
647 SetPanelTitle(SdResId(STR_SLIDE_NAME));
650 mbTitle = true;
653 break;
654 default:
655 break;
659 void SlideBackground::populateMasterSlideDropdown()
661 mxMasterSlide->clear();
662 ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() );
663 SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr;
664 sal_uInt16 nCount = pDoc ? pDoc->GetMasterPageCount() : 0;
665 for( sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++ )
667 SdPage* pMaster = static_cast<SdPage*>(pDoc->GetMasterPage(nLayout));
668 if( pMaster->GetPageKind() == PageKind::Standard)
670 OUString aLayoutName(pMaster->GetLayoutName());
671 aLayoutName = aLayoutName.copy(0,aLayoutName.indexOf(SD_LT_SEPARATOR));
672 mxMasterSlide->append_text(aLayoutName);
675 updateMasterSlideSelection();
678 void SlideBackground::updateMasterSlideSelection()
680 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
681 SdPage* pPage = pMainViewShell ? pMainViewShell->getCurrentPage() : nullptr;
682 if (pPage != nullptr && pPage->TRG_HasMasterPage())
684 SdrPage& rMasterPage (pPage->TRG_GetMasterPage());
685 SdPage* pMasterPage = static_cast<SdPage*>(&rMasterPage);
686 mxMasterSlide->set_active_text(pMasterPage->GetName());
690 SlideBackground::~SlideBackground()
692 removeListener();
694 mxCustomEntry.reset();
695 mxMarginLabel.reset();
696 mxPaperSizeBox.reset();
697 mxPaperOrientation.reset();
698 mxMasterSlide.reset();
699 mxBackgroundLabel.reset();
700 mxFillAttr.reset();
701 mxFillGrad1.reset();
702 mxFillGrad2.reset();
703 mxFillStyle.reset();
704 mxFillLB.reset();
705 mxInsertImage.reset();
706 mxMarginSelectBox.reset();
707 mxDspMasterBackground.reset();
708 mxDspMasterObjects.reset();
709 mxMasterLabel.reset();
710 mxEditMaster.reset();
711 mxCloseMaster.reset();
713 maPaperSizeController.dispose();
714 maPaperOrientationController.dispose();
715 maPaperMarginLRController.dispose();
716 maPaperMarginULController.dispose();
717 maBckColorController.dispose();
718 maBckGradientController.dispose();
719 maBckHatchController.dispose();
720 maBckBitmapController.dispose();
721 maBckFillStyleController.dispose();
722 maBckImageController.dispose();
723 maDspBckController.dispose();
724 maDspObjController.dispose();
725 maMetricController.dispose();
726 maCloseMasterController.dispose();
728 mpPageItem.reset();
729 mpColorItem.reset();
730 mpHatchItem.reset();
731 mpBitmapItem.reset();
732 mpPageLRMarginItem.reset();
733 mpPageULMarginItem.reset();
736 void SlideBackground::ExecuteMarginLRChange(const ::tools::Long mnPageLeftMargin, const ::tools::Long mnPageRightMargin)
738 mpPageLRMarginItem->SetLeft(mnPageLeftMargin);
739 mpPageLRMarginItem->SetRight(mnPageRightMargin);
740 GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE, SfxCallMode::RECORD, { mpPageLRMarginItem.get() } );
743 void SlideBackground::ExecuteMarginULChange(const ::tools::Long mnPageTopMargin, const ::tools::Long mnPageBottomMargin)
745 mpPageULMarginItem->SetUpper(mnPageTopMargin);
746 mpPageULMarginItem->SetLower(mnPageBottomMargin);
747 GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE, SfxCallMode::RECORD, { mpPageULMarginItem.get() } );
750 Color const & SlideBackground::GetColorSetOrDefault()
752 // Tango Sky Blue 1, to be consistent w/ area fill panel (b/c COL_AUTO for slides is transparent)
753 if ( !mpColorItem )
754 mpColorItem.reset( new XFillColorItem( OUString(), Color(0x72, 0x9f, 0xcf) ) );
756 return mpColorItem->GetColorValue();
759 basegfx::BGradient const & SlideBackground::GetGradientSetOrDefault()
761 if( !mpGradientItem )
763 basegfx::BGradient aGradient;
764 OUString aGradientName;
765 if (SfxObjectShell* pSh = SfxObjectShell::Current())
767 const SvxGradientListItem * pGradListItem = pSh->GetItem(SID_GRADIENT_LIST);
768 aGradient = pGradListItem->GetGradientList()->GetGradient(0)->GetGradient();
769 aGradientName = pGradListItem->GetGradientList()->GetGradient(0)->GetName();
771 mpGradientItem.reset( new XFillGradientItem( aGradientName, aGradient ) );
774 return mpGradientItem->GetGradientValue();
777 OUString const & SlideBackground::GetHatchingSetOrDefault()
779 if( !mpHatchItem )
781 XHatch aHatch;
782 OUString aHatchName;
783 if (SfxObjectShell* pSh = SfxObjectShell::Current())
785 const SvxHatchListItem * pHatchListItem = pSh->GetItem(SID_HATCH_LIST);
786 aHatch = pHatchListItem->GetHatchList()->GetHatch(0)->GetHatch();
787 aHatchName = pHatchListItem->GetHatchList()->GetHatch(0)->GetName();
789 mpHatchItem.reset( new XFillHatchItem( aHatchName, aHatch ) );
792 return mpHatchItem->GetName();
795 OUString const & SlideBackground::GetBitmapSetOrDefault()
797 if( !mpBitmapItem || mpBitmapItem->isPattern())
799 GraphicObject aGraphObj;
800 OUString aBmpName;
801 if (SfxObjectShell* pSh = SfxObjectShell::Current())
803 const SvxBitmapListItem * pBmpListItem = pSh->GetItem(SID_BITMAP_LIST);
804 aGraphObj = pBmpListItem->GetBitmapList()->GetBitmap(0)->GetGraphicObject();
805 aBmpName = pBmpListItem->GetBitmapList()->GetBitmap(0)->GetName();
807 mpBitmapItem.reset( new XFillBitmapItem( aBmpName, aGraphObj ) );
810 return mpBitmapItem->GetName();
813 OUString const & SlideBackground::GetPatternSetOrDefault()
815 if( !mpBitmapItem || !(mpBitmapItem->isPattern()))
817 GraphicObject aGraphObj;
818 OUString aPtrnName;
819 if (SfxObjectShell* pSh = SfxObjectShell::Current())
821 const SvxPatternListItem * pPtrnListItem = pSh->GetItem(SID_PATTERN_LIST);
822 aGraphObj = pPtrnListItem->GetPatternList()->GetBitmap(0)->GetGraphicObject();
823 aPtrnName = pPtrnListItem->GetPatternList()->GetBitmap(0)->GetName();
825 mpBitmapItem.reset( new XFillBitmapItem( aPtrnName, aGraphObj ) );
828 return mpBitmapItem->GetName();
831 void SlideBackground::NotifyItemUpdate(
832 const sal_uInt16 nSID,
833 const SfxItemState eState,
834 const SfxPoolItem* pState)
836 switch(nSID)
839 case SID_ATTR_PAGE_COLOR:
841 if(eState >= SfxItemState::DEFAULT)
843 mxFillStyle->set_active(static_cast< sal_Int32 >(SOLID));
844 mpColorItem.reset(pState ? static_cast< XFillColorItem* >(pState->Clone()) : nullptr);
845 Update();
848 break;
850 case SID_ATTR_PAGE_HATCH:
852 if(eState >= SfxItemState::DEFAULT)
854 mxFillStyle->set_active(static_cast< sal_Int32 >(HATCH));
855 mpHatchItem.reset(pState ? static_cast < XFillHatchItem* >(pState->Clone()) : nullptr);
856 Update();
859 break;
861 case SID_ATTR_PAGE_GRADIENT:
863 if(eState >= SfxItemState::DEFAULT)
865 mxFillStyle->set_active(static_cast< sal_Int32>(GRADIENT));
866 mpGradientItem.reset(pState ? static_cast< XFillGradientItem* >(pState->Clone()) : nullptr);
867 Update();
870 break;
871 case SID_ATTR_PAGE_BITMAP:
873 if(eState >= SfxItemState::DEFAULT)
875 mpBitmapItem.reset(pState ? static_cast< XFillBitmapItem* >(pState->Clone()) : nullptr);
876 if(mpBitmapItem)
878 if(mpBitmapItem->isPattern())
879 mxFillStyle->set_active(static_cast< sal_Int32 >(PATTERN));
880 else
881 mxFillStyle->set_active(static_cast< sal_Int32 >(BITMAP));
883 else
884 mxFillStyle->set_active(static_cast< sal_Int32 >(BITMAP));
885 Update();
888 break;
890 case SID_ATTR_PAGE_FILLSTYLE:
892 const XFillStyleItem* pFillStyleItem = nullptr;
893 if (eState >= SfxItemState::DEFAULT)
894 pFillStyleItem = dynamic_cast< const XFillStyleItem* >(pState);
895 if (pFillStyleItem)
897 css::drawing::FillStyle eXFS = pFillStyleItem->GetValue();
898 switch(eXFS)
900 case drawing::FillStyle_NONE:
901 mxFillStyle->set_active(static_cast< sal_Int32 >(NONE));
902 break;
903 case drawing::FillStyle_SOLID:
904 mxFillStyle->set_active(static_cast< sal_Int32 >(SOLID));
905 break;
906 case drawing::FillStyle_GRADIENT:
907 mxFillStyle->set_active(static_cast< sal_Int32 >(GRADIENT));
908 break;
909 case drawing::FillStyle_HATCH:
910 mxFillStyle->set_active(static_cast< sal_Int32 >(HATCH));
911 break;
912 case drawing::FillStyle_BITMAP:
914 if(mpBitmapItem->isPattern())
915 mxFillStyle->set_active(static_cast< sal_Int32 >(PATTERN));
916 else
917 mxFillStyle->set_active(static_cast< sal_Int32 >(BITMAP));
919 break;
920 default:
921 break;
923 Update();
926 break;
928 case SID_ATTR_PAGE_SIZE:
930 const SvxSizeItem* pSizeItem = nullptr;
931 if (eState >= SfxItemState::DEFAULT)
932 pSizeItem = dynamic_cast<const SvxSizeItem*>(pState);
933 if (pSizeItem)
935 Size aPaperSize = pSizeItem->GetSize();
936 if (mxPaperOrientation->get_active() == 0)
937 Swap(aPaperSize);
939 Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, meUnit);
940 mxPaperSizeBox->set_active_id( ePaper );
943 break;
945 case SID_ATTR_PAGE:
947 const SvxPageItem* pPageItem = nullptr;
948 if (eState >= SfxItemState::DEFAULT)
949 pPageItem = dynamic_cast<const SvxPageItem*>(pState);
950 if (pPageItem)
952 mpPageItem.reset(pPageItem->Clone());
953 bool bIsLandscape = mpPageItem->IsLandscape();
954 mxPaperOrientation->set_active( bIsLandscape ? 0 : 1 );
957 break;
959 case SID_ATTR_PAGE_LRSPACE:
961 const SvxLongLRSpaceItem* pLRItem = nullptr;
962 if (eState >= SfxItemState::DEFAULT)
963 pLRItem = dynamic_cast<const SvxLongLRSpaceItem*>(pState);
964 if (pLRItem)
966 mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) );
967 UpdateMarginBox();
970 break;
972 case SID_ATTR_PAGE_ULSPACE:
974 const SvxLongULSpaceItem* pULItem = nullptr;
975 if (eState >= SfxItemState::DEFAULT)
976 pULItem = dynamic_cast<const SvxLongULSpaceItem*>(pState);
977 if (pULItem)
979 mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pState->Clone()) );
980 UpdateMarginBox();
983 break;
985 case SID_DISPLAY_MASTER_BACKGROUND:
987 const SfxBoolItem* pBoolItem = nullptr;
988 if (eState >= SfxItemState::DEFAULT)
989 pBoolItem = dynamic_cast< const SfxBoolItem* >(pState);
990 if (pBoolItem)
991 mxDspMasterBackground->set_active(pBoolItem->GetValue());
993 break;
994 case SID_DISPLAY_MASTER_OBJECTS:
996 const SfxBoolItem* pBoolItem = nullptr;
997 if (eState >= SfxItemState::DEFAULT)
998 pBoolItem = dynamic_cast< const SfxBoolItem* >(pState);
999 if (pBoolItem)
1000 mxDspMasterObjects->set_active(pBoolItem->GetValue());
1002 break;
1003 case SID_SELECT_BACKGROUND:
1005 if(eState >= SfxItemState::DEFAULT)
1007 mxFillStyle->set_active(static_cast< sal_Int32 >(BITMAP));
1008 Update();
1011 break;
1012 case SID_ATTR_METRIC:
1014 FieldUnit eFUnit = GetCurrentUnit(eState, pState);
1015 if (meFUnit != eFUnit)
1017 meFUnit = eFUnit;
1018 SetMarginsFieldUnit();
1019 UpdateMarginBox();
1022 break;
1023 default:
1024 break;
1028 IMPL_LINK_NOARG(SlideBackground, FillStyleModifyHdl, weld::ComboBox&, void)
1030 const eFillStyle nPos = static_cast<eFillStyle>(mxFillStyle->get_active());
1031 Update();
1033 switch (nPos)
1035 case NONE:
1037 const XFillStyleItem aXFillStyleItem(drawing::FillStyle_NONE);
1038 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_FILLSTYLE, SfxCallMode::RECORD, { &aXFillStyleItem });
1040 break;
1042 case SOLID:
1044 if (mpColorItem)
1046 const XFillColorItem aItem( OUString(), mpColorItem->GetColorValue() );
1047 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, SfxCallMode::RECORD, { &aItem });
1050 break;
1052 case GRADIENT:
1054 if (mpGradientItem)
1056 const XFillGradientItem aItem( mpGradientItem->GetName(), mpGradientItem->GetGradientValue() );
1057 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, SfxCallMode::RECORD, { &aItem });
1060 break;
1062 case HATCH:
1064 if (mpHatchItem)
1066 const XFillHatchItem aItem( mpHatchItem->GetName(), mpHatchItem->GetHatchValue() );
1067 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, SfxCallMode::RECORD, { &aItem });
1070 break;
1072 case BITMAP:
1073 case PATTERN:
1075 if (mpBitmapItem)
1077 const XFillBitmapItem aItem( mpBitmapItem->GetName(), mpBitmapItem->GetGraphicObject() );
1078 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, SfxCallMode::RECORD, { &aItem });
1081 break;
1083 default:
1084 break;
1086 //TODO mxFillStyle->Selected();
1089 IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, weld::ComboBox&, void)
1091 const Paper ePaper = mxPaperSizeBox->get_active_id();
1092 Size aSize(SvxPaperInfo::GetPaperSize(ePaper, meUnit));
1094 if (mxPaperOrientation->get_active() == 0)
1095 Swap(aSize);
1097 mpPageItem->SetLandscape(mxPaperOrientation->get_active() == 0);
1098 const SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, aSize);
1099 // Page/slide properties dialog (FuPage::ExecuteDialog and ::ApplyItemSet) misuses
1100 // SID_ATTR_PAGE_EXT1 to distinguish between Impress and Draw, as for whether to fit
1101 // objects to paper size. Until that is handled somehow better, we do the same here
1102 const SfxBoolItem aFitObjs(SID_ATTR_PAGE_EXT1, IsImpress());
1104 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD,
1105 { &aSizeItem, mpPageItem.get(), &aFitObjs });
1107 // Notify LOK clients of the page size change.
1108 if (!comphelper::LibreOfficeKit::isActive())
1109 return;
1111 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1112 while (pViewShell)
1114 if (pViewShell->GetDocId() == mrBase.GetDocId())
1116 SdXImpressDocument* pDoc = comphelper::getFromUnoTunnel<SdXImpressDocument>(pViewShell->GetCurrentDocument());
1117 SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
1119 pViewShell = SfxViewShell::GetNext(*pViewShell);
1123 IMPL_LINK_NOARG(SlideBackground, FillColorHdl, ColorListBox&, void)
1125 const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mxFillStyle->get_active());
1126 switch(eXFS)
1128 case drawing::FillStyle_SOLID:
1130 XFillColorItem aItem(OUString(), mxFillLB->GetSelectEntryColor());
1131 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, SfxCallMode::RECORD, { &aItem });
1133 break;
1134 case drawing::FillStyle_GRADIENT:
1136 basegfx::BGradient aGradient = GetGradientSetOrDefault();
1137 aGradient.SetColorStops(createColorStops());
1139 // the name doesn't really matter, it'll be converted to unique one eventually,
1140 // but it has to be non-empty
1141 XFillGradientItem aItem(u"gradient"_ustr, aGradient);
1142 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, SfxCallMode::RECORD, { &aItem });
1144 break;
1145 default:
1146 break;
1150 IMPL_LINK_NOARG(SlideBackground, FillBackgroundHdl, weld::ComboBox&, void)
1152 const eFillStyle nFillPos = static_cast<eFillStyle>(mxFillStyle->get_active());
1153 SfxObjectShell* pSh = SfxObjectShell::Current();
1154 if (!pSh)
1155 return;
1156 switch(nFillPos)
1159 case HATCH:
1161 const SvxHatchListItem * pHatchListItem = pSh->GetItem(SID_HATCH_LIST);
1162 sal_uInt16 nPos = mxFillAttr->get_active();
1163 XHatch aHatch = pHatchListItem->GetHatchList()->GetHatch(nPos)->GetHatch();
1164 const OUString aHatchName = pHatchListItem->GetHatchList()->GetHatch(nPos)->GetName();
1166 XFillHatchItem aItem(aHatchName, aHatch);
1167 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, SfxCallMode::RECORD, { &aItem });
1169 break;
1171 case BITMAP:
1172 case PATTERN:
1174 sal_Int16 nPos = mxFillAttr->get_active();
1175 GraphicObject aBitmap;
1176 OUString aName;
1177 if( nFillPos == BITMAP )
1179 SvxBitmapListItem const * pBitmapListItem = pSh->GetItem(SID_BITMAP_LIST);
1180 aBitmap = pBitmapListItem->GetBitmapList()->GetBitmap(nPos)->GetGraphicObject();
1181 aName = pBitmapListItem->GetBitmapList()->GetBitmap(nPos)->GetName();
1183 else if( nFillPos == PATTERN )
1185 SvxPatternListItem const * pPatternListItem = pSh->GetItem(SID_PATTERN_LIST);
1186 aBitmap = pPatternListItem->GetPatternList()->GetBitmap(nPos)->GetGraphicObject();
1187 aName = pPatternListItem->GetPatternList()->GetBitmap(nPos)->GetName();
1189 XFillBitmapItem aItem(aName, aBitmap);
1190 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, SfxCallMode::RECORD, { &aItem });
1192 break;
1194 default:
1195 break;
1199 IMPL_LINK_NOARG(SlideBackground, AssignMasterPage, weld::ComboBox&, void)
1201 ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() );
1202 SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr;
1203 if (!pDoc)
1204 return;
1206 auto pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(mrBase);
1207 if (pSSVS == nullptr)
1208 return;
1210 auto& rSSController = pSSVS->GetSlideSorter().GetController();
1211 auto& rPageSelector = rSSController.GetPageSelector();
1213 for( sal_uInt16 nPage = 0; nPage < pDoc->GetSdPageCount(PageKind::Standard); nPage++ )
1215 if (rPageSelector.IsPageSelected(nPage))
1217 OUString aLayoutName(mxMasterSlide->get_active_text());
1218 pDoc->SetMasterPage(nPage, aLayoutName, pDoc, false, false);
1223 IMPL_LINK_NOARG(SlideBackground, EditMasterHdl, weld::Button&, void)
1225 GetBindings()->GetDispatcher()->Execute( SID_SLIDE_MASTER_MODE, SfxCallMode::RECORD );
1228 IMPL_LINK_NOARG(SlideBackground, SelectBgHdl, weld::Button&, void)
1230 GetBindings()->GetDispatcher()->Execute( SID_SELECT_BACKGROUND, SfxCallMode::RECORD );
1233 IMPL_LINK_NOARG(SlideBackground, CloseMasterHdl, weld::Button&, void)
1235 GetBindings()->GetDispatcher()->Execute( SID_CLOSE_MASTER_VIEW, SfxCallMode::RECORD );
1238 IMPL_LINK_NOARG(SlideBackground, DspBackground, weld::Toggleable&, void)
1240 bool IsChecked = mxDspMasterBackground->get_active();
1241 const SfxBoolItem aBoolItem(SID_DISPLAY_MASTER_BACKGROUND, IsChecked);
1242 GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_BACKGROUND, SfxCallMode::RECORD, { &aBoolItem });
1245 IMPL_LINK_NOARG(SlideBackground, DspObjects, weld::Toggleable&, void)
1247 bool IsChecked = mxDspMasterObjects->get_active();
1248 const SfxBoolItem aBoolItem(SID_DISPLAY_MASTER_OBJECTS,IsChecked);
1249 GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_OBJECTS, SfxCallMode::RECORD, { &aBoolItem, &aBoolItem });
1252 IMPL_LINK_NOARG( SlideBackground, ModifyMarginHdl, weld::ComboBox&, void )
1254 bool bApplyNewPageMargins = true;
1255 switch ( mxMarginSelectBox->get_active() )
1257 case 0:
1258 SetNone(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1259 break;
1260 case 1:
1261 SetNarrow(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1262 break;
1263 case 2:
1264 SetModerate(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1265 break;
1266 case 3:
1267 SetNormal075(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1268 break;
1269 case 4:
1270 SetNormal100(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1271 break;
1272 case 5:
1273 SetNormal125(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1274 break;
1275 case 6:
1276 SetWide(m_nPageLeftMargin, m_nPageRightMargin, m_nPageTopMargin, m_nPageBottomMargin);
1277 break;
1278 default:
1279 bApplyNewPageMargins = false;
1280 break;
1283 if(bApplyNewPageMargins)
1285 ExecuteMarginLRChange(m_nPageLeftMargin, m_nPageRightMargin);
1286 ExecuteMarginULChange(m_nPageTopMargin, m_nPageBottomMargin);
1290 basegfx::BColorStops SlideBackground::createColorStops()
1292 basegfx::BColorStops aColorStops;
1294 if (maColorStops.size() >= 2)
1296 aColorStops = maColorStops;
1297 aColorStops.front() = basegfx::BColorStop(maColorStops.front().getStopOffset(),
1298 mxFillGrad1->GetSelectEntryColor().getBColor());
1299 aColorStops.back() = basegfx::BColorStop(maColorStops.back().getStopOffset(),
1300 mxFillGrad2->GetSelectEntryColor().getBColor());
1302 else
1304 aColorStops.emplace_back(0.0, mxFillGrad1->GetSelectEntryColor().getBColor());
1305 aColorStops.emplace_back(1.0, mxFillGrad2->GetSelectEntryColor().getBColor());
1308 return aColorStops;
1314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */