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 // STATIC DATA -----------------------------------------------------------
34 SFX_IMPL_MENU_CONTROL(SvxFontMenuControl
, SvxFontItem
);
36 //--------------------------------------------------------------------
40 Ctor; setzt den Select-Handler am Men"u und tr"agt das Men"u
44 SvxFontMenuControl::SvxFontMenuControl
48 SfxBindings
& rBindings
50 pMenu ( new FontNameMenu
),
53 rMenu
.SetPopupMenu( _nId
, pMenu
);
54 pMenu
->SetSelectHdl( LINK( this, SvxFontMenuControl
, MenuSelect
) );
55 StartListening( rBindings
);
59 //--------------------------------------------------------------------
63 F"ullt das Men"u mit den aktuellen Fonts aus der Fontlist
67 void SvxFontMenuControl::FillMenu()
69 SfxObjectShell
*pDoc
= SfxObjectShell::Current();
73 const SvxFontListItem
* pFonts
=
74 (const SvxFontListItem
*)pDoc
->GetItem( SID_ATTR_CHAR_FONTLIST
);
75 const FontList
* pList
= pFonts
? pFonts
->GetFontList(): 0;
76 DBG_ASSERT( pList
, "Kein Fonts gefunden" );
81 //--------------------------------------------------------------------
85 Statusbenachrichtigung;
86 f"ullt ggf. das Men"u mit den aktuellen Fonts aus der Fontlist
88 Ist die Funktionalit"at disabled, wird der entsprechende
89 Men"ueintrag im Parentmen"u disabled, andernfalls wird er enabled.
90 Der aktuelle Font wird mit einer Checkmark versehen.
93 void SvxFontMenuControl::StateChanged(
95 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
98 rParent
.EnableItem( GetId(), SFX_ITEM_DISABLED
!= eState
);
100 if ( SFX_ITEM_AVAILABLE
== eState
)
102 if ( !pMenu
->GetItemCount() )
104 const SvxFontItem
* pFontItem
= PTR_CAST( SvxFontItem
, pState
);
108 aFont
= pFontItem
->GetFamilyName();
109 pMenu
->SetCurName( aFont
);
113 //--------------------------------------------------------------------
117 Statusbenachrichtigung "uber Bindings; bei DOCCHANGED
118 wird das Men"u mit den aktuellen Fonts aus der Fontlist
119 der DocumentShell gef"ullt.
122 void SvxFontMenuControl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
124 if ( rHint
.Type() != TYPE(SfxSimpleHint
) &&
125 ( (SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DOCCHANGED
)
129 //--------------------------------------------------------------------
133 Select-Handler des Men"us; der Name des selektierten Fonts
134 wird in einem SvxFontItem verschickt. Das F"ullen mit den
135 weiteren Fontinformationen mu\s durch die Applikation geschehen.
138 IMPL_LINK_INLINE_START( SvxFontMenuControl
, MenuSelect
, FontNameMenu
*, pMen
)
140 SvxFontItem
aItem( GetId() );
141 aItem
.SetFamilyName(pMen
->GetCurName());
142 GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_RECORD
, &aItem
, 0L );
145 IMPL_LINK_INLINE_END( SvxFontMenuControl
, MenuSelect
, FontNameMenu
*, pMen
)
147 //--------------------------------------------------------------------
151 Dtor; gibt das Men"u frei.
154 SvxFontMenuControl::~SvxFontMenuControl()
159 //--------------------------------------------------------------------
163 Gibt das Men"u zur"uck
166 PopupMenu
* SvxFontMenuControl::GetPopup() const
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */