bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / mnuctrls / fntctl.cxx
blob3dd099569bf86c51c98fcf64bd3e31e6a9b41523
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <string>
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);
36 /* [Beschreibung]
38 Ctor; setzt den Select-Handler am Men"u und tr"agt das Men"u
39 in seinen Parent ein.
42 SvxFontMenuControl::SvxFontMenuControl
44 sal_uInt16 _nId,
45 Menu& rMenu,
46 SfxBindings& rBindings
47 ) :
48 pMenu ( new FontNameMenu ),
49 rParent ( rMenu )
51 rMenu.SetPopupMenu( _nId, pMenu );
52 pMenu->SetSelectHdl( LINK( this, SvxFontMenuControl, MenuSelect ) );
53 StartListening( rBindings );
54 FillMenu();
59 /* [Beschreibung]
61 F"ullt das Men"u mit den aktuellen Fonts aus der Fontlist
62 der DocumentShell.
65 void SvxFontMenuControl::FillMenu()
67 SfxObjectShell *pDoc = SfxObjectShell::Current();
69 if ( pDoc )
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" );
75 pMenu->Fill( pList );
81 /* [Beschreibung]
83 Statusbenachrichtigung;
84 f"ullt ggf. das Men"u mit den aktuellen Fonts aus der Fontlist
85 der DocumentShell.
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() )
101 FillMenu();
102 const SvxFontItem* pFontItem = PTR_CAST( SvxFontItem, pState );
103 OUString aFont;
105 if ( pFontItem )
106 aFont = pFontItem->GetFamilyName();
107 pMenu->SetCurName( aFont );
113 /* [Beschreibung]
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 );
123 if ( pSimpleHint &&
124 pSimpleHint->GetId() == SFX_HINT_DOCCHANGED )
125 FillMenu();
130 /* [Beschreibung]
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 );
142 return 0;
145 /* [Beschreibung]
147 Dtor; gibt das Men"u frei.
150 SvxFontMenuControl::~SvxFontMenuControl()
152 delete pMenu;
157 /* [Beschreibung]
159 Gibt das Men"u zur"uck
162 PopupMenu* SvxFontMenuControl::GetPopup() const
164 return pMenu;
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */