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 .
20 #include <com/sun/star/ui/XDeck.hpp>
21 #include <com/sun/star/ui/XPanel.hpp>
22 #include "SlideBackground.hxx"
23 #include <TransitionPreset.hxx>
24 #include <sdresid.hxx>
25 #include <ViewShellBase.hxx>
26 #include <FrameView.hxx>
27 #include <DrawDocShell.hxx>
28 #include <SlideSorterViewShell.hxx>
29 #include <drawdoc.hxx>
31 #include <filedlg.hxx>
33 #include <optsitem.hxx>
34 #include "PageMarginUtils.hxx"
35 #include <strings.hrc>
36 #include <pageformatpanel.hrc>
37 #include "DocumentHelper.hxx"
38 #include "MasterPagesSelector.hxx"
39 #include <DrawViewShell.hxx>
40 #include <DrawController.hxx>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <svtools/controldims.hxx>
43 #include <svx/colorbox.hxx>
44 #include <svx/gallery.hxx>
45 #include <svx/drawitem.hxx>
46 #include <unotools/pathoptions.hxx>
47 #include <tools/urlobj.hxx>
48 #include <sfx2/sidebar/Theme.hxx>
50 #include <editeng/paperinf.hxx>
51 #include <svx/xflgrit.hxx>
52 #include <svx/rulritem.hxx>
53 #include <svx/svxids.hrc>
54 #include <svx/xflclit.hxx>
55 #include <svx/xgrad.hxx>
56 #include <svx/xbitmap.hxx>
57 #include <svx/xflbckit.hxx>
58 #include <svx/xbtmpit.hxx>
59 #include <svx/xflhtit.hxx>
60 #include <svx/svdpage.hxx>
61 #include <sfx2/bindings.hxx>
62 #include <sfx2/dispatch.hxx>
63 #include <sfx2/objface.hxx>
64 #include <svx/dlgutil.hxx>
65 #include <sfx2/tabdlg.hxx>
66 #include <sfx2/sidebar/Panel.hxx>
68 #include <EventMultiplexer.hxx>
69 #include <vcl/EnumContext.hxx>
71 #include <editeng/ulspitem.hxx>
72 #include <editeng/lrspitem.hxx>
73 #include <editeng/sizeitem.hxx>
74 #include <svl/itemset.hxx>
75 #include <comphelper/lok.hxx>
76 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
78 using namespace ::com::sun::star
;
80 using ::com::sun::star::uno::Reference
;
82 namespace sd
{ namespace sidebar
{
94 SlideBackground::SlideBackground(
97 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
98 SfxBindings
* pBindings
100 PanelLayout( pParent
, "SlideBackgroundPanel", "modules/simpress/ui/sidebarslidebackground.ui", rxFrame
),
102 maPaperSizeController(SID_ATTR_PAGE_SIZE
, *pBindings
, *this),
103 maPaperOrientationController(SID_ATTR_PAGE
, *pBindings
, *this),
104 maPaperMarginLRController(SID_ATTR_PAGE_LRSPACE
, *pBindings
, *this),
105 maPaperMarginULController(SID_ATTR_PAGE_ULSPACE
, *pBindings
, *this),
106 maBckColorController(SID_ATTR_PAGE_COLOR
, *pBindings
, *this),
107 maBckGradientController(SID_ATTR_PAGE_GRADIENT
, *pBindings
, *this),
108 maBckHatchController(SID_ATTR_PAGE_HATCH
, *pBindings
, *this),
109 maBckBitmapController(SID_ATTR_PAGE_BITMAP
, *pBindings
, *this),
110 maBckFillStyleController(SID_ATTR_PAGE_FILLSTYLE
, *pBindings
, *this),
111 maBckImageController(SID_SELECT_BACKGROUND
, *pBindings
, *this),
112 maDspBckController(SID_DISPLAY_MASTER_BACKGROUND
, *pBindings
, *this),
113 maDspObjController(SID_DISPLAY_MASTER_OBJECTS
, *pBindings
, *this),
114 maMetricController(SID_ATTR_METRIC
, *pBindings
, *this),
115 maCloseMasterController(SID_CLOSE_MASTER_VIEW
, *pBindings
, *this),
116 mpPageItem( new SvxPageItem(SID_ATTR_PAGE
) ),
121 mbSwitchModeToNormal(false),
122 mbSwitchModeToMaster(false),
125 maDrawOtherContext(vcl::EnumContext::Application::Draw
, vcl::EnumContext::Context::DrawPage
),
126 maDrawMasterContext(vcl::EnumContext::Application::Draw
, vcl::EnumContext::Context::MasterPage
),
127 maImpressOtherContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::DrawPage
),
128 maImpressMasterContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::MasterPage
),
129 maImpressHandoutContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::HandoutPage
),
130 maImpressNotesContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::NotesPage
),
132 mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE
) ),
133 mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE
) ),
134 m_nPageLeftMargin(0),
135 m_nPageRightMargin(0),
137 m_nPageBottomMargin(0),
139 mpBindings(pBindings
)
141 get(mpPaperSizeBox
,"paperformat");
142 get(mpPaperOrientation
, "orientation");
143 get(mpMasterSlide
, "masterslide");
144 //let the listbox shrink to any size so the sidebar isn't forced to grow to
145 //the size of the longest master slide name in the document
146 mpMasterSlide
->set_width_request(0);
147 get(mpBackgroundLabel
, "label3");
148 get(mpFillAttr
, "fillattr1");
149 get(mpFillGrad
, "fillattr2");
150 get(mpFillStyle
, "fillstyle");
151 get(mpFillLB
, "fillattr");
152 get(mpInsertImage
, "button2");
153 get(mpDspMasterBackground
, "displaymasterbackground");
154 get(mpDspMasterObjects
, "displaymasterobjects");
155 get(mpCloseMaster
, "closemasterslide");
156 get(mpEditMaster
, "masterslidebutton");
157 get(mpMasterLabel
, "masterlabel");
158 get(mpMarginSelectBox
, "marginLB");
160 ::sd::DrawDocShell
* pDocSh
= dynamic_cast<::sd::DrawDocShell
*>( SfxObjectShell::Current() );
161 SdDrawDocument
* pDoc
= pDocSh
? pDocSh
->GetDoc() : nullptr;
164 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(pDoc
->GetDocumentType());
167 FieldUnit eMetric
= static_cast<FieldUnit
>(pOptions
->GetMetric());
170 for (size_t i
= 0; i
< SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH
); ++i
)
171 mpMarginSelectBox
->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_INCH
[i
]));
175 for (size_t i
= 0; i
< SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM
); ++i
)
176 mpMarginSelectBox
->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_CM
[i
]));
181 maCustomEntry
= get
<FixedText
>("customlabel")->GetText();
187 SlideBackground::~SlideBackground()
192 bool SlideBackground::IsDraw()
194 return ( maContext
== maDrawMasterContext
||
195 maContext
== maDrawOtherContext
);
198 bool SlideBackground::IsImpress()
200 return ( maContext
== maImpressMasterContext
||
201 maContext
== maImpressOtherContext
||
202 maContext
== maImpressHandoutContext
||
203 maContext
== maImpressNotesContext
);
206 void SlideBackground::Initialize()
208 mpPaperSizeBox
->FillPaperSizeEntries( PaperSizeApp::Draw
);
209 mpPaperSizeBox
->SetSelectHdl(LINK(this,SlideBackground
,PaperSizeModifyHdl
));
210 mpPaperOrientation
->SetSelectHdl(LINK(this,SlideBackground
,PaperSizeModifyHdl
));
211 mpCloseMaster
->SetClickHdl(LINK(this, SlideBackground
, CloseMasterHdl
));
212 meUnit
= maPaperSizeController
.GetCoreMetric();
214 mpMasterSlide
->SetSelectHdl(LINK(this, SlideBackground
, AssignMasterPage
));
216 mpFillStyle
->SetSelectHdl(LINK(this, SlideBackground
, FillStyleModifyHdl
));
217 mpFillLB
->SetSelectHdl(LINK(this, SlideBackground
, FillColorHdl
));
218 mpFillGrad
->SetSelectHdl(LINK(this, SlideBackground
, FillColorHdl
));
219 mpFillAttr
->SetSelectHdl(LINK(this, SlideBackground
, FillBackgroundHdl
));
221 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
224 FrameView
*pFrameView
= pMainViewShell
->GetFrameView();
226 if ( pFrameView
->GetViewShEditMode() == EditMode::Page
)
228 SdPage
* mpPage
= pMainViewShell
->getCurrentPage();
229 populateMasterSlideDropdown();
231 OUString
aLayoutName( mpPage
->GetLayoutName() );
232 aLayoutName
= aLayoutName
.copy(0,aLayoutName
.indexOf(SD_LT_SEPARATOR
));
233 mpMasterSlide
->SelectEntry(aLayoutName
);
237 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(NONE
));
239 mpDspMasterBackground
->SetClickHdl(LINK(this, SlideBackground
, DspBackground
));
240 mpDspMasterObjects
->SetClickHdl(LINK(this,SlideBackground
, DspObjects
));
243 mpMarginSelectBox
->SetSelectHdl(LINK(this, SlideBackground
,ModifyMarginHdl
));
249 void SlideBackground::HandleContextChange(
250 const vcl::EnumContext
& rContext
)
252 if (maContext
== rContext
)
254 maContext
= rContext
;
258 mpMasterLabel
->SetText(SdResId(STR_MASTERSLIDE_LABEL
));
260 // margin selector is only for Draw
261 mpMarginSelectBox
->Hide();
262 VclPtr
<FixedText
> pMarginLabel
;
263 get(pMarginLabel
, "labelmargin");
265 pMarginLabel
->Hide();
267 if ( maContext
== maImpressMasterContext
)
269 mpCloseMaster
->Show();
270 mpEditMaster
->Hide();
271 mpMasterSlide
->Disable();
272 mpDspMasterBackground
->Disable();
273 mpDspMasterObjects
->Disable();
275 mpBackgroundLabel
->Hide();
276 mpInsertImage
->Show();
278 else if ( maContext
== maImpressHandoutContext
|| maContext
== maImpressNotesContext
)
280 mpCloseMaster
->Hide();
281 mpEditMaster
->Hide();
282 mpMasterSlide
->Disable();
283 mpDspMasterBackground
->Disable();
284 mpDspMasterObjects
->Disable();
286 mpBackgroundLabel
->Hide();
287 mpInsertImage
->Hide();
289 else if (maContext
== maImpressOtherContext
)
291 mpCloseMaster
->Hide();
292 mpEditMaster
->Show();
293 mpMasterSlide
->Enable();
294 mpDspMasterBackground
->Enable();
295 mpDspMasterObjects
->Enable();
297 mpBackgroundLabel
->Show();
298 mpInsertImage
->Show();
301 // Need to do a relayouting, otherwise the panel size is not updated after show / hide controls
302 sfx2::sidebar::Panel
* pPanel
= dynamic_cast<sfx2::sidebar::Panel
*>(GetParent());
304 pPanel
->TriggerDeckLayouting();
308 mpMasterLabel
->SetText(SdResId(STR_MASTERPAGE_LABEL
));
310 if (maContext
== maDrawOtherContext
)
312 mpEditMaster
->Hide();
314 mpBackgroundLabel
->Show();
316 else if (maContext
== maDrawMasterContext
)
319 mpBackgroundLabel
->Hide();
324 void SlideBackground::Update()
326 eFillStyle nPos
= static_cast<eFillStyle
>(mpFillStyle
->GetSelectedEntryPos());
328 if(maContext
!= maImpressOtherContext
&& maContext
!= maDrawOtherContext
)
331 SfxObjectShell
* pSh
= SfxObjectShell::Current();
349 const Color aColor
= GetColorSetOrDefault();
350 mpFillLB
->SelectEntry(aColor
);
359 const XGradient xGradient
= GetGradientSetOrDefault();
360 const Color aStartColor
= xGradient
.GetStartColor();
361 mpFillLB
->SelectEntry(aStartColor
);
362 const Color aEndColor
= xGradient
.GetEndColor();
363 mpFillGrad
->SelectEntry(aEndColor
);
372 mpFillAttr
->Fill(pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
375 const OUString aHatchName
= GetHatchingSetOrDefault();
376 mpFillAttr
->SelectEntry( aHatchName
);
390 mpFillAttr
->Fill(pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
391 aName
= GetBitmapSetOrDefault();
393 else if(nPos
== PATTERN
)
395 mpFillAttr
->Fill(pSh
->GetItem(SID_PATTERN_LIST
)->GetPatternList());
396 aName
= GetPatternSetOrDefault();
398 mpFillAttr
->SelectEntry( aName
);
406 void SlideBackground::UpdateMarginBox()
408 m_nPageLeftMargin
= mpPageLRMarginItem
->GetLeft();
409 m_nPageRightMargin
= mpPageLRMarginItem
->GetRight();
410 m_nPageTopMargin
= mpPageULMarginItem
->GetUpper();
411 m_nPageBottomMargin
= mpPageULMarginItem
->GetLower();
413 if( IsNone(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
415 mpMarginSelectBox
->SelectEntryPos(0);
416 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
418 else if( IsNarrow(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
420 mpMarginSelectBox
->SelectEntryPos(1);
421 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
423 else if( IsModerate(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
425 mpMarginSelectBox
->SelectEntryPos(2);
426 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
428 else if( IsNormal075(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
430 mpMarginSelectBox
->SelectEntryPos(3);
431 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
433 else if( IsNormal100(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
435 mpMarginSelectBox
->SelectEntryPos(4);
436 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
438 else if( IsNormal125(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
440 mpMarginSelectBox
->SelectEntryPos(5);
441 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
443 else if( IsWide(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
445 mpMarginSelectBox
->SelectEntryPos(6);
446 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
450 if(mpMarginSelectBox
->GetEntryPos(maCustomEntry
) == LISTBOX_ENTRY_NOTFOUND
)
451 mpMarginSelectBox
->InsertEntry(maCustomEntry
);
452 mpMarginSelectBox
->SelectEntry(maCustomEntry
);
456 void SlideBackground::SetPanelTitle( const OUString
& rTitle
)
458 Reference
<frame::XController2
> xController( mxFrame
->getController(), uno::UNO_QUERY
);
459 if ( !xController
.is() )
462 Reference
<ui::XSidebarProvider
> xSidebarProvider( xController
->getSidebar(), uno::UNO_QUERY
);
463 if ( !xSidebarProvider
.is() )
466 Reference
<ui::XDecks
> xDecks ( xSidebarProvider
->getDecks(), uno::UNO_QUERY
);
470 Reference
<ui::XDeck
> xDeck ( xDecks
->getByName("PropertyDeck"), uno::UNO_QUERY
);
474 Reference
<ui::XPanels
> xPanels ( xDeck
->getPanels(), uno::UNO_QUERY
);
478 if (xPanels
->hasByName("SlideBackgroundPanel"))
480 Reference
<ui::XPanel
> xPanel ( xPanels
->getByName("SlideBackgroundPanel"), uno::UNO_QUERY
);
484 xPanel
->setTitle( rTitle
);
488 void SlideBackground::addListener()
490 Link
<tools::EventMultiplexerEvent
&,void> aLink( LINK(this, SlideBackground
, EventMultiplexerListener
) );
491 mrBase
.GetEventMultiplexer()->AddEventListener( aLink
);
494 void SlideBackground::removeListener()
496 Link
<tools::EventMultiplexerEvent
&,void> aLink( LINK(this, SlideBackground
, EventMultiplexerListener
) );
497 mrBase
.GetEventMultiplexer()->RemoveEventListener( aLink
);
500 IMPL_LINK(SlideBackground
, EventMultiplexerListener
,
501 tools::EventMultiplexerEvent
&, rEvent
, void)
503 switch (rEvent
.meEventId
)
505 // add more events as per requirement
506 // Master Page change triggers a shape change event. Solves sync problem.
507 case EventMultiplexerEventId::ShapeChanged
:
508 populateMasterSlideDropdown();
510 case EventMultiplexerEventId::EditModeNormal
:
511 mbSwitchModeToNormal
= true;
513 case EventMultiplexerEventId::EditModeMaster
:
514 mbSwitchModeToMaster
= true;
516 case EventMultiplexerEventId::EditViewSelection
:
517 case EventMultiplexerEventId::EndTextEdit
:
519 if ( mbSwitchModeToMaster
)
522 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME
));
524 SetPanelTitle(SdResId(STR_MASTERPAGE_NAME
));
525 mbSwitchModeToMaster
= false;
527 else if ( mbSwitchModeToNormal
)
530 SetPanelTitle(SdResId(STR_SLIDE_NAME
));
532 SetPanelTitle(SdResId(STR_PAGE_NAME
));
533 mbSwitchModeToNormal
= false;
538 case EventMultiplexerEventId::CurrentPageChanged
:
540 static const sal_uInt16 SidArray
[] = {
542 SID_ATTR_PAGE_GRADIENT
,
544 SID_ATTR_PAGE_BITMAP
,
545 SID_ATTR_PAGE_FILLSTYLE
,
546 SID_DISPLAY_MASTER_BACKGROUND
,
547 SID_DISPLAY_MASTER_OBJECTS
,
549 updateMasterSlideSelection();
550 GetBindings()->Invalidate( SidArray
);
553 case EventMultiplexerEventId::ViewAdded
:
559 mpCloseMaster
->Hide();
560 mpEditMaster
->Hide();
561 if( maContext
== maDrawMasterContext
)
562 SetPanelTitle(SdResId(STR_MASTERPAGE_NAME
));
564 SetPanelTitle(SdResId(STR_PAGE_NAME
));
566 else if ( maContext
== maImpressOtherContext
|| maContext
== maImpressMasterContext
)
568 if( maContext
== maImpressMasterContext
)
569 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME
));
571 SetPanelTitle(SdResId(STR_SLIDE_NAME
));
573 else if ( maContext
== maImpressNotesContext
)
575 mpMasterLabel
->SetText(SdResId(STR_MASTERSLIDE_LABEL
));
576 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
580 DrawViewShell
* pDrawViewShell
= static_cast<DrawViewShell
*>(pMainViewShell
);
581 if ( pDrawViewShell
->GetEditMode() == EditMode::MasterPage
)
582 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME
));
583 else // EditMode::Page
584 SetPanelTitle(SdResId(STR_SLIDE_NAME
));
596 void SlideBackground::populateMasterSlideDropdown()
598 mpMasterSlide
->Clear();
599 ::sd::DrawDocShell
* pDocSh
= dynamic_cast<::sd::DrawDocShell
*>( SfxObjectShell::Current() );
600 SdDrawDocument
* pDoc
= pDocSh
? pDocSh
->GetDoc() : nullptr;
601 sal_uInt16 nCount
= pDoc
? pDoc
->GetMasterPageCount() : 0;
602 for( sal_uInt16 nLayout
= 0; nLayout
< nCount
; nLayout
++ )
604 SdPage
* pMaster
= static_cast<SdPage
*>(pDoc
->GetMasterPage(nLayout
));
605 if( pMaster
->GetPageKind() == PageKind::Standard
)
607 OUString
aLayoutName(pMaster
->GetLayoutName());
608 aLayoutName
= aLayoutName
.copy(0,aLayoutName
.indexOf(SD_LT_SEPARATOR
));
609 mpMasterSlide
->InsertEntry(aLayoutName
);
612 updateMasterSlideSelection();
615 void SlideBackground::updateMasterSlideSelection()
617 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
618 SdPage
* pPage
= pMainViewShell
? pMainViewShell
->getCurrentPage() : nullptr;
619 if (pPage
!= nullptr && pPage
->TRG_HasMasterPage())
621 SdrPage
& rMasterPage (pPage
->TRG_GetMasterPage());
622 SdPage
* pMasterPage
= static_cast<SdPage
*>(&rMasterPage
);
623 mpMasterSlide
->SelectEntry(pMasterPage
->GetName());
627 void SlideBackground::dispose()
631 mpPaperSizeBox
.clear();
632 mpPaperOrientation
.clear();
633 mpMasterSlide
.clear();
634 mpBackgroundLabel
.clear();
639 mpInsertImage
.clear();
640 mpMarginSelectBox
.disposeAndClear();
641 mpDspMasterBackground
.clear();
642 mpDspMasterObjects
.clear();
643 mpMasterLabel
.clear();
644 mpEditMaster
.clear();
645 mpCloseMaster
.clear();
647 m_pContainer
.clear();
649 maPaperSizeController
.dispose();
650 maPaperOrientationController
.dispose();
651 maPaperMarginLRController
.dispose();
652 maPaperMarginULController
.dispose();
653 maBckColorController
.dispose();
654 maBckGradientController
.dispose();
655 maBckHatchController
.dispose();
656 maBckBitmapController
.dispose();
657 maBckFillStyleController
.dispose();
658 maBckImageController
.dispose();
659 maDspBckController
.dispose();
660 maDspObjController
.dispose();
661 maMetricController
.dispose();
662 maCloseMasterController
.dispose();
667 mpBitmapItem
.reset();
668 mpPageLRMarginItem
.reset();
669 mpPageULMarginItem
.reset();
670 PanelLayout::dispose();
673 void SlideBackground::ExecuteMarginLRChange(const long mnPageLeftMargin
, const long mnPageRightMargin
)
675 mpPageLRMarginItem
->SetLeft(mnPageLeftMargin
);
676 mpPageLRMarginItem
->SetRight(mnPageRightMargin
);
677 GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE
, SfxCallMode::RECORD
, { mpPageLRMarginItem
.get() } );
680 void SlideBackground::ExecuteMarginULChange(const long mnPageTopMargin
, const long mnPageBottomMargin
)
682 mpPageULMarginItem
->SetUpper(mnPageTopMargin
);
683 mpPageULMarginItem
->SetLower(mnPageBottomMargin
);
684 GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE
, SfxCallMode::RECORD
, { mpPageULMarginItem
.get() } );
687 Color
const & SlideBackground::GetColorSetOrDefault()
689 // Tango Sky Blue 1, to be consistent w/ area fill panel (b/c COL_AUTO for slides is transparent)
691 mpColorItem
.reset( new XFillColorItem( OUString(), Color(0x72, 0x9f, 0xcf) ) );
693 return mpColorItem
->GetColorValue();
696 XGradient
const & SlideBackground::GetGradientSetOrDefault()
698 if( !mpGradientItem
)
700 SfxObjectShell
* pSh
= SfxObjectShell::Current();
701 const SvxGradientListItem
* pGradListItem
= pSh
->GetItem(SID_GRADIENT_LIST
);
702 const XGradient aGradient
= pGradListItem
->GetGradientList()->GetGradient(0)->GetGradient();
703 const OUString aGradientName
= pGradListItem
->GetGradientList()->GetGradient(0)->GetName();
705 mpGradientItem
.reset( new XFillGradientItem( aGradientName
, aGradient
) );
708 return mpGradientItem
->GetGradientValue();
711 OUString
const & SlideBackground::GetHatchingSetOrDefault()
715 SfxObjectShell
* pSh
= SfxObjectShell::Current();
716 const SvxHatchListItem
* pHatchListItem
= pSh
->GetItem(SID_HATCH_LIST
);
717 const XHatch aHatch
= pHatchListItem
->GetHatchList()->GetHatch(0)->GetHatch();
718 const OUString aHatchName
= pHatchListItem
->GetHatchList()->GetHatch(0)->GetName();
720 mpHatchItem
.reset( new XFillHatchItem( aHatchName
, aHatch
) );
723 return mpHatchItem
->GetName();
726 OUString
const & SlideBackground::GetBitmapSetOrDefault()
728 if( !mpBitmapItem
|| mpBitmapItem
->isPattern())
730 SfxObjectShell
* pSh
= SfxObjectShell::Current();
731 const SvxBitmapListItem
* pBmpListItem
= pSh
->GetItem(SID_BITMAP_LIST
);
732 const GraphicObject aGraphObj
= pBmpListItem
->GetBitmapList()->GetBitmap(0)->GetGraphicObject();
733 const OUString aBmpName
= pBmpListItem
->GetBitmapList()->GetBitmap(0)->GetName();
735 mpBitmapItem
.reset( new XFillBitmapItem( aBmpName
, aGraphObj
) );
738 return mpBitmapItem
->GetName();
741 OUString
const & SlideBackground::GetPatternSetOrDefault()
743 if( !mpBitmapItem
|| !(mpBitmapItem
->isPattern()))
745 SfxObjectShell
* pSh
= SfxObjectShell::Current();
746 const SvxPatternListItem
* pPtrnListItem
= pSh
->GetItem(SID_PATTERN_LIST
);
747 const GraphicObject aGraphObj
= pPtrnListItem
->GetPatternList()->GetBitmap(0)->GetGraphicObject();
748 const OUString aPtrnName
= pPtrnListItem
->GetPatternList()->GetBitmap(0)->GetName();
750 mpBitmapItem
.reset( new XFillBitmapItem( aPtrnName
, aGraphObj
) );
753 return mpBitmapItem
->GetName();
756 void SlideBackground::DataChanged (const DataChangedEvent
& /*rEvent*/)
761 void SlideBackground::NotifyItemUpdate(
762 const sal_uInt16 nSID
,
763 const SfxItemState eState
,
764 const SfxPoolItem
* pState
,
770 case SID_ATTR_PAGE_COLOR
:
772 if(eState
>= SfxItemState::DEFAULT
)
774 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(SOLID
));
775 mpColorItem
.reset(pState
? static_cast< XFillColorItem
* >(pState
->Clone()) : nullptr);
781 case SID_ATTR_PAGE_HATCH
:
783 if(eState
>= SfxItemState::DEFAULT
)
785 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(HATCH
));
786 mpHatchItem
.reset(pState
? static_cast < XFillHatchItem
* >(pState
->Clone()) : nullptr);
792 case SID_ATTR_PAGE_GRADIENT
:
794 if(eState
>= SfxItemState::DEFAULT
)
796 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(GRADIENT
));
797 mpGradientItem
.reset(pState
? static_cast< XFillGradientItem
* >(pState
->Clone()) : nullptr);
802 case SID_ATTR_PAGE_BITMAP
:
804 if(eState
>= SfxItemState::DEFAULT
)
806 mpBitmapItem
.reset(pState
? static_cast< XFillBitmapItem
* >(pState
->Clone()) : nullptr);
809 if(mpBitmapItem
->isPattern())
810 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(PATTERN
));
812 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
815 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
821 case SID_ATTR_PAGE_FILLSTYLE
:
823 const XFillStyleItem
* pFillStyleItem
= nullptr;
824 if (eState
>= SfxItemState::DEFAULT
)
825 pFillStyleItem
= dynamic_cast< const XFillStyleItem
* >(pState
);
828 css::drawing::FillStyle eXFS
= pFillStyleItem
->GetValue();
831 case drawing::FillStyle_NONE
:
832 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(NONE
));
834 case drawing::FillStyle_SOLID
:
835 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(SOLID
));
837 case drawing::FillStyle_GRADIENT
:
838 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(GRADIENT
));
840 case drawing::FillStyle_HATCH
:
841 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(HATCH
));
843 case drawing::FillStyle_BITMAP
:
845 if(mpBitmapItem
->isPattern())
846 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(PATTERN
));
848 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
859 case SID_ATTR_PAGE_SIZE
:
861 const SvxSizeItem
* pSizeItem
= nullptr;
862 if (eState
>= SfxItemState::DEFAULT
)
863 pSizeItem
= dynamic_cast<const SvxSizeItem
*>(pState
);
866 Size aPaperSize
= pSizeItem
->GetSize();
867 if(mpPaperOrientation
->GetSelectedEntryPos() == 0)
870 Paper ePaper
= SvxPaperInfo::GetSvxPaper(aPaperSize
, meUnit
);
871 mpPaperSizeBox
->SetSelection( ePaper
);
878 const SvxPageItem
* pPageItem
= nullptr;
879 if (eState
>= SfxItemState::DEFAULT
)
880 pPageItem
= dynamic_cast<const SvxPageItem
*>(pState
);
883 mpPageItem
.reset(static_cast<SvxPageItem
*>(pPageItem
->Clone()));
884 bool bIsLandscape
= mpPageItem
->IsLandscape();
885 mpPaperOrientation
->SelectEntryPos( bIsLandscape
? 0 : 1 );
890 case SID_ATTR_PAGE_LRSPACE
:
892 const SvxLongLRSpaceItem
* pLRItem
= nullptr;
893 if (eState
>= SfxItemState::DEFAULT
)
894 pLRItem
= dynamic_cast<const SvxLongLRSpaceItem
*>(pState
);
897 mpPageLRMarginItem
.reset( static_cast<SvxLongLRSpaceItem
*>(pState
->Clone()) );
903 case SID_ATTR_PAGE_ULSPACE
:
905 const SvxLongULSpaceItem
* pULItem
= nullptr;
906 if (eState
>= SfxItemState::DEFAULT
)
907 pULItem
= dynamic_cast<const SvxLongULSpaceItem
*>(pState
);
910 mpPageULMarginItem
.reset( static_cast<SvxLongULSpaceItem
*>(pState
->Clone()) );
916 case SID_DISPLAY_MASTER_BACKGROUND
:
918 const SfxBoolItem
* pBoolItem
= nullptr;
919 if (eState
>= SfxItemState::DEFAULT
)
920 pBoolItem
= dynamic_cast< const SfxBoolItem
* >(pState
);
922 mpDspMasterBackground
->Check(pBoolItem
->GetValue());
925 case SID_DISPLAY_MASTER_OBJECTS
:
927 const SfxBoolItem
* pBoolItem
= nullptr;
928 if (eState
>= SfxItemState::DEFAULT
)
929 pBoolItem
= dynamic_cast< const SfxBoolItem
* >(pState
);
931 mpDspMasterObjects
->Check(pBoolItem
->GetValue());
934 case SID_SELECT_BACKGROUND
:
936 if(eState
>= SfxItemState::DEFAULT
)
938 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
948 IMPL_LINK_NOARG(SlideBackground
, FillStyleModifyHdl
, ListBox
&, void)
950 const eFillStyle nPos
= static_cast<eFillStyle
>(mpFillStyle
->GetSelectedEntryPos());
957 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_NONE
);
958 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_FILLSTYLE
, SfxCallMode::RECORD
, { &aXFillStyleItem
});
964 const XFillColorItem
aItem( OUString(), mpColorItem
->GetColorValue() );
965 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR
, SfxCallMode::RECORD
, { &aItem
});
971 const XFillGradientItem
aItem( mpGradientItem
->GetName(), mpGradientItem
->GetGradientValue() );
972 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT
, SfxCallMode::RECORD
, { &aItem
});
978 const XFillHatchItem
aItem( mpHatchItem
->GetName(), mpHatchItem
->GetHatchValue() );
979 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH
, SfxCallMode::RECORD
, { &aItem
});
986 const XFillBitmapItem
aItem( mpBitmapItem
->GetName(), mpBitmapItem
->GetGraphicObject() );
987 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP
, SfxCallMode::RECORD
, { &aItem
});
994 mpFillStyle
->Selected();
997 IMPL_LINK_NOARG(SlideBackground
, PaperSizeModifyHdl
, ListBox
&, void)
999 const Paper ePaper
= mpPaperSizeBox
->GetSelection();
1000 Size
aSize(SvxPaperInfo::GetPaperSize(ePaper
, meUnit
));
1002 if (mpPaperOrientation
->GetSelectedEntryPos() == 0)
1005 mpPageItem
->SetLandscape(mpPaperOrientation
->GetSelectedEntryPos() == 0);
1006 const SvxSizeItem
aSizeItem(SID_ATTR_PAGE_SIZE
, aSize
);
1007 // Page/slide properties dialog (FuPage::ExecuteDialog and ::ApplyItemSet) misuses
1008 // SID_ATTR_PAGE_EXT1 to distinguish between Impress and Draw, as for whether to fit
1009 // objects to paper size. Until that is handled somehow better, we do the same here
1010 const SfxBoolItem
aFitObjs(SID_ATTR_PAGE_EXT1
, IsImpress());
1012 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE
, SfxCallMode::RECORD
,
1013 { &aSizeItem
, mpPageItem
.get(), &aFitObjs
});
1015 // Notify LOK clients of the page size chagne.
1016 if (comphelper::LibreOfficeKit::isActive())
1018 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
1021 pViewShell
->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED
, "");
1022 pViewShell
= SfxViewShell::GetNext(*pViewShell
);
1027 IMPL_LINK_NOARG(SlideBackground
, FillColorHdl
, SvxColorListBox
&, void)
1029 const drawing::FillStyle eXFS
= static_cast<drawing::FillStyle
>(mpFillStyle
->GetSelectedEntryPos());
1032 case drawing::FillStyle_SOLID
:
1034 XFillColorItem
aItem(OUString(), mpFillLB
->GetSelectEntryColor());
1035 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR
, SfxCallMode::RECORD
, { &aItem
});
1038 case drawing::FillStyle_GRADIENT
:
1040 XGradient aGradient
;
1041 aGradient
.SetStartColor(mpFillLB
->GetSelectEntryColor());
1042 aGradient
.SetEndColor(mpFillGrad
->GetSelectEntryColor());
1044 // the name doesn't really matter, it'll be converted to unique one eventually,
1045 // but it has to be non-empty
1046 XFillGradientItem
aItem("gradient", aGradient
);
1047 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT
, SfxCallMode::RECORD
, { &aItem
});
1055 IMPL_LINK_NOARG(SlideBackground
, FillBackgroundHdl
, ListBox
&, void)
1057 const eFillStyle nFillPos
= static_cast<eFillStyle
>(mpFillStyle
->GetSelectedEntryPos());
1058 SfxObjectShell
* pSh
= SfxObjectShell::Current();
1064 const SvxHatchListItem
* pHatchListItem
= pSh
->GetItem(SID_HATCH_LIST
);
1065 sal_uInt16 nPos
= mpFillAttr
->GetSelectedEntryPos();
1066 XHatch aHatch
= pHatchListItem
->GetHatchList()->GetHatch(nPos
)->GetHatch();
1067 const OUString aHatchName
= pHatchListItem
->GetHatchList()->GetHatch(nPos
)->GetName();
1069 XFillHatchItem
aItem(aHatchName
, aHatch
);
1070 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH
, SfxCallMode::RECORD
, { &aItem
});
1077 sal_Int16 nPos
= mpFillAttr
->GetSelectedEntryPos();
1078 GraphicObject aBitmap
;
1080 if( nFillPos
== BITMAP
)
1082 SvxBitmapListItem
const * pBitmapListItem
= pSh
->GetItem(SID_BITMAP_LIST
);
1083 aBitmap
= pBitmapListItem
->GetBitmapList()->GetBitmap(nPos
)->GetGraphicObject();
1084 aName
= pBitmapListItem
->GetBitmapList()->GetBitmap(nPos
)->GetName();
1086 else if( nFillPos
== PATTERN
)
1088 SvxPatternListItem
const * pPatternListItem
= pSh
->GetItem(SID_PATTERN_LIST
);
1089 aBitmap
= pPatternListItem
->GetPatternList()->GetBitmap(nPos
)->GetGraphicObject();
1090 aName
= pPatternListItem
->GetPatternList()->GetBitmap(nPos
)->GetName();
1092 XFillBitmapItem
aItem(aName
, aBitmap
);
1093 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP
, SfxCallMode::RECORD
, { &aItem
});
1102 IMPL_LINK_NOARG(SlideBackground
, AssignMasterPage
, ListBox
&, void)
1104 ::sd::DrawDocShell
* pDocSh
= dynamic_cast<::sd::DrawDocShell
*>( SfxObjectShell::Current() );
1105 SdDrawDocument
* pDoc
= pDocSh
? pDocSh
->GetDoc() : nullptr;
1108 sal_uInt16 nSelectedPage
= SDRPAGE_NOTFOUND
;
1109 for( sal_uInt16 nPage
= 0; nPage
< pDoc
->GetSdPageCount(PageKind::Standard
); nPage
++ )
1111 if (pDoc
->GetSdPage(nPage
,PageKind::Standard
)->IsSelected())
1113 nSelectedPage
= nPage
;
1117 OUString
aLayoutName(mpMasterSlide
->GetSelectedEntry());
1118 pDoc
->SetMasterPage(nSelectedPage
, aLayoutName
, pDoc
, false, false);
1121 IMPL_LINK_NOARG(SlideBackground
, CloseMasterHdl
, Button
*, void)
1123 GetBindings()->GetDispatcher()->Execute( SID_CLOSE_MASTER_VIEW
, SfxCallMode::RECORD
);
1126 IMPL_LINK_NOARG(SlideBackground
, DspBackground
, Button
*, void)
1128 bool IsChecked
= mpDspMasterBackground
->IsChecked();
1129 const SfxBoolItem
aBoolItem(SID_DISPLAY_MASTER_BACKGROUND
, IsChecked
);
1130 GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_BACKGROUND
, SfxCallMode::RECORD
, { &aBoolItem
});
1133 IMPL_LINK_NOARG(SlideBackground
, DspObjects
, Button
*, void)
1135 bool IsChecked
= mpDspMasterObjects
->IsChecked();
1136 const SfxBoolItem
aBoolItem(SID_DISPLAY_MASTER_OBJECTS
,IsChecked
);
1137 GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_OBJECTS
, SfxCallMode::RECORD
, { &aBoolItem
, &aBoolItem
});
1140 IMPL_LINK_NOARG( SlideBackground
, ModifyMarginHdl
, ListBox
&, void )
1142 bool bApplyNewPageMargins
= true;
1143 switch ( mpMarginSelectBox
->GetSelectedEntryPos() )
1146 SetNone(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1149 SetNarrow(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1152 SetModerate(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1155 SetNormal075(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1158 SetNormal100(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1161 SetNormal125(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1164 SetWide(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1167 bApplyNewPageMargins
= false;
1171 if(bApplyNewPageMargins
)
1173 ExecuteMarginLRChange(m_nPageLeftMargin
, m_nPageRightMargin
);
1174 ExecuteMarginULChange(m_nPageTopMargin
, m_nPageBottomMargin
);
1180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */