LibreOffice Module sd (master) 1
LayoutMenu.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "LayoutMenu.hxx"
21
22#include <app.hrc>
23#include <drawdoc.hxx>
25#include <strings.hrc>
26#include <helpids.h>
27#include <pres.hxx>
28#include <sdmod.hxx>
29
30#include <sdpage.hxx>
31#include <sdresid.hxx>
32#include <unokywds.hxx>
33#include <bitmaps.hlst>
34#include <tools/gen.hxx>
36#include <DrawController.hxx>
37#include <DrawDocShell.hxx>
38#include <DrawViewShell.hxx>
39#include <EventMultiplexer.hxx>
41#include <ViewShellBase.hxx>
43#include <sal/log.hxx>
44
46#include <sfx2/dispatch.hxx>
47#include <sfx2/request.hxx>
48#include <sfx2/viewfrm.hxx>
49#include <svl/cjkoptions.hxx>
50#include <svl/stritem.hxx>
51#include <svl/intitem.hxx>
52#include <utility>
53#include <vcl/commandevent.hxx>
54#include <vcl/image.hxx>
55#include <xmloff/autolayout.hxx>
56
57#include <com/sun/star/drawing/framework/XControllerManager.hpp>
58#include <com/sun/star/drawing/framework/XView.hpp>
59#include <com/sun/star/drawing/framework/ResourceId.hpp>
60
61#include <vector>
62
63using namespace ::com::sun::star;
64using namespace ::com::sun::star::text;
65using namespace ::com::sun::star::uno;
67using namespace ::sd::slidesorter;
68using ::sd::framework::FrameworkHelper;
69
70namespace sd::sidebar {
71
72namespace {
73
74struct snew_slide_value_info
75{
76 rtl::OUStringConstExpr msBmpResId;
80};
81
82}
83
84constexpr OUStringLiteral EMPTY = u"";
85
86const snew_slide_value_info notes[] =
87{
88 {BMP_SLIDEN_01, STR_AUTOLAYOUT_NOTES, WritingMode_LR_TB,
90 {EMPTY, {}, WritingMode_LR_TB, AUTOLAYOUT_NONE},
91};
92
93const snew_slide_value_info handout[] =
94{
95 {BMP_SLIDEH_01, STR_AUTOLAYOUT_HANDOUT1, WritingMode_LR_TB,
97 {BMP_SLIDEH_02, STR_AUTOLAYOUT_HANDOUT2, WritingMode_LR_TB,
99 {BMP_SLIDEH_03, STR_AUTOLAYOUT_HANDOUT3, WritingMode_LR_TB,
101 {BMP_SLIDEH_04, STR_AUTOLAYOUT_HANDOUT4, WritingMode_LR_TB,
103 {BMP_SLIDEH_06, STR_AUTOLAYOUT_HANDOUT6, WritingMode_LR_TB,
105 {BMP_SLIDEH_09, STR_AUTOLAYOUT_HANDOUT9, WritingMode_LR_TB,
107 {EMPTY, {}, WritingMode_LR_TB, AUTOLAYOUT_NONE},
108};
109
110const snew_slide_value_info standard[] =
111{
112 {BMP_LAYOUT_EMPTY, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB, AUTOLAYOUT_NONE},
113 {BMP_LAYOUT_HEAD03, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE},
114 {BMP_LAYOUT_HEAD02, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_CONTENT},
115 {BMP_LAYOUT_HEAD02A, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_2CONTENT},
116 {BMP_LAYOUT_HEAD01, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE_ONLY},
117 {BMP_LAYOUT_TEXTONLY, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TEXT},
118 {BMP_LAYOUT_HEAD03B, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_2CONTENT_CONTENT},
119 {BMP_LAYOUT_HEAD03C, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_CONTENT_2CONTENT},
120 {BMP_LAYOUT_HEAD03A, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT},
121 {BMP_LAYOUT_HEAD02B, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT},
122 {BMP_LAYOUT_HEAD04, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_4CONTENT},
123 {BMP_LAYOUT_HEAD06, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TITLE_6CONTENT},
124
125 // vertical
126 {BMP_LAYOUT_VERTICAL02, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL, AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT},
127 {BMP_LAYOUT_VERTICAL01, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VTITLE_VCONTENT},
128 {BMP_LAYOUT_HEAD02, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VCONTENT},
129 {BMP_LAYOUT_HEAD02A, STR_AL_TITLE_VERT_OUTLINE_CLIPART, WritingMode_TB_RL, AUTOLAYOUT_TITLE_2VTEXT},
130 {EMPTY, {}, WritingMode_LR_TB, AUTOLAYOUT_NONE}
131};
132
134{
135private:
137
144 int CalculateRowCount(const Size& rItemSize, int nColumnCount);
145
146public:
148 : ValueSet(nullptr)
149 , mrMenu(rMenu)
150 {
151 }
152
153 virtual void Resize() override;
154
155 virtual bool Command(const CommandEvent& rEvent) override;
156};
157
159 weld::Widget* pParent,
160 ViewShellBase& rViewShellBase,
161 css::uno::Reference<css::ui::XSidebar> xSidebar)
162 : PanelLayout( pParent, "LayoutPanel", "modules/simpress/ui/layoutpanel.ui" ),
163 mrBase(rViewShellBase),
164 mxLayoutValueSet(new LayoutValueSet(*this)),
165 mxLayoutValueSetWin(new weld::CustomWeld(*m_xBuilder, "layoutvalueset", *mxLayoutValueSet)),
166 mbIsMainViewChangePending(false),
167 mxSidebar(std::move(xSidebar)),
168 mbIsDisposed(false)
169{
171 SAL_INFO("sd.ui", "created LayoutMenu at " << this);
172
174
176}
177
179{
180 OSL_ENSURE( mrBase.GetDocument()->GetDocSh() == &rDocumentShell,
181 "LayoutMenu::implConstruct: hmm?" );
182 // if this fires, then my assumption that the rDocumentShell parameter to our first ctor is superfluous ...
183 (void) rDocumentShell;
184
185 mxLayoutValueSet->SetStyle (
186 ( mxLayoutValueSet->GetStyle() & ~(WB_ITEMBORDER) )
187 | WB_TABSTOP
190 );
191 mxLayoutValueSet->SetExtraSpacing(2);
192 mxLayoutValueSet->SetSelectHdl (LINK(this, LayoutMenu, ClickHandler));
194
195 Link<::sd::tools::EventMultiplexerEvent&,void> aEventListenerLink (LINK(this,LayoutMenu,EventMultiplexerListener));
196 mrBase.GetEventMultiplexer()->AddEventListener(aEventListenerLink);
197
199 mxLayoutValueSet->SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE));
200
201 Link<const OUString&,void> aStateChangeLink (LINK(this,LayoutMenu,StateChangeHandler));
202 mxListener = new ::sd::tools::SlotStateListener(
203 aStateChangeLink,
204 Reference<frame::XDispatchProvider>(mrBase.GetController()->getFrame(), UNO_QUERY),
205 ".uno:VerticalTextState");
206}
207
209{
210 SAL_INFO("sd.ui", "destroying LayoutMenu at " << this);
211 Dispose();
212 mxLayoutValueSetWin.reset();
213 mxLayoutValueSet.reset();
214}
215
217{
218 if (mbIsDisposed)
219 return;
220
221 SAL_INFO("sd.ui", "disposing LayoutMenu at " << this);
222
223 mbIsDisposed = true;
224
225 Reference<lang::XComponent> xComponent (mxListener, UNO_QUERY);
226 if (xComponent.is())
227 xComponent->dispose();
228
229 Clear();
230 Link<tools::EventMultiplexerEvent&,void> aLink (LINK(this,LayoutMenu,EventMultiplexerListener));
231 mrBase.GetEventMultiplexer()->RemoveEventListener (aLink);
232}
233
235{
236 AutoLayout aResult = AUTOLAYOUT_NONE;
237
238 if (!mxLayoutValueSet->IsNoSelection() && mxLayoutValueSet->GetSelectedItemId()!=0)
239 {
240 AutoLayout* pLayout = static_cast<AutoLayout*>(mxLayoutValueSet->GetItemData(mxLayoutValueSet->GetSelectedItemId()));
241 if (pLayout != nullptr)
242 aResult = *pLayout;
243 }
244
245 return aResult;
246}
247
248ui::LayoutSize LayoutMenu::GetHeightForWidth (const sal_Int32 nWidth)
249{
250 sal_Int32 nPreferredHeight = 200;
251 if (mxLayoutValueSet->GetItemCount()>0)
252 {
253 Image aImage = mxLayoutValueSet->GetItemImage(mxLayoutValueSet->GetItemId(0));
254 Size aItemSize = mxLayoutValueSet->CalcItemSizePixel(aImage.GetSizePixel());
255 if (nWidth>0 && aItemSize.Width()>0)
256 {
257 aItemSize.AdjustWidth(8 );
258 aItemSize.AdjustHeight(8 );
259 int nColumnCount = nWidth / aItemSize.Width();
260 if (nColumnCount <= 0)
261 nColumnCount = 1;
262 else if (nColumnCount > 4)
263 nColumnCount = 4;
264 int nRowCount = (mxLayoutValueSet->GetItemCount() + nColumnCount-1) / nColumnCount;
265 nPreferredHeight = nRowCount * aItemSize.Height();
266 }
267 }
268 return ui::LayoutSize(nPreferredHeight,nPreferredHeight,nPreferredHeight);
269}
270
272{
273 Size aWindowSize = GetOutputSizePixel();
274 if (IsVisible() && aWindowSize.Width() > 0)
275 {
276 // Calculate the number of rows and columns.
277 if (GetItemCount() > 0)
278 {
279 Image aImage = GetItemImage(GetItemId(0));
280 Size aItemSize = CalcItemSizePixel (
281 aImage.GetSizePixel());
282 aItemSize.AdjustWidth(8 );
283 aItemSize.AdjustHeight(8 );
284 int nColumnCount = aWindowSize.Width() / aItemSize.Width();
285 if (nColumnCount < 1)
286 nColumnCount = 1;
287 else if (nColumnCount > 4)
288 nColumnCount = 4;
289
290 int nRowCount = CalculateRowCount (aItemSize, nColumnCount);
291
292 SetColCount(nColumnCount);
293 SetLineCount(nRowCount);
294 }
295 }
296
298}
299
301{
302 if (rEvent.GetCommand() != CommandEventId::ContextMenu)
303 return false;
304
305 // As a preparation for the context menu the item under the mouse is
306 // selected.
307 if (rEvent.IsMouseEvent())
308 {
309 sal_uInt16 nIndex = GetItemId(rEvent.GetMousePosPixel());
310 if (nIndex > 0)
312 }
313
314 mrMenu.ShowContextMenu(rEvent.IsMouseEvent() ? &rEvent.GetMousePosPixel() : nullptr);
315 return true;
316}
317
319{
320 ViewShell* pViewShell = mrBase.GetMainViewShell().get();
321 if (pViewShell == nullptr)
322 return;
323
324 SfxViewFrame& rViewFrame = mrBase.GetViewFrame();
325 SfxDispatcher* pDispatcher = rViewFrame.GetDispatcher();
326 if (pDispatcher == nullptr)
327 return;
328
329 // Call SID_INSERTPAGE with the right arguments. This is because
330 // the popup menu can not call this slot with arguments directly.
331 SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout));
332 if (aRequest.GetArgs() != nullptr)
333 {
334 pDispatcher->Execute(
335 SID_INSERTPAGE,
336 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
337 *aRequest.GetArgs());
338 }
340}
341
343{
344 // Throw away the current set and fill the menu anew according to the
345 // current settings (this includes the support for vertical writing.)
346 Fill();
347
348 if (mxSidebar.is())
349 mxSidebar->requestLayout();
350
351 // set selection inside the control during Impress start up
353}
354
355int LayoutValueSet::CalculateRowCount (const Size&, int nColumnCount)
356{
357 int nRowCount = 0;
358
359 if (GetItemCount() > 0 && nColumnCount > 0)
360 {
361 nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount;
362 if (nRowCount < 1)
363 nRowCount = 1;
364 }
365
366 return nRowCount;
367}
368
369IMPL_LINK_NOARG(LayoutMenu, ClickHandler, ValueSet*, void)
370{
371 AssignLayoutToSelectedSlides( GetSelectedAutoLayout() );
372}
373
378{
379 using namespace ::sd::slidesorter;
380 using namespace ::sd::slidesorter::controller;
381
382 do
383 {
384 // The view shell in the center pane has to be present.
385 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
386 if (pMainViewShell == nullptr)
387 break;
388
389 // Determine if the current view is in an invalid master page mode.
390 // The handout view is always in master page mode and therefore not
391 // invalid.
392 bool bMasterPageMode (false);
393 switch (pMainViewShell->GetShellType())
394 {
397 {
398 DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
399 if (pDrawViewShell->GetEditMode() == EditMode::MasterPage)
400 bMasterPageMode = true;
401 break;
402 }
403 default:
404 break;
405 }
406 if (bMasterPageMode)
407 break;
408
409 // Get a list of all selected slides and call the SID_MODIFYPAGE
410 // slot for all of them.
412
413 // Get a list of selected pages.
414 // First we try to obtain this list from a slide sorter. This is
415 // possible only some of the view shells in the center pane. When
416 // no valid slide sorter is available then ask the main view shell
417 // for its current page.
418 SlideSorterViewShell* pSlideSorter = nullptr;
419 switch (pMainViewShell->GetShellType())
420 {
424 pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase);
425 break;
426 default:
427 break;
428 }
429 if (pSlideSorter != nullptr)
430 {
431 // There is a slide sorter visible so get the list of selected pages from it.
432 pPageSelection = pSlideSorter->GetPageSelection();
433 }
434
435 if( (pSlideSorter == nullptr) || !pPageSelection || pPageSelection->empty() )
436 {
437 // No valid slide sorter available. Ask the main view shell for
438 // its current page.
439 pPageSelection = std::make_shared<::sd::slidesorter::SlideSorterViewShell::PageSelection>();
440 pPageSelection->push_back(pMainViewShell->GetActualPage());
441 }
442
443 if (pPageSelection->empty())
444 break;
445
446 for (const auto& rpPage : *pPageSelection)
447 {
448 if (rpPage == nullptr)
449 continue;
450
451 // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters.
452 SfxRequest aRequest(mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT);
453 aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, (rpPage->GetPageNum()-1)/2));
454 aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout));
455 pMainViewShell->ExecuteSlot (aRequest, false);
456 }
457 }
458 while(false);
459}
460
462 sal_uInt16 nSlotId,
463 AutoLayout aLayout)
464{
465 SfxRequest aRequest(mrBase.GetViewFrame(), nSlotId);
466
467 do
468 {
469 SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin());
470 SdrLayerID aBackground (rLayerAdmin.GetLayerID(sUNO_LayerName_background));
471 SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects));
472 ViewShell* pViewShell = mrBase.GetMainViewShell().get();
473 if (pViewShell == nullptr)
474 break;
475 SdPage* pPage = pViewShell->GetActualPage();
476 if (pPage == nullptr)
477 break;
478
479 SdrLayerIDSet aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers());
480
481 aRequest.AppendItem(
482 SfxStringItem (ID_VAL_PAGENAME, OUString()));//pPage->GetName()));
483 aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout));
484 aRequest.AppendItem(
485 SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground)));
486 aRequest.AppendItem(
488 ID_VAL_ISPAGEOBJ,
489 aVisibleLayers.IsSet(aBackgroundObject)));
490 }
491 while (false);
492
493 return aRequest;
494}
495
497{
498 bool bVertical = SvtCJKOptions::IsVerticalTextEnabled();
499 SdDrawDocument* pDocument = mrBase.GetDocument();
500 bool bRightToLeft = (pDocument!=nullptr
501 && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB);
502
503 // Get URL of the view in the center pane.
504 OUString sCenterPaneViewName;
505 try
506 {
508 {
509 Reference<XResourceId> xPaneId (ResourceId::create(
510 ::comphelper::getProcessComponentContext(),
511 FrameworkHelper::msCenterPaneURL));
512 Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId));
513 if (xView.is())
514 sCenterPaneViewName = xView->getResourceId()->getResourceURL();
515 }
516 }
517 catch (RuntimeException&)
518 {}
519
520 const snew_slide_value_info* pInfo = nullptr;
521 if (sCenterPaneViewName == framework::FrameworkHelper::msNotesViewURL)
522 {
523 pInfo = notes;
524 }
525 else if (sCenterPaneViewName == framework::FrameworkHelper::msHandoutViewURL)
526 {
527 pInfo = handout;
528 }
529 else if (sCenterPaneViewName == framework::FrameworkHelper::msImpressViewURL
530 || sCenterPaneViewName == framework::FrameworkHelper::msSlideSorterURL)
531 {
532 pInfo = standard;
533 }
534 else
535 {
536 pInfo = nullptr;
537 }
538
539 Clear();
540 for (sal_uInt16 i=1; pInfo!=nullptr && pInfo->mpStrResId; i++, pInfo++)
541 {
542 if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical)
543 {
544 Image aImg("private:graphicrepository/" + static_cast<const OUString &>(pInfo->msBmpResId));
545
546 if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode))
547 { // FIXME: avoid interpolating RTL layouts.
548 BitmapEx aRTL = aImg.GetBitmapEx();
549 aRTL.Mirror(BmpMirrorFlags::Horizontal);
550 aImg = Image(aRTL);
551 }
552
553 mxLayoutValueSet->InsertItem(i, aImg, SdResId(pInfo->mpStrResId));
554 mxLayoutValueSet->SetItemData (i, new AutoLayout(pInfo->maAutoLayout));
555 }
556 }
557}
558
560{
561 for (size_t nId=1; nId<=mxLayoutValueSet->GetItemCount(); nId++)
562 delete static_cast<AutoLayout*>(mxLayoutValueSet->GetItemData(nId));
563 mxLayoutValueSet->Clear();
564}
565
567{
568 if (SD_MOD()->GetWaterCan())
569 return;
570
571 // Determine the position where to show the menu.
572 Point aMenuPosition;
573 if (pPos)
574 {
575 auto nItemId = mxLayoutValueSet->GetItemId(*pPos);
576 if (nItemId <= 0)
577 return;
578 mxLayoutValueSet->SelectItem(nItemId);
579 aMenuPosition = *pPos;
580 }
581 else
582 {
583 if (mxLayoutValueSet->GetSelectedItemId() == sal_uInt16(-1))
584 return;
585 ::tools::Rectangle aBBox(mxLayoutValueSet->GetItemRect(mxLayoutValueSet->GetSelectedItemId()));
586 aMenuPosition = aBBox.Center();
587 }
588
589 // Setup the menu.
590 ::tools::Rectangle aRect(aMenuPosition, Size(1, 1));
591 weld::Widget* pPopupParent = mxLayoutValueSet->GetDrawingArea();
592 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "modules/simpress/ui/layoutmenu.ui"));
593 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
594
595 // Disable the SID_INSERTPAGE_LAYOUT_MENU item when
596 // the document is read-only.
597 const SfxPoolItem* pItem = nullptr;
598 const SfxItemState aState (
599 mrBase.GetViewFrame().GetDispatcher()->QueryState(SID_INSERTPAGE, pItem));
600 if (aState == SfxItemState::DISABLED)
601 xMenu->set_sensitive("insert", false);
602
603 // Show the menu.
604 OnMenuItemSelected(xMenu->popup_at_rect(pPopupParent, aRect));
605}
606
607IMPL_LINK_NOARG(LayoutMenu, StateChangeHandler, const OUString&, void)
608{
609 InvalidateContent();
610}
611
612void LayoutMenu::OnMenuItemSelected(std::u16string_view ident)
613{
614 if (ident.empty())
615 return;
616
617 if (ident == u"apply")
618 {
620 }
621 else if (ident == u"insert")
622 {
623 // Add arguments to this slot and forward it to the main view
624 // shell.
626 }
627}
628
629// Selects an appropriate layout of the slide inside control.
630//
631// Method may be called several times with the same item-id to be selected -
632// only once the actually state of the control will be changed.
633//
635{
636 bool bItemSelected = false;
637
638 do
639 {
640 // Get current page of main view.
641 ViewShell* pViewShell = mrBase.GetMainViewShell().get();
642 if (pViewShell == nullptr)
643 break;
644
645 SdPage* pCurrentPage = pViewShell->getCurrentPage();
646 if (pCurrentPage == nullptr)
647 break;
648
649 // Get layout of current page.
650 AutoLayout aLayout (pCurrentPage->GetAutoLayout());
651 if (aLayout<AUTOLAYOUT_START || aLayout>AUTOLAYOUT_END)
652 break;
653
654 // Find the entry of the menu for to the layout.
655 const sal_uInt16 nItemCount = mxLayoutValueSet->GetItemCount();
656 for (sal_uInt16 nId=1; nId<=nItemCount; nId++)
657 {
658 if (*static_cast<AutoLayout*>(mxLayoutValueSet->GetItemData(nId)) == aLayout)
659 {
660 // do not set selection twice to the same item
661 if (mxLayoutValueSet->GetSelectedItemId() != nId)
662 {
663 mxLayoutValueSet->SetNoSelection();
664 mxLayoutValueSet->SelectItem(nId);
665 }
666
667 bItemSelected = true; // no need to call SetNoSelection()
668 break;
669 }
670 }
671 }
672 while (false);
673
674 if (!bItemSelected)
675 mxLayoutValueSet->SetNoSelection();
676}
677
678IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent&, rEvent, void)
679{
680 switch (rEvent.meEventId)
681 {
682 // tdf#89890 During changes of the Layout of the slide when focus is not set inside main area
683 // we do not receive notification EventMultiplexerEventId::CurrentPageChanged, but we receive the following 3 notification types.
684 // => let's make UpdateSelection() also when some shape is changed (during Layout changes)
688 UpdateSelection();
689 break;
690
693 UpdateSelection();
694 break;
695
697 mbIsMainViewChangePending = true;
698 break;
699
701 mxLayoutValueSet->Invalidate(); // redraw without focus
702 break;
703
705 if (mbIsMainViewChangePending)
706 {
707 mbIsMainViewChangePending = false;
708 InvalidateContent();
709 }
710 break;
711
712 default:
713 break;
714 }
715}
716
718{
720 Fill();
721 mxLayoutValueSet->StyleUpdated();
723}
724
725} // end of namespace ::sd::sidebar
726
727/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ ShapeRemoved
A shape has been removed from a page.
@ SlideSortedSelection
The selection in the slide sorter has changed, regardless of whether the slide sorter is displayed in...
@ MainViewRemoved
The current MainViewShell (the ViewShell displayed in the center pane) has been removed.
@ ShapeChanged
The state of a shape has changed.
@ MainViewAdded
A new ViewShell has been made the MainViewShell.
@ ConfigurationUpdated
A configuration update has been completed.
@ CurrentPageChanged
The current page has changed.
@ ShapeInserted
A shape has been inserted to a page.
AutoLayout maAutoLayout
Definition: LayoutMenu.cxx:79
rtl::OUStringConstExpr msBmpResId
Definition: LayoutMenu.cxx:76
TranslateId mpStrResId
Definition: LayoutMenu.cxx:77
WritingMode meWritingMode
Definition: LayoutMenu.cxx:78
AutoLayout
AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT
AUTOLAYOUT_TITLE
AUTOLAYOUT_HANDOUT1
AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT
AUTOLAYOUT_TITLE_2VTEXT
AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT
AUTOLAYOUT_VTITLE_VCONTENT
AUTOLAYOUT_TITLE_ONLY
AUTOLAYOUT_TITLE_2CONTENT
AUTOLAYOUT_ONLY_TEXT
AUTOLAYOUT_TITLE_6CONTENT
AUTOLAYOUT_HANDOUT9
AUTOLAYOUT_TITLE_2CONTENT_CONTENT
AUTOLAYOUT_HANDOUT2
AUTOLAYOUT_TITLE_CONTENT_2CONTENT
AUTOLAYOUT_HANDOUT4
AUTOLAYOUT_NONE
AUTOLAYOUT_END
AUTOLAYOUT_HANDOUT6
AUTOLAYOUT_NOTES
AUTOLAYOUT_TITLE_CONTENT
AUTOLAYOUT_HANDOUT3
AUTOLAYOUT_TITLE_VCONTENT
AUTOLAYOUT_TITLE_4CONTENT
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
bool Mirror(BmpMirrorFlags nMirrorFlags)
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
BitmapEx GetBitmapEx() const
Size GetSizePixel() const
virtual void DataChanged(const DataChangedEvent &rEvent)
css::text::WritingMode GetDefaultWritingMode() const
Definition: drawdoc4.cxx:1184
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
AutoLayout GetAutoLayout() const
Definition: sdpage.hxx:190
SdrLayerID GetLayerID(const OUString &rName) const
bool IsSet(SdrLayerID a) const
const SdrLayerAdmin & GetLayerAdmin() const
const SdrLayerIDSet & TRG_GetMasterPageVisibleLayers() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SfxItemState QueryState(sal_uInt16 nSID, const SfxPoolItem *&rpState)
const SfxItemSet * GetArgs() const
void AppendItem(const SfxPoolItem &)
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
SfxDispatcher * GetDispatcher()
css::uno::Reference< css::frame::XController > GetController() const
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
size_t GetItemCount() const
void SelectItem(sal_uInt16 nItemId)
Size CalcItemSizePixel(const Size &rSize) const
void SetLineCount(sal_uInt16 nNewLines=0)
void SetColCount(sal_uInt16 nNewCols=1)
virtual void Resize() override
sal_uInt16 GetItemId(size_t nPos) const
Image GetItemImage(sal_uInt16 nItemId) const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
EditMode GetEditMode() const
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
DrawController * GetDrawController() const
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
std::shared_ptr< tools::EventMultiplexer > const & GetEventMultiplexer() const
Return an event multiplexer.
SdDrawDocument * GetDocument() const
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
virtual SdPage * getCurrentPage() const =0
virtual SdPage * GetActualPage()=0
SD_DLLPUBLIC ShellType GetShellType() const
Return the type of the shell.
Definition: viewshel.cxx:1402
static const OUString msHandoutViewURL
static const OUString msNotesViewURL
static const OUString msSlideSorterURL
static const OUString msImpressViewURL
void InvalidateContent()
Call this method when the set of displayed layouts is not up-to-date anymore.
Definition: LayoutMenu.cxx:342
virtual void DataChanged(const DataChangedEvent &rEvent) override
Call Fill() when switching to or from high contrast mode so that the correct set of icons is displaye...
Definition: LayoutMenu.cxx:717
void OnMenuItemSelected(std::u16string_view ident)
Definition: LayoutMenu.cxx:612
AutoLayout GetSelectedAutoLayout() const
Return a numerical value representing the currently selected layout.
Definition: LayoutMenu.cxx:234
void ShowContextMenu(const Point *pPos)
The context menu is requested over this ShowContextMenu() method.
Definition: LayoutMenu.cxx:566
void UpdateSelection()
Select the layout that is used by the current page.
Definition: LayoutMenu.cxx:634
virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 nWidth) override
Definition: LayoutMenu.cxx:248
void Fill()
Fill the value set with the layouts that are applicable to the current main view shell.
Definition: LayoutMenu.cxx:496
LayoutMenu(weld::Widget *pParent, ViewShellBase &rViewShellBase, css::uno::Reference< css::ui::XSidebar > xSidebar)
Create a new layout menu.
Definition: LayoutMenu.cxx:158
std::unique_ptr< weld::CustomWeld > mxLayoutValueSetWin
Definition: LayoutMenu.hxx:97
ViewShellBase & mrBase
Definition: LayoutMenu.hxx:94
std::unique_ptr< LayoutValueSet > mxLayoutValueSet
Definition: LayoutMenu.hxx:96
css::uno::Reference< css::frame::XStatusListener > mxListener
If we are asked for the preferred window size, then use this many columns for the calculation.
Definition: LayoutMenu.hxx:102
void AssignLayoutToSelectedSlides(AutoLayout aLayout)
Assign the given layout to all selected slides of a slide sorter.
Definition: LayoutMenu.cxx:377
virtual ~LayoutMenu() override
Definition: LayoutMenu.cxx:208
css::uno::Reference< css::ui::XSidebar > mxSidebar
Definition: LayoutMenu.hxx:104
void Clear()
Remove all items from the value set.
Definition: LayoutMenu.cxx:559
void implConstruct(DrawDocShell &rDocumentShell)
Definition: LayoutMenu.cxx:178
void InsertPageWithLayout(AutoLayout aLayout)
Insert a new page with the given layout.
Definition: LayoutMenu.cxx:318
SfxRequest CreateRequest(sal_uInt16 nSlotId, AutoLayout aLayout)
Create a request structure that can be used with the SID_INSERTPAGE and SID_MODIFYPAGE slots.
Definition: LayoutMenu.cxx:461
LayoutValueSet(LayoutMenu &rMenu)
Definition: LayoutMenu.cxx:147
virtual void Resize() override
Definition: LayoutMenu.cxx:271
int CalculateRowCount(const Size &rItemSize, int nColumnCount)
Calculate the number of displayed rows.
Definition: LayoutMenu.cxx:355
virtual bool Command(const CommandEvent &rEvent) override
Definition: LayoutMenu.cxx:300
static Color GetColor(const ThemeItem eItem)
constexpr Point Center() const
float u
constexpr OUStringLiteral HID_SD_TASK_PANE_PREVIEW_LAYOUTS
Definition: helpids.h:47
sal_Int32 nIndex
#define SAL_INFO(area, stream)
bool IsVerticalTextEnabled()
int i
const snew_slide_value_info handout[]
Definition: LayoutMenu.cxx:93
const snew_slide_value_info notes[]
Definition: LayoutMenu.cxx:86
constexpr OUStringLiteral EMPTY
Definition: LayoutMenu.cxx:84
const snew_slide_value_info standard[]
Definition: LayoutMenu.cxx:110
IMPL_LINK_NOARG(LayoutMenu, ClickHandler, ValueSet *, void)
Definition: LayoutMenu.cxx:369
IMPL_LINK(CurrentMasterPagesSelector, EventMultiplexerListener, sd::tools::EventMultiplexerEvent &, rEvent, void)
std::shared_ptr< SlideSorterViewShell::PageSelection > SharedPageSelection
sal_Int16 nId
SfxItemState
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
constexpr OUStringLiteral sUNO_LayerName_background_objects
Definition: unokywds.hxx:30
constexpr OUStringLiteral sUNO_LayerName_background
Definition: unokywds.hxx:29
#define WB_FLATVALUESET
#define WB_ITEMBORDER
#define WB_MENUSTYLEVALUESET
#define WB_NO_DIRECTSELECT
WinBits const WB_TABSTOP