diff options
Diffstat (limited to 'svx/source/mnuctrls')
-rw-r--r-- | svx/source/mnuctrls/SmartTagCtl.cxx | 225 | ||||
-rw-r--r-- | svx/source/mnuctrls/clipboardctl.cxx | 163 | ||||
-rw-r--r-- | svx/source/mnuctrls/fntctl.cxx | 182 | ||||
-rw-r--r-- | svx/source/mnuctrls/fntszctl.cxx | 211 | ||||
-rw-r--r-- | svx/source/mnuctrls/makefile.mk | 71 | ||||
-rw-r--r-- | svx/source/mnuctrls/mnuctrls.src | 81 |
6 files changed, 933 insertions, 0 deletions
diff --git a/svx/source/mnuctrls/SmartTagCtl.cxx b/svx/source/mnuctrls/SmartTagCtl.cxx new file mode 100644 index 000000000000..6833117a1335 --- /dev/null +++ b/svx/source/mnuctrls/SmartTagCtl.cxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <svx/SmartTagCtl.hxx> +#include <com/sun/star/smarttags/XSmartTagAction.hpp> +#ifndef _COM_SUN_STAR_SMARTTAGS_XSTRINGKEYMAP_HPP_ +#include <com/sun/star/container/XStringKeyMap.hpp> +#endif +#include <svtools/stdmenu.hxx> +#include <svl/eitem.hxx> +#include <sfx2/dispatch.hxx> +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif + +#include <svx/SmartTagItem.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +#define C2U(cChar) rtl::OUString::createFromAscii(cChar) + +// STATIC DATA ----------------------------------------------------------- + +SFX_IMPL_MENU_CONTROL(SvxSmartTagsControl, SvxSmartTagItem); + +//-------------------------------------------------------------------- + +SvxSmartTagsControl::SvxSmartTagsControl +( + USHORT _nId, + Menu& rMenu, + SfxBindings& /*rBindings*/ +) : + mpMenu ( new PopupMenu ), + mrParent ( rMenu ), + mpSmartTagItem( 0 ) +{ + rMenu.SetPopupMenu( _nId, mpMenu ); +} + +//-------------------------------------------------------------------- + +const USHORT MN_ST_INSERT_START = 500; + +void SvxSmartTagsControl::FillMenu() +{ + if ( !mpSmartTagItem ) + return; + + USHORT nMenuPos = 0; + USHORT nSubMenuPos = 0; + USHORT nMenuId = 1; + USHORT nSubMenuId = MN_ST_INSERT_START; + + const Sequence < Sequence< Reference< smarttags::XSmartTagAction > > >& rActionComponentsSequence = mpSmartTagItem->GetActionComponentsSequence(); + const Sequence < Sequence< sal_Int32 > >& rActionIndicesSequence = mpSmartTagItem->GetActionIndicesSequence(); + const Sequence< Reference< container::XStringKeyMap > >& rStringKeyMaps = mpSmartTagItem->GetStringKeyMaps(); + const lang::Locale& rLocale = mpSmartTagItem->GetLocale(); + const rtl::OUString aApplicationName = mpSmartTagItem->GetApplicationName(); + const rtl::OUString aRangeText = mpSmartTagItem->GetRangeText(); + const Reference<text::XTextRange>& xTextRange = mpSmartTagItem->GetTextRange(); + const Reference<frame::XController>& xController = mpSmartTagItem->GetController(); + + for ( USHORT j = 0; j < rActionComponentsSequence.getLength(); ++j ) + { + Reference< container::XStringKeyMap > xSmartTagProperties = rStringKeyMaps[j]; + + // Get all actions references associated with the current smart tag type: + const Sequence< Reference< smarttags::XSmartTagAction > >& rActionComponents = rActionComponentsSequence[j]; + const Sequence< sal_Int32 >& rActionIndices = rActionIndicesSequence[j]; + + if ( 0 == rActionComponents.getLength() || 0 == rActionIndices.getLength() ) + continue; + + // Ask first entry for the smart tag type caption: + Reference< smarttags::XSmartTagAction > xAction = rActionComponents[0]; + + if ( !xAction.is() ) + continue; + + const sal_Int32 nSmartTagIndex = rActionIndices[0]; + const rtl::OUString aSmartTagType = xAction->getSmartTagName( nSmartTagIndex ); + const rtl::OUString aSmartTagCaption = xAction->getSmartTagCaption( nSmartTagIndex, rLocale ); + + // no sub-menues if there's only one smart tag type listed: + PopupMenu* pSbMenu = mpMenu; + if ( 1 < rActionComponentsSequence.getLength() ) + { + mpMenu->InsertItem( nMenuId, aSmartTagCaption, 0, nMenuPos++); + pSbMenu = new PopupMenu; + mpMenu->SetPopupMenu( nMenuId++, pSbMenu ); + } + pSbMenu->SetSelectHdl( LINK( this, SvxSmartTagsControl, MenuSelect ) ); + + // sub-menu starts with smart tag caption and separator + const rtl::OUString aSmartTagCaption2 = aSmartTagCaption + C2U(": ") + aRangeText; + nSubMenuPos = 0; + pSbMenu->InsertItem( nMenuId++, aSmartTagCaption2, MIB_NOSELECT, nSubMenuPos++ ); + pSbMenu->InsertSeparator( nSubMenuPos++ ); + + // Add subitem for every action reference for the current smart tag type: + for ( USHORT i = 0; i < rActionComponents.getLength(); ++i ) + { + xAction = rActionComponents[i]; + + for ( sal_Int32 k = 0; k < xAction->getActionCount( aSmartTagType, xController ); ++k ) + { + const sal_uInt32 nActionID = xAction->getActionID( aSmartTagType, k, xController ); + rtl::OUString aActionCaption = xAction->getActionCaptionFromID( nActionID, + aApplicationName, + rLocale, + xSmartTagProperties, + aRangeText, + rtl::OUString(), + xController, + xTextRange ); + + pSbMenu->InsertItem( nSubMenuId++, aActionCaption, 0, nSubMenuPos++ ); + InvokeAction aEntry( xAction, xSmartTagProperties, nActionID ); + maInvokeActions.push_back( aEntry ); + } + } + } +} + +//-------------------------------------------------------------------- + +void SvxSmartTagsControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState ) + +{ + mrParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState ); + + if ( SFX_ITEM_AVAILABLE == eState ) + { + const SvxSmartTagItem* pSmartTagItem = PTR_CAST( SvxSmartTagItem, pState ); + if ( 0 != pSmartTagItem ) + { + delete mpSmartTagItem; + mpSmartTagItem = new SvxSmartTagItem( *pSmartTagItem ); + FillMenu(); + } + } +} + +//-------------------------------------------------------------------- + +IMPL_LINK_INLINE_START( SvxSmartTagsControl, MenuSelect, PopupMenu *, pMen ) +{ + if ( !mpSmartTagItem ) + return 0; + + sal_uInt16 nMyId = pMen->GetCurItemId(); + + if ( nMyId < MN_ST_INSERT_START) return 0; + nMyId -= MN_ST_INSERT_START; + + // compute smarttag lib index and action index + Reference< smarttags::XSmartTagAction > xSmartTagAction = maInvokeActions[ nMyId ].mxAction; + + // execute action + if ( xSmartTagAction.is() ) + { + xSmartTagAction->invokeAction( maInvokeActions[ nMyId ].mnActionID, + mpSmartTagItem->GetApplicationName(), + mpSmartTagItem->GetController(), + mpSmartTagItem->GetTextRange(), + maInvokeActions[ nMyId ].mxSmartTagProperties, + mpSmartTagItem->GetRangeText(), + rtl::OUString(), + mpSmartTagItem->GetLocale() ); + } + + // ohne dispatcher!!! + // GetBindings().Execute( GetId(), SFX_CALLMODE_RECORD,meine beiden items, 0L );*/ + //SfxBoolItem aBool(SID_OPEN_SMARTTAGOPTIONS, TRUE); + //GetBindings().GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SFX_CALLMODE_ASYNCHRON, &aBool, 0L ); + + return 0; +} +IMPL_LINK_INLINE_END( SvxSmartTagsControl, MenuSelect, PopupMenu *, pMen ) + +//-------------------------------------------------------------------- + +SvxSmartTagsControl::~SvxSmartTagsControl() +{ + delete mpSmartTagItem; + delete mpMenu; +} + +//-------------------------------------------------------------------- + +PopupMenu* SvxSmartTagsControl::GetPopup() const +{ + return mpMenu; +} + + diff --git a/svx/source/mnuctrls/clipboardctl.cxx b/svx/source/mnuctrls/clipboardctl.cxx new file mode 100644 index 000000000000..f6b95067c5e2 --- /dev/null +++ b/svx/source/mnuctrls/clipboardctl.cxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <sfx2/app.hxx> +#include <sfx2/tbxctrl.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <tools/gen.hxx> +#include <svl/intitem.hxx> +#include <sot/exchange.hxx> +#include <svl/eitem.hxx> +#include <vcl/toolbox.hxx> +#include <clipboardctl.hxx> +#include <clipfmtitem.hxx> + +#include <svtools/insdlg.hxx> +#include <svx/svxids.hrc> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; + +///////////////////////////////////////////////////////////////// + +SFX_IMPL_TOOLBOX_CONTROL( SvxClipBoardControl, SfxVoidItem /*SfxUInt16Item*/ ); + + +SvxClipBoardControl::SvxClipBoardControl( + USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + + SfxToolBoxControl( nSlotId, nId, rTbx ), + pClipboardFmtItem( 0 ), + pPopup (0), + nItemId (nId), + bDisabled( FALSE ) +{ + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ClipboardFormatItems" ))); + ToolBox& rBox = GetToolBox(); + rBox.SetItemBits( nId, TIB_DROPDOWN | rBox.GetItemBits( nId ) ); + rBox.Invalidate(); +} + + +SvxClipBoardControl::~SvxClipBoardControl() +{ + DelPopup(); + delete pClipboardFmtItem; +} + + +SfxPopupWindow* SvxClipBoardControl::CreatePopupWindow() +{ + const SvxClipboardFmtItem* pFmtItem = PTR_CAST( SvxClipboardFmtItem, pClipboardFmtItem ); + if ( pFmtItem ) + { + if (pPopup) + pPopup->Clear(); + else + pPopup = new PopupMenu; + + USHORT nCount = pFmtItem->Count(); + for (USHORT i = 0; i < nCount; ++i) + { + ULONG nFmtID = pFmtItem->GetClipbrdFormatId( i ); + String aFmtStr( pFmtItem->GetClipbrdFormatName( i ) ); + if (!aFmtStr.Len()) + aFmtStr = SvPasteObjectHelper::GetSotFormatUIName( nFmtID ); + pPopup->InsertItem( (USHORT)nFmtID, aFmtStr ); + } + + ToolBox& rBox = GetToolBox(); + USHORT nId = GetId(); + rBox.SetItemDown( nId, TRUE ); + + pPopup->Execute( &rBox, rBox.GetItemRect( nId ), + (rBox.GetAlign() == WINDOWALIGN_TOP || rBox.GetAlign() == WINDOWALIGN_BOTTOM) ? + POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT ); + + rBox.SetItemDown( nId, FALSE ); + + SfxUInt32Item aItem( SID_CLIPBOARD_FORMAT_ITEMS, pPopup->GetCurItemId() ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedFormat" )); + aItem.QueryValue( a ); + aArgs[0].Value = a; + Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ClipboardFormatItems" )), + aArgs ); + } + + GetToolBox().EndSelection(); + DelPopup(); + return 0; +} + + +SfxPopupWindowType SvxClipBoardControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONTIMEOUT; +} + + +void SvxClipBoardControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + if ( SID_CLIPBOARD_FORMAT_ITEMS == nSID ) + { + DELETEZ( pClipboardFmtItem ); + if ( eState >= SFX_ITEM_AVAILABLE ) + { + pClipboardFmtItem = pState->Clone(); + GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) | TIB_DROPDOWN ); + } + else if ( !bDisabled ) + GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) & ~TIB_DROPDOWN ); + GetToolBox().Invalidate( GetToolBox().GetItemRect( GetId() ) ); + } + else + { + // enable the item as a whole + bDisabled = (GetItemState(pState) == SFX_ITEM_DISABLED); + GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) ); + } +} + + +void SvxClipBoardControl::DelPopup() +{ + if(pPopup) + { + delete pPopup; + pPopup = 0; + } +} + + +///////////////////////////////////////////////////////////////// + diff --git a/svx/source/mnuctrls/fntctl.cxx b/svx/source/mnuctrls/fntctl.cxx new file mode 100644 index 000000000000..0cd5dfa335da --- /dev/null +++ b/svx/source/mnuctrls/fntctl.cxx @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headern +#include <svtools/stdmenu.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/dispatch.hxx> + +#include <svx/fntctl.hxx> // +#include <svx/svxids.hrc> +#include "editeng/flstitem.hxx" +#include "editeng/fontitem.hxx" + +// STATIC DATA ----------------------------------------------------------- + +SFX_IMPL_MENU_CONTROL(SvxFontMenuControl, SvxFontItem); + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Ctor; setzt den Select-Handler am Men"u und tr"agt das Men"u + in seinen Parent ein. +*/ + +SvxFontMenuControl::SvxFontMenuControl +( + USHORT _nId, + Menu& rMenu, + SfxBindings& rBindings +) : + pMenu ( new FontNameMenu ), + rParent ( rMenu ) +{ + rMenu.SetPopupMenu( _nId, pMenu ); + pMenu->SetSelectHdl( LINK( this, SvxFontMenuControl, MenuSelect ) ); + StartListening( rBindings ); + FillMenu(); +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + F"ullt das Men"u mit den aktuellen Fonts aus der Fontlist + der DocumentShell. +*/ + +void SvxFontMenuControl::FillMenu() +{ + SfxObjectShell *pDoc = SfxObjectShell::Current(); + + if ( pDoc ) + { + const SvxFontListItem* pFonts = + (const SvxFontListItem*)pDoc->GetItem( SID_ATTR_CHAR_FONTLIST ); + const FontList* pList = pFonts ? pFonts->GetFontList(): 0; + DBG_ASSERT( pList, "Kein Fonts gefunden" ); + pMenu->Fill( pList ); + } +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Statusbenachrichtigung; + f"ullt ggf. das Men"u mit den aktuellen Fonts aus der Fontlist + der DocumentShell. + Ist die Funktionalit"at disabled, wird der entsprechende + Men"ueintrag im Parentmen"u disabled, andernfalls wird er enabled. + Der aktuelle Font wird mit einer Checkmark versehen. +*/ + +void SvxFontMenuControl::StateChanged( + + USHORT, SfxItemState eState, const SfxPoolItem* pState ) + +{ + rParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState ); + + if ( SFX_ITEM_AVAILABLE == eState ) + { + if ( !pMenu->GetItemCount() ) + FillMenu(); + const SvxFontItem* pFontItem = PTR_CAST( SvxFontItem, pState ); + String aFont; + + if ( pFontItem ) + aFont = pFontItem->GetFamilyName(); + pMenu->SetCurName( aFont ); + } +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Statusbenachrichtigung "uber Bindings; bei DOCCHANGED + wird das Men"u mit den aktuellen Fonts aus der Fontlist + der DocumentShell gef"ullt. +*/ + +void SvxFontMenuControl::Notify( SfxBroadcaster&, const SfxHint& rHint ) +{ + if ( rHint.Type() != TYPE(SfxSimpleHint) && + ( (SfxSimpleHint&)rHint ).GetId() == SFX_HINT_DOCCHANGED ) + FillMenu(); +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Select-Handler des Men"us; der Name des selektierten Fonts + wird in einem SvxFontItem verschickt. Das F"ullen mit den + weiteren Fontinformationen mu\s durch die Applikation geschehen. +*/ + +IMPL_LINK_INLINE_START( SvxFontMenuControl, MenuSelect, FontNameMenu *, pMen ) +{ + SvxFontItem aItem( GetId() ); + aItem.GetFamilyName() = pMen->GetCurName(); + GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_RECORD, &aItem, 0L ); + return 0; +} +IMPL_LINK_INLINE_END( SvxFontMenuControl, MenuSelect, FontNameMenu *, pMen ) + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Dtor; gibt das Men"u frei. +*/ + +SvxFontMenuControl::~SvxFontMenuControl() +{ + delete pMenu; +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Gibt das Men"u zur"uck +*/ + +PopupMenu* SvxFontMenuControl::GetPopup() const +{ + return pMenu; +} + + + diff --git a/svx/source/mnuctrls/fntszctl.cxx b/svx/source/mnuctrls/fntszctl.cxx new file mode 100644 index 000000000000..68e7c4d32472 --- /dev/null +++ b/svx/source/mnuctrls/fntszctl.cxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headern +#include <svl/itempool.hxx> +#include <svtools/stdmenu.hxx> +#include <svtools/ctrltool.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/dispatch.hxx> + +#include <svx/fntszctl.hxx> // +#include <svx/dialogs.hrc> +#include <editeng/fhgtitem.hxx> +#include "editeng/fontitem.hxx" +#include "editeng/flstitem.hxx" + +#include "dlgutil.hxx" +#include <svx/dialmgr.hxx> + +#define LOGIC OutputDevice::LogicToLogic + +SFX_IMPL_MENU_CONTROL(SvxFontSizeMenuControl, SvxFontHeightItem); + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Select-Handler des Men"us; die aktuelle Fontgr"o\se + wird in einem SvxFontHeightItem verschickt. +*/ + +IMPL_LINK( SvxFontSizeMenuControl, MenuSelect, FontSizeMenu*, pMen ) +{ + SfxViewFrame* pFrm = SfxViewFrame::Current(); + SfxShell* pSh = pFrm ? pFrm->GetDispatcher()->GetShell( 0 ) : NULL; + + if ( !pSh ) + return 0; + + const SfxItemPool& rPool = pSh->GetPool(); + USHORT nWhich = rPool.GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); + const SfxMapUnit eUnit = rPool.GetMetric( nWhich ); + long nH = LOGIC( pMen->GetCurHeight(), MAP_POINT, (MapUnit)eUnit ) / 10; + SvxFontHeightItem aItem( nH, 100, GetId() ); + GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_RECORD, &aItem, 0L ); + return 1; +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Statusbenachrichtigung; + Ist die Funktionalit"at disabled, wird der entsprechende + Men"ueintrag im Parentmenu disabled, andernfalls wird er enabled. + die aktuelle Fontgr"o\se wird mit einer Checkmark versehen. +*/ + +void SvxFontSizeMenuControl::StateChanged( + + USHORT, SfxItemState eState, const SfxPoolItem* pState ) + +{ + rParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState ); + + if ( SFX_ITEM_AVAILABLE == eState ) + { + if ( pState->ISA(SvxFontHeightItem) ) + { + const SvxFontHeightItem* pItem = + PTR_CAST( SvxFontHeightItem, pState ); + long nVal = 0; + + if ( pItem ) + { + SfxViewFrame* pFrm = SfxViewFrame::Current(); + SfxShell* pSh = pFrm ? pFrm->GetDispatcher()->GetShell( 0 ) + : NULL; + + if ( !pSh ) + return; + + const SfxItemPool& rPool = pSh->GetPool(); + USHORT nWhich = rPool.GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); + const SfxMapUnit eUnit = rPool.GetMetric( nWhich ); + long nH = pItem->GetHeight() * 10; + nVal = LOGIC( nH, (MapUnit)eUnit, MAP_POINT ); + } + pMenu->SetCurHeight( nVal ); + } + else if ( pState->ISA(SvxFontItem) ) + { + const SvxFontItem* pItem = PTR_CAST( SvxFontItem, pState ); + + if ( pItem ) + { + SfxObjectShell *pDoc = SfxObjectShell::Current(); + + if ( pDoc ) + { + const SvxFontListItem* pFonts = (const SvxFontListItem*) + pDoc->GetItem( SID_ATTR_CHAR_FONTLIST ); + const FontList* pList = pFonts ? pFonts->GetFontList(): 0; + + if ( pList ) + { + FontInfo aFntInf = pList->Get( pItem->GetFamilyName(), + pItem->GetStyleName() ); + pMenu->Fill( aFntInf, pList ); + } + // else manche Shells haben keine Fontliste (z.B. Image) + } + } + } + } + else + { + // irgendwie muss man ja das Men"u f"ullen + SfxObjectShell* pSh = SfxObjectShell::Current(); + + if ( pSh ) + { + // daf"ur von der Shell eine Fontliste besorgen + const SvxFontListItem* pFonts = + (const SvxFontListItem*)pSh->GetItem( SID_ATTR_CHAR_FONTLIST ); + const FontList* pList = pFonts ? pFonts->GetFontList(): NULL; + if ( pList ) + pMenu->Fill( pList->GetFontName(0), pList ); + } + } +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Ctor; setzt den Select-Handler am Men"u und tr"agt Men"u + in seinen Parent ein. +*/ + +SvxFontSizeMenuControl::SvxFontSizeMenuControl +( + USHORT _nId, + Menu& rMenu, + SfxBindings& rBindings +) : + SfxMenuControl( _nId, rBindings ), + + pMenu ( new FontSizeMenu ), + rParent ( rMenu ), + aFontNameForwarder( SID_ATTR_CHAR_FONT, *this ) + +{ + rMenu.SetPopupMenu( _nId, pMenu ); + pMenu->SetSelectHdl( LINK( this, SvxFontSizeMenuControl, MenuSelect ) ); +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Dtor; gibt das Men"u frei. +*/ + +SvxFontSizeMenuControl::~SvxFontSizeMenuControl() +{ + delete pMenu; +} + +//-------------------------------------------------------------------- + +/* [Beschreibung] + + Gibt das Men"u zur"uck +*/ + +PopupMenu* SvxFontSizeMenuControl::GetPopup() const +{ + return pMenu; +} + + diff --git a/svx/source/mnuctrls/makefile.mk b/svx/source/mnuctrls/makefile.mk new file mode 100644 index 000000000000..9c208d9a787c --- /dev/null +++ b/svx/source/mnuctrls/makefile.mk @@ -0,0 +1,71 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=..$/.. + +PROJECTPCH4DLL=TRUE +PROJECTPCH=svxpch +PROJECTPCHSOURCE=$(PRJ)$/util$/svxpch + +ENABLE_EXCEPTIONS=TRUE + +PRJNAME=svx +TARGET=mnuctrls + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES = \ + mnuctrls.src + +SLOFILES= \ + $(SLO)$/clipboardctl.obj \ + $(SLO)$/fntctl.obj \ + $(SLO)$/fntszctl.obj \ + $(SLO)$/SmartTagCtl.obj + +HXX1TARGET=mnuctrls +HXX1EXT= hxx +HXX1EXCL= -E:*include* +HXX1DEPN=\ + $(INC)$/clipboardctl.hxx \ + $(INC)$/fntctl.hxx \ + $(INC)$/fntszctl.hxx \ + $(INC)$/SmartTagCtl.hxx + +EXCEPTIONSFILES= \ + $(SLO)$/SmartTagCtl.obj + + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/svx/source/mnuctrls/mnuctrls.src b/svx/source/mnuctrls/mnuctrls.src new file mode 100644 index 000000000000..e973ea249fa4 --- /dev/null +++ b/svx/source/mnuctrls/mnuctrls.src @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <svx/dialogs.hrc> + +Menu RID_MN_FONTSIZE { + ItemList = { + MenuItem { + Text = "6"; + Identifier = 6; + }; + MenuItem { + Text = "8"; + Identifier = 8; + }; + MenuItem { + Text = "10"; + Identifier = 10; + }; + MenuItem { + Text = "12"; + Identifier = 12; + }; + MenuItem { + Text = "14"; + Identifier = 14; + }; + MenuItem { + Text = "18"; + Identifier = 18; + }; + MenuItem { + Text = "24"; + Identifier = 24; + }; + MenuItem { + Text = "36"; + Identifier = 36; + }; + MenuItem { + Text = "48"; + Identifier = 48; + }; + MenuItem { + Text = "60"; + Identifier = 60; + }; + MenuItem { + Text = "72"; + Identifier = 72; + }; + }; +}; + + + + |