[Libreoffice-commits] core.git: cui/Library_cui.mk cui/source
Muhammet Kara
muhammet.kara at pardus.org.tr
Sat Jul 22 20:27:52 UTC 2017
cui/Library_cui.mk | 1
cui/source/customize/SvxConfigPageHelper.cxx | 476 ++++++++++++++++++++++++
cui/source/customize/SvxMenuConfigPage.cxx | 11
cui/source/customize/SvxToolbarConfigPage.cxx | 23 -
cui/source/customize/cfg.cxx | 87 ++--
cui/source/inc/SvxConfigPageHelper.hxx | 89 ++++
cui/source/inc/cfg.hxx | 502 --------------------------
7 files changed, 627 insertions(+), 562 deletions(-)
New commits:
commit 9f45e431abf0cc24cb1db86a0dd0979848d8eb8d
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date: Wed Jul 5 10:36:06 2017 +0300
Add new helper class to cui for SvxConfigPage
And kill the temporary namespace killmelater.
This class will contain helper functions/methods
for use of the tab pages of the Customize Dialog.
Change-Id: I63a05c9495a79009ed5b47f7790a46cff9f58c6a
Reviewed-on: https://gerrit.libreoffice.org/39617
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Muhammet Kara <muhammet.kara at pardus.org.tr>
Reviewed-on: https://gerrit.libreoffice.org/40308
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 8f29a4fa3ce0..4efdb440b242 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -88,6 +88,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/customize/cfgutil \
cui/source/customize/eventdlg \
cui/source/customize/macropg \
+ cui/source/customize/SvxConfigPageHelper \
cui/source/customize/SvxMenuConfigPage \
cui/source/customize/SvxToolbarConfigPage \
cui/source/dialogs/about \
diff --git a/cui/source/customize/SvxConfigPageHelper.cxx b/cui/source/customize/SvxConfigPageHelper.cxx
new file mode 100644
index 000000000000..0e8c9ec5e6e0
--- /dev/null
+++ b/cui/source/customize/SvxConfigPageHelper.cxx
@@ -0,0 +1,476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "SvxConfigPageHelper.hxx"
+
+static sal_Int16 theImageType =
+ css::ui::ImageType::COLOR_NORMAL |
+ css::ui::ImageType::SIZE_DEFAULT;
+
+void SvxConfigPageHelper::RemoveEntry( SvxEntries* pEntries, SvxConfigEntry* pChildEntry )
+{
+ SvxEntries::iterator iter = pEntries->begin();
+
+ while ( iter != pEntries->end() )
+ {
+ if ( pChildEntry == *iter )
+ {
+ pEntries->erase( iter );
+ break;
+ }
+ ++iter;
+ }
+}
+
+OUString SvxConfigPageHelper::replaceSaveInName( const OUString& rMessage, const OUString& rSaveInName )
+{
+ const OUString placeholder("%SAVE IN SELECTION%" );
+
+ OUString name = rMessage.replaceFirst(placeholder, rSaveInName);
+
+ return name;
+}
+
+OUString SvxConfigPageHelper::stripHotKey( const OUString& str )
+{
+ return str.replaceFirst("~", "");
+}
+
+OUString SvxConfigPageHelper::replaceSixteen( const OUString& str, sal_Int32 nReplacement )
+{
+ return str.replaceAll( OUString::number( 16 ), OUString::number( nReplacement ));
+}
+
+sal_Int16 SvxConfigPageHelper::GetImageType()
+{
+ return theImageType;
+}
+
+void SvxConfigPageHelper::InitImageType()
+{
+ theImageType =
+ css::ui::ImageType::COLOR_NORMAL |
+ css::ui::ImageType::SIZE_DEFAULT;
+
+ if (SvtMiscOptions().GetSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE)
+ {
+ theImageType |= css::ui::ImageType::SIZE_LARGE;
+ }
+ else if (SvtMiscOptions().GetSymbolsSize() == SFX_SYMBOLS_SIZE_32)
+ {
+ theImageType |= css::ui::ImageType::SIZE_32;
+ }
+}
+
+css::uno::Reference< css::graphic::XGraphic > SvxConfigPageHelper::GetGraphic(
+ const css::uno::Reference< css::ui::XImageManager >& xImageManager,
+ const OUString& rCommandURL )
+{
+ css::uno::Reference< css::graphic::XGraphic > result;
+
+ if ( xImageManager.is() )
+ {
+ // TODO handle large graphics
+ css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > aGraphicSeq;
+
+ css::uno::Sequence<OUString> aImageCmdSeq { rCommandURL };
+
+ try
+ {
+ aGraphicSeq =
+ xImageManager->getImages( GetImageType(), aImageCmdSeq );
+
+ if ( aGraphicSeq.getLength() > 0 )
+ {
+ result = aGraphicSeq[0];
+ }
+ }
+ catch ( css::uno::Exception& )
+ {
+ // will return empty XGraphic
+ }
+ }
+
+ return result;
+}
+
+OUString
+SvxConfigPageHelper::generateCustomName(
+ const OUString& prefix,
+ SvxEntries* entries,
+ sal_Int32 suffix /*= 1*/ )
+{
+ OUString name;
+ sal_Int32 pos = 0;
+
+ // find and replace the %n placeholder in the prefix string
+ name = prefix.replaceFirst( "%n", OUString::number( suffix ), &pos );
+
+ if ( pos == -1 )
+ {
+ // no placeholder found so just append the suffix
+ name += OUString::number( suffix );
+ }
+
+ if (!entries)
+ return name;
+
+ // now check if there is an already existing entry with this name
+ SvxEntries::const_iterator iter = entries->begin();
+
+ while ( iter != entries->end() )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( name.equals( pEntry->GetName() ) )
+ {
+ break;
+ }
+ ++iter;
+ }
+
+ if ( iter != entries->end() )
+ {
+ // name already exists so try the next number up
+ return generateCustomName( prefix, entries, ++suffix );
+ }
+
+ return name;
+}
+
+OUString SvxConfigPageHelper::generateCustomMenuURL(
+ SvxEntries* entries,
+ sal_Int32 suffix /*= 1*/ )
+{
+ OUString url = "vnd.openoffice.org:CustomMenu" + OUString::number( suffix );
+ if (!entries)
+ return url;
+
+ // now check is there is an already existing entry with this url
+ SvxEntries::const_iterator iter = entries->begin();
+
+ while ( iter != entries->end() )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( url.equals( pEntry->GetCommand() ) )
+ {
+ break;
+ }
+ ++iter;
+ }
+
+ if ( iter != entries->end() )
+ {
+ // url already exists so try the next number up
+ return generateCustomMenuURL( entries, ++suffix );
+ }
+
+ return url;
+}
+
+sal_uInt32 SvxConfigPageHelper::generateRandomValue()
+{
+ return comphelper::rng::uniform_uint_distribution(0, std::numeric_limits<unsigned int>::max());
+}
+
+OUString SvxConfigPageHelper::generateCustomURL( SvxEntries* entries )
+{
+ OUString url = ITEM_TOOLBAR_URL;
+ url += CUSTOM_TOOLBAR_STR;
+
+ // use a random number to minimize possible clash with existing custom toolbars
+ url += OUString::number( generateRandomValue(), 16 );
+
+ // now check is there is an already existing entry with this url
+ SvxEntries::const_iterator iter = entries->begin();
+
+ while ( iter != entries->end() )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( url.equals( pEntry->GetCommand() ) )
+ {
+ break;
+ }
+ ++iter;
+ }
+
+ if ( iter != entries->end() )
+ {
+ // url already exists so try the next number up
+ return generateCustomURL( entries );
+ }
+
+ return url;
+}
+
+OUString SvxConfigPageHelper::GetModuleName( const OUString& aModuleId )
+{
+ if ( aModuleId == "com.sun.star.text.TextDocument" ||
+ aModuleId == "com.sun.star.text.GlobalDocument" )
+ return OUString("Writer");
+ else if ( aModuleId == "com.sun.star.text.WebDocument" )
+ return OUString("Writer/Web");
+ else if ( aModuleId == "com.sun.star.drawing.DrawingDocument" )
+ return OUString("Draw");
+ else if ( aModuleId == "com.sun.star.presentation.PresentationDocument" )
+ return OUString("Impress");
+ else if ( aModuleId == "com.sun.star.sheet.SpreadsheetDocument" )
+ return OUString("Calc");
+ else if ( aModuleId == "com.sun.star.script.BasicIDE" )
+ return OUString("Basic");
+ else if ( aModuleId == "com.sun.star.formula.FormulaProperties" )
+ return OUString("Math");
+ else if ( aModuleId == "com.sun.star.sdb.RelationDesign" )
+ return OUString("Relation Design");
+ else if ( aModuleId == "com.sun.star.sdb.QueryDesign" )
+ return OUString("Query Design");
+ else if ( aModuleId == "com.sun.star.sdb.TableDesign" )
+ return OUString("Table Design");
+ else if ( aModuleId == "com.sun.star.sdb.DataSourceBrowser" )
+ return OUString("Data Source Browser" );
+ else if ( aModuleId == "com.sun.star.sdb.DatabaseDocument" )
+ return OUString("Database" );
+
+ return OUString();
+}
+
+OUString SvxConfigPageHelper::GetUIModuleName(
+ const OUString& aModuleId,
+ const css::uno::Reference< css::frame::XModuleManager2 >& rModuleManager )
+{
+ assert(rModuleManager.is());
+
+ OUString aModuleUIName;
+
+ try
+ {
+ css::uno::Any a = rModuleManager->getByName( aModuleId );
+ css::uno::Sequence< css::beans::PropertyValue > aSeq;
+
+ if ( a >>= aSeq )
+ {
+ for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
+ {
+ if ( aSeq[i].Name == "ooSetupFactoryUIName" )
+ {
+ aSeq[i].Value >>= aModuleUIName;
+ break;
+ }
+ }
+ }
+ }
+ catch ( css::uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch ( css::uno::Exception& )
+ {
+ }
+
+ if ( aModuleUIName.isEmpty() )
+ aModuleUIName = GetModuleName( aModuleId );
+
+ return aModuleUIName;
+}
+
+bool SvxConfigPageHelper::GetMenuItemData(
+ const css::uno::Reference< css::container::XIndexAccess >& rItemContainer,
+ sal_Int32 nIndex,
+ OUString& rCommandURL,
+ OUString& rLabel,
+ sal_uInt16& rType,
+ css::uno::Reference< css::container::XIndexAccess >& rSubMenu )
+{
+ try
+ {
+ css::uno::Sequence< css::beans::PropertyValue > aProp;
+ if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
+ {
+ for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
+ {
+ if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
+ {
+ aProp[i].Value >>= rCommandURL;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_CONTAINER )
+ {
+ aProp[i].Value >>= rSubMenu;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
+ {
+ aProp[i].Value >>= rLabel;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
+ {
+ aProp[i].Value >>= rType;
+ }
+ }
+
+ return true;
+ }
+ }
+ catch ( css::lang::IndexOutOfBoundsException& )
+ {
+ }
+
+ return false;
+}
+
+bool SvxConfigPageHelper::GetToolbarItemData(
+ const css::uno::Reference< css::container::XIndexAccess >& rItemContainer,
+ sal_Int32 nIndex,
+ OUString& rCommandURL,
+ OUString& rLabel,
+ sal_uInt16& rType,
+ bool& rIsVisible,
+ sal_Int32& rStyle )
+{
+ try
+ {
+ css::uno::Sequence< css::beans::PropertyValue > aProp;
+ if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
+ {
+ for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
+ {
+ if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
+ {
+ aProp[i].Value >>= rCommandURL;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_STYLE )
+ {
+ aProp[i].Value >>= rStyle;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
+ {
+ aProp[i].Value >>= rLabel;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
+ {
+ aProp[i].Value >>= rType;
+ }
+ else if ( aProp[i].Name == ITEM_DESCRIPTOR_ISVISIBLE )
+ {
+ aProp[i].Value >>= rIsVisible;
+ }
+ }
+
+ return true;
+ }
+ }
+ catch ( css::lang::IndexOutOfBoundsException& )
+ {
+ }
+
+ return false;
+}
+
+css::uno::Sequence< css::beans::PropertyValue > SvxConfigPageHelper::ConvertSvxConfigEntry(
+ const SvxConfigEntry* pEntry )
+{
+ css::uno::Sequence< css::beans::PropertyValue > aPropSeq( 3 );
+
+ aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
+ aPropSeq[0].Value <<= pEntry->GetCommand();
+
+ aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE;
+ aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
+
+ // If the name has not been changed, then the label can be stored
+ // as an empty string.
+ // It will be initialised again later using the command to label map.
+ aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL;
+ if ( !pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty() )
+ {
+ aPropSeq[2].Value <<= OUString();
+ }
+ else
+ {
+ aPropSeq[2].Value <<= pEntry->GetName();
+ }
+
+ return aPropSeq;
+}
+
+css::uno::Sequence< css::beans::PropertyValue > SvxConfigPageHelper::ConvertToolbarEntry(
+ const SvxConfigEntry* pEntry )
+{
+ css::uno::Sequence< css::beans::PropertyValue > aPropSeq( 4 );
+
+ aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
+ aPropSeq[0].Value <<= pEntry->GetCommand();
+
+ aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE;
+ aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
+
+ // If the name has not been changed, then the label can be stored
+ // as an empty string.
+ // It will be initialised again later using the command to label map.
+ aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL;
+ if ( !pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty() )
+ {
+ aPropSeq[2].Value <<= OUString();
+ }
+ else
+ {
+ aPropSeq[2].Value <<= pEntry->GetName();
+ }
+
+ aPropSeq[3].Name = ITEM_DESCRIPTOR_ISVISIBLE;
+ aPropSeq[3].Value <<= pEntry->IsVisible();
+
+ return aPropSeq;
+}
+
+bool SvxConfigPageHelper::showKeyConfigTabPage(
+ const css::uno::Reference< css::frame::XFrame >& xFrame )
+{
+ if (!xFrame.is())
+ {
+ return false;
+ }
+ OUString sModuleId(
+ css::frame::ModuleManager::create(
+ comphelper::getProcessComponentContext())
+ ->identify(xFrame));
+ return !sModuleId.isEmpty()
+ && sModuleId != "com.sun.star.frame.StartModule";
+}
+
+bool SvxConfigPageHelper::EntrySort( SvxConfigEntry* a, SvxConfigEntry* b )
+{
+ return a->GetName().compareTo( b->GetName() ) < 0;
+}
+
+bool SvxConfigPageHelper::SvxConfigEntryModified( SvxConfigEntry* pEntry )
+{
+ SvxEntries* pEntries = pEntry->GetEntries();
+ if ( !pEntries )
+ return false;
+
+ for ( const auto& entry : *pEntries )
+ {
+ if ( entry->IsModified() || SvxConfigEntryModified( entry ) )
+ return true;
+ }
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 26a16baee01c..ec4b2866fe86 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -59,6 +59,7 @@
#include "acccfg.hxx"
#include "cfg.hxx"
#include "SvxMenuConfigPage.hxx"
+#include "SvxConfigPageHelper.hxx"
#include "eventdlg.hxx"
#include <dialmgr.hxx>
@@ -252,7 +253,7 @@ void SvxMenuConfigPage::DeleteSelectedTopLevel()
SvxEntries* pParentEntries =
FindParentForChild( GetSaveInData()->GetEntries(), pMenuData );
- killmelater::RemoveEntry( pParentEntries, pMenuData );
+ SvxConfigPageHelper::RemoveEntry( pParentEntries, pMenuData );
delete pMenuData;
ReloadTopLevelListBox();
@@ -274,7 +275,7 @@ void SvxMenuConfigPage::DeleteSelectedContent()
SvxConfigEntry* pMenu = GetTopLevelSelection();
// remove menu entry from the list for this menu
- killmelater::RemoveEntry( pMenu->GetEntries(), pMenuEntry );
+ SvxConfigPageHelper::RemoveEntry( pMenu->GetEntries(), pMenuEntry );
// remove menu entry from UI
m_pContentsListBox->GetModel()->Remove( pActEntry );
@@ -300,7 +301,7 @@ short SvxMenuConfigPage::QueryReset()
OUString saveInName = m_pSaveInListBox->GetEntry(
m_pSaveInListBox->GetSelectEntryPos() );
- OUString label = killmelater::replaceSaveInName( msg, saveInName );
+ OUString label = SvxConfigPageHelper::replaceSaveInName( msg, saveInName );
ScopedVclPtrInstance<QueryBox> qbox( this, WB_YES_NO, label );
@@ -350,7 +351,7 @@ IMPL_LINK( SvxMenuConfigPage, MenuSelectHdl, MenuButton *, pButton, void )
{
SvxConfigEntry* pMenuData = GetTopLevelSelection();
- OUString aNewName( killmelater::stripHotKey( pMenuData->GetName() ) );
+ OUString aNewName( SvxConfigPageHelper::stripHotKey( pMenuData->GetName() ) );
OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
@@ -394,7 +395,7 @@ IMPL_LINK( SvxMenuConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
SvxConfigEntry* pEntry =
static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
- OUString aNewName( killmelater::stripHotKey( pEntry->GetName() ) );
+ OUString aNewName( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 272409d2825e..5df50650cd57 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -59,6 +59,7 @@
#include "acccfg.hxx"
#include "cfg.hxx"
#include "SvxToolbarConfigPage.hxx"
+#include "SvxConfigPageHelper.hxx"
#include "eventdlg.hxx"
#include <dialmgr.hxx>
@@ -281,7 +282,7 @@ void SvxToolbarConfigPage::DeleteSelectedContent()
SvxConfigEntry* pToolbar = GetTopLevelSelection();
// remove entry from the list for this toolbar
- killmelater::RemoveEntry( pToolbar->GetEntries(), pEntry );
+ SvxConfigPageHelper::RemoveEntry( pToolbar->GetEntries(), pEntry );
// remove toolbar entry from UI
m_pContentsListBox->GetModel()->Remove( pActEntry );
@@ -347,7 +348,7 @@ IMPL_LINK( SvxToolbarConfigPage, ToolbarSelectHdl, MenuButton *, pButton, void )
}
else if (sCommand == "modtoolrename")
{
- OUString aNewName( killmelater::stripHotKey( pToolbar->GetName() ) );
+ OUString aNewName( SvxConfigPageHelper::stripHotKey( pToolbar->GetName() ) );
OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
@@ -386,7 +387,7 @@ IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
SvxConfigEntry* pEntry =
static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
- OUString aNewName( killmelater::stripHotKey( pEntry->GetName() ) );
+ OUString aNewName( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
@@ -433,7 +434,7 @@ IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
{
pEntry->SetName( aSystemName );
m_pContentsListBox->SetEntryText(
- pActEntry, killmelater::stripHotKey( aSystemName ) );
+ pActEntry, SvxConfigPageHelper::stripHotKey( aSystemName ) );
bNeedsApply = true;
}
@@ -442,7 +443,7 @@ IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
try
{
GetSaveInData()->GetImageManager()->removeImages(
- killmelater::GetImageType(), aURLSeq );
+ SvxConfigPageHelper::GetImageType(), aURLSeq );
// reset backup in entry
pEntry->SetBackupGraphic(
@@ -508,7 +509,7 @@ IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
if ( !pEntry->GetBackupGraphic().is() )
{
css::uno::Reference< css::graphic::XGraphic > backup;
- backup = killmelater::GetGraphic(
+ backup = SvxConfigPageHelper::GetGraphic(
GetSaveInData()->GetImageManager(), aURLSeq[ 0 ] );
if ( backup.is() )
@@ -521,7 +522,7 @@ IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
try
{
GetSaveInData()->GetImageManager()->replaceImages(
- killmelater::GetImageType(), aURLSeq, aGraphicSeq );
+ SvxConfigPageHelper::GetImageType(), aURLSeq, aGraphicSeq );
m_pContentsListBox->GetModel()->Remove( pActEntry );
SvTreeListEntry* pNewLBEntry =
@@ -574,7 +575,7 @@ IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton, void )
try
{
GetSaveInData()->GetImageManager()->replaceImages(
- killmelater::GetImageType(), aURLSeq, aGraphicSeq );
+ SvxConfigPageHelper::GetImageType(), aURLSeq, aGraphicSeq );
m_pContentsListBox->GetModel()->Remove( pActEntry );
@@ -704,7 +705,7 @@ short SvxToolbarConfigPage::QueryReset()
OUString saveInName = m_pSaveInListBox->GetEntry(
m_pSaveInListBox->GetSelectEntryPos() );
- OUString label = killmelater::replaceSaveInName( msg, saveInName );
+ OUString label = SvxConfigPageHelper::replaceSaveInName( msg, saveInName );
ScopedVclPtrInstance< QueryBox > qbox( this, WB_YES_NO, label );
@@ -828,10 +829,10 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, NewToolbarHdl, Button *, void )
OUString prefix = CuiResId( RID_SVXSTR_NEW_TOOLBAR );
OUString aNewName =
- killmelater::generateCustomName( prefix, GetSaveInData()->GetEntries() );
+ SvxConfigPageHelper::generateCustomName( prefix, GetSaveInData()->GetEntries() );
OUString aNewURL =
- killmelater::generateCustomURL( GetSaveInData()->GetEntries() );
+ SvxConfigPageHelper::generateCustomURL( GetSaveInData()->GetEntries() );
VclPtrInstance< SvxNewToolbarDialog > pNameDialog( nullptr, aNewName );
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 89d6db93a34e..675e6370907a 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -59,6 +59,7 @@
#include "cfg.hxx"
#include "SvxMenuConfigPage.hxx"
#include "SvxToolbarConfigPage.hxx"
+#include "SvxConfigPageHelper.hxx"
#include "eventdlg.hxx"
#include <dialmgr.hxx>
@@ -217,7 +218,7 @@ SvxConfigDialog::SvxConfigDialog(vcl::Window * pParent, const SfxItemSet* pInSet
, m_nToolbarsPageId(0)
, m_nEventsPageId(0)
{
- killmelater::InitImageType();
+ SvxConfigPageHelper::InitImageType();
m_nMenusPageId = AddTabPage("menus", CreateSvxMenuConfigPage, nullptr);
m_nContextMenusPageId = AddTabPage("contextmenus", CreateSvxContextMenuConfigPage, nullptr);
@@ -243,7 +244,7 @@ void SvxConfigDialog::SetFrame(const css::uno::Reference< css::frame::XFrame >&
{
m_xFrame = xFrame;
- if (!killmelater::showKeyConfigTabPage( xFrame ))
+ if (!SvxConfigPageHelper::showKeyConfigTabPage( xFrame ))
RemoveTabPage(m_nKeyboardPageId);
}
@@ -330,7 +331,7 @@ Image SaveInData::GetImage( const OUString& rCommandURL )
Image aImage;
uno::Reference< graphic::XGraphic > xGraphic =
- killmelater::GetGraphic( m_xImgMgr, rCommandURL );
+ SvxConfigPageHelper::GetGraphic( m_xImgMgr, rCommandURL );
if ( xGraphic.is() )
{
@@ -338,7 +339,7 @@ Image SaveInData::GetImage( const OUString& rCommandURL )
}
else if ( xDefaultImgMgr != nullptr && (*xDefaultImgMgr).is() )
{
- xGraphic = killmelater::GetGraphic( (*xDefaultImgMgr), rCommandURL );
+ xGraphic = SvxConfigPageHelper::GetGraphic( (*xDefaultImgMgr), rCommandURL );
if ( xGraphic.is() )
{
@@ -470,7 +471,7 @@ bool SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >&
sal_uInt16 nType( css::ui::ItemType::DEFAULT );
- bool bItem = killmelater::GetMenuItemData( xMenuSettings, nIndex,
+ bool bItem = SvxConfigPageHelper::GetMenuItemData( xMenuSettings, nIndex,
aCommandURL, aLabel, nType, xSubMenu );
if ( bItem )
@@ -548,7 +549,7 @@ bool SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >&
pEntry->SetMain();
}
- subMenuTitle += killmelater::stripHotKey( aLabel );
+ subMenuTitle += SvxConfigPageHelper::stripHotKey( aLabel );
LoadSubMenus( xSubMenu, subMenuTitle, pEntry, bContextMenu );
}
@@ -629,7 +630,7 @@ void MenuSaveInData::Apply(
SvxConfigEntry* pEntryData = *iter;
uno::Sequence< beans::PropertyValue > aPropValueSeq =
- killmelater::ConvertSvxConfigEntry( pEntryData );
+ SvxConfigPageHelper::ConvertSvxConfigEntry( pEntryData );
uno::Reference< container::XIndexContainer > xSubMenuBar(
rFactory->createInstanceWithContext( xContext ),
@@ -662,7 +663,7 @@ void SaveInData::ApplyMenu(
if ( pEntry->IsPopup() )
{
uno::Sequence< beans::PropertyValue > aPropValueSeq =
- killmelater::ConvertSvxConfigEntry( pEntry );
+ SvxConfigPageHelper::ConvertSvxConfigEntry( pEntry );
uno::Reference< container::XIndexContainer > xSubMenuBar(
rFactory->createInstanceWithContext( xContext ),
@@ -687,7 +688,7 @@ void SaveInData::ApplyMenu(
else
{
uno::Sequence< beans::PropertyValue > aPropValueSeq =
- killmelater::ConvertSvxConfigEntry( pEntry );
+ SvxConfigPageHelper::ConvertSvxConfigEntry( pEntry );
rMenuBar->insertByIndex(
rMenuBar->getCount(), uno::Any( aPropValueSeq ));
}
@@ -857,7 +858,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true );
}
}
- std::sort( m_pRootEntry->GetEntries()->begin(), m_pRootEntry->GetEntries()->end(), killmelater::EntrySort );
+ std::sort( m_pRootEntry->GetEntries()->begin(), m_pRootEntry->GetEntries()->end(), SvxConfigPageHelper::EntrySort );
}
return m_pRootEntry->GetEntries();
}
@@ -891,7 +892,7 @@ bool ContextMenuSaveInData::Apply()
SvxEntries* pEntries = GetEntries();
for ( const auto& pEntry : *pEntries )
{
- if ( pEntry->IsModified() || killmelater::SvxConfigEntryModified( pEntry ) )
+ if ( pEntry->IsModified() || SvxConfigPageHelper::SvxConfigEntryModified( pEntry ) )
{
css::uno::Reference< css::container::XIndexContainer > xIndexContainer( GetConfigManager()->createSettings(), css::uno::UNO_QUERY );
css::uno::Reference< css::lang::XSingleComponentFactory > xFactory( xIndexContainer, css::uno::UNO_QUERY );
@@ -1235,7 +1236,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
// replace %MODULENAME in the label with the correct module name
uno::Reference< css::frame::XModuleManager2 > xModuleManager(
css::frame::ModuleManager::create( xContext ));
- OUString aModuleName = killmelater::GetUIModuleName( aModuleId, xModuleManager );
+ OUString aModuleName = SvxConfigPageHelper::GetUIModuleName( aModuleId, xModuleManager );
OUString title = m_pTopLevel->get_label();
OUString aSearchString("%MODULENAME" );
@@ -1524,13 +1525,13 @@ void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry* pToSelect )
for ( ; iter != end; ++iter )
{
SvxConfigEntry* pEntryData = *iter;
- const sal_Int32 nPos = m_pTopLevelListBox->InsertEntry( killmelater::stripHotKey( pEntryData->GetName() ) );
+ const sal_Int32 nPos = m_pTopLevelListBox->InsertEntry( SvxConfigPageHelper::stripHotKey( pEntryData->GetName() ) );
m_pTopLevelListBox->SetEntryData( nPos, pEntryData );
if ( pEntryData == pToSelect )
nSelectionPos = nPos;
- AddSubMenusToUI( killmelater::stripHotKey( pEntryData->GetName() ), pEntryData );
+ AddSubMenusToUI( SvxConfigPageHelper::stripHotKey( pEntryData->GetName() ), pEntryData );
}
}
#ifdef DBG_UTIL
@@ -1561,7 +1562,7 @@ void SvxConfigPage::AddSubMenusToUI(
if ( pEntryData->IsPopup() )
{
- OUString subMenuTitle = rBaseTitle + aMenuSeparatorStr + killmelater::stripHotKey( pEntryData->GetName() );
+ OUString subMenuTitle = rBaseTitle + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey( pEntryData->GetName() );
const sal_Int32 nPos = m_pTopLevelListBox->InsertEntry( subMenuTitle );
m_pTopLevelListBox->SetEntryData( nPos, pEntryData );
@@ -1724,7 +1725,7 @@ SvTreeListEntry* SvxConfigPage::InsertEntryIntoUI(
}
else
{
- OUString aName = killmelater::stripHotKey( pNewEntryData->GetName() );
+ OUString aName = SvxConfigPageHelper::stripHotKey( pNewEntryData->GetName() );
Image aImage = GetSaveInData()->GetImage(
pNewEntryData->GetCommand());
@@ -1819,7 +1820,7 @@ bool SvxConfigPage::MoveEntryData(
if ( pSourceData != nullptr && pTargetData != nullptr )
{
// remove the source entry from our list
- killmelater::RemoveEntry( pEntries, pSourceData );
+ SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
SvxEntries::iterator iter = pEntries->begin();
SvxEntries::const_iterator end = pEntries->end();
@@ -1839,8 +1840,6 @@ bool SvxConfigPage::MoveEntryData(
return false;
}
-// SvxMenuConfigPage was here
-
SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
vcl::Window* pParent, SvxEntries* entries,
SvxConfigEntry* selection, bool bCreateMenu )
@@ -1865,7 +1864,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
{
SvxConfigEntry* pEntry = *iter;
SvTreeListEntry* pLBEntry =
- m_pMenuListBox->InsertEntry( killmelater::stripHotKey( pEntry->GetName() ) );
+ m_pMenuListBox->InsertEntry( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
pLBEntry->SetUserData( pEntry );
mpEntries->push_back( pEntry );
@@ -1882,8 +1881,8 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
// Generate custom name for new menu
OUString prefix = CuiResId( RID_SVXSTR_NEW_MENU );
- OUString newname = killmelater::generateCustomName( prefix, entries );
- OUString newurl = killmelater::generateCustomMenuURL( mpEntries );
+ OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries );
+ OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries );
SvxConfigEntry* pNewEntryData =
new SvxConfigEntry( newname, newurl, true );
@@ -1892,7 +1891,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
pNewEntryData->SetMain();
pNewMenuEntry =
- m_pMenuListBox->InsertEntry( killmelater::stripHotKey( pNewEntryData->GetName() ) );
+ m_pMenuListBox->InsertEntry( SvxConfigPageHelper::stripHotKey( pNewEntryData->GetName() ) );
m_pMenuListBox->Select( pNewMenuEntry );
pNewMenuEntry->SetUserData( pNewEntryData );
@@ -2471,7 +2470,7 @@ SvxEntries* ToolbarSaveInData::GetEntries()
}
}
- std::sort( GetEntries()->begin(), GetEntries()->end(), killmelater::EntrySort );
+ std::sort( GetEntries()->begin(), GetEntries()->end(), SvxConfigPageHelper::EntrySort );
}
return pRootEntry->GetEntries();
@@ -2577,7 +2576,7 @@ void ToolbarSaveInData::ApplyToolbar(
if ( pEntry->IsPopup() )
{
uno::Sequence< beans::PropertyValue > aPropValueSeq =
- killmelater::ConvertToolbarEntry( pEntry );
+ SvxConfigPageHelper::ConvertToolbarEntry( pEntry );
uno::Reference< container::XIndexContainer > xSubMenuBar(
rFactory->createInstanceWithContext( xContext ),
@@ -2600,7 +2599,7 @@ void ToolbarSaveInData::ApplyToolbar(
else
{
uno::Sequence< beans::PropertyValue > aPropValueSeq =
- killmelater::ConvertToolbarEntry( pEntry );
+ SvxConfigPageHelper::ConvertToolbarEntry( pEntry );
rToolbarBar->insertByIndex(
rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
@@ -2708,7 +2707,7 @@ void ToolbarSaveInData::RemoveToolbar( SvxConfigEntry* pToolbar )
{
OUString url = pToolbar->GetCommand();
GetConfigManager()->removeSettings( url );
- killmelater::RemoveEntry( GetEntries(), pToolbar );
+ SvxConfigPageHelper::RemoveEntry( GetEntries(), pToolbar );
delete pToolbar;
PersistChanges( GetConfigManager() );
@@ -2774,7 +2773,7 @@ void ToolbarSaveInData::RestoreToolbar( SvxConfigEntry* pToolbar )
try
{
- GetImageManager()->removeImages( killmelater::GetImageType(), aURLSeq );
+ GetImageManager()->removeImages( SvxConfigPageHelper::GetImageType(), aURLSeq );
}
catch ( uno::Exception& )
{
@@ -2805,7 +2804,7 @@ void ToolbarSaveInData::LoadToolbar(
sal_uInt16 nType( css::ui::ItemType::DEFAULT );
- bool bItem = killmelater::GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL,
+ bool bItem = SvxConfigPageHelper::GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL,
aLabel, nType, bIsVisible, nStyle );
if ( bItem )
@@ -2921,14 +2920,14 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( vcl::Window *pWindow,
pTbSymbol->SetPageScroll( true );
m_nExpectedSize = 16;
- if (killmelater::GetImageType() & css::ui::ImageType::SIZE_LARGE)
+ if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_LARGE)
m_nExpectedSize = 26;
- else if (killmelater::GetImageType() & css::ui::ImageType::SIZE_32)
+ else if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_32)
m_nExpectedSize = 32;
if ( m_nExpectedSize != 16 )
{
- pFtNote->SetText( killmelater::replaceSixteen( pFtNote->GetText(), m_nExpectedSize ) );
+ pFtNote->SetText( SvxConfigPageHelper::replaceSixteen( pFtNote->GetText(), m_nExpectedSize ) );
}
uno::Reference< uno::XComponentContext > xComponentContext =
@@ -2987,7 +2986,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( vcl::Window *pWindow,
uno::Sequence< OUString > names;
if ( m_xImportedImageManager.is() )
{
- names = m_xImportedImageManager->getAllImageNames( killmelater::GetImageType() );
+ names = m_xImportedImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
for ( sal_Int32 n = 0; n < names.getLength(); ++n )
aImageInfo1.insert( ImageInfo::value_type( names[n], false ));
}
@@ -2997,7 +2996,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( vcl::Window *pWindow,
while ( pConstIter != aImageInfo1.end() )
{
name[ 0 ] = pConstIter->first;
- uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( killmelater::GetImageType(), name );
+ uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
if ( graphics.getLength() > 0 )
{
Image img = Image( graphics[ 0 ] );
@@ -3017,12 +3016,12 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( vcl::Window *pWindow,
if ( m_xParentImageManager.is() )
{
- names = m_xParentImageManager->getAllImageNames( killmelater::GetImageType() );
+ names = m_xParentImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
for ( sal_Int32 n = 0; n < names.getLength(); ++n )
aImageInfo.insert( ImageInfo::value_type( names[n], false ));
}
- names = m_xImageManager->getAllImageNames( killmelater::GetImageType() );
+ names = m_xImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
for ( sal_Int32 n = 0; n < names.getLength(); ++n )
{
ImageInfo::iterator pIter = aImageInfo.find( names[n] );
@@ -3042,9 +3041,9 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( vcl::Window *pWindow,
try
{
if ( pConstIter->second )
- graphics = m_xImageManager->getImages( killmelater::GetImageType(), name );
+ graphics = m_xImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
else
- graphics = m_xParentImageManager->getImages( killmelater::GetImageType(), name );
+ graphics = m_xParentImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
}
catch ( uno::Exception& )
{
@@ -3148,7 +3147,7 @@ IMPL_LINK_NOARG( SvxIconSelectorDialog, SelectHdl, ToolBox *, void )
pTbSymbol->CheckItem( nId );
OUString aSelImageText = pTbSymbol->GetItemText( nId );
- if ( m_xImportedImageManager->hasImage( killmelater::GetImageType(), aSelImageText ) )
+ if ( m_xImportedImageManager->hasImage( SvxConfigPageHelper::GetImageType(), aSelImageText ) )
{
pBtnDelete->Enable();
}
@@ -3200,7 +3199,7 @@ IMPL_LINK_NOARG( SvxIconSelectorDialog, DeleteHdl, Button *, void )
OUString aSelImageText = pTbSymbol->GetItemText( nId );
uno::Sequence< OUString > URLs { aSelImageText };
pTbSymbol->RemoveItem( pTbSymbol->GetItemPos( nId ) );
- m_xImportedImageManager->removeImages( killmelater::GetImageType(), URLs );
+ m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs );
uno::Reference< css::ui::XUIConfigurationPersistence >
xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY );
if ( xConfigPersistence.is() && xConfigPersistence->isModified() )
@@ -3273,7 +3272,7 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
URLs[0] = aURL;
aImportGraph[ 0 ] = xGraphic;
- m_xImportedImageManager->replaceImages( killmelater::GetImageType(), URLs, aImportGraph );
+ m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), URLs, aImportGraph );
xConfigPer->store();
bResult = true;
@@ -3303,7 +3302,7 @@ void SvxIconSelectorDialog::ImportGraphics(
if ( rPaths.getLength() == 1 )
{
- if ( m_xImportedImageManager->hasImage( killmelater::GetImageType(), rPaths[0] ) )
+ if ( m_xImportedImageManager->hasImage( SvxConfigPageHelper::GetImageType(), rPaths[0] ) )
{
aIndex = rPaths[0].lastIndexOf( '/' );
aIconName = rPaths[0].copy( aIndex+1 );
@@ -3331,7 +3330,7 @@ void SvxIconSelectorDialog::ImportGraphics(
for ( sal_Int32 i = 1; i < rPaths.getLength(); ++i )
{
OUString aPath = aSourcePath + rPaths[i];
- if ( m_xImportedImageManager->hasImage( killmelater::GetImageType(), aPath ) )
+ if ( m_xImportedImageManager->hasImage( SvxConfigPageHelper::GetImageType(), aPath ) )
{
aIndex = rPaths[i].lastIndexOf( '/' );
aIconName = rPaths[i].copy( aIndex+1 );
@@ -3437,7 +3436,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
uno::Sequence<OUString> aImportURL { aURL };
uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
aImportGraph[ 0 ] = xGraphic;
- m_xImportedImageManager->insertImages( killmelater::GetImageType(), aImportURL, aImportGraph );
+ m_xImportedImageManager->insertImages( SvxConfigPageHelper::GetImageType(), aImportURL, aImportGraph );
uno::Reference< css::ui::XUIConfigurationPersistence >
xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY );
diff --git a/cui/source/inc/SvxConfigPageHelper.hxx b/cui/source/inc/SvxConfigPageHelper.hxx
new file mode 100644
index 000000000000..4b83b1c7dfd6
--- /dev/null
+++ b/cui/source/inc/SvxConfigPageHelper.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CUI_SOURCE_INC_SVXCONFIGPAGEHELPER_HXX
+#define INCLUDED_CUI_SOURCE_INC_SVXCONFIGPAGEHELPER_HXX
+
+#include <vector>
+
+#include "cfg.hxx"
+
+class SvxConfigPageHelper
+{
+public:
+ static void RemoveEntry( SvxEntries* pEntries, SvxConfigEntry* pChildEntry );
+
+ static OUString replaceSaveInName( const OUString& rMessage, const OUString& rSaveInName );
+ static OUString stripHotKey( const OUString& str );
+ static OUString replaceSixteen( const OUString& str, sal_Int32 nReplacement );
+
+ static sal_Int16 GetImageType();
+ static void InitImageType();
+ static css::uno::Reference< css::graphic::XGraphic > GetGraphic(
+ const css::uno::Reference< css::ui::XImageManager >& xImageManager,
+ const OUString& rCommandURL );
+
+ static OUString generateCustomName(
+ const OUString& prefix,
+ SvxEntries* entries,
+ sal_Int32 suffix = 1 );
+ static OUString generateCustomMenuURL(
+ SvxEntries* entries,
+ sal_Int32 suffix = 1 );
+ static sal_uInt32 generateRandomValue();
+ static OUString generateCustomURL( SvxEntries* entries );
+
+ static OUString GetModuleName( const OUString& aModuleId );
+ 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,
+ css::uno::Reference< css::container::XIndexAccess >& rSubMenu );
+ 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 css::uno::Sequence< css::beans::PropertyValue > ConvertSvxConfigEntry(
+ const SvxConfigEntry* pEntry );
+ static css::uno::Sequence< css::beans::PropertyValue > ConvertToolbarEntry(
+ const SvxConfigEntry* pEntry );
+
+ static bool showKeyConfigTabPage(
+ const css::uno::Reference< css::frame::XFrame >& xFrame );
+
+ static bool EntrySort( SvxConfigEntry* a, SvxConfigEntry* b );
+
+ static bool SvxConfigEntryModified( SvxConfigEntry* pEntry );
+
+};
+
+#endif // INCLUDED_CUI_SOURCE_INC_SVXCONFIGPAGEHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 44e738f8a419..6b8950ee5146 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -676,508 +676,6 @@ public:
virtual void dispose() override;
};
-namespace killmelater
-{
-//TODO:This is copy/pasted from cfg.cxx
-inline void RemoveEntry( SvxEntries* pEntries, SvxConfigEntry* pChildEntry )
-{
- SvxEntries::iterator iter = pEntries->begin();
-
- while ( iter != pEntries->end() )
- {
- if ( pChildEntry == *iter )
- {
- pEntries->erase( iter );
- break;
- }
- ++iter;
- }
-}
-
-//TODO:This is copy/pasted from cfg.cxx
-inline OUString replaceSaveInName(
- const OUString& rMessage,
- const OUString& rSaveInName )
-{
- OUString name;
- OUString placeholder("%SAVE IN SELECTION%" );
-
- sal_Int32 pos = rMessage.indexOf( placeholder );
-
- if ( pos != -1 )
- {
- name = rMessage.replaceAt(
- pos, placeholder.getLength(), rSaveInName );
- }
-
- return name;
-}
-
-//TODO:This is copy/pasted from cfg.cxx
-inline OUString
-stripHotKey( const OUString& str )
-{
- sal_Int32 index = str.indexOf( '~' );
- if ( index == -1 )
- {
- return str;
- }
- else
- {
- return str.replaceAt( index, 1, OUString() );
- }
-}
-
-inline OUString
-replaceSixteen( const OUString& str, sal_Int32 nReplacement )
-{
- OUString result( str );
- OUString sixteen = OUString::number( 16 );
- OUString expected = OUString::number( nReplacement );
-
- sal_Int32 len = sixteen.getLength();
- sal_Int32 index = result.indexOf( sixteen );
-
- while ( index != -1 )
- {
- result = result.replaceAt( index, len, expected );
- index = result.indexOf( sixteen, index );
- }
-
- return result;
-}
-
-static sal_Int16 theImageType =
- css::ui::ImageType::COLOR_NORMAL |
- css::ui::ImageType::SIZE_DEFAULT;
-
-//TODO:This is copy/pasted from cfg.cxx
-inline sal_Int16 GetImageType()
-{
- return theImageType;
-}
-
-inline void InitImageType()
-{
- theImageType =
- css::ui::ImageType::COLOR_NORMAL |
- css::ui::ImageType::SIZE_DEFAULT;
-
- if (SvtMiscOptions().GetSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE)
- {
- theImageType |= css::ui::ImageType::SIZE_LARGE;
- }
- else if (SvtMiscOptions().GetSymbolsSize() == SFX_SYMBOLS_SIZE_32)
- {
- theImageType |= css::ui::ImageType::SIZE_32;
- }
-}
-
-//TODO:This is copy/pasted from cfg.cxx
-inline css::uno::Reference< css::graphic::XGraphic > GetGraphic(
- const css::uno::Reference< css::ui::XImageManager >& xImageManager,
- const OUString& rCommandURL )
-{
- css::uno::Reference< css::graphic::XGraphic > result;
-
- if ( xImageManager.is() )
- {
- // TODO handle large graphics
- css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > aGraphicSeq;
-
- css::uno::Sequence<OUString> aImageCmdSeq { rCommandURL };
-
- try
- {
- aGraphicSeq =
- xImageManager->getImages( killmelater::GetImageType(), aImageCmdSeq );
-
- if ( aGraphicSeq.getLength() > 0 )
- {
- result = aGraphicSeq[0];
- }
- }
- catch ( css::uno::Exception& )
- {
- // will return empty XGraphic
- }
- }
-
- return result;
-}
-
-//TODO:This is copy/pasted from cfg.cxx
-inline OUString
-generateCustomName(
- const OUString& prefix,
- SvxEntries* entries,
- sal_Int32 suffix = 1 )
-{
- // find and replace the %n placeholder in the prefix string
- OUString name;
- OUString placeholder("%n" );
-
- sal_Int32 pos = prefix.indexOf( placeholder );
-
- if ( pos != -1 )
- {
- name = prefix.replaceAt(
- pos, placeholder.getLength(), OUString::number( suffix ) );
- }
- else
- {
- // no placeholder found so just append the suffix
- name = prefix + OUString::number( suffix );
- }
-
- if (!entries)
- return name;
-
- // now check is there is an already existing entry with this name
- SvxEntries::const_iterator iter = entries->begin();
-
- while ( iter != entries->end() )
- {
- SvxConfigEntry* pEntry = *iter;
-
- if ( name.equals( pEntry->GetName() ) )
- {
- break;
- }
- ++iter;
- }
-
- if ( iter != entries->end() )
- {
- // name already exists so try the next number up
- return generateCustomName( prefix, entries, ++suffix );
- }
-
- return name;
-}
-
-inline OUString
-generateCustomMenuURL(
- SvxEntries* entries,
- sal_Int32 suffix = 1 )
-{
- OUString url = "vnd.openoffice.org:CustomMenu" + OUString::number( suffix );
- if (!entries)
- return url;
-
- // now check is there is an already existing entry with this url
- SvxEntries::const_iterator iter = entries->begin();
-
- while ( iter != entries->end() )
- {
- SvxConfigEntry* pEntry = *iter;
-
- if ( url.equals( pEntry->GetCommand() ) )
- {
- break;
- }
- ++iter;
- }
-
- if ( iter != entries->end() )
- {
- // url already exists so try the next number up
- return generateCustomMenuURL( entries, ++suffix );
- }
-
- return url;
-}
-
-inline sal_uInt32 generateRandomValue()
-{
- return comphelper::rng::uniform_uint_distribution(0, std::numeric_limits<unsigned int>::max());
-}
-
-inline OUString
-generateCustomURL(
- SvxEntries* entries )
-{
- OUString url = ITEM_TOOLBAR_URL;
- url += CUSTOM_TOOLBAR_STR;
-
- // use a random number to minimize possible clash with existing custom toolbars
- url += OUString::number( generateRandomValue(), 16 );
-
- // now check is there is an already existing entry with this url
- SvxEntries::const_iterator iter = entries->begin();
-
- while ( iter != entries->end() )
- {
- SvxConfigEntry* pEntry = *iter;
-
- if ( url.equals( pEntry->GetCommand() ) )
- {
- break;
- }
- ++iter;
- }
-
- if ( iter != entries->end() )
- {
- // url already exists so try the next number up
- return generateCustomURL( entries );
- }
-
- return url;
-}
-
-inline OUString GetModuleName( const OUString& aModuleId )
-{
- if ( aModuleId == "com.sun.star.text.TextDocument" ||
- aModuleId == "com.sun.star.text.GlobalDocument" )
- return OUString("Writer");
- else if ( aModuleId == "com.sun.star.text.WebDocument" )
- return OUString("Writer/Web");
- else if ( aModuleId == "com.sun.star.drawing.DrawingDocument" )
- return OUString("Draw");
- else if ( aModuleId == "com.sun.star.presentation.PresentationDocument" )
- return OUString("Impress");
- else if ( aModuleId == "com.sun.star.sheet.SpreadsheetDocument" )
- return OUString("Calc");
- else if ( aModuleId == "com.sun.star.script.BasicIDE" )
- return OUString("Basic");
- else if ( aModuleId == "com.sun.star.formula.FormulaProperties" )
- return OUString("Math");
- else if ( aModuleId == "com.sun.star.sdb.RelationDesign" )
- return OUString("Relation Design");
- else if ( aModuleId == "com.sun.star.sdb.QueryDesign" )
- return OUString("Query Design");
- else if ( aModuleId == "com.sun.star.sdb.TableDesign" )
- return OUString("Table Design");
- else if ( aModuleId == "com.sun.star.sdb.DataSourceBrowser" )
- return OUString("Data Source Browser" );
- else if ( aModuleId == "com.sun.star.sdb.DatabaseDocument" )
- return OUString("Database" );
-
- return OUString();
-}
-
-inline OUString GetUIModuleName( const OUString& aModuleId, const css::uno::Reference< css::frame::XModuleManager2 >& rModuleManager )
-{
- assert(rModuleManager.is());
-
- OUString aModuleUIName;
-
- try
- {
- css::uno::Any a = rModuleManager->getByName( aModuleId );
- css::uno::Sequence< css::beans::PropertyValue > aSeq;
-
- if ( a >>= aSeq )
- {
- for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
- {
- if ( aSeq[i].Name == "ooSetupFactoryUIName" )
- {
- aSeq[i].Value >>= aModuleUIName;
- break;
- }
- }
- }
- }
- catch ( css::uno::RuntimeException& )
- {
- throw;
- }
- catch ( css::uno::Exception& )
- {
- }
-
- if ( aModuleUIName.isEmpty() )
- aModuleUIName = GetModuleName( aModuleId );
-
- return aModuleUIName;
-}
-
-inline bool GetMenuItemData(
- const css::uno::Reference< css::container::XIndexAccess >& rItemContainer,
- sal_Int32 nIndex,
- OUString& rCommandURL,
- OUString& rLabel,
- sal_uInt16& rType,
- css::uno::Reference< css::container::XIndexAccess >& rSubMenu )
-{
- try
- {
- css::uno::Sequence< css::beans::PropertyValue > aProp;
- if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
- {
- for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
- {
- if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
- {
- aProp[i].Value >>= rCommandURL;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_CONTAINER )
- {
- aProp[i].Value >>= rSubMenu;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
- {
- aProp[i].Value >>= rLabel;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
- {
- aProp[i].Value >>= rType;
- }
- }
-
- return true;
- }
- }
- catch ( css::lang::IndexOutOfBoundsException& )
- {
- }
-
- return false;
-}
-
-inline 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 )
-{
- try
- {
- css::uno::Sequence< css::beans::PropertyValue > aProp;
- if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
- {
- for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
- {
- if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
- {
- aProp[i].Value >>= rCommandURL;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_STYLE )
- {
- aProp[i].Value >>= rStyle;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
- {
- aProp[i].Value >>= rLabel;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
- {
- aProp[i].Value >>= rType;
- }
- else if ( aProp[i].Name == ITEM_DESCRIPTOR_ISVISIBLE )
- {
- aProp[i].Value >>= rIsVisible;
- }
- }
-
- return true;
- }
- }
- catch ( css::lang::IndexOutOfBoundsException& )
- {
- }
-
- return false;
-}
-
-inline css::uno::Sequence< css::beans::PropertyValue >
-ConvertSvxConfigEntry( const SvxConfigEntry* pEntry )
-{
- css::uno::Sequence< css::beans::PropertyValue > aPropSeq( 3 );
-
- aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
- aPropSeq[0].Value <<= pEntry->GetCommand();
-
- aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE;
- aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
-
- // If the name has not been changed, then the label can be stored
- // as an empty string.
- // It will be initialised again later using the command to label map.
- aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL;
- if ( !pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty() )
- {
- aPropSeq[2].Value <<= OUString();
- }
- else
- {
- aPropSeq[2].Value <<= pEntry->GetName();
- }
-
- return aPropSeq;
-}
-
-inline css::uno::Sequence< css::beans::PropertyValue >
-ConvertToolbarEntry( const SvxConfigEntry* pEntry )
-{
- css::uno::Sequence< css::beans::PropertyValue > aPropSeq( 4 );
-
- aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
- aPropSeq[0].Value <<= pEntry->GetCommand();
-
- aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE;
- aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
-
- // If the name has not been changed, then the label can be stored
- // as an empty string.
- // It will be initialised again later using the command to label map.
- aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL;
- if ( !pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty() )
- {
- aPropSeq[2].Value <<= OUString();
- }
- else
- {
- aPropSeq[2].Value <<= pEntry->GetName();
- }
-
- aPropSeq[3].Name = ITEM_DESCRIPTOR_ISVISIBLE;
- aPropSeq[3].Value <<= pEntry->IsVisible();
-
- return aPropSeq;
-}
-
-//Was in anonymous namespace in cfg.cxx
-inline bool showKeyConfigTabPage( const css::uno::Reference< css::frame::XFrame >& xFrame )
-{
- if (!xFrame.is())
- {
- return false;
- }
- OUString sModuleId(
- css::frame::ModuleManager::create(
- comphelper::getProcessComponentContext())
- ->identify(xFrame));
- return !sModuleId.isEmpty()
- && sModuleId != "com.sun.star.frame.StartModule";
-}
-
-inline bool EntrySort( SvxConfigEntry* a, SvxConfigEntry* b )
-{
- return a->GetName().compareTo( b->GetName() ) < 0;
-}
-
-inline bool SvxConfigEntryModified( SvxConfigEntry* pEntry )
-{
- SvxEntries* pEntries = pEntry->GetEntries();
- if ( !pEntries )
- return false;
-
- for ( const auto& entry : *pEntries )
- {
- if ( entry->IsModified() || SvxConfigEntryModified( entry ) )
- return true;
- }
- return false;
-}
-
-}
-
#endif // INCLUDED_CUI_SOURCE_INC_CFG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list