1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <svtools/stdmenu.hxx>
23 #include <sfx2/app.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <sfx2/dispatch.hxx>
27 #include <svx/fntctl.hxx>
28 #include <svx/svxids.hrc>
29 #include "editeng/flstitem.hxx"
30 #include "editeng/fontitem.hxx"
32 SFX_IMPL_MENU_CONTROL(SvxFontMenuControl
, SvxFontItem
);
38 Ctor; setzt den Select-Handler am Men"u und tr"agt das Men"u
42 SvxFontMenuControl::SvxFontMenuControl
46 SfxBindings
& rBindings
48 pMenu ( new FontNameMenu
),
51 rMenu
.SetPopupMenu( _nId
, pMenu
);
52 pMenu
->SetSelectHdl( LINK( this, SvxFontMenuControl
, MenuSelect
) );
53 StartListening( rBindings
);
61 F"ullt das Men"u mit den aktuellen Fonts aus der Fontlist
65 void SvxFontMenuControl::FillMenu()
67 SfxObjectShell
*pDoc
= SfxObjectShell::Current();
71 const SvxFontListItem
* pFonts
=
72 static_cast<const SvxFontListItem
*>(pDoc
->GetItem( SID_ATTR_CHAR_FONTLIST
));
73 const FontList
* pList
= pFonts
? pFonts
->GetFontList(): 0;
74 DBG_ASSERT( pList
, "Kein Fonts gefunden" );
83 Statusbenachrichtigung;
84 f"ullt ggf. das Men"u mit den aktuellen Fonts aus der Fontlist
86 Ist die Funktionalit"at disabled, wird der entsprechende
87 Men"ueintrag im Parentmen"u disabled, andernfalls wird er enabled.
88 Der aktuelle Font wird mit einer Checkmark versehen.
91 void SvxFontMenuControl::StateChanged(
93 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
96 rParent
.EnableItem( GetId(), SfxItemState::DISABLED
!= eState
);
98 if ( SfxItemState::DEFAULT
== eState
)
100 if ( !pMenu
->GetItemCount() )
102 const SvxFontItem
* pFontItem
= PTR_CAST( SvxFontItem
, pState
);
106 aFont
= pFontItem
->GetFamilyName();
107 pMenu
->SetCurName( aFont
);
115 Statusbenachrichtigung "uber Bindings; bei DOCCHANGED
116 wird das Men"u mit den aktuellen Fonts aus der Fontlist
117 der DocumentShell gef"ullt.
120 void SvxFontMenuControl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
122 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>( &rHint
);
124 pSimpleHint
->GetId() == SFX_HINT_DOCCHANGED
)
132 Select-Handler des Men"us; der Name des selektierten Fonts
133 wird in einem SvxFontItem verschickt. Das F"ullen mit den
134 weiteren Fontinformationen mu\s durch die Applikation geschehen.
137 IMPL_LINK( SvxFontMenuControl
, MenuSelect
, FontNameMenu
*, pMen
)
139 SvxFontItem
aItem( GetId() );
140 aItem
.SetFamilyName(pMen
->GetCurName());
141 GetBindings().GetDispatcher()->Execute( GetId(), SfxCallMode::RECORD
, &aItem
, 0L );
147 Dtor; gibt das Men"u frei.
150 SvxFontMenuControl::~SvxFontMenuControl()
159 Gibt das Men"u zur"uck
162 PopupMenu
* SvxFontMenuControl::GetPopup() const
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */