LibreOffice Module cui (master) 1
cfg.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 <sal/config.h>
21#include <sal/log.hxx>
22
23#include <cassert>
24#include <stdlib.h>
25#include <typeinfo>
26
27#include <utility>
28#include <vcl/stdtext.hxx>
30#include <vcl/event.hxx>
31#include <vcl/graph.hxx>
32#include <vcl/graphicfilter.hxx>
33#include <vcl/svapp.hxx>
34#include <vcl/toolbox.hxx>
35#include <vcl/weld.hxx>
36#include <vcl/decoview.hxx>
37#include <vcl/virdev.hxx>
38
39#include <sfx2/sfxhelp.hxx>
40#include <sfx2/viewfrm.hxx>
42#include <sfx2/sfxsids.hrc>
43#include <svl/stritem.hxx>
44#include <rtl/ustrbuf.hxx>
45#include <tools/debug.hxx>
46#include <tools/diagnose_ex.h>
48
49#include <algorithm>
50#include <strings.hrc>
51
52#include <acccfg.hxx>
53#include <cfg.hxx>
55#include <SvxMenuConfigPage.hxx>
59#include "eventdlg.hxx"
60#include <dialmgr.hxx>
61
63#include <com/sun/star/container/XNameContainer.hpp>
64#include <com/sun/star/embed/ElementModes.hpp>
65#include <com/sun/star/embed/FileSystemStorageFactory.hpp>
66#include <com/sun/star/frame/ModuleManager.hpp>
67#include <com/sun/star/frame/XFrames.hpp>
68#include <com/sun/star/frame/XLayoutManager.hpp>
69#include <com/sun/star/frame/FrameSearchFlag.hpp>
70#include <com/sun/star/frame/XController.hpp>
71#include <com/sun/star/frame/Desktop.hpp>
72#include <com/sun/star/frame/theUICommandDescription.hpp>
73#include <com/sun/star/graphic/GraphicProvider.hpp>
74#include <com/sun/star/io/IOException.hpp>
75#include <com/sun/star/ui/ItemType.hpp>
76#include <com/sun/star/ui/ItemStyle.hpp>
77#include <com/sun/star/ui/ImageManager.hpp>
78#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
79#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
80#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
81#include <com/sun/star/ui/XUIElement.hpp>
82#include <com/sun/star/ui/UIElementType.hpp>
83#include <com/sun/star/ui/ImageType.hpp>
84#include <com/sun/star/ui/theWindowStateConfiguration.hpp>
85#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
86#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
87#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
88#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
89#include <com/sun/star/util/thePathSettings.hpp>
94
95namespace uno = com::sun::star::uno;
97namespace lang = com::sun::star::lang;
101
102#if OSL_DEBUG_LEVEL > 1
103
105 const OUString& prefix,
107{
109 xPropSet->getPropertySetInfo();
110
111 const uno::Sequence< beans::Property >& aPropDetails =
112 xPropSetInfo->getProperties();
113
114 SAL_WARN("cui", "printPropertySet: " << aPropDetails.getLength() << " properties" );
115
116 for ( beans::Property const & aPropDetail : aPropDetails )
117 {
118 OUString tmp;
119 sal_Int32 ival;
120
121 uno::Any a = xPropSet->getPropertyValue( aPropDetail.Name );
122
123 if ( a >>= tmp )
124 {
125 SAL_WARN("cui", prefix << ": Got property: " << aPropDetail.Name << tmp);
126 }
127 else if ( ( a >>= ival ) )
128 {
129 SAL_WARN("cui", prefix << ": Got property: " << aPropDetail.Name << " = " << ival);
130 }
131 else
132 {
133 SAL_WARN("cui", prefix << ": Got property: " << aPropDetail.Name << " of type " << a.getValueTypeName());
134 }
135 }
136}
137
139 const OUString& prefix,
141{
142 for (beans::PropertyValue const & aPropVal : aProp)
143 {
144 OUString tmp;
145
146 aPropVal.Value >>= tmp;
147
148 SAL_WARN("cui", prefix << ": Got property: " << aPropVal.Name << " = " << tmp);
149 }
150}
151
153{
154 for (auto const& entry : *entries)
155 {
156 SAL_WARN("cui", "printEntries: " << entry->GetName());
157 }
158}
159
160#endif
161
162bool
163SvxConfigPage::CanConfig( std::u16string_view aModuleId )
164{
165 return aModuleId != u"com.sun.star.script.BasicIDE" && aModuleId != u"com.sun.star.frame.Bibliography";
166}
167
168static std::unique_ptr<SfxTabPage> CreateSvxMenuConfigPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
169{
170 return std::make_unique<SvxMenuConfigPage>(pPage, pController, *rSet);
171}
172
173static std::unique_ptr<SfxTabPage> CreateSvxContextMenuConfigPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
174{
175 return std::make_unique<SvxMenuConfigPage>(pPage, pController, *rSet, false);
176}
177
178static std::unique_ptr<SfxTabPage> CreateKeyboardConfigPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
179{
180 return std::make_unique<SfxAcceleratorConfigPage>(pPage, pController, *rSet);
181}
182
183static std::unique_ptr<SfxTabPage> CreateSvxNotebookbarConfigPage(weld::Container* pPage, weld::DialogController* pController,
184 const SfxItemSet* rSet)
185{
186 return std::make_unique<SvxNotebookbarConfigPage>(pPage, pController, *rSet);
187}
188
189static std::unique_ptr<SfxTabPage> CreateSvxToolbarConfigPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
190{
191 return std::make_unique<SvxToolbarConfigPage>(pPage, pController, *rSet);
192}
193
194static std::unique_ptr<SfxTabPage> CreateSvxEventConfigPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
195{
196 return std::make_unique<SvxEventConfigPage>(pPage, pController, *rSet, SvxEventConfigPage::EarlyInit());
197}
198
199/******************************************************************************
200 *
201 * SvxConfigDialog is the configuration dialog which is brought up from the
202 * Tools menu. It includes tabs for customizing menus, toolbars, events and
203 * key bindings.
204 *
205 *****************************************************************************/
207 : SfxTabDialogController(pParent, "cui/ui/customizedialog.ui", "CustomizeDialog", pInSet)
208{
210
211 AddTabPage("menus", CreateSvxMenuConfigPage, nullptr);
212 AddTabPage("toolbars", CreateSvxToolbarConfigPage, nullptr);
213 AddTabPage("notebookbar", CreateSvxNotebookbarConfigPage, nullptr);
214 AddTabPage("contextmenus", CreateSvxContextMenuConfigPage, nullptr);
215 AddTabPage("keyboard", CreateKeyboardConfigPage, nullptr);
216 AddTabPage("events", CreateSvxEventConfigPage, nullptr);
217 m_xTabCtrl->connect_enter_page(LINK(this, SvxConfigDialog, ActivatePageHdl));
218
219 const SfxPoolItem* pItem = pInSet->GetItem( SID_CONFIG );
220
221 if ( pItem )
222 {
223 OUString text = static_cast<const SfxStringItem*>(pItem)->GetValue();
224
225 if (text.startsWith( ITEM_TOOLBAR_URL ) )
226 {
227 SetCurPageId("toolbars");
228 }
229 }
230}
231
232IMPL_LINK(SvxConfigDialog, ActivatePageHdl, const OString&, rPage, void)
233{
234 GetResetButton()->set_visible(rPage != "keyboard");
235}
236
237void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xFrame)
238{
241
242 if (aModuleId != "com.sun.star.text.TextDocument" &&
243 aModuleId != "com.sun.star.sheet.SpreadsheetDocument" &&
244 aModuleId != "com.sun.star.presentation.PresentationDocument" &&
245 aModuleId != "com.sun.star.drawing.DrawingDocument")
246 RemoveTabPage("notebookbar");
247
248 if (aModuleId == "com.sun.star.frame.StartModule")
249 RemoveTabPage("keyboard");
250}
251
252void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage)
253{
254 if (rId == "menus" || rId == "keyboard" || rId == "notebookbar"
255 || rId == "toolbars" || rId == "contextmenus")
256 {
257 rPage.SetFrame(m_xFrame);
258 }
259 else if (rId == "events")
260 {
261 dynamic_cast< SvxEventConfigPage& >( rPage ).LateInit( m_xFrame );
262 }
263}
264
265/******************************************************************************
266 *
267 * The SaveInData class is used to hold data for entries in the Save In
268 * ListBox controls in the menu and toolbar tabs
269 *
270 ******************************************************************************/
271
272// Initialize static variable which holds default XImageManager
274
278 const OUString& aModuleId,
279 bool isDocConfig )
280 :
281 bModified( false ),
282 bDocConfig( isDocConfig ),
283 bReadOnly( false ),
284 m_xCfgMgr(std::move( xCfgMgr )),
285 m_xParentCfgMgr(std::move( xParentCfgMgr )),
287 css::ui::ItemType::SEPARATOR_LINE) }
288{
289 if ( bDocConfig )
290 {
292 xDocPersistence( GetConfigManager(), uno::UNO_QUERY );
293
294 bReadOnly = xDocPersistence->isReadOnly();
295 }
296
297 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
298
300 css::frame::theUICommandDescription::get(xContext) );
301
302 xNameAccess->getByName( aModuleId ) >>= m_xCommandToLabelMap;
303
304 if ( !m_xImgMgr.is() )
305 {
306 m_xImgMgr.set( GetConfigManager()->getImageManager(), uno::UNO_QUERY );
307 }
308
309 if ( !IsDocConfig() )
310 {
311 // If this is not a document configuration then it is the settings
312 // for the module (writer, calc, impress etc.) Use this as the default
313 // XImageManager instance
315 }
316 else
317 {
318 // If this is a document configuration then use the module image manager
319 // as default.
320 if ( m_xParentCfgMgr.is() )
321 {
322 m_xParentImgMgr.set( m_xParentCfgMgr->getImageManager(), uno::UNO_QUERY );
324 }
325 }
326}
327
329{
332
333 if (!xGraphic.is() && xDefaultImgMgr != nullptr && (*xDefaultImgMgr).is())
334 {
335 xGraphic = SvxConfigPageHelper::GetGraphic( (*xDefaultImgMgr), rCommandURL );
336 }
337
338 return xGraphic;
339}
340
342 const uno::Reference< uno::XInterface >& xManager )
343{
344 bool result = true;
345
346 try
347 {
348 if ( xManager.is() && !IsReadOnly() )
349 {
351 xConfigPersistence( xManager, uno::UNO_QUERY );
352
353 if ( xConfigPersistence->isModified() )
354 {
355 xConfigPersistence->store();
356 }
357 }
358 }
359 catch ( css::io::IOException& )
360 {
361 result = false;
362 }
363
364 return result;
365}
366
367/******************************************************************************
368 *
369 * The MenuSaveInData class extends SaveInData and provides menu specific
370 * load and store functionality.
371 *
372 ******************************************************************************/
373
374// Initialize static variable which holds default Menu data
376
380 const OUString& aModuleId,
381 bool isDocConfig )
382 :
383 SaveInData( cfgmgr, xParentCfgMgr, aModuleId, isDocConfig ),
384 m_aMenuResourceURL(
386 m_aDescriptorContainer(
388{
389 try
390 {
391 m_xMenuSettings = GetConfigManager()->getSettings( ITEM_MENUBAR_URL, false );
392 }
393 catch ( container::NoSuchElementException& )
394 {
395 // will use menu settings for the module
396 }
397
398 // If this is not a document configuration then it is the settings
399 // for the module (writer, calc, impress etc.). These settings should
400 // be set as the default to be used for SaveIn locations that do not
401 // have custom settings
402 if ( !IsDocConfig() )
403 {
404 SetDefaultData( this );
405 }
406}
407
409{
410}
411
414{
415 if ( pRootEntry == nullptr )
416 {
417 pRootEntry.reset( new SvxConfigEntry( "MainMenus", OUString(), true, /*bParentData*/false) );
418
419 if ( m_xMenuSettings.is() )
420 {
421 LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry.get(), false );
422 }
423 else if ( GetDefaultData() != nullptr )
424 {
425 // If the doc has no config settings use module config settings
426 LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry.get(), false );
427 }
428 }
429
430 return pRootEntry->GetEntries();
431}
432
433void
434MenuSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
435{
436 pRootEntry->SetEntries( std::move(pNewEntries) );
437}
438
440 const OUString& rBaseTitle, SvxConfigEntry const * pParentData, bool bContextMenu )
441{
442 SvxEntries* pEntries = pParentData->GetEntries();
443
444 // Don't access non existing menu configuration!
445 if ( !xMenuSettings.is() )
446 return;
447
448 for ( sal_Int32 nIndex = 0; nIndex < xMenuSettings->getCount(); ++nIndex )
449 {
451 OUString aCommandURL;
452 OUString aLabel;
453
454 sal_uInt16 nType( css::ui::ItemType::DEFAULT );
455 sal_Int32 nStyle(0);
456
457 bool bItem = SvxConfigPageHelper::GetMenuItemData( xMenuSettings, nIndex,
458 aCommandURL, aLabel, nType, nStyle, xSubMenu );
459
460 if ( bItem )
461 {
462 bool bIsUserDefined = true;
463
464 if ( nType == css::ui::ItemType::DEFAULT )
465 {
466 uno::Any a;
467 try
468 {
469 a = m_xCommandToLabelMap->getByName( aCommandURL );
470 bIsUserDefined = false;
471 }
472 catch ( container::NoSuchElementException& )
473 {
474 bIsUserDefined = true;
475 }
476
477 bool bUseDefaultLabel = false;
478 // If custom label not set retrieve it from the command
479 // to info service
480 if ( aLabel.isEmpty() )
481 {
482 bUseDefaultLabel = true;
484 if ( a >>= aPropSeq )
485 {
486 OUString aMenuLabel;
487 for ( const beans::PropertyValue& prop : std::as_const(aPropSeq) )
488 {
489 if ( bContextMenu )
490 {
491 if ( prop.Name == "PopupLabel" )
492 {
493 prop.Value >>= aLabel;
494 break;
495 }
496 else if ( prop.Name == "Label" )
497 {
498 prop.Value >>= aMenuLabel;
499 }
500 }
501 else if ( prop.Name == "Label" )
502 {
503 prop.Value >>= aLabel;
504 break;
505 }
506 }
507 if ( aLabel.isEmpty() )
508 aLabel = aMenuLabel;
509 }
510 }
511
512 SvxConfigEntry* pEntry = new SvxConfigEntry(
513 aLabel, aCommandURL, xSubMenu.is(), /*bParentData*/false );
514
515 pEntry->SetStyle( nStyle );
516 pEntry->SetUserDefined( bIsUserDefined );
517 if ( !bUseDefaultLabel )
518 pEntry->SetName( aLabel );
519
520 pEntries->push_back( pEntry );
521
522 if ( xSubMenu.is() )
523 {
524 // popup menu
525 OUString subMenuTitle( rBaseTitle );
526
527 if ( !subMenuTitle.isEmpty() )
528 {
529 subMenuTitle += aMenuSeparatorStr;
530 }
531 else
532 {
533 pEntry->SetMain();
534 }
535
536 subMenuTitle += SvxConfigPageHelper::stripHotKey( aLabel );
537
538 LoadSubMenus( xSubMenu, subMenuTitle, pEntry, bContextMenu );
539 }
540 }
541 else
542 {
543 SvxConfigEntry* pEntry = new SvxConfigEntry;
544 pEntry->SetUserDefined( bIsUserDefined );
545 pEntries->push_back( pEntry );
546 }
547 }
548 }
549}
550
552{
553 bool result = false;
554
555 if ( IsModified() )
556 {
557 // Apply new menu bar structure to our settings container
558 m_xMenuSettings = GetConfigManager()->createSettings();
559
561 m_xMenuSettings, uno::UNO_QUERY );
562
564 m_xMenuSettings, uno::UNO_QUERY );
565
566 Apply( xIndexContainer, xFactory );
567
568 try
569 {
570 if ( GetConfigManager()->hasSettings( m_aMenuResourceURL ) )
571 {
572 GetConfigManager()->replaceSettings(
574 }
575 else
576 {
577 GetConfigManager()->insertSettings(
579 }
580 }
581 catch ( css::uno::Exception& )
582 {
583 TOOLS_WARN_EXCEPTION("cui.customize", "caught some other exception saving settings");
584 }
585
586 SetModified( false );
587
589 }
590
591 return result;
592}
593
597{
598 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
599
600 for (auto const& entryData : *GetEntries())
601 {
604
606 rFactory->createInstanceWithContext( xContext ),
607 uno::UNO_QUERY );
608
609 sal_Int32 nIndex = aPropValueSeq.getLength();
610 aPropValueSeq.realloc( nIndex + 1 );
611 auto pPropValueSeq = aPropValueSeq.getArray();
612 pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
613 pPropValueSeq[nIndex].Value <<= xSubMenuBar;
614 rMenuBar->insertByIndex(
615 rMenuBar->getCount(), uno::Any( aPropValueSeq ));
616 ApplyMenu( xSubMenuBar, rFactory, entryData );
617 }
618}
619
623 SvxConfigEntry* pMenuData )
624{
625 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
626
627 for (auto const& entry : *pMenuData->GetEntries())
628 {
629 if (entry->IsPopup())
630 {
633
635 rFactory->createInstanceWithContext( xContext ),
636 uno::UNO_QUERY );
637
638 sal_Int32 nIndex = aPropValueSeq.getLength();
639 aPropValueSeq.realloc( nIndex + 1 );
640 auto pPropValueSeq = aPropValueSeq.getArray();
641 pPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER;
642 pPropValueSeq[nIndex].Value <<= xSubMenuBar;
643
644 rMenuBar->insertByIndex(
645 rMenuBar->getCount(), uno::Any( aPropValueSeq ));
646
647 ApplyMenu( xSubMenuBar, rFactory, entry );
648 entry->SetModified( false );
649 }
650 else if (entry->IsSeparator())
651 {
652 rMenuBar->insertByIndex(
653 rMenuBar->getCount(), uno::Any( m_aSeparatorSeq ));
654 }
655 else
656 {
659 rMenuBar->insertByIndex(
660 rMenuBar->getCount(), uno::Any( aPropValueSeq ));
661 }
662 }
663 pMenuData->SetModified( false );
664}
665
666void
668{
669 try
670 {
671 GetConfigManager()->removeSettings( m_aMenuResourceURL );
672 }
673 catch ( const css::uno::Exception& )
674 {}
675
677
678 pRootEntry.reset();
679
680 try
681 {
682 m_xMenuSettings = GetConfigManager()->getSettings(
683 m_aMenuResourceURL, false );
684 }
685 catch ( container::NoSuchElementException& )
686 {
687 // will use default settings
688 }
689}
690
692 const css::uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
693 const css::uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
694 const OUString& aModuleId, bool bIsDocConfig )
695 : SaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bIsDocConfig )
696{
697 css::uno::Reference< css::uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
698 css::uno::Reference< css::container::XNameAccess > xConfig( css::ui::theWindowStateConfiguration::get( xContext ) );
699 xConfig->getByName( aModuleId ) >>= m_xPersistentWindowState;
700}
701
703{
704}
705
706OUString ContextMenuSaveInData::GetUIName( const OUString& rResourceURL )
707{
708 if ( m_xPersistentWindowState.is() )
709 {
710 css::uno::Sequence< css::beans::PropertyValue > aProps;
711 try
712 {
713 m_xPersistentWindowState->getByName( rResourceURL ) >>= aProps;
714 }
715 catch ( const css::uno::Exception& )
716 {}
717
718 for ( const auto& aProp : std::as_const(aProps) )
719 {
720 if ( aProp.Name == ITEM_DESCRIPTOR_UINAME )
721 {
722 OUString aResult;
723 aProp.Value >>= aResult;
724 return aResult;
725 }
726 }
727 }
728 return OUString();
729}
730
732{
733 if ( !m_pRootEntry )
734 {
735 std::unordered_map< OUString, bool > aMenuInfo;
736
737 m_pRootEntry.reset( new SvxConfigEntry( "ContextMenus", OUString(), true, /*bParentData*/false ) );
738 css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aElementsInfo;
739 try
740 {
741 aElementsInfo = GetConfigManager()->getUIElementsInfo( css::ui::UIElementType::POPUPMENU );
742 }
743 catch ( const css::lang::IllegalArgumentException& )
744 {}
745
746 for ( const auto& aElement : std::as_const(aElementsInfo) )
747 {
748 OUString aUrl;
749 for ( const auto& aElementProp : aElement )
750 {
751 if ( aElementProp.Name == ITEM_DESCRIPTOR_RESOURCEURL )
752 {
753 aElementProp.Value >>= aUrl;
754 break;
755 }
756 }
757
758 css::uno::Reference< css::container::XIndexAccess > xPopupMenu;
759 try
760 {
761 xPopupMenu = GetConfigManager()->getSettings( aUrl, false );
762 }
763 catch ( const css::uno::Exception& )
764 {}
765
766 if ( xPopupMenu.is() )
767 {
768 // insert into std::unordered_map to filter duplicates from the parent
769 aMenuInfo.emplace( aUrl, true );
770
771 OUString aUIMenuName = GetUIName( aUrl );
772 if ( aUIMenuName.isEmpty() )
773 // Menus without UI name aren't supposed to be customized.
774 continue;
775
776 SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true, /*bParentData*/false );
777 pEntry->SetMain();
778 m_pRootEntry->GetEntries()->push_back( pEntry );
779 LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true );
780 }
781 }
782
783 // Retrieve also the parent menus, to make it possible to configure module menus and save them into the document.
784 css::uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr = GetParentConfigManager();
785 css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aParentElementsInfo;
786 try
787 {
788 if ( xParentCfgMgr.is() )
789 aParentElementsInfo = xParentCfgMgr->getUIElementsInfo( css::ui::UIElementType::POPUPMENU );
790 }
791 catch ( const css::lang::IllegalArgumentException& )
792 {}
793
794 for ( const auto& aElement : std::as_const(aParentElementsInfo) )
795 {
796 OUString aUrl;
797 for ( const auto& aElementProp : aElement )
798 {
799 if ( aElementProp.Name == ITEM_DESCRIPTOR_RESOURCEURL )
800 {
801 aElementProp.Value >>= aUrl;
802 break;
803 }
804 }
805
806 css::uno::Reference< css::container::XIndexAccess > xPopupMenu;
807 try
808 {
809 if ( aMenuInfo.find( aUrl ) == aMenuInfo.end() )
810 xPopupMenu = xParentCfgMgr->getSettings( aUrl, false );
811 }
812 catch ( const css::uno::Exception& )
813 {}
814
815 if ( xPopupMenu.is() )
816 {
817 OUString aUIMenuName = GetUIName( aUrl );
818 if ( aUIMenuName.isEmpty() )
819 continue;
820
821 SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true, true );
822 pEntry->SetMain();
823 m_pRootEntry->GetEntries()->push_back( pEntry );
824 LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true );
825 }
826 }
827 std::sort( m_pRootEntry->GetEntries()->begin(), m_pRootEntry->GetEntries()->end(), SvxConfigPageHelper::EntrySort );
828 }
829 return m_pRootEntry->GetEntries();
830}
831
832void ContextMenuSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
833{
834 m_pRootEntry->SetEntries( std::move(pNewEntries) );
835}
836
837bool ContextMenuSaveInData::HasURL( const OUString& rURL )
838{
839 SvxEntries* pEntries = GetEntries();
840 for ( const auto& pEntry : *pEntries )
841 if ( pEntry->GetCommand() == rURL )
842 return true;
843
844 return false;
845}
846
848{
849 return m_pRootEntry && !m_pRootEntry->GetEntries()->empty();
850}
851
853{
854 if ( !IsModified() )
855 return false;
856
857 SvxEntries* pEntries = GetEntries();
858 for ( const auto& pEntry : *pEntries )
859 {
860 if ( pEntry->IsModified() || SvxConfigPageHelper::SvxConfigEntryModified( pEntry ) )
861 {
862 css::uno::Reference< css::container::XIndexContainer > xIndexContainer = GetConfigManager()->createSettings();
863 css::uno::Reference< css::lang::XSingleComponentFactory > xFactory( xIndexContainer, css::uno::UNO_QUERY );
864 ApplyMenu( xIndexContainer, xFactory, pEntry );
865
866 const OUString& aUrl = pEntry->GetCommand();
867 try
868 {
869 if ( GetConfigManager()->hasSettings( aUrl ) )
870 GetConfigManager()->replaceSettings( aUrl, xIndexContainer );
871 else
872 GetConfigManager()->insertSettings( aUrl, xIndexContainer );
873 }
874 catch ( const css::uno::Exception& )
875 {}
876 }
877 }
878 SetModified( false );
880}
881
883{
884 SvxEntries* pEntries = GetEntries();
885 for ( const auto& pEntry : *pEntries )
886 {
887 try
888 {
889 GetConfigManager()->removeSettings( pEntry->GetCommand() );
890 }
891 catch ( const css::uno::Exception& )
892 {
893 TOOLS_WARN_EXCEPTION("cui.customize", "Exception caught while resetting context menus");
894 }
895 }
897 m_pRootEntry.reset();
898}
899
901{
902 try
903 {
904 GetConfigManager()->removeSettings( pEntry->GetCommand() );
905 }
906 catch ( const css::uno::Exception& )
907 {
908 TOOLS_WARN_EXCEPTION("cui.customize", "Exception caught while resetting context menu");
909 }
911 m_pRootEntry.reset();
912}
913
915{
916 int nWidth = (m_xControl->get_text_height() * 3) / 4;
917 m_xDropDown->SetOutputSizePixel(Size(nWidth, nWidth));
918 DecorationView aDecoView(m_xDropDown.get());
919 aDecoView.DrawSymbol(tools::Rectangle(Point(0, 0), Size(nWidth, nWidth)),
920 SymbolType::SPIN_RIGHT, m_xDropDown->GetTextColor(),
921 DrawSymbolFlags::NONE);
922}
923
924/******************************************************************************
925 *
926 * SvxMenuEntriesListBox is the listbox in which the menu items for a
927 * particular menu are shown. We have a custom listbox because we need
928 * to add drag'n'drop support from the Macro Selector and within the
929 * listbox
930 *
931 *****************************************************************************/
932SvxMenuEntriesListBox::SvxMenuEntriesListBox(std::unique_ptr<weld::TreeView> xControl, SvxConfigPage* pPg)
933 : m_xControl(std::move(xControl))
934 , m_xDropDown(m_xControl->create_virtual_device())
935 , m_pPage(pPg)
936{
937 m_xControl->enable_toggle_buttons(weld::ColumnToggleType::Check);
939 m_xControl->connect_key_press(LINK(this, SvxMenuEntriesListBox, KeyInputHdl));
940}
941
943{
944}
945
946IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
947{
948 vcl::KeyCode keycode = rKeyEvent.GetKeyCode();
949
950 // support DELETE for removing the current entry
951 if ( keycode == KEY_DELETE )
952 {
953 m_pPage->DeleteSelectedContent();
954 }
955 // support CTRL+UP and CTRL+DOWN for moving selected entries
956 else if ( keycode.GetCode() == KEY_UP && keycode.IsMod1() )
957 {
958 m_pPage->MoveEntry( true );
959 }
960 else if ( keycode.GetCode() == KEY_DOWN && keycode.IsMod1() )
961 {
962 m_pPage->MoveEntry( false );
963 }
964 else
965 {
966 return false; // pass on to default handler
967 }
968 return true;
969}
970
971/******************************************************************************
972 *
973 * SvxConfigPage is the abstract base class on which the Menu and Toolbar
974 * configuration tabpages are based. It includes methods which are common to
975 * both tabpages to add, delete, move and rename items etc.
976 *
977 *****************************************************************************/
979 : SfxTabPage(pPage, pController, "cui/ui/menuassignpage.ui", "MenuAssignPage", &rSet)
980 , m_aUpdateDataTimer( "SvxConfigPage UpdateDataTimer" )
981 , bInitialised(false)
982 , pCurrentSaveInData(nullptr)
983 , m_xCommandCategoryListBox(new CommandCategoryListBox(m_xBuilder->weld_combo_box("commandcategorylist")))
984 , m_xFunctions(new CuiConfigFunctionListBox(m_xBuilder->weld_tree_view("functions")))
985 , m_xCategoryLabel(m_xBuilder->weld_label("categorylabel"))
986 , m_xDescriptionFieldLb(m_xBuilder->weld_label("descriptionlabel"))
987 , m_xDescriptionField(m_xBuilder->weld_text_view("desc"))
988 , m_xLeftFunctionLabel(m_xBuilder->weld_label("leftfunctionlabel"))
989 , m_xSearchEdit(m_xBuilder->weld_entry("searchEntry"))
990 , m_xSearchLabel(m_xBuilder->weld_label("searchlabel"))
991 , m_xCustomizeLabel(m_xBuilder->weld_label("customizelabel"))
992 , m_xTopLevelListBox(m_xBuilder->weld_combo_box("toplevellist"))
993 , m_xMoveUpButton(m_xBuilder->weld_button("up"))
994 , m_xMoveDownButton(m_xBuilder->weld_button("down"))
995 , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
996 , m_xInsertBtn(m_xBuilder->weld_menu_button("insert"))
997 , m_xModifyBtn(m_xBuilder->weld_menu_button("modify"))
998 , m_xResetBtn(m_xBuilder->weld_button("defaultsbtn"))
999 , m_xAddCommandButton(m_xBuilder->weld_button("add"))
1000 , m_xRemoveCommandButton(m_xBuilder->weld_button("remove"))
1001{
1003
1004 m_xTopLevelListBox->connect_changed(LINK(this, SvxConfigPage, SelectElementHdl));
1005
1006 weld::TreeView& rTreeView = m_xFunctions->get_widget();
1007 Size aSize(rTreeView.get_approximate_digit_width() * 40, rTreeView.get_height_rows(8));
1008 m_xFunctions->set_size_request(aSize.Width(), aSize.Height());
1009 m_xDescriptionField->set_size_request(aSize.Width(), m_xDescriptionField->get_height_rows(3));
1010
1011 m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SvxConfigPage, ImplUpdateDataHdl));
1013
1014 m_xSearchEdit->connect_changed(LINK(this, SvxConfigPage, SearchUpdateHdl));
1015 m_xSearchEdit->connect_focus_out(LINK(this, SvxConfigPage, FocusOut_Impl));
1016
1017 rTreeView.connect_row_activated(LINK(this, SvxConfigPage, FunctionDoubleClickHdl));
1018 rTreeView.connect_changed(LINK(this, SvxConfigPage, SelectFunctionHdl));
1019}
1020
1022{
1023 SelectElement();
1024}
1025
1027{
1028 int cnt = m_xSaveInListBox->get_count();
1029 for(int i=0; i < cnt; ++i)
1030 {
1031 SaveInData *pData = weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i));
1032 delete pData;
1033 }
1034}
1035
1037{
1038 // If we haven't initialised our XMultiServiceFactory reference
1039 // then Reset is being called at the opening of the dialog.
1040
1041 // Load menu configuration data for the module of the currently
1042 // selected document, for the currently selected document, and for
1043 // all other open documents of the same module type
1044 if ( !bInitialised )
1045 {
1046 sal_Int32 nPos = 0;
1049
1051 ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
1052
1053 m_xFrame = GetFrame();
1055
1056 // replace %MODULENAME in the label with the correct module name
1058 css::frame::ModuleManager::create( xContext ));
1059 OUString aModuleName = SvxConfigPageHelper::GetUIModuleName( m_aModuleId, xModuleManager );
1060
1062 xModuleCfgSupplier( css::ui::theModuleUIConfigurationManagerSupplier::get(xContext) );
1063
1064 // Set up data for module specific menus
1065 SaveInData* pModuleData = nullptr;
1066
1067 try
1068 {
1069 xCfgMgr =
1070 xModuleCfgSupplier->getUIConfigurationManager( m_aModuleId );
1071
1072 pModuleData = CreateSaveInData( xCfgMgr,
1075 false );
1076 }
1077 catch ( container::NoSuchElementException& )
1078 {
1079 }
1080
1081 if ( pModuleData != nullptr )
1082 {
1083 OUString sId(weld::toId(pModuleData));
1084 m_xSaveInListBox->append(sId, utl::ConfigManager::getProductName() + " " + aModuleName);
1085 }
1086
1087 // try to retrieve the document based ui configuration manager
1088 OUString aTitle;
1090 m_xFrame->getController();
1091 if ( CanConfig( m_aModuleId ) && xController.is() )
1092 {
1094 if ( xModel.is() )
1095 {
1097 xCfgSupplier( xModel, uno::UNO_QUERY );
1098
1099 if ( xCfgSupplier.is() )
1100 {
1101 xDocCfgMgr = xCfgSupplier->getUIConfigurationManager();
1102 }
1103 aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
1104 }
1105 }
1106
1107 SaveInData* pDocData = nullptr;
1108 if ( xDocCfgMgr.is() )
1109 {
1110 pDocData = CreateSaveInData( xDocCfgMgr, xCfgMgr, m_aModuleId, true );
1111
1112 if ( !pDocData->IsReadOnly() )
1113 {
1114 OUString sId(weld::toId(pDocData));
1115 m_xSaveInListBox->append(sId, aTitle);
1116 }
1117 }
1118
1119 // if an item to select has been passed in (eg. the ResourceURL for a
1120 // toolbar) then try to select the SaveInData entry that has that item
1121 bool bURLToSelectFound = false;
1122 if ( !m_aURLToSelect.isEmpty() )
1123 {
1124 if ( pDocData && pDocData->HasURL( m_aURLToSelect ) )
1125 {
1126 m_xSaveInListBox->set_active(nPos);
1127 pCurrentSaveInData = pDocData;
1128 bURLToSelectFound = true;
1129 }
1130 else if ( pModuleData && pModuleData->HasURL( m_aURLToSelect ) )
1131 {
1132 m_xSaveInListBox->set_active(0);
1133 pCurrentSaveInData = pModuleData;
1134 bURLToSelectFound = true;
1135 }
1136 }
1137
1138 if ( !bURLToSelectFound )
1139 {
1140 // if the document has menu configuration settings select it
1141 // it the SaveIn listbox, otherwise select the module data
1142 if ( pDocData != nullptr && pDocData->HasSettings() )
1143 {
1144 m_xSaveInListBox->set_active(nPos);
1145 pCurrentSaveInData = pDocData;
1146 }
1147 else
1148 {
1149 m_xSaveInListBox->set_active(0);
1150 pCurrentSaveInData = pModuleData;
1151 }
1152 }
1153
1154#ifdef DBG_UTIL
1155 DBG_ASSERT( pCurrentSaveInData, "SvxConfigPage::Reset(): no SaveInData" );
1156#endif
1157
1158 if ( CanConfig( m_aModuleId ) )
1159 {
1160 // Load configuration for other open documents which have
1161 // same module type
1163 try
1164 {
1165 uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
1166 xContext );
1167
1169 xFramesSupplier->getFrames();
1170
1171 aFrameList = xFrames->queryFrames(
1172 frame::FrameSearchFlag::ALL & ~frame::FrameSearchFlag::SELF );
1173
1174 }
1175 catch( const uno::Exception& )
1176 {
1177 DBG_UNHANDLED_EXCEPTION("cui.customize");
1178 }
1179
1180 for ( uno::Reference < frame::XFrame > const & xf : std::as_const(aFrameList) )
1181 {
1182 if ( xf.is() && xf != m_xFrame )
1183 {
1184 OUString aCheckId;
1185 try{
1186 aCheckId = xModuleManager->identify( xf );
1187 } catch(const uno::Exception&)
1188 { aCheckId.clear(); }
1189
1190 if ( m_aModuleId == aCheckId )
1191 {
1192 // try to get the document based ui configuration manager
1193 OUString aTitle2;
1195 xf->getController();
1196
1197 if ( xController_.is() )
1198 {
1200 xController_->getModel() );
1201
1202 if ( xModel.is() )
1203 {
1205 css::ui::XUIConfigurationManagerSupplier >
1206 xCfgSupplier( xModel, uno::UNO_QUERY );
1207
1208 if ( xCfgSupplier.is() )
1209 {
1210 xDocCfgMgr =
1211 xCfgSupplier->getUIConfigurationManager();
1212 }
1213 aTitle2 = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
1214 }
1215 }
1216
1217 if ( xDocCfgMgr.is() )
1218 {
1219 SaveInData* pData = CreateSaveInData( xDocCfgMgr, xCfgMgr, m_aModuleId, true );
1220
1221 if ( pData && !pData->IsReadOnly() )
1222 {
1223 OUString sId(weld::toId(pData));
1224 m_xSaveInListBox->append(sId, aTitle2);
1225 }
1226 }
1227 }
1228 }
1229 }
1230 }
1231
1232 m_xSaveInListBox->connect_changed(
1233 LINK( this, SvxConfigPage, SelectSaveInLocation ) );
1234
1235 bInitialised = true;
1236
1237 Init();
1238 }
1239 else
1240 {
1241 if ( QueryReset() == RET_YES )
1242 {
1243 // Reset menu configuration for currently selected SaveInData
1244 GetSaveInData()->Reset();
1245
1246 Init();
1247 }
1248 }
1249}
1250
1252{
1253 OUString sModuleID;
1254 try
1255 {
1257 ::comphelper::getProcessComponentContext() );
1258
1259 uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(
1260 xContext );
1261
1262 if ( !_inout_rxFrame.is() )
1263 _inout_rxFrame = xDesktop->getActiveFrame();
1264
1265 if ( !_inout_rxFrame.is() )
1266 {
1267 _inout_rxFrame = xDesktop->getCurrentFrame();
1268 }
1269
1270 if ( !_inout_rxFrame.is() && SfxViewFrame::Current() )
1271 _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
1272
1273 if ( !_inout_rxFrame.is() )
1274 {
1275 SAL_WARN( "cui.customize", "SvxConfigPage::GetFrameWithDefaultAndIdentify(): no frame found!" );
1276 return sModuleID;
1277 }
1278
1279 sModuleID = vcl::CommandInfoProvider::GetModuleIdentifier(_inout_rxFrame);
1280 }
1281 catch( const uno::Exception& )
1282 {
1283 DBG_UNHANDLED_EXCEPTION("cui.customize");
1284 }
1285
1286 return sModuleID;
1287}
1288
1290{
1291 OUString result;
1292
1293 SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
1294 if (pData)
1295 {
1296 if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
1297 ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) ||
1298 ( pData->nKind == SfxCfgKind::GROUP_STYLES ) )
1299 {
1300 result = pData->sCommand;
1301 }
1302 }
1303
1304 return result;
1305}
1306
1308{
1309 return m_xFunctions->get_selected_text();
1310}
1311
1313{
1314 bool result = false;
1315
1316 for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
1317 {
1318 OUString sId = m_xSaveInListBox->get_id(i);
1319 if (sId != notebookbarTabScope)
1320 {
1321 SaveInData* pData = weld::fromId<SaveInData*>(sId);
1322 result = pData->Apply();
1323 }
1324 }
1325 return result;
1326}
1327
1328IMPL_LINK_NOARG(SvxConfigPage, SelectSaveInLocation, weld::ComboBox&, void)
1329{
1330 OUString sId = m_xSaveInListBox->get_active_id();
1331 if (sId != notebookbarTabScope)
1332 pCurrentSaveInData = weld::fromId<SaveInData*>(sId);
1333 Init();
1334}
1335
1337{
1338 int nSelectionPos = m_xTopLevelListBox->get_active();
1339 m_xTopLevelListBox->clear();
1340
1341 if ( GetSaveInData() && GetSaveInData()->GetEntries() )
1342 {
1343 for (auto const& entryData : *GetSaveInData()->GetEntries())
1344 {
1345 OUString sId(weld::toId(entryData));
1346 m_xTopLevelListBox->append(sId, SvxConfigPageHelper::stripHotKey(entryData->GetName()));
1347
1348 if (entryData == pToSelect)
1349 nSelectionPos = m_xTopLevelListBox->get_count() - 1;
1350
1351 AddSubMenusToUI( SvxConfigPageHelper::stripHotKey( entryData->GetName() ), entryData );
1352 }
1353 }
1354#ifdef DBG_UTIL
1355 else
1356 {
1357 DBG_ASSERT( GetSaveInData(), "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData" );
1358 DBG_ASSERT( GetSaveInData()->GetEntries() ,
1359 "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData entries" );
1360 }
1361#endif
1362
1363 nSelectionPos = (nSelectionPos != -1 && nSelectionPos < m_xTopLevelListBox->get_count()) ?
1364 nSelectionPos : m_xTopLevelListBox->get_count() - 1;
1365
1366 m_xTopLevelListBox->set_active(nSelectionPos);
1367 SelectElement();
1368}
1369
1371 std::u16string_view rBaseTitle, SvxConfigEntry const * pParentData )
1372{
1373 for (auto const& entryData : *pParentData->GetEntries())
1374 {
1375 if (entryData->IsPopup())
1376 {
1377 OUString subMenuTitle = OUString::Concat(rBaseTitle) + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey(entryData->GetName());
1378
1379 OUString sId(weld::toId(entryData));
1380 m_xTopLevelListBox->append(sId, subMenuTitle);
1381
1382 AddSubMenusToUI( subMenuTitle, entryData );
1383 }
1384 }
1385}
1386
1388 SvxEntries* pRootEntries, SvxConfigEntry* pChildData )
1389{
1390 for (auto const& entryData : *pRootEntries)
1391 {
1392
1393 if (entryData == pChildData)
1394 {
1395 return pRootEntries;
1396 }
1397 else if (entryData->IsPopup())
1398 {
1400 FindParentForChild( entryData->GetEntries(), pChildData );
1401
1402 if ( result != nullptr )
1403 {
1404 return result;
1405 }
1406 }
1407 }
1408 return nullptr;
1409}
1410
1412{
1413 OUString aDisplayName;
1414
1415 if ( aURL.isEmpty() ) {
1416 return nullptr;
1417 }
1418
1420
1421 if ( typeid(*pCurrentSaveInData) == typeid(ContextMenuSaveInData) )
1423 else if ( typeid(*pCurrentSaveInData) == typeid(MenuSaveInData) )
1425 else
1427
1428 SvxConfigEntry* toret =
1429 new SvxConfigEntry( aDisplayName, aURL, false, /*bParentData*/false );
1430
1431 toret->SetUserDefined();
1432
1433 if ( aDisplayName.isEmpty() )
1434 toret->SetName( GetSelectedDisplayName() );
1435
1436 return toret;
1437}
1438
1440 const SvxEntries *pEntries)
1441{
1442 bool toret = false;
1443
1444 if ( pEntries != nullptr
1445 && pEntryData != nullptr )
1446 {
1447 for (auto const& entry : *pEntries)
1448 {
1449 if ( entry->GetCommand() == pEntryData->GetCommand() )
1450 {
1451 toret = true;
1452 break;
1453 }
1454 }
1455 }
1456
1457 return toret;
1458}
1459
1460int SvxConfigPage::AddFunction(int nTarget, bool bAllowDuplicates)
1461{
1462 int toret = -1;
1463 OUString aURL = GetScriptURL();
1465
1466 if ( aURL.isEmpty() || pParent == nullptr )
1467 {
1468 return -1;
1469 }
1470
1471
1472 SvxConfigEntry * pNewEntryData = CreateCommandFromSelection( aURL );
1473
1474 // check that this function is not already in the menu
1475 if ( !bAllowDuplicates
1476 && IsCommandInMenuList( pNewEntryData, pParent->GetEntries() )
1477 )
1478 {
1479 delete pNewEntryData;
1480 } else {
1481 toret = AppendEntry( pNewEntryData, nTarget );
1482 }
1483
1485 return toret;
1486}
1487
1489 SvxConfigEntry* pNewEntryData,
1490 int nTarget)
1491{
1492 SvxConfigEntry* pTopLevelSelection = GetTopLevelSelection();
1493
1494 if (pTopLevelSelection == nullptr)
1495 return -1;
1496
1497 // Grab the entries list for the currently selected menu
1498 SvxEntries* pEntries = pTopLevelSelection->GetEntries();
1499
1500 int nNewEntry = -1;
1501 int nCurEntry =
1502 nTarget != -1 ? nTarget : m_xContentsListBox->get_selected_index();
1503
1504 OUString sId(weld::toId(pNewEntryData));
1505
1506 if (nCurEntry == -1 || nCurEntry == m_xContentsListBox->n_children() - 1)
1507 {
1508 pEntries->push_back( pNewEntryData );
1509 m_xContentsListBox->insert(-1, sId);
1510 nNewEntry = m_xContentsListBox->n_children() - 1;
1511 }
1512 else
1513 {
1514 SvxConfigEntry* pEntryData =
1515 weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry));
1516
1517 SvxEntries::iterator iter = pEntries->begin();
1518 SvxEntries::const_iterator end = pEntries->end();
1519
1520 // Advance the iterator to the data for currently selected entry
1521 sal_uInt16 nPos = 0;
1522 while (*iter != pEntryData && ++iter != end)
1523 {
1524 ++nPos;
1525 }
1526
1527 // Now step past it to the entry after the currently selected one
1528 ++iter;
1529 ++nPos;
1530
1531 // Now add the new entry to the UI and to the parent's list
1532 if ( iter != end )
1533 {
1534 pEntries->insert( iter, pNewEntryData );
1535 m_xContentsListBox->insert(nPos, sId);
1536 nNewEntry = nPos;
1537 }
1538 }
1539
1540 if (nNewEntry != -1)
1541 {
1542 m_xContentsListBox->select(nNewEntry);
1543 m_xContentsListBox->scroll_to_row(nNewEntry);
1544
1547 }
1548
1549 return nNewEntry;
1550}
1551
1552namespace
1553{
1554 template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, SaveInData* pSaveInData,
1555 VirtualDevice& rDropDown, bool bMenu)
1556 {
1557 OUString sId(weld::toId(pNewEntryData));
1558
1559 rTreeView.set_id(rIter, sId);
1560
1561 if (pNewEntryData->IsSeparator())
1562 {
1563 rTreeView.set_text(rIter, "----------------------------------", 0);
1564 }
1565 else
1566 {
1567 auto xImage = pSaveInData->GetImage(pNewEntryData->GetCommand());
1568 if (xImage.is())
1569 rTreeView.set_image(rIter, xImage, -1);
1570 OUString aName = SvxConfigPageHelper::stripHotKey( pNewEntryData->GetName() );
1571 rTreeView.set_text(rIter, aName, 0);
1572 }
1573
1574 if (bMenu) // menus
1575 {
1576 if (pNewEntryData->IsPopup() || pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN)
1577 rTreeView.set_image(rIter, rDropDown, 1);
1578 else
1579 rTreeView.set_image(rIter, css::uno::Reference<css::graphic::XGraphic>(), 1);
1580 }
1581 }
1582}
1583
1584void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, int nPos, bool bMenu)
1585{
1586 TmplInsertEntryIntoUI<int>(pNewEntryData, rTreeView, nPos, GetSaveInData(),
1587 m_xContentsListBox->get_dropdown_image(), bMenu);
1588}
1589
1590void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, weld::TreeIter& rIter, bool bMenu)
1591{
1592 TmplInsertEntryIntoUI<weld::TreeIter>(pNewEntryData, rTreeView, rIter, GetSaveInData(),
1593 m_xContentsListBox->get_dropdown_image(), bMenu);
1594}
1595
1596IMPL_LINK(SvxConfigPage, MoveHdl, weld::Button&, rButton, void)
1597{
1598 MoveEntry(&rButton == m_xMoveUpButton.get());
1599}
1600
1601IMPL_LINK_NOARG(SvxConfigPage, FunctionDoubleClickHdl, weld::TreeView&, bool)
1602{
1603 if (m_xAddCommandButton->get_sensitive())
1604 m_xAddCommandButton->clicked();
1605 return true;
1606}
1607
1609{
1610 // GetScriptURL() returns a non-empty string if a
1611 // valid command is selected on the left box
1612 OUString aSelectCommand = GetScriptURL();
1613 bool bIsValidCommand = !aSelectCommand.isEmpty();
1614
1615 // Enable/disable Add and Remove buttons depending on current selection
1616 if (bIsValidCommand)
1617 {
1618 m_xAddCommandButton->set_sensitive(true);
1619 m_xRemoveCommandButton->set_sensitive(true);
1620
1622 {
1623 m_xDescriptionField->set_text(m_xFunctions->GetHelpText(false));
1624 }
1625 else
1626 {
1627 SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
1628 if (pData)
1629 {
1630 bool bIsExperimental
1631 = vcl::CommandInfoProvider::IsExperimental(pData->sCommand, m_aModuleId);
1632
1633 OUString aExperimental = "\n" + CuiResId(RID_CUISTR_COMMANDEXPERIMENTAL);
1634 OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pData->sLabel + "\n";
1635 OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": " + pData->sCommand + "\n";
1636 OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": " + pData->sTooltip;
1637 if (bIsExperimental)
1638 m_xDescriptionField->set_text(aLabel + aName + aTip + aExperimental);
1639 else
1640 m_xDescriptionField->set_text(aLabel + aName + aTip);
1641 }
1642 }
1643 }
1644 else
1645 {
1646
1647 m_xAddCommandButton->set_sensitive(false);
1648 m_xRemoveCommandButton->set_sensitive(false);
1649
1650 m_xDescriptionField->set_text("");
1651 }
1652
1653 UpdateButtonStates();
1654}
1655
1656IMPL_LINK_NOARG(SvxConfigPage, ImplUpdateDataHdl, Timer*, void)
1657{
1658 OUString aSearchTerm(m_xSearchEdit->get_text());
1659 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
1660 SelectFunctionHdl(m_xFunctions->get_widget());
1661}
1662
1664{
1665 m_aUpdateDataTimer.Start();
1666}
1667
1669{
1670 if (m_aUpdateDataTimer.IsActive())
1671 {
1672 m_aUpdateDataTimer.Stop();
1673 m_aUpdateDataTimer.Invoke();
1674 }
1675}
1676
1678{
1679 weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
1680
1681 int nSourceEntry = rTreeView.get_selected_index();
1682 int nTargetEntry = -1;
1683 int nToSelect = -1;
1684
1685 if (nSourceEntry == -1)
1686 {
1687 return;
1688 }
1689
1690 if ( bMoveUp )
1691 {
1692 // Move Up is just a Move Down with the source and target reversed
1693 nTargetEntry = nSourceEntry;
1694 nSourceEntry = nTargetEntry - 1;
1695 nToSelect = nSourceEntry;
1696 }
1697 else
1698 {
1699 nTargetEntry = nSourceEntry + 1;
1700 nToSelect = nTargetEntry;
1701 }
1702
1703 if (MoveEntryData(nSourceEntry, nTargetEntry))
1704 {
1705 rTreeView.swap(nSourceEntry, nTargetEntry);
1706 rTreeView.select(nToSelect);
1707 rTreeView.scroll_to_row(nToSelect);
1708
1710 }
1711}
1712
1713bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry)
1714{
1715 //#i53677#
1716 if (nSourceEntry == -1 || nTargetEntry == -1)
1717 {
1718 return false;
1719 }
1720
1721 // Grab the entries list for the currently selected menu
1723
1724 SvxConfigEntry* pSourceData =
1725 weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry));
1726
1727 SvxConfigEntry* pTargetData =
1728 weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry));
1729
1730 if ( pSourceData == nullptr || pTargetData == nullptr )
1731 return false;
1732
1733 // remove the source entry from our list
1734 SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
1735
1736 SvxEntries::iterator iter = pEntries->begin();
1737 SvxEntries::const_iterator end = pEntries->end();
1738
1739 // advance the iterator to the position of the target entry
1740 while (*iter != pTargetData && ++iter != end) ;
1741
1742 // insert the source entry at the position after the target
1743 pEntries->insert( ++iter, pSourceData );
1744
1747
1748 return true;
1749}
1750
1752 weld::Window* pParent, SvxEntries* entries,
1753 SvxConfigEntry const * selection, bool bCreateMenu )
1754 : GenericDialogController(pParent, "cui/ui/movemenu.ui", "MoveMenuDialog")
1755 , m_xMenuBox(m_xBuilder->weld_widget("namebox"))
1756 , m_xMenuNameEdit(m_xBuilder->weld_entry("menuname"))
1757 , m_xMenuListBox(m_xBuilder->weld_tree_view("menulist"))
1758 , m_xMoveUpButton(m_xBuilder->weld_button("up"))
1759 , m_xMoveDownButton(m_xBuilder->weld_button("down"))
1760{
1761 m_xMenuListBox->set_size_request(-1, m_xMenuListBox->get_height_rows(12));
1762
1763 // Copy the entries list passed in
1764 if ( entries != nullptr )
1765 {
1766 mpEntries.reset( new SvxEntries );
1767 for (auto const& entry : *entries)
1768 {
1769 m_xMenuListBox->append(weld::toId(entry),
1770 SvxConfigPageHelper::stripHotKey(entry->GetName()));
1771 mpEntries->push_back(entry);
1772 if (entry == selection)
1773 {
1774 m_xMenuListBox->select(m_xMenuListBox->n_children() - 1);
1775 }
1776 }
1777 }
1778
1779 if ( bCreateMenu )
1780 {
1781 // Generate custom name for new menu
1782 OUString prefix = CuiResId( RID_CUISTR_NEW_MENU );
1783
1784 OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries );
1785 OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries.get() );
1786
1787 SvxConfigEntry* pNewEntryData =
1788 new SvxConfigEntry( newname, newurl, true, /*bParentData*/false );
1789 pNewEntryData->SetName( newname );
1790 pNewEntryData->SetUserDefined();
1791 pNewEntryData->SetMain();
1792
1793 m_sNewMenuEntryId = weld::toId(pNewEntryData);
1795 SvxConfigPageHelper::stripHotKey(pNewEntryData->GetName()));
1796 m_xMenuListBox->select(m_xMenuListBox->n_children() - 1);
1797
1798 if (mpEntries)
1799 mpEntries->push_back(pNewEntryData);
1800
1801 m_xMenuNameEdit->set_text(newname);
1802 m_xMenuNameEdit->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, ModifyHdl));
1803 }
1804 else
1805 {
1806 // hide name label and textfield
1807 m_xMenuBox->hide();
1808 // change the title
1809 m_xDialog->set_title(CuiResId(RID_CUISTR_MOVE_MENU));
1810 }
1811
1812 m_xMenuListBox->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, SelectHdl));
1813
1814 m_xMoveUpButton->connect_clicked(LINK( this, SvxMainMenuOrganizerDialog, MoveHdl));
1815 m_xMoveDownButton->connect_clicked(LINK( this, SvxMainMenuOrganizerDialog, MoveHdl));
1816
1818}
1819
1821{
1822}
1823
1825{
1826 // if the Edit control is empty do not change the name
1827 if (m_xMenuNameEdit->get_text().isEmpty())
1828 {
1829 return;
1830 }
1831
1832 SvxConfigEntry* pNewEntryData = weld::fromId<SvxConfigEntry*>(m_sNewMenuEntryId);
1833 pNewEntryData->SetName(m_xMenuNameEdit->get_text());
1834
1835 const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId);
1836 const int nOldSelection = m_xMenuListBox->get_selected_index();
1837 m_xMenuListBox->remove(nNewMenuPos);
1838 m_xMenuListBox->insert(nNewMenuPos, pNewEntryData->GetName(), &m_sNewMenuEntryId, nullptr, nullptr);
1839 m_xMenuListBox->select(nOldSelection);
1840}
1841
1843{
1844 UpdateButtonStates();
1845}
1846
1848{
1849 // Disable Up and Down buttons depending on current selection
1850 const int nSelected = m_xMenuListBox->get_selected_index();
1851 m_xMoveUpButton->set_sensitive(nSelected > 0);
1852 m_xMoveDownButton->set_sensitive(nSelected != -1 && nSelected < m_xMenuListBox->n_children() - 1);
1853}
1854
1856{
1857 int nSourceEntry = m_xMenuListBox->get_selected_index();
1858 if (nSourceEntry == -1)
1859 return;
1860
1861 int nTargetEntry;
1862
1863 if (&rButton == m_xMoveDownButton.get())
1864 {
1865 nTargetEntry = nSourceEntry + 1;
1866 }
1867 else
1868 {
1869 // Move Up is just a Move Down with the source and target reversed
1870 nTargetEntry = nSourceEntry - 1;
1871 }
1872
1873 OUString sId = m_xMenuListBox->get_id(nSourceEntry);
1874 OUString sEntry = m_xMenuListBox->get_text(nSourceEntry);
1875 m_xMenuListBox->remove(nSourceEntry);
1876 m_xMenuListBox->insert(nTargetEntry, sEntry, &sId, nullptr, nullptr);
1877 m_xMenuListBox->select(nTargetEntry);
1878
1879 std::swap(mpEntries->at(nSourceEntry), mpEntries->at(nTargetEntry));
1880
1881 UpdateButtonStates();
1882}
1883
1885{
1886 const int nSelected(m_xMenuListBox->get_selected_index());
1887 if (nSelected == -1)
1888 return nullptr;
1889 return weld::fromId<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected));
1890}
1891
1892SvxConfigEntry::SvxConfigEntry( OUString aDisplayName,
1893 OUString aCommandURL, bool bPopup, bool bParentData )
1894 : nId( 1 )
1895 , aLabel(std::move(aDisplayName))
1896 , aCommand(std::move(aCommandURL))
1897 , bPopUp(bPopup)
1898 , bStrEdited( false )
1899 , bIsUserDefined( false )
1900 , bIsMain( false )
1901 , bIsParentData( bParentData )
1902 , bIsModified( false )
1903 , bIsVisible( true )
1904 , nStyle( 0 )
1905{
1906 if (bPopUp)
1907 {
1908 mpEntries.reset( new SvxEntries );
1909 }
1910}
1911
1913{
1914 if (mpEntries)
1915 {
1916 for (auto const& entry : *mpEntries)
1917 {
1918 delete entry;
1919 }
1920 }
1921}
1922
1924{
1925 return !IsPopup() || IsMain();
1926}
1927
1929{
1930 return !IsMain() || IsUserDefined();
1931}
1932
1934{
1935 return !IsMain() || IsUserDefined();
1936}
1937
1941 const OUString& aModuleId,
1942 bool docConfig ) :
1943
1944 SaveInData ( xCfgMgr, xParentCfgMgr, aModuleId, docConfig ),
1945 m_aDescriptorContainer ( ITEM_DESCRIPTOR_CONTAINER )
1946
1947{
1948 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
1949 // Initialize the m_xPersistentWindowState variable which is used
1950 // to get the default properties of system toolbars such as name
1951 uno::Reference< container::XNameAccess > xPWSS = css::ui::theWindowStateConfiguration::get( xContext );
1952
1953 xPWSS->getByName( aModuleId ) >>= m_xPersistentWindowState;
1954}
1955
1957{
1958}
1959
1960sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
1961{
1962 sal_Int32 result = 0;
1963
1964 if ( rResourceURL.startsWith( "private" ) &&
1966 m_xPersistentWindowState->hasByName( rResourceURL ) )
1967 {
1968 try
1969 {
1971 uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
1972
1973 if ( a >>= aProps )
1974 {
1975 for ( beans::PropertyValue const & prop : std::as_const(aProps) )
1976 {
1977 if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
1978 {
1979 prop.Value >>= result;
1980 break;
1981 }
1982 }
1983 }
1984 }
1985 catch ( uno::Exception& )
1986 {
1987 // do nothing, a default value is returned
1988 }
1989 }
1990
1991 return result;
1992}
1993
1995 const uno::Reference< frame::XFrame >& xFrame,
1996 const OUString& rResourceURL,
1997 sal_Int32 nStyle )
1998{
1999 // change the style using the API
2000 SetSystemStyle( rResourceURL, nStyle );
2001
2002 // this code is a temporary hack as the UI is not updating after
2003 // changing the toolbar style via the API
2005 vcl::Window *window = nullptr;
2006
2007 uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
2008 if ( xPropSet.is() )
2009 {
2010 uno::Any a = xPropSet->getPropertyValue( "LayoutManager" );
2011 a >>= xLayoutManager;
2012 }
2013
2014 if ( xLayoutManager.is() )
2015 {
2017 xLayoutManager->getElement( rResourceURL );
2018
2019 // check reference before we call getRealInterface. The layout manager
2020 // can only provide references for elements that have been created
2021 // before. It's possible that the current element is not available.
2023 if ( xUIElement.is() )
2024 xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY );
2025
2026 window = VCLUnoHelper::GetWindow( xWindow );
2027 }
2028
2029 if ( window == nullptr || window->GetType() != WindowType::TOOLBOX )
2030 return;
2031
2032 ToolBox* toolbox = static_cast<ToolBox*>(window);
2033
2034 if ( nStyle == 0 )
2035 {
2036 toolbox->SetButtonType( ButtonType::SYMBOLONLY );
2037 }
2038 else if ( nStyle == 1 )
2039 {
2040 toolbox->SetButtonType( ButtonType::TEXT );
2041 }
2042 if ( nStyle == 2 )
2043 {
2044 toolbox->SetButtonType( ButtonType::SYMBOLTEXT );
2045 }
2046}
2047
2049 const OUString& rResourceURL,
2050 sal_Int32 nStyle )
2051{
2052 if ( !(rResourceURL.startsWith( "private" ) &&
2054 m_xPersistentWindowState->hasByName( rResourceURL )) )
2055 return;
2056
2057 try
2058 {
2060
2061 uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
2062
2063 if ( a >>= aProps )
2064 {
2065 for ( beans::PropertyValue& prop : asNonConstRange(aProps) )
2066 {
2067 if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
2068 {
2069 prop.Value <<= nStyle;
2070 break;
2071 }
2072 }
2073 }
2074
2076 xNameReplace( m_xPersistentWindowState, uno::UNO_QUERY );
2077
2078 xNameReplace->replaceByName( rResourceURL, uno::Any( aProps ) );
2079 }
2080 catch ( uno::Exception& )
2081 {
2082 // do nothing, a default value is returned
2083 TOOLS_WARN_EXCEPTION("cui.customize", "Exception setting toolbar style");
2084 }
2085}
2086
2087OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
2088{
2089 OUString result;
2090
2091 if ( rResourceURL.startsWith( "private" ) &&
2093 m_xPersistentWindowState->hasByName( rResourceURL ) )
2094 {
2095 try
2096 {
2098 uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
2099
2100 if ( a >>= aProps )
2101 {
2102 for ( beans::PropertyValue const & prop : std::as_const(aProps) )
2103 {
2104 if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
2105 {
2106 prop.Value >>= result;
2107 }
2108 }
2109 }
2110 }
2111 catch ( uno::Exception& )
2112 {
2113 // do nothing, an empty UIName will be returned
2114 }
2115 }
2116
2117 if ( rResourceURL.startsWith( ".uno" ) &&
2118 m_xCommandToLabelMap.is() &&
2119 m_xCommandToLabelMap->hasByName( rResourceURL ) )
2120 {
2121 uno::Any a;
2122 try
2123 {
2124 a = m_xCommandToLabelMap->getByName( rResourceURL );
2125
2127 if ( a >>= aPropSeq )
2128 {
2129 for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
2130 {
2131 if ( prop.Name == ITEM_DESCRIPTOR_LABEL )
2132 {
2133 prop.Value >>= result;
2134 }
2135 }
2136 }
2137 }
2138 catch ( uno::Exception& )
2139 {
2140 // not a system command name
2141 }
2142 }
2143
2144 return result;
2145}
2146
2148{
2149 typedef std::unordered_map<OUString, bool > ToolbarInfo;
2150
2151 ToolbarInfo aToolbarInfo;
2152
2153 if ( pRootEntry == nullptr )
2154 {
2155
2156 pRootEntry.reset( new SvxConfigEntry( "MainToolbars", OUString(), true, /*bParentData*/false) );
2157
2159 GetConfigManager()->getUIElementsInfo(
2160 css::ui::UIElementType::TOOLBAR );
2161
2162 for ( uno::Sequence<beans::PropertyValue> const & props : info )
2163 {
2164 OUString url;
2165 OUString systemname;
2166 OUString uiname;
2167
2168 for ( const beans::PropertyValue& prop : props )
2169 {
2170 if ( prop.Name == ITEM_DESCRIPTOR_RESOURCEURL )
2171 {
2172 prop.Value >>= url;
2173 systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
2174 }
2175 else if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
2176 {
2177 prop.Value >>= uiname;
2178 }
2179 }
2180
2181 try
2182 {
2184 GetConfigManager()->getSettings( url, false );
2185
2186 if ( uiname.isEmpty() )
2187 {
2188 // try to get the name from m_xPersistentWindowState
2189 uiname = GetSystemUIName( url );
2190
2191 if ( uiname.isEmpty() )
2192 {
2193 uiname = systemname;
2194 }
2195 }
2196
2197 SvxConfigEntry* pEntry = new SvxConfigEntry(
2198 uiname, url, true, /*bParentData*/false );
2199
2200 pEntry->SetMain();
2201 pEntry->SetStyle( GetSystemStyle( url ) );
2202
2203
2204 // insert into std::unordered_map to filter duplicates from the parent
2205 aToolbarInfo.emplace( systemname, true );
2206
2207 if ( systemname.startsWith( CUSTOM_TOOLBAR_STR ) )
2208 {
2209 pEntry->SetUserDefined();
2210 }
2211 else
2212 {
2213 pEntry->SetUserDefined( false );
2214 }
2215
2216 pRootEntry->GetEntries()->push_back( pEntry );
2217
2218 LoadToolbar( xToolbarSettings, pEntry );
2219 }
2220 catch ( container::NoSuchElementException& )
2221 {
2222 // TODO, handle resourceURL with no settings
2223 }
2224 }
2225
2227 if ( xParentCfgMgr.is() )
2228 {
2229 // Retrieve also the parent toolbars to make it possible
2230 // to configure module toolbars and save them into the document
2231 // config manager.
2233 xParentCfgMgr->getUIElementsInfo(
2234 css::ui::UIElementType::TOOLBAR );
2235
2236 for ( uno::Sequence<beans::PropertyValue> const & props : info_ )
2237 {
2238 OUString url;
2239 OUString systemname;
2240 OUString uiname;
2241
2242 for ( const beans::PropertyValue& prop : props )
2243 {
2244 if ( prop.Name == ITEM_DESCRIPTOR_RESOURCEURL )
2245 {
2246 prop.Value >>= url;
2247 systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
2248 }
2249 else if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
2250 {
2251 prop.Value >>= uiname;
2252 }
2253 }
2254
2255 // custom toolbars of the parent are not visible in the document layer
2256 OUString custom(CUSTOM_TOOLBAR_STR);
2257 if ( systemname.startsWith( custom ) )
2258 continue;
2259
2260 // check if toolbar is already in the document layer
2261 ToolbarInfo::const_iterator pIter = aToolbarInfo.find( systemname );
2262 if ( pIter == aToolbarInfo.end() )
2263 {
2264 aToolbarInfo.emplace( systemname, true );
2265
2266 try
2267 {
2269 xParentCfgMgr->getSettings( url, false );
2270
2271 if ( uiname.isEmpty() )
2272 {
2273 // try to get the name from m_xPersistentWindowState
2274 uiname = GetSystemUIName( url );
2275
2276 if ( uiname.isEmpty() )
2277 {
2278 uiname = systemname;
2279 }
2280 }
2281
2282 SvxConfigEntry* pEntry = new SvxConfigEntry(
2283 uiname, url, true, true );
2284
2285 pEntry->SetMain();
2286 pEntry->SetStyle( GetSystemStyle( url ) );
2287
2288 if ( systemname.startsWith( custom ) )
2289 {
2290 pEntry->SetUserDefined();
2291 }
2292 else
2293 {
2294 pEntry->SetUserDefined( false );
2295 }
2296
2297 pRootEntry->GetEntries()->push_back( pEntry );
2298
2299 LoadToolbar( xToolbarSettings, pEntry );
2300 }
2301 catch ( container::NoSuchElementException& )
2302 {
2303 // TODO, handle resourceURL with no settings
2304 }
2305 }
2306 }
2307 }
2308
2310 }
2311
2312 return pRootEntry->GetEntries();
2313}
2314
2315void
2316ToolbarSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
2317{
2318 pRootEntry->SetEntries( std::move(pNewEntries) );
2319}
2320
2321bool
2322ToolbarSaveInData::HasURL( const OUString& rURL )
2323{
2324 for (auto const& entry : *GetEntries())
2325 {
2326 if (entry->GetCommand() == rURL)
2327 {
2328 return !entry->IsParentData();
2329 }
2330 }
2331 return false;
2332}
2333
2335{
2336 // return true if there is at least one toolbar entry
2337 return !GetEntries()->empty();
2338}
2339
2341{
2342 // reset each toolbar by calling removeSettings for its toolbar URL
2343 for (auto const& entry : *GetEntries())
2344 {
2345 try
2346 {
2347 const OUString& url = entry->GetCommand();
2348 GetConfigManager()->removeSettings( url );
2349 }
2350 catch ( uno::Exception& )
2351 {
2352 // error occurred removing the settings
2353 // TODO - add error dialog in future?
2354 }
2355 }
2356
2357 // persist changes to toolbar storage
2359
2360 // now delete the root SvxConfigEntry the next call to GetEntries()
2361 // causes it to be reinitialised
2362 pRootEntry.reset();
2363
2364 // reset all icons to default
2365 try
2366 {
2367 GetImageManager()->reset();
2369 }
2370 catch ( uno::Exception& )
2371 {
2372 SAL_WARN("cui.customize", "Error resetting all icons when resetting toolbars");
2373 }
2374}
2375
2377{
2378 // toolbar changes are instantly applied
2379 return false;
2380}
2381
2385 SvxConfigEntry const * pToolbarData )
2386{
2387 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
2388
2389 for (auto const& entry : *pToolbarData->GetEntries())
2390 {
2391 if (entry->IsPopup())
2392 {
2395
2397 rFactory->createInstanceWithContext( xContext ),
2398 uno::UNO_QUERY );
2399
2400 sal_Int32 nIndex = aPropValueSeq.getLength();
2401 aPropValueSeq.realloc( nIndex + 1 );
2402 auto pPropValueSeq = aPropValueSeq.getArray();
2403 pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
2404 pPropValueSeq[nIndex].Value <<= xSubMenuBar;
2405 rToolbarBar->insertByIndex(
2406 rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
2407
2408 ApplyToolbar(xSubMenuBar, rFactory, entry);
2409 }
2410 else if (entry->IsSeparator())
2411 {
2412 rToolbarBar->insertByIndex(
2413 rToolbarBar->getCount(), uno::Any( m_aSeparatorSeq ));
2414 }
2415 else
2416 {
2419
2420 rToolbarBar->insertByIndex(
2421 rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
2422 }
2423 }
2424}
2425
2427{
2428 // Apply new toolbar structure to our settings container
2430 GetConfigManager()->createSettings();
2431
2433 xSettings, uno::UNO_QUERY );
2434
2436 xSettings, uno::UNO_QUERY );
2437
2438 ApplyToolbar( xIndexContainer, xFactory, pToolbar );
2439
2441 xSettings, uno::UNO_QUERY );
2442
2443 if ( pToolbar->IsUserDefined() )
2444 {
2445 xProps->setPropertyValue(
2447 uno::Any( pToolbar->GetName() ) );
2448 }
2449
2450 try
2451 {
2452 if ( GetConfigManager()->hasSettings( pToolbar->GetCommand() ) )
2453 {
2454 GetConfigManager()->replaceSettings(
2455 pToolbar->GetCommand(), xSettings );
2456 }
2457 else
2458 {
2459 GetConfigManager()->insertSettings(
2460 pToolbar->GetCommand(), xSettings );
2461 if ( pToolbar->IsParentData() )
2462 pToolbar->SetParentData( false );
2463 }
2464 }
2465 catch ( css::uno::Exception const & )
2466 {
2467 TOOLS_WARN_EXCEPTION("cui.customize", "caught exception saving settings");
2468 }
2469
2471}
2472
2474{
2475 // show the new toolbar in the UI also
2477 xSettings = GetConfigManager()->createSettings();
2478
2480 xPropertySet( xSettings, uno::UNO_QUERY );
2481
2482 xPropertySet->setPropertyValue(
2484 uno::Any( pToolbar->GetName() ) );
2485
2486 try
2487 {
2488 GetConfigManager()->insertSettings( pToolbar->GetCommand(), xSettings );
2489 }
2490 catch ( css::uno::Exception const & )
2491 {
2492 TOOLS_WARN_EXCEPTION("cui.customize", "caught exception saving settings");
2493 }
2494
2495 GetEntries()->push_back( pToolbar );
2496
2498}
2499
2501{
2502 try
2503 {
2504 OUString url = pToolbar->GetCommand();
2505 GetConfigManager()->removeSettings( url );
2507 delete pToolbar;
2508
2510
2511 // remove the persistent window state data
2512 css::uno::Reference< css::container::XNameContainer > xNameContainer(
2513 m_xPersistentWindowState, css::uno::UNO_QUERY_THROW );
2514
2515 xNameContainer->removeByName( url );
2516 }
2517 catch ( uno::Exception& )
2518 {
2519 // error occurred removing the settings
2520 }
2521}
2522
2524{
2525 OUString url = pToolbar->GetCommand();
2526
2527 // Restore of toolbar is done by removing it from
2528 // its configuration manager and then getting it again
2529 bool bParentToolbar = pToolbar->IsParentData();
2530
2531 // Cannot restore parent toolbar
2532 if ( bParentToolbar )
2533 return;
2534
2535 try
2536 {
2537 GetConfigManager()->removeSettings( url );
2538 pToolbar->GetEntries()->clear();
2540 }
2541 catch ( uno::Exception& )
2542 {
2543 // if an error occurs removing the settings then just return
2544 return;
2545 }
2546
2547 // Now reload the toolbar settings
2548 try
2549 {
2551 if ( IsDocConfig() )
2552 {
2553 xToolbarSettings = GetParentConfigManager()->getSettings( url, false );
2554 pToolbar->SetParentData();
2555 }
2556 else
2557 xToolbarSettings = GetConfigManager()->getSettings( url, false );
2558
2559 LoadToolbar( xToolbarSettings, pToolbar );
2560
2561 // After reloading, ensure that the icon is reset of each entry
2562 // in the toolbar
2563 uno::Sequence< OUString > aURLSeq( 1 );
2564 auto pURLSeq = aURLSeq.getArray();
2565 for (auto const& entry : *pToolbar->GetEntries())
2566 {
2567 pURLSeq[ 0 ] = entry->GetCommand();
2568
2569 try
2570 {
2571 GetImageManager()->removeImages( SvxConfigPageHelper::GetImageType(), aURLSeq );
2572 }
2573 catch ( uno::Exception& )
2574 {
2575 SAL_WARN("cui.customize", "Error restoring icon when resetting toolbar");
2576 }
2577 }
2579 }
2580 catch ( container::NoSuchElementException& )
2581 {
2582 // cannot find the resource URL after removing it
2583 // so no entry will appear in the toolbar list
2584 }
2585}
2586
2588 const uno::Reference< container::XIndexAccess >& xToolbarSettings,
2589 SvxConfigEntry const * pParentData )
2590{
2591 SvxEntries* pEntries = pParentData->GetEntries();
2592
2593 for ( sal_Int32 nIndex = 0; nIndex < xToolbarSettings->getCount(); ++nIndex )
2594 {
2595 OUString aCommandURL;
2596 OUString aLabel;
2597 bool bIsVisible;
2598 sal_Int32 nStyle;
2599
2600 sal_uInt16 nType( css::ui::ItemType::DEFAULT );
2601
2602 bool bItem = SvxConfigPageHelper::GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL,
2603 aLabel, nType, bIsVisible, nStyle );
2604
2605 if ( bItem )
2606 {
2607 bool bIsUserDefined = true;
2608
2609 if ( nType == css::ui::ItemType::DEFAULT )
2610 {
2611 uno::Any a;
2612 try
2613 {
2614 a = m_xCommandToLabelMap->getByName( aCommandURL );
2615 bIsUserDefined = false;
2616 }
2617 catch ( container::NoSuchElementException& )
2618 {
2619 bIsUserDefined = true;
2620 }
2621
2622 bool bUseDefaultLabel = false;
2623 // If custom label not set retrieve it from the command
2624 // to info service
2625 if ( aLabel.isEmpty() )
2626 {
2627 bUseDefaultLabel = true;
2629 if ( a >>= aPropSeq )
2630 {
2631 for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
2632 {
2633 if ( prop.Name == "Name" )
2634 {
2635 prop.Value >>= aLabel;
2636 break;
2637 }
2638 }
2639 }
2640 }
2641
2642 SvxConfigEntry* pEntry = new SvxConfigEntry(
2643 aLabel, aCommandURL, false, /*bParentData*/false );
2644
2645 pEntry->SetUserDefined( bIsUserDefined );
2646 pEntry->SetVisible( bIsVisible );
2647 pEntry->SetStyle( nStyle );
2648
2649 if ( !bUseDefaultLabel )
2650 pEntry->SetName( aLabel );
2651
2652 pEntries->push_back( pEntry );
2653 }
2654 else
2655 {
2656 SvxConfigEntry* pEntry = new SvxConfigEntry;
2657 pEntry->SetUserDefined( bIsUserDefined );
2658 pEntries->push_back( pEntry );
2659 }
2660 }
2661 }
2662}
2663
2665 : GenericDialogController(pWindow, "cui/ui/newtoolbardialog.ui", "NewToolbarDialog")
2666 , m_xEdtName(m_xBuilder->weld_entry("edit"))
2667 , m_xBtnOK(m_xBuilder->weld_button("ok"))
2668 , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
2669{
2670 m_xEdtName->set_text(rName);
2671 m_xEdtName->select_region(0, -1);
2672}
2673
2675{
2676}
2677
2678/*******************************************************************************
2679*
2680* The SvxIconSelectorDialog class
2681*
2682*******************************************************************************/
2685 uno::Reference< css::ui::XImageManager > xParentImageManager)
2686 : GenericDialogController(pWindow, "cui/ui/iconselectordialog.ui", "IconSelector")
2687 , m_xImageManager(std::move(xImageManager))
2688 , m_xParentImageManager(std::move(xParentImageManager))
2689 , m_xTbSymbol(new ValueSet(m_xBuilder->weld_scrolled_window("symbolswin", true)))
2690 , m_xTbSymbolWin(new weld::CustomWeld(*m_xBuilder, "symbolsToolbar", *m_xTbSymbol))
2691 , m_xFtNote(m_xBuilder->weld_label("noteLabel"))
2692 , m_xBtnImport(m_xBuilder->weld_button("importButton"))
2693 , m_xBtnDelete(m_xBuilder->weld_button("deleteButton"))
2694{
2695 typedef std::unordered_map< OUString, bool > ImageInfo;
2696
2697 m_nExpectedSize = 16;
2698 if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_LARGE)
2699 m_nExpectedSize = 24;
2700 else if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_32)
2701 m_nExpectedSize = 32;
2702
2703 if ( m_nExpectedSize != 16 )
2704 {
2706 }
2707
2708 m_xTbSymbol->SetStyle(m_xTbSymbol->GetStyle() | WB_ITEMBORDER | WB_VSCROLL);
2709 m_xTbSymbol->SetColCount(11);
2710 m_xTbSymbol->SetLineCount(5);
2711 m_xTbSymbol->SetItemWidth(m_nExpectedSize);
2712 m_xTbSymbol->SetItemHeight(m_nExpectedSize);
2713 m_xTbSymbol->SetExtraSpacing(6);
2714 Size aSize(m_xTbSymbol->CalcWindowSizePixel(Size(m_nExpectedSize, m_nExpectedSize), 11, 5));
2715 m_xTbSymbol->set_size_request(aSize.Width(), aSize.Height());
2716
2718 ::comphelper::getProcessComponentContext();
2719
2720 m_xGraphProvider.set( graphic::GraphicProvider::create( xComponentContext ) );
2721
2723 css::util::thePathSettings::get( xComponentContext );
2724
2725
2726 OUString aDirectory = xPathSettings->getUserConfig();
2727
2728 sal_Int32 aCount = aDirectory.getLength();
2729
2730 if ( aCount > 0 )
2731 {
2732 sal_Unicode aChar = aDirectory[ aCount-1 ];
2733 if ( aChar != '/')
2734 {
2735 aDirectory += "/";
2736 }
2737 }
2738 else
2739 {
2740 m_xBtnImport->set_sensitive(false);
2741 }
2742
2743 aDirectory += "soffice.cfg/import";
2744
2746 css::embed::FileSystemStorageFactory::create( xComponentContext ) );
2747
2748 uno::Sequence< uno::Any > aArgs{ uno::Any(aDirectory),
2749 uno::Any(css::embed::ElementModes::READWRITE) };
2750
2752 xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
2753
2755 {
2756 {"UserConfigStorage", uno::Any(xStorage)},
2757 {"OpenMode", uno::Any(css::embed::ElementModes::READWRITE)}
2758 }));
2759 m_xImportedImageManager = css::ui::ImageManager::create( xComponentContext );
2760 m_xImportedImageManager->initialize(aProp);
2761
2762 ImageInfo aImageInfo1;
2763 if ( m_xImportedImageManager.is() )
2764 {
2766 for (auto const & name : names )
2767 aImageInfo1.emplace( name, false );
2768 }
2769
2771 auto pname = name.getArray();
2772 for (auto const& elem : aImageInfo1)
2773 {
2774 pname[ 0 ] = elem.first;
2776 if ( graphics.hasElements() )
2777 {
2778 m_aGraphics.push_back(graphics[0]);
2779 Image img(graphics[0]);
2780 m_xTbSymbol->InsertItem(m_aGraphics.size(), img, elem.first);
2781 }
2782 }
2783
2784 ImageInfo aImageInfo;
2785
2786 if ( m_xParentImageManager.is() )
2787 {
2789 for ( auto const & i : names )
2790 aImageInfo.emplace( i, false );
2791 }
2792
2794 for ( auto const & i : names )
2795 {
2796 ImageInfo::iterator pIter = aImageInfo.find( i );
2797 if ( pIter != aImageInfo.end() )
2798 pIter->second = true;
2799 else
2800 aImageInfo.emplace( i, true );
2801 }
2802
2803 // large growth factor, expecting many entries
2804 for (auto const& elem : aImageInfo)
2805 {
2806 pname[ 0 ] = elem.first;
2807
2809 try
2810 {
2811 if (elem.second)
2812 graphics = m_xImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
2813 else
2815 }
2816 catch ( uno::Exception& )
2817 {
2818 // can't get sequence for this name so it will not be
2819 // added to the list
2820 }
2821
2822 if ( graphics.hasElements() )
2823 {
2824 Image img(graphics[0]);
2825 if (!img.GetBitmapEx().IsEmpty())
2826 {
2827 m_aGraphics.push_back(graphics[0]);
2828 m_xTbSymbol->InsertItem(m_aGraphics.size(), img, elem.first);
2829 }
2830 }
2831 }
2832
2833 m_xBtnDelete->set_sensitive( false );
2834 m_xTbSymbol->SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) );
2835 m_xBtnImport->connect_clicked( LINK(this, SvxIconSelectorDialog, ImportHdl) );
2836 m_xBtnDelete->connect_clicked( LINK(this, SvxIconSelectorDialog, DeleteHdl) );
2837}
2838
2840{
2841}
2842
2844{
2846
2847 sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
2848
2849 if (nId)
2850 {
2851 result = m_aGraphics[nId - 1];
2852 }
2853
2854 return result;
2855}
2856
2858{
2859 sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
2860
2861 if (!nId)
2862 {
2863 m_xBtnDelete->set_sensitive(false);
2864 return;
2865 }
2866
2867 OUString aSelImageText = m_xTbSymbol->GetItemText(nId);
2868 if (m_xImportedImageManager->hasImage(SvxConfigPageHelper::GetImageType(), aSelImageText))
2869 {
2870 m_xBtnDelete->set_sensitive(true);
2871 }
2872 else
2873 {
2874 m_xBtnDelete->set_sensitive(false);
2875 }
2876}
2877
2879{
2880 sfx2::FileDialogHelper aImportDialog(
2881 css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
2882 FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, m_xDialog.get());
2884
2885 // disable the link checkbox in the dialog
2887 xController( aImportDialog.GetFilePicker(), uno::UNO_QUERY);
2888 if ( xController.is() )
2889 {
2890 xController->enableControl(
2891 css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK,
2892 false);
2893 }
2894
2896 sal_uInt16 nFilter = rFilter.GetImportFormatNumberForShortName(u"png");
2897 aImportDialog.SetCurrentFilter(rFilter.GetImportFormatName(nFilter));
2898
2899 if ( ERRCODE_NONE == aImportDialog.Execute() )
2900 {
2901 uno::Sequence< OUString > paths = aImportDialog.GetMPath();
2902 ImportGraphics ( paths );
2903 }
2904}
2905
2907{
2908 OUString message = CuiResId( RID_CUISTR_DELETE_ICON_CONFIRM );
2909
2910 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(),
2911 VclMessageType::Warning, VclButtonsType::OkCancel,
2912 message));
2913 if (xWarn->run() != RET_OK)
2914 return;
2915
2916 sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
2917
2918 OUString aSelImageText = m_xTbSymbol->GetItemText( nId );
2919 uno::Sequence< OUString > URLs { aSelImageText };
2920 m_xTbSymbol->RemoveItem(nId);
2921 m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs );
2922 if ( m_xImportedImageManager->isModified() )
2923 {
2924 m_xImportedImageManager->store();
2925 }
2926}
2927
2929 const OUString& aURL )
2930{
2933
2934 css::awt::Size aSize;
2935 bool bOK = false;
2936 try
2937 {
2938 xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
2939
2941 m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
2942 uno::Any a = props->getPropertyValue( "SizePixel" );
2943 a >>= aSize;
2944 if (0 == aSize.Width || 0 == aSize.Height)
2945 return false;
2946 else
2947 bOK = true;
2948 }
2949 catch ( uno::Exception& )
2950 {
2951 return false;
2952 }
2953
2954 bool bResult( false );
2955 size_t nCount = m_xTbSymbol->GetItemCount();
2956 for (size_t n = 0; n < nCount; ++n)
2957 {
2958 sal_uInt16 nId = m_xTbSymbol->GetItemId( n );
2959
2960 if ( m_xTbSymbol->GetItemText( nId ) == aURL )
2961 {
2962 try
2963 {
2964 // replace/insert image with provided URL
2965 size_t nPos = nId - 1;
2966 assert(nPos == m_xTbSymbol->GetItemPos(nId));
2967 m_xTbSymbol->RemoveItem(nId);
2968
2969 Image aImage( xGraphic );
2970 if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
2971 {
2972 BitmapEx aBitmap = aImage.GetBitmapEx();
2974 aImage = Image( aBitmapex);
2975 }
2976 m_xTbSymbol->InsertItem(nId, aImage, aURL, nPos); //modify
2977
2979
2980 m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), { aURL }, { xGraphic } );
2981 m_xImportedImageManager->store();
2982
2983 bResult = true;
2984 break;
2985 }
2986 catch ( css::uno::Exception& )
2987 {
2988 break;
2989 }
2990 }
2991 }
2992
2993 return bResult;
2994}
2995
2996namespace
2997{
2998 OUString ReplaceIconName(std::u16string_view rMessage)
2999 {
3000 OUString name;
3001 OUString message = CuiResId( RID_CUISTR_REPLACE_ICON_WARNING );
3002 OUString placeholder("%ICONNAME" );
3003 sal_Int32 pos = message.indexOf( placeholder );
3004 if ( pos != -1 )
3005 {
3006 name = message.replaceAt(
3007 pos, placeholder.getLength(), rMessage );
3008 }
3009 return name;
3010 }
3011
3012 class SvxIconReplacementDialog
3013 {
3014 private:
3015 std::unique_ptr<weld::MessageDialog> m_xQueryBox;
3016 public:
3017 SvxIconReplacementDialog(weld::Window *pParent, std::u16string_view rMessage, bool bYestoAll)
3018 : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::NONE, ReplaceIconName(rMessage)))
3019 {
3020 m_xQueryBox->set_title(CuiResId(RID_CUISTR_REPLACE_ICON_CONFIRM));
3021 m_xQueryBox->add_button(GetStandardText(StandardButtonType::Yes), 2);
3022 if (bYestoAll)
3023 m_xQueryBox->add_button(CuiResId(RID_CUISTR_YESTOALL), 5);
3024 m_xQueryBox->add_button(GetStandardText(StandardButtonType::No), 4);
3025 m_xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), 6);
3026 m_xQueryBox->set_default_response(2);
3027 }
3028 short run() { return m_xQueryBox->run(); }
3029 };
3030}
3031
3033 const uno::Sequence< OUString >& rPaths )
3034{
3035 std::vector< OUString > rejected( rPaths.getLength() );
3036 sal_Int32 rejectedCount = 0;
3037
3038 sal_uInt16 ret = 0;
3039 sal_Int32 aIndex;
3040 OUString aIconName;
3041
3042 if ( rPaths.getLength() == 1 )
3043 {
3044 if ( m_xImportedImageManager->hasImage( SvxConfigPageHelper::GetImageType(), rPaths[0] ) )
3045 {
3046 aIndex = rPaths[0].lastIndexOf( '/' );
3047 aIconName = rPaths[0].copy( aIndex+1 );
3048 SvxIconReplacementDialog aDlg(m_xDialog.get(), aIconName, false);
3049 ret = aDlg.run();
3050 if ( ret == 2 )
3051 {
3052 ReplaceGraphicItem( rPaths[0] );
3053 }
3054 }
3055 else
3056 {
3057 if ( !ImportGraphic( rPaths[0] ) )
3058 {
3059 rejected[0] = rPaths[0];
3060 rejectedCount = 1;
3061 }
3062 }
3063 }
3064 else
3065 {
3066 OUString aSourcePath( rPaths[0] );
3067 if ( rPaths[0].lastIndexOf( '/' ) != rPaths[0].getLength() -1 )
3068 aSourcePath = rPaths[0] + "/";
3069
3070 for ( sal_Int32 i = 1; i < rPaths.getLength(); ++i )
3071 {
3072 OUString aPath = aSourcePath + rPaths[i];
3074 {
3075 aIndex = rPaths[i].lastIndexOf( '/' );
3076 aIconName = rPaths[i].copy( aIndex+1 );
3077 SvxIconReplacementDialog aDlg(m_xDialog.get(), aIconName, true);
3078 ret = aDlg.run();
3079 if ( ret == 2 )
3080 {
3081 ReplaceGraphicItem( aPath );
3082 }
3083 else if ( ret == 5 )
3084 {
3085 for ( sal_Int32 k = i; k < rPaths.getLength(); ++k )
3086 {
3087 aPath = aSourcePath + rPaths[k];
3088 bool bHasReplaced = ReplaceGraphicItem( aPath );
3089
3090 if ( !bHasReplaced )
3091 {
3092 bool result = ImportGraphic( aPath );
3093 if ( !result )
3094 {
3095 rejected[ rejectedCount ] = rPaths[i];
3096 ++rejectedCount;
3097 }
3098 }
3099 }
3100 break;
3101 }
3102 }
3103 else
3104 {
3105 bool result = ImportGraphic( aSourcePath + rPaths[i] );
3106 if ( !result )
3107 {
3108 rejected[ rejectedCount ] = rPaths[i];
3109 ++rejectedCount;
3110 }
3111 }
3112 }
3113 }
3114
3115 if ( rejectedCount == 0 )
3116 return;
3117
3118 OUStringBuffer message;
3119 OUString fPath;
3120 if (rejectedCount > 1)
3121 fPath = OUString::Concat(rPaths[0].subView(8)) + "/";
3122 for ( sal_Int32 i = 0; i < rejectedCount; ++i )
3123 {
3124 message.append(fPath + rejected[i] + "\n");
3125 }
3126
3127 SvxIconChangeDialog aDialog(m_xDialog.get(), message.makeStringAndClear());
3128 aDialog.run();
3129}
3130
3131bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
3132{
3133 bool result = false;
3134
3136
3137 try
3138 {
3140 m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
3141
3142 uno::Any a = props->getPropertyValue("SizePixel");
3143
3144 uno::Reference< graphic::XGraphic > xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
3145 if ( xGraphic.is() )
3146 {
3147 bool bOK = true;
3148 css::awt::Size aSize;
3149
3150 a >>= aSize;
3151 if ( 0 == aSize.Width || 0 == aSize.Height )
3152 bOK = false;
3153
3154 Image aImage( xGraphic );
3155
3156 if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
3157 {
3158 BitmapEx aBitmap = aImage.GetBitmapEx();
3160 aImage = Image( aBitmapex);
3161 }
3162 if ( bOK && !!aImage )
3163 {
3164 m_aGraphics.push_back(Graphic(aImage.GetBitmapEx()).GetXGraphic());
3165 m_xTbSymbol->InsertItem(m_aGraphics.size(), aImage, aURL);
3166
3167 uno::Sequence<OUString> aImportURL { aURL };
3168 uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph{ xGraphic };
3169 m_xImportedImageManager->insertImages( SvxConfigPageHelper::GetImageType(), aImportURL, aImportGraph );
3170 if ( m_xImportedImageManager->isModified() )
3171 {
3172 m_xImportedImageManager->store();
3173 }
3174
3175 result = true;
3176 }
3177 else
3178 {
3179 SAL_WARN("cui.customize", "could not create Image from XGraphic");
3180 }
3181 }
3182 else
3183 {
3184 SAL_WARN("cui.customize", "could not get query XGraphic");
3185 }
3186 }
3187 catch( uno::Exception const & )
3188 {
3189 TOOLS_WARN_EXCEPTION("cui.customize", "Caught exception importing XGraphic");
3190 }
3191 return result;
3192}
3193
3194/*******************************************************************************
3195*
3196* The SvxIconChangeDialog class added for issue83555
3197*
3198*******************************************************************************/
3200 : MessageDialogController(pWindow, "cui/ui/iconchangedialog.ui", "IconChange", "grid")
3201 , m_xLineEditDescription(m_xBuilder->weld_text_view("addrTextview"))
3202{
3203 m_xLineEditDescription->set_size_request(m_xLineEditDescription->get_approximate_digit_width() * 48,
3204 m_xLineEditDescription->get_text_height() * 8);
3205 m_xLineEditDescription->set_text(rMessage);
3206}
3207
3209 : weld::ReorderingDropTarget(rTreeView)
3210 , m_rPage(rPage)
3211{
3212}
3213
3215{
3218 return nRet;;
3219}
3220
3221/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::MessageDialog > m_xQueryBox
static std::unique_ptr< SfxTabPage > CreateSvxContextMenuConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cfg.cxx:173
IMPL_LINK_NOARG(SvxConfigPage, SelectElementHdl, weld::ComboBox &, void)
Definition: cfg.cxx:1021
void printProperties(const OUString &prefix, const uno::Sequence< beans::PropertyValue > &aProp)
Definition: cfg.cxx:138
static std::unique_ptr< SfxTabPage > CreateSvxMenuConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cfg.cxx:168
static std::unique_ptr< SfxTabPage > CreateSvxNotebookbarConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cfg.cxx:183
void printPropertySet(const OUString &prefix, const uno::Reference< beans::XPropertySet > &xPropSet)
Definition: cfg.cxx:104
static std::unique_ptr< SfxTabPage > CreateSvxToolbarConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cfg.cxx:189
void printEntries(SvxEntries *entries)
Definition: cfg.cxx:152
static std::unique_ptr< SfxTabPage > CreateKeyboardConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cfg.cxx:178
static std::unique_ptr< SfxTabPage > CreateSvxEventConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cfg.cxx:194
IMPL_LINK(SvxConfigDialog, ActivatePageHdl, const OString &, rPage, void)
Definition: cfg.cxx:232
constexpr OUStringLiteral CUSTOM_TOOLBAR_STR
Definition: cfg.hxx:57
constexpr OUStringLiteral ITEM_TOOLBAR_URL
Definition: cfg.hxx:55
constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE
Definition: cfg.hxx:49
constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE
Definition: cfg.hxx:48
constexpr OUStringLiteral ITEM_DESCRIPTOR_RESOURCEURL
Definition: cfg.hxx:51
constexpr OUStringLiteral ITEM_DESCRIPTOR_UINAME
Definition: cfg.hxx:52
constexpr OUStringLiteral aMenuSeparatorStr
Definition: cfg.hxx:59
std::vector< SvxConfigEntry * > SvxEntries
Definition: cfg.hxx:62
constexpr OUStringLiteral notebookbarTabScope
Definition: cfg.hxx:43
constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL
Definition: cfg.hxx:47
constexpr OUStringLiteral ITEM_MENUBAR_URL
Definition: cfg.hxx:54
constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER
Definition: cfg.hxx:46
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
static BitmapEx AutoScaleBitmap(BitmapEx const &aBitmap, const tools::Long aStandardSize)
bool IsEmpty() const
OUString GetUIName(const OUString &rResourceURL)
Definition: cfg.cxx:706
ContextMenuSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &xCfgMgr, const css::uno::Reference< css::ui::XUIConfigurationManager > &xParentCfgMgr, const OUString &aModuleId, bool bIsDocConfig)
Definition: cfg.cxx:691
std::unique_ptr< SvxConfigEntry > m_pRootEntry
Definition: cfg.hxx:208
bool HasURL(const OUString &rURL) override
Definition: cfg.cxx:837
void ResetContextMenu(const SvxConfigEntry *pEntry)
Definition: cfg.cxx:900
void SetEntries(std::unique_ptr< SvxEntries > pNewEntries) override
Definition: cfg.cxx:832
bool HasSettings() override
Definition: cfg.cxx:847
bool Apply() override
Definition: cfg.cxx:852
void Reset() override
Definition: cfg.cxx:882
css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState
Definition: cfg.hxx:209
SvxEntries * GetEntries() override
Definition: cfg.cxx:731
virtual ~ContextMenuSaveInData() override
Definition: cfg.cxx:702
static void getFileNameAndAppName(OUString &sAppName, OUString &sNotebookbarUIFileName)
void DrawSymbol(const tools::Rectangle &rRect, SymbolType eType, const Color &rColor, DrawSymbolFlags nStyle=DrawSymbolFlags::NONE)
static GraphicFilter & GetGraphicFilter()
OUString GetImportFormatName(sal_uInt16 nFormat)
sal_uInt16 GetImportFormatNumberForShortName(std::u16string_view rShortName)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
BitmapEx GetBitmapEx() const
static void SetDefaultData(MenuSaveInData *pData)
Definition: cfg.hxx:179
bool Apply() override
Definition: cfg.cxx:551
static MenuSaveInData * pDefaultData
static holder of the default menu data
Definition: cfg.hxx:177
OUString m_aDescriptorContainer
Definition: cfg.hxx:169
void SetEntries(std::unique_ptr< SvxEntries >) override
Definition: cfg.cxx:434
void Reset() override
Definition: cfg.cxx:667
css::uno::Reference< css::container::XIndexAccess > m_xMenuSettings
Definition: cfg.hxx:172
static MenuSaveInData * GetDefaultData()
Definition: cfg.hxx:180
MenuSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig)
Definition: cfg.cxx:377
OUString m_aMenuResourceURL
Definition: cfg.hxx:168
virtual ~MenuSaveInData() override
Definition: cfg.cxx:408
std::unique_ptr< SvxConfigEntry > pRootEntry
Definition: cfg.hxx:174
SvxEntries * GetEntries() override
methods inherited from SaveInData
Definition: cfg.cxx:413
css::uno::Reference< css::graphic::XGraphic > GetImage(const OUString &rCommandURL)
Definition: cfg.cxx:328
void LoadSubMenus(const css::uno::Reference< css::container::XIndexAccess > &xMenuSettings, const OUString &rBaseTitle, SvxConfigEntry const *pParentData, bool bContextMenu)
Definition: cfg.cxx:439
css::uno::Reference< css::ui::XImageManager > m_xParentImgMgr
Definition: cfg.hxx:97
bool IsDocConfig() const
Definition: cfg.hxx:130
bool IsReadOnly() const
Definition: cfg.hxx:129
virtual bool HasSettings()=0
bool bReadOnly
Definition: cfg.hxx:85
const css::uno::Reference< css::ui::XImageManager > & GetImageManager() const
Definition: cfg.hxx:142
css::uno::Reference< css::container::XNameAccess > m_xCommandToLabelMap
Definition: cfg.hxx:146
virtual void Reset()=0
const css::uno::Reference< css::ui::XUIConfigurationManager > & GetConfigManager() const
Definition: cfg.hxx:134
css::uno::Sequence< css::beans::PropertyValue > m_aSeparatorSeq
Definition: cfg.hxx:152
virtual bool HasURL(const OUString &aURL)=0
void ApplyMenu(css::uno::Reference< css::container::XIndexContainer > const &rMenuBar, css::uno::Reference< css::lang::XSingleComponentFactory > &rFactory, SvxConfigEntry *pMenuData)
Definition: cfg.cxx:620
void SetModified(bool bValue=true)
Definition: cfg.hxx:126
css::uno::Reference< css::ui::XUIConfigurationManager > m_xParentCfgMgr
Definition: cfg.hxx:91
bool bDocConfig
Definition: cfg.hxx:84
bool IsModified() const
Definition: cfg.hxx:127
static css::uno::Reference< css::ui::XImageManager > * xDefaultImgMgr
Definition: cfg.hxx:100
SaveInData(css::uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr, css::uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr, const OUString &aModuleId, bool docConfig)
Definition: cfg.cxx:275
css::uno::Reference< css::ui::XImageManager > m_xImgMgr
Definition: cfg.hxx:94
bool PersistChanges(const css::uno::Reference< css::uno::XInterface > &xManager)
Definition: cfg.cxx:341
const css::uno::Reference< css::ui::XUIConfigurationManager > & GetParentConfigManager() const
Definition: cfg.hxx:138
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
static bool IsHelpInstalled()
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void SetCurPageId(const OString &rName)
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
std::unique_ptr< weld::Notebook > m_xTabCtrl
void RemoveTabPage(const OString &rName)
css::uno::Reference< css::frame::XFrame > GetFrame() const
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
static SfxViewFrame * Current()
SfxFrame & GetFrame() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: cfg.hxx:69
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: cfg.cxx:237
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: cfg.cxx:252
SvxConfigDialog(weld::Window *, const SfxItemSet *)
Definition: cfg.cxx:206
sal_Int32 GetStyle() const
Definition: cfg.hxx:315
const OUString & GetCommand() const
Definition: cfg.hxx:276
bool IsDeletable() const
Definition: cfg.cxx:1928
void SetStyle(sal_Int32 style)
Definition: cfg.hxx:316
bool IsParentData() const
Definition: cfg.hxx:297
void SetParentData(bool bValue=true)
Definition: cfg.hxx:296
SvxEntries * GetEntries() const
Definition: cfg.hxx:290
std::unique_ptr< SvxEntries > mpEntries
Definition: cfg.hxx:252
bool IsMovable() const
Definition: cfg.cxx:1923
bool IsPopup() const
Definition: cfg.hxx:282
SvxConfigEntry()
Definition: cfg.hxx:261
void SetMain()
Definition: cfg.hxx:293
void SetName(const OUString &rStr)
Definition: cfg.hxx:279
void SetModified(bool bValue=true)
Definition: cfg.hxx:299
bool IsUserDefined() const
Definition: cfg.hxx:285
bool bPopUp
Definition: cfg.hxx:238
void SetUserDefined(bool bOn=true)
Definition: cfg.hxx:284
void SetVisible(bool b)
Definition: cfg.hxx:306
bool IsRenamable() const
Definition: cfg.cxx:1933
const OUString & GetName() const
Definition: cfg.hxx:278
bool IsSeparator() const
Definition: cfg.hxx:288
bool IsMain() const
Definition: cfg.hxx:294
~SvxConfigEntry()
Definition: cfg.cxx:1912
SvxConfigPage & m_rPage
Definition: cfg.hxx:358
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: cfg.cxx:3214
SvxConfigPageFunctionDropTarget(SvxConfigPage &rPage, weld::TreeView &rTreeView)
Definition: cfg.cxx:3208
static sal_Int16 GetImageType()
static OUString generateCustomMenuURL(SvxEntries *entries, sal_Int32 suffix=1)
static OUString GetUIModuleName(const OUString &aModuleId, const css::uno::Reference< css::frame::XModuleManager2 > &rModuleManager)
static bool GetMenuItemData(const css::uno::Reference< css::container::XIndexAccess > &rItemContainer, sal_Int32 nIndex, OUString &rCommandURL, OUString &rLabel, sal_uInt16 &rType, sal_Int32 &rStyle, css::uno::Reference< css::container::XIndexAccess > &rSubMenu)
static css::uno::Sequence< css::beans::PropertyValue > ConvertSvxConfigEntry(const SvxConfigEntry *pEntry)
static OUString stripHotKey(const OUString &str)
static OUString generateCustomName(const OUString &prefix, SvxEntries *entries, sal_Int32 suffix=1)
static bool GetToolbarItemData(const css::uno::Reference< css::container::XIndexAccess > &rItemContainer, sal_Int32 nIndex, OUString &rCommandURL, OUString &rLabel, sal_uInt16 &rType, bool &rIsVisible, sal_Int32 &rStyle)
static void RemoveEntry(SvxEntries *pEntries, SvxConfigEntry const *pChildEntry)
static bool SvxConfigEntryModified(SvxConfigEntry const *pEntry)
static css::uno::Reference< css::graphic::XGraphic > GetGraphic(const css::uno::Reference< css::ui::XImageManager > &xImageManager, const OUString &rCommandURL)
static OUString replaceSixteen(const OUString &str, sal_Int32 nReplacement)
static css::uno::Sequence< css::beans::PropertyValue > ConvertToolbarEntry(const SvxConfigEntry *pEntry)
static bool EntrySort(SvxConfigEntry const *a, SvxConfigEntry const *b)
void ReloadTopLevelListBox(SvxConfigEntry const *pSelection=nullptr)
Definition: cfg.cxx:1336
void InsertEntryIntoUI(SvxConfigEntry *pNewEntryData, weld::TreeView &rTreeView, int nPos, bool bMenu=false)
Definition: cfg.cxx:1584
OUString GetScriptURL() const
Definition: cfg.cxx:1289
OUString m_aModuleId
Definition: cfg.hxx:382
std::unique_ptr< weld::ComboBox > m_xTopLevelListBox
Definition: cfg.hxx:400
static bool CanConfig(std::u16string_view rModuleId)
Definition: cfg.cxx:163
virtual void ListModified()
Definition: cfg.hxx:495
virtual ~SvxConfigPage() override
Definition: cfg.cxx:1026
void Reset(const SfxItemSet *) override
Definition: cfg.cxx:1036
SvxConfigEntry * GetTopLevelSelection()
Definition: cfg.hxx:497
int AppendEntry(SvxConfigEntry *pNewEntryData, int nTarget)
Definition: cfg.cxx:1488
static OUString GetFrameWithDefaultAndIdentify(css::uno::Reference< css::frame::XFrame > &_inout_rxFrame)
identifies the module in the given frame.
Definition: cfg.cxx:1251
virtual void SelectElement()=0
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
Definition: cfg.hxx:387
virtual void UpdateButtonStates()=0
virtual SaveInData * CreateSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig)=0
std::unique_ptr< weld::Entry > m_xSearchEdit
Definition: cfg.hxx:393
int AddFunction(int nTarget, bool bAllowDuplicates)
Definition: cfg.cxx:1460
bool bInitialised
Definition: cfg.hxx:371
OUString m_aURLToSelect
the ResourceURL to select when opening the dialog
Definition: cfg.hxx:379
void AddSubMenusToUI(std::u16string_view rBaseTitle, SvxConfigEntry const *pParentData)
Definition: cfg.cxx:1370
static bool IsCommandInMenuList(const SvxConfigEntry *pEntryData, const SvxEntries *pEntries)
Definition: cfg.cxx:1439
std::unique_ptr< weld::TextView > m_xDescriptionField
Definition: cfg.hxx:391
OUString GetSelectedDisplayName() const
Definition: cfg.cxx:1307
SvxConfigEntry * CreateCommandFromSelection(const OUString &aURL)
Definition: cfg.cxx:1411
OUString m_sAppName
Definition: cfg.hxx:420
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: cfg.hxx:381
Timer m_aUpdateDataTimer
Definition: cfg.hxx:370
virtual void Init()=0
bool MoveEntryData(int SourceEntry, int nTargetEntry)
Definition: cfg.cxx:1713
OUString m_sFileName
Definition: cfg.hxx:421
bool FillItemSet(SfxItemSet *) override
Definition: cfg.cxx:1312
virtual void MoveEntry(bool bMoveUp)
Definition: cfg.cxx:1677
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
Definition: cfg.hxx:409
SaveInData * GetSaveInData()
Definition: cfg.hxx:478
SaveInData * pCurrentSaveInData
Definition: cfg.hxx:372
SvxConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &)
Definition: cfg.cxx:978
SvxEntries * FindParentForChild(SvxEntries *pParentEntries, SvxConfigEntry *pChildData)
Definition: cfg.cxx:1387
virtual short QueryReset()=0
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
Definition: cfg.hxx:403
std::unique_ptr< weld::TextView > m_xLineEditDescription
Definition: cfg.hxx:667
SvxIconChangeDialog(weld::Window *pWindow, const OUString &rMessage)
Definition: cfg.cxx:3199
void ImportGraphics(const css::uno::Sequence< OUString > &aURLs)
Definition: cfg.cxx:3032
bool ReplaceGraphicItem(const OUString &aURL)
Definition: cfg.cxx:2928
std::unique_ptr< weld::Button > m_xBtnImport
Definition: cfg.hxx:637
std::unique_ptr< weld::Label > m_xFtNote
Definition: cfg.hxx:636
std::unique_ptr< weld::Button > m_xBtnDelete
Definition: cfg.hxx:638
SvxIconSelectorDialog(weld::Window *pWindow, css::uno::Reference< css::ui::XImageManager > xImageManager, css::uno::Reference< css::ui::XImageManager > xParentImageManager)
Definition: cfg.cxx:2683
virtual ~SvxIconSelectorDialog() override
Definition: cfg.cxx:2839
std::vector< css::uno::Reference< css::graphic::XGraphic > > m_aGraphics
Definition: cfg.hxx:632
sal_Int32 m_nExpectedSize
Definition: cfg.hxx:618
css::uno::Reference< css::graphic::XGraphic > GetSelectedIcon()
Definition: cfg.cxx:2843
bool ImportGraphic(const OUString &aURL)
Definition: cfg.cxx:3131
std::unique_ptr< ValueSet > m_xTbSymbol
Definition: cfg.hxx:634
css::uno::Reference< css::ui::XImageManager > m_xImportedImageManager
Definition: cfg.hxx:627
css::uno::Reference< css::ui::XImageManager > m_xParentImageManager
Definition: cfg.hxx:624
css::uno::Reference< css::graphic::XGraphicProvider > m_xGraphProvider
Definition: cfg.hxx:630
css::uno::Reference< css::ui::XImageManager > m_xImageManager
Definition: cfg.hxx:621
OUString m_sNewMenuEntryId
Definition: cfg.hxx:522
SvxMainMenuOrganizerDialog(weld::Window *, SvxEntries *, SvxConfigEntry const *, bool bCreateMenu)
Definition: cfg.cxx:1751
virtual ~SvxMainMenuOrganizerDialog() override
Definition: cfg.cxx:1820
std::unique_ptr< weld::Button > m_xMoveUpButton
Definition: cfg.hxx:527
SvxConfigEntry * GetSelectedEntry()
Definition: cfg.cxx:1884
std::unique_ptr< weld::Widget > m_xMenuBox
Definition: cfg.hxx:524
std::unique_ptr< weld::TreeView > m_xMenuListBox
Definition: cfg.hxx:526
std::unique_ptr< weld::Entry > m_xMenuNameEdit
Definition: cfg.hxx:525
std::unique_ptr< weld::Button > m_xMoveDownButton
Definition: cfg.hxx:528
std::unique_ptr< SvxEntries > mpEntries
Definition: cfg.hxx:521
SvxMenuEntriesListBox(std::unique_ptr< weld::TreeView > xControl, SvxConfigPage *pPage)
Definition: cfg.cxx:932
std::unique_ptr< weld::TreeView > m_xControl
Definition: cfg.hxx:322
ScopedVclPtr< VirtualDevice > m_xDropDown
Definition: cfg.hxx:323
virtual ~SvxMenuEntriesListBox()
Definition: cfg.cxx:942
void CreateDropDown()
Definition: cfg.cxx:914
virtual ~SvxNewToolbarDialog() override
Definition: cfg.cxx:2674
SvxNewToolbarDialog(weld::Window *pWindow, const OUString &rName)
Definition: cfg.cxx:2664
std::unique_ptr< weld::Entry > m_xEdtName
Definition: cfg.hxx:601
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void SetButtonType(ButtonType eNewType)
void SetEntries(std::unique_ptr< SvxEntries >) override
Definition: cfg.cxx:2316
void SetSystemStyle(const OUString &rResourceURL, sal_Int32 nStyle)
Definition: cfg.cxx:2048
std::unique_ptr< SvxConfigEntry > pRootEntry
Definition: cfg.hxx:550
SvxEntries * GetEntries() override
Definition: cfg.cxx:2147
void RestoreToolbar(SvxConfigEntry *pToolbar)
Definition: cfg.cxx:2523
sal_Int32 GetSystemStyle(const OUString &rResourceURL)
Definition: cfg.cxx:1960
void CreateToolbar(SvxConfigEntry *pToolbar)
Definition: cfg.cxx:2473
bool HasURL(const OUString &rURL) override
Definition: cfg.cxx:2322
void ApplyToolbar(css::uno::Reference< css::container::XIndexContainer > const &rNewToolbarBar, css::uno::Reference< css::lang::XSingleComponentFactory > &rFactory, SvxConfigEntry const *pToolbar)
virtual ~ToolbarSaveInData() override
Definition: cfg.cxx:1956
void LoadToolbar(const css::uno::Reference< css::container::XIndexAccess > &xToolBarSettings, SvxConfigEntry const *pParentData)
Definition: cfg.cxx:2587
bool Apply() override
Definition: cfg.cxx:2376
void RemoveToolbar(SvxConfigEntry *pToolbar)
Definition: cfg.cxx:2500
OUString m_aDescriptorContainer
Definition: cfg.hxx:551
bool HasSettings() override
Definition: cfg.cxx:2334
css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState
Definition: cfg.hxx:554
void Reset() override
Definition: cfg.cxx:2340
ToolbarSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig)
Definition: cfg.cxx:1938
OUString GetSystemUIName(const OUString &rResourceURL)
Definition: cfg.cxx:2087
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
css::uno::Sequence< OUString > GetMPath() const
void SetCurrentFilter(const OUString &rFilter)
void SetContext(Context _eNewContext)
static OUString getProductName()
bool IsMod1() const
sal_uInt16 GetCode() const
WindowType GetType() const
virtual short run()
std::shared_ptr< weld::Dialog > m_xDialog
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
virtual void scroll_to_row(int row)=0
void connect_row_activated(const Link< TreeView &, bool > &rLink)
virtual void swap(int pos1, int pos2)=0
virtual void set_text(int row, const OUString &rText, int col=-1)=0
void connect_changed(const Link< TreeView &, void > &rLink)
virtual void set_image(int row, const OUString &rImage, int col=-1)=0
virtual int get_height_rows(int nRows) const=0
virtual void select(int pos)=0
virtual void set_id(int row, const OUString &rId)=0
virtual int get_selected_index() const=0
virtual float get_approximate_digit_width() const=0
void Init()
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
URL aURL
virtual OUString GetScriptURL() const override
virtual tools::Long GetValue() const override
float u
#define ERRCODE_NONE
std::deque< AttacherIndex_Impl > aIndex
Reference< XSingleServiceFactory > xFactory
bool bReadOnly
const char * name
sal_Int32 nIndex
OUString aName
sal_Int64 n
uno_Any a
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_DOWN
sal_uInt16 nPos
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
def text(shape, orig_st)
def run(arg=None, arg2=-1)
NONE
ItemType
double getLength(const B2DPolygon &rCandidate)
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Warning
int i
enumrange< T >::Iterator begin(enumrange< T >)
end
dictionary props
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
OUString GetPopupLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
bool IsExperimental(const OUString &rsCommandName, const OUString &rModuleName)
OUString GetMenuLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
OUString toId(const void *pValue)
sal_Int16 nId
QPRO_FUNC_TYPE nType
static SfxItemSet & rSet
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)
this is only to let callers know that there is a LateInit which must be called
Definition: eventdlg.hxx:42
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel
#define EDIT_UPDATEDATA_TIMEOUT
OUString aCommand
sal_uInt16 sal_Unicode
signed char sal_Int8
Any result
bool bIsExperimental
OUString aLabel
bool bPopup
OUString sId
#define WB_ITEMBORDER
RET_OK
RET_YES
VclMessageType
VclButtonsType
Reference< XControl > m_xControl
WinBits const WB_VSCROLL
size_t pos