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>
30 #include <filedlg.hxx>
31 #include "PageMarginUtils.hxx"
32 #include <strings.hrc>
33 #include "DocumentHelper.hxx"
34 #include "MasterPagesSelector.hxx"
35 #include <DrawViewShell.hxx>
36 #include <DrawController.hxx>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <svtools/controldims.hxx>
39 #include <svx/colorbox.hxx>
40 #include <svx/gallery.hxx>
41 #include <svx/drawitem.hxx>
42 #include <unotools/pathoptions.hxx>
43 #include <tools/urlobj.hxx>
44 #include <sfx2/sidebar/Theme.hxx>
46 #include <editeng/paperinf.hxx>
47 #include <svx/rulritem.hxx>
48 #include <svx/svxids.hrc>
49 #include <svx/xflclit.hxx>
50 #include <svx/xgrad.hxx>
51 #include <svx/xbitmap.hxx>
52 #include <svx/xflbckit.hxx>
53 #include <svx/xbtmpit.hxx>
54 #include <svx/xattr.hxx>
55 #include <svx/xflhtit.hxx>
56 #include <svx/svdpage.hxx>
57 #include <sfx2/bindings.hxx>
58 #include <sfx2/dispatch.hxx>
59 #include <sfx2/objface.hxx>
60 #include <svx/dlgutil.hxx>
61 #include <sfx2/tabdlg.hxx>
62 #include <sfx2/sidebar/Panel.hxx>
64 #include <EventMultiplexer.hxx>
65 #include <vcl/salbtype.hxx>
66 #include <vcl/EnumContext.hxx>
68 #include <editeng/ulspitem.hxx>
69 #include <editeng/lrspitem.hxx>
70 #include <svl/itemset.hxx>
72 using namespace ::com::sun::star
;
74 using ::com::sun::star::uno::Reference
;
76 namespace sd
{ namespace sidebar
{
88 SlideBackground::SlideBackground(
91 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
92 SfxBindings
* pBindings
94 PanelLayout( pParent
, "SlideBackgroundPanel", "modules/simpress/ui/sidebarslidebackground.ui", rxFrame
),
96 maPaperSizeController(SID_ATTR_PAGE_SIZE
, *pBindings
, *this),
97 maPaperOrientationController(SID_ATTR_PAGE
, *pBindings
, *this),
98 maPaperMarginLRController(SID_ATTR_PAGE_LRSPACE
, *pBindings
, *this),
99 maPaperMarginULController(SID_ATTR_PAGE_ULSPACE
, *pBindings
, *this),
100 maBckColorController(SID_ATTR_PAGE_COLOR
, *pBindings
, *this),
101 maBckGradientController(SID_ATTR_PAGE_GRADIENT
, *pBindings
, *this),
102 maBckHatchController(SID_ATTR_PAGE_HATCH
, *pBindings
, *this),
103 maBckBitmapController(SID_ATTR_PAGE_BITMAP
, *pBindings
, *this),
104 maBckFillStyleController(SID_ATTR_PAGE_FILLSTYLE
, *pBindings
, *this),
105 maBckImageController(SID_SELECT_BACKGROUND
, *pBindings
, *this),
106 maDspBckController(SID_DISPLAY_MASTER_BACKGROUND
, *pBindings
, *this),
107 maDspObjController(SID_DISPLAY_MASTER_OBJECTS
, *pBindings
, *this),
108 maMetricController(SID_ATTR_METRIC
, *pBindings
, *this),
109 maCloseMasterController(SID_CLOSE_MASTER_VIEW
, *pBindings
, *this),
110 mpPageItem( new SvxPageItem(SID_ATTR_PAGE
) ),
115 mbEditModeChangePending(false),
118 maDrawOtherContext(vcl::EnumContext::Application::Draw
, vcl::EnumContext::Context::DrawPage
),
119 maDrawMasterContext(vcl::EnumContext::Application::Draw
, vcl::EnumContext::Context::MasterPage
),
120 maImpressOtherContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::DrawPage
),
121 maImpressMasterContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::MasterPage
),
122 maImpressHandoutContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::HandoutPage
),
123 maImpressNotesContext(vcl::EnumContext::Application::Impress
, vcl::EnumContext::Context::NotesPage
),
125 mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE
) ),
126 mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE
) ),
127 m_nPageLeftMargin(0),
128 m_nPageRightMargin(0),
130 m_nPageBottomMargin(0),
132 mpBindings(pBindings
)
134 get(mpPaperSizeBox
,"paperformat");
135 get(mpPaperOrientation
, "orientation");
136 get(mpMasterSlide
, "masterslide");
137 //let the listbox shrink to any size so the sidebar isn't forced to grow to
138 //the size of the longest master slide name in the document
139 mpMasterSlide
->set_width_request(0);
140 get(mpBackgroundLabel
, "label3");
141 get(mpFillAttr
, "fillattr1");
142 get(mpFillGrad
, "fillattr2");
143 get(mpFillStyle
, "fillstyle");
144 get(mpFillLB
, "fillattr");
145 get(mpInsertImage
, "button2");
146 get(mpDspMasterBackground
, "displaymasterbackground");
147 get(mpDspMasterObjects
, "displaymasterobjects");
148 get(mpCloseMaster
, "closemasterslide");
149 get(mpEditMaster
, "masterslidebutton");
150 get(mpMasterLabel
, "masterlabel");
151 get(mpMarginSelectBox
, "marginLB");
153 maCustomEntry
= get
<FixedText
>("customlabel")->GetText();
159 SlideBackground::~SlideBackground()
164 bool SlideBackground::IsDraw()
166 return ( maContext
== maDrawMasterContext
||
167 maContext
== maDrawOtherContext
);
170 bool SlideBackground::IsImpress()
172 return ( maContext
== maImpressMasterContext
||
173 maContext
== maImpressOtherContext
||
174 maContext
== maImpressHandoutContext
||
175 maContext
== maImpressNotesContext
);
178 void SlideBackground::Initialize()
180 mpPaperSizeBox
->FillPaperSizeEntries( PaperSizeApp::Draw
);
181 mpPaperSizeBox
->SetSelectHdl(LINK(this,SlideBackground
,PaperSizeModifyHdl
));
182 mpPaperOrientation
->SetSelectHdl(LINK(this,SlideBackground
,PaperSizeModifyHdl
));
183 mpCloseMaster
->SetClickHdl(LINK(this, SlideBackground
, CloseMasterHdl
));
184 meUnit
= maPaperSizeController
.GetCoreMetric();
186 mpMasterSlide
->SetSelectHdl(LINK(this, SlideBackground
, AssignMasterPage
));
188 mpFillStyle
->SetSelectHdl(LINK(this, SlideBackground
, FillStyleModifyHdl
));
189 mpFillLB
->SetSelectHdl(LINK(this, SlideBackground
, FillColorHdl
));
190 mpFillGrad
->SetSelectHdl(LINK(this, SlideBackground
, FillColorHdl
));
191 mpFillAttr
->SetSelectHdl(LINK(this, SlideBackground
, FillBackgroundHdl
));
193 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
196 FrameView
*pFrameView
= pMainViewShell
->GetFrameView();
198 if ( pFrameView
->GetViewShEditMode() == EditMode::Page
)
200 SdPage
* mpPage
= pMainViewShell
->getCurrentPage();
201 populateMasterSlideDropdown();
203 OUString
aLayoutName( mpPage
->GetLayoutName() );
204 aLayoutName
= aLayoutName
.copy(0,aLayoutName
.indexOf(SD_LT_SEPARATOR
));
205 mpMasterSlide
->SelectEntry(aLayoutName
);
209 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(NONE
));
211 mpDspMasterBackground
->SetClickHdl(LINK(this, SlideBackground
, DspBackground
));
212 mpDspMasterObjects
->SetClickHdl(LINK(this,SlideBackground
, DspObjects
));
215 mpMarginSelectBox
->SetSelectHdl(LINK(this, SlideBackground
,ModifyMarginHdl
));
221 void SlideBackground::HandleContextChange(
222 const vcl::EnumContext
& rContext
)
224 if (maContext
== rContext
)
226 maContext
= rContext
;
230 mpMasterLabel
->SetText(SdResId(STR_MASTERSLIDE_LABEL
));
232 // margin selector is only for Draw
233 mpMarginSelectBox
->Hide();
234 VclPtr
<FixedText
> pMarginLabel
;
235 get(pMarginLabel
, "labelmargin");
237 pMarginLabel
->Hide();
239 if ( maContext
== maImpressMasterContext
)
241 mpCloseMaster
->Show();
242 mpEditMaster
->Hide();
243 mpMasterSlide
->Disable();
244 mpDspMasterBackground
->Disable();
245 mpDspMasterObjects
->Disable();
247 mpBackgroundLabel
->Show();
248 mpInsertImage
->Show();
250 else if ( maContext
== maImpressHandoutContext
)
252 mpCloseMaster
->Hide();
253 mpEditMaster
->Hide();
254 mpMasterSlide
->Disable();
255 mpDspMasterBackground
->Disable();
256 mpDspMasterObjects
->Disable();
258 mpBackgroundLabel
->Hide();
259 mpInsertImage
->Hide();
261 else if (maContext
== maImpressOtherContext
)
263 mpCloseMaster
->Hide();
264 mpEditMaster
->Show();
265 mpMasterSlide
->Enable();
266 mpDspMasterBackground
->Enable();
267 mpDspMasterObjects
->Enable();
269 mpBackgroundLabel
->Show();
270 mpInsertImage
->Show();
272 else if (maContext
== maImpressNotesContext
)
274 mpCloseMaster
->Hide();
275 mpEditMaster
->Hide();
276 mpMasterSlide
->Disable();
277 mpDspMasterBackground
->Disable();
278 mpDspMasterObjects
->Disable();
280 mpBackgroundLabel
->Show();
281 mpInsertImage
->Hide();
283 // Need to do a relayouting, otherwise the panel size is not updated after show / hide controls
284 sfx2::sidebar::Panel
* pPanel
= dynamic_cast<sfx2::sidebar::Panel
*>(GetParent());
286 pPanel
->TriggerDeckLayouting();
290 mpMasterLabel
->SetText(SdResId(STR_MASTERPAGE_LABEL
));
294 void SlideBackground::Update()
296 eFillStyle nPos
= static_cast<eFillStyle
>(mpFillStyle
->GetSelectedEntryPos());
298 if(maContext
== maImpressHandoutContext
)
301 SfxObjectShell
* pSh
= SfxObjectShell::Current();
319 const Color aColor
= GetColorSetOrDefault();
320 mpFillLB
->SelectEntry(aColor
);
329 const XGradient xGradient
= GetGradientSetOrDefault();
330 const Color aStartColor
= xGradient
.GetStartColor();
331 mpFillLB
->SelectEntry(aStartColor
);
332 const Color aEndColor
= xGradient
.GetEndColor();
333 mpFillGrad
->SelectEntry(aEndColor
);
342 mpFillAttr
->Fill(pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
345 const OUString aHatchName
= GetHatchingSetOrDefault();
346 mpFillAttr
->SelectEntry( aHatchName
);
360 mpFillAttr
->Fill(pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
361 aName
= GetBitmapSetOrDefault();
363 else if(nPos
== PATTERN
)
365 mpFillAttr
->Fill(pSh
->GetItem(SID_PATTERN_LIST
)->GetPatternList());
366 aName
= GetPatternSetOrDefault();
368 mpFillAttr
->SelectEntry( aName
);
376 void SlideBackground::UpdateMarginBox()
378 m_nPageLeftMargin
= mpPageLRMarginItem
->GetLeft();
379 m_nPageRightMargin
= mpPageLRMarginItem
->GetRight();
380 m_nPageTopMargin
= mpPageULMarginItem
->GetUpper();
381 m_nPageBottomMargin
= mpPageULMarginItem
->GetLower();
383 if( IsNone(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
385 mpMarginSelectBox
->SelectEntryPos(0);
386 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
388 else if( IsNarrow(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
390 mpMarginSelectBox
->SelectEntryPos(1);
391 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
393 else if( IsModerate(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
395 mpMarginSelectBox
->SelectEntryPos(2);
396 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
398 else if( IsNormal075(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
400 mpMarginSelectBox
->SelectEntryPos(3);
401 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
403 else if( IsNormal100(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
405 mpMarginSelectBox
->SelectEntryPos(4);
406 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
408 else if( IsNormal125(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
410 mpMarginSelectBox
->SelectEntryPos(5);
411 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
413 else if( IsWide(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
) )
415 mpMarginSelectBox
->SelectEntryPos(6);
416 mpMarginSelectBox
->RemoveEntry(maCustomEntry
);
420 if(mpMarginSelectBox
->GetEntryPos(maCustomEntry
) == LISTBOX_ENTRY_NOTFOUND
)
421 mpMarginSelectBox
->InsertEntry(maCustomEntry
);
422 mpMarginSelectBox
->SelectEntry(maCustomEntry
);
426 void SlideBackground::SetPanelTitle( const OUString
& rTitle
)
428 Reference
<frame::XController2
> xController( mxFrame
->getController(), uno::UNO_QUERY
);
429 if ( !xController
.is() )
432 Reference
<ui::XSidebarProvider
> xSidebarProvider( xController
->getSidebar(), uno::UNO_QUERY
);
433 if ( !xSidebarProvider
.is() )
436 Reference
<ui::XDecks
> xDecks ( xSidebarProvider
->getDecks(), uno::UNO_QUERY
);
440 Reference
<ui::XDeck
> xDeck ( xDecks
->getByName("PropertyDeck"), uno::UNO_QUERY
);
444 Reference
<ui::XPanels
> xPanels ( xDeck
->getPanels(), uno::UNO_QUERY
);
448 if (xPanels
->hasByName("SlideBackgroundPanel"))
450 Reference
<ui::XPanel
> xPanel ( xPanels
->getByName("SlideBackgroundPanel"), uno::UNO_QUERY
);
454 xPanel
->setTitle( rTitle
);
458 void SlideBackground::addListener()
460 Link
<tools::EventMultiplexerEvent
&,void> aLink( LINK(this, SlideBackground
, EventMultiplexerListener
) );
461 mrBase
.GetEventMultiplexer()->AddEventListener( aLink
);
464 void SlideBackground::removeListener()
466 Link
<tools::EventMultiplexerEvent
&,void> aLink( LINK(this, SlideBackground
, EventMultiplexerListener
) );
467 mrBase
.GetEventMultiplexer()->RemoveEventListener( aLink
);
470 IMPL_LINK(SlideBackground
, EventMultiplexerListener
,
471 tools::EventMultiplexerEvent
&, rEvent
, void)
473 switch (rEvent
.meEventId
)
475 // add more events as per requirement
476 // Master Page change triggers a shape change event. Solves sync problem.
477 case EventMultiplexerEventId::ShapeChanged
:
478 populateMasterSlideDropdown();
480 case EventMultiplexerEventId::EditModeNormal
:
481 case EventMultiplexerEventId::EditModeMaster
:
482 mbEditModeChangePending
= true;
484 case EventMultiplexerEventId::EditViewSelection
:
485 case EventMultiplexerEventId::EndTextEdit
:
487 if (mbEditModeChangePending
)
489 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
493 DrawViewShell
* pDrawViewShell
= static_cast<DrawViewShell
*>(pMainViewShell
);
494 EditMode eMode
= pDrawViewShell
->GetEditMode();
496 if ( eMode
== EditMode::MasterPage
)
499 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME
));
501 SetPanelTitle(SdResId(STR_MASTERPAGE_NAME
));
503 else // EditMode::Page
506 SetPanelTitle(SdResId(STR_SLIDE_NAME
));
508 SetPanelTitle(SdResId(STR_PAGE_NAME
));
511 mbEditModeChangePending
= false;
515 case EventMultiplexerEventId::CurrentPageChanged
:
517 static const sal_uInt16 SidArray
[] = {
519 SID_ATTR_PAGE_GRADIENT
,
521 SID_ATTR_PAGE_BITMAP
,
522 SID_ATTR_PAGE_FILLSTYLE
,
523 SID_DISPLAY_MASTER_BACKGROUND
,
524 SID_DISPLAY_MASTER_OBJECTS
,
526 updateMasterSlideSelection();
527 GetBindings()->Invalidate( SidArray
);
530 case EventMultiplexerEventId::ViewAdded
:
536 mpCloseMaster
->Hide();
537 mpEditMaster
->Hide();
538 if( maContext
== maDrawMasterContext
)
539 SetPanelTitle(SdResId(STR_MASTERPAGE_NAME
));
541 SetPanelTitle(SdResId(STR_PAGE_NAME
));
543 else if ( maContext
== maImpressOtherContext
|| maContext
== maImpressMasterContext
)
545 if( maContext
== maImpressMasterContext
)
546 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME
));
548 SetPanelTitle(SdResId(STR_SLIDE_NAME
));
550 else if ( maContext
== maImpressNotesContext
)
552 mpMasterLabel
->SetText(SdResId(STR_MASTERSLIDE_LABEL
));
553 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
557 DrawViewShell
* pDrawViewShell
= static_cast<DrawViewShell
*>(pMainViewShell
);
558 if ( pDrawViewShell
->GetEditMode() == EditMode::MasterPage
)
559 SetPanelTitle(SdResId(STR_MASTERSLIDE_NAME
));
560 else // EditMode::Page
561 SetPanelTitle(SdResId(STR_SLIDE_NAME
));
573 void SlideBackground::populateMasterSlideDropdown()
575 mpMasterSlide
->Clear();
576 ::sd::DrawDocShell
* pDocSh
= dynamic_cast<::sd::DrawDocShell
*>( SfxObjectShell::Current() );
577 SdDrawDocument
* pDoc
= pDocSh
? pDocSh
->GetDoc() : nullptr;
578 sal_uInt16 nCount
= pDoc
? pDoc
->GetMasterPageCount() : 0;
579 for( sal_uInt16 nLayout
= 0; nLayout
< nCount
; nLayout
++ )
581 SdPage
* pMaster
= static_cast<SdPage
*>(pDoc
->GetMasterPage(nLayout
));
582 if( pMaster
->GetPageKind() == PageKind::Standard
)
584 OUString
aLayoutName(pMaster
->GetLayoutName());
585 aLayoutName
= aLayoutName
.copy(0,aLayoutName
.indexOf(SD_LT_SEPARATOR
));
586 mpMasterSlide
->InsertEntry(aLayoutName
);
589 updateMasterSlideSelection();
592 void SlideBackground::updateMasterSlideSelection()
594 ViewShell
* pMainViewShell
= mrBase
.GetMainViewShell().get();
595 SdPage
* pPage
= pMainViewShell
? pMainViewShell
->getCurrentPage() : nullptr;
596 if (pPage
!= nullptr && pPage
->TRG_HasMasterPage())
598 SdrPage
& rMasterPage (pPage
->TRG_GetMasterPage());
599 SdPage
* pMasterPage
= static_cast<SdPage
*>(&rMasterPage
);
600 mpMasterSlide
->SelectEntry(pMasterPage
->GetName());
604 void SlideBackground::dispose()
608 mpPaperSizeBox
.clear();
609 mpPaperOrientation
.clear();
610 mpMasterSlide
.clear();
611 mpBackgroundLabel
.clear();
616 mpInsertImage
.clear();
617 mpMarginSelectBox
.disposeAndClear();
618 mpDspMasterBackground
.clear();
619 mpDspMasterObjects
.clear();
620 mpMasterLabel
.clear();
621 mpEditMaster
.clear();
622 mpCloseMaster
.clear();
624 m_pContainer
.clear();
626 maPaperSizeController
.dispose();
627 maPaperOrientationController
.dispose();
628 maPaperMarginLRController
.dispose();
629 maPaperMarginULController
.dispose();
630 maBckColorController
.dispose();
631 maBckGradientController
.dispose();
632 maBckHatchController
.dispose();
633 maBckBitmapController
.dispose();
634 maBckFillStyleController
.dispose();
635 maBckImageController
.dispose();
636 maDspBckController
.dispose();
637 maDspObjController
.dispose();
638 maMetricController
.dispose();
639 maCloseMasterController
.dispose();
644 mpBitmapItem
.reset();
645 mpPageLRMarginItem
.reset();
646 mpPageULMarginItem
.reset();
647 PanelLayout::dispose();
650 void SlideBackground::ExecuteMarginLRChange(const long mnPageLeftMargin
, const long mnPageRightMargin
)
652 mpPageLRMarginItem
->SetLeft(mnPageLeftMargin
);
653 mpPageLRMarginItem
->SetRight(mnPageRightMargin
);
654 GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE
, SfxCallMode::RECORD
, { mpPageLRMarginItem
.get() } );
657 void SlideBackground::ExecuteMarginULChange(const long mnPageTopMargin
, const long mnPageBottomMargin
)
659 mpPageULMarginItem
->SetUpper(mnPageTopMargin
);
660 mpPageULMarginItem
->SetLower(mnPageBottomMargin
);
661 GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE
, SfxCallMode::RECORD
, { mpPageULMarginItem
.get() } );
664 Color
const & SlideBackground::GetColorSetOrDefault()
666 // Tango Sky Blue 1, to be consistent w/ area fill panel (b/c COL_AUTO for slides is transparent)
668 mpColorItem
.reset( new XFillColorItem( OUString(), Color(0x72, 0x9f, 0xcf) ) );
670 return mpColorItem
->GetColorValue();
673 XGradient
const & SlideBackground::GetGradientSetOrDefault()
675 if( !mpGradientItem
)
677 SfxObjectShell
* pSh
= SfxObjectShell::Current();
678 const SvxGradientListItem
* pGradListItem
= pSh
->GetItem(SID_GRADIENT_LIST
);
679 const XGradient aGradient
= pGradListItem
->GetGradientList()->GetGradient(0)->GetGradient();
680 const OUString aGradientName
= pGradListItem
->GetGradientList()->GetGradient(0)->GetName();
682 mpGradientItem
.reset( new XFillGradientItem( aGradientName
, aGradient
) );
685 return mpGradientItem
->GetGradientValue();
688 OUString
const & SlideBackground::GetHatchingSetOrDefault()
692 SfxObjectShell
* pSh
= SfxObjectShell::Current();
693 const SvxHatchListItem
* pHatchListItem
= pSh
->GetItem(SID_HATCH_LIST
);
694 const XHatch aHatch
= pHatchListItem
->GetHatchList()->GetHatch(0)->GetHatch();
695 const OUString aHatchName
= pHatchListItem
->GetHatchList()->GetHatch(0)->GetName();
697 mpHatchItem
.reset( new XFillHatchItem( aHatchName
, aHatch
) );
700 return mpHatchItem
->GetName();
703 OUString
const & SlideBackground::GetBitmapSetOrDefault()
705 if( !mpBitmapItem
|| mpBitmapItem
->isPattern())
707 SfxObjectShell
* pSh
= SfxObjectShell::Current();
708 const SvxBitmapListItem
* pBmpListItem
= pSh
->GetItem(SID_BITMAP_LIST
);
709 const GraphicObject aGraphObj
= pBmpListItem
->GetBitmapList()->GetBitmap(0)->GetGraphicObject();
710 const OUString aBmpName
= pBmpListItem
->GetBitmapList()->GetBitmap(0)->GetName();
712 mpBitmapItem
.reset( new XFillBitmapItem( aBmpName
, aGraphObj
) );
715 return mpBitmapItem
->GetName();
718 OUString
const & SlideBackground::GetPatternSetOrDefault()
720 if( !mpBitmapItem
|| !(mpBitmapItem
->isPattern()))
722 SfxObjectShell
* pSh
= SfxObjectShell::Current();
723 const SvxPatternListItem
* pPtrnListItem
= pSh
->GetItem(SID_PATTERN_LIST
);
724 const GraphicObject aGraphObj
= pPtrnListItem
->GetPatternList()->GetBitmap(0)->GetGraphicObject();
725 const OUString aPtrnName
= pPtrnListItem
->GetPatternList()->GetBitmap(0)->GetName();
727 mpBitmapItem
.reset( new XFillBitmapItem( aPtrnName
, aGraphObj
) );
730 return mpBitmapItem
->GetName();
733 void SlideBackground::DataChanged (const DataChangedEvent
& /*rEvent*/)
738 void SlideBackground::NotifyItemUpdate(
739 const sal_uInt16 nSID
,
740 const SfxItemState eState
,
741 const SfxPoolItem
* pState
,
747 case SID_ATTR_PAGE_COLOR
:
749 if(eState
>= SfxItemState::DEFAULT
)
751 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(SOLID
));
752 mpColorItem
.reset(pState
? static_cast< XFillColorItem
* >(pState
->Clone()) : nullptr);
758 case SID_ATTR_PAGE_HATCH
:
760 if(eState
>= SfxItemState::DEFAULT
)
762 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(HATCH
));
763 mpHatchItem
.reset(pState
? static_cast < XFillHatchItem
* >(pState
->Clone()) : nullptr);
769 case SID_ATTR_PAGE_GRADIENT
:
771 if(eState
>= SfxItemState::DEFAULT
)
773 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(GRADIENT
));
774 mpGradientItem
.reset(pState
? static_cast< XFillGradientItem
* >(pState
->Clone()) : nullptr);
779 case SID_ATTR_PAGE_BITMAP
:
781 if(eState
>= SfxItemState::DEFAULT
)
783 mpBitmapItem
.reset(pState
? static_cast< XFillBitmapItem
* >(pState
->Clone()) : nullptr);
786 if(mpBitmapItem
->isPattern())
787 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(PATTERN
));
789 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
792 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
798 case SID_ATTR_PAGE_FILLSTYLE
:
800 const XFillStyleItem
* pFillStyleItem
= nullptr;
801 if (eState
>= SfxItemState::DEFAULT
)
802 pFillStyleItem
= dynamic_cast< const XFillStyleItem
* >(pState
);
805 css::drawing::FillStyle eXFS
= pFillStyleItem
->GetValue();
808 case drawing::FillStyle_NONE
:
809 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(NONE
));
811 case drawing::FillStyle_SOLID
:
812 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(SOLID
));
814 case drawing::FillStyle_GRADIENT
:
815 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(GRADIENT
));
817 case drawing::FillStyle_HATCH
:
818 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(HATCH
));
820 case drawing::FillStyle_BITMAP
:
822 if(mpBitmapItem
->isPattern())
823 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(PATTERN
));
825 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
836 case SID_ATTR_PAGE_SIZE
:
838 const SvxSizeItem
* pSizeItem
= nullptr;
839 if (eState
>= SfxItemState::DEFAULT
)
840 pSizeItem
= dynamic_cast<const SvxSizeItem
*>(pState
);
843 Size aPaperSize
= pSizeItem
->GetSize();
844 if(mpPaperOrientation
->GetSelectedEntryPos() == 0)
847 Paper ePaper
= SvxPaperInfo::GetSvxPaper(aPaperSize
, meUnit
);
848 mpPaperSizeBox
->SetSelection( ePaper
);
855 const SvxPageItem
* pPageItem
= nullptr;
856 if (eState
>= SfxItemState::DEFAULT
)
857 pPageItem
= dynamic_cast<const SvxPageItem
*>(pState
);
860 mpPageItem
.reset(static_cast<SvxPageItem
*>(pPageItem
->Clone()));
861 bool bIsLandscape
= mpPageItem
->IsLandscape();
862 mpPaperOrientation
->SelectEntryPos( bIsLandscape
? 0 : 1 );
867 case SID_ATTR_PAGE_LRSPACE
:
869 const SvxLongLRSpaceItem
* pLRItem
= nullptr;
870 if (eState
>= SfxItemState::DEFAULT
)
871 pLRItem
= dynamic_cast<const SvxLongLRSpaceItem
*>(pState
);
874 mpPageLRMarginItem
.reset( static_cast<SvxLongLRSpaceItem
*>(pState
->Clone()) );
880 case SID_ATTR_PAGE_ULSPACE
:
882 const SvxLongULSpaceItem
* pULItem
= nullptr;
883 if (eState
>= SfxItemState::DEFAULT
)
884 pULItem
= dynamic_cast<const SvxLongULSpaceItem
*>(pState
);
887 mpPageULMarginItem
.reset( static_cast<SvxLongULSpaceItem
*>(pState
->Clone()) );
893 case SID_DISPLAY_MASTER_BACKGROUND
:
895 const SfxBoolItem
* pBoolItem
= nullptr;
896 if (eState
>= SfxItemState::DEFAULT
)
897 pBoolItem
= dynamic_cast< const SfxBoolItem
* >(pState
);
899 mpDspMasterBackground
->Check(pBoolItem
->GetValue());
902 case SID_DISPLAY_MASTER_OBJECTS
:
904 const SfxBoolItem
* pBoolItem
= nullptr;
905 if (eState
>= SfxItemState::DEFAULT
)
906 pBoolItem
= dynamic_cast< const SfxBoolItem
* >(pState
);
908 mpDspMasterObjects
->Check(pBoolItem
->GetValue());
911 case SID_SELECT_BACKGROUND
:
913 if(eState
>= SfxItemState::DEFAULT
)
915 mpFillStyle
->SelectEntryPos(static_cast< sal_Int32
>(BITMAP
));
925 IMPL_LINK_NOARG(SlideBackground
, FillStyleModifyHdl
, ListBox
&, void)
927 const eFillStyle nPos
= static_cast<eFillStyle
>(mpFillStyle
->GetSelectedEntryPos());
934 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_NONE
);
935 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_FILLSTYLE
, SfxCallMode::RECORD
, { &aXFillStyleItem
});
941 const XFillColorItem
aItem( OUString(), mpColorItem
->GetColorValue() );
942 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR
, SfxCallMode::RECORD
, { &aItem
});
948 const XFillGradientItem
aItem( mpGradientItem
->GetName(), mpGradientItem
->GetGradientValue() );
949 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT
, SfxCallMode::RECORD
, { &aItem
});
955 const XFillHatchItem
aItem( mpHatchItem
->GetName(), mpHatchItem
->GetHatchValue() );
956 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH
, SfxCallMode::RECORD
, { &aItem
});
963 const XFillBitmapItem
aItem( mpBitmapItem
->GetName(), mpBitmapItem
->GetGraphicObject() );
964 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP
, SfxCallMode::RECORD
, { &aItem
});
971 mpFillStyle
->Selected();
974 IMPL_LINK_NOARG(SlideBackground
, PaperSizeModifyHdl
, ListBox
&, void)
976 Paper ePaper
= mpPaperSizeBox
->GetSelection();
977 Size
aSize(SvxPaperInfo::GetPaperSize(ePaper
, meUnit
));
979 if(mpPaperOrientation
->GetSelectedEntryPos() == 0)
982 mpPageItem
->SetLandscape(mpPaperOrientation
->GetSelectedEntryPos() == 0);
983 SvxSizeItem
aSizeItem(SID_ATTR_PAGE_SIZE
, aSize
);
984 // Page/slide properties dialog (FuPage::ExecuteDialog and ::ApplyItemSet) misuses
985 // SID_ATTR_PAGE_EXT1 to distinguish between Impress and Draw, as for whether to fit
986 // objects to paper size. Until that is handled somehow better, we do the same here
987 SfxBoolItem
aFitObjs(SID_ATTR_PAGE_EXT1
, IsImpress());
989 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE
, SfxCallMode::RECORD
, { &aSizeItem
, mpPageItem
.get(), &aFitObjs
});
992 IMPL_LINK_NOARG(SlideBackground
, FillColorHdl
, SvxColorListBox
&, void)
994 const drawing::FillStyle eXFS
= static_cast<drawing::FillStyle
>(mpFillStyle
->GetSelectedEntryPos());
997 case drawing::FillStyle_SOLID
:
999 XFillColorItem
aItem(OUString(), mpFillLB
->GetSelectEntryColor());
1000 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR
, SfxCallMode::RECORD
, { &aItem
});
1003 case drawing::FillStyle_GRADIENT
:
1005 XGradient aGradient
;
1006 aGradient
.SetStartColor(mpFillLB
->GetSelectEntryColor());
1007 aGradient
.SetEndColor(mpFillGrad
->GetSelectEntryColor());
1009 // the name doesn't really matter, it'll be converted to unique one eventually,
1010 // but it has to be non-empty
1011 XFillGradientItem
aItem("gradient", aGradient
);
1012 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT
, SfxCallMode::RECORD
, { &aItem
});
1020 IMPL_LINK_NOARG(SlideBackground
, FillBackgroundHdl
, ListBox
&, void)
1022 const eFillStyle nFillPos
= static_cast<eFillStyle
>(mpFillStyle
->GetSelectedEntryPos());
1023 SfxObjectShell
* pSh
= SfxObjectShell::Current();
1029 const SvxHatchListItem
* pHatchListItem
= pSh
->GetItem(SID_HATCH_LIST
);
1030 sal_uInt16 nPos
= mpFillAttr
->GetSelectedEntryPos();
1031 XHatch aHatch
= pHatchListItem
->GetHatchList()->GetHatch(nPos
)->GetHatch();
1032 const OUString aHatchName
= pHatchListItem
->GetHatchList()->GetHatch(nPos
)->GetName();
1034 XFillHatchItem
aItem(aHatchName
, aHatch
);
1035 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH
, SfxCallMode::RECORD
, { &aItem
});
1042 sal_Int16 nPos
= mpFillAttr
->GetSelectedEntryPos();
1043 GraphicObject aBitmap
;
1045 if( nFillPos
== BITMAP
)
1047 SvxBitmapListItem
const * pBitmapListItem
= pSh
->GetItem(SID_BITMAP_LIST
);
1048 aBitmap
= pBitmapListItem
->GetBitmapList()->GetBitmap(nPos
)->GetGraphicObject();
1049 aName
= pBitmapListItem
->GetBitmapList()->GetBitmap(nPos
)->GetName();
1051 else if( nFillPos
== PATTERN
)
1053 SvxPatternListItem
const * pPatternListItem
= pSh
->GetItem(SID_PATTERN_LIST
);
1054 aBitmap
= pPatternListItem
->GetPatternList()->GetBitmap(nPos
)->GetGraphicObject();
1055 aName
= pPatternListItem
->GetPatternList()->GetBitmap(nPos
)->GetName();
1057 XFillBitmapItem
aItem(aName
, aBitmap
);
1058 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP
, SfxCallMode::RECORD
, { &aItem
});
1067 IMPL_LINK_NOARG(SlideBackground
, AssignMasterPage
, ListBox
&, void)
1069 ::sd::DrawDocShell
* pDocSh
= dynamic_cast<::sd::DrawDocShell
*>( SfxObjectShell::Current() );
1070 SdDrawDocument
* pDoc
= pDocSh
? pDocSh
->GetDoc() : nullptr;
1073 sal_uInt16 nSelectedPage
= SDRPAGE_NOTFOUND
;
1074 for( sal_uInt16 nPage
= 0; nPage
< pDoc
->GetSdPageCount(PageKind::Standard
); nPage
++ )
1076 if (pDoc
->GetSdPage(nPage
,PageKind::Standard
)->IsSelected())
1078 nSelectedPage
= nPage
;
1082 OUString
aLayoutName(mpMasterSlide
->GetSelectedEntry());
1083 pDoc
->SetMasterPage(nSelectedPage
, aLayoutName
, pDoc
, false, false);
1086 IMPL_LINK_NOARG(SlideBackground
, CloseMasterHdl
, Button
*, void)
1088 GetBindings()->GetDispatcher()->Execute( SID_CLOSE_MASTER_VIEW
, SfxCallMode::RECORD
);
1091 IMPL_LINK_NOARG(SlideBackground
, DspBackground
, Button
*, void)
1093 bool IsChecked
= mpDspMasterBackground
->IsChecked();
1094 const SfxBoolItem
aBoolItem(SID_DISPLAY_MASTER_BACKGROUND
, IsChecked
);
1095 GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_BACKGROUND
, SfxCallMode::RECORD
, { &aBoolItem
});
1098 IMPL_LINK_NOARG(SlideBackground
, DspObjects
, Button
*, void)
1100 bool IsChecked
= mpDspMasterObjects
->IsChecked();
1101 const SfxBoolItem
aBoolItem(SID_DISPLAY_MASTER_OBJECTS
,IsChecked
);
1102 GetBindings()->GetDispatcher()->ExecuteList(SID_DISPLAY_MASTER_OBJECTS
, SfxCallMode::RECORD
, { &aBoolItem
, &aBoolItem
});
1105 IMPL_LINK_NOARG( SlideBackground
, ModifyMarginHdl
, ListBox
&, void )
1107 bool bApplyNewPageMargins
= true;
1108 switch ( mpMarginSelectBox
->GetSelectedEntryPos() )
1111 SetNone(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1114 SetNarrow(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1117 SetModerate(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1120 SetNormal075(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1123 SetNormal100(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1126 SetNormal125(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1129 SetWide(m_nPageLeftMargin
, m_nPageRightMargin
, m_nPageTopMargin
, m_nPageBottomMargin
);
1132 bApplyNewPageMargins
= false;
1136 if(bApplyNewPageMargins
)
1138 ExecuteMarginLRChange(m_nPageLeftMargin
, m_nPageRightMargin
);
1139 ExecuteMarginULChange(m_nPageTopMargin
, m_nPageBottomMargin
);
1145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */