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>
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
218 const SfxPoolItem* pItem = pInSet->GetItem( SID_CONFIG );
219
220 if ( pItem )
221 {
222 OUString text = static_cast<const SfxStringItem*>(pItem)->GetValue();
223
224 if (text.startsWith( ITEM_TOOLBAR_URL ) )
225 {
226 SetCurPageId("toolbars");
227 }
228 }
229}
230
231void SvxConfigDialog::ActivatePage(const OString& rPage)
232{
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 m_xControl->connect_query_tooltip(LINK(this, SvxMenuEntriesListBox, QueryTooltip));
941}
942
944{
945}
946
947IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
948{
949 vcl::KeyCode keycode = rKeyEvent.GetKeyCode();
950
951 // support DELETE for removing the current entry
952 if ( keycode == KEY_DELETE )
953 {
954 m_pPage->DeleteSelectedContent();
955 }
956 // support CTRL+UP and CTRL+DOWN for moving selected entries
957 else if ( keycode.GetCode() == KEY_UP && keycode.IsMod1() )
958 {
959 m_pPage->MoveEntry( true );
960 }
961 else if ( keycode.GetCode() == KEY_DOWN && keycode.IsMod1() )
962 {
963 m_pPage->MoveEntry( false );
964 }
965 else
966 {
967 return false; // pass on to default handler
968 }
969 return true;
970}
971
972IMPL_LINK(SvxMenuEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString)
973{
974 SvxConfigEntry *pEntry = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(rIter));
975 if (!pEntry || pEntry->GetCommand().isEmpty())
976 return OUString();
977 const OUString sCommand(pEntry->GetCommand());
978 OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame()));
980 OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(sCommand, aProperties,
981 m_pPage->GetFrame());
982 return CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pEntry->GetName().replaceFirst("~", "") + "\n" +
983 CuiResId(RID_CUISTR_COMMANDNAME) + ": " + sCommand + "\n" +
984 CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", "");
985}
986
987/******************************************************************************
988 *
989 * SvxConfigPage is the abstract base class on which the Menu and Toolbar
990 * configuration tabpages are based. It includes methods which are common to
991 * both tabpages to add, delete, move and rename items etc.
992 *
993 *****************************************************************************/
995 : SfxTabPage(pPage, pController, "cui/ui/menuassignpage.ui", "MenuAssignPage", &rSet)
996 , m_aUpdateDataTimer( "SvxConfigPage UpdateDataTimer" )
997 , bInitialised(false)
998 , pCurrentSaveInData(nullptr)
999 , m_xCommandCategoryListBox(new CommandCategoryListBox(m_xBuilder->weld_combo_box("commandcategorylist")))
1000 , m_xFunctions(new CuiConfigFunctionListBox(m_xBuilder->weld_tree_view("functions")))
1001 , m_xCategoryLabel(m_xBuilder->weld_label("categorylabel"))
1002 , m_xDescriptionFieldLb(m_xBuilder->weld_label("descriptionlabel"))
1003 , m_xDescriptionField(m_xBuilder->weld_text_view("desc"))
1004 , m_xLeftFunctionLabel(m_xBuilder->weld_label("leftfunctionlabel"))
1005 , m_xSearchEdit(m_xBuilder->weld_entry("searchEntry"))
1006 , m_xSearchLabel(m_xBuilder->weld_label("searchlabel"))
1007 , m_xCustomizeLabel(m_xBuilder->weld_label("customizelabel"))
1008 , m_xTopLevelListBox(m_xBuilder->weld_combo_box("toplevellist"))
1009 , m_xMoveUpButton(m_xBuilder->weld_button("up"))
1010 , m_xMoveDownButton(m_xBuilder->weld_button("down"))
1011 , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
1012 , m_xInsertBtn(m_xBuilder->weld_menu_button("insert"))
1013 , m_xModifyBtn(m_xBuilder->weld_menu_button("modify"))
1014 , m_xResetBtn(m_xBuilder->weld_button("defaultsbtn"))
1015 , m_xAddCommandButton(m_xBuilder->weld_button("add"))
1016 , m_xRemoveCommandButton(m_xBuilder->weld_button("remove"))
1017{
1019
1020 m_xTopLevelListBox->connect_changed(LINK(this, SvxConfigPage, SelectElementHdl));
1021
1022 weld::TreeView& rTreeView = m_xFunctions->get_widget();
1023 Size aSize(rTreeView.get_approximate_digit_width() * 40, rTreeView.get_height_rows(8));
1024 m_xFunctions->set_size_request(aSize.Width(), aSize.Height());
1025 m_xDescriptionField->set_size_request(aSize.Width(), m_xDescriptionField->get_height_rows(3));
1026
1027 m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SvxConfigPage, ImplUpdateDataHdl));
1029
1030 m_xSearchEdit->connect_changed(LINK(this, SvxConfigPage, SearchUpdateHdl));
1031 m_xSearchEdit->connect_focus_out(LINK(this, SvxConfigPage, FocusOut_Impl));
1032
1033 rTreeView.connect_row_activated(LINK(this, SvxConfigPage, FunctionDoubleClickHdl));
1034 rTreeView.connect_changed(LINK(this, SvxConfigPage, SelectFunctionHdl));
1035}
1036
1038{
1039 SelectElement();
1040}
1041
1043{
1044 int cnt = m_xSaveInListBox->get_count();
1045 for(int i=0; i < cnt; ++i)
1046 {
1047 SaveInData *pData = weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i));
1048 delete pData;
1049 }
1050}
1051
1053{
1054 // If we haven't initialised our XMultiServiceFactory reference
1055 // then Reset is being called at the opening of the dialog.
1056
1057 // Load menu configuration data for the module of the currently
1058 // selected document, for the currently selected document, and for
1059 // all other open documents of the same module type
1060 if ( !bInitialised )
1061 {
1062 sal_Int32 nPos = 0;
1065
1067 ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
1068
1069 m_xFrame = GetFrame();
1071
1072 // replace %MODULENAME in the label with the correct module name
1074 css::frame::ModuleManager::create( xContext ));
1075 OUString aModuleName = SvxConfigPageHelper::GetUIModuleName( m_aModuleId, xModuleManager );
1076
1078 xModuleCfgSupplier( css::ui::theModuleUIConfigurationManagerSupplier::get(xContext) );
1079
1080 // Set up data for module specific menus
1081 SaveInData* pModuleData = nullptr;
1082
1083 try
1084 {
1085 xCfgMgr =
1086 xModuleCfgSupplier->getUIConfigurationManager( m_aModuleId );
1087
1088 pModuleData = CreateSaveInData( xCfgMgr,
1091 false );
1092 }
1093 catch ( container::NoSuchElementException& )
1094 {
1095 }
1096
1097 if ( pModuleData != nullptr )
1098 {
1099 OUString sId(weld::toId(pModuleData));
1100 m_xSaveInListBox->append(sId, utl::ConfigManager::getProductName() + " " + aModuleName);
1101 }
1102
1103 // try to retrieve the document based ui configuration manager
1104 OUString aTitle;
1106 m_xFrame->getController();
1107 if ( CanConfig( m_aModuleId ) && xController.is() )
1108 {
1110 if ( xModel.is() )
1111 {
1113 xCfgSupplier( xModel, uno::UNO_QUERY );
1114
1115 if ( xCfgSupplier.is() )
1116 {
1117 xDocCfgMgr = xCfgSupplier->getUIConfigurationManager();
1118 }
1119 aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
1120 }
1121 }
1122
1123 SaveInData* pDocData = nullptr;
1124 if ( xDocCfgMgr.is() )
1125 {
1126 pDocData = CreateSaveInData( xDocCfgMgr, xCfgMgr, m_aModuleId, true );
1127
1128 if ( !pDocData->IsReadOnly() )
1129 {
1130 OUString sId(weld::toId(pDocData));
1131 m_xSaveInListBox->append(sId, aTitle);
1132 }
1133 }
1134
1135 // if an item to select has been passed in (eg. the ResourceURL for a
1136 // toolbar) then try to select the SaveInData entry that has that item
1137 bool bURLToSelectFound = false;
1138 if ( !m_aURLToSelect.isEmpty() )
1139 {
1140 if ( pDocData && pDocData->HasURL( m_aURLToSelect ) )
1141 {
1142 m_xSaveInListBox->set_active(nPos);
1143 pCurrentSaveInData = pDocData;
1144 bURLToSelectFound = true;
1145 }
1146 else if ( pModuleData && pModuleData->HasURL( m_aURLToSelect ) )
1147 {
1148 m_xSaveInListBox->set_active(0);
1149 pCurrentSaveInData = pModuleData;
1150 bURLToSelectFound = true;
1151 }
1152 }
1153
1154 if ( !bURLToSelectFound )
1155 {
1156 // if the document has menu configuration settings select it
1157 // it the SaveIn listbox, otherwise select the module data
1158 if ( pDocData != nullptr && pDocData->HasSettings() )
1159 {
1160 m_xSaveInListBox->set_active(nPos);
1161 pCurrentSaveInData = pDocData;
1162 }
1163 else
1164 {
1165 m_xSaveInListBox->set_active(0);
1166 pCurrentSaveInData = pModuleData;
1167 }
1168 }
1169
1170#ifdef DBG_UTIL
1171 DBG_ASSERT( pCurrentSaveInData, "SvxConfigPage::Reset(): no SaveInData" );
1172#endif
1173
1174 if ( CanConfig( m_aModuleId ) )
1175 {
1176 // Load configuration for other open documents which have
1177 // same module type
1179 try
1180 {
1181 uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
1182 xContext );
1183
1185 xFramesSupplier->getFrames();
1186
1187 aFrameList = xFrames->queryFrames(
1188 frame::FrameSearchFlag::ALL & ~frame::FrameSearchFlag::SELF );
1189
1190 }
1191 catch( const uno::Exception& )
1192 {
1193 DBG_UNHANDLED_EXCEPTION("cui.customize");
1194 }
1195
1196 for ( uno::Reference < frame::XFrame > const & xf : std::as_const(aFrameList) )
1197 {
1198 if ( xf.is() && xf != m_xFrame )
1199 {
1200 OUString aCheckId;
1201 try{
1202 aCheckId = xModuleManager->identify( xf );
1203 } catch(const uno::Exception&)
1204 { aCheckId.clear(); }
1205
1206 if ( m_aModuleId == aCheckId )
1207 {
1208 // try to get the document based ui configuration manager
1209 OUString aTitle2;
1211 xf->getController();
1212
1213 if ( xController_.is() )
1214 {
1216 xController_->getModel() );
1217
1218 if ( xModel.is() )
1219 {
1221 css::ui::XUIConfigurationManagerSupplier >
1222 xCfgSupplier( xModel, uno::UNO_QUERY );
1223
1224 if ( xCfgSupplier.is() )
1225 {
1226 xDocCfgMgr =
1227 xCfgSupplier->getUIConfigurationManager();
1228 }
1229 aTitle2 = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
1230 }
1231 }
1232
1233 if ( xDocCfgMgr.is() )
1234 {
1235 SaveInData* pData = CreateSaveInData( xDocCfgMgr, xCfgMgr, m_aModuleId, true );
1236
1237 if ( pData && !pData->IsReadOnly() )
1238 {
1239 OUString sId(weld::toId(pData));
1240 m_xSaveInListBox->append(sId, aTitle2);
1241 }
1242 }
1243 }
1244 }
1245 }
1246 }
1247
1248 m_xSaveInListBox->connect_changed(
1249 LINK( this, SvxConfigPage, SelectSaveInLocation ) );
1250
1251 bInitialised = true;
1252
1253 Init();
1254 }
1255 else
1256 {
1257 if ( QueryReset() == RET_YES )
1258 {
1259 // Reset menu configuration for currently selected SaveInData
1260 GetSaveInData()->Reset();
1261
1262 Init();
1263 }
1264 }
1265}
1266
1268{
1269 OUString sModuleID;
1270 try
1271 {
1273 ::comphelper::getProcessComponentContext() );
1274
1275 uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(
1276 xContext );
1277
1278 if ( !_inout_rxFrame.is() )
1279 _inout_rxFrame = xDesktop->getActiveFrame();
1280
1281 if ( !_inout_rxFrame.is() )
1282 {
1283 _inout_rxFrame = xDesktop->getCurrentFrame();
1284 }
1285
1286 if ( !_inout_rxFrame.is() && SfxViewFrame::Current() )
1287 _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
1288
1289 if ( !_inout_rxFrame.is() )
1290 {
1291 SAL_WARN( "cui.customize", "SvxConfigPage::GetFrameWithDefaultAndIdentify(): no frame found!" );
1292 return sModuleID;
1293 }
1294
1295 sModuleID = vcl::CommandInfoProvider::GetModuleIdentifier(_inout_rxFrame);
1296 }
1297 catch( const uno::Exception& )
1298 {
1299 DBG_UNHANDLED_EXCEPTION("cui.customize");
1300 }
1301
1302 return sModuleID;
1303}
1304
1306{
1307 OUString result;
1308
1309 SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
1310 if (pData)
1311 {
1312 if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
1313 ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) ||
1314 ( pData->nKind == SfxCfgKind::GROUP_STYLES ) )
1315 {
1316 result = pData->sCommand;
1317 }
1318 }
1319
1320 return result;
1321}
1322
1324{
1325 return m_xFunctions->get_selected_text();
1326}
1327
1329{
1330 bool result = false;
1331
1332 for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
1333 {
1334 OUString sId = m_xSaveInListBox->get_id(i);
1335 if (sId != notebookbarTabScope)
1336 {
1337 SaveInData* pData = weld::fromId<SaveInData*>(sId);
1338 result = pData->Apply();
1339 }
1340 }
1341 return result;
1342}
1343
1344IMPL_LINK_NOARG(SvxConfigPage, SelectSaveInLocation, weld::ComboBox&, void)
1345{
1346 OUString sId = m_xSaveInListBox->get_active_id();
1347 if (sId != notebookbarTabScope)
1348 pCurrentSaveInData = weld::fromId<SaveInData*>(sId);
1349 Init();
1350}
1351
1353{
1354 int nSelectionPos = m_xTopLevelListBox->get_active();
1355 m_xTopLevelListBox->clear();
1356
1357 if ( GetSaveInData() && GetSaveInData()->GetEntries() )
1358 {
1359 for (auto const& entryData : *GetSaveInData()->GetEntries())
1360 {
1361 OUString sId(weld::toId(entryData));
1362 m_xTopLevelListBox->append(sId, SvxConfigPageHelper::stripHotKey(entryData->GetName()));
1363
1364 if (entryData == pToSelect)
1365 nSelectionPos = m_xTopLevelListBox->get_count() - 1;
1366
1367 AddSubMenusToUI( SvxConfigPageHelper::stripHotKey( entryData->GetName() ), entryData );
1368 }
1369 }
1370#ifdef DBG_UTIL
1371 else
1372 {
1373 DBG_ASSERT( GetSaveInData(), "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData" );
1374 DBG_ASSERT( GetSaveInData()->GetEntries() ,
1375 "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData entries" );
1376 }
1377#endif
1378
1379 nSelectionPos = (nSelectionPos != -1 && nSelectionPos < m_xTopLevelListBox->get_count()) ?
1380 nSelectionPos : m_xTopLevelListBox->get_count() - 1;
1381
1382 m_xTopLevelListBox->set_active(nSelectionPos);
1383 SelectElement();
1384}
1385
1387 std::u16string_view rBaseTitle, SvxConfigEntry const * pParentData )
1388{
1389 for (auto const& entryData : *pParentData->GetEntries())
1390 {
1391 if (entryData->IsPopup())
1392 {
1393 OUString subMenuTitle = OUString::Concat(rBaseTitle) + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey(entryData->GetName());
1394
1395 OUString sId(weld::toId(entryData));
1396 m_xTopLevelListBox->append(sId, subMenuTitle);
1397
1398 AddSubMenusToUI( subMenuTitle, entryData );
1399 }
1400 }
1401}
1402
1404 SvxEntries* pRootEntries, SvxConfigEntry* pChildData )
1405{
1406 for (auto const& entryData : *pRootEntries)
1407 {
1408
1409 if (entryData == pChildData)
1410 {
1411 return pRootEntries;
1412 }
1413 else if (entryData->IsPopup())
1414 {
1416 FindParentForChild( entryData->GetEntries(), pChildData );
1417
1418 if ( result != nullptr )
1419 {
1420 return result;
1421 }
1422 }
1423 }
1424 return nullptr;
1425}
1426
1428{
1429 OUString aDisplayName;
1430
1431 if ( aURL.isEmpty() ) {
1432 return nullptr;
1433 }
1434
1436
1437 if ( typeid(*pCurrentSaveInData) == typeid(ContextMenuSaveInData) )
1439 else if ( typeid(*pCurrentSaveInData) == typeid(MenuSaveInData) )
1441 else
1443
1444 SvxConfigEntry* toret =
1445 new SvxConfigEntry( aDisplayName, aURL, false, /*bParentData*/false );
1446
1447 toret->SetUserDefined();
1448
1449 if ( aDisplayName.isEmpty() )
1450 toret->SetName( GetSelectedDisplayName() );
1451
1452 return toret;
1453}
1454
1456 const SvxEntries *pEntries)
1457{
1458 bool toret = false;
1459
1460 if ( pEntries != nullptr
1461 && pEntryData != nullptr )
1462 {
1463 for (auto const& entry : *pEntries)
1464 {
1465 if ( entry->GetCommand() == pEntryData->GetCommand() )
1466 {
1467 toret = true;
1468 break;
1469 }
1470 }
1471 }
1472
1473 return toret;
1474}
1475
1476int SvxConfigPage::AddFunction(int nTarget, bool bAllowDuplicates)
1477{
1478 int toret = -1;
1479 OUString aURL = GetScriptURL();
1481
1482 if ( aURL.isEmpty() || pParent == nullptr )
1483 {
1484 return -1;
1485 }
1486
1487
1488 SvxConfigEntry * pNewEntryData = CreateCommandFromSelection( aURL );
1489
1490 // check that this function is not already in the menu
1491 if ( !bAllowDuplicates
1492 && IsCommandInMenuList( pNewEntryData, pParent->GetEntries() )
1493 )
1494 {
1495 delete pNewEntryData;
1496 } else {
1497 toret = AppendEntry( pNewEntryData, nTarget );
1498 }
1499
1501 return toret;
1502}
1503
1505 SvxConfigEntry* pNewEntryData,
1506 int nTarget)
1507{
1508 SvxConfigEntry* pTopLevelSelection = GetTopLevelSelection();
1509
1510 if (pTopLevelSelection == nullptr)
1511 return -1;
1512
1513 // Grab the entries list for the currently selected menu
1514 SvxEntries* pEntries = pTopLevelSelection->GetEntries();
1515
1516 int nNewEntry = -1;
1517 int nCurEntry =
1518 nTarget != -1 ? nTarget : m_xContentsListBox->get_selected_index();
1519
1520 OUString sId(weld::toId(pNewEntryData));
1521
1522 if (nCurEntry == -1 || nCurEntry == m_xContentsListBox->n_children() - 1)
1523 {
1524 pEntries->push_back( pNewEntryData );
1525 m_xContentsListBox->insert(-1, sId);
1526 nNewEntry = m_xContentsListBox->n_children() - 1;
1527 }
1528 else
1529 {
1530 SvxConfigEntry* pEntryData =
1531 weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry));
1532
1533 SvxEntries::iterator iter = pEntries->begin();
1534 SvxEntries::const_iterator end = pEntries->end();
1535
1536 // Advance the iterator to the data for currently selected entry
1537 sal_uInt16 nPos = 0;
1538 while (*iter != pEntryData && ++iter != end)
1539 {
1540 ++nPos;
1541 }
1542
1543 // Now step past it to the entry after the currently selected one
1544 ++iter;
1545 ++nPos;
1546
1547 // Now add the new entry to the UI and to the parent's list
1548 if ( iter != end )
1549 {
1550 pEntries->insert( iter, pNewEntryData );
1551 m_xContentsListBox->insert(nPos, sId);
1552 nNewEntry = nPos;
1553 }
1554 }
1555
1556 if (nNewEntry != -1)
1557 {
1558 m_xContentsListBox->select(nNewEntry);
1559 m_xContentsListBox->scroll_to_row(nNewEntry);
1560
1563 }
1564
1565 return nNewEntry;
1566}
1567
1568namespace
1569{
1570 template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, SaveInData* pSaveInData,
1571 VirtualDevice& rDropDown, bool bMenu)
1572 {
1573 OUString sId(weld::toId(pNewEntryData));
1574
1575 rTreeView.set_id(rIter, sId);
1576
1577 if (pNewEntryData->IsSeparator())
1578 {
1579 rTreeView.set_text(rIter, "----------------------------------", 0);
1580 }
1581 else
1582 {
1583 auto xImage = pSaveInData->GetImage(pNewEntryData->GetCommand());
1584 if (xImage.is())
1585 rTreeView.set_image(rIter, xImage, -1);
1586 OUString aName = SvxConfigPageHelper::stripHotKey( pNewEntryData->GetName() );
1587 rTreeView.set_text(rIter, aName, 0);
1588 }
1589
1590 if (bMenu) // menus
1591 {
1592 if (pNewEntryData->IsPopup() || pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN)
1593 rTreeView.set_image(rIter, rDropDown, 1);
1594 else
1595 rTreeView.set_image(rIter, css::uno::Reference<css::graphic::XGraphic>(), 1);
1596 }
1597 }
1598}
1599
1600void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, int nPos, bool bMenu)
1601{
1602 TmplInsertEntryIntoUI<int>(pNewEntryData, rTreeView, nPos, GetSaveInData(),
1603 m_xContentsListBox->get_dropdown_image(), bMenu);
1604}
1605
1606void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, weld::TreeIter& rIter, bool bMenu)
1607{
1608 TmplInsertEntryIntoUI<weld::TreeIter>(pNewEntryData, rTreeView, rIter, GetSaveInData(),
1609 m_xContentsListBox->get_dropdown_image(), bMenu);
1610}
1611
1612IMPL_LINK(SvxConfigPage, MoveHdl, weld::Button&, rButton, void)
1613{
1614 MoveEntry(&rButton == m_xMoveUpButton.get());
1615}
1616
1617IMPL_LINK_NOARG(SvxConfigPage, FunctionDoubleClickHdl, weld::TreeView&, bool)
1618{
1619 if (m_xAddCommandButton->get_sensitive())
1620 m_xAddCommandButton->clicked();
1621 return true;
1622}
1623
1625{
1626 // GetScriptURL() returns a non-empty string if a
1627 // valid command is selected on the left box
1628 OUString aSelectCommand = GetScriptURL();
1629 bool bIsValidCommand = !aSelectCommand.isEmpty();
1630
1631 // Enable/disable Add and Remove buttons depending on current selection
1632 if (bIsValidCommand)
1633 {
1634 m_xAddCommandButton->set_sensitive(true);
1635 m_xRemoveCommandButton->set_sensitive(true);
1636
1638 {
1639 m_xDescriptionField->set_text(m_xFunctions->GetHelpText(false));
1640 }
1641 else
1642 {
1643 SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
1644 if (pData)
1645 {
1646 bool bIsExperimental
1647 = vcl::CommandInfoProvider::IsExperimental(pData->sCommand, m_aModuleId);
1648
1649 OUString aExperimental = "\n" + CuiResId(RID_CUISTR_COMMANDEXPERIMENTAL);
1650 OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pData->sLabel + "\n";
1651 OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": " + pData->sCommand + "\n";
1652 OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": " + pData->sTooltip;
1653 if (bIsExperimental)
1654 m_xDescriptionField->set_text(aLabel + aName + aTip + aExperimental);
1655 else
1656 m_xDescriptionField->set_text(aLabel + aName + aTip);
1657 }
1658 }
1659 }
1660 else
1661 {
1662
1663 m_xAddCommandButton->set_sensitive(false);
1664 m_xRemoveCommandButton->set_sensitive(false);
1665
1666 m_xDescriptionField->set_text("");
1667 }
1668
1669 UpdateButtonStates();
1670}
1671
1672IMPL_LINK_NOARG(SvxConfigPage, ImplUpdateDataHdl, Timer*, void)
1673{
1674 OUString aSearchTerm(m_xSearchEdit->get_text());
1675 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
1676 SelectFunctionHdl(m_xFunctions->get_widget());
1677}
1678
1680{
1681 m_aUpdateDataTimer.Start();
1682}
1683
1685{
1686 if (m_aUpdateDataTimer.IsActive())
1687 {
1688 m_aUpdateDataTimer.Stop();
1689 m_aUpdateDataTimer.Invoke();
1690 }
1691}
1692
1694{
1695 weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
1696
1697 int nSourceEntry = rTreeView.get_selected_index();
1698 int nTargetEntry = -1;
1699 int nToSelect = -1;
1700
1701 if (nSourceEntry == -1)
1702 {
1703 return;
1704 }
1705
1706 if ( bMoveUp )
1707 {
1708 // Move Up is just a Move Down with the source and target reversed
1709 nTargetEntry = nSourceEntry;
1710 nSourceEntry = nTargetEntry - 1;
1711 nToSelect = nSourceEntry;
1712 }
1713 else
1714 {
1715 nTargetEntry = nSourceEntry + 1;
1716 nToSelect = nTargetEntry;
1717 }
1718
1719 if (MoveEntryData(nSourceEntry, nTargetEntry))
1720 {
1721 rTreeView.swap(nSourceEntry, nTargetEntry);
1722 rTreeView.select(nToSelect);
1723 rTreeView.scroll_to_row(nToSelect);
1724
1726 }
1727}
1728
1729bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry)
1730{
1731 //#i53677#
1732 if (nSourceEntry == -1 || nTargetEntry == -1)
1733 {
1734 return false;
1735 }
1736
1737 // Grab the entries list for the currently selected menu
1739
1740 SvxConfigEntry* pSourceData =
1741 weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry));
1742
1743 SvxConfigEntry* pTargetData =
1744 weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry));
1745
1746 if ( pSourceData == nullptr || pTargetData == nullptr )
1747 return false;
1748
1749 // remove the source entry from our list
1750 SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
1751
1752 SvxEntries::iterator iter = pEntries->begin();
1753 SvxEntries::const_iterator end = pEntries->end();
1754
1755 // advance the iterator to the position of the target entry
1756 while (*iter != pTargetData && ++iter != end) ;
1757
1758 // insert the source entry at the position after the target
1759 pEntries->insert( ++iter, pSourceData );
1760
1763
1764 return true;
1765}
1766
1768 weld::Window* pParent, SvxEntries* entries,
1769 SvxConfigEntry const * selection, bool bCreateMenu )
1770 : GenericDialogController(pParent, "cui/ui/movemenu.ui", "MoveMenuDialog")
1771 , m_xMenuBox(m_xBuilder->weld_widget("namebox"))
1772 , m_xMenuNameEdit(m_xBuilder->weld_entry("menuname"))
1773 , m_xMenuListBox(m_xBuilder->weld_tree_view("menulist"))
1774 , m_xMoveUpButton(m_xBuilder->weld_button("up"))
1775 , m_xMoveDownButton(m_xBuilder->weld_button("down"))
1776{
1777 m_xMenuListBox->set_size_request(-1, m_xMenuListBox->get_height_rows(12));
1778
1779 // Copy the entries list passed in
1780 if ( entries != nullptr )
1781 {
1782 mpEntries.reset( new SvxEntries );
1783 for (auto const& entry : *entries)
1784 {
1785 m_xMenuListBox->append(weld::toId(entry),
1786 SvxConfigPageHelper::stripHotKey(entry->GetName()));
1787 mpEntries->push_back(entry);
1788 if (entry == selection)
1789 {
1790 m_xMenuListBox->select(m_xMenuListBox->n_children() - 1);
1791 }
1792 }
1793 }
1794
1795 if ( bCreateMenu )
1796 {
1797 // Generate custom name for new menu
1798 OUString prefix = CuiResId( RID_CUISTR_NEW_MENU );
1799
1800 OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries );
1801 OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries.get() );
1802
1803 SvxConfigEntry* pNewEntryData =
1804 new SvxConfigEntry( newname, newurl, true, /*bParentData*/false );
1805 pNewEntryData->SetName( newname );
1806 pNewEntryData->SetUserDefined();
1807 pNewEntryData->SetMain();
1808
1809 m_sNewMenuEntryId = weld::toId(pNewEntryData);
1811 SvxConfigPageHelper::stripHotKey(pNewEntryData->GetName()));
1812 m_xMenuListBox->select(m_xMenuListBox->n_children() - 1);
1813
1814 if (mpEntries)
1815 mpEntries->push_back(pNewEntryData);
1816
1817 m_xMenuNameEdit->set_text(newname);
1818 m_xMenuNameEdit->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, ModifyHdl));
1819 }
1820 else
1821 {
1822 // hide name label and textfield
1823 m_xMenuBox->hide();
1824 // change the title
1825 m_xDialog->set_title(CuiResId(RID_CUISTR_MOVE_MENU));
1826 }
1827
1828 m_xMenuListBox->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, SelectHdl));
1829
1830 m_xMoveUpButton->connect_clicked(LINK( this, SvxMainMenuOrganizerDialog, MoveHdl));
1831 m_xMoveDownButton->connect_clicked(LINK( this, SvxMainMenuOrganizerDialog, MoveHdl));
1832
1834}
1835
1837{
1838}
1839
1841{
1842 // if the Edit control is empty do not change the name
1843 if (m_xMenuNameEdit->get_text().isEmpty())
1844 {
1845 return;
1846 }
1847
1848 SvxConfigEntry* pNewEntryData = weld::fromId<SvxConfigEntry*>(m_sNewMenuEntryId);
1849 pNewEntryData->SetName(m_xMenuNameEdit->get_text());
1850
1851 const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId);
1852 const int nOldSelection = m_xMenuListBox->get_selected_index();
1853 m_xMenuListBox->remove(nNewMenuPos);
1854 m_xMenuListBox->insert(nNewMenuPos, pNewEntryData->GetName(), &m_sNewMenuEntryId, nullptr, nullptr);
1855 m_xMenuListBox->select(nOldSelection);
1856}
1857
1859{
1860 UpdateButtonStates();
1861}
1862
1864{
1865 // Disable Up and Down buttons depending on current selection
1866 const int nSelected = m_xMenuListBox->get_selected_index();
1867 m_xMoveUpButton->set_sensitive(nSelected > 0);
1868 m_xMoveDownButton->set_sensitive(nSelected != -1 && nSelected < m_xMenuListBox->n_children() - 1);
1869}
1870
1872{
1873 int nSourceEntry = m_xMenuListBox->get_selected_index();
1874 if (nSourceEntry == -1)
1875 return;
1876
1877 int nTargetEntry;
1878
1879 if (&rButton == m_xMoveDownButton.get())
1880 {
1881 nTargetEntry = nSourceEntry + 1;
1882 }
1883 else
1884 {
1885 // Move Up is just a Move Down with the source and target reversed
1886 nTargetEntry = nSourceEntry - 1;
1887 }
1888
1889 OUString sId = m_xMenuListBox->get_id(nSourceEntry);
1890 OUString sEntry = m_xMenuListBox->get_text(nSourceEntry);
1891 m_xMenuListBox->remove(nSourceEntry);
1892 m_xMenuListBox->insert(nTargetEntry, sEntry, &sId, nullptr, nullptr);
1893 m_xMenuListBox->select(nTargetEntry);
1894
1895 std::swap(mpEntries->at(nSourceEntry), mpEntries->at(nTargetEntry));
1896
1897 UpdateButtonStates();
1898}
1899
1901{
1902 const int nSelected(m_xMenuListBox->get_selected_index());
1903 if (nSelected == -1)
1904 return nullptr;
1905 return weld::fromId<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected));
1906}
1907
1908SvxConfigEntry::SvxConfigEntry( OUString aDisplayName,
1909 OUString aCommandURL, bool bPopup, bool bParentData )
1910 : nId( 1 )
1911 , aLabel(std::move(aDisplayName))
1912 , aCommand(std::move(aCommandURL))
1913 , bPopUp(bPopup)
1914 , bStrEdited( false )
1915 , bIsUserDefined( false )
1916 , bIsMain( false )
1917 , bIsParentData( bParentData )
1918 , bIsModified( false )
1919 , bIsVisible( true )
1920 , nStyle( 0 )
1921{
1922 if (bPopUp)
1923 {
1924 mpEntries.reset( new SvxEntries );
1925 }
1926}
1927
1929{
1930 if (mpEntries)
1931 {
1932 for (auto const& entry : *mpEntries)
1933 {
1934 delete entry;
1935 }
1936 }
1937}
1938
1940{
1941 return !IsPopup() || IsMain();
1942}
1943
1945{
1946 return !IsMain() || IsUserDefined();
1947}
1948
1950{
1951 return !IsMain() || IsUserDefined();
1952}
1953
1957 const OUString& aModuleId,
1958 bool docConfig ) :
1959
1960 SaveInData ( xCfgMgr, xParentCfgMgr, aModuleId, docConfig ),
1961 m_aDescriptorContainer ( ITEM_DESCRIPTOR_CONTAINER )
1962
1963{
1964 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
1965 // Initialize the m_xPersistentWindowState variable which is used
1966 // to get the default properties of system toolbars such as name
1967 uno::Reference< container::XNameAccess > xPWSS = css::ui::theWindowStateConfiguration::get( xContext );
1968
1969 xPWSS->getByName( aModuleId ) >>= m_xPersistentWindowState;
1970}
1971
1973{
1974}
1975
1976sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
1977{
1978 sal_Int32 result = 0;
1979
1980 if ( rResourceURL.startsWith( "private" ) &&
1982 m_xPersistentWindowState->hasByName( rResourceURL ) )
1983 {
1984 try
1985 {
1987 uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
1988
1989 if ( a >>= aProps )
1990 {
1991 for ( beans::PropertyValue const & prop : std::as_const(aProps) )
1992 {
1993 if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
1994 {
1995 prop.Value >>= result;
1996 break;
1997 }
1998 }
1999 }
2000 }
2001 catch ( uno::Exception& )
2002 {
2003 // do nothing, a default value is returned
2004 }
2005 }
2006
2007 return result;
2008}
2009
2011 const uno::Reference< frame::XFrame >& xFrame,
2012 const OUString& rResourceURL,
2013 sal_Int32 nStyle )
2014{
2015 // change the style using the API
2016 SetSystemStyle( rResourceURL, nStyle );
2017
2018 // this code is a temporary hack as the UI is not updating after
2019 // changing the toolbar style via the API
2021 vcl::Window *window = nullptr;
2022
2023 uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
2024 if ( xPropSet.is() )
2025 {
2026 uno::Any a = xPropSet->getPropertyValue( "LayoutManager" );
2027 a >>= xLayoutManager;
2028 }
2029
2030 if ( xLayoutManager.is() )
2031 {
2033 xLayoutManager->getElement( rResourceURL );
2034
2035 // check reference before we call getRealInterface. The layout manager
2036 // can only provide references for elements that have been created
2037 // before. It's possible that the current element is not available.
2039 if ( xUIElement.is() )
2040 xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY );
2041
2042 window = VCLUnoHelper::GetWindow( xWindow );
2043 }
2044
2045 if ( window == nullptr || window->GetType() != WindowType::TOOLBOX )
2046 return;
2047
2048 ToolBox* toolbox = static_cast<ToolBox*>(window);
2049
2050 if ( nStyle == 0 )
2051 {
2052 toolbox->SetButtonType( ButtonType::SYMBOLONLY );
2053 }
2054 else if ( nStyle == 1 )
2055 {
2056 toolbox->SetButtonType( ButtonType::TEXT );
2057 }
2058 if ( nStyle == 2 )
2059 {
2060 toolbox->SetButtonType( ButtonType::SYMBOLTEXT );
2061 }
2062}
2063
2065 const OUString& rResourceURL,
2066 sal_Int32 nStyle )
2067{
2068 if ( !(rResourceURL.startsWith( "private" ) &&
2070 m_xPersistentWindowState->hasByName( rResourceURL )) )
2071 return;
2072
2073 try
2074 {
2076
2077 uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
2078
2079 if ( a >>= aProps )
2080 {
2081 for ( beans::PropertyValue& prop : asNonConstRange(aProps) )
2082 {
2083 if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
2084 {
2085 prop.Value <<= nStyle;
2086 break;
2087 }
2088 }
2089 }
2090
2092 xNameReplace( m_xPersistentWindowState, uno::UNO_QUERY );
2093
2094 xNameReplace->replaceByName( rResourceURL, uno::Any( aProps ) );
2095 }
2096 catch ( uno::Exception& )
2097 {
2098 // do nothing, a default value is returned
2099 TOOLS_WARN_EXCEPTION("cui.customize", "Exception setting toolbar style");
2100 }
2101}
2102
2103OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
2104{
2105 OUString result;
2106
2107 if ( rResourceURL.startsWith( "private" ) &&
2109 m_xPersistentWindowState->hasByName( rResourceURL ) )
2110 {
2111 try
2112 {
2114 uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
2115
2116 if ( a >>= aProps )
2117 {
2118 for ( beans::PropertyValue const & prop : std::as_const(aProps) )
2119 {
2120 if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
2121 {
2122 prop.Value >>= result;
2123 }
2124 }
2125 }
2126 }
2127 catch ( uno::Exception& )
2128 {
2129 // do nothing, an empty UIName will be returned
2130 }
2131 }
2132
2133 if ( rResourceURL.startsWith( ".uno" ) &&
2134 m_xCommandToLabelMap.is() &&
2135 m_xCommandToLabelMap->hasByName( rResourceURL ) )
2136 {
2137 uno::Any a;
2138 try
2139 {
2140 a = m_xCommandToLabelMap->getByName( rResourceURL );
2141
2143 if ( a >>= aPropSeq )
2144 {
2145 for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
2146 {
2147 if ( prop.Name == ITEM_DESCRIPTOR_LABEL )
2148 {
2149 prop.Value >>= result;
2150 }
2151 }
2152 }
2153 }
2154 catch ( uno::Exception& )
2155 {
2156 // not a system command name
2157 }
2158 }
2159
2160 return result;
2161}
2162
2164{
2165 typedef std::unordered_map<OUString, bool > ToolbarInfo;
2166
2167 ToolbarInfo aToolbarInfo;
2168
2169 if ( pRootEntry == nullptr )
2170 {
2171
2172 pRootEntry.reset( new SvxConfigEntry( "MainToolbars", OUString(), true, /*bParentData*/false) );
2173
2175 GetConfigManager()->getUIElementsInfo(
2176 css::ui::UIElementType::TOOLBAR );
2177
2178 for ( uno::Sequence<beans::PropertyValue> const & props : info )
2179 {
2180 OUString url;
2181 OUString systemname;
2182 OUString uiname;
2183
2184 for ( const beans::PropertyValue& prop : props )
2185 {
2186 if ( prop.Name == ITEM_DESCRIPTOR_RESOURCEURL )
2187 {
2188 prop.Value >>= url;
2189 systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
2190 }
2191 else if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
2192 {
2193 prop.Value >>= uiname;
2194 }
2195 }
2196
2197 try
2198 {
2200 GetConfigManager()->getSettings( url, false );
2201
2202 if ( uiname.isEmpty() )
2203 {
2204 // try to get the name from m_xPersistentWindowState
2205 uiname = GetSystemUIName( url );
2206
2207 if ( uiname.isEmpty() )
2208 {
2209 uiname = systemname;
2210 }
2211 }
2212
2213 SvxConfigEntry* pEntry = new SvxConfigEntry(
2214 uiname, url, true, /*bParentData*/false );
2215
2216 pEntry->SetMain();
2217 pEntry->SetStyle( GetSystemStyle( url ) );
2218
2219
2220 // insert into std::unordered_map to filter duplicates from the parent
2221 aToolbarInfo.emplace( systemname, true );
2222
2223 if ( systemname.startsWith( CUSTOM_TOOLBAR_STR ) )
2224 {
2225 pEntry->SetUserDefined();
2226 }
2227 else
2228 {
2229 pEntry->SetUserDefined( false );
2230 }
2231
2232 pRootEntry->GetEntries()->push_back( pEntry );
2233
2234 LoadToolbar( xToolbarSettings, pEntry );
2235 }
2236 catch ( container::NoSuchElementException& )
2237 {
2238 // TODO, handle resourceURL with no settings
2239 }
2240 }
2241
2243 if ( xParentCfgMgr.is() )
2244 {
2245 // Retrieve also the parent toolbars to make it possible
2246 // to configure module toolbars and save them into the document
2247 // config manager.
2249 xParentCfgMgr->getUIElementsInfo(
2250 css::ui::UIElementType::TOOLBAR );
2251
2252 for ( uno::Sequence<beans::PropertyValue> const & props : info_ )
2253 {
2254 OUString url;
2255 OUString systemname;
2256 OUString uiname;
2257
2258 for ( const beans::PropertyValue& prop : props )
2259 {
2260 if ( prop.Name == ITEM_DESCRIPTOR_RESOURCEURL )
2261 {
2262 prop.Value >>= url;
2263 systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
2264 }
2265 else if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
2266 {
2267 prop.Value >>= uiname;
2268 }
2269 }
2270
2271 // custom toolbars of the parent are not visible in the document layer
2272 OUString custom(CUSTOM_TOOLBAR_STR);
2273 if ( systemname.startsWith( custom ) )
2274 continue;
2275
2276 // check if toolbar is already in the document layer
2277 ToolbarInfo::const_iterator pIter = aToolbarInfo.find( systemname );
2278 if ( pIter == aToolbarInfo.end() )
2279 {
2280 aToolbarInfo.emplace( systemname, true );
2281
2282 try
2283 {
2285 xParentCfgMgr->getSettings( url, false );
2286
2287 if ( uiname.isEmpty() )
2288 {
2289 // try to get the name from m_xPersistentWindowState
2290 uiname = GetSystemUIName( url );
2291
2292 if ( uiname.isEmpty() )
2293 {
2294 uiname = systemname;
2295 }
2296 }
2297
2298 SvxConfigEntry* pEntry = new SvxConfigEntry(
2299 uiname, url, true, true );
2300
2301 pEntry->SetMain();
2302 pEntry->SetStyle( GetSystemStyle( url ) );
2303
2304 if ( systemname.startsWith( custom ) )
2305 {
2306 pEntry->SetUserDefined();
2307 }
2308 else
2309 {
2310 pEntry->SetUserDefined( false );
2311 }
2312
2313 pRootEntry->GetEntries()->push_back( pEntry );
2314
2315 LoadToolbar( xToolbarSettings, pEntry );
2316 }
2317 catch ( container::NoSuchElementException& )
2318 {
2319 // TODO, handle resourceURL with no settings
2320 }
2321 }
2322 }
2323 }
2324
2326 }
2327
2328 return pRootEntry->GetEntries();
2329}
2330
2331void
2332ToolbarSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
2333{
2334 pRootEntry->SetEntries( std::move(pNewEntries) );
2335}
2336
2337bool
2338ToolbarSaveInData::HasURL( const OUString& rURL )
2339{
2340 for (auto const& entry : *GetEntries())
2341 {
2342 if (entry->GetCommand() == rURL)
2343 {
2344 return !entry->IsParentData();
2345 }
2346 }
2347 return false;
2348}
2349
2351{
2352 // return true if there is at least one toolbar entry
2353 return !GetEntries()->empty();
2354}
2355
2357{
2358 // reset each toolbar by calling removeSettings for its toolbar URL
2359 for (auto const& entry : *GetEntries())
2360 {
2361 try
2362 {
2363 const OUString& url = entry->GetCommand();
2364 GetConfigManager()->removeSettings( url );
2365 }
2366 catch ( uno::Exception& )
2367 {
2368 // error occurred removing the settings
2369 // TODO - add error dialog in future?
2370 }
2371 }
2372
2373 // persist changes to toolbar storage
2375
2376 // now delete the root SvxConfigEntry the next call to GetEntries()
2377 // causes it to be reinitialised
2378 pRootEntry.reset();
2379
2380 // reset all icons to default
2381 try
2382 {
2383 GetImageManager()->reset();
2385 }
2386 catch ( uno::Exception& )
2387 {
2388 SAL_WARN("cui.customize", "Error resetting all icons when resetting toolbars");
2389 }
2390}
2391
2393{
2394 // toolbar changes are instantly applied
2395 return false;
2396}
2397
2401 SvxConfigEntry const * pToolbarData )
2402{
2403 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
2404
2405 for (auto const& entry : *pToolbarData->GetEntries())
2406 {
2407 if (entry->IsPopup())
2408 {
2411
2413 rFactory->createInstanceWithContext( xContext ),
2414 uno::UNO_QUERY );
2415
2416 sal_Int32 nIndex = aPropValueSeq.getLength();
2417 aPropValueSeq.realloc( nIndex + 1 );
2418 auto pPropValueSeq = aPropValueSeq.getArray();
2419 pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
2420 pPropValueSeq[nIndex].Value <<= xSubMenuBar;
2421 rToolbarBar->insertByIndex(
2422 rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
2423
2424 ApplyToolbar(xSubMenuBar, rFactory, entry);
2425 }
2426 else if (entry->IsSeparator())
2427 {
2428 rToolbarBar->insertByIndex(
2429 rToolbarBar->getCount(), uno::Any( m_aSeparatorSeq ));
2430 }
2431 else
2432 {
2435
2436 rToolbarBar->insertByIndex(
2437 rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
2438 }
2439 }
2440}
2441
2443{
2444 // Apply new toolbar structure to our settings container
2446 GetConfigManager()->createSettings();
2447
2449 xSettings, uno::UNO_QUERY );
2450
2452 xSettings, uno::UNO_QUERY );
2453
2454 ApplyToolbar( xIndexContainer, xFactory, pToolbar );
2455
2457 xSettings, uno::UNO_QUERY );
2458
2459 if ( pToolbar->IsUserDefined() )
2460 {
2461 xProps->setPropertyValue(
2463 uno::Any( pToolbar->GetName() ) );
2464 }
2465
2466 try
2467 {
2468 if ( GetConfigManager()->hasSettings( pToolbar->GetCommand() ) )
2469 {
2470 GetConfigManager()->replaceSettings(
2471 pToolbar->GetCommand(), xSettings );
2472 }
2473 else
2474 {
2475 GetConfigManager()->insertSettings(
2476 pToolbar->GetCommand(), xSettings );
2477 if ( pToolbar->IsParentData() )
2478 pToolbar->SetParentData( false );
2479 }
2480 }
2481 catch ( css::uno::Exception const & )
2482 {
2483 TOOLS_WARN_EXCEPTION("cui.customize", "caught exception saving settings");
2484 }
2485
2487}
2488
2490{
2491 // show the new toolbar in the UI also
2493 xSettings = GetConfigManager()->createSettings();
2494
2496 xPropertySet( xSettings, uno::UNO_QUERY );
2497
2498 xPropertySet->setPropertyValue(
2500 uno::Any( pToolbar->GetName() ) );
2501
2502 try
2503 {
2504 GetConfigManager()->insertSettings( pToolbar->GetCommand(), xSettings );
2505 }
2506 catch ( css::uno::Exception const & )
2507 {
2508 TOOLS_WARN_EXCEPTION("cui.customize", "caught exception saving settings");
2509 }
2510
2511 GetEntries()->push_back( pToolbar );
2512
2514}
2515
2517{
2518 try
2519 {
2520 OUString url = pToolbar->GetCommand();
2521 GetConfigManager()->removeSettings( url );
2523 delete pToolbar;
2524
2526
2527 // remove the persistent window state data
2528 css::uno::Reference< css::container::XNameContainer > xNameContainer(
2529 m_xPersistentWindowState, css::uno::UNO_QUERY_THROW );
2530
2531 xNameContainer->removeByName( url );
2532 }
2533 catch ( uno::Exception& )
2534 {
2535 // error occurred removing the settings
2536 }
2537}
2538
2540{
2541 OUString url = pToolbar->GetCommand();
2542
2543 // Restore of toolbar is done by removing it from
2544 // its configuration manager and then getting it again
2545 bool bParentToolbar = pToolbar->IsParentData();
2546
2547 // Cannot restore parent toolbar
2548 if ( bParentToolbar )
2549 return;
2550
2551 try
2552 {
2553 GetConfigManager()->removeSettings( url );
2554 pToolbar->GetEntries()->clear();
2556 }
2557 catch ( uno::Exception& )
2558 {
2559 // if an error occurs removing the settings then just return
2560 return;
2561 }
2562
2563 // Now reload the toolbar settings
2564 try
2565 {
2567 if ( IsDocConfig() )
2568 {
2569 xToolbarSettings = GetParentConfigManager()->getSettings( url, false );
2570 pToolbar->SetParentData();
2571 }
2572 else
2573 xToolbarSettings = GetConfigManager()->getSettings( url, false );
2574
2575 LoadToolbar( xToolbarSettings, pToolbar );
2576
2577 // After reloading, ensure that the icon is reset of each entry
2578 // in the toolbar
2579 uno::Sequence< OUString > aURLSeq( 1 );
2580 auto pURLSeq = aURLSeq.getArray();
2581 for (auto const& entry : *pToolbar->GetEntries())
2582 {
2583 pURLSeq[ 0 ] = entry->GetCommand();
2584
2585 try
2586 {
2587 GetImageManager()->removeImages( SvxConfigPageHelper::GetImageType(), aURLSeq );
2588 }
2589 catch ( uno::Exception& )
2590 {
2591 SAL_WARN("cui.customize", "Error restoring icon when resetting toolbar");
2592 }
2593 }
2595 }
2596 catch ( container::NoSuchElementException& )
2597 {
2598 // cannot find the resource URL after removing it
2599 // so no entry will appear in the toolbar list
2600 }
2601}
2602
2604 const uno::Reference< container::XIndexAccess >& xToolbarSettings,
2605 SvxConfigEntry const * pParentData )
2606{
2607 SvxEntries* pEntries = pParentData->GetEntries();
2608
2609 for ( sal_Int32 nIndex = 0; nIndex < xToolbarSettings->getCount(); ++nIndex )
2610 {
2611 OUString aCommandURL;
2612 OUString aLabel;
2613 bool bIsVisible;
2614 sal_Int32 nStyle;
2615
2616 sal_uInt16 nType( css::ui::ItemType::DEFAULT );
2617
2618 bool bItem = SvxConfigPageHelper::GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL,
2619 aLabel, nType, bIsVisible, nStyle );
2620
2621 if ( bItem )
2622 {
2623 bool bIsUserDefined = true;
2624
2625 if ( nType == css::ui::ItemType::DEFAULT )
2626 {
2627 uno::Any a;
2628 try
2629 {
2630 a = m_xCommandToLabelMap->getByName( aCommandURL );
2631 bIsUserDefined = false;
2632 }
2633 catch ( container::NoSuchElementException& )
2634 {
2635 bIsUserDefined = true;
2636 }
2637
2638 bool bUseDefaultLabel = false;
2639 // If custom label not set retrieve it from the command
2640 // to info service
2641 if ( aLabel.isEmpty() )
2642 {
2643 bUseDefaultLabel = true;
2645 if ( a >>= aPropSeq )
2646 {
2647 for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
2648 {
2649 if ( prop.Name == "Name" )
2650 {
2651 prop.Value >>= aLabel;
2652 break;
2653 }
2654 }
2655 }
2656 }
2657
2658 SvxConfigEntry* pEntry = new SvxConfigEntry(
2659 aLabel, aCommandURL, false, /*bParentData*/false );
2660
2661 pEntry->SetUserDefined( bIsUserDefined );
2662 pEntry->SetVisible( bIsVisible );
2663 pEntry->SetStyle( nStyle );
2664
2665 if ( !bUseDefaultLabel )
2666 pEntry->SetName( aLabel );
2667
2668 pEntries->push_back( pEntry );
2669 }
2670 else
2671 {
2672 SvxConfigEntry* pEntry = new SvxConfigEntry;
2673 pEntry->SetUserDefined( bIsUserDefined );
2674 pEntries->push_back( pEntry );
2675 }
2676 }
2677 }
2678}
2679
2681 : GenericDialogController(pWindow, "cui/ui/newtoolbardialog.ui", "NewToolbarDialog")
2682 , m_xEdtName(m_xBuilder->weld_entry("edit"))
2683 , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
2684{
2685 m_xEdtName->set_text(rName);
2686 m_xEdtName->select_region(0, -1);
2687}
2688
2690{
2691}
2692
2693/*******************************************************************************
2694*
2695* The SvxIconSelectorDialog class
2696*
2697*******************************************************************************/
2700 uno::Reference< css::ui::XImageManager > xParentImageManager)
2701 : GenericDialogController(pWindow, "cui/ui/iconselectordialog.ui", "IconSelector")
2702 , m_xImageManager(std::move(xImageManager))
2703 , m_xParentImageManager(std::move(xParentImageManager))
2704 , m_xTbSymbol(new ValueSet(m_xBuilder->weld_scrolled_window("symbolswin", true)))
2705 , m_xTbSymbolWin(new weld::CustomWeld(*m_xBuilder, "symbolsToolbar", *m_xTbSymbol))
2706 , m_xFtNote(m_xBuilder->weld_label("noteLabel"))
2707 , m_xBtnImport(m_xBuilder->weld_button("importButton"))
2708 , m_xBtnDelete(m_xBuilder->weld_button("deleteButton"))
2709{
2710 typedef std::unordered_map< OUString, bool > ImageInfo;
2711
2712 m_nExpectedSize = 16;
2713 if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_LARGE)
2714 m_nExpectedSize = 24;
2715 else if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_32)
2716 m_nExpectedSize = 32;
2717
2718 if ( m_nExpectedSize != 16 )
2719 {
2721 }
2722
2723 m_xTbSymbol->SetStyle(m_xTbSymbol->GetStyle() | WB_ITEMBORDER | WB_VSCROLL);
2724 m_xTbSymbol->SetColCount(11);
2725 m_xTbSymbol->SetLineCount(5);
2726 m_xTbSymbol->SetItemWidth(m_nExpectedSize);
2727 m_xTbSymbol->SetItemHeight(m_nExpectedSize);
2728 m_xTbSymbol->SetExtraSpacing(6);
2729 Size aSize(m_xTbSymbol->CalcWindowSizePixel(Size(m_nExpectedSize, m_nExpectedSize), 11, 5));
2730 m_xTbSymbol->set_size_request(aSize.Width(), aSize.Height());
2731
2733 ::comphelper::getProcessComponentContext();
2734
2735 m_xGraphProvider.set( graphic::GraphicProvider::create( xComponentContext ) );
2736
2738 css::util::thePathSettings::get( xComponentContext );
2739
2740
2741 OUString aDirectory = xPathSettings->getUserConfig();
2742
2743 sal_Int32 aCount = aDirectory.getLength();
2744
2745 if ( aCount > 0 )
2746 {
2747 sal_Unicode aChar = aDirectory[ aCount-1 ];
2748 if ( aChar != '/')
2749 {
2750 aDirectory += "/";
2751 }
2752 }
2753 else
2754 {
2755 m_xBtnImport->set_sensitive(false);
2756 }
2757
2758 aDirectory += "soffice.cfg/import";
2759
2761 css::embed::FileSystemStorageFactory::create( xComponentContext ) );
2762
2763 uno::Sequence< uno::Any > aArgs{ uno::Any(aDirectory),
2764 uno::Any(css::embed::ElementModes::READWRITE) };
2765
2767 xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
2768
2770 {
2771 {"UserConfigStorage", uno::Any(xStorage)},
2772 {"OpenMode", uno::Any(css::embed::ElementModes::READWRITE)}
2773 }));
2774 m_xImportedImageManager = css::ui::ImageManager::create( xComponentContext );
2775 m_xImportedImageManager->initialize(aProp);
2776
2777 ImageInfo aImageInfo1;
2778 if ( m_xImportedImageManager.is() )
2779 {
2781 for (auto const & name : names )
2782 aImageInfo1.emplace( name, false );
2783 }
2784
2786 auto pname = name.getArray();
2787 for (auto const& elem : aImageInfo1)
2788 {
2789 pname[ 0 ] = elem.first;
2791 if ( graphics.hasElements() )
2792 {
2793 m_aGraphics.push_back(graphics[0]);
2794 Image img(graphics[0]);
2795 m_xTbSymbol->InsertItem(m_aGraphics.size(), img, elem.first);
2796 }
2797 }
2798
2799 ImageInfo aImageInfo;
2800
2801 if ( m_xParentImageManager.is() )
2802 {
2804 for ( auto const & i : names )
2805 aImageInfo.emplace( i, false );
2806 }
2807
2809 for ( auto const & i : names )
2810 {
2811 ImageInfo::iterator pIter = aImageInfo.find( i );
2812 if ( pIter != aImageInfo.end() )
2813 pIter->second = true;
2814 else
2815 aImageInfo.emplace( i, true );
2816 }
2817
2818 // large growth factor, expecting many entries
2819 for (auto const& elem : aImageInfo)
2820 {
2821 pname[ 0 ] = elem.first;
2822
2824 try
2825 {
2826 if (elem.second)
2827 graphics = m_xImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
2828 else
2830 }
2831 catch ( uno::Exception& )
2832 {
2833 // can't get sequence for this name so it will not be
2834 // added to the list
2835 }
2836
2837 if ( graphics.hasElements() )
2838 {
2839 Image img(graphics[0]);
2840 if (!img.GetBitmapEx().IsEmpty())
2841 {
2842 m_aGraphics.push_back(graphics[0]);
2843 m_xTbSymbol->InsertItem(m_aGraphics.size(), img, elem.first);
2844 }
2845 }
2846 }
2847
2848 m_xBtnDelete->set_sensitive( false );
2849 m_xTbSymbol->SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) );
2850 m_xBtnImport->connect_clicked( LINK(this, SvxIconSelectorDialog, ImportHdl) );
2851 m_xBtnDelete->connect_clicked( LINK(this, SvxIconSelectorDialog, DeleteHdl) );
2852}
2853
2855{
2856}
2857
2859{
2861
2862 sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
2863
2864 if (nId)
2865 {
2866 result = m_aGraphics[nId - 1];
2867 }
2868
2869 return result;
2870}
2871
2873{
2874 sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
2875
2876 if (!nId)
2877 {
2878 m_xBtnDelete->set_sensitive(false);
2879 return;
2880 }
2881
2882 OUString aSelImageText = m_xTbSymbol->GetItemText(nId);
2883 if (m_xImportedImageManager->hasImage(SvxConfigPageHelper::GetImageType(), aSelImageText))
2884 {
2885 m_xBtnDelete->set_sensitive(true);
2886 }
2887 else
2888 {
2889 m_xBtnDelete->set_sensitive(false);
2890 }
2891}
2892
2894{
2895 sfx2::FileDialogHelper aImportDialog(
2896 css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
2897 FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, m_xDialog.get());
2899
2900 // disable the link checkbox in the dialog
2902 xController( aImportDialog.GetFilePicker(), uno::UNO_QUERY);
2903 if ( xController.is() )
2904 {
2905 xController->enableControl(
2906 css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK,
2907 false);
2908 }
2909
2911 sal_uInt16 nFilter = rFilter.GetImportFormatNumberForShortName(u"png");
2912 aImportDialog.SetCurrentFilter(rFilter.GetImportFormatName(nFilter));
2913
2914 if ( ERRCODE_NONE == aImportDialog.Execute() )
2915 {
2916 uno::Sequence< OUString > paths = aImportDialog.GetMPath();
2917 ImportGraphics ( paths );
2918 }
2919}
2920
2922{
2923 OUString message = CuiResId( RID_CUISTR_DELETE_ICON_CONFIRM );
2924
2925 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(),
2926 VclMessageType::Warning, VclButtonsType::OkCancel,
2927 message));
2928 if (xWarn->run() != RET_OK)
2929 return;
2930
2931 sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
2932
2933 OUString aSelImageText = m_xTbSymbol->GetItemText( nId );
2934 uno::Sequence< OUString > URLs { aSelImageText };
2935 m_xTbSymbol->RemoveItem(nId);
2936 m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs );
2937 if ( m_xImportedImageManager->isModified() )
2938 {
2939 m_xImportedImageManager->store();
2940 }
2941}
2942
2944 const OUString& aURL )
2945{
2948
2949 css::awt::Size aSize;
2950 bool bOK = false;
2951 try
2952 {
2953 xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
2954
2956 m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
2957 uno::Any a = props->getPropertyValue( "SizePixel" );
2958 a >>= aSize;
2959 if (0 == aSize.Width || 0 == aSize.Height)
2960 return false;
2961 else
2962 bOK = true;
2963 }
2964 catch ( uno::Exception& )
2965 {
2966 return false;
2967 }
2968
2969 bool bResult( false );
2970 size_t nCount = m_xTbSymbol->GetItemCount();
2971 for (size_t n = 0; n < nCount; ++n)
2972 {
2973 sal_uInt16 nId = m_xTbSymbol->GetItemId( n );
2974
2975 if ( m_xTbSymbol->GetItemText( nId ) == aURL )
2976 {
2977 try
2978 {
2979 // replace/insert image with provided URL
2980 size_t nPos = nId - 1;
2981 assert(nPos == m_xTbSymbol->GetItemPos(nId));
2982 m_xTbSymbol->RemoveItem(nId);
2983
2984 Image aImage( xGraphic );
2985 if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
2986 {
2987 BitmapEx aBitmap = aImage.GetBitmapEx();
2989 aImage = Image( aBitmapex);
2990 }
2991 m_xTbSymbol->InsertItem(nId, aImage, aURL, nPos); //modify
2992
2994
2995 m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), { aURL }, { xGraphic } );
2996 m_xImportedImageManager->store();
2997
2998 bResult = true;
2999 break;
3000 }
3001 catch ( css::uno::Exception& )
3002 {
3003 break;
3004 }
3005 }
3006 }
3007
3008 return bResult;
3009}
3010
3011namespace
3012{
3013 OUString ReplaceIconName(std::u16string_view rMessage)
3014 {
3015 OUString name;
3016 OUString message = CuiResId( RID_CUISTR_REPLACE_ICON_WARNING );
3017 OUString placeholder("%ICONNAME" );
3018 sal_Int32 pos = message.indexOf( placeholder );
3019 if ( pos != -1 )
3020 {
3021 name = message.replaceAt(
3022 pos, placeholder.getLength(), rMessage );
3023 }
3024 return name;
3025 }
3026
3027 class SvxIconReplacementDialog
3028 {
3029 private:
3030 std::unique_ptr<weld::MessageDialog> m_xQueryBox;
3031 public:
3032 SvxIconReplacementDialog(weld::Window *pParent, std::u16string_view rMessage, bool bYestoAll)
3033 : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::NONE, ReplaceIconName(rMessage)))
3034 {
3035 m_xQueryBox->set_title(CuiResId(RID_CUISTR_REPLACE_ICON_CONFIRM));
3036 m_xQueryBox->add_button(GetStandardText(StandardButtonType::Yes), 2);
3037 if (bYestoAll)
3038 m_xQueryBox->add_button(CuiResId(RID_CUISTR_YESTOALL), 5);
3039 m_xQueryBox->add_button(GetStandardText(StandardButtonType::No), 4);
3040 m_xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), 6);
3041 m_xQueryBox->set_default_response(2);
3042 }
3043 short run() { return m_xQueryBox->run(); }
3044 };
3045}
3046
3048 const uno::Sequence< OUString >& rPaths )
3049{
3050 std::vector< OUString > rejected( rPaths.getLength() );
3051 sal_Int32 rejectedCount = 0;
3052
3053 sal_uInt16 ret = 0;
3054 sal_Int32 aIndex;
3055 OUString aIconName;
3056
3057 if ( rPaths.getLength() == 1 )
3058 {
3059 if ( m_xImportedImageManager->hasImage( SvxConfigPageHelper::GetImageType(), rPaths[0] ) )
3060 {
3061 aIndex = rPaths[0].lastIndexOf( '/' );
3062 aIconName = rPaths[0].copy( aIndex+1 );
3063 SvxIconReplacementDialog aDlg(m_xDialog.get(), aIconName, false);
3064 ret = aDlg.run();
3065 if ( ret == 2 )
3066 {
3067 ReplaceGraphicItem( rPaths[0] );
3068 }
3069 }
3070 else
3071 {
3072 if ( !ImportGraphic( rPaths[0] ) )
3073 {
3074 rejected[0] = rPaths[0];
3075 rejectedCount = 1;
3076 }
3077 }
3078 }
3079 else
3080 {
3081 OUString aSourcePath( rPaths[0] );
3082 if ( rPaths[0].lastIndexOf( '/' ) != rPaths[0].getLength() -1 )
3083 aSourcePath = rPaths[0] + "/";
3084
3085 for ( sal_Int32 i = 1; i < rPaths.getLength(); ++i )
3086 {
3087 OUString aPath = aSourcePath + rPaths[i];
3089 {
3090 aIndex = rPaths[i].lastIndexOf( '/' );
3091 aIconName = rPaths[i].copy( aIndex+1 );
3092 SvxIconReplacementDialog aDlg(m_xDialog.get(), aIconName, true);
3093 ret = aDlg.run();
3094 if ( ret == 2 )
3095 {
3096 ReplaceGraphicItem( aPath );
3097 }
3098 else if ( ret == 5 )
3099 {
3100 for ( sal_Int32 k = i; k < rPaths.getLength(); ++k )
3101 {
3102 aPath = aSourcePath + rPaths[k];
3103 bool bHasReplaced = ReplaceGraphicItem( aPath );
3104
3105 if ( !bHasReplaced )
3106 {
3107 bool result = ImportGraphic( aPath );
3108 if ( !result )
3109 {
3110 rejected[ rejectedCount ] = rPaths[i];
3111 ++rejectedCount;
3112 }
3113 }
3114 }
3115 break;
3116 }
3117 }
3118 else
3119 {
3120 bool result = ImportGraphic( aSourcePath + rPaths[i] );
3121 if ( !result )
3122 {
3123 rejected[ rejectedCount ] = rPaths[i];
3124 ++rejectedCount;
3125 }
3126 }
3127 }
3128 }
3129
3130 if ( rejectedCount == 0 )
3131 return;
3132
3133 OUStringBuffer message;
3134 OUString fPath;
3135 if (rejectedCount > 1)
3136 fPath = OUString::Concat(rPaths[0].subView(8)) + "/";
3137 for ( sal_Int32 i = 0; i < rejectedCount; ++i )
3138 {
3139 message.append(fPath + rejected[i] + "\n");
3140 }
3141
3142 SvxIconChangeDialog aDialog(m_xDialog.get(), message.makeStringAndClear());
3143 aDialog.run();
3144}
3145
3146bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
3147{
3148 bool result = false;
3149
3151
3152 try
3153 {
3155 m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
3156
3157 uno::Any a = props->getPropertyValue("SizePixel");
3158
3159 uno::Reference< graphic::XGraphic > xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
3160 if ( xGraphic.is() )
3161 {
3162 bool bOK = true;
3163 css::awt::Size aSize;
3164
3165 a >>= aSize;
3166 if ( 0 == aSize.Width || 0 == aSize.Height )
3167 bOK = false;
3168
3169 Image aImage( xGraphic );
3170
3171 if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
3172 {
3173 BitmapEx aBitmap = aImage.GetBitmapEx();
3175 aImage = Image( aBitmapex);
3176 }
3177 if ( bOK && !!aImage )
3178 {
3179 m_aGraphics.push_back(Graphic(aImage.GetBitmapEx()).GetXGraphic());
3180 m_xTbSymbol->InsertItem(m_aGraphics.size(), aImage, aURL);
3181
3182 uno::Sequence<OUString> aImportURL { aURL };
3183 uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph{ xGraphic };
3184 m_xImportedImageManager->insertImages( SvxConfigPageHelper::GetImageType(), aImportURL, aImportGraph );
3185 if ( m_xImportedImageManager->isModified() )
3186 {
3187 m_xImportedImageManager->store();
3188 }
3189
3190 result = true;
3191 }
3192 else
3193 {
3194 SAL_WARN("cui.customize", "could not create Image from XGraphic");
3195 }
3196 }
3197 else
3198 {
3199 SAL_WARN("cui.customize", "could not get query XGraphic");
3200 }
3201 }
3202 catch( uno::Exception const & )
3203 {
3204 TOOLS_WARN_EXCEPTION("cui.customize", "Caught exception importing XGraphic");
3205 }
3206 return result;
3207}
3208
3209/*******************************************************************************
3210*
3211* The SvxIconChangeDialog class added for issue83555
3212*
3213*******************************************************************************/
3215 : MessageDialogController(pWindow, "cui/ui/iconchangedialog.ui", "IconChange", "grid")
3216 , m_xLineEditDescription(m_xBuilder->weld_text_view("addrTextview"))
3217{
3218 m_xLineEditDescription->set_size_request(m_xLineEditDescription->get_approximate_digit_width() * 48,
3219 m_xLineEditDescription->get_text_height() * 8);
3220 m_xLineEditDescription->set_text(rMessage);
3221}
3222
3224 : weld::ReorderingDropTarget(rTreeView)
3225 , m_rPage(rPage)
3226{
3227}
3228
3230{
3233 return nRet;;
3234}
3235
3236/* 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:1037
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
IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent &, rKeyEvent, bool)
Definition: cfg.cxx:947
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
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:210
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:211
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:181
bool Apply() override
Definition: cfg.cxx:551
static MenuSaveInData * pDefaultData
static holder of the default menu data
Definition: cfg.hxx:179
OUString m_aDescriptorContainer
Definition: cfg.hxx:171
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:174
static MenuSaveInData * GetDefaultData()
Definition: cfg.hxx:182
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:170
virtual ~MenuSaveInData() override
Definition: cfg.cxx:408
std::unique_ptr< SvxConfigEntry > pRootEntry
Definition: cfg.hxx:176
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:99
bool IsDocConfig() const
Definition: cfg.hxx:132
bool IsReadOnly() const
Definition: cfg.hxx:131
virtual bool HasSettings()=0
bool bReadOnly
Definition: cfg.hxx:87
const css::uno::Reference< css::ui::XImageManager > & GetImageManager() const
Definition: cfg.hxx:144
css::uno::Reference< css::container::XNameAccess > m_xCommandToLabelMap
Definition: cfg.hxx:148
virtual void Reset()=0
const css::uno::Reference< css::ui::XUIConfigurationManager > & GetConfigManager() const
Definition: cfg.hxx:136
css::uno::Sequence< css::beans::PropertyValue > m_aSeparatorSeq
Definition: cfg.hxx:154
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:128
css::uno::Reference< css::ui::XUIConfigurationManager > m_xParentCfgMgr
Definition: cfg.hxx:93
bool bDocConfig
Definition: cfg.hxx:86
bool IsModified() const
Definition: cfg.hxx:129
static css::uno::Reference< css::ui::XImageManager > * xDefaultImgMgr
Definition: cfg.hxx:102
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:96
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:140
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)
virtual void ActivatePage(const OString &rPage)
weld::Button * GetResetButton() const
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
virtual void ActivatePage(const OString &rPage) override
Definition: cfg.cxx:231
SvxConfigDialog(weld::Window *, const SfxItemSet *)
Definition: cfg.cxx:206
sal_Int32 GetStyle() const
Definition: cfg.hxx:317
const OUString & GetCommand() const
Definition: cfg.hxx:278
bool IsDeletable() const
Definition: cfg.cxx:1944
void SetStyle(sal_Int32 style)
Definition: cfg.hxx:318
bool IsParentData() const
Definition: cfg.hxx:299
void SetParentData(bool bValue=true)
Definition: cfg.hxx:298
SvxEntries * GetEntries() const
Definition: cfg.hxx:292
std::unique_ptr< SvxEntries > mpEntries
Definition: cfg.hxx:254
bool IsMovable() const
Definition: cfg.cxx:1939
bool IsPopup() const
Definition: cfg.hxx:284
SvxConfigEntry()
Definition: cfg.hxx:263
void SetMain()
Definition: cfg.hxx:295
void SetName(const OUString &rStr)
Definition: cfg.hxx:281
void SetModified(bool bValue=true)
Definition: cfg.hxx:301
bool IsUserDefined() const
Definition: cfg.hxx:287
bool bPopUp
Definition: cfg.hxx:240
void SetUserDefined(bool bOn=true)
Definition: cfg.hxx:286
void SetVisible(bool b)
Definition: cfg.hxx:308
bool IsRenamable() const
Definition: cfg.cxx:1949
const OUString & GetName() const
Definition: cfg.hxx:280
bool IsSeparator() const
Definition: cfg.hxx:290
bool IsMain() const
Definition: cfg.hxx:296
~SvxConfigEntry()
Definition: cfg.cxx:1928
SvxConfigPage & m_rPage
Definition: cfg.hxx:361
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: cfg.cxx:3229
SvxConfigPageFunctionDropTarget(SvxConfigPage &rPage, weld::TreeView &rTreeView)
Definition: cfg.cxx:3223
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:1352
void InsertEntryIntoUI(SvxConfigEntry *pNewEntryData, weld::TreeView &rTreeView, int nPos, bool bMenu=false)
Definition: cfg.cxx:1600
OUString GetScriptURL() const
Definition: cfg.cxx:1305
OUString m_aModuleId
Definition: cfg.hxx:385
std::unique_ptr< weld::ComboBox > m_xTopLevelListBox
Definition: cfg.hxx:403
static bool CanConfig(std::u16string_view rModuleId)
Definition: cfg.cxx:163
virtual void ListModified()
Definition: cfg.hxx:498
virtual ~SvxConfigPage() override
Definition: cfg.cxx:1042
void Reset(const SfxItemSet *) override
Definition: cfg.cxx:1052
SvxConfigEntry * GetTopLevelSelection()
Definition: cfg.hxx:500
int AppendEntry(SvxConfigEntry *pNewEntryData, int nTarget)
Definition: cfg.cxx:1504
static OUString GetFrameWithDefaultAndIdentify(css::uno::Reference< css::frame::XFrame > &_inout_rxFrame)
identifies the module in the given frame.
Definition: cfg.cxx:1267
virtual void SelectElement()=0
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
Definition: cfg.hxx:390
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:396
int AddFunction(int nTarget, bool bAllowDuplicates)
Definition: cfg.cxx:1476
bool bInitialised
Definition: cfg.hxx:374
OUString m_aURLToSelect
the ResourceURL to select when opening the dialog
Definition: cfg.hxx:382
void AddSubMenusToUI(std::u16string_view rBaseTitle, SvxConfigEntry const *pParentData)
Definition: cfg.cxx:1386
static bool IsCommandInMenuList(const SvxConfigEntry *pEntryData, const SvxEntries *pEntries)
Definition: cfg.cxx:1455
std::unique_ptr< weld::TextView > m_xDescriptionField
Definition: cfg.hxx:394
OUString GetSelectedDisplayName() const
Definition: cfg.cxx:1323
SvxConfigEntry * CreateCommandFromSelection(const OUString &aURL)
Definition: cfg.cxx:1427
OUString m_sAppName
Definition: cfg.hxx:423
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: cfg.hxx:384
Timer m_aUpdateDataTimer
Definition: cfg.hxx:373
virtual void Init()=0
bool MoveEntryData(int SourceEntry, int nTargetEntry)
Definition: cfg.cxx:1729
OUString m_sFileName
Definition: cfg.hxx:424
bool FillItemSet(SfxItemSet *) override
Definition: cfg.cxx:1328
virtual void MoveEntry(bool bMoveUp)
Definition: cfg.cxx:1693
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
Definition: cfg.hxx:412
SaveInData * GetSaveInData()
Definition: cfg.hxx:481
SaveInData * pCurrentSaveInData
Definition: cfg.hxx:375
SvxConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &)
Definition: cfg.cxx:994
SvxEntries * FindParentForChild(SvxEntries *pParentEntries, SvxConfigEntry *pChildData)
Definition: cfg.cxx:1403
virtual short QueryReset()=0
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
Definition: cfg.hxx:406
std::unique_ptr< weld::TextView > m_xLineEditDescription
Definition: cfg.hxx:669
SvxIconChangeDialog(weld::Window *pWindow, const OUString &rMessage)
Definition: cfg.cxx:3214
void ImportGraphics(const css::uno::Sequence< OUString > &aURLs)
Definition: cfg.cxx:3047
bool ReplaceGraphicItem(const OUString &aURL)
Definition: cfg.cxx:2943
std::unique_ptr< weld::Button > m_xBtnImport
Definition: cfg.hxx:639
std::unique_ptr< weld::Label > m_xFtNote
Definition: cfg.hxx:638
std::unique_ptr< weld::Button > m_xBtnDelete
Definition: cfg.hxx:640
SvxIconSelectorDialog(weld::Window *pWindow, css::uno::Reference< css::ui::XImageManager > xImageManager, css::uno::Reference< css::ui::XImageManager > xParentImageManager)
Definition: cfg.cxx:2698
virtual ~SvxIconSelectorDialog() override
Definition: cfg.cxx:2854
std::vector< css::uno::Reference< css::graphic::XGraphic > > m_aGraphics
Definition: cfg.hxx:634
sal_Int32 m_nExpectedSize
Definition: cfg.hxx:620
css::uno::Reference< css::graphic::XGraphic > GetSelectedIcon()
Definition: cfg.cxx:2858
bool ImportGraphic(const OUString &aURL)
Definition: cfg.cxx:3146
std::unique_ptr< ValueSet > m_xTbSymbol
Definition: cfg.hxx:636
css::uno::Reference< css::ui::XImageManager > m_xImportedImageManager
Definition: cfg.hxx:629
css::uno::Reference< css::ui::XImageManager > m_xParentImageManager
Definition: cfg.hxx:626
css::uno::Reference< css::graphic::XGraphicProvider > m_xGraphProvider
Definition: cfg.hxx:632
css::uno::Reference< css::ui::XImageManager > m_xImageManager
Definition: cfg.hxx:623
OUString m_sNewMenuEntryId
Definition: cfg.hxx:525
SvxMainMenuOrganizerDialog(weld::Window *, SvxEntries *, SvxConfigEntry const *, bool bCreateMenu)
Definition: cfg.cxx:1767
virtual ~SvxMainMenuOrganizerDialog() override
Definition: cfg.cxx:1836
std::unique_ptr< weld::Button > m_xMoveUpButton
Definition: cfg.hxx:530
SvxConfigEntry * GetSelectedEntry()
Definition: cfg.cxx:1900
std::unique_ptr< weld::Widget > m_xMenuBox
Definition: cfg.hxx:527
std::unique_ptr< weld::TreeView > m_xMenuListBox
Definition: cfg.hxx:529
std::unique_ptr< weld::Entry > m_xMenuNameEdit
Definition: cfg.hxx:528
std::unique_ptr< weld::Button > m_xMoveDownButton
Definition: cfg.hxx:531
std::unique_ptr< SvxEntries > mpEntries
Definition: cfg.hxx:524
SvxMenuEntriesListBox(std::unique_ptr< weld::TreeView > xControl, SvxConfigPage *pPage)
Definition: cfg.cxx:932
std::unique_ptr< weld::TreeView > m_xControl
Definition: cfg.hxx:324
ScopedVclPtr< VirtualDevice > m_xDropDown
Definition: cfg.hxx:325
virtual ~SvxMenuEntriesListBox()
Definition: cfg.cxx:943
void CreateDropDown()
Definition: cfg.cxx:914
virtual ~SvxNewToolbarDialog() override
Definition: cfg.cxx:2689
SvxNewToolbarDialog(weld::Window *pWindow, const OUString &rName)
Definition: cfg.cxx:2680
std::unique_ptr< weld::Entry > m_xEdtName
Definition: cfg.hxx:604
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:2332
void SetSystemStyle(const OUString &rResourceURL, sal_Int32 nStyle)
Definition: cfg.cxx:2064
std::unique_ptr< SvxConfigEntry > pRootEntry
Definition: cfg.hxx:553
SvxEntries * GetEntries() override
Definition: cfg.cxx:2163
void RestoreToolbar(SvxConfigEntry *pToolbar)
Definition: cfg.cxx:2539
sal_Int32 GetSystemStyle(const OUString &rResourceURL)
Definition: cfg.cxx:1976
void CreateToolbar(SvxConfigEntry *pToolbar)
Definition: cfg.cxx:2489
bool HasURL(const OUString &rURL) override
Definition: cfg.cxx:2338
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:1972
void LoadToolbar(const css::uno::Reference< css::container::XIndexAccess > &xToolBarSettings, SvxConfigEntry const *pParentData)
Definition: cfg.cxx:2603
bool Apply() override
Definition: cfg.cxx:2392
void RemoveToolbar(SvxConfigEntry *pToolbar)
Definition: cfg.cxx:2516
OUString m_aDescriptorContainer
Definition: cfg.hxx:554
bool HasSettings() override
Definition: cfg.cxx:2350
css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState
Definition: cfg.hxx:557
void Reset() override
Definition: cfg.cxx:2356
ToolbarSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig)
Definition: cfg.cxx:1954
OUString GetSystemUIName(const OUString &rResourceURL)
Definition: cfg.cxx:2103
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 void set_visible(bool visible)
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 GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)
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