Kaydet (Commit) 8e71acc7 authored tarafından Muhammet Kara's avatar Muhammet Kara

Separate SvxToolbarConfigPage from cfg.cxx

Change-Id: I4aa504b92e9507635152c623a07d0538079860de
Reviewed-on: https://gerrit.libreoffice.org/39389Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Reviewed-on: https://gerrit.libreoffice.org/40297Reviewed-by: 's avatarMuhammet Kara <muhammet.kara@pardus.org.tr>
üst 62f41516
......@@ -89,6 +89,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/customize/eventdlg \
cui/source/customize/macropg \
cui/source/customize/SvxMenuConfigPage \
cui/source/customize/SvxToolbarConfigPage \
cui/source/dialogs/about \
cui/source/dialogs/colorpicker \
cui/source/dialogs/cuicharmap \
......
This diff is collapsed.
This diff is collapsed.
......@@ -19,8 +19,6 @@
#ifndef INCLUDED_CUI_SOURCE_INC_SVXMENUCONFIGPAGE_HXX
#define INCLUDED_CUI_SOURCE_INC_SVXMENUCONFIGPAGE_HXX
#endif // INCLUDED_CUI_SOURCE_INC_SVXMENUCONFIGPAGE_HXX
#include <vcl/fixed.hxx>
#include <vcl/group.hxx>
#include <vcl/layout.hxx>
......@@ -84,4 +82,6 @@ public:
bool docConfig ) override;
};
#endif // INCLUDED_CUI_SOURCE_INC_SVXMENUCONFIGPAGE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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_SVXTOOLBARCONFIGPAGE_HXX
#define INCLUDED_CUI_SOURCE_INC_SVXTOOLBARCONFIGPAGE_HXX
#include <vcl/fixed.hxx>
#include <vcl/group.hxx>
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/toolbox.hxx>
#include <svtools/treelistbox.hxx>
#include <svtools/svmedit2.hxx>
#include <svtools/svmedit.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/ui/XUIConfigurationListener.hpp>
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
#include <com/sun/star/ui/XImageManager.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <sfx2/tabdlg.hxx>
#include <memory>
#include <vector>
#include <vcl/msgbox.hxx>
//#include "cfgutil.hxx"
#include "cfg.hxx" //for SvxConfigPage and SaveInData
class SvxToolbarConfigPage : public SvxConfigPage
{
private:
DECL_LINK( SelectToolbar, ListBox&, void );
DECL_LINK( SelectToolbarEntry, SvTreeListBox*, void );
DECL_LINK( ToolbarSelectHdl, MenuButton *, void );
DECL_LINK( EntrySelectHdl, MenuButton *, void );
DECL_LINK( StyleChangeHdl, Button *, void );
DECL_LINK( NewToolbarHdl, Button *, void );
DECL_LINK( AddCommandsHdl, Button *, void );
DECL_LINK( AddSeparatorHdl, Button *, void );
DECL_LINK( DeleteCommandHdl, Button *, void );
DECL_LINK( ResetTopLevelHdl, Button *, void );
DECL_LINK( AddFunctionHdl, SvxScriptSelectorDialog&, void );
DECL_LINK( MoveHdl, Button *, void );
void UpdateButtonStates() override;
short QueryReset() override;
void Init() override;
void DeleteSelectedContent() override;
void DeleteSelectedTopLevel() override;
VclPtr<PopupMenu> m_pMenu;
VclPtr<PopupMenu> m_pEntry;
public:
SvxToolbarConfigPage( vcl::Window *pParent, const SfxItemSet& rItemSet );
virtual ~SvxToolbarConfigPage() override;
virtual void dispose() override;
void AddFunction( SvTreeListEntry* pTarget = nullptr,
bool bFront = false );
void MoveEntry( bool bMoveUp ) override;
SaveInData* CreateSaveInData(
const css::uno::Reference <
css::ui::XUIConfigurationManager >&,
const css::uno::Reference <
css::ui::XUIConfigurationManager >&,
const OUString& aModuleId,
bool docConfig ) override;
};
class SvxToolbarEntriesListBox : public SvxMenuEntriesListBox
{
Size m_aCheckBoxImageSizePixel;
SvLBoxButtonData* m_pButtonData;
VclPtr<SvxConfigPage> pPage;
void ChangeVisibility( SvTreeListEntry* pEntry );
protected:
virtual void CheckButtonHdl() override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
void BuildCheckBoxButtonImages( SvLBoxButtonData* );
Image GetSizedImage(
VirtualDevice& aDev, const Size& aNewSize, const Image& aImage );
public:
SvxToolbarEntriesListBox(vcl::Window* pParent, SvxToolbarConfigPage* pPg);
virtual ~SvxToolbarEntriesListBox() override;
virtual void dispose() override;
virtual TriState NotifyMoving(
SvTreeListEntry*, SvTreeListEntry*, SvTreeListEntry*&, sal_uLong& ) override;
virtual TriState NotifyCopying(
SvTreeListEntry*, SvTreeListEntry*, SvTreeListEntry*&, sal_uLong&) override;
void KeyInput( const KeyEvent& rKeyEvent ) override;
};
#endif // INCLUDED_CUI_SOURCE_INC_SVXTOOLBARCONFIGPAGE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -25,15 +25,22 @@
#include <vcl/lstbox.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/toolbox.hxx>
#include <svtools/imgdef.hxx>
#include <svtools/miscopt.hxx>
#include <svtools/treelistbox.hxx>
#include <svtools/svmedit2.hxx>
#include <svtools/svmedit.hxx>
#include <comphelper/documentinfo.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/random.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/ui/XUIConfigurationListener.hpp>
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
#include <com/sun/star/ui/XImageManager.hpp>
#include <com/sun/star/ui/ImageType.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
......@@ -46,9 +53,15 @@
#include "cfgutil.hxx"
static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
static const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_";
static const char aMenuSeparatorStr[] = " | ";
class SvxConfigEntry;
class SvxConfigPage;
class SvxToolbarConfigPage;
typedef std::vector< SvxConfigEntry* > SvxEntries;
......@@ -501,81 +514,9 @@ public:
SvxConfigEntry* GetSelectedEntry();
};
class SvxToolbarEntriesListBox : public SvxMenuEntriesListBox
{
Size m_aCheckBoxImageSizePixel;
SvLBoxButtonData* m_pButtonData;
VclPtr<SvxConfigPage> pPage;
void ChangeVisibility( SvTreeListEntry* pEntry );
protected:
virtual void CheckButtonHdl() override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
void BuildCheckBoxButtonImages( SvLBoxButtonData* );
Image GetSizedImage(
VirtualDevice& aDev, const Size& aNewSize, const Image& aImage );
public:
SvxToolbarEntriesListBox(vcl::Window* pParent, SvxToolbarConfigPage* pPg);
virtual ~SvxToolbarEntriesListBox() override;
virtual void dispose() override;
virtual TriState NotifyMoving(
SvTreeListEntry*, SvTreeListEntry*, SvTreeListEntry*&, sal_uLong& ) override;
virtual TriState NotifyCopying(
SvTreeListEntry*, SvTreeListEntry*, SvTreeListEntry*&, sal_uLong&) override;
void KeyInput( const KeyEvent& rKeyEvent ) override;
};
class SvxToolbarConfigPage : public SvxConfigPage
{
private:
DECL_LINK( SelectToolbar, ListBox&, void );
DECL_LINK( SelectToolbarEntry, SvTreeListBox*, void );
DECL_LINK( ToolbarSelectHdl, MenuButton *, void );
DECL_LINK( EntrySelectHdl, MenuButton *, void );
DECL_LINK( StyleChangeHdl, Button *, void );
DECL_LINK( NewToolbarHdl, Button *, void );
DECL_LINK( AddCommandsHdl, Button *, void );
DECL_LINK( AddSeparatorHdl, Button *, void );
DECL_LINK( DeleteCommandHdl, Button *, void );
DECL_LINK( ResetTopLevelHdl, Button *, void );
DECL_LINK( AddFunctionHdl, SvxScriptSelectorDialog&, void );
DECL_LINK( MoveHdl, Button *, void );
void UpdateButtonStates() override;
short QueryReset() override;
void Init() override;
void DeleteSelectedContent() override;
void DeleteSelectedTopLevel() override;
VclPtr<PopupMenu> m_pMenu;
VclPtr<PopupMenu> m_pEntry;
public:
SvxToolbarConfigPage( vcl::Window *pParent, const SfxItemSet& rItemSet );
virtual ~SvxToolbarConfigPage() override;
virtual void dispose() override;
void AddFunction( SvTreeListEntry* pTarget = nullptr,
bool bFront = false );
//SvxToolbarEntriesListBox class was here
void MoveEntry( bool bMoveUp ) override;
SaveInData* CreateSaveInData(
const css::uno::Reference <
css::ui::XUIConfigurationManager >&,
const css::uno::Reference <
css::ui::XUIConfigurationManager >&,
const OUString& aModuleId,
bool docConfig ) override;
};
//SvxToolbarConfigPage class was here
class ToolbarSaveInData : public SaveInData
{
......@@ -775,6 +716,154 @@ stripHotKey( const OUString& str )
return str.replaceAt( index, 1, OUString() );
}
}
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 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;
}
}
#endif // INCLUDED_CUI_SOURCE_INC_CFG_HXX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment