Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
c65e00d9
Kaydet (Commit)
c65e00d9
authored
Kas 07, 2015
tarafından
Maxim Monastirsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
tdf#93837 Make customization actually work
Change-Id: I004c9ad3a7d389228b9bb532a1b2c5d6294f7e42
üst
899453aa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
240 additions
and
20 deletions
+240
-20
cfg.cxx
cui/source/customize/cfg.cxx
+204
-11
cfg.hxx
cui/source/inc/cfg.hxx
+36
-9
No files found.
cui/source/customize/cfg.cxx
Dosyayı görüntüle @
c65e00d9
...
@@ -775,6 +775,25 @@ bool showKeyConfigTabPage( const css::uno::Reference< css::frame::XFrame >& xFra
...
@@ -775,6 +775,25 @@ bool showKeyConfigTabPage( const css::uno::Reference< css::frame::XFrame >& xFra
&& sModuleId != "com.sun.star.frame.StartModule";
&& sModuleId != "com.sun.star.frame.StartModule";
}
}
bool EntrySort( SvxConfigEntry* a, SvxConfigEntry* b )
{
return a->GetName().compareTo( b->GetName() ) < 0;
}
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;
}
}
}
/******************************************************************************
/******************************************************************************
...
@@ -1071,7 +1090,7 @@ MenuSaveInData::SetEntries( SvxEntries* pNewEntries )
...
@@ -1071,7 +1090,7 @@ MenuSaveInData::SetEntries( SvxEntries* pNewEntries )
pRootEntry->SetEntries( pNewEntries );
pRootEntry->SetEntries( pNewEntries );
}
}
bool
Menu
SaveInData
::
LoadSubMenus
(
bool SaveInData::LoadSubMenus(
const uno::Reference< container::XIndexAccess >& xMenuSettings,
const uno::Reference< container::XIndexAccess >& xMenuSettings,
const OUString& rBaseTitle,
const OUString& rBaseTitle,
SvxConfigEntry* pParentData )
SvxConfigEntry* pParentData )
...
@@ -1111,7 +1130,7 @@ bool MenuSaveInData::LoadSubMenus(
...
@@ -1111,7 +1130,7 @@ bool MenuSaveInData::LoadSubMenus(
// If custom label not set retrieve it from the command
// If custom label not set retrieve it from the command
// to info service
// to info service
if
(
aLabel
.
equals
(
OUString
()
)
)
if ( aLabel.
isEmpty(
) )
{
{
uno::Sequence< beans::PropertyValue > aPropSeq;
uno::Sequence< beans::PropertyValue > aPropSeq;
if ( a >>= aPropSeq )
if ( a >>= aPropSeq )
...
@@ -1257,7 +1276,7 @@ void MenuSaveInData::Apply(
...
@@ -1257,7 +1276,7 @@ void MenuSaveInData::Apply(
}
}
}
}
void
Menu
SaveInData
::
ApplyMenu
(
void SaveInData::ApplyMenu(
uno::Reference< container::XIndexContainer >& rMenuBar,
uno::Reference< container::XIndexContainer >& rMenuBar,
uno::Reference< lang::XSingleComponentFactory >& rFactory,
uno::Reference< lang::XSingleComponentFactory >& rFactory,
SvxConfigEntry* pMenuData )
SvxConfigEntry* pMenuData )
...
@@ -1282,13 +1301,14 @@ void MenuSaveInData::ApplyMenu(
...
@@ -1282,13 +1301,14 @@ void MenuSaveInData::ApplyMenu(
sal_Int32 nIndex = aPropValueSeq.getLength();
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
aPropValueSeq.realloc( nIndex + 1 );
aPropValueSeq
[
nIndex
].
Name
=
m_aDescriptorContainer
;
aPropValueSeq[nIndex].Name =
ITEM_DESCRIPTOR_CONTAINER
;
aPropValueSeq[nIndex].Value <<= xSubMenuBar;
aPropValueSeq[nIndex].Value <<= xSubMenuBar;
rMenuBar->insertByIndex(
rMenuBar->insertByIndex(
rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
ApplyMenu( xSubMenuBar, rFactory, pEntry );
ApplyMenu( xSubMenuBar, rFactory, pEntry );
pEntry->SetModified( false );
}
}
else if ( pEntry->IsSeparator() )
else if ( pEntry->IsSeparator() )
{
{
...
@@ -1303,6 +1323,7 @@ void MenuSaveInData::ApplyMenu(
...
@@ -1303,6 +1323,7 @@ void MenuSaveInData::ApplyMenu(
rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
}
}
}
}
pMenuData->SetModified( false );
}
}
void
void
...
@@ -1324,6 +1345,177 @@ MenuSaveInData::Reset()
...
@@ -1324,6 +1345,177 @@ MenuSaveInData::Reset()
}
}
}
}
ContextMenuSaveInData::ContextMenuSaveInData(
const css::uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
const css::uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
const OUString& aModuleId, bool bIsDocConfig )
: SaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bIsDocConfig )
{
}
ContextMenuSaveInData::~ContextMenuSaveInData()
{
}
SvxEntries* ContextMenuSaveInData::GetEntries()
{
if ( !m_pRootEntry )
{
typedef std::unordered_map< OUString, bool, OUStringHash, std::equal_to< OUString > > MenuInfo;
MenuInfo aMenuInfo;
m_pRootEntry.reset( new SvxConfigEntry( "ContextMenus", OUString(), true ) );
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aElementsInfo;
try
{
aElementsInfo = GetConfigManager()->getUIElementsInfo( css::ui::UIElementType::POPUPMENU );
}
catch ( const css::lang::IllegalArgumentException& )
{}
for ( const auto& aElement : aElementsInfo )
{
OUString aUrl;
for ( const auto& aElementProp : aElement )
{
if ( aElementProp.Name == ITEM_DESCRIPTOR_RESOURCEURL )
aElementProp.Value >>= aUrl;
}
css::uno::Reference< css::container::XIndexAccess > xPopupMenu;
try
{
xPopupMenu = GetConfigManager()->getSettings( aUrl, sal_False );
}
catch ( const css::uno::Exception& )
{}
if ( xPopupMenu.is() )
{
OUString aMenuName = aUrl.copy( aUrl.lastIndexOf( '/' ) + 1 );
// insert into std::unordered_map to filter duplicates from the parent
aMenuInfo.insert( MenuInfo::value_type( aMenuName, true ) );
SvxConfigEntry* pEntry = new SvxConfigEntry( aMenuName, aUrl, true );
pEntry->SetMain();
m_pRootEntry->GetEntries()->push_back( pEntry );
LoadSubMenus( xPopupMenu, aMenuName, pEntry );
}
}
// Retrieve also the parent menus, to make it possible to configure module menus and save them into the document.
css::uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr = GetParentConfigManager();
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aParentElementsInfo;
try
{
if ( xParentCfgMgr.is() )
aParentElementsInfo = xParentCfgMgr->getUIElementsInfo( css::ui::UIElementType::POPUPMENU );
}
catch ( const css::lang::IllegalArgumentException& )
{}
for ( const auto& aElement : aParentElementsInfo )
{
OUString aUrl, aMenuName;
for ( const auto& aElementProp : aElement )
{
if ( aElementProp.Name == ITEM_DESCRIPTOR_RESOURCEURL )
{
aElementProp.Value >>= aUrl;
aMenuName = aUrl.copy( aUrl.lastIndexOf( '/' ) + 1 );
}
}
css::uno::Reference< css::container::XIndexAccess > xPopupMenu;
try
{
if ( aMenuInfo.find( aMenuName ) == aMenuInfo.end() )
xPopupMenu = xParentCfgMgr->getSettings( aUrl, sal_False );
}
catch ( const css::uno::Exception& )
{}
if ( xPopupMenu.is() )
{
SvxConfigEntry* pEntry = new SvxConfigEntry( aMenuName, aUrl, true, true );
pEntry->SetMain();
m_pRootEntry->GetEntries()->push_back( pEntry );
LoadSubMenus( xPopupMenu, aMenuName, pEntry );
}
}
std::sort( m_pRootEntry->GetEntries()->begin(), m_pRootEntry->GetEntries()->end(), EntrySort );
}
return m_pRootEntry->GetEntries();
}
void ContextMenuSaveInData::SetEntries( SvxEntries* pNewEntries )
{
delete m_pRootEntry->GetEntries();
m_pRootEntry->SetEntries( pNewEntries );
}
bool ContextMenuSaveInData::HasURL( const OUString& rURL )
{
SvxEntries* pEntries = GetEntries();
for ( const auto& pEntry : *pEntries )
if ( pEntry->GetCommand() == rURL )
return true;
return false;
}
bool ContextMenuSaveInData::HasSettings()
{
return m_pRootEntry && m_pRootEntry->GetEntries()->size();
}
bool ContextMenuSaveInData::Apply()
{
if ( !IsModified() )
return false;
SvxEntries* pEntries = GetEntries();
for ( const auto& pEntry : *pEntries )
{
if ( pEntry->IsModified() || 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 );
ApplyMenu( xIndexContainer, xFactory, pEntry );
OUString aUrl = pEntry->GetCommand();
try
{
if ( GetConfigManager()->hasSettings( aUrl ) )
GetConfigManager()->replaceSettings( aUrl, xIndexContainer );
else
GetConfigManager()->insertSettings( aUrl, xIndexContainer );
}
catch ( const css::uno::Exception& )
{}
}
}
SetModified( false );
return PersistChanges( GetConfigManager() );
}
void ContextMenuSaveInData::Reset()
{
SvxEntries* pEntries = GetEntries();
for ( const auto& pEntry : *pEntries )
{
try
{
GetConfigManager()->removeSettings( pEntry->GetCommand() );
}
catch ( const css::uno::Exception& )
{}
}
PersistChanges( GetConfigManager() );
m_pRootEntry.reset();
}
class PopupPainter : public SvLBoxString
class PopupPainter : public SvLBoxString
{
{
public:
public:
...
@@ -2069,6 +2261,7 @@ SvTreeListEntry* SvxConfigPage::InsertEntry(
...
@@ -2069,6 +2261,7 @@ SvTreeListEntry* SvxConfigPage::InsertEntry(
m_pContentsListBox->MakeVisible( pNewEntry );
m_pContentsListBox->MakeVisible( pNewEntry );
GetSaveInData()->SetModified();
GetSaveInData()->SetModified();
GetTopLevelSelection()->SetModified();
}
}
return pNewEntry;
return pNewEntry;
...
@@ -2196,6 +2389,7 @@ bool SvxConfigPage::MoveEntryData(
...
@@ -2196,6 +2389,7 @@ bool SvxConfigPage::MoveEntryData(
pEntries->insert( ++iter, pSourceData );
pEntries->insert( ++iter, pSourceData );
GetSaveInData()->SetModified();
GetSaveInData()->SetModified();
GetTopLevelSelection()->SetModified();
return true;
return true;
}
}
...
@@ -2381,6 +2575,7 @@ bool SvxMenuConfigPage::DeleteSelectedContent()
...
@@ -2381,6 +2575,7 @@ bool SvxMenuConfigPage::DeleteSelectedContent()
delete pMenuEntry;
delete pMenuEntry;
GetSaveInData()->SetModified();
GetSaveInData()->SetModified();
pMenu->SetModified();
return true;
return true;
}
}
...
@@ -2589,8 +2784,10 @@ SaveInData* SvxMenuConfigPage::CreateSaveInData(
...
@@ -2589,8 +2784,10 @@ SaveInData* SvxMenuConfigPage::CreateSaveInData(
const OUString& aModuleId,
const OUString& aModuleId,
bool bDocConfig )
bool bDocConfig )
{
{
return
static_cast
<
SaveInData
*
>
(
if ( !m_bIsMenuBar )
new
MenuSaveInData
(
xCfgMgr
,
xParentCfgMgr
,
aModuleId
,
bDocConfig
));
return static_cast< SaveInData* >( new ContextMenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ) );
return static_cast< SaveInData* >( new MenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ) );
}
}
SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
...
@@ -2804,6 +3001,7 @@ SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
...
@@ -2804,6 +3001,7 @@ SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
, bIsUserDefined( false )
, bIsUserDefined( false )
, bIsMain( false )
, bIsMain( false )
, bIsParentData( bParentData )
, bIsParentData( bParentData )
, bIsModified( false )
, bIsVisible( true )
, bIsVisible( true )
, nStyle( 0 )
, nStyle( 0 )
, mpEntries( nullptr )
, mpEntries( nullptr )
...
@@ -3668,11 +3866,6 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
...
@@ -3668,11 +3866,6 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
return result;
return result;
}
}
bool
EntrySort
(
SvxConfigEntry
*
a
,
SvxConfigEntry
*
b
)
{
return
a
->
GetName
().
compareTo
(
b
->
GetName
()
)
<
0
;
}
SvxEntries* ToolbarSaveInData::GetEntries()
SvxEntries* ToolbarSaveInData::GetEntries()
{
{
typedef std::unordered_map<OUString, bool,
typedef std::unordered_map<OUString, bool,
...
...
cui/source/inc/cfg.hxx
Dosyayı görüntüle @
c65e00d9
...
@@ -95,6 +95,17 @@ private:
...
@@ -95,6 +95,17 @@ private:
static
css
::
uno
::
Reference
static
css
::
uno
::
Reference
<
css
::
ui
::
XImageManager
>*
xDefaultImgMgr
;
<
css
::
ui
::
XImageManager
>*
xDefaultImgMgr
;
protected
:
void
ApplyMenu
(
css
::
uno
::
Reference
<
css
::
container
::
XIndexContainer
>&
rMenuBar
,
css
::
uno
::
Reference
<
css
::
lang
::
XSingleComponentFactory
>&
rFactory
,
SvxConfigEntry
*
pMenuData
=
nullptr
);
bool
LoadSubMenus
(
const
css
::
uno
::
Reference
<
css
::
container
::
XIndexAccess
>&
xMenuSettings
,
const
OUString
&
rBaseTitle
,
SvxConfigEntry
*
pParentData
);
public
:
public
:
SaveInData
(
SaveInData
(
...
@@ -170,15 +181,6 @@ private:
...
@@ -170,15 +181,6 @@ private:
css
::
uno
::
Reference
<
css
::
lang
::
XSingleComponentFactory
>&
rFactory
,
css
::
uno
::
Reference
<
css
::
lang
::
XSingleComponentFactory
>&
rFactory
,
SvTreeListEntry
*
pParent
=
nullptr
);
SvTreeListEntry
*
pParent
=
nullptr
);
void
ApplyMenu
(
css
::
uno
::
Reference
<
css
::
container
::
XIndexContainer
>&
rNewMenuBar
,
css
::
uno
::
Reference
<
css
::
lang
::
XSingleComponentFactory
>&
rFactory
,
SvxConfigEntry
*
pMenuData
=
nullptr
);
bool
LoadSubMenus
(
const
css
::
uno
::
Reference
<
css
::
container
::
XIndexAccess
>&
xMenuBarSettings
,
const
OUString
&
rBaseTitle
,
SvxConfigEntry
*
pParentData
);
public
:
public
:
MenuSaveInData
(
MenuSaveInData
(
...
@@ -198,6 +200,26 @@ public:
...
@@ -198,6 +200,26 @@ public:
bool
Apply
()
override
;
bool
Apply
()
override
;
};
};
class
ContextMenuSaveInData
:
public
SaveInData
{
private
:
std
::
unique_ptr
<
SvxConfigEntry
>
m_pRootEntry
;
public
:
ContextMenuSaveInData
(
const
css
::
uno
::
Reference
<
css
::
ui
::
XUIConfigurationManager
>&
xCfgMgr
,
const
css
::
uno
::
Reference
<
css
::
ui
::
XUIConfigurationManager
>&
xParentCfgMgr
,
const
OUString
&
aModuleId
,
bool
bIsDocConfig
);
virtual
~
ContextMenuSaveInData
();
SvxEntries
*
GetEntries
()
override
;
void
SetEntries
(
SvxEntries
*
pNewEntries
)
override
;
bool
HasSettings
()
override
;
bool
HasURL
(
const
OUString
&
rURL
)
override
;
void
Reset
()
override
;
bool
Apply
()
override
;
};
class
SvxConfigEntry
class
SvxConfigEntry
{
{
private
:
private
:
...
@@ -213,6 +235,7 @@ private:
...
@@ -213,6 +235,7 @@ private:
bool
bIsUserDefined
;
bool
bIsUserDefined
;
bool
bIsMain
;
bool
bIsMain
;
bool
bIsParentData
;
bool
bIsParentData
;
bool
bIsModified
;
/// toolbar specific properties
/// toolbar specific properties
bool
bIsVisible
;
bool
bIsVisible
;
...
@@ -238,6 +261,7 @@ public:
...
@@ -238,6 +261,7 @@ public:
bIsUserDefined
(
false
),
bIsUserDefined
(
false
),
bIsMain
(
false
),
bIsMain
(
false
),
bIsParentData
(
false
),
bIsParentData
(
false
),
bIsModified
(
false
),
bIsVisible
(
true
),
bIsVisible
(
true
),
nStyle
(
0
),
nStyle
(
0
),
mpEntries
(
nullptr
)
mpEntries
(
nullptr
)
...
@@ -270,6 +294,9 @@ public:
...
@@ -270,6 +294,9 @@ public:
void
SetParentData
(
bool
bValue
=
true
)
{
bIsParentData
=
bValue
;
}
void
SetParentData
(
bool
bValue
=
true
)
{
bIsParentData
=
bValue
;
}
bool
IsParentData
()
{
return
bIsParentData
;
}
bool
IsParentData
()
{
return
bIsParentData
;
}
void
SetModified
(
bool
bValue
=
true
)
{
bIsModified
=
bValue
;
}
bool
IsModified
()
{
return
bIsModified
;
}
bool
IsMovable
();
bool
IsMovable
();
bool
IsDeletable
();
bool
IsDeletable
();
bool
IsRenamable
();
bool
IsRenamable
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment