diff options
Diffstat (limited to 'svx/source/tbxctrls')
35 files changed, 14755 insertions, 0 deletions
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx new file mode 100644 index 000000000000..4596d350cee4 --- /dev/null +++ b/svx/source/tbxctrls/colorwindow.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +//======================================================================== +// class SvxColorWindow_Impl -------------------------------------------------- +//======================================================================== +#ifndef __SVX_COLORWINDOW_HXX_ +#define __SVX_COLORWINDOW_HXX_ + +#include <sfx2/tbxctrl.hxx> +#include <svl/lstner.hxx> +#include <rtl/ustring.hxx> +#include <com/sun/star/frame/XFrame.hpp> + +//======================================================================== +// class SvxColorWindow_Impl -------------------------------------------------- +//======================================================================== + +class SvxColorWindow_Impl : public SfxPopupWindow +{ + using FloatingWindow::StateChanged; + +private: + const USHORT theSlotId; + ValueSet aColorSet; + rtl::OUString maCommand; + +#if _SOLAR__PRIVATE + DECL_LINK( SelectHdl, void * ); +#endif + +protected: + virtual void Resize(); + virtual BOOL Close(); + +public: + SvxColorWindow_Impl( const rtl::OUString& rCommand, + USHORT nSlotId, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const String& rWndTitle, + Window* pParentWindow ); + ~SvxColorWindow_Impl(); + void StartSelection(); + + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + + virtual SfxPopupWindow* Clone() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx new file mode 100644 index 000000000000..6c59847f28ac --- /dev/null +++ b/svx/source/tbxctrls/colrctrl.cxx @@ -0,0 +1,664 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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/dialogs.hrc> + + +#include <tools/list.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/dispatch.hxx> +#include <vcl/image.hxx> + +#include <svx/colrctrl.hxx> + +#include <svx/svdview.hxx> +#include "drawitem.hxx" +#include <editeng/colritem.hxx> +#include "xattr.hxx" +#include <svx/xtable.hxx> +#include <svx/dialmgr.hxx> +#include "xexch.hxx" +#include <vcl/svapp.hxx> + +SFX_IMPL_DOCKINGWINDOW( SvxColorChildWindow, SID_COLOR_CONTROL ) + +// ------------------------ +// - SvxColorValueSetData - +// ------------------------ + +class SvxColorValueSetData : public TransferableHelper +{ +private: + + XFillExchangeData maData; + +protected: + + virtual void AddSupportedFormats(); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + +public: + + SvxColorValueSetData( const XFillAttrSetItem& rSetItem ) : + maData( rSetItem ) {} +}; + +// ----------------------------------------------------------------------------- + +void SvxColorValueSetData::AddSupportedFormats() +{ + AddFormat( SOT_FORMATSTR_ID_XFA ); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvxColorValueSetData::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +{ + sal_Bool bRet = sal_False; + + if( SotExchange::GetFormat( rFlavor ) == SOT_FORMATSTR_ID_XFA ) + { + SetObject( &maData, 0, rFlavor ); + bRet = sal_True; + } + + return bRet; +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvxColorValueSetData::WriteObject( SotStorageStreamRef& rxOStm, void*, sal_uInt32 , const ::com::sun::star::datatransfer::DataFlavor& ) +{ + *rxOStm << maData; + return( rxOStm->GetError() == ERRCODE_NONE ); +} + +/************************************************************************* +|* +|* SvxColorValueSet: Ctor +|* +\************************************************************************/ + +SvxColorValueSet::SvxColorValueSet( Window* _pParent, WinBits nWinStyle ) : + ValueSet( _pParent, nWinStyle ), + DragSourceHelper( this ), + bLeft (TRUE) +{ +} + +/************************************************************************* +|* +|* SvxColorValueSet: Ctor +|* +\************************************************************************/ + +SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) : + ValueSet( _pParent, rResId ), + DragSourceHelper( this ), + bLeft (TRUE) +{ +} + +/************************************************************************* +|* +|* SvxColorValueSet: MouseButtonDown +|* +\************************************************************************/ + +void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt ) +{ + // Fuer Mac noch anders handlen ! + if( rMEvt.IsLeft() ) + { + bLeft = TRUE; + ValueSet::MouseButtonDown( rMEvt ); + } + else + { + bLeft = FALSE; + MouseEvent aMEvt( rMEvt.GetPosPixel(), + rMEvt.GetClicks(), + rMEvt.GetMode(), + MOUSE_LEFT, + rMEvt.GetModifier() ); + ValueSet::MouseButtonDown( aMEvt ); + } + + aDragPosPixel = GetPointerPosPixel(); +} + +/************************************************************************* +|* +|* SvxColorValueSet: MouseButtonUp +|* +\************************************************************************/ + +void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt ) +{ + // Fuer Mac noch anders handlen ! + if( rMEvt.IsLeft() ) + { + bLeft = TRUE; + ValueSet::MouseButtonUp( rMEvt ); + } + else + { + bLeft = FALSE; + MouseEvent aMEvt( rMEvt.GetPosPixel(), + rMEvt.GetClicks(), + rMEvt.GetMode(), + MOUSE_LEFT, + rMEvt.GetModifier() ); + ValueSet::MouseButtonUp( aMEvt ); + } + SetNoSelection(); +} + +/************************************************************************* +|* +|* Command-Event +|* +\************************************************************************/ + +void SvxColorValueSet::Command(const CommandEvent& rCEvt) +{ + // Basisklasse + ValueSet::Command(rCEvt); +} + +/************************************************************************* +|* +|* StartDrag +|* +\************************************************************************/ + +void SvxColorValueSet::StartDrag( sal_Int8 , const Point& ) +{ + Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl)); +} + +/************************************************************************* +|* +|* Drag&Drop asynchron ausfuehren +|* +\************************************************************************/ + +void SvxColorValueSet::DoDrag() +{ + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + USHORT nItemId = GetItemId( aDragPosPixel ); + + if( pDocSh && nItemId ) + { + XFillAttrSetItem aXFillSetItem( &pDocSh->GetPool() ); + SfxItemSet& rSet = aXFillSetItem.GetItemSet(); + + rSet.Put( XFillColorItem( GetItemText( nItemId ), GetItemColor( nItemId ) ) ); + rSet.Put(XFillStyleItem( ( 1 == nItemId ) ? XFILL_NONE : XFILL_SOLID ) ); + + EndSelection(); + ( new SvxColorValueSetData( aXFillSetItem ) )->StartDrag( this, DND_ACTION_COPY ); + ReleaseMouse(); + } +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG) +{ + // Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die + // Farbleiste geloescht werden darf + pThis->DoDrag(); + return(0); +} + +/************************************************************************* +|* +|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator +|* +\************************************************************************/ + +SvxColorChildWindow::SvxColorChildWindow( Window* _pParent, + USHORT nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ) : + SfxChildWindow( _pParent, nId ) +{ + SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this, + _pParent, SVX_RES( RID_SVXCTRL_COLOR ) ); + pWindow = pWin; + + eChildAlignment = SFX_ALIGN_BOTTOM; + + pWin->Initialize( pInfo ); +} + + + +/************************************************************************* +|* +|* Ctor: SvxColorDockingWindow +|* +\************************************************************************/ + +SvxColorDockingWindow::SvxColorDockingWindow +( + SfxBindings* _pBindings, + SfxChildWindow* pCW, + Window* _pParent, + const ResId& rResId +) : + + SfxDockingWindow( _pBindings, pCW, _pParent, rResId ), + + pColorTable ( NULL ), + aColorSet ( this, ResId( 1, *rResId.GetResMgr() ) ), + nLeftSlot ( SID_ATTR_FILL_COLOR ), + nRightSlot ( SID_ATTR_LINE_COLOR ), + nCols ( 20 ), + nLines ( 1 ), + aColorSize ( 14, 14 ) + +{ + FreeResource(); + + aColorSet.SetStyle( aColorSet.GetStyle() | WB_ITEMBORDER ); + aColorSet.SetSelectHdl( LINK( this, SvxColorDockingWindow, SelectHdl ) ); + + // Get the model from the view shell. Using SfxObjectShell::Current() + // is unreliable when called at the wrong times. + SfxObjectShell* pDocSh = NULL; + if (_pBindings != NULL) + { + SfxDispatcher* pDispatcher = _pBindings->GetDispatcher(); + if (pDispatcher != NULL) + { + SfxViewFrame* pFrame = pDispatcher->GetFrame(); + if (pFrame != NULL) + { + SfxViewShell* pViewShell = pFrame->GetViewShell(); + if (pViewShell != NULL) + pDocSh = pViewShell->GetObjectShell(); + } + } + } + + if ( pDocSh ) + { + const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); + if( pItem ) + { + pColorTable = ( (SvxColorTableItem*) pItem )->GetColorTable(); + FillValueSet(); + } + } + aItemSize = aColorSet.CalcItemSizePixel( aColorSize ); + aItemSize.Width() = aItemSize.Width() + aColorSize.Width(); + aItemSize.Width() /= 2; + aItemSize.Height() = aItemSize.Height() + aColorSize.Height(); + aItemSize.Height() /= 2; + + SetSize(); + aColorSet.Show(); + StartListening( *_pBindings, TRUE ); +} + + +/************************************************************************* +|* +|* Dtor: SvxColorDockingWindow +|* +\************************************************************************/ + +SvxColorDockingWindow::~SvxColorDockingWindow() +{ + EndListening( GetBindings() ); +} + +/************************************************************************* +|* +|* Notify +|* +\************************************************************************/ + +void SvxColorDockingWindow::Notify( SfxBroadcaster& , const SfxHint& rHint ) +{ + const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint); + if ( pPoolItemHint + && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) ) + { + // Die Liste der Farben hat sich geaendert + pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable(); + FillValueSet(); + } +} + +/************************************************************************* +|* +|* FillValueSet +|* +\************************************************************************/ + +void SvxColorDockingWindow::FillValueSet() +{ + if( pColorTable ) + { + aColorSet.Clear(); + + // Erster Eintrag: unsichtbar + long nPtX = aColorSize.Width() - 1; + long nPtY = aColorSize.Height() - 1; + VirtualDevice aVD; + aVD.SetOutputSizePixel( aColorSize ); + aVD.SetLineColor( Color( COL_BLACK ) ); + aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) ); + aVD.DrawLine( Point(), Point( nPtX, nPtY ) ); + aVD.DrawLine( Point( 0, nPtY ), Point( nPtX, 0 ) ); + + Bitmap aBmp( aVD.GetBitmap( Point(), aColorSize ) ); + + aColorSet.InsertItem( (USHORT)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) ); + + XColorEntry* pEntry; + nCount = pColorTable->Count(); + + for( long i = 0; i < nCount; i++ ) + { + pEntry = pColorTable->GetColor( i ); + aColorSet.InsertItem( (USHORT)i+2, + pEntry->GetColor(), pEntry->GetName() ); + } + } +} + +/************************************************************************* +|* +|* SetSize +|* +\************************************************************************/ + +void SvxColorDockingWindow::SetSize() +{ + // Groesse fuer ValueSet berechnen + Size aSize = GetOutputSizePixel(); + aSize.Width() -= 4; + aSize.Height() -= 4; + + // Zeilen und Spalten berechnen + nCols = (USHORT) ( aSize.Width() / aItemSize.Width() ); + nLines = (USHORT) ( (float) aSize.Height() / (float) aItemSize.Height() /*+ 0.35*/ ); + if( nLines == 0 ) + nLines++; + + // Scrollbar setzen/entfernen + WinBits nBits = aColorSet.GetStyle(); + if ( nLines * nCols >= nCount ) + nBits &= ~WB_VSCROLL; + else + nBits |= WB_VSCROLL; + aColorSet.SetStyle( nBits ); + + // ScrollBar ? + long nScrollWidth = aColorSet.GetScrollWidth(); + if( nScrollWidth > 0 ) + { + // Spalten mit ScrollBar berechnen + nCols = (USHORT) ( ( aSize.Width() - nScrollWidth ) / aItemSize.Width() ); + } + aColorSet.SetColCount( nCols ); + + if( IsFloatingMode() ) + aColorSet.SetLineCount( nLines ); + else + { + aColorSet.SetLineCount( 0 ); // sonst wird LineHeight ignoriert + aColorSet.SetItemHeight( aItemSize.Height() ); + } + + aColorSet.SetPosSizePixel( Point( 2, 2 ), aSize ); +} + +/************************************************************************* +|* +|* SvxColorDockingWindow: Close +|* +\************************************************************************/ + +BOOL SvxColorDockingWindow::Close() +{ + SfxBoolItem aItem( SID_COLOR_CONTROL, FALSE ); + GetBindings().GetDispatcher()->Execute( + SID_COLOR_CONTROL, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); + SfxDockingWindow::Close(); + return( TRUE ); +} + +/************************************************************************* +|* +|* SelectHdl +|* +\************************************************************************/ + +IMPL_LINK( SvxColorDockingWindow, SelectHdl, void *, EMPTYARG ) +{ + SfxDispatcher* pDispatcher = GetBindings().GetDispatcher(); + USHORT nPos = aColorSet.GetSelectItemId(); + Color aColor( aColorSet.GetItemColor( nPos ) ); + String aStr( aColorSet.GetItemText( nPos ) ); + + if (aColorSet.IsLeftButton()) + { + if ( nLeftSlot == SID_ATTR_FILL_COLOR ) + { + if ( nPos == 1 ) // unsichtbar + { + XFillStyleItem aXFillStyleItem( XFILL_NONE ); + pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L ); + } + else + { + BOOL bDone = FALSE; + + // Wenn wir eine DrawView haben und uns im TextEdit-Modus befinden, + // wird nicht die Flaechen-, sondern die Textfarbe zugewiesen + SfxViewShell* pViewSh = SfxViewShell::Current(); + if ( pViewSh ) + { + SdrView* pView = pViewSh->GetDrawView(); + if ( pView && pView->IsTextEdit() ) + { + SvxColorItem aTextColorItem( aColor, SID_ATTR_CHAR_COLOR ); + pDispatcher->Execute( + SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aTextColorItem, 0L ); + bDone = TRUE; + } + } + if ( !bDone ) + { + XFillStyleItem aXFillStyleItem( XFILL_SOLID ); + XFillColorItem aXFillColorItem( aStr, aColor ); + pDispatcher->Execute( + nLeftSlot, SFX_CALLMODE_RECORD, &aXFillColorItem, &aXFillStyleItem, 0L ); + } + } + } + else if ( nPos != 1 ) // unsichtbar + { + SvxColorItem aLeftColorItem( aColor, nLeftSlot ); + pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aLeftColorItem, 0L ); + } + } + else + { + if ( nRightSlot == SID_ATTR_LINE_COLOR ) + { + if( nPos == 1 ) // unsichtbar + { + XLineStyleItem aXLineStyleItem( XLINE_NONE ); + pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L ); + } + else + { + // Sollte der LineStyle unsichtbar sein, so wird er auf SOLID gesetzt + SfxViewShell* pViewSh = SfxViewShell::Current(); + if ( pViewSh ) + { + SdrView* pView = pViewSh->GetDrawView(); + if ( pView ) + { + SfxItemSet aAttrSet( pView->GetModel()->GetItemPool() ); + pView->GetAttributes( aAttrSet ); + if ( aAttrSet.GetItemState( XATTR_LINESTYLE ) != SFX_ITEM_DONTCARE ) + { + XLineStyle eXLS = (XLineStyle) + ( (const XLineStyleItem&)aAttrSet.Get( XATTR_LINESTYLE ) ).GetValue(); + if ( eXLS == XLINE_NONE ) + { + XLineStyleItem aXLineStyleItem( XLINE_SOLID ); + pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L ); + } + } + } + } + + XLineColorItem aXLineColorItem( aStr, aColor ); + pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineColorItem, 0L ); + } + } + else if ( nPos != 1 ) // unsichtbar + { + SvxColorItem aRightColorItem( aColor, nRightSlot ); + pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aRightColorItem, 0L ); + } + } + + return 0; +} + +/************************************************************************* +|* +|* Resizing +|* +\************************************************************************/ + + +void SvxColorDockingWindow::Resizing( Size& rNewSize ) +{ + rNewSize.Width() -= 4; + rNewSize.Height() -= 4; + + // Spalten und Reihen ermitteln + nCols = (USHORT) ( (float) rNewSize.Width() / (float) aItemSize.Width() + 0.5 ); + nLines = (USHORT) ( (float) rNewSize.Height() / (float) aItemSize.Height() + 0.5 ); + if( nLines == 0 ) + nLines = 1; + + // Scrollbar setzen/entfernen + WinBits nBits = aColorSet.GetStyle(); + if ( nLines * nCols >= nCount ) + nBits &= ~WB_VSCROLL; + else + nBits |= WB_VSCROLL; + aColorSet.SetStyle( nBits ); + + // ScrollBar ? + long nScrollWidth = aColorSet.GetScrollWidth(); + if( nScrollWidth > 0 ) + { + // Spalten mit ScrollBar berechnen + nCols = (USHORT) ( ( ( (float) rNewSize.Width() - (float) nScrollWidth ) ) + / (float) aItemSize.Width() + 0.5 ); + } + if( nCols <= 1 ) + nCols = 2; + + // Max. Reihen anhand der gegebenen Spalten berechnen + long nMaxLines = nCount / nCols; + if( nCount % nCols ) + nMaxLines++; + + nLines = sal::static_int_cast< USHORT >( + std::min< long >( nLines, nMaxLines ) ); + + // Groesse des Windows setzen + rNewSize.Width() = nCols * aItemSize.Width() + nScrollWidth + 4; + rNewSize.Height() = nLines * aItemSize.Height() + 4; +} + +/************************************************************************* +|* +|* Resize +|* +\************************************************************************/ + +void SvxColorDockingWindow::Resize() +{ + if ( !IsFloatingMode() || !GetFloatingWindow()->IsRollUp() ) + SetSize(); + SfxDockingWindow::Resize(); +} + + + +void SvxColorDockingWindow::GetFocus (void) +{ + SfxDockingWindow::GetFocus(); + // Grab the focus to the color value set so that it can be controlled + // with the keyboard. + aColorSet.GrabFocus(); +} + +long SvxColorDockingWindow::Notify( NotifyEvent& rNEvt ) +{ + long nRet = 0; + if( ( rNEvt.GetType() == EVENT_KEYINPUT ) ) + { + KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); + USHORT nKeyCode = aKeyEvt.GetKeyCode().GetCode(); + switch( nKeyCode ) + { + case KEY_ESCAPE: + GrabFocusToDocument(); + nRet = 1; + break; + } + } + + return nRet ? nRet : SfxDockingWindow::Notify( rNEvt ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/colrctrl.src b/svx/source/tbxctrls/colrctrl.src new file mode 100644 index 000000000000..909ce34ea607 --- /dev/null +++ b/svx/source/tbxctrls/colrctrl.src @@ -0,0 +1,83 @@ +/************************************************************************* + * + * 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> +#include "helpid.hrc" + // pragma ---------------------------------------------------------------- + + // RID_SVXCTRL_COLOR ----------------------------------------------------- +DockingWindow RID_SVXCTRL_COLOR +{ + HelpID = HID_CTRL_COLOR ; + Border = TRUE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + Dockable = TRUE ; + EnableResizing = TRUE ; + Size = MAP_APPFONT ( 150 , 22 ) ; + Text [ en-US ] = "Colors" ; + Control 1 + { + HelpId = HID_COLOR_CTL_COLORS ; + Pos = MAP_APPFONT ( 2 , 2 ) ; + Size = MAP_APPFONT ( 146 , 18 ) ; + Border = FALSE ; + }; +}; + // ********************************************************************** EOF + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx new file mode 100644 index 000000000000..61dcededf870 --- /dev/null +++ b/svx/source/tbxctrls/extrusioncontrols.cxx @@ -0,0 +1,1052 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 headers + +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/awt/MenuItemStyle.hpp> +#include <com/sun/star/awt/XPopupMenuExtended.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> + +#include <osl/mutex.hxx> + +#include <vcl/toolbox.hxx> +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> +#include <svl/eitem.hxx> +#include <vcl/settings.hxx> +#include <svl/intitem.hxx> +#include <editeng/colritem.hxx> +#include <tools/urlobj.hxx> + +#include <svx/dialogs.hrc> +#include <svx/svdtrans.hxx> +#include <svx/sdasitm.hxx> +#include <svx/dialmgr.hxx> +#include "svx/extrusioncolorcontrol.hxx" + +#include "helpid.hrc" +#include "extrusioncontrols.hxx" +#include "extrusioncontrols.hrc" +#include "colorwindow.hxx" +#include "extrusiondepthdialog.hxx" + +//////////// + +using ::rtl::OUString; +using ::svtools::ToolbarMenu; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::graphic; + +namespace svx +{ + +/************************************************************************* +|* +|* ExtrusionDirectionWindow +|* +\************************************************************************/ + +static sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 }; + +ExtrusionDirectionWindow::ExtrusionDirectionWindow( + svt::ToolboxController& rController, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + Window* pParentWindow +) +: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION )) , + mrController( rController ) , + maImgPerspective( SVX_RES( IMG_PERSPECTIVE ) ) , + maImgParallel( SVX_RES( IMG_PARALLEL ) ) , + msExtrusionDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" ) ) , + msExtrusionProjection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" ) ) +{ + SetHelpId( HID_MENU_EXTRUSION_DIRECTION ); + + USHORT i; + for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ ) + { + maImgDirection[i] = Image( SVX_RES( IMG_DIRECTION + i ) ); + } + + SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) ); + mpDirectionSet = createEmptyValueSetControl(); + mpDirectionSet->SetHelpId( HID_VALUESET_EXTRUSION_DIRECTION ); + + mpDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) ); + mpDirectionSet->SetColCount( 3 ); + mpDirectionSet->EnableFullItemMode( FALSE ); + + for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ ) + { + String aText( SVX_RES( STR_DIRECTION + i ) ); + mpDirectionSet->InsertItem( i+1, maImgDirection[ i ], aText ); + } + + mpDirectionSet->SetOutputSizePixel( Size( 72, 72 ) ); + + appendEntry( 2, mpDirectionSet ); + appendSeparator(); + appendEntry( 0, String( SVX_RES( STR_PERSPECTIVE ) ), maImgPerspective ); + appendEntry( 1, String( SVX_RES( STR_PARALLEL ) ), maImgParallel ); + + SetOutputSizePixel( getMenuSize() ); + + FreeResource(); + + AddStatusListener( msExtrusionDirection ); + AddStatusListener( msExtrusionProjection ); +} + +void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ToolbarMenu::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + for( USHORT i = DIRECTION_NW; i <= DIRECTION_SE; i++ ) + { + mpDirectionSet->SetItemImage( i+1, maImgDirection[ i ] ); + } + + setEntryImage( 0, maImgPerspective ); + setEntryImage( 1, maImgParallel ); + } +} + +// ----------------------------------------------------------------------- + +void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled ) +{ + if( mpDirectionSet ) + { + USHORT nItemId; + for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ ) + { + if( gSkewList[nItemId] == nSkew ) + break; + } + + if( nItemId <= DIRECTION_SE ) + { + mpDirectionSet->SelectItem( nItemId+1 ); + } + else + { + mpDirectionSet->SetNoSelection(); + } + } + enableEntry( 2, bEnabled ); +} + +// ----------------------------------------------------------------------- + +void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled ) +{ + checkEntry( 0, (nProjection == 0) && bEnabled ); + checkEntry( 1, (nProjection == 1 ) && bEnabled ); + enableEntry( 0, bEnabled ); + enableEntry( 1, bEnabled ); +} + +// ----------------------------------------------------------------------- + +void SAL_CALL ExtrusionDirectionWindow::statusChanged( + const ::com::sun::star::frame::FeatureStateEvent& Event +) throw ( ::com::sun::star::uno::RuntimeException ) +{ + if( Event.FeatureURL.Main.equals( msExtrusionDirection ) ) + { + if( !Event.IsEnabled ) + { + implSetDirection( -1, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetDirection( nValue, true ); + } + } + else if( Event.FeatureURL.Main.equals( msExtrusionProjection ) ) + { + if( !Event.IsEnabled ) + { + implSetProjection( -1, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetProjection( nValue, true ); + } + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl ) +{ + if ( IsInPopupMode() ) + EndPopupMode(); + + if( pControl == mpDirectionSet ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msExtrusionDirection.copy(5); + aArgs[0].Value <<= (sal_Int32)gSkewList[mpDirectionSet->GetSelectItemId()-1]; + + mrController.dispatchCommand( msExtrusionDirection, aArgs ); + } + else + { + int nProjection = getSelectedEntryId(); + if( (nProjection >= 0) && (nProjection < 2 ) ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msExtrusionProjection.copy(5); + aArgs[0].Value <<= (sal_Int32)nProjection; + + mrController.dispatchCommand( msExtrusionProjection, aArgs ); + implSetProjection( nProjection, true ); + } + } + + return 0; +} + +// ======================================================================= +// ExtrusionDirectionControl +// ======================================================================= + +ExtrusionDirectionControl::ExtrusionDirectionControl( + const Reference< lang::XMultiServiceFactory >& rServiceManager +) : svt::PopupWindowController( + rServiceManager, + Reference< frame::XFrame >(), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) ) + ) +{ +} + +// ----------------------------------------------------------------------- + +::Window* ExtrusionDirectionControl::createPopupWindow( ::Window* pParent ) +{ + return new ExtrusionDirectionWindow( *this, m_xFrame, pParent ); +} + +// ----------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionDirectionControl_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDirectionController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDirectionControl_createInstance( + const Reference< XMultiServiceFactory >& rSMgr +) throw( RuntimeException ) +{ + return *new ExtrusionDirectionControl( rSMgr ); +} + +// -------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionDirectionControl::getImplementationName( ) throw (RuntimeException) +{ + return ExtrusionDirectionControl_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionDirectionControl::getSupportedServiceNames( ) throw (RuntimeException) +{ + return ExtrusionDirectionControl_getSupportedServiceNames(); +} + +// #################################################################### + +ExtrusionDepthDialog::ExtrusionDepthDialog( Window* pParent, double fDepth, FieldUnit eDefaultUnit ) +: ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_EXTRUSION_DEPTH ) ), + maFLDepth( this, SVX_RES( FL_DEPTH ) ), + maMtrDepth( this, SVX_RES( MTR_DEPTH ) ), + maOKButton( this, SVX_RES( BTN_OK ) ), + maCancelButton( this, SVX_RES( BTN_CANCEL ) ), + maHelpButton( this, SVX_RES( BTN_HELP ) ) +{ + bool bMetric = IsMetric( eDefaultUnit ); + maMtrDepth.SetUnit( bMetric ? FUNIT_CM : FUNIT_INCH ); + maMtrDepth.SetValue( (int) fDepth * 100, FUNIT_100TH_MM ); + + FreeResource(); +} + +ExtrusionDepthDialog::~ExtrusionDepthDialog() +{ +} + +double ExtrusionDepthDialog::getDepth() const +{ + return (double)( maMtrDepth.GetValue( FUNIT_100TH_MM ) ) / 100.0; +} + +// #################################################################### + +double aDepthListInch[] = { 0, 1270,2540,5080,10160 }; +double aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 }; + +ExtrusionDepthWindow::ExtrusionDepthWindow( + svt::ToolboxController& rController, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + Window* pParentWindow +) : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH )) + , mrController( rController ) + , maImgDepth0( SVX_RES( IMG_DEPTH_0 ) ) + , maImgDepth1( SVX_RES( IMG_DEPTH_1 ) ) + , maImgDepth2( SVX_RES( IMG_DEPTH_2 ) ) + , maImgDepth3( SVX_RES( IMG_DEPTH_3 ) ) + , maImgDepth4( SVX_RES( IMG_DEPTH_4 ) ) + , maImgDepthInfinity( SVX_RES( IMG_DEPTH_INFINITY ) ) + , mfDepth( -1.0 ) + , msExtrusionDepth( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" ) ) + , msMetricUnit( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ) ) +{ + SetHelpId( HID_MENU_EXTRUSION_DEPTH ); + + SetSelectHdl( LINK( this, ExtrusionDepthWindow, SelectHdl ) ); + + String aEmpty; + appendEntry( 0, aEmpty, maImgDepth0 ); + appendEntry( 1, aEmpty, maImgDepth1 ); + appendEntry( 2, aEmpty, maImgDepth2 ); + appendEntry( 3, aEmpty, maImgDepth3 ); + appendEntry( 4, aEmpty, maImgDepth4 ); + appendEntry( 5, String( SVX_RES( STR_INFINITY ) ), maImgDepthInfinity ); + appendEntry( 6, String( SVX_RES( STR_CUSTOM ) ) ); + + SetOutputSizePixel( getMenuSize() ); + + FreeResource(); + + AddStatusListener( msExtrusionDepth ); + AddStatusListener( msMetricUnit ); +} + +// ----------------------------------------------------------------------- + +void ExtrusionDepthWindow::implSetDepth( double fDepth ) +{ + mfDepth = fDepth; + int i; + for( i = 0; i < 7; i++ ) + { + if( i == 5 ) + { + checkEntry( i, fDepth >= 338666 ); + } + else if( i != 6 ) + { + checkEntry( i, (fDepth == (IsMetric( meUnit ) ? aDepthListMM[i] : aDepthListInch[i]) ) ); + } + } +} + +// ----------------------------------------------------------------------- + +void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit ) +{ + meUnit = eUnit; + USHORT nResource = IsMetric( eUnit ) ? RID_SVXSTR_DEPTH_0 : RID_SVXSTR_DEPTH_0_INCH; + + for( int i = 0; i < 5; i++ ) + { + String aStr( SVX_RES( nResource + i ) ); + setEntryText( i, aStr ); + }; +} + +// ----------------------------------------------------------------------- + +void SAL_CALL ExtrusionDepthWindow::statusChanged( + const ::com::sun::star::frame::FeatureStateEvent& Event +) throw ( ::com::sun::star::uno::RuntimeException ) +{ + if( Event.FeatureURL.Main.equals( msExtrusionDepth ) ) + { + if( !Event.IsEnabled ) + { + implSetDepth( 0 ); + } + else + { + double fValue = 0.0; + if( Event.State >>= fValue ) + implSetDepth( fValue ); + } + } + else if( Event.FeatureURL.Main.equals( msMetricUnit ) ) + { + if( Event.IsEnabled ) + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + { + implFillStrings( static_cast<FieldUnit>(nValue) ); + if( mfDepth >= 0.0 ) + implSetDepth( mfDepth ); + } + } + } +} + +// ----------------------------------------------------------------------- + +void ExtrusionDepthWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ToolbarMenu::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + setEntryImage( 0, maImgDepth0 ); + setEntryImage( 1, maImgDepth1 ); + setEntryImage( 2, maImgDepth2 ); + setEntryImage( 3, maImgDepth3 ); + setEntryImage( 4, maImgDepth4 ); + setEntryImage( 5, maImgDepthInfinity ); + } +} + + +// ----------------------------------------------------------------------- + +IMPL_LINK( ExtrusionDepthWindow, SelectHdl, void *, EMPTYARG ) +{ + int nSelected = getSelectedEntryId(); + if( nSelected != -1 ) + { + if( nSelected == 6 ) + { + if ( IsInPopupMode() ) + EndPopupMode(); + + const rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthDialog" )); + + Any a; + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Depth" )); + aArgs[0].Value <<= mfDepth; + aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" )); + aArgs[1].Value <<= static_cast<sal_Int32>( meUnit ); + + mrController.dispatchCommand( aCommand, aArgs ); + } + else + { + double fDepth; + + if( nSelected == 5 ) + { + fDepth = 338666.6; + } + else + { + fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected]; + } + + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msExtrusionDepth.copy(5); + aArgs[0].Value <<= fDepth; + + mrController.dispatchCommand( msExtrusionDepth, aArgs ); + implSetDepth( fDepth ); + + if ( IsInPopupMode() ) + EndPopupMode(); + } + } + return 0; +} + +// ======================================================================= +// ExtrusionDirectionControl +// ======================================================================= + +ExtrusionDepthController::ExtrusionDepthController( + const Reference< lang::XMultiServiceFactory >& rServiceManager +) : svt::PopupWindowController( + rServiceManager, + Reference< frame::XFrame >(), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthFloater" ) ) + ) +{ +} + +// ----------------------------------------------------------------------- + +::Window* ExtrusionDepthController::createPopupWindow( ::Window* pParent ) +{ + return new ExtrusionDepthWindow( *this, m_xFrame, pParent ); +} + + +// ----------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionDepthController_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDepthController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDepthController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) +{ + return *new ExtrusionDepthController( rSMgr ); +} + +// -------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionDepthController::getImplementationName( ) throw (RuntimeException) +{ + return ExtrusionDepthController_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionDepthController::getSupportedServiceNames( ) throw (RuntimeException) +{ + return ExtrusionDepthController_getSupportedServiceNames(); +} + + +// #################################################################### + +// ------------------------------------------------------------------------- + +ExtrusionLightingWindow::ExtrusionLightingWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) +: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING )) +, mrController( rController ) +, maImgBright( SVX_RES( IMG_LIGHTING_BRIGHT ) ) +, maImgNormal( SVX_RES( IMG_LIGHTING_NORMAL ) ) +, maImgDim( SVX_RES( IMG_LIGHTING_DIM ) ) +, mnLevel( 0 ) +, mbLevelEnabled( false ) +, mnDirection( FROM_FRONT ) +, mbDirectionEnabled( false ) +, msExtrusionLightingDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" )) +, msExtrusionLightingIntensity( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" )) +{ + USHORT i; + for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ ) + { + if( i != FROM_FRONT ) + { + maImgLightingOff[ i ] = Image( SVX_RES( IMG_LIGHT_OFF + i ) ); + maImgLightingOn[ i ] = Image( SVX_RES( IMG_LIGHT_ON + i ) ); + } + maImgLightingPreview[i] = Image( SVX_RES( IMG_LIGHT_PREVIEW + i ) ); + } + + SetHelpId( HID_MENU_EXTRUSION_LIGHTING ); + SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) ); + + mpLightingSet = createEmptyValueSetControl(); + mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING ); + + mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) ); + mpLightingSet->SetColCount( 3 ); + mpLightingSet->EnableFullItemMode( FALSE ); + + for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ ) + { + if( i != FROM_FRONT ) + { + mpLightingSet->InsertItem( i+1, maImgLightingOff[i] ); + } + else + { + mpLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] ); + } + } + mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) ); + + appendEntry( 3, mpLightingSet ); + appendSeparator(); + appendEntry( 0, String( SVX_RES( STR_BRIGHT ) ), maImgBright ); + appendEntry( 1, String( SVX_RES( STR_NORMAL ) ), maImgNormal ); + appendEntry( 2, String( SVX_RES( STR_DIM ) ), maImgDim ); + + SetOutputSizePixel( getMenuSize() ); + + FreeResource(); + + AddStatusListener( msExtrusionLightingDirection ); + AddStatusListener( msExtrusionLightingIntensity ); +} + +// ----------------------------------------------------------------------- + +void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled ) +{ + mnLevel = nLevel; + mbLevelEnabled = bEnabled; + int i = 0; + for( i = 0; i < 3; i++ ) + { + checkEntry( i, (i == nLevel) && bEnabled ); + enableEntry( i, bEnabled ); + } +} + +// ----------------------------------------------------------------------- + +void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled ) +{ + mnDirection = nDirection; + mbDirectionEnabled = bEnabled; + + if( !bEnabled ) + nDirection = FROM_FRONT; + + USHORT nItemId; + for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ ) + { + if( nItemId == FROM_FRONT ) + { + mpLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] ); + } + else + { + mpLightingSet->SetItemImage( + nItemId + 1, + (USHORT)nDirection == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId] + ); + } + } + + enableEntry( 3, bEnabled ); +} + +// ----------------------------------------------------------------------- + +void SAL_CALL ExtrusionLightingWindow::statusChanged( + const ::com::sun::star::frame::FeatureStateEvent& Event +) throw ( ::com::sun::star::uno::RuntimeException ) +{ + if( Event.FeatureURL.Main.equals( msExtrusionLightingIntensity ) ) + { + if( !Event.IsEnabled ) + { + implSetIntensity( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetIntensity( nValue, true ); + } + } + else if( Event.FeatureURL.Main.equals( msExtrusionLightingDirection ) ) + { + if( !Event.IsEnabled ) + { + implSetDirection( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetDirection( nValue, true ); + } + } +} + +// ----------------------------------------------------------------------- + +void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ToolbarMenu::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + implSetDirection( mnDirection, mbDirectionEnabled ); + setEntryImage( 0, maImgBright ); + setEntryImage( 1, maImgNormal ); + setEntryImage( 2, maImgDim ); + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl ) +{ + if ( IsInPopupMode() ) + EndPopupMode(); + + if( pControl == this ) + { + int nLevel = getSelectedEntryId(); + if( nLevel >= 0 ) + { + if( nLevel != 3 ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msExtrusionLightingIntensity.copy(5); + aArgs[0].Value <<= (sal_Int32)nLevel; + + mrController.dispatchCommand( msExtrusionLightingIntensity, aArgs ); + + implSetIntensity( nLevel, true ); + } + } + } + else + { + sal_Int32 nDirection = mpLightingSet->GetSelectItemId(); + + if( (nDirection > 0) && (nDirection < 10) ) + { + nDirection--; + + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msExtrusionLightingDirection.copy(5); + aArgs[0].Value <<= (sal_Int32)nDirection; + + mrController.dispatchCommand( msExtrusionLightingDirection, aArgs ); + + implSetDirection( nDirection, true ); + } + + } + + return 0; +} + +// ======================================================================== + +ExtrusionLightingControl::ExtrusionLightingControl( + const Reference< lang::XMultiServiceFactory >& rServiceManager +) : svt::PopupWindowController( rServiceManager, + Reference< frame::XFrame >(), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) ) + ) +{ +} + +// ----------------------------------------------------------------------- + +::Window* ExtrusionLightingControl::createPopupWindow( ::Window* pParent ) +{ + return new ExtrusionLightingWindow( *this, m_xFrame, pParent ); +} + +// ----------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionLightingControl_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionLightingController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SAL_CALL ExtrusionLightingControl_createInstance( + const Reference< XMultiServiceFactory >& rSMgr +) throw( RuntimeException ) +{ + return *new ExtrusionLightingControl( rSMgr ); +} + +// -------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionLightingControl::getImplementationName( ) throw (RuntimeException) +{ + return ExtrusionLightingControl_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionLightingControl::getSupportedServiceNames( ) throw (RuntimeException) +{ + return ExtrusionLightingControl_getSupportedServiceNames(); +} + +// #################################################################### + +ExtrusionSurfaceWindow::ExtrusionSurfaceWindow( + svt::ToolboxController& rController, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + Window* pParentWindow +) : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE ) ) + , mrController( rController ) + , maImgSurface1( SVX_RES( IMG_WIRE_FRAME ) ) + , maImgSurface2( SVX_RES( IMG_MATTE ) ) + , maImgSurface3( SVX_RES( IMG_PLASTIC ) ) + , maImgSurface4( SVX_RES( IMG_METAL ) ) + , msExtrusionSurface( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" ) ) +{ + SetHelpId( HID_MENU_EXTRUSION_SURFACE ); + SetSelectHdl( LINK( this, ExtrusionSurfaceWindow, SelectHdl ) ); + + appendEntry( 0, String( SVX_RES( STR_WIREFRAME ) ), maImgSurface1 ); + appendEntry( 1, String( SVX_RES( STR_MATTE ) ), maImgSurface2 ); + appendEntry( 2, String( SVX_RES( STR_PLASTIC ) ), maImgSurface3 ); + appendEntry( 3, String( SVX_RES( STR_METAL ) ), maImgSurface4 ); + + SetOutputSizePixel( getMenuSize() ); + + FreeResource(); + + AddStatusListener( msExtrusionSurface ); +} + +// ----------------------------------------------------------------------- + +void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled ) +{ + int i; + for( i = 0; i < 4; i++ ) + { + checkEntry( i, (i == nSurface) && bEnabled ); + enableEntry( i, bEnabled ); + } +} + +// ----------------------------------------------------------------------- + +void SAL_CALL ExtrusionSurfaceWindow::statusChanged( + const ::com::sun::star::frame::FeatureStateEvent& Event +) throw ( ::com::sun::star::uno::RuntimeException ) +{ + if( Event.FeatureURL.Main.equals( msExtrusionSurface ) ) + { + if( !Event.IsEnabled ) + { + implSetSurface( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetSurface( nValue, true ); + } + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( ExtrusionSurfaceWindow, SelectHdl, void *, EMPTYARG ) +{ + if ( IsInPopupMode() ) + EndPopupMode(); + + sal_Int32 nSurface = getSelectedEntryId(); + if( nSurface >= 0 ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msExtrusionSurface.copy(5); + aArgs[0].Value <<= (sal_Int32)nSurface; + + mrController.dispatchCommand( msExtrusionSurface, aArgs ); + + implSetSurface( nSurface, true ); + } + + return 0; +} + +// ======================================================================== + +ExtrusionSurfaceControl::ExtrusionSurfaceControl( + const Reference< lang::XMultiServiceFactory >& rServiceManager +) +: svt::PopupWindowController( + rServiceManager, + Reference< frame::XFrame >(), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurfaceFloater" ) ) + ) +{ +} + +// ----------------------------------------------------------------------- + +::Window* ExtrusionSurfaceControl::createPopupWindow( ::Window* pParent ) +{ + return new ExtrusionSurfaceWindow( *this, m_xFrame, pParent ); +} + +// ----------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionSurfaceControl_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionSurfaceController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SAL_CALL ExtrusionSurfaceControl_createInstance( + const Reference< XMultiServiceFactory >& rSMgr +) throw( RuntimeException ) +{ + return *new ExtrusionSurfaceControl( rSMgr ); +} + +// -------------------------------------------------------------------- + +OUString SAL_CALL ExtrusionSurfaceControl::getImplementationName( ) throw (RuntimeException) +{ + return ExtrusionSurfaceControl_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ExtrusionSurfaceControl::getSupportedServiceNames( ) throw (RuntimeException) +{ + return ExtrusionSurfaceControl_getSupportedServiceNames(); +} + +//======================================================================== + +SFX_IMPL_TOOLBOX_CONTROL( ExtrusionColorControl, SvxColorItem ); + +ExtrusionColorControl::ExtrusionColorControl( + USHORT nSlotId, USHORT nId, ToolBox& rTbx ) +: SfxToolBoxControl ( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); + mpBtnUpdater = new ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW ); +} + +// ----------------------------------------------------------------------- + +ExtrusionColorControl::~ExtrusionColorControl() +{ + delete mpBtnUpdater; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType ExtrusionColorControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* ExtrusionColorControl::CreatePopupWindow() +{ + SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Extrusion3DColor" )), + SID_EXTRUSION_3D_COLOR, + m_xFrame, + SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR ), + &GetToolBox() ); + pColorWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); + pColorWin->StartSelection(); + SetPopupWindow( pColorWin ); + return pColorWin; +} + +// ----------------------------------------------------------------------- + +void ExtrusionColorControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + + if( nSID == SID_EXTRUSION_3D_COLOR ) + { + const SvxColorItem* pItem = 0; + + if( SFX_ITEM_DONTCARE != eState ) + pItem = PTR_CAST( SvxColorItem, pState ); + + if ( pItem ) + mpBtnUpdater->Update( pItem->GetValue()); + } + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/extrusioncontrols.hrc b/svx/source/tbxctrls/extrusioncontrols.hrc new file mode 100644 index 000000000000..9ae43248a499 --- /dev/null +++ b/svx/source/tbxctrls/extrusioncontrols.hrc @@ -0,0 +1,95 @@ +/************************************************************************* + * + * 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> + +// enum to index light images +#define FROM_TOP_LEFT 0 +#define FROM_TOP 1 +#define FROM_TOP_RIGHT 2 +#define FROM_LEFT 3 +#define FROM_FRONT 4 +#define FROM_RIGHT 5 +#define FROM_BOTTOM_LEFT 6 +#define FROM_BOTTOM 7 +#define FROM_BOTTOM_RIGHT 8 + +#define DIRECTION_NW 0 +#define DIRECTION_N 1 +#define DIRECTION_NE 2 +#define DIRECTION_W 3 +#define DIRECTION_NONE 4 +#define DIRECTION_E 5 +#define DIRECTION_SW 6 +#define DIRECTION_S 7 +#define DIRECTION_SE 8 + +#define STR_PERSPECTIVE 1 +#define STR_PARALLEL 2 +#define STR_CUSTOM 3 +#define STR_INFINITY 4 + +#define STR_BRIGHT 15 +#define STR_NORMAL 16 +#define STR_DIM 17 + +#define STR_WIREFRAME 18 +#define STR_MATTE 19 +#define STR_PLASTIC 20 +#define STR_METAL 21 + +#define STR_DIRECTION 30 // needs 10 resource ids + +#define IMG_DIRECTION 1 // needs 10 resource ids + +#define IMG_DEPTH_0 19 +#define IMG_DEPTH_1 20 +#define IMG_DEPTH_2 21 +#define IMG_DEPTH_3 22 +#define IMG_DEPTH_4 23 +#define IMG_DEPTH_INFINITY 24 + +#define IMG_PERSPECTIVE 31 +#define IMG_PARALLEL 33 + +#define IMG_WIRE_FRAME 35 +#define IMG_MATTE 36 +#define IMG_PLASTIC 37 +#define IMG_METAL 38 + +#define IMG_LIGHT_OFF 50 // needs 10 resource ids +#define IMG_LIGHT_ON 60 // needs 10 resource ids +#define IMG_LIGHT_PREVIEW 70 // needs 10 resource ids + +#define IMG_LIGHTING_BRIGHT 110 +#define IMG_LIGHTING_NORMAL 111 +#define IMG_LIGHTING_DIM 112 + +#define FL_DEPTH 1 +#define MTR_DEPTH 2 +#define BTN_OK 3 +#define BTN_CANCEL 4 +#define BTN_HELP 5 diff --git a/svx/source/tbxctrls/extrusioncontrols.hxx b/svx/source/tbxctrls/extrusioncontrols.hxx new file mode 100644 index 000000000000..35993c461beb --- /dev/null +++ b/svx/source/tbxctrls/extrusioncontrols.hxx @@ -0,0 +1,240 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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. + * + ************************************************************************/ +#ifndef _SVX_EXTRUSION_CONTROLS_HXX +#define _SVX_EXTRUSION_CONTROLS_HXX + +#include "svx/svxdllapi.h" + +#include <svtools/valueset.hxx> +#include <svtools/svtreebx.hxx> +#include <vcl/button.hxx> +#include <vcl/dialog.hxx> +#include <vcl/field.hxx> +#include <vcl/fixed.hxx> + +#include <svtools/toolbarmenu.hxx> +#include <svtools/popupwindowcontroller.hxx> +#include <svtools/popupmenucontrollerbase.hxx> + +class SfxBindings; +class SfxStatusForwarder; + +//======================================================================== + +namespace svx +{ +class ToolboxButtonColorUpdater; + +class ExtrusionDirectionWindow : public svtools::ToolbarMenu +{ +public: + ExtrusionDirectionWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ); + + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +private: + svt::ToolboxController& mrController; + ValueSet* mpDirectionSet; + + Image maImgDirection[9]; + Image maImgPerspective; + Image maImgParallel; + + const rtl::OUString msExtrusionDirection; + const rtl::OUString msExtrusionProjection; + + DECL_LINK( SelectHdl, void * ); + void FillValueSet(); + + void implSetDirection( sal_Int32 nSkew, bool bEnabled = true ); + void implSetProjection( sal_Int32 nProjection, bool bEnabled = true ); + +}; + +//======================================================================== + +class ExtrusionDirectionControl : public svt::PopupWindowController +{ +public: + ExtrusionDirectionControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + + using svt::PopupWindowController::createPopupWindow; +}; + +//======================================================================== + +class ExtrusionDepthWindow : public svtools::ToolbarMenu +{ +private: + svt::ToolboxController& mrController; + + Image maImgDepth0; + Image maImgDepth1; + Image maImgDepth2; + Image maImgDepth3; + Image maImgDepth4; + Image maImgDepthInfinity; + + FieldUnit meUnit; + double mfDepth; + + const rtl::OUString msExtrusionDepth; + const rtl::OUString msMetricUnit; + + DECL_LINK( SelectHdl, void * ); + + void implFillStrings( FieldUnit eUnit ); + void implSetDepth( double fDepth ); + +public: + ExtrusionDepthWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ); + + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); +}; + +//======================================================================== + +class ExtrusionDepthController : public svt::PopupWindowController +{ +public: + ExtrusionDepthController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + + using svt::PopupWindowController::createPopupWindow; +}; + +//======================================================================== + +class ExtrusionLightingWindow : public svtools::ToolbarMenu +{ +private: + svt::ToolboxController& mrController; + ValueSet* mpLightingSet; + + Image maImgLightingOff[9]; + Image maImgLightingOn[9]; + Image maImgLightingPreview[9]; + + Image maImgBright; + Image maImgNormal; + Image maImgDim; + + int mnLevel; + bool mbLevelEnabled; + int mnDirection; + bool mbDirectionEnabled; + + const rtl::OUString msExtrusionLightingDirection; + const rtl::OUString msExtrusionLightingIntensity; + + void implSetIntensity( int nLevel, bool bEnabled ); + void implSetDirection( int nDirection, bool bEnabled ); + + DECL_LINK( SelectHdl, void * ); +public: + ExtrusionLightingWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ); + + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); +}; + +//======================================================================== + +class ExtrusionLightingControl : public svt::PopupWindowController +{ +public: + ExtrusionLightingControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + + using svt::PopupWindowController::createPopupWindow; +}; + +//======================================================================== + +class ExtrusionSurfaceWindow : public svtools::ToolbarMenu +{ +private: + svt::ToolboxController& mrController; + + Image maImgSurface1; + Image maImgSurface2; + Image maImgSurface3; + Image maImgSurface4; + + const rtl::OUString msExtrusionSurface; + + DECL_LINK( SelectHdl, void * ); + + void implSetSurface( int nSurface, bool bEnabled ); + +public: + ExtrusionSurfaceWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ); + + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); +}; + +//======================================================================== + +class ExtrusionSurfaceControl : public svt::PopupWindowController +{ +public: + ExtrusionSurfaceControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + + using svt::PopupWindowController::createPopupWindow; +}; + +//======================================================================== + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/extrusioncontrols.src b/svx/source/tbxctrls/extrusioncontrols.src new file mode 100644 index 000000000000..55c9ec508d5d --- /dev/null +++ b/svx/source/tbxctrls/extrusioncontrols.src @@ -0,0 +1,548 @@ +/************************************************************************* + * + * 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> +#include "extrusioncontrols.hrc" + +#define MASKCOLOR MaskColor = Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; }; + +DockingWindow RID_SVXFLOAT_EXTRUSION_DIRECTION +{ + Border = FALSE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = FALSE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + + Text [ en-US ] = "Extrusion Direction" ; + + Image IMG_DIRECTION + DIRECTION_NW + { + ImageBitmap = Bitmap { File = "directionnorthwest_22.bmp" ; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_N + { + ImageBitmap = Bitmap { File = "directionnorth_22.bmp" ; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_NE + { + ImageBitmap = Bitmap { File = "directionnortheast_22.bmp"; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_W + { + ImageBitmap = Bitmap { File = "directionwest_22.bmp"; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_NONE + { + ImageBitmap = Bitmap { File = "directionstraight_22.bmp"; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_E + { + ImageBitmap = Bitmap { File = "directioneast_22.bmp"; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_SW + { + ImageBitmap = Bitmap { File = "directionsouthwest_22.bmp"; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_S + { + ImageBitmap = Bitmap { File = "directionsouth_22.bmp"; }; + MASKCOLOR + }; + Image IMG_DIRECTION + DIRECTION_SE + { + ImageBitmap = Bitmap { File = "directionsoutheast_22.bmp"; }; + MASKCOLOR + }; + Image IMG_PERSPECTIVE + { + ImageBitmap = Bitmap { File = "perspective_16.bmp"; }; + MASKCOLOR + }; + Image IMG_PARALLEL + { + ImageBitmap = Bitmap { File = "parallel_16.bmp"; }; + MASKCOLOR + }; + + String STR_PERSPECTIVE + { + Text [ en-US ] = "~Perspective" ; + }; + + String STR_PARALLEL + { + Text [ en-US ] = "P~arallel" ; + }; + String STR_DIRECTION + DIRECTION_NW + { + Text [ en-US ] = "Extrusion North-West"; + }; + String STR_DIRECTION + DIRECTION_N + { + Text [ en-US ] = "Extrusion North"; + }; + String STR_DIRECTION + DIRECTION_NE + { + Text [ en-US ] = "Extrusion North-East"; + }; + String STR_DIRECTION + DIRECTION_W + { + Text [ en-US ] = "Extrusion West"; + }; + String STR_DIRECTION + DIRECTION_NONE + { + Text [ en-US ] = "Extrusion Backwards"; + }; + String STR_DIRECTION + DIRECTION_E + { + Text [ en-US ] = "Extrusion East"; + }; + String STR_DIRECTION + DIRECTION_SW + { + Text [ en-US ] = "Extrusion South-West"; + }; + String STR_DIRECTION + DIRECTION_S + { + Text [ en-US ] = "Extrusion South"; + }; + String STR_DIRECTION + DIRECTION_SE + { + Text [ en-US ] = "Extrusion South-East"; + }; +}; + +DockingWindow RID_SVXFLOAT_EXTRUSION_DEPTH +{ + Border = FALSE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = FALSE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + + Text [ en-US ] = "Extrusion Depth" ; + + String STR_CUSTOM + { + Text [ en-US ] = "~Custom..."; + }; + + String STR_INFINITY + { + Text [ en-US ] = "~Infinity"; + }; + + Image IMG_DEPTH_0 + { + ImageBitmap = Bitmap { File = "extrusion0inch_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_DEPTH_1 + { + ImageBitmap = Bitmap { File = "extrusion05inch_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_DEPTH_2 + { + ImageBitmap = Bitmap { File = "extrusion1inch_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_DEPTH_3 + { + ImageBitmap = Bitmap { File = "extrusion2inch_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_DEPTH_4 + { + ImageBitmap = Bitmap { File = "extrusion4inch_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_DEPTH_INFINITY + { + ImageBitmap = Bitmap { File = "extrusioninfinity_16.bmp"; }; + MASKCOLOR + }; +}; + + +DockingWindow RID_SVXFLOAT_EXTRUSION_LIGHTING +{ + Border = FALSE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = FALSE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + + Text [ en-US ] = "Extrusion Lighting" ; + + Image IMG_LIGHT_OFF + FROM_TOP_LEFT + { + ImageBitmap = Bitmap { File = "lightofffromtopleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_TOP + { + ImageBitmap = Bitmap { File = "lightofffromtop_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_TOP_RIGHT + { + ImageBitmap = Bitmap { File = "lightofffromtopright_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_LEFT + { + ImageBitmap = Bitmap { File = "lightofffromleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_RIGHT + { + ImageBitmap = Bitmap { File = "lightofffromright_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_BOTTOM_LEFT + { + ImageBitmap = Bitmap { File = "lightofffrombottomleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_BOTTOM + { + ImageBitmap = Bitmap { File = "lightofffrombottom_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_OFF + FROM_BOTTOM_RIGHT + { + ImageBitmap = Bitmap { File = "lightofffrombottomright_22.bmp"; }; + MASKCOLOR + }; + + Image IMG_LIGHT_ON + FROM_TOP_LEFT + { + ImageBitmap = Bitmap { File = "lightonfromtopleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_TOP + { + ImageBitmap = Bitmap { File = "lightonfromtop_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_TOP_RIGHT + { + ImageBitmap = Bitmap { File = "lightonfromtopright_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_LEFT + { + ImageBitmap = Bitmap { File = "lightonfromleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_RIGHT + { + ImageBitmap = Bitmap { File = "lightonfromright_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_BOTTOM_LEFT + { + ImageBitmap = Bitmap { File = "lightonfrombottomleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_BOTTOM + { + ImageBitmap = Bitmap { File = "lightonfrombottom_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_ON + FROM_BOTTOM_RIGHT + { + ImageBitmap = Bitmap { File = "lightonfrombottomright_22.bmp"; }; + MASKCOLOR + }; + + Image IMG_LIGHT_PREVIEW + FROM_TOP_LEFT + { + ImageBitmap = Bitmap { File = "lightfromtopleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_TOP + { + ImageBitmap = Bitmap { File = "lightfromtop_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_TOP_RIGHT + { + ImageBitmap = Bitmap { File = "lightfromtopright_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_LEFT + { + ImageBitmap = Bitmap { File = "lightfromleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_RIGHT + { + ImageBitmap = Bitmap { File = "lightfromright_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_FRONT + { + ImageBitmap = Bitmap { File = "lightfromfront_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_BOTTOM_LEFT + { + ImageBitmap = Bitmap { File = "lightfrombottomleft_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_BOTTOM + { + ImageBitmap = Bitmap { File = "lightfrombottom_22.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHT_PREVIEW + FROM_BOTTOM_RIGHT + { + ImageBitmap = Bitmap { File = "lightfrombottomright_22.bmp"; }; + MASKCOLOR + }; + + Image IMG_LIGHTING_BRIGHT + { + ImageBitmap = Bitmap { File = "brightlit_16.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHTING_NORMAL + { + ImageBitmap = Bitmap { File = "normallit_16.bmp"; }; + MASKCOLOR + }; + Image IMG_LIGHTING_DIM + { + ImageBitmap = Bitmap { File = "dimlit_16.bmp"; }; + MASKCOLOR + }; + + String STR_BRIGHT + { + Text [ en-US ] = "~Bright"; + }; + + String STR_NORMAL + { + Text [ en-US ] = "~Normal"; + }; + + String STR_DIM + { + Text [ en-US ] = "~Dim"; + }; +}; + +DockingWindow RID_SVXFLOAT_EXTRUSION_SURFACE +{ + Border = FALSE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = FALSE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + + Text [ en-US ] = "Extrusion Surface" ; + + String STR_WIREFRAME + { + Text [ en-US ] = "~Wire Frame"; + }; + + String STR_MATTE + { + Text [ en-US ] = "~Matt"; + }; + + String STR_PLASTIC + { + Text [ en-US ] = "~Plastic"; + }; + + String STR_METAL + { + Text [ en-US ] = "Me~tal"; + }; + + Image IMG_WIRE_FRAME + { + ImageBitmap = Bitmap { File = "wireframe_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_MATTE + { + ImageBitmap = Bitmap { File = "matte_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_PLASTIC + { + ImageBitmap = Bitmap { File = "plastic_16.bmp"; }; + MASKCOLOR + }; + + Image IMG_METAL + { + ImageBitmap = Bitmap { File = "metal_16.bmp"; }; + MASKCOLOR + }; +}; + +#define WIDTH 140 +#define HEIGHT (4 * 3 + 3 * 14) + +ModalDialog RID_SVX_MDLG_EXTRUSION_DEPTH +{ + OutputSize = TRUE; + SVLook = TRUE ; + Moveable = TRUE; + Closeable = TRUE; + + Size = MAP_APPFONT( WIDTH, HEIGHT ); + + Text [ en-US ] = "Extrusion Depth" ; + + FixedText FL_DEPTH + { + Pos = MAP_APPFONT ( 3 , 3 ) ; + Size = MAP_APPFONT ( WIDTH - 50 - 12 , 8 ) ; + Text [ en-US ] = "~Value" ; + }; + MetricField MTR_DEPTH + { + Border = FALSE ; + Pos = MAP_APPFONT ( 3 , 14 ) ; + Size = MAP_APPFONT ( WIDTH - 50 - 12, 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + Maximum = 338666 ; + StrictFormat = TRUE ; + DecimalDigits = 2 ; + Unit = FUNIT_MM ; + SpinSize = 10 ; + }; + OkButton BTN_OK + { + Pos = MAP_APPFONT ( WIDTH - 50 - 3 , 1 * 3 + 0 * 14 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + DefButton = TRUE ; + TabStop = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( WIDTH - 50 - 3 , 2 * 3 + 1 * 14 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + TabStop = TRUE ; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( WIDTH - 50 - 3 , 3 * 3 + 2 * 14 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + TabStop = TRUE ; + }; +}; + +String RID_SVXSTR_EXTRUSION_COLOR +{ + Text [ en-US ] = "Extrusion Color"; +}; + +String RID_SVXSTR_DEPTH_0 +{ + Text [ en-US ] = "~0 cm"; +}; + +String RID_SVXSTR_DEPTH_1 +{ + Text [ en-US ] = "~1 cm"; +}; + +String RID_SVXSTR_DEPTH_2 +{ + Text [ en-US ] = "~2.5 cm"; +}; + +String RID_SVXSTR_DEPTH_3 +{ + Text [ en-US ] = "~5 cm"; +}; + +String RID_SVXSTR_DEPTH_4 +{ + Text [ en-US ] = "10 ~cm"; +}; + +String RID_SVXSTR_DEPTH_0_INCH +{ + Text [ en-US ] = "0 inch"; +}; + +String RID_SVXSTR_DEPTH_1_INCH +{ + Text [ en-US ] = "0.~5 inch"; +}; + +String RID_SVXSTR_DEPTH_2_INCH +{ + Text [ en-US ] = "~1 inch"; +}; + +String RID_SVXSTR_DEPTH_3_INCH +{ + Text [ en-US ] = "~2 inch"; +}; + +String RID_SVXSTR_DEPTH_4_INCH +{ + Text [ en-US ] = "~4 inch"; +}; + + diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx new file mode 100644 index 000000000000..f130c84f9741 --- /dev/null +++ b/svx/source/tbxctrls/fillctrl.cxx @@ -0,0 +1,845 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 --------------------------------------------------------------- + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headers +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> +#include <rtl/ustring.hxx> + +#include <svx/dialogs.hrc> + +#define DELAY_TIMEOUT 300 + +#define TMP_STR_BEGIN '[' +#define TMP_STR_END ']' + +#include "drawitem.hxx" +#include "xattr.hxx" +#include <svx/xtable.hxx> +#include <svx/fillctrl.hxx> +#include <svx/itemwin.hxx> +#include <svx/dialmgr.hxx> +#include "helpid.hrc" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::lang; + +SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem ); + +/************************************************************************* +|* +|* SvxFillToolBoxControl +|* +\************************************************************************/ + +SvxFillToolBoxControl::SvxFillToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ), + + pStyleItem ( NULL ), + pColorItem ( NULL ), + pGradientItem ( NULL ), + pHatchItem ( NULL ), + pBitmapItem ( NULL ), + pFillControl ( NULL ), + pFillTypeLB ( NULL ), + pFillAttrLB ( NULL ), + bUpdate ( FALSE ), + bIgnoreStatusUpdate( FALSE ), + eLastXFS ( XFILL_NONE ) +{ + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GradientListState" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HatchListState" ))); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BitmapListState" ))); +} + +//======================================================================== + +SvxFillToolBoxControl::~SvxFillToolBoxControl() +{ + delete pStyleItem; + delete pColorItem; + delete pGradientItem; + delete pHatchItem; + delete pBitmapItem; +} + +//======================================================================== + +void SvxFillToolBoxControl::StateChanged( + + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) + +{ + bool bEnableControls = false; + + if ( bIgnoreStatusUpdate ) + return; + + if( eState == SFX_ITEM_DISABLED ) + { + if( nSID == SID_ATTR_FILL_STYLE ) + { + pFillTypeLB->Disable(); + pFillTypeLB->SetNoSelection(); + } + pFillAttrLB->Disable(); + pFillAttrLB->SetNoSelection(); + } + else + { + if ( SFX_ITEM_AVAILABLE == eState ) + { + if( nSID == SID_ATTR_FILL_STYLE ) + { + delete pStyleItem; + pStyleItem = (XFillStyleItem*) pState->Clone(); + pFillTypeLB->Enable(); + + eLastXFS = pFillTypeLB->GetSelectEntryPos(); + bUpdate = TRUE; + + XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); + pFillTypeLB->SelectEntryPos( + sal::static_int_cast< USHORT >( eXFS ) ); + pFillAttrLB->Enable(); + } + else if( pStyleItem ) + { + XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); + + if( nSID == SID_ATTR_FILL_COLOR ) + { + delete pColorItem; + pColorItem = (XFillColorItem*) pState->Clone(); + + if( eXFS == XFILL_SOLID ) + bEnableControls = true; + } + else if( nSID == SID_ATTR_FILL_GRADIENT ) + { + delete pGradientItem; + pGradientItem = (XFillGradientItem*) pState->Clone(); + + if( eXFS == XFILL_GRADIENT ) + bEnableControls = true; + } + else if( nSID == SID_ATTR_FILL_HATCH ) + { + delete pHatchItem; + pHatchItem = (XFillHatchItem*) pState->Clone(); + + if( eXFS == XFILL_HATCH ) + bEnableControls = true; + } + else if( nSID == SID_ATTR_FILL_BITMAP ) + { + delete pBitmapItem; + pBitmapItem = (XFillBitmapItem*) pState->Clone(); + + if( eXFS == XFILL_BITMAP ) + bEnableControls = true; + } + } + if( bEnableControls ) + { + //pFillTypeLB->Enable(); + pFillAttrLB->Enable(); + + bUpdate = TRUE; + } + + Update( pState ); + } + else + { + // leerer oder uneindeutiger Status + if( nSID == SID_ATTR_FILL_STYLE ) + { + pFillTypeLB->SetNoSelection(); + pFillAttrLB->Disable(); + pFillAttrLB->SetNoSelection(); + bUpdate = FALSE; + } + else + { + XFillStyle eXFS = XFILL_NONE; + if( pStyleItem ) + eXFS = (XFillStyle)pStyleItem->GetValue(); + if( !pStyleItem || + ( nSID == SID_ATTR_FILL_COLOR && eXFS == XFILL_SOLID ) || + ( nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT ) || + ( nSID == SID_ATTR_FILL_HATCH && eXFS == XFILL_HATCH ) || + ( nSID == SID_ATTR_FILL_BITMAP && eXFS == XFILL_BITMAP ) ) + { + pFillAttrLB->SetNoSelection(); + //bUpdate = FALSE; + } + } + } + } +} + +//======================================================================== + +void SvxFillToolBoxControl::IgnoreStatusUpdate( sal_Bool bSet ) +{ + bIgnoreStatusUpdate = bSet; +} + +//======================================================================== + +void SvxFillToolBoxControl::Update( const SfxPoolItem* pState ) +{ + if ( pStyleItem && pState && bUpdate ) + { + bUpdate = FALSE; + + XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); + + // Pruefen, ob Fuellstil schon vorher aktiv war + //if( eTmpXFS != eXFS ) + if( (XFillStyle) eLastXFS != eXFS ) + pFillControl->SelectFillTypeHdl( NULL ); + //eLastXFS = eXFS; + + switch( eXFS ) + { + case XFILL_NONE: + break; + + case XFILL_SOLID: + { + if ( pColorItem ) + { + String aString( pColorItem->GetName() ); + ::Color aColor = pColorItem->GetColorValue(); + + pFillAttrLB->SelectEntry( aString ); + + if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || + pFillAttrLB->GetSelectEntryColor() != aColor ) + pFillAttrLB->SelectEntry( aColor ); + + // NEU + // Pruefen, ob Eintrag nicht in der Liste ist + if( pFillAttrLB->GetSelectEntryPos() == + LISTBOX_ENTRY_NOTFOUND || + pFillAttrLB->GetSelectEntryColor() != aColor ) + { + USHORT nCount = pFillAttrLB->GetEntryCount(); + String aTmpStr; + if( nCount > 0 ) + { + //Letzter Eintrag wird auf temporaere Farbe geprueft + aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); + if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) + { + pFillAttrLB->RemoveEntry( nCount - 1 ); + } + } + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; + + //pFillAttrLB->SetUpdateMode( FALSE ); + USHORT nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr ); + //pFillAttrLB->SetUpdateMode( TRUE ); + pFillAttrLB->SelectEntryPos( nPos ); + } + // NEU + } + else + pFillAttrLB->SetNoSelection(); + } + break; + + case XFILL_GRADIENT: + { + if ( pGradientItem ) + { + String aString( pGradientItem->GetName() ); + pFillAttrLB->SelectEntry( aString ); + // NEU + // Pruefen, ob Eintrag nicht in der Liste ist + if( pFillAttrLB->GetSelectEntry() != aString ) + { + USHORT nCount = pFillAttrLB->GetEntryCount(); + String aTmpStr; + if( nCount > 0 ) + { + //Letzter Eintrag wird auf temporaeren Eintrag geprueft + aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); + if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) + { + pFillAttrLB->RemoveEntry( nCount - 1 ); + } + } + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; + + XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr ); + String aEmptyString = String(); + XGradientList aGradientList( aEmptyString ); + aGradientList.Insert( pEntry ); + aGradientList.SetDirty( FALSE ); + Bitmap* pBmp = aGradientList.CreateBitmapForUI( 0 ); + + if( pBmp ) + { + ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp ); + pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); + delete pBmp; + } + + aGradientList.Remove( 0 ); + delete pEntry; + } + // NEU + } + else + pFillAttrLB->SetNoSelection(); + } + break; + + case XFILL_HATCH: + { + if ( pHatchItem ) + { + String aString( pHatchItem->GetName() ); + pFillAttrLB->SelectEntry( aString ); + // NEU + // Pruefen, ob Eintrag nicht in der Liste ist + if( pFillAttrLB->GetSelectEntry() != aString ) + { + USHORT nCount = pFillAttrLB->GetEntryCount(); + String aTmpStr; + if( nCount > 0 ) + { + //Letzter Eintrag wird auf temporaeren Eintrag geprueft + aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); + if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) + { + pFillAttrLB->RemoveEntry( nCount - 1 ); + } + } + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; + + XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr ); + String aEmptyString = String(); + XHatchList aHatchList( aEmptyString ); + aHatchList.Insert( pEntry ); + aHatchList.SetDirty( FALSE ); + Bitmap* pBmp = aHatchList.CreateBitmapForUI( 0 ); + + if( pBmp ) + { + ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp ); + pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); + delete pBmp; + } + + aHatchList.Remove( 0 ); + delete pEntry; + } + // NEU + } + else + pFillAttrLB->SetNoSelection(); + } + break; + + case XFILL_BITMAP: + { + if ( pBitmapItem ) + // && + // SfxObjectShell::Current() && + // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) + { + String aString( pBitmapItem->GetName() ); + // Bitmap aBitmap( pBitmapItem->GetValue() ); + + // SvxBitmapListItem aItem( *(const SvxBitmapListItem*)( + // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) ); + pFillAttrLB->SelectEntry( aString ); + // NEU + // Pruefen, ob Eintrag nicht in der Liste ist + if( pFillAttrLB->GetSelectEntry() != aString ) + { + USHORT nCount = pFillAttrLB->GetEntryCount(); + String aTmpStr; + if( nCount > 0 ) + { + //Letzter Eintrag wird auf temporaeren Eintrag geprueft + aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); + if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) + { + pFillAttrLB->RemoveEntry( nCount - 1 ); + } + } + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; + + XBitmapEntry* pEntry = new XBitmapEntry( pBitmapItem->GetBitmapValue(), aTmpStr ); + XBitmapList aBitmapList( String::CreateFromAscii("TmpList") ); + aBitmapList.Insert( pEntry ); + aBitmapList.SetDirty( FALSE ); + //Bitmap* pBmp = aBitmapList.GetBitmap( 0 ); + //( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp ); + pFillAttrLB->Fill( &aBitmapList ); + pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); + aBitmapList.Remove( 0 ); + delete pEntry; + } + // NEU + } + else + pFillAttrLB->SetNoSelection(); + } + break; + + default: + DBG_ERROR( "Nicht unterstuetzter Flaechentyp" ); + break; + } + } + + if( pState && pStyleItem ) + { + XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue(); + + // Die Listen haben sich geaendert ? + if( pState->ISA( SvxColorTableItem ) && + eXFS == XFILL_SOLID ) + { + ::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() ); + pFillAttrLB->Clear(); + pFillAttrLB->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() ); + pFillAttrLB->SelectEntry( aTmpColor ); + } + if( pState->ISA( SvxGradientListItem ) && + eXFS == XFILL_GRADIENT ) + { + String aString( pFillAttrLB->GetSelectEntry() ); + pFillAttrLB->Clear(); + pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() ); + pFillAttrLB->SelectEntry( aString ); + } + if( pState->ISA( SvxHatchListItem ) && + eXFS == XFILL_HATCH ) + { + String aString( pFillAttrLB->GetSelectEntry() ); + pFillAttrLB->Clear(); + pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() ); + pFillAttrLB->SelectEntry( aString ); + } + if( pState->ISA( SvxBitmapListItem ) && + eXFS == XFILL_BITMAP ) + { + String aString( pFillAttrLB->GetSelectEntry() ); + pFillAttrLB->Clear(); + pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() ); + pFillAttrLB->SelectEntry( aString ); + } + } +} + +//======================================================================== + +Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent ) +{ + if ( GetSlotId() == SID_ATTR_FILL_STYLE ) + { + pFillControl = new FillControl( pParent ); + // Damit dem FillControl das SvxFillToolBoxControl bekannt ist + // (und um kompatibel zu bleiben) + pFillControl->SetData( this ); + + pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr; + pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType; + + pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX ); + pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX ); + + return pFillControl; + } + return NULL; +} + +/************************************************************************* +|* +|* FillControl +|* +\************************************************************************/ + +FillControl::FillControl( Window* pParent, WinBits nStyle ) : + Window( pParent, nStyle | WB_DIALOGCONTROL ), + pLbFillType(new SvxFillTypeBox( this )), + aLogicalFillSize(40,80), + aLogicalAttrSize(50,80) +{ + pLbFillAttr = new SvxFillAttrBox( this ); + Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); + Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); + pLbFillType->SetSizePixel(aTypeSize); + pLbFillAttr->SetSizePixel(aAttrSize); + //to get the base height + aTypeSize = pLbFillType->GetSizePixel(); + aAttrSize = pLbFillAttr->GetSizePixel(); + Point aAttrPnt = pLbFillAttr->GetPosPixel(); + SetSizePixel( + Size( aAttrPnt.X() + aAttrSize.Width(), + Max( aAttrSize.Height(), aTypeSize.Height() ) ) ); + + pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) ); + pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) ); + + aDelayTimer.SetTimeout( DELAY_TIMEOUT ); + aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) ); + aDelayTimer.Start(); +} + +//------------------------------------------------------------------------ + +FillControl::~FillControl() +{ + delete pLbFillType; + delete pLbFillAttr; +} + +//------------------------------------------------------------------------ + +IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG ) +{ + SelectFillTypeHdl( NULL ); + ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" ))); +// ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE ); + return 0; +} +IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer ) + +//------------------------------------------------------------------------ + +IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox ) +{ + XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos(); + + // Spaeter sollte eine Optimierung derart erfolgen, dass die + // Listen, bzw. Tables nur dann geloescht und wieder aufgebaut + // werden, wenn sich die Listen, bzw. Tables tatsaechlich geaendert + // haben (in den LBs natuerlich). + + if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox ) + { + // Damit wir in folgendem Fall einen Status anzeigen koennen: + // Ein Typ wurde ausgewaehlt aber kein Attribut. + // Die Selektion hat genau die gleichen Attribute wie die vorherige. +// SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData(); +// if( pControlerItem ) +// pControlerItem->ClearCache(); + + pLbFillAttr->Clear(); + SfxObjectShell* pSh = SfxObjectShell::Current(); + + switch( eXFS ) + { + case XFILL_NONE: + { + pLbFillType->Selected(); + SelectFillAttrHdl( pBox ); + pLbFillAttr->Disable(); + } + break; + + case XFILL_SOLID: + { + if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) ) + { + SvxColorTableItem aItem( *(const SvxColorTableItem*)( + pSh->GetItem( SID_COLOR_TABLE ) ) ); + pLbFillAttr->Enable(); + pLbFillAttr->Fill( aItem.GetColorTable() ); + } + else + pLbFillAttr->Disable(); + } + break; + + case XFILL_GRADIENT: + { + if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) ) + { + SvxGradientListItem aItem( *(const SvxGradientListItem*)( + pSh->GetItem( SID_GRADIENT_LIST ) ) ); + pLbFillAttr->Enable(); + pLbFillAttr->Fill( aItem.GetGradientList() ); + } + else + pLbFillAttr->Disable(); + } + break; + + case XFILL_HATCH: + { + if ( pSh && pSh->GetItem( SID_HATCH_LIST ) ) + { + SvxHatchListItem aItem( *(const SvxHatchListItem*)( + pSh->GetItem( SID_HATCH_LIST ) ) ); + pLbFillAttr->Enable(); + pLbFillAttr->Fill( aItem.GetHatchList() ); + } + else + pLbFillAttr->Disable(); + } + break; + + case XFILL_BITMAP: + { + if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) ) + { + SvxBitmapListItem aItem( *(const SvxBitmapListItem*)( + pSh->GetItem( SID_BITMAP_LIST ) ) ); + pLbFillAttr->Enable(); + pLbFillAttr->Fill( aItem.GetBitmapList() ); + } + else + pLbFillAttr->Disable(); + } + break; + } + + if( eXFS != XFILL_NONE ) // Wurde schon erledigt + { + if ( pBox ) + pLbFillType->Selected(); + + // release focus + if ( pBox && pLbFillType->IsRelease() ) + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + if( pViewShell && pViewShell->GetWindow() ) + pViewShell->GetWindow()->GrabFocus(); + } + } + } + return 0; +} + +//------------------------------------------------------------------------ + +IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox ) +{ + XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos(); + XFillStyleItem aXFillStyleItem( eXFS ); + BOOL bAction = pBox && !pLbFillAttr->IsTravelSelect(); + + SfxObjectShell* pSh = SfxObjectShell::Current(); + if ( bAction ) + { + Any a; + Sequence< PropertyValue > aArgs( 1 ); + + // First set the style + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )); + aXFillStyleItem.QueryValue( a ); + aArgs[0].Value = a; + ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( TRUE ); + ((SvxFillToolBoxControl*)GetData())->Dispatch( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs ); + ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( FALSE ); + + switch( eXFS ) + { + case XFILL_NONE: + { + } + break; + + case XFILL_SOLID: + { + // NEU + //Eintrag wird auf temporaere Farbe geprueft + String aTmpStr = pLbFillAttr->GetSelectEntry(); + if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) + { + aTmpStr.Erase( aTmpStr.Len()-1, 1 ); + aTmpStr.Erase( 0, 1 ); + } + + XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() ); + + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" )); + aXFillColorItem.QueryValue( a ); + aArgs[0].Value = a; + ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )), + aArgs ); + } + break; + case XFILL_GRADIENT: + { + USHORT nPos = pLbFillAttr->GetSelectEntryPos(); + + if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) ) + { + SvxGradientListItem aItem( + *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) ); + + if ( nPos < aItem.GetGradientList()->Count() ) // kein temp. Eintrag ? + { + XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient(); + XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient ); + + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" )); + aXFillGradientItem.QueryValue( a ); + aArgs[0].Value = a; + ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )), + aArgs ); + } + } + } + break; + + case XFILL_HATCH: + { + USHORT nPos = pLbFillAttr->GetSelectEntryPos(); + + if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) ) + { + SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) ); + + if ( nPos < aItem.GetHatchList()->Count() ) // kein temp. Eintrag ? + { + XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch(); + XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch ); + + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" )); + aXFillHatchItem.QueryValue( a ); + aArgs[0].Value = a; + ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )), + aArgs ); + } + } + } + break; + + case XFILL_BITMAP: + { + USHORT nPos = pLbFillAttr->GetSelectEntryPos(); + + if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) ) + { + SvxBitmapListItem aItem( + *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) ); + + if ( nPos < aItem.GetBitmapList()->Count() ) // kein temp. Eintrag ? + { + XOBitmap aXOBitmap = aItem.GetBitmapList()->GetBitmap( nPos )->GetXBitmap(); + XFillBitmapItem aXFillBitmapItem( pLbFillAttr->GetSelectEntry(), aXOBitmap ); + + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" )); + aXFillBitmapItem.QueryValue( a ); + aArgs[0].Value = a; + ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )), + aArgs ); + } + } + } + break; + } + + // release focus + if ( pLbFillAttr->IsRelease() && pBox ) + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + if( pViewShell && pViewShell->GetWindow() ) + { + pViewShell->GetWindow()->GrabFocus(); + } + } + } + + return 0; +} + +//------------------------------------------------------------------------ + +void FillControl::Resize() +{ + // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5 + long nW = GetOutputSizePixel().Width() / 5; + long nH = 180; + long nSep = 0; // war vorher 4 + + pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) ); + pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) ); +} + +void FillControl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); + Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); + pLbFillType->SetSizePixel(aTypeSize); + pLbFillAttr->SetSizePixel(aAttrSize); + //to get the base height + aTypeSize = pLbFillType->GetSizePixel(); + aAttrSize = pLbFillAttr->GetSizePixel(); + Point aAttrPnt = pLbFillAttr->GetPosPixel(); + + SetSizePixel( + Size( aAttrPnt.X() + aAttrSize.Width(), + Max( aAttrSize.Height(), aTypeSize.Height() ) ) ); + } + Window::DataChanged( rDCEvt ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx new file mode 100644 index 000000000000..5a107c55cdd2 --- /dev/null +++ b/svx/source/tbxctrls/fontworkgallery.cxx @@ -0,0 +1,807 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 <com/sun/star/text/WritingMode.hpp> + +#include <vcl/toolbox.hxx> + +#include <svl/itempool.hxx> + +#include <svtools/toolbarmenu.hxx> +#include <svtools/popupwindowcontroller.hxx> +#include <svtools/popupmenucontrollerbase.hxx> + +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> + +#include <editeng/eeitem.hxx> +#include <editeng/frmdiritem.hxx> + +#include <svx/fmmodel.hxx> +#include <svx/svxids.hrc> +#include <svx/dialmgr.hxx> +#include <svx/dialogs.hrc> +#include <svx/svdpage.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdview.hxx> +#include <svx/svdoutl.hxx> + +#include "gallery.hxx" +#include <dlgutil.hxx> + +#include "fontworkgallery.hxx" +#include "fontworkgallery.hrc" + +#include <algorithm> + +#include "helpid.hrc" + +using ::rtl::OUString; +using ::svtools::ToolbarMenu; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::frame; + +namespace svx +{ + +const int nColCount = 4; +const int nLineCount = 4; + +/************************************************************************* +|* Svx3DWin - FloatingWindow +\************************************************************************/ +FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, Window* pParent, sal_uInt16 /*nSID*/ ) : + ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_GALLERY ) ), + maCtlFavorites ( this, SVX_RES( CTL_FAVORITES ) ), + maFLFavorites ( this, SVX_RES( FL_FAVORITES ) ), + maOKButton ( this, SVX_RES( BTN_OK ) ), + maCancelButton ( this, SVX_RES( BTN_CANCEL ) ), + maHelpButton ( this, SVX_RES( BTN_HELP ) ), + mnThemeId ( 0xffff ), + mpSdrView ( pSdrView ), + mpModel ( (FmFormModel*)pSdrView->GetModel() ), + maStrClickToAddText ( SVX_RES( STR_CLICK_TO_ADD_TEXT ) ), + mppSdrObject ( NULL ), + mpDestModel ( NULL ) +{ + FreeResource(); + + maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) ); + maOKButton.SetClickHdl( LINK( this, FontWorkGalleryDialog, ClickOKHdl ) ); + + maCtlFavorites.SetColCount( nColCount ); + maCtlFavorites.SetLineCount( nLineCount ); + maCtlFavorites.SetExtraSpacing( 3 ); + + initfavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal ); + fillFavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal ); +} + +static void delete_bitmap( Bitmap* p ) { delete p; } + +// ----------------------------------------------------------------------- +FontWorkGalleryDialog::~FontWorkGalleryDialog() +{ + std::for_each( maFavoritesHorizontal.begin(), maFavoritesHorizontal.end(), delete_bitmap ); +} + +// ----------------------------------------------------------------------- + +void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites) +{ + // Ueber die Gallery werden die Favoriten eingelesen + ULONG nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId ); + + // Gallery thema locken + GalleryExplorer::BeginLocking(nThemeId); + + sal_uInt32 nModelPos; + FmFormModel *pModel = NULL; + for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ ) + { + Bitmap* pThumb = new Bitmap; + + if( GalleryExplorer::GetSdrObj( nThemeId, nModelPos, pModel, pThumb ) ) + { +/* + VirtualDevice aVDev; + Size aRenderSize( aThumbSize.Width() * 4, aThumbSize.Height() * 4 ); + aVDev.SetOutputSizePixel( aRenderSize ); + + if( GalleryExplorer::DrawCentered( &aVDev, *pModel ) ) + { + aThumb = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); + + Size aMS( 4, 4 ); + BmpFilterParam aParam( aMS ); + aThumb.Filter( BMP_FILTER_MOSAIC, &aParam ); + aThumb.Scale( aThumbSize ); + } +*/ + } + + rFavorites.push_back( pThumb ); + } + + // Gallery thema freigeben + GalleryExplorer::EndLocking(nThemeId); +} + +void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites ) +{ + mnThemeId = nThemeId; + + Size aThumbSize( maCtlFavorites.GetSizePixel() ); + aThumbSize.Width() /= nColCount; + aThumbSize.Height() /= nLineCount; + aThumbSize.Width() -= 12; + aThumbSize.Height() -= 12; + + std::vector< Bitmap * >::size_type nFavCount = rFavorites.size(); + + // ValueSet Favoriten + if( nFavCount > (nColCount * nLineCount) ) + { + WinBits nWinBits = maCtlFavorites.GetStyle(); + nWinBits |= WB_VSCROLL; + maCtlFavorites.SetStyle( nWinBits ); + } + + maCtlFavorites.Clear(); + + sal_uInt32 nFavorite; + for( nFavorite = 1; nFavorite <= nFavCount; nFavorite++ ) + { + String aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE)); + aStr += sal_Unicode(' '); + aStr += String::CreateFromInt32((sal_Int32)nFavorite); + Image aThumbImage( *rFavorites[nFavorite-1] ); + maCtlFavorites.InsertItem( (sal_uInt16)nFavorite, aThumbImage, aStr ); + } +} + +void FontWorkGalleryDialog::changeText( SdrTextObj* pObj ) +{ + if( pObj ) + { + SdrOutliner& rOutl = mpModel->GetDrawOutliner(pObj); + + USHORT nOutlMode = rOutl.GetMode(); + Size aPaperSize = rOutl.GetPaperSize(); + BOOL bUpdateMode = rOutl.GetUpdateMode(); + rOutl.SetUpdateMode(FALSE); + rOutl.SetParaAttribs( 0, rOutl.GetEmptyItemSet() ); + + // #95114# Always set the object's StyleSheet at the Outliner to + // use the current objects StyleSheet. Thus it's the same as in + // SetText(...). + // #95114# Moved this implementation from where SetObjText(...) was called + // to inside this method to work even when outliner is fetched here. + rOutl.SetStyleSheet(0, pObj->GetStyleSheet()); + + rOutl.SetPaperSize( pObj->GetLogicRect().GetSize() ); + + rOutl.SetText( maStrClickToAddText, rOutl.GetParagraph( 0 ) ); + pObj->SetOutlinerParaObject( rOutl.CreateParaObject() ); + + rOutl.Init( nOutlMode ); + rOutl.SetParaAttribs( 0, rOutl.GetEmptyItemSet() ); + rOutl.SetUpdateMode( bUpdateMode ); + rOutl.SetPaperSize( aPaperSize ); + + rOutl.Clear(); + } +} + +void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel ) +{ + mppSdrObject = ppSdrObject; + mpDestModel = pModel; +} + +void FontWorkGalleryDialog::insertSelectedFontwork() +{ + USHORT nItemId = maCtlFavorites.GetSelectItemId(); + + if( nItemId > 0 ) + { + FmFormModel* pModel = new FmFormModel(); + pModel->GetItemPool().FreezeIdRanges(); + + if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) ) + { + SdrPage* pPage = pModel->GetPage(0); + if( pPage && pPage->GetObjCount() ) + { + SdrObject* pNewObject = pPage->GetObj(0)->Clone(); + + // center shape on current view + OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice(); + if( pOutDev ) + { + Rectangle aObjRect( pNewObject->GetLogicRect() ); + Rectangle aVisArea = pOutDev->PixelToLogic(Rectangle(Point(0,0), pOutDev->GetOutputSizePixel())); +/* + sal_Int32 nObjHeight = aObjRect.GetHeight(); + VirtualDevice aVirDev( 1 ); // calculating the optimal textwidth + Font aFont; + aFont.SetHeight( nObjHeight ); + aVirDev.SetMapMode( MAP_100TH_MM ); + aVirDev.SetFont( aFont ); + aObjRect.SetSize( Size( aVirDev.GetTextWidth( maStrClickToAddText ), nObjHeight ) ); +*/ + Point aPagePos = aVisArea.Center(); + aPagePos.X() -= aObjRect.GetWidth() / 2; + aPagePos.Y() -= aObjRect.GetHeight() / 2; + Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize()); + SdrPageView* pPV = mpSdrView->GetSdrPageView(); + + pNewObject->SetLogicRect(aNewObjectRectangle); + if ( mppSdrObject ) + { + *mppSdrObject = pNewObject; + (*mppSdrObject)->SetModel( mpDestModel ); + } + else if( pPV ) + { + mpSdrView->InsertObjectAtView( pNewObject, *pPV ); + // changeText( PTR_CAST( SdrTextObj, pNewObject ) ); + } + } + } + } + + delete pModel; + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FontWorkGalleryDialog, ClickOKHdl, void*, EMPTYARG ) +{ + insertSelectedFontwork(); + EndDialog( true ); + return 0; +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FontWorkGalleryDialog, DoubleClickFavoriteHdl, void*, EMPTYARG ) +{ + insertSelectedFontwork(); + EndDialog( true ); + return( 0L ); +} + +//------------------------------------------------------------------------ + +SFX_IMPL_TOOLBOX_CONTROL( FontWorkShapeTypeControl, SfxStringItem ); +FontWorkShapeTypeControl::FontWorkShapeTypeControl( USHORT nSlotId, USHORT nId, ToolBox &rTbx ) +: SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------- + +FontWorkShapeTypeControl::~FontWorkShapeTypeControl() +{ +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType FontWorkShapeTypeControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; //( aLastAction.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT ); +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* FontWorkShapeTypeControl::CreatePopupWindow() +{ + rtl::OUString aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/fontworkshapetype" ) ); + createAndPositionSubToolBar( aSubTbxResName ); + return NULL; +} + +// ----------------------------------------------------------------------- + +void FontWorkShapeTypeControl::Select( BOOL ) +{ + +} + +// ======================================================================== +// FontWorkAlignmentWindow +// ======================================================================== + +class FontWorkAlignmentWindow : public ToolbarMenu +{ +public: + FontWorkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ); + + virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +private: + svt::ToolboxController& mrController; + + Image maImgAlgin1; + Image maImgAlgin2; + Image maImgAlgin3; + Image maImgAlgin4; + Image maImgAlgin5; + + const rtl::OUString msFontworkAlignment; + + DECL_LINK( SelectHdl, void * ); + + void implSetAlignment( int nAlignmentMode, bool bEnabled ); +}; + +FontWorkAlignmentWindow::FontWorkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ) +: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT )) +, mrController( rController ) +, maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16 ) ) +, maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16 ) ) +, maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16 ) ) +, maImgAlgin4( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16 ) ) +, maImgAlgin5( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16 ) ) +, msFontworkAlignment( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) +{ + SetHelpId( HID_POPUP_FONTWORK_ALIGN ); + SetSelectHdl( LINK( this, FontWorkAlignmentWindow, SelectHdl ) ); + + appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), maImgAlgin1 ); + appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), maImgAlgin2 ); + appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), maImgAlgin3 ); + appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), maImgAlgin4 ); + appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), maImgAlgin5 ); + + SetOutputSizePixel( getMenuSize() ); + + FreeResource(); + + AddStatusListener( msFontworkAlignment ); +} + +// ----------------------------------------------------------------------- + +void FontWorkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled ) +{ + int i; + for( i = 0; i < 5; i++ ) + { + checkEntry( i, (i == nSurface) && bEnabled ); + enableEntry( i, bEnabled ); + } +} + +// ----------------------------------------------------------------------- + +void SAL_CALL FontWorkAlignmentWindow::statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException ) +{ + if( Event.FeatureURL.Main.equals( msFontworkAlignment ) ) + { + if( !Event.IsEnabled ) + { + implSetAlignment( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetAlignment( nValue, true ); + } + } +} + +// ----------------------------------------------------------------------- + +void FontWorkAlignmentWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ToolbarMenu::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), maImgAlgin1 ); + appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), maImgAlgin2 ); + appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), maImgAlgin3 ); + appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), maImgAlgin4 ); + appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), maImgAlgin5 ); + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FontWorkAlignmentWindow, SelectHdl, void *, EMPTYARG ) +{ + if ( IsInPopupMode() ) + EndPopupMode(); + + sal_Int32 nAlignment = getSelectedEntryId(); + if( nAlignment >= 0 ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msFontworkAlignment.copy(5); + aArgs[0].Value <<= (sal_Int32)nAlignment; + + mrController.dispatchCommand( msFontworkAlignment, aArgs ); + + implSetAlignment( nAlignment, true ); + } + + return 0; +} + +// ======================================================================== +// FontWorkAlignmentControl +// ======================================================================== + +class FontWorkAlignmentControl : public svt::PopupWindowController +{ +public: + FontWorkAlignmentControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + + using svt::PopupWindowController::createPopupWindow; +}; + + +// ----------------------------------------------------------------------- + +FontWorkAlignmentControl::FontWorkAlignmentControl( const Reference< lang::XMultiServiceFactory >& rServiceManager ) +: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) ) +{ +} + +// ----------------------------------------------------------------------- + +::Window* FontWorkAlignmentControl::createPopupWindow( ::Window* pParent ) +{ + return new FontWorkAlignmentWindow( *this, m_xFrame, pParent ); +} + +// ----------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------- + +OUString SAL_CALL FontWorkAlignmentControl_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontWorkAlignmentController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL FontWorkAlignmentControl_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SAL_CALL FontWorkAlignmentControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) +{ + return *new FontWorkAlignmentControl( rSMgr ); +} + +// -------------------------------------------------------------------- + +OUString SAL_CALL FontWorkAlignmentControl::getImplementationName( ) throw (RuntimeException) +{ + return FontWorkAlignmentControl_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL FontWorkAlignmentControl::getSupportedServiceNames( ) throw (RuntimeException) +{ + return FontWorkAlignmentControl_getSupportedServiceNames(); +} + + +// #################################################################### + +class FontWorkCharacterSpacingWindow : public ToolbarMenu +{ +public: + FontWorkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ); + + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); +private: + svt::ToolboxController& mrController; + + const rtl::OUString msFontworkCharacterSpacing; + const rtl::OUString msFontworkKernCharacterPairs; + + DECL_LINK( SelectHdl, void * ); + + void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled ); + void implSetKernCharacterPairs( sal_Bool bKernOnOff, bool bEnabled ); + +}; + +// ----------------------------------------------------------------------- + +FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ) +: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING )) +, mrController( rController ) +, msFontworkCharacterSpacing( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ) ) +, msFontworkKernCharacterPairs( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ) ) +{ + SetHelpId( HID_POPUP_FONTWORK_CHARSPACE ); + SetSelectHdl( LINK( this, FontWorkCharacterSpacingWindow, SelectHdl ) ); + + appendEntry( 0, String( SVX_RES( STR_CHARS_SPACING_VERY_TIGHT ) ), MIB_RADIOCHECK ); + appendEntry( 1, String( SVX_RES( STR_CHARS_SPACING_TIGHT ) ), MIB_RADIOCHECK ); + appendEntry( 2, String( SVX_RES( STR_CHARS_SPACING_NORMAL ) ), MIB_RADIOCHECK ); + appendEntry( 3, String( SVX_RES( STR_CHARS_SPACING_LOOSE ) ), MIB_RADIOCHECK ); + appendEntry( 4, String( SVX_RES( STR_CHARS_SPACING_VERY_LOOSE ) ), MIB_RADIOCHECK ); + appendEntry( 5, String( SVX_RES( STR_CHARS_SPACING_CUSTOM ) ), MIB_RADIOCHECK ); + appendSeparator(); + appendEntry( 6, String( SVX_RES( STR_CHARS_SPACING_KERN_PAIRS ) ), MIB_CHECKABLE ); + + SetOutputSizePixel( getMenuSize() ); + + FreeResource(); + + AddStatusListener( msFontworkCharacterSpacing ); + AddStatusListener( msFontworkKernCharacterPairs ); +} + +// ----------------------------------------------------------------------- + +void FontWorkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled ) +{ + sal_Int32 i; + for ( i = 0; i < 6; i++ ) + { + checkEntry( i, sal_False ); + enableEntry( i, bEnabled ); + } + if ( nCharacterSpacing != -1 ) + { + sal_Int32 nEntry; + switch( nCharacterSpacing ) + { + case 80 : nEntry = 0; break; + case 90 : nEntry = 1; break; + case 100 : nEntry = 2; break; + case 120 : nEntry = 3; break; + case 150 : nEntry = 4; break; + default : nEntry = 5; break; + } + checkEntry( nEntry, bEnabled ); + } +} + +// ----------------------------------------------------------------------- + +void FontWorkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool, bool bEnabled ) +{ + enableEntry( 6, bEnabled ); + checkEntry( 6, bEnabled ); +} + +// ----------------------------------------------------------------------- + +void SAL_CALL FontWorkCharacterSpacingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) +{ + if( Event.FeatureURL.Main.equals( msFontworkCharacterSpacing ) ) + { + if( !Event.IsEnabled ) + { + implSetCharacterSpacing( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetCharacterSpacing( nValue, true ); + } + } + else if( Event.FeatureURL.Main.equals( msFontworkKernCharacterPairs ) ) + { + if( !Event.IsEnabled ) + { + implSetKernCharacterPairs( 0, false ); + } + else + { + sal_Bool bValue = sal_False; + if( Event.State >>= bValue ) + implSetKernCharacterPairs( bValue, true ); + } + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( FontWorkCharacterSpacingWindow, SelectHdl, void *, EMPTYARG ) +{ + if ( IsInPopupMode() ) + EndPopupMode(); + + sal_Int32 nSelection = getSelectedEntryId(); + sal_Int32 nCharacterSpacing; + switch( nSelection ) + { + case 0 : nCharacterSpacing = 80; break; + case 1 : nCharacterSpacing = 90; break; + case 2 : nCharacterSpacing = 100; break; + case 3 : nCharacterSpacing = 120; break; + case 4 : nCharacterSpacing = 150; break; + default : nCharacterSpacing = 100; break; + } + if ( nSelection == 5 ) // custom spacing + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msFontworkCharacterSpacing.copy(5); + aArgs[0].Value <<= (sal_Int32)nCharacterSpacing; + + mrController.dispatchCommand( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingDialog" )), aArgs ); + } + else if ( nSelection == 6 ) // KernCharacterPairs + { + rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" )); + + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msFontworkKernCharacterPairs.copy(5); + aArgs[0].Value <<= (sal_Bool) sal_True; + + mrController.dispatchCommand( msFontworkKernCharacterPairs, aArgs ); + + implSetKernCharacterPairs( sal_True, true ); + } + else if( nSelection >= 0 ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = msFontworkCharacterSpacing.copy(5); + aArgs[0].Value <<=( sal_Int32)nCharacterSpacing; + + mrController.dispatchCommand( msFontworkCharacterSpacing, aArgs ); + + implSetCharacterSpacing( nCharacterSpacing, true ); + } + + return 0; +} + +// ======================================================================== +// FontWorkCharacterSpacingControl +// ======================================================================== + +class FontWorkCharacterSpacingControl : public svt::PopupWindowController +{ +public: + FontWorkCharacterSpacingControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + + using svt::PopupWindowController::createPopupWindow; +}; + + +FontWorkCharacterSpacingControl::FontWorkCharacterSpacingControl( const Reference< lang::XMultiServiceFactory >& rServiceManager ) +: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingFloater" ) ) ) +{ +} + +// ----------------------------------------------------------------------- + +::Window* FontWorkCharacterSpacingControl::createPopupWindow( ::Window* pParent ) +{ + return new FontWorkCharacterSpacingWindow( *this, m_xFrame, pParent ); +} + +// ----------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------- + +OUString SAL_CALL FontWorkCharacterSpacingControl_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontWorkCharacterSpacingController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SAL_CALL FontWorkCharacterSpacingControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) +{ + return *new FontWorkCharacterSpacingControl( rSMgr ); +} + +// -------------------------------------------------------------------- + +OUString SAL_CALL FontWorkCharacterSpacingControl::getImplementationName( ) throw (RuntimeException) +{ + return FontWorkCharacterSpacingControl_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl::getSupportedServiceNames( ) throw (RuntimeException) +{ + return FontWorkCharacterSpacingControl_getSupportedServiceNames(); +} + +// ======================================================================== +// FontworkCharacterSpacingDialog +// ======================================================================== + +FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog( Window* pParent, sal_Int32 nScale ) +: ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_CHARSPACING ) ), + maFLScale( this, SVX_RES( FT_VALUE ) ), + maMtrScale( this, SVX_RES( MF_VALUE ) ), + maOKButton( this, SVX_RES( BTN_OK ) ), + maCancelButton( this, SVX_RES( BTN_CANCEL ) ), + maHelpButton( this, SVX_RES( BTN_HELP ) ) +{ + maMtrScale.SetValue( nScale ); + FreeResource(); +} + +FontworkCharacterSpacingDialog::~FontworkCharacterSpacingDialog() +{ +} + +sal_Int32 FontworkCharacterSpacingDialog::getScale() const +{ + return (sal_Int32)maMtrScale.GetValue(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/fontworkgallery.src b/svx/source/tbxctrls/fontworkgallery.src new file mode 100644 index 000000000000..ffa1e7c9f3f0 --- /dev/null +++ b/svx/source/tbxctrls/fontworkgallery.src @@ -0,0 +1,273 @@ +/************************************************************************* + * + * 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 "helpid.hrc" +#include <svx/dialogs.hrc> +#include "fontworkgallery.hrc" +#include "svtools/controldims.hrc" + +#define WIDTH 256 +#define HEIGHT 256 + +#define MASKCOLOR MaskColor = Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; }; + +ModalDialog RID_SVX_MDLG_FONTWORK_GALLERY +{ + OutputSize = TRUE; + SVLook = TRUE ; + Moveable = TRUE; + Closeable = TRUE; + + Size = MAP_APPFONT( WIDTH, HEIGHT ); + + Text [ en-US ] = "Fontwork Gallery" ; + + FixedLine FL_FAVORITES + { + Pos = MAP_APPFONT ( 3 , 3 ) ; + Size = MAP_APPFONT ( WIDTH - 6 , 8 ) ; + Text [ en-US ] = "Select a Fontwork style:" ; + }; + Control CTL_FAVORITES + { + HelpId = HID_CTL_FONTWORK_FAVORITES ; + Border = FALSE ; + Pos = MAP_APPFONT ( 3 , 14 ) ; + Size = MAP_APPFONT ( WIDTH - 6, + HEIGHT - RSC_CD_PUSHBUTTON_HEIGHT - + 6 - RSC_CD_PUSHBUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; + OkButton BTN_OK + { + Pos = MAP_APPFONT ( WIDTH - 3 * RSC_CD_PUSHBUTTON_WIDTH - 9 , + HEIGHT - 3 - RSC_CD_PUSHBUTTON_HEIGHT ) ; + Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH, + RSC_CD_PUSHBUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( WIDTH - 2 * RSC_CD_PUSHBUTTON_WIDTH - 6 , + HEIGHT - 3 - RSC_CD_PUSHBUTTON_HEIGHT ) ; + Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH, + RSC_CD_PUSHBUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( WIDTH - 1 * RSC_CD_PUSHBUTTON_WIDTH - 3 , + HEIGHT - 3 - RSC_CD_PUSHBUTTON_HEIGHT ) ; + Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH, + RSC_CD_PUSHBUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; + String STR_CLICK_TO_ADD_TEXT + { + Text [ en-US ] = "Click to edit text" ; + }; +}; + +DockingWindow RID_SVXFLOAT_FONTWORK_ALIGNMENT +{ + Border = FALSE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = FALSE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + + Text [ en-US ] = "Fontwork Alignment" ; + + String STR_ALIGN_LEFT + { + Text [ en-US ] = "~Left Align"; + }; + String STR_ALIGN_CENTER + { + Text [ en-US ] = "~Center"; + }; + String STR_ALIGN_RIGHT + { + Text [ en-US ] = "~Right Align"; + }; + String STR_ALIGN_WORD + { + Text [ en-US ] = "~Word Justify"; + }; + String STR_ALIGN_STRETCH + { + Text [ en-US ] = "S~tretch Justify"; + }; + + Image IMG_FONTWORK_ALIGN_LEFT_16 + { + ImageBitmap = Bitmap { File = "fontworkalignleft_16.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_LEFT_26 + { + ImageBitmap = Bitmap { File = "fontworkalignleft_26.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_CENTER_16 + { + ImageBitmap = Bitmap { File = "fontworkaligncentered_16.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_CENTER_26 + { + ImageBitmap = Bitmap { File = "fontworkaligncentered_26.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_RIGHT_16 + { + ImageBitmap = Bitmap { File = "fontworkalignright_16.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_RIGHT_26 + { + ImageBitmap = Bitmap { File = "fontworkalignright_26.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_WORD_16 + { + ImageBitmap = Bitmap { File = "fontworkalignjustified_16.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_WORD_26 + { + ImageBitmap = Bitmap { File = "fontworkalignjustified_26.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_STRETCH_16 + { + ImageBitmap = Bitmap { File = "fontworkalignstretch_16.png"; }; + MASKCOLOR + }; + Image IMG_FONTWORK_ALIGN_STRETCH_26 + { + ImageBitmap = Bitmap { File = "fontworkalignstretch_26.png"; }; + MASKCOLOR + }; +}; + +DockingWindow RID_SVXFLOAT_FONTWORK_CHARSPACING +{ + Border = FALSE ; + Hide = TRUE ; + SVLook = TRUE ; + Sizeable = FALSE ; + Moveable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + + Text [ en-US ] = "Fontwork Character Spacing" ; + + String STR_CHARS_SPACING_VERY_TIGHT + { + Text [ en-US ] = "~Very Tight"; + }; + String STR_CHARS_SPACING_TIGHT + { + Text [ en-US ] = "~Tight"; + }; + String STR_CHARS_SPACING_NORMAL + { + Text [ en-US ] = "~Normal"; + }; + String STR_CHARS_SPACING_LOOSE + { + Text [ en-US ] = "~Loose"; + }; + String STR_CHARS_SPACING_VERY_LOOSE + { + Text [ en-US ] = "Very ~Loose"; + }; + String STR_CHARS_SPACING_CUSTOM + { + Text [ en-US ] = "~Custom..."; + }; + String STR_CHARS_SPACING_KERN_PAIRS + { + Text [ en-US ] = "~Kern Character Pairs"; + }; +}; + +ModalDialog RID_SVX_MDLG_FONTWORK_CHARSPACING +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 139 , 64 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + + Text [ en-US ] = "Fontwork Character Spacing" ; + + OKButton BTN_OK + { + Pos = MAP_APPFONT ( 83 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( 83 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 83 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + FixedText FT_VALUE + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( 76 , 8 ) ; + Text[ en-US ] = "~Value"; + }; + MetricField MF_VALUE + { + Border = FALSE ; + Pos = MAP_APPFONT ( 6 , 17 ) ; + Size = MAP_APPFONT ( 32 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 500 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = "%" ; + Last = 100 ; + SpinSize = 5 ; + }; +}; + diff --git a/svx/source/tbxctrls/formatpaintbrushctrl.cxx b/svx/source/tbxctrls/formatpaintbrushctrl.cxx new file mode 100644 index 000000000000..6c554f46fdc5 --- /dev/null +++ b/svx/source/tbxctrls/formatpaintbrushctrl.cxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 "formatpaintbrushctrl.hxx" + +// header for class SfxBoolItem +#include <svl/eitem.hxx> + +// header for define SFX_APP +#include <sfx2/app.hxx> + +// header for class ToolBox +#include <vcl/toolbox.hxx> + +//............................................................................. +namespace svx +{ +//............................................................................. + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; + +SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem ); + +FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) + : SfxToolBoxControl( nSlotId, nId, rTbx ) + , m_bPersistentCopy(false) + , m_aDoubleClickTimer() +{ + ULONG nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime(); + + m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) ); + m_aDoubleClickTimer.SetTimeout(nDblClkTime); +} + +// ----------------------------------------------------------------------- + +FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl() +{ + m_aDoubleClickTimer.Stop(); +} + +// ----------------------------------------------------------------------- +void FormatPaintBrushToolBoxControl::impl_executePaintBrush() +{ + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistentCopy" )); + aArgs[0].Value = makeAny( static_cast<sal_Bool>(m_bPersistentCopy) ); + Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatPaintbrush" )) + , aArgs ); +} + +// ----------------------------------------------------------------------- +void FormatPaintBrushToolBoxControl::DoubleClick() +{ + m_aDoubleClickTimer.Stop(); + + m_bPersistentCopy = true; + this->impl_executePaintBrush(); +} + +// ----------------------------------------------------------------------- +void FormatPaintBrushToolBoxControl::Click() +{ + m_bPersistentCopy = false; + m_aDoubleClickTimer.Start(); +} + +// ----------------------------------------------------------------------- +IMPL_LINK(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl, void*, EMPTYARG ) +{ + //there was no second click during waiting + this->impl_executePaintBrush(); + return 0; +} + +// ----------------------------------------------------------------------- +void FormatPaintBrushToolBoxControl::Select( BOOL ) +{ +} + +// ----------------------------------------------------------------------- +void FormatPaintBrushToolBoxControl::StateChanged( USHORT nSID, SfxItemState eState, + const SfxPoolItem* pState ) +{ + if( ( eState & SFX_ITEM_SET ) == 0 ) + m_bPersistentCopy = false; + SfxToolBoxControl::StateChanged( nSID, eState, pState ); +} + +//............................................................................. +} //namespace svx +//............................................................................. + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx new file mode 100644 index 000000000000..cd94a9156acd --- /dev/null +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -0,0 +1,1286 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 headers + +#include <vcl/toolbox.hxx> +#include <vcl/field.hxx> +#include <vcl/fixed.hxx> +#include <vcl/msgbox.hxx> +#include <svl/intitem.hxx> +#include <svl/eitem.hxx> +#include <svl/whiter.hxx> +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/request.hxx> +#include <sfx2/basedlgs.hxx> +#include <tools/urlobj.hxx> +#include <comphelper/processfactory.hxx> + +#include <svx/svxids.hrc> +#include "grafctrl.hrc" +#include <svx/dialogs.hrc> +#include <editeng/brshitem.hxx> +#include <editeng/sizeitem.hxx> +#include <svx/sdgcpitm.hxx> + +#include <svx/itemwin.hxx> +#include <svx/dialmgr.hxx> +#include <svx/svdview.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdundo.hxx> +#include <svx/svdtrans.hxx> +#include "grafctrl.hxx" +#include "tbxcolor.hxx" + +// namespaces +using ::rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; + +#include <svx/svxdlg.hxx> +// ----------- +// - Defines - +// ----------- + +#define SYMBOL_TO_FIELD_OFFSET 4 +#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() +#define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) ) + +// ---------------- +// - TbxImageItem - +// ---------------- + +TYPEINIT1_AUTOFACTORY( TbxImageItem, SfxUInt16Item ); + +//--------------------------------------------------------- + +TbxImageItem::TbxImageItem( USHORT _nWhich, UINT16 nImage ) : + SfxUInt16Item( _nWhich, nImage ) +{ +} + +//--------------------------------------------------------- + +SfxPoolItem* TbxImageItem::Clone( SfxItemPool* ) const +{ + return new TbxImageItem( *this ); +} + +//--------------------------------------------------------- + +int TbxImageItem::operator==( const SfxPoolItem& rItem ) const +{ + return( ( (TbxImageItem&) rItem ).GetValue() == GetValue() ); +} + +// ----------------------- +// - ImplGrafMetricField - +// ----------------------- + +class ImplGrafMetricField : public MetricField +{ + using Window::Update; + +private: + Timer maTimer; + OUString maCommand; + Reference< XFrame > mxFrame; + + DECL_LINK( ImplModifyHdl, Timer* ); + +protected: + + virtual void Modify(); + +public: + + ImplGrafMetricField( Window* pParent, const rtl::OUString& aCmd, const Reference< XFrame >& rFrame ); + ~ImplGrafMetricField(); + + void Update( const SfxPoolItem* pItem ); + const OUString& GetCommand() const { return maCommand; } +}; + +// ----------------------------------------------------------------------------- + +ImplGrafMetricField::ImplGrafMetricField( Window* pParent, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame ) : + MetricField( pParent, WB_BORDER | WB_SPIN | WB_REPEAT | WB_3DLOOK ), + maCommand( rCmd ), + mxFrame( rFrame ) +{ + Size aSize( GetTextWidth( String::CreateFromAscii("-100 %") ), GetTextHeight() ); + + aSize.Width() += 20, aSize.Height() += 6; + SetSizePixel( aSize ); + + if ( maCommand.equalsAscii( ".uno:GrafGamma" )) + { + SetDecimalDigits( 2 ); + + SetMin( 10 ); + SetFirst( 10 ); + SetMax( 1000 ); + SetLast( 1000 ); + SetSpinSize( 10 ); + } + else + { + const long nMinVal = ( maCommand.equalsAscii( ".uno:GrafTransparence" )) ? 0 : -100; + + SetUnit( FUNIT_CUSTOM ); + SetCustomUnitText( String::CreateFromAscii(" %") ); + SetDecimalDigits( 0 ); + + SetMin( nMinVal ); + SetFirst( nMinVal ); + SetMax( 100 ); + SetLast( 100 ); + SetSpinSize( 1 ); + } + + maTimer.SetTimeout( 100 ); + maTimer.SetTimeoutHdl( LINK( this, ImplGrafMetricField, ImplModifyHdl ) ); +} + +// ----------------------------------------------------------------------------- + +ImplGrafMetricField::~ImplGrafMetricField() +{ +} + +// ----------------------------------------------------------------------------- + +void ImplGrafMetricField::Modify() +{ + maTimer.Start(); +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImplGrafMetricField, ImplModifyHdl, Timer*, EMPTYARG ) +{ + const sal_Int64 nVal = GetValue(); + + // Convert value to an any to be usable with dispatch API + Any a; + if ( maCommand.equalsAscii( ".uno:GrafRed" ) || + maCommand.equalsAscii( ".uno:GrafGreen" ) || + maCommand.equalsAscii( ".uno:GrafBlue" ) || + maCommand.equalsAscii( ".uno:GrafLuminance" ) || + maCommand.equalsAscii( ".uno:GrafContrast" )) + a = makeAny( sal_Int16( nVal )); + else if ( maCommand.equalsAscii( ".uno:GrafGamma" ) || + maCommand.equalsAscii( ".uno:GrafTransparence" )) + a = makeAny( sal_Int32( nVal )); + + if ( a.hasValue() ) + { + INetURLObject aObj( maCommand ); + + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + aArgs[0].Value = a; + + SfxToolBoxControl::Dispatch( + Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + maCommand, + aArgs ); + } + return 0L; +} + +// ----------------------------------------------------------------------------- + +void ImplGrafMetricField::Update( const SfxPoolItem* pItem ) +{ + if( pItem ) + { + long nValue; + + if ( maCommand.equalsAscii( ".uno:GrafTransparence" )) + nValue = ( (SfxUInt16Item*) pItem )->GetValue(); + else if ( maCommand.equalsAscii( ".uno:GrafGamma" )) + nValue = ( (SfxUInt32Item*) pItem )->GetValue(); + else + nValue = ( (SfxInt16Item*) pItem )->GetValue(); + + SetValue( nValue ); + } + else + SetText( String() ); +} + +// -------------------- +// - ImplGrafControl - +// -------------------- + +struct CommandToRID +{ + const char* pCommand; + USHORT nResId; +}; + +static USHORT ImplGetRID( const OUString& aCommand ) +{ + static const CommandToRID aImplCommandToResMap[] = + { + { ".uno:GrafRed", RID_SVXIMG_GRAF_RED }, + { ".uno:GrafGreen", RID_SVXIMG_GRAF_GREEN }, + { ".uno:GrafBlue", RID_SVXIMG_GRAF_BLUE }, + { ".uno:GrafLuminance", RID_SVXIMG_GRAF_LUMINANCE }, + { ".uno:GrafContrast", RID_SVXIMG_GRAF_CONTRAST }, + { ".uno:GrafGamma", RID_SVXIMG_GRAF_GAMMA }, + { ".uno:GrafTransparence", RID_SVXIMG_GRAF_TRANSPARENCE }, + { 0, 0 } + }; + + USHORT nRID = 0; + + sal_Int32 i( 0 ); + while ( aImplCommandToResMap[ i ].pCommand ) + { + if ( aCommand.equalsAscii( aImplCommandToResMap[ i ].pCommand )) + { + nRID = aImplCommandToResMap[ i ].nResId; + break; + } + ++i; + } + + return nRID; +} + +// ----------------------------------------------------------------------------- + +class ImplGrafControl : public Control +{ + using Window::Update; +private: + FixedImage maImage; + ImplGrafMetricField maField; + +protected: + + virtual void GetFocus(); + +public: + + ImplGrafControl( Window* pParent, USHORT nSlotId, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame ); + ~ImplGrafControl(); + + void Update( const SfxPoolItem* pItem ) { maField.Update( pItem ); } + void SetText( const String& rStr ) { maField.SetText( rStr ); } +}; + +// ----------------------------------------------------------------------------- + +ImplGrafControl::ImplGrafControl( + Window* pParent, + USHORT nSlotId, + const rtl::OUString& rCmd, + const Reference< XFrame >& rFrame +) : Control( pParent, WB_TABSTOP ) + , maImage( this ) + , maField( this, rCmd, rFrame ) +{ + ResId aResId( ImplGetRID( rCmd ), DIALOG_MGR() ) ; + Image aImage( aResId ); + + Size aImgSize( aImage.GetSizePixel() ); + Size aFldSize( maField.GetSizePixel() ); + long nFldY, nImgY; + + maImage.SetImage( aImage ); + maImage.SetSizePixel( aImgSize ); + // we want to see the backbround of the toolbox, not of the FixedImage or Control + maImage.SetBackground( Wallpaper( COL_TRANSPARENT ) ); + SetBackground( Wallpaper( COL_TRANSPARENT ) ); + + if( aImgSize.Height() > aFldSize.Height() ) + nImgY = 0, nFldY = ( aImgSize.Height() - aFldSize.Height() ) >> 1; + else + nFldY = 0, nImgY = ( aFldSize.Height() - aImgSize.Height() ) >> 1; + + long nOffset = SYMBOL_TO_FIELD_OFFSET / 2; + maImage.SetPosPixel( Point( nOffset, nImgY ) ); + maField.SetPosPixel( Point( aImgSize.Width() + SYMBOL_TO_FIELD_OFFSET, nFldY ) ); + SetSizePixel( Size( aImgSize.Width() + aFldSize.Width() + SYMBOL_TO_FIELD_OFFSET + nOffset, + Max( aImgSize.Height(), aFldSize.Height() ) ) ); + + SetBackground( Wallpaper() ); // transparent background + + maImage.Show(); + + maField.SetHelpId( nSlotId ); + maField.SetSmartHelpId( SmartId( rCmd )); + maField.Show(); +} + +// ----------------------------------------------------------------------------- + +ImplGrafControl::~ImplGrafControl() +{ +} + +// ----------------------------------------------------------------------------- + +void ImplGrafControl::GetFocus() +{ + maField.GrabFocus(); +} + +// ----------------------- +// - ImplGrafModeControl - +// ----------------------- + +class ImplGrafModeControl : public ListBox +{ + using Window::Update; +private: + USHORT mnCurPos; + Reference< XFrame > mxFrame; + + virtual void Select(); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + void ImplReleaseFocus(); + +public: + + ImplGrafModeControl( Window* pParent, const Reference< XFrame >& rFrame ); + ~ImplGrafModeControl(); + + void Update( const SfxPoolItem* pItem ); +}; + +// ----------------------------------------------------------------------------- + +ImplGrafModeControl::ImplGrafModeControl( Window* pParent, const Reference< XFrame >& rFrame ) : + ListBox( pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL ), + mnCurPos( 0 ), + mxFrame( rFrame ) +{ + SetSizePixel( Size( 100, 260 ) ); + + InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_STANDARD ) ); + InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_GREYS ) ); + InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_MONO ) ); + InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_WATERMARK ) ); + + Show(); +} + +// ----------------------------------------------------------------------- + +ImplGrafModeControl::~ImplGrafModeControl() +{ +} + +// ----------------------------------------------------------------------- + +void ImplGrafModeControl::Select() +{ + if ( !IsTravelSelect() ) + { + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GrafMode" )); + aArgs[0].Value = makeAny( sal_Int16( GetSelectEntryPos() )); + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + ImplReleaseFocus(); + + SfxToolBoxControl::Dispatch( + Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GrafMode" )), + aArgs ); + } +} + +// ----------------------------------------------------------------------- + +long ImplGrafModeControl::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + if( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) + mnCurPos = GetSelectEntryPos(); + + return ListBox::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long ImplGrafModeControl::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = ListBox::Notify( rNEvt ); + + if( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + + switch( pKEvt->GetKeyCode().GetCode() ) + { + case KEY_RETURN: + { + Select(); + nHandled = 1; + } + break; + + case KEY_ESCAPE: + { + SelectEntryPos( mnCurPos ); + ImplReleaseFocus(); + nHandled = 1; + } + break; + } + } + + return nHandled; +} + +// ----------------------------------------------------------------------- + +void ImplGrafModeControl::ImplReleaseFocus() +{ + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + + if( pShellWnd ) + pShellWnd->GrabFocus(); + } +} + +// ----------------------------------------------------------------------- + +void ImplGrafModeControl::Update( const SfxPoolItem* pItem ) +{ + if( pItem ) + SelectEntryPos( ((SfxUInt16Item*)pItem)->GetValue() ); + else + SetNoSelection(); +} + +// ----------------------- +// - ImplGrafFilterPopup - +// ----------------------- +/* +CD!!! +class ImplGrafFilterPopup : public SfxPopupWindow +{ +private: + + SvxGrafFilterToolBoxControl* mpParent; + Reference< XConfigurableUIElement > m_xToolBar; +// SfxToolBoxManager maTbxMgr; + ResId maResIdWin; + ResId maResIdTbx; + WindowAlign meTbxAlign; + Link maSelectHdl; + + DECL_LINK( TbxSelectHdl, void* ); + +public: + ImplGrafFilterPopup( USHORT nId, SvxGrafFilterToolBoxControl* pParent, + WindowAlign eAlign, + const ResId& rResIdWin, const ResId& rResIdTbx, + SfxBindings& rBindings ); + ~ImplGrafFilterPopup(); + + virtual SfxPopupWindow* Clone() const; + virtual void PopupModeEnd(); + + void StartSelection() { maTbxMgr.GetToolBox().StartSelection(); } + void Update(); +}; + +// ----------------------------------------------------------------------------- + +ImplGrafFilterPopup::ImplGrafFilterPopup( USHORT nId, SvxGrafFilterToolBoxControl* pParent, + WindowAlign eAlign, + const ResId& rResIdWin, const ResId& rResIdTbx ) : + SfxPopupWindow ( nId, rResIdWin ), + mpParent ( pParent ), + maTbxMgr ( this, GetBindings(), rResIdTbx ), + maResIdWin ( rResIdWin ), + maResIdTbx ( rResIdTbx ), + meTbxAlign ( eAlign ) +{ + maTbxMgr.UseDefault(); + + maSelectHdl = maTbxMgr.GetToolBox().GetSelectHdl(); + maTbxMgr.GetToolBox().SetSelectHdl( LINK( this, ImplGrafFilterPopup, TbxSelectHdl ) ); + + FreeResource(); + + const Size aSize( maTbxMgr.CalcWindowSizePixel() ); + maTbxMgr.SetPosSizePixel( Point(), aSize ); + SetOutputSizePixel( aSize ); +} + +// ----------------------------------------------------------------------------- + +ImplGrafFilterPopup::~ImplGrafFilterPopup() +{ +} + +// ----------------------------------------------------------------------------- + +SfxPopupWindow* ImplGrafFilterPopup::Clone() const +{ + return( new ImplGrafFilterPopup( GetId(), mpParent, meTbxAlign, + maResIdWin, maResIdTbx, + (SfxBindings&) GetBindings() ) ); +} + +// ----------------------------------------------------------------------------- + +void ImplGrafFilterPopup::Update() +{ + ToolBox* pBox = &maTbxMgr.GetToolBox(); + maTbxMgr.Activate( pBox ); + maTbxMgr.Deactivate( pBox ); +} + +// ----------------------------------------------------------------------------- + +void ImplGrafFilterPopup::PopupModeEnd() +{ + maTbxMgr.GetToolBox().EndSelection(); + SfxPopupWindow::PopupModeEnd(); +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImplGrafFilterPopup, TbxSelectHdl, void*, EMPTYARG ) +{ + const USHORT nSlotId = maTbxMgr.GetToolBox().GetCurItemId(); + + if( IsInPopupMode() ) + EndPopupMode(); + + GetBindings().GetDispatcher()->Execute( nSlotId, SFX_CALLMODE_ASYNCHRON ); + + return 0; +} +*/ +// ------------------------------- +// - SvxGrafFilterToolBoxControl - +// ------------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafFilterToolBoxControl, TbxImageItem ); + +// ----------------------------------------------------------------------------- + +SvxGrafFilterToolBoxControl::SvxGrafFilterToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------------- + +SvxGrafFilterToolBoxControl::~SvxGrafFilterToolBoxControl() +{ +} + +// ----------------------------------------------------------------------------- + +void SvxGrafFilterToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* ) +{ + GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) ); +} + +// ----------------------------------------------------------------------------- + +SfxPopupWindowType SvxGrafFilterToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------------- + +SfxPopupWindow* SvxGrafFilterToolBoxControl::CreatePopupWindow() +{ + rtl::OUString aSubTbxResName( + RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/graffilterbar" ) ); + createAndPositionSubToolBar( aSubTbxResName ); + + return NULL; +} + +// ------------------------- +// - SvxGrafToolBoxControl - +// ------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafToolBoxControl, SfxVoidItem ); + +// ----------------------------------------------------------------------------- + +SvxGrafToolBoxControl::SvxGrafToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------------- + +SvxGrafToolBoxControl::~SvxGrafToolBoxControl() +{ +} + +// ----------------------------------------------------------------------------- + +void SvxGrafToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState ) + +{ + ImplGrafControl* pCtrl = (ImplGrafControl*) GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pCtrl, "Control not found" ); + + if( eState == SFX_ITEM_DISABLED ) + { + pCtrl->Disable(); + pCtrl->SetText( String() ); + } + else + { + pCtrl->Enable(); + + if( eState == SFX_ITEM_AVAILABLE ) + pCtrl->Update( pState ); + else + pCtrl->Update( NULL ); + } +} + +// ----------------------------------------------------------------------------- + +Window* SvxGrafToolBoxControl::CreateItemWindow( Window *pParent ) +{ + return( new ImplGrafControl( pParent, GetSlotId(), m_aCommandURL, m_xFrame ) ); +} + +// ---------------------------- +// - SvxGrafRedToolBoxControl - +// ---------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafRedToolBoxControl, SfxInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafRedToolBoxControl::SvxGrafRedToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ------------------------------ +// - SvxGrafGreenToolBoxControl - +// ------------------------------ + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGreenToolBoxControl, SfxInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafGreenToolBoxControl::SvxGrafGreenToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ----------------------------- +// - SvxGrafBlueToolBoxControl - +// ----------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafBlueToolBoxControl, SfxInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafBlueToolBoxControl::SvxGrafBlueToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ---------------------------------- +// - SvxGrafLuminanceToolBoxControl - +// ---------------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafLuminanceToolBoxControl, SfxInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafLuminanceToolBoxControl::SvxGrafLuminanceToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ---------------------------------- +// - SvxGrafContrastToolBoxControl - +// ---------------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafContrastToolBoxControl, SfxInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafContrastToolBoxControl::SvxGrafContrastToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ------------------------------ +// - SvxGrafGammaToolBoxControl - +// ------------------------------ + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGammaToolBoxControl, SfxUInt32Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafGammaToolBoxControl::SvxGrafGammaToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ------------------------------------- +// - SvxGrafTransparenceToolBoxControl - +// ------------------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafTransparenceToolBoxControl, SfxUInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafTransparenceToolBoxControl::SvxGrafTransparenceToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxGrafToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ----------------------------- +// - SvxGrafModeToolBoxControl - +// ----------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( SvxGrafModeToolBoxControl, SfxUInt16Item ); + +// ----------------------------------------------------------------------------- + +SvxGrafModeToolBoxControl::SvxGrafModeToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ----------------------------------------------------------------------------- + +SvxGrafModeToolBoxControl::~SvxGrafModeToolBoxControl() +{ +} + +// ----------------------------------------------------------------------------- + +void SvxGrafModeToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState ) + +{ + ImplGrafModeControl* pCtrl = (ImplGrafModeControl*) GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pCtrl, "Control not found" ); + + if( eState == SFX_ITEM_DISABLED ) + { + pCtrl->Disable(); + pCtrl->SetText( String() ); + } + else + { + pCtrl->Enable(); + + if( eState == SFX_ITEM_AVAILABLE ) + pCtrl->Update( pState ); + else + pCtrl->Update( NULL ); + } +} + +// ----------------------------------------------------------------------------- + +Window* SvxGrafModeToolBoxControl::CreateItemWindow( Window *pParent ) +{ + return( new ImplGrafModeControl( pParent, m_xFrame ) ); +} + +// --------------------- +// - SvxGrafAttrHelper - +// --------------------- + +void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) +{ + SfxItemPool& rPool = rView.GetModel()->GetItemPool(); + SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST ); + + const bool bUndo = rView.IsUndoEnabled(); + + String aUndoStr; + + if( bUndo ) + { + aUndoStr = rView.GetDescriptionOfMarkedObjects(); + aUndoStr.Append( sal_Unicode(' ') ); + } + + const SfxItemSet* pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + USHORT nSlot = rReq.GetSlot(); + + if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, FALSE, &pItem )) + pItem = 0; + + switch( nSlot ) + { + case SID_ATTR_GRAF_RED: + { + if( pItem ) + { + aSet.Put( SdrGrafRedItem( ((SfxInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFRED ) ) ); + } + } + break; + + case SID_ATTR_GRAF_GREEN: + { + if( pItem ) + { + aSet.Put( SdrGrafGreenItem( ((SfxInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGREEN ) ) ); + } + } + break; + + case SID_ATTR_GRAF_BLUE: + { + if( pItem ) + { + aSet.Put( SdrGrafBlueItem( ((SfxInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFBLUE ) ) ); + } + } + break; + + case SID_ATTR_GRAF_LUMINANCE: + { + if( pItem ) + { + aSet.Put( SdrGrafLuminanceItem( ((SfxInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFLUMINANCE ) ) ); + } + } + break; + + case SID_ATTR_GRAF_CONTRAST: + { + if( pItem ) + { + aSet.Put( SdrGrafContrastItem( ((SfxInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCONTRAST ) ) ); + } + } + break; + + case SID_ATTR_GRAF_GAMMA: + { + if( pItem ) + { + aSet.Put( SdrGrafGamma100Item( ((SfxUInt32Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGAMMA ) ) ); + } + } + break; + + case SID_ATTR_GRAF_TRANSPARENCE: + { + if( pItem ) + { + aSet.Put( SdrGrafTransparenceItem( ((SfxUInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFTRANSPARENCY ) ) ); + } + } + break; + + case SID_ATTR_GRAF_MODE: + { + if( pItem ) + { + aSet.Put( SdrGrafModeItem( (GraphicDrawMode) ((SfxUInt16Item*)pItem)->GetValue() )); + if( bUndo ) + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFMODE ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_CROP ): + { + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + + if( 0 < rMarkList.GetMarkCount() ) + { + SdrGrafObj* pObj = (SdrGrafObj*) rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrGrafObj ) && + ( pObj->GetGraphicType() != GRAPHIC_NONE ) && + ( pObj->GetGraphicType() != GRAPHIC_DEFAULT ) ) + { + SfxItemSet aGrfAttr( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP, 0 ); + const SfxMapUnit eOldMetric = rPool.GetMetric( 0 ); + const MapMode aMap100( MAP_100TH_MM ); + const MapMode aMapTwip( MAP_TWIP ); + + aGrfAttr.Put(pObj->GetMergedItemSet()); + rPool.SetDefaultMetric( SFX_MAPUNIT_TWIP ); + + SfxItemSet aCropDlgAttr( rPool, + SDRATTR_GRAFCROP, SDRATTR_GRAFCROP, + SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE, + SID_ATTR_GRAF_CROP, SID_ATTR_GRAF_CROP, 0 ); + + aCropDlgAttr.Put( SvxBrushItem( pObj->GetGraphic(), GPOS_MM, SID_ATTR_GRAF_GRAPHIC ) ); + aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_PAGE_SIZE, + Size( OutputDevice::LogicToLogic( + Size( 200000, 200000 ), aMap100, aMapTwip ) ) ) ); + aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_GRAF_FRMSIZE, OutputDevice::LogicToLogic( + pObj->GetLogicRect().GetSize(), aMap100, aMapTwip ) ) ); + + const SdrGrafCropItem& rCrop = (const SdrGrafCropItem&) aGrfAttr.Get( SDRATTR_GRAFCROP ); + Size aLTSize( OutputDevice::LogicToLogic( + Size( rCrop.GetLeft(), rCrop.GetTop() ), aMap100, aMapTwip ) ); + Size aRBSize( OutputDevice::LogicToLogic( + Size( rCrop.GetRight(), rCrop.GetBottom() ), aMap100, aMapTwip ) ); + + aCropDlgAttr.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(), + aRBSize.Width(), aRBSize.Height() ) ); + + SfxSingleTabDialog aCropDialog( SfxViewShell::Current() ? SfxViewShell::Current()->GetWindow() : NULL, + aCropDlgAttr, 950 ); + const String aCropStr = SVX_RESSTR( RID_SVXSTR_GRAFCROP ); + + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet error!"); + ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP ); + DBG_ASSERT(fnCreatePage, "Dialogdiet error!"); + SfxTabPage* pTabPage = (*fnCreatePage)( &aCropDialog, aCropDlgAttr ); + + pTabPage->SetText( aCropStr ); + aCropDialog.SetTabPage( pTabPage ); + + if( aCropDialog.Execute() == RET_OK ) + { + const SfxItemSet* pOutAttr = aCropDialog.GetOutputItemSet(); + + if( pOutAttr ) + { + aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCROP ) ) ); + + // set crop attributes + if( SFX_ITEM_SET <= pOutAttr->GetItemState( SDRATTR_GRAFCROP ) ) + { + const SdrGrafCropItem& rNewCrop = (const SdrGrafCropItem&) pOutAttr->Get( SDRATTR_GRAFCROP ); + + aLTSize = OutputDevice::LogicToLogic( Size( rNewCrop.GetLeft(), rNewCrop.GetTop() ), aMapTwip, aMap100 ); + aRBSize = OutputDevice::LogicToLogic( Size( rNewCrop.GetRight(), rNewCrop.GetBottom() ), aMapTwip, aMap100 ); + aSet.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(), aRBSize.Width(), aRBSize.Height() ) ); + } + + // set new logic rect + if( SFX_ITEM_SET <= pOutAttr->GetItemState( SID_ATTR_GRAF_FRMSIZE ) ) + { + Point aNewOrigin( pObj->GetLogicRect().TopLeft() ); + const Size& rGrfSize = ( (const SvxSizeItem&) pOutAttr->Get( SID_ATTR_GRAF_FRMSIZE ) ).GetSize(); + Size aNewGrfSize( OutputDevice::LogicToLogic( rGrfSize, aMapTwip, aMap100 ) ); + Size aOldGrfSize( pObj->GetLogicRect().GetSize() ); + + Rectangle aNewRect( aNewOrigin, aNewGrfSize ); + Point aOffset( (aNewGrfSize.Width() - aOldGrfSize.Width()) >> 1, + (aNewGrfSize.Height() - aOldGrfSize.Height()) >> 1 ); + + // #106181# rotate snap rect before setting it + const GeoStat& aGeo = pObj->GetGeoStat(); + + if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) + { + Polygon aPol(aNewRect); + + // also transform origin offset + if (aGeo.nShearWink!=0) + { + ShearPoly(aPol, + aNewRect.TopLeft(), + aGeo.nTan); + ShearPoint(aOffset, Point(0,0), aGeo.nTan); + } + if (aGeo.nDrehWink!=0) + { + RotatePoly(aPol, + aNewRect.TopLeft(), + aGeo.nSin,aGeo.nCos); + RotatePoint(aOffset, Point(0,0), aGeo.nSin,aGeo.nCos); + } + + // apply offset + aPol.Move( -aOffset.X(), -aOffset.Y() ); + aNewRect=aPol.GetBoundRect(); + } + else + { + aNewRect.Move( -aOffset.X(), -aOffset.Y() ); + } + + if( !aSet.Count() ) + rView.SetMarkedObjRect( aNewRect ); + else + { + if( bUndo ) + { + rView.BegUndo( aUndoStr ); + rView.AddUndo( rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); + } + pObj->SetSnapRect( aNewRect ); + rView.SetAttributes( aSet ); + + if( bUndo ) + rView.EndUndo(); + aSet.ClearItem(); + } + } + } + } + + rPool.SetDefaultMetric( eOldMetric ); + } + } + } + break; + + case SID_COLOR_SETTINGS: + { + svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); + aToolboxAccess.toggleToolbox(); + rReq.Done(); + break; + } + + default: + break; + } + + if( aSet.Count() ) + { + if( bUndo ) + rView.BegUndo( aUndoStr ); + + rView.SetAttributes( aSet ); + + if( bUndo ) + rView.EndUndo(); + } +} + +// ----------------------------------------------------------------------------- + +void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) +{ + SfxItemPool& rPool = rView.GetModel()->GetItemPool(); + SfxItemSet aAttrSet( rPool ); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + rView.GetAttributes( aAttrSet ); + + while( nWhich ) + { + USHORT nSlotId = SfxItemPool::IsWhich( nWhich ) ? rPool.GetSlotId( nWhich ) : nWhich; + + switch( nSlotId ) + { + case( SID_ATTR_GRAF_MODE ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) ) + { + rSet.Put( SfxUInt16Item( nSlotId, + sal::static_int_cast< UINT16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_RED ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_GREEN ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_BLUE ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_LUMINANCE ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_CONTRAST ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_GAMMA ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) ) + { + rSet.Put( SfxUInt32Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + } + } + break; + + case( SID_ATTR_GRAF_TRANSPARENCE ): + { + if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) ) + { + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + BOOL bEnable = TRUE; + + for( USHORT i = 0, nCount = (USHORT) rMarkList.GetMarkCount(); + ( i < nCount ) && bEnable; i++ ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + if( !pObj || !pObj->ISA( SdrGrafObj ) || + ( (SdrGrafObj*) pObj )->HasGDIMetaFile() || + ( (SdrGrafObj*) pObj )->IsAnimated() ) + { + bEnable = FALSE; + } + } + + if( bEnable ) + rSet.Put( SfxUInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) ); + else + rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE ); + } + } + break; + + case( SID_ATTR_GRAF_CROP ): + { + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + BOOL bDisable = TRUE; + + if( 1 == rMarkList.GetMarkCount() ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrGrafObj ) ) + { + SdrGrafObj* pGrafObj = (SdrGrafObj*) pObj; + + if( ( pGrafObj->GetGraphicType() != GRAPHIC_NONE ) && + ( pGrafObj->GetGraphicType() != GRAPHIC_DEFAULT ) ) + { + bDisable = FALSE; + } + } + } + + if( bDisable ) + rSet.DisableItem( nSlotId ); + } + break; + + case SID_COLOR_SETTINGS : + { + svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); + rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) ); + break; + } + + default: + break; + } + + nWhich = aIter.NextWhich(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/grafctrl.hrc b/svx/source/tbxctrls/grafctrl.hrc new file mode 100644 index 000000000000..2da0c45c8a42 --- /dev/null +++ b/svx/source/tbxctrls/grafctrl.hrc @@ -0,0 +1,28 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#define TBX_GRFFILTER 1 diff --git a/svx/source/tbxctrls/grafctrl.src b/svx/source/tbxctrls/grafctrl.src new file mode 100644 index 000000000000..3ca726bfde7f --- /dev/null +++ b/svx/source/tbxctrls/grafctrl.src @@ -0,0 +1,192 @@ +/************************************************************************* + * + * 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 "grafctrl.hrc" +#include <svx/dialogs.hrc> +#include "helpid.hrc" +#include <svx/svxids.hrc> + +FloatingWindow RID_SVXTBX_GRFFILTER +{ + HelpId = HID_GRFFILTER; + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE ; + SVLook = TRUE ; + Text [ en-US ] = "Filters" ; + ToolBox TBX_GRFFILTER + { + SVLook = TRUE ; + MenuStrings = TRUE ; + Align = BOXALIGN_TOP; + LineCount = 3; + ItemList = + { + ToolBoxItem + { + Identifier = SID_GRFFILTER_INVERT ; + HelpID = HID_GRFFILTER_INVERT ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_SMOOTH ; + HelpID = HID_GRFFILTER_SMOOTH ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_SHARPEN ; + HelpID = HID_GRFFILTER_SHARPEN ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_REMOVENOISE ; + HelpID = HID_GRFFILTER_REMOVENOISE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_BREAK ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_SOLARIZE ; + HelpId = HID_GRFFILTER_SOLARIZE ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_SEPIA ; + HelpId = HID_GRFFILTER_SEPIA ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_POSTER ; + HelpId = HID_GRFFILTER_POSTER ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_POPART ; + HelpId = HID_GRFFILTER_POPART ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_BREAK ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_SOBEL ; + HelpId = HID_GRFFILTER_SOBEL ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_EMBOSS ; + HelpId = HID_GRFFILTER_EMBOSS ; + }; + ToolBoxItem + { + Identifier = SID_GRFFILTER_MOSAIC ; + HelpId = HID_GRFFILTER_MOSAIC ; + }; + }; + }; +}; + +// ----------- +// - Strings - +// ----------- + +String RID_SVXSTR_UNDO_GRAFMODE +{ + Text [ en-US ] = "Graphics Mode"; +}; +String RID_SVXSTR_UNDO_GRAFRED +{ + Text [ en-US ] = "Red"; +}; +String RID_SVXSTR_UNDO_GRAFGREEN +{ + Text [ en-US ] = "Green"; +}; +String RID_SVXSTR_UNDO_GRAFBLUE +{ + Text [ en-US ] = "Blue"; +}; +String RID_SVXSTR_UNDO_GRAFLUMINANCE +{ + Text [ en-US ] = "Brightness"; +}; +String RID_SVXSTR_UNDO_GRAFCONTRAST +{ + Text [ en-US ] = "Contrast"; +}; +String RID_SVXSTR_UNDO_GRAFGAMMA +{ + Text [ en-US ] = "Gamma"; +}; +String RID_SVXSTR_UNDO_GRAFTRANSPARENCY +{ + Text [ en-US ] = "Transparency"; +}; +String RID_SVXSTR_GRAFCROP +{ + Text [ en-US ] = "Crop"; +}; + +// ********************************************************************** EOF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx new file mode 100644 index 000000000000..056392c1de71 --- /dev/null +++ b/svx/source/tbxctrls/itemwin.cxx @@ -0,0 +1,801 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 --------------------------------------------------------------- +#include <tools/shl.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/module.hxx> +#include <tools/urlobj.hxx> + +#define _SVX_ITEMWIN_CXX + +#include <vcl/svapp.hxx> + +#include <svx/dialogs.hrc> + +#define DELAY_TIMEOUT 100 + +#include <svx/xlnclit.hxx> +#include <svx/xlnwtit.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xtable.hxx> +#include "drawitem.hxx" +#include <svx/dialmgr.hxx> +#include "dlgutil.hxx" +#include <svx/itemwin.hxx> +#include "linectrl.hxx" +#include <svtools/colorcfg.hxx> + +#include "linectrl.hrc" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; + +#define LOGICAL_EDIT_HEIGHT 12 +//======================================================================== +// SvxLineBox +//======================================================================== + +SvxLineBox::SvxLineBox( Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) : + LineLB( pParent, nBits ), + nCurPos ( 0 ), + aLogicalSize(40,140), + bRelease ( TRUE ), + mpSh ( NULL ), + mxFrame ( rFrame ) +{ + SetSizePixel( LogicToPixel( aLogicalSize, MAP_APPFONT )); + Show(); + + aDelayTimer.SetTimeout( DELAY_TIMEOUT ); + aDelayTimer.SetTimeoutHdl( LINK( this, SvxLineBox, DelayHdl_Impl ) ); + aDelayTimer.Start(); +} + +// ----------------------------------------------------------------------- + +SvxLineBox::~SvxLineBox() +{ +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxLineBox, DelayHdl_Impl, Timer *, EMPTYARG ) +{ + if ( GetEntryCount() == 0 ) + { + mpSh = SfxObjectShell::Current(); + FillControl(); + } + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxLineBox::Select() +{ + // Call the parent's Select() member to trigger accessibility events. + LineLB::Select(); + + if ( !IsTravelSelect() ) + { + XLineStyle eXLS; + USHORT nPos = GetSelectEntryPos(); + + switch ( nPos ) + { + case 0: + eXLS = XLINE_NONE; + break; + + case 1: + eXLS = XLINE_SOLID; + break; + + default: + { + eXLS = XLINE_DASH; + + if ( nPos != LISTBOX_ENTRY_NOTFOUND && + SfxObjectShell::Current() && + SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) + { + // LineDashItem wird nur geschickt, wenn es auch einen Dash besitzt. + // Notify k"ummert sich darum! + SvxDashListItem aItem( *(const SvxDashListItem*)( + SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) ); + XLineDashItem aLineDashItem( GetSelectEntry(), + aItem.GetDashList()->GetDash( nPos - 2 )->GetDash() ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" )); + aLineDashItem.QueryValue ( a ); + aArgs[0].Value = a; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )), + aArgs ); + } + } + break; + } + + XLineStyleItem aLineStyleItem( eXLS ); + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XLineStyle" )); + aLineStyleItem.QueryValue ( a ); + aArgs[0].Value = a; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:XLineStyle" )), + aArgs ); + + nCurPos = GetSelectEntryPos(); + ReleaseFocus_Impl(); + } +} + +// ----------------------------------------------------------------------- + +long SvxLineBox::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + switch(nType) + { + case EVENT_MOUSEBUTTONDOWN: + case EVENT_GETFOCUS: + nCurPos = GetSelectEntryPos(); + break; + case EVENT_LOSEFOCUS: + SelectEntryPos(nCurPos); + break; + case EVENT_KEYINPUT: + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + if( pKEvt->GetKeyCode().GetCode() == KEY_TAB) + { + bRelease = FALSE; + Select(); + } + } + break; + } + return LineLB::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxLineBox::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = LineLB::Notify( rNEvt ); + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + + switch ( pKEvt->GetKeyCode().GetCode() ) + { + case KEY_RETURN: + Select(); + nHandled = 1; + break; + + case KEY_ESCAPE: + SelectEntryPos( nCurPos ); + ReleaseFocus_Impl(); + nHandled = 1; + break; + } + } + return nHandled; +} + +// ----------------------------------------------------------------------- + +void SvxLineBox::ReleaseFocus_Impl() +{ + if(!bRelease) + { + bRelease = TRUE; + return; + } + + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + + if ( pShellWnd ) + pShellWnd->GrabFocus(); + } +} + +void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); + Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT); + SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT)); + } + + LineLB::DataChanged( rDCEvt ); +} + +void SvxLineBox::FillControl() +{ + FillStyles(); + if ( !mpSh ) + mpSh = SfxObjectShell::Current(); + + if( mpSh ) + { + const SvxDashListItem* pItem = (const SvxDashListItem*)( mpSh->GetItem( SID_DASH_LIST ) ); + if ( pItem ) + Fill( pItem->GetDashList() ); + } +} + +//======================================================================== +// SvxColorBox +//======================================================================== + +SvxColorBox::SvxColorBox( + Window* pParent, + const ::rtl::OUString& rCommand, + const Reference< XFrame >& rFrame, + WinBits nBits ) : + ColorLB( pParent, nBits ), + nCurPos ( 0 ), + aLogicalSize(45,80), + bRelease ( TRUE ), + maCommand ( rCommand ), + mxFrame ( rFrame ) +{ + SetSizePixel( LogicToPixel( aLogicalSize , MAP_APPFONT)); + Show(); + + SfxObjectShell* pSh = SfxObjectShell::Current(); + + if ( pSh ) + { + const SvxColorTableItem* pItem = + (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) ); + if(pItem) + Fill( pItem->GetColorTable() ); + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxColorBox, DelayHdl_Impl, Timer *, EMPTYARG ) +{ + SfxObjectShell* pSh = SfxObjectShell::Current(); + + if ( pSh ) + { + const SvxColorTableItem* pItem = (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) ); + if ( pItem ) + Fill( pItem->GetColorTable() ); + } + return 0; +} + +// ----------------------------------------------------------------------- + +SvxColorBox::~SvxColorBox() +{ +} + +// ----------------------------------------------------------------------- + +void SvxColorBox::Update( const XLineColorItem* pItem ) +{ + if ( pItem ) + SelectEntry( pItem->GetColorValue() ); + else + SetNoSelection(); +} + +// ----------------------------------------------------------------------- + +void SvxColorBox::Select() +{ + // OJ: base class call needed here because otherwise no event is send for accessibility + ColorLB::Select(); + if ( !IsTravelSelect() ) + { + XLineColorItem aLineColorItem( GetSelectEntry(), GetSelectEntryColor() ); + + INetURLObject aObj( maCommand ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + aLineColorItem.QueryValue( a ); + aArgs[0].Value = a; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + maCommand, + aArgs ); + + nCurPos = GetSelectEntryPos(); + ReleaseFocus_Impl(); + } +} + +// ----------------------------------------------------------------------- + +long SvxColorBox::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + switch(nType) + { + case EVENT_MOUSEBUTTONDOWN: + case EVENT_GETFOCUS: + nCurPos = GetSelectEntryPos(); + break; + case EVENT_LOSEFOCUS: + SelectEntryPos(nCurPos); + break; + case EVENT_KEYINPUT: + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + + if( pKEvt->GetKeyCode().GetCode() == KEY_TAB) + { + bRelease = FALSE; + Select(); + } + } + } + + return ColorLB::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxColorBox::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = ColorLB::Notify( rNEvt ); + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + + switch ( pKEvt->GetKeyCode().GetCode() ) + { + case KEY_RETURN: + Select(); + nHandled = 1; + break; + + case KEY_ESCAPE: + SelectEntryPos( nCurPos ); + ReleaseFocus_Impl(); + nHandled = 1; + break; + } + } + return nHandled; +} + +void SvxColorBox::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); + Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT); + SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT)); + } + + ColorLB::DataChanged( rDCEvt ); +} +// ----------------------------------------------------------------------- + +void SvxColorBox::ReleaseFocus_Impl() +{ + if(!bRelease) + { + bRelease = TRUE; + return; + } + + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + + if ( pShellWnd ) + pShellWnd->GrabFocus(); + } +} + +//======================================================================== +// SvxMetricField +//======================================================================== + +SvxMetricField::SvxMetricField( + Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) : + MetricField( pParent, nBits ), + aCurTxt( String() ), + mxFrame( rFrame ) +{ + Size aSize = Size(GetTextWidth( String::CreateFromAscii("99,99mm") ),GetTextHeight()); + aSize.Width() += 20; + aSize.Height() += 6; + SetSizePixel( aSize ); + aLogicalSize = PixelToLogic(aSize, MAP_APPFONT); + SetUnit( FUNIT_MM ); + SetDecimalDigits( 2 ); + SetMax( 5000 ); + SetMin( 0 ); + SetLast( 5000 ); + SetFirst( 0 ); + + eDlgUnit = SfxModule::GetCurrentFieldUnit(); + SetFieldUnit( *this, eDlgUnit, FALSE ); + Show(); +} + +// ----------------------------------------------------------------------- + +SvxMetricField::~SvxMetricField() +{ +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::Update( const XLineWidthItem* pItem ) +{ + if ( pItem ) + { + if ( pItem->GetValue() != GetCoreValue( *this, ePoolUnit ) ) + SetMetricValue( *this, pItem->GetValue(), ePoolUnit ); + } + else + SetText( String() ); +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::Modify() +{ + MetricField::Modify(); + long nTmp = GetCoreValue( *this, ePoolUnit ); + XLineWidthItem aLineWidthItem( nTmp ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" )); + aLineWidthItem.QueryValue( a ); + aArgs[0].Value = a; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineWidth" )), + aArgs ); +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::ReleaseFocus_Impl() +{ + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + if ( pShellWnd ) + pShellWnd->GrabFocus(); + } +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::Down() +{ + sal_Int64 nValue = GetValue(); + nValue -= GetSpinSize(); + + // Um unter OS/2 einen Sprung auf Max zu verhindern + if ( nValue >= GetMin() ) + MetricField::Down(); +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::Up() +{ + MetricField::Up(); +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit ) +{ + ePoolUnit = eUnit; +} + +// ----------------------------------------------------------------------- + +void SvxMetricField::RefreshDlgUnit() +{ + FieldUnit eTmpUnit = SfxModule::GetCurrentFieldUnit(); + if ( eDlgUnit != eTmpUnit ) + { + eDlgUnit = eTmpUnit; + SetFieldUnit( *this, eDlgUnit, FALSE ); + } +} + +// ----------------------------------------------------------------------- + +long SvxMetricField::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) + aCurTxt = GetText(); + + return MetricField::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxMetricField::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = MetricField::Notify( rNEvt ); + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + const KeyCode& rKey = pKEvt->GetKeyCode(); + SfxViewShell* pSh = SfxViewShell::Current(); + + if ( rKey.GetModifier() && rKey.GetGroup() != KEYGROUP_CURSOR && pSh ) + pSh->KeyInput( *pKEvt ); + else + { + bool bHandled = false; + + switch ( rKey.GetCode() ) + { + case KEY_RETURN: + Reformat(); + bHandled = true; + break; + + case KEY_ESCAPE: + SetText( aCurTxt ); + bHandled = true; + break; + } + + if ( bHandled ) + { + nHandled = 1; + Modify(); + ReleaseFocus_Impl(); + } + } + } + return nHandled; +} + +void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); + } + + MetricField::DataChanged( rDCEvt ); +} + +//======================================================================== +// SvxFillTypeBox +//======================================================================== + +SvxFillTypeBox::SvxFillTypeBox( Window* pParent, WinBits nBits ) : + FillTypeLB( pParent, nBits | WB_TABSTOP ), + nCurPos ( 0 ), + bSelect ( FALSE ), + bRelease(TRUE) +{ + SetSizePixel( LogicToPixel( Size(40, 40 ),MAP_APPFONT )); + Fill(); + SelectEntryPos( XFILL_SOLID ); + Show(); +} + +// ----------------------------------------------------------------------- + +SvxFillTypeBox::~SvxFillTypeBox() +{ +} + +// ----------------------------------------------------------------------- + +long SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) + nCurPos = GetSelectEntryPos(); + else if ( EVENT_LOSEFOCUS == nType + && Application::GetFocusWindow() + && !IsWindowOrChild( Application::GetFocusWindow(), TRUE ) ) + { + if ( !bSelect ) + SelectEntryPos( nCurPos ); + else + bSelect = FALSE; + } + + return FillTypeLB::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxFillTypeBox::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = FillTypeLB::Notify( rNEvt ); + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + switch ( pKEvt->GetKeyCode().GetCode() ) + { + case KEY_RETURN: + nHandled = 1; + ( (Link&)GetSelectHdl() ).Call( this ); + break; + case KEY_TAB: + bRelease = FALSE; + ( (Link&)GetSelectHdl() ).Call( this ); + bRelease = TRUE; + break; + + case KEY_ESCAPE: + SelectEntryPos( nCurPos ); + ReleaseFocus_Impl(); + nHandled = 1; + break; + } + } + return nHandled; +} + +// ----------------------------------------------------------------------- + +void SvxFillTypeBox::ReleaseFocus_Impl() +{ + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + + if ( pShellWnd ) + pShellWnd->GrabFocus(); + } +} + +//======================================================================== +// SvxFillAttrBox +//======================================================================== + +SvxFillAttrBox::SvxFillAttrBox( Window* pParent, WinBits nBits ) : + + FillAttrLB( pParent, nBits | WB_TABSTOP ), + + nCurPos( 0 ), + bRelease( TRUE ) + +{ + SetPosPixel( Point( 90, 0 ) ); + SetSizePixel( LogicToPixel( Size(50, 80 ), MAP_APPFONT )); + Show(); +} + +// ----------------------------------------------------------------------- + +SvxFillAttrBox::~SvxFillAttrBox() +{ +} + +// ----------------------------------------------------------------------- + +long SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) + nCurPos = GetSelectEntryPos(); + + return FillAttrLB::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxFillAttrBox::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = FillAttrLB::Notify( rNEvt ); + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); + + switch ( pKEvt->GetKeyCode().GetCode() ) + { + case KEY_RETURN: + ( (Link&)GetSelectHdl() ).Call( this ); + nHandled = 1; + break; + case KEY_TAB: + bRelease = FALSE; + GetSelectHdl().Call( this ); + bRelease = TRUE; + break; + case KEY_ESCAPE: + SelectEntryPos( nCurPos ); + ReleaseFocus_Impl(); + nHandled = 1; + break; + } + } + return nHandled; +} + +// ----------------------------------------------------------------------- + +void SvxFillAttrBox::Select() +{ + FillAttrLB::Select(); +} + +// ----------------------------------------------------------------------- + +void SvxFillAttrBox::ReleaseFocus_Impl() +{ + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + + if ( pShellWnd ) + pShellWnd->GrabFocus(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/layctrl.cxx b/svx/source/tbxctrls/layctrl.cxx new file mode 100644 index 000000000000..c67194929ce9 --- /dev/null +++ b/svx/source/tbxctrls/layctrl.cxx @@ -0,0 +1,844 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 --------------------------------------------------------------- + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headers +#include <vcl/toolbox.hxx> +#include <vcl/button.hxx> +#include <svl/intitem.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/app.hxx> + +#include <svx/dialogs.hrc> +#include "layctrl.hxx" +#include <svx/dialmgr.hxx> +#include <comphelper/processfactory.hxx> +#include <svtools/colorcfg.hxx> + +// namespaces +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::frame; + +SFX_IMPL_TOOLBOX_CONTROL(SvxTableToolBoxControl,SfxUInt16Item); +SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl,SfxUInt16Item); + +// class TableWindow ----------------------------------------------------- + +const long TABLE_CELL_WIDTH = 15; +const long TABLE_CELL_HEIGHT = 15; + +const long TABLE_CELLS_HORIZ = 10; +const long TABLE_CELLS_VERT = 15; + +const long TABLE_POS_X = 2; +const long TABLE_POS_Y = 2; + +const long TABLE_WIDTH = TABLE_POS_X + TABLE_CELLS_HORIZ*TABLE_CELL_WIDTH; +const long TABLE_HEIGHT = TABLE_POS_Y + TABLE_CELLS_VERT*TABLE_CELL_HEIGHT; + +class TableWindow : public SfxPopupWindow +{ +private: + PushButton aTableButton; + ::Color aLineColor; + ::Color aFillColor; + ::Color aHighlightFillColor; + ::Color aBackgroundColor; + long nCol; + long nLine; + BOOL bInitialKeyInput; + BOOL m_bMod1; + ToolBox& rTbx; + Reference< XFrame > mxFrame; + rtl::OUString maCommand; + + DECL_LINK( SelectHdl, void * ); + +public: + TableWindow( USHORT nSlotId, + const rtl::OUString& rCmd, + const String& rText, + ToolBox& rParentTbx, + const Reference< XFrame >& rFrame ); + ~TableWindow(); + + void KeyInput( const KeyEvent& rKEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void Paint( const Rectangle& ); + virtual void PopupModeEnd(); + virtual SfxPopupWindow* Clone() const; + +private: + void Update( long nNewCol, long nNewLine ); + void TableDialog( const Sequence< PropertyValue >& rArgs ); + void CloseAndShowTableDialog(); +}; + +// ----------------------------------------------------------------------- + +IMPL_LINK( TableWindow, SelectHdl, void *, EMPTYARG ) +{ + CloseAndShowTableDialog(); + return 0; +} + +// ----------------------------------------------------------------------- + +TableWindow::TableWindow( USHORT nSlotId, const rtl::OUString& rCmd, const String& rText, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) : + SfxPopupWindow( nSlotId, rFrame, WinBits( WB_STDPOPUP ) ), + aTableButton( this ), + nCol( 0 ), + nLine( 0 ), + bInitialKeyInput(TRUE), + m_bMod1(FALSE), + rTbx(rParentTbx), + mxFrame( rFrame ), + maCommand( rCmd ) +{ + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); + svtools::ColorConfig aColorConfig; + + aLineColor = rStyles.GetShadowColor(); + aFillColor = rStyles.GetWindowColor(); + aHighlightFillColor = rStyles.GetHighlightColor(); + aBackgroundColor = GetSettings().GetStyleSettings().GetFaceColor(); + + SetBackground( aBackgroundColor ); + Font aFont = GetFont(); + aFont.SetColor( ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ) ); + aFont.SetFillColor( aBackgroundColor ); + aFont.SetTransparent( FALSE ); + SetFont( aFont ); + + SetText( rText ); + + aTableButton.SetPosSizePixel( Point( TABLE_POS_X + TABLE_CELL_WIDTH, TABLE_HEIGHT + 5 ), + Size( TABLE_WIDTH - TABLE_POS_X - 2*TABLE_CELL_WIDTH, 24 ) ); + aTableButton.SetText( String( SVX_RESSTR( RID_SVXSTR_MORE ) ) ); + aTableButton.SetClickHdl( LINK( this, TableWindow, SelectHdl ) ); + aTableButton.Show(); + + SetOutputSizePixel( Size( TABLE_WIDTH + 3, TABLE_HEIGHT + 33 ) ); +} + +// ----------------------------------------------------------------------- + +TableWindow::~TableWindow() +{ +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* TableWindow::Clone() const +{ + return new TableWindow( GetId(), maCommand, GetText(), rTbx, mxFrame ); +} + +// ----------------------------------------------------------------------- + +void TableWindow::MouseMove( const MouseEvent& rMEvt ) +{ + SfxPopupWindow::MouseMove( rMEvt ); + Point aPos = rMEvt.GetPosPixel(); + Point aMousePos( aPos ); + + long nNewCol = ( aMousePos.X() - TABLE_POS_X + TABLE_CELL_WIDTH ) / TABLE_CELL_WIDTH; + long nNewLine = ( aMousePos.Y() - TABLE_POS_Y + TABLE_CELL_HEIGHT ) / TABLE_CELL_HEIGHT; + + Update( nNewCol, nNewLine ); +} + +// ----------------------------------------------------------------------- + +void TableWindow::KeyInput( const KeyEvent& rKEvt ) +{ + bool bHandled = false; + USHORT nModifier = rKEvt.GetKeyCode().GetModifier(); + USHORT nKey = rKEvt.GetKeyCode().GetCode(); + if ( !nModifier ) + { + bHandled = true; + long nNewCol = nCol; + long nNewLine = nLine; + switch(nKey) + { + case KEY_UP: + if ( nNewLine > 1 ) + nNewLine--; + else + EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL ); + break; + case KEY_DOWN: + if ( nNewLine < TABLE_CELLS_VERT ) + nNewLine++; + else + CloseAndShowTableDialog(); + break; + case KEY_LEFT: + if ( nNewCol > 1 ) + nNewCol--; + else + EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL ); + break; + case KEY_RIGHT: + if ( nNewCol < TABLE_CELLS_HORIZ ) + nNewCol++; + else + CloseAndShowTableDialog(); + break; + case KEY_ESCAPE: + EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL ); + break; + case KEY_RETURN: + EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); + break; + case KEY_TAB: + CloseAndShowTableDialog(); + break; + default: + bHandled = false; + } + if ( bHandled ) + { + //make sure that a table can initially be created + if(bInitialKeyInput) + { + bInitialKeyInput = FALSE; + if(!nNewLine) + nNewLine = 1; + if(!nNewCol) + nNewCol = 1; + } + Update( nNewCol, nNewLine ); + } + } + else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey) + { + m_bMod1 = TRUE; + EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); + } + + if(!bHandled) + SfxPopupWindow::KeyInput(rKEvt); +} + +// ----------------------------------------------------------------------- + +void TableWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + SfxPopupWindow::MouseButtonUp( rMEvt ); + EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); +} + +// ----------------------------------------------------------------------- + +void TableWindow::Paint( const Rectangle& ) +{ + const long nSelectionWidth = TABLE_POS_X + nCol*TABLE_CELL_WIDTH; + const long nSelectionHeight = TABLE_POS_Y + nLine*TABLE_CELL_HEIGHT; + + // the non-selected parts of the table + SetLineColor( aLineColor ); + SetFillColor( aFillColor ); + DrawRect( Rectangle( nSelectionWidth, TABLE_POS_Y, TABLE_WIDTH, nSelectionHeight ) ); + DrawRect( Rectangle( TABLE_POS_X, nSelectionHeight, nSelectionWidth, TABLE_HEIGHT ) ); + DrawRect( Rectangle( nSelectionWidth, nSelectionHeight, TABLE_WIDTH, TABLE_HEIGHT ) ); + + // the selection + if ( nCol > 0 && nLine > 0 ) + { + SetFillColor( aHighlightFillColor ); + DrawRect( Rectangle( TABLE_POS_X, TABLE_POS_Y, + nSelectionWidth, nSelectionHeight ) ); + } + + // lines inside of the table + SetLineColor( aLineColor ); + for ( long i = 1; i < TABLE_CELLS_VERT; ++i ) + DrawLine( Point( TABLE_POS_X, TABLE_POS_Y + i*TABLE_CELL_HEIGHT ), + Point( TABLE_WIDTH, TABLE_POS_Y + i*TABLE_CELL_HEIGHT ) ); + + for ( long i = 1; i < TABLE_CELLS_HORIZ; ++i ) + DrawLine( Point( TABLE_POS_X + i*TABLE_CELL_WIDTH, TABLE_POS_Y ), + Point( TABLE_POS_X + i*TABLE_CELL_WIDTH, TABLE_HEIGHT ) ); + + // the text near the mouse cursor telling the table dimensions + if ( nCol && nLine ) + { + String aText; + aText += String::CreateFromInt32( nCol ); + aText.AppendAscii( " x " ); + aText += String::CreateFromInt32( nLine ); + if(GetId() == FN_SHOW_MULTIPLE_PAGES) + { + aText += ' '; + aText += String(SVX_RESSTR(RID_SVXSTR_PAGES)); + } + + Size aSize = GetOutputSizePixel(); + Size aTextSize( GetTextWidth( aText ), GetTextHeight() ); + + long nTextX = nSelectionWidth + TABLE_CELL_WIDTH; + long nTextY = nSelectionHeight + TABLE_CELL_HEIGHT; + const long nTipBorder = 2; + + if ( aTextSize.Width() + TABLE_POS_X + TABLE_CELL_WIDTH + 2*nTipBorder < nSelectionWidth ) + nTextX = nSelectionWidth - TABLE_CELL_WIDTH - aTextSize.Width(); + + if ( aTextSize.Height() + TABLE_POS_Y + TABLE_CELL_HEIGHT + 2*nTipBorder < nSelectionHeight ) + nTextY = nSelectionHeight - TABLE_CELL_HEIGHT - aTextSize.Height(); + + SetLineColor( aLineColor ); + SetFillColor( aBackgroundColor ); + DrawRect( Rectangle ( nTextX - 2*nTipBorder, nTextY - 2*nTipBorder, + nTextX + aTextSize.Width() + nTipBorder, nTextY + aTextSize.Height() + nTipBorder ) ); + + // #i95350# force RTL output + if ( IsRTLEnabled() ) + aText.Insert( 0x202D, 0 ); + + DrawText( Point( nTextX, nTextY ), aText ); + } +} + +// ----------------------------------------------------------------------- + +void TableWindow::PopupModeEnd() +{ + if ( !IsPopupModeCanceled() && nCol && nLine ) + { + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" )); + aArgs[0].Value = makeAny( sal_Int16( nCol )); + aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rows" )); + aArgs[1].Value = makeAny( sal_Int16( nLine )); + + TableDialog( aArgs ); + } + + SfxPopupWindow::PopupModeEnd(); +} + +// ----------------------------------------------------------------------- + +void TableWindow::Update( long nNewCol, long nNewLine ) +{ + if ( nNewCol < 0 || nNewCol > TABLE_CELLS_HORIZ ) + nNewCol = 0; + + if ( nNewLine < 0 || nNewLine > TABLE_CELLS_VERT ) + nNewLine = 0; + + if ( nNewCol != nCol || nNewLine != nLine ) + { + nCol = nNewCol; + nLine = nNewLine; + Invalidate( Rectangle( TABLE_POS_X, TABLE_POS_Y, TABLE_WIDTH, TABLE_HEIGHT ) ); + } +} + +// ----------------------------------------------------------------------- + +void TableWindow::TableDialog( const Sequence< PropertyValue >& rArgs ) +{ + Window* pParent = rTbx.GetParent(); + USHORT nId = GetId(); + pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId)); + + Reference< XDispatchProvider > xDispatchProvider( mxFrame, UNO_QUERY ); + if ( xDispatchProvider.is() ) + { + com::sun::star::util::URL aTargetURL; + Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer"))), + UNO_QUERY ); + aTargetURL.Complete = maCommand; + xTrans->parseStrict( aTargetURL ); + + Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); + if ( xDispatch.is() ) + xDispatch->dispatch( aTargetURL, rArgs ); + } +} + +// ----------------------------------------------------------------------- + +void TableWindow::CloseAndShowTableDialog() +{ + // close the toolbar tool + EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL ); + + // and open the table dialog instead + TableDialog( Sequence< PropertyValue >() ); +} + +// class ColumnsWindow --------------------------------------------------- + +class ColumnsWindow : public SfxPopupWindow +{ +private: + ::Color aLineColor; + ::Color aHighlightLineColor; + ::Color aFillColor; + ::Color aHighlightFillColor; + ::Color aFaceColor; + long nCol; + long nWidth; + long nMX; + long nTextHeight; + BOOL bInitialKeyInput; + BOOL m_bMod1; + ToolBox& rTbx; + Reference< XFrame > mxFrame; + ::rtl::OUString maCommand; + + void UpdateSize_Impl( long nNewCol ); +public: + ColumnsWindow( USHORT nId, const ::rtl::OUString& rCmd, const String& rText, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ); + + void KeyInput( const KeyEvent& rKEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void Paint( const Rectangle& ); + virtual void PopupModeEnd(); + virtual SfxPopupWindow* Clone() const; + + USHORT GetColCount() const { return (USHORT)nCol; } +}; + +// ----------------------------------------------------------------------- + +ColumnsWindow::ColumnsWindow( USHORT nId, const ::rtl::OUString& rCmd, const String& rText, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) : + SfxPopupWindow( nId, rFrame, WB_STDPOPUP ), + bInitialKeyInput(TRUE), + m_bMod1(FALSE), + rTbx(rParentTbx), + mxFrame(rFrame), + maCommand( rCmd ) +{ + const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); + svtools::ColorConfig aColorConfig; + aLineColor = ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); + aHighlightLineColor = rStyles.GetHighlightTextColor(); + aFillColor = rStyles.GetWindowColor(); + aHighlightFillColor = rStyles.GetHighlightColor(); + aFaceColor = rStyles.GetFaceColor(); + + nTextHeight = GetTextHeight()+1; + SetBackground(); + Font aFont( GetFont() ); + aFont.SetColor( aLineColor ); + aFont.SetFillColor( aFaceColor ); + aFont.SetTransparent( FALSE ); + SetFont( aFont ); + + nCol = 0; + nWidth = 4; + + SetText( rText ); + + Size aLogicSize = LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM ) ); + nMX = aLogicSize.Width(); + SetOutputSizePixel( Size( nMX*nWidth-1, aLogicSize.Height()+nTextHeight ) ); + StartCascading(); +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* ColumnsWindow::Clone() const +{ + return new ColumnsWindow( GetId(), maCommand, GetText(), rTbx, mxFrame ); +} + +// ----------------------------------------------------------------------- + +void ColumnsWindow::MouseMove( const MouseEvent& rMEvt ) +{ + SfxPopupWindow::MouseMove( rMEvt ); + Point aPos = rMEvt.GetPosPixel(); + Point aMousePos = aPos; + Point aWinPos = GetPosPixel(); + + if ( rMEvt.IsEnterWindow() ) + CaptureMouse(); + else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 ) + { + nCol = 0; + ReleaseMouse(); + Invalidate(); + return; + } + + long nNewCol = 0; + if ( aPos.X() > 0 ) + nNewCol = aPos.X() / nMX + 1; + if ( aPos.Y() < 0 ) + nNewCol = 0; + if ( nNewCol > 20 ) + nNewCol = 20; + UpdateSize_Impl( nNewCol ); +} + +void ColumnsWindow::UpdateSize_Impl( long nNewCol ) +{ + Size aWinSize = GetOutputSizePixel(); + Point aWinPos;// = GetPosPixel(); + + if ( nWidth <= nNewCol ) + { + Point aMaxPos = OutputToScreenPixel( GetDesktopRectPixel().BottomRight() ); + + if ( nWidth <= nNewCol ) + { + nWidth = nNewCol; + nWidth++; + } + + while ( nWidth > 0 && + (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 ) + nWidth--; + + if ( nNewCol > nWidth ) + nNewCol = nWidth; + + Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2, + aWinSize.Width(), aWinSize.Height() ) ); + SetOutputSizePixel( Size( nMX*nWidth-1, aWinSize.Height() ) ); + } + + + if ( nNewCol != nCol ) + { + Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2, + aWinSize.Width(), aWinSize.Height() ) ); + + long nMinCol = 0, nMaxCol = 0; + + if ( nNewCol < nCol ) + { + nMinCol = nNewCol; + nMaxCol = nCol; + } + else + { + nMinCol = nCol; + nMaxCol = nNewCol; + } + + Invalidate( Rectangle( nMinCol*nMX-1, 0, + nMaxCol*nMX+1, aWinSize.Height()-nTextHeight+2 ) ); + nCol = nNewCol; + } + Update(); +} +// ----------------------------------------------------------------------- + +void ColumnsWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + SfxPopupWindow::MouseButtonDown( rMEvt ); + CaptureMouse(); +} + +void ColumnsWindow::KeyInput( const KeyEvent& rKEvt ) +{ + BOOL bHandled = FALSE; + USHORT nModifier = rKEvt.GetKeyCode().GetModifier(); + USHORT nKey = rKEvt.GetKeyCode().GetCode(); + if(!nModifier) + { + if( KEY_LEFT == nKey || KEY_RIGHT == nKey || + KEY_RETURN == nKey ||KEY_ESCAPE == nKey || + KEY_UP == nKey) + { + bHandled = TRUE; + long nNewCol = nCol; + switch(nKey) + { + case KEY_LEFT : + if(nNewCol) + nNewCol--; + break; + case KEY_RIGHT : + nNewCol++; + break; + case KEY_RETURN : + if(IsMouseCaptured()) + ReleaseMouse(); + EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL ); + break; + case KEY_ESCAPE : + case KEY_UP : + EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL); + break; + } + //make sure that a table can initially be created + if(bInitialKeyInput) + { + bInitialKeyInput = FALSE; + if(!nNewCol) + nNewCol = 1; + } + UpdateSize_Impl( nNewCol ); + } + } + else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey) + { + m_bMod1 = TRUE; + if(IsMouseCaptured()) + ReleaseMouse(); + EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL ); + } + if(!bHandled) + SfxPopupWindow::KeyInput(rKEvt); +} + +// ----------------------------------------------------------------------- + +void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + SfxPopupWindow::MouseButtonUp( rMEvt ); + ReleaseMouse(); + + if ( IsInPopupMode() ) + EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); +} + +// ----------------------------------------------------------------------- + +void ColumnsWindow::Paint( const Rectangle& ) +{ + long i; + long j; + long nLineWidth; + Size aSize = GetOutputSizePixel(); + + for ( i = 0; i < nWidth; i++ ) + { + if ( i < nCol ) + { + SetLineColor( aHighlightLineColor ); + SetFillColor( aHighlightFillColor ); + } + else + { + SetLineColor( aLineColor ); + SetFillColor( aFillColor ); + } + + DrawRect( Rectangle( i*nMX-1, -1, + i*nMX+nMX, aSize.Height()-nTextHeight+1 ) ); + + j = 4; + while ( j < aSize.Height()-nTextHeight-4 ) + { + if ( !(j % 16) ) + nLineWidth = 10; + else + nLineWidth = 4; + DrawLine( Point( i*nMX+4, j ), Point( i*nMX+nMX-nLineWidth-4, j ) ); + j += 4; + } + } + + SetLineColor(); + SetFillColor( aFaceColor ); + String aText; + if ( nCol ) + aText = String( String::CreateFromInt32(nCol) ); + else + aText = Button::GetStandardText( BUTTON_CANCEL ).EraseAllChars( '~' ); + + Size aTextSize(GetTextWidth( aText ), GetTextHeight()); + DrawText( Point( ( aSize.Width() - aTextSize.Width() ) / 2, aSize.Height() - nTextHeight + 2 ), aText ); + + DrawRect( Rectangle( 0, aSize.Height()-nTextHeight+2, (aSize.Width()-aTextSize.Width())/2-1, aSize.Height() ) ); + DrawRect( Rectangle( (aSize.Width()-aTextSize.Width())/2+aTextSize.Width(), aSize.Height()-nTextHeight+2, aSize.Width(), aSize.Height() ) ); + + SetLineColor( aLineColor ); + SetFillColor(); + DrawRect( Rectangle( 0, 0, aSize.Width() - 1, aSize.Height() - nTextHeight + 1 ) ); +} + +// ----------------------------------------------------------------------- + +void ColumnsWindow::PopupModeEnd() +{ + if ( !IsPopupModeCanceled() && nCol ) + { + USHORT nId = GetId(); + Window* pParent = rTbx.GetParent(); + pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId)); + + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" )); + aArgs[0].Value = makeAny( sal_Int16( nCol )); + aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Modifier" )); + aArgs[1].Value = makeAny( sal_Int16( m_bMod1 ? KEY_MOD1 : 0 )); + + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + maCommand, + aArgs ); + } + else if ( IsPopupModeCanceled() ) + ReleaseMouse(); + SfxPopupWindow::PopupModeEnd(); +} + +// class SvxTableToolBoxControl ------------------------------------------ + +SvxTableToolBoxControl::SvxTableToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ), + bEnabled( TRUE ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------- + +SvxTableToolBoxControl::~SvxTableToolBoxControl() +{ +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxTableToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindow() +{ + if ( bEnabled ) + { + ToolBox& rTbx = GetToolBox(); + TableWindow* pWin = new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), rTbx, m_xFrame ); + pWin->StartPopupMode( &rTbx, FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE ); + SetPopupWindow( pWin ); + return pWin; + } + return 0; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindowCascading() +{ + if ( bEnabled ) + return new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame ); + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxTableToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState ) +{ + if ( pState && pState->ISA(SfxUInt16Item) ) + { + INT16 nValue = static_cast< const SfxUInt16Item* >( pState )->GetValue(); + bEnabled = ( nValue != 0 ); + } + else + bEnabled = SFX_ITEM_DISABLED != eState; + + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, + ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); +} + +// class SvxColumnsToolBoxControl ------------------------------------------ + +SvxColumnsToolBoxControl::SvxColumnsToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------- + +SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl() +{ +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxColumnsToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindow() +{ + ColumnsWindow* pWin = 0; + if(bEnabled) + { + pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame ); + pWin->StartPopupMode( &GetToolBox(), + FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE ); + SetPopupWindow( pWin ); + } + return pWin; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindowCascading() +{ + ColumnsWindow* pWin = 0; + if(bEnabled) + { + pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame ); + } + return pWin; +} + +void SvxColumnsToolBoxControl::StateChanged( USHORT nSID, + SfxItemState eState, + const SfxPoolItem* pState ) +{ + bEnabled = SFX_ITEM_DISABLED != eState; + SfxToolBoxControl::StateChanged(nSID, eState, pState ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/lboxctrl.cxx b/svx/source/tbxctrls/lboxctrl.cxx new file mode 100644 index 000000000000..d687d6eb568e --- /dev/null +++ b/svx/source/tbxctrls/lboxctrl.cxx @@ -0,0 +1,349 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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" + +#ifdef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#include <vcl/lstbox.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/event.hxx> +#include <sfx2/app.hxx> +#include <sfx2/tbxctrl.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewsh.hxx> +#include <tools/gen.hxx> +#include <svl/intitem.hxx> +#include <svl/eitem.hxx> +#include <svtools/stdctrl.hxx> +#include <svl/slstitm.hxx> +#include <svl/stritem.hxx> +#include <svx/dialmgr.hxx> +#include <lboxctrl.hxx> +#include <vcl/mnemonic.hxx> +#include <tools/urlobj.hxx> + +#include <svx/svxids.hrc> +#include <svx/dialogs.hrc> + +#include "lboxctrl.hrc" + + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::frame; + +class SvxPopupWindowListBox; + +///////////////////////////////////////////////////////////////// + +class SvxPopupWindowListBox : public SfxPopupWindow +{ + using FloatingWindow::StateChanged; + + ListBox * pListBox; + ToolBox & rToolBox; + BOOL bUserSel; + USHORT nTbxId; + rtl::OUString maCommandURL; + // disallow copy-constructor and assignment-operator + + SvxPopupWindowListBox(const int& ); + SvxPopupWindowListBox & operator = (const int& ); + +// SvxPopupWindowListBox( USHORT nSlotId, ToolBox& rTbx, USHORT nTbxItemId ); + +public: + SvxPopupWindowListBox( USHORT nSlotId, const rtl::OUString& rCommandURL, USHORT nTbxId, ToolBox& rTbx ); + virtual ~SvxPopupWindowListBox(); + + // SfxPopupWindow + virtual SfxPopupWindow * Clone() const; + virtual void PopupModeEnd(); + virtual void StateChanged( USHORT nSID, SfxItemState eState, + const SfxPoolItem* pState ); + + void StartSelection(); + inline ListBox & GetListBox() { return *pListBox; } + + BOOL IsUserSelected() const { return bUserSel; } + void SetUserSelected( BOOL bVal ) { bUserSel = bVal; } + /*virtual*/Window* GetPreferredKeyInputWindow(); +}; + +///////////////////////////////////////////////////////////////// + +SvxPopupWindowListBox::SvxPopupWindowListBox( USHORT nSlotId, const rtl::OUString& rCommandURL, USHORT nId, ToolBox& rTbx ) : + SfxPopupWindow( nSlotId, Reference< XFrame >(), SVX_RES( RID_SVXTBX_UNDO_REDO_CTRL ) ), + rToolBox ( rTbx ), + bUserSel ( FALSE ), + nTbxId ( nId ), + maCommandURL( rCommandURL ) +{ + DBG_ASSERT( nSlotId == GetId(), "id mismatch" ); + pListBox = new ListBox( this, SVX_RES( LB_SVXTBX_UNDO_REDO_CTRL ) ); + FreeResource(); + pListBox->EnableMultiSelection( TRUE, TRUE ); + SetBackground( GetSettings().GetStyleSettings().GetDialogColor() ); + AddStatusListener( rCommandURL ); +} + + +SvxPopupWindowListBox::~SvxPopupWindowListBox() +{ + delete pListBox; +} + + +SfxPopupWindow* SvxPopupWindowListBox::Clone() const +{ + return new SvxPopupWindowListBox( GetId(), maCommandURL, nTbxId, rToolBox ); +} + + +void SvxPopupWindowListBox::PopupModeEnd() +{ + rToolBox.EndSelection(); + SfxPopupWindow::PopupModeEnd(); + //FloatingWindow::PopupModeEnd(); + + if( SfxViewShell::Current() ) + { + Window* pShellWnd = SfxViewShell::Current()->GetWindow(); + if (pShellWnd) + pShellWnd->GrabFocus(); + } +} + + +void SvxPopupWindowListBox::StateChanged( + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + rToolBox.EnableItem( nTbxId, ( SfxToolBoxControl::GetItemState( pState ) != SFX_ITEM_DISABLED) ); + SfxPopupWindow::StateChanged( nSID, eState, pState ); +} + + +void SvxPopupWindowListBox::StartSelection() +{ + rToolBox.StartSelection(); +} + +Window* SvxPopupWindowListBox::GetPreferredKeyInputWindow() +{ + // allows forwarding key events in the correct window + // without setting the focus + return pListBox->GetPreferredKeyInputWindow(); +} + +///////////////////////////////////////////////////////////////// + +SFX_IMPL_TOOLBOX_CONTROL( SvxListBoxControl, SfxStringItem ); + + +SvxListBoxControl::SvxListBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) + :SfxToolBoxControl( nSlotId, nId, rTbx ), + pPopupWin ( 0 ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + + +SvxListBoxControl::~SvxListBoxControl() +{ +} + + +SfxPopupWindow* SvxListBoxControl::CreatePopupWindow() +{ + DBG_ERROR( "not implemented" ); + return 0; +} + + +SfxPopupWindowType SvxListBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONTIMEOUT; +} + + +void SvxListBoxControl::StateChanged( + USHORT, SfxItemState, const SfxPoolItem* pState ) +{ + GetToolBox().EnableItem( GetId(), + SFX_ITEM_DISABLED != GetItemState(pState) ); +} + + +IMPL_LINK( SvxListBoxControl, PopupModeEndHdl, void *, EMPTYARG ) +{ + if( pPopupWin && 0 == pPopupWin->GetPopupModeFlags() && + pPopupWin->IsUserSelected() ) + { + USHORT nCount = pPopupWin->GetListBox().GetSelectEntryCount(); + + INetURLObject aObj( m_aCommandURL ); + + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + aArgs[0].Value = makeAny( sal_Int16( nCount )); + SfxToolBoxControl::Dispatch( m_aCommandURL, aArgs ); + } + return 0; +} + + +void SvxListBoxControl::Impl_SetInfo( USHORT nCount ) +{ + DBG_ASSERT( pPopupWin, "NULL pointer, PopupWindow missing" ); + +// ListBox &rListBox = pPopupWin->GetListBox(); + + USHORT nId; + if (nCount == 1) + nId = SID_UNDO == GetSlotId() ? RID_SVXSTR_NUM_UNDO_ACTION : RID_SVXSTR_NUM_REDO_ACTION; + else + nId = SID_UNDO == GetSlotId() ? RID_SVXSTR_NUM_UNDO_ACTIONS : RID_SVXSTR_NUM_REDO_ACTIONS; + + aActionStr = String(SVX_RES(nId)); + + String aText( aActionStr ); + aText.SearchAndReplaceAllAscii( "$(ARG1)", String::CreateFromInt32( nCount ) ); + pPopupWin->SetText( aText ); +} + + +IMPL_LINK( SvxListBoxControl, SelectHdl, void *, EMPTYARG ) +{ + if (pPopupWin) + { + //pPopupWin->SetUserSelected( FALSE ); + + ListBox &rListBox = pPopupWin->GetListBox(); + if (rListBox.IsTravelSelect()) + Impl_SetInfo( rListBox.GetSelectEntryCount() ); + else + { + pPopupWin->SetUserSelected( TRUE ); + pPopupWin->EndPopupMode( 0 ); + } + } + return 0; +} + +///////////////////////////////////////////////////////////////// + +SFX_IMPL_TOOLBOX_CONTROL( SvxUndoRedoControl, SfxStringItem ); + +SvxUndoRedoControl::SvxUndoRedoControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) + : SvxListBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); + aDefaultText = MnemonicGenerator::EraseAllMnemonicChars( rTbx.GetItemText( nId ) ); +} + +SvxUndoRedoControl::~SvxUndoRedoControl() +{ +} + +void SvxUndoRedoControl::StateChanged( + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + if ( nSID == SID_UNDO || nSID == SID_REDO ) + { + if ( eState == SFX_ITEM_DISABLED ) + { + ToolBox& rBox = GetToolBox(); + rBox.SetQuickHelpText( GetId(), aDefaultText ); + } + else if ( pState && pState->ISA( SfxStringItem ) ) + { + SfxStringItem& rItem = *(SfxStringItem *)pState; + ToolBox& rBox = GetToolBox(); + String aQuickHelpText = MnemonicGenerator::EraseAllMnemonicChars( rItem.GetValue() ); + rBox.SetQuickHelpText( GetId(), aQuickHelpText ); + } + SvxListBoxControl::StateChanged( nSID, eState, pState ); + } + else + { + aUndoRedoList.clear(); + + if ( pState && pState->ISA( SfxStringListItem ) ) + { + SfxStringListItem &rItem = *(SfxStringListItem *)pState; + const List* pLst = rItem.GetList(); + DBG_ASSERT( pLst, "no undo actions available" ); + if ( pLst ) + { + for( long nI = 0, nEnd = pLst->Count(); nI < nEnd; ++nI ) + aUndoRedoList.push_back( rtl::OUString( *(String *)pLst->GetObject( nI ))); + } + } + } +} + +SfxPopupWindow* SvxUndoRedoControl::CreatePopupWindow() +{ + DBG_ASSERT(( SID_UNDO == GetSlotId() || SID_REDO == GetSlotId() ), "mismatching ids" ); + + if ( m_aCommandURL.equalsAscii( ".uno:Undo" )) + updateStatus( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GetUndoStrings" ))); + else + updateStatus( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GetRedoStrings" ))); + + ToolBox& rBox = GetToolBox(); + + pPopupWin = new SvxPopupWindowListBox( GetSlotId(), m_aCommandURL, GetId(), rBox ); + pPopupWin->SetPopupModeEndHdl( LINK( this, SvxUndoRedoControl, + PopupModeEndHdl ) ); + ListBox &rListBox = pPopupWin->GetListBox(); + rListBox.SetSelectHdl( LINK( this, SvxUndoRedoControl, SelectHdl ) ); + + for( sal_uInt32 n = 0; n < aUndoRedoList.size(); n++ ) + rListBox.InsertEntry( String( aUndoRedoList[n] )); + + rListBox.SelectEntryPos( 0 ); + aActionStr = String( SVX_RES( SID_UNDO == GetSlotId() ? + RID_SVXSTR_NUM_UNDO_ACTIONS : RID_SVXSTR_NUM_REDO_ACTIONS ) ); + Impl_SetInfo( rListBox.GetSelectEntryCount() ); + + // move focus in floating window without + // closing it (GrabFocus() would close it!) + pPopupWin->StartPopupMode( &rBox, FLOATWIN_POPUPMODE_GRABFOCUS ); + //pPopupWin->GetListBox().GrabFocus(); + + return pPopupWin; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/lboxctrl.hrc b/svx/source/tbxctrls/lboxctrl.hrc new file mode 100644 index 000000000000..3026fee5cff3 --- /dev/null +++ b/svx/source/tbxctrls/lboxctrl.hrc @@ -0,0 +1,30 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#define LB_SVXTBX_UNDO_REDO_CTRL 11 +#define FT_NUM_OPERATIONS 12 + diff --git a/svx/source/tbxctrls/lboxctrl.src b/svx/source/tbxctrls/lboxctrl.src new file mode 100644 index 000000000000..2022ddd0ee3c --- /dev/null +++ b/svx/source/tbxctrls/lboxctrl.src @@ -0,0 +1,69 @@ +/************************************************************************* + * + * 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> +#include <helpid.hrc> +#include "lboxctrl.hrc" + +FloatingWindow RID_SVXTBX_UNDO_REDO_CTRL +{ + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 102 , 87 ) ; + HelpID = HID_SVXTBX_UNDO_REDO_CTRL ; + StdPopup = TRUE; + Hide = TRUE ; + OutputSize = TRUE ; + + ListBox LB_SVXTBX_UNDO_REDO_CTRL + { + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 100 , 85 ) ; + Border = TRUE ; + DropDown = FALSE ; + OutputSize = TRUE ; + }; +}; + +String RID_SVXSTR_NUM_UNDO_ACTIONS +{ + Text[ en-US ] = "Actions to undo: $(ARG1)"; +}; + +String RID_SVXSTR_NUM_UNDO_ACTION +{ + Text[ en-US ] = "Actions to undo: $(ARG1)" ; +}; + +String RID_SVXSTR_NUM_REDO_ACTIONS +{ + Text[ en-US ] = "Actions to redo: $(ARG1)"; +}; + +String RID_SVXSTR_NUM_REDO_ACTION +{ + Text[ en-US ] = "Actions to redo: $(ARG1)"; +}; diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx new file mode 100644 index 000000000000..251780b3b897 --- /dev/null +++ b/svx/source/tbxctrls/linectrl.cxx @@ -0,0 +1,785 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 --------------------------------------------------------------- + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headers + +#include <vcl/toolbox.hxx> +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> + +#include <svx/dialogs.hrc> +#include "helpid.hrc" + +#include "drawitem.hxx" +#include "xattr.hxx" +#include <svx/xtable.hxx> +#include "linectrl.hxx" +#include <svx/itemwin.hxx> +#include <svx/dialmgr.hxx> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::lang; + +// Fuer Linienenden-Controller +#define MAX_LINES 12 + +// STATIC DATA ----------------------------------------------------------- + +#define RESIZE_VALUE_POPUP(value_set) \ +{ \ + Size aSize = GetOutputSizePixel(); \ + aSize.Width() -= 4; \ + aSize.Height() -= 4; \ + (value_set).SetPosSizePixel( Point(2,2), aSize ); \ +} + +#define CALCSIZE_VALUE_POPUP(value_set,item_size) \ +{ \ + Size aSize = (value_set).CalcWindowSizePixel( (item_size) ); \ + aSize.Width() += 4; \ + aSize.Height() += 4; \ + SetOutputSizePixel( aSize ); \ +} + + +SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl, SfxBoolItem ); + +/************************************************************************* +|* +|* SvxLineStyleToolBoxControl +|* +\************************************************************************/ + +SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ), + pStyleItem ( NULL ), + pDashItem ( NULL ), + bUpdate ( FALSE ) +{ + addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" ))); + addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DashListState" ))); +} + +//======================================================================== + +SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl() +{ + delete pStyleItem; + delete pDashItem; +} + +//======================================================================== + +void SvxLineStyleToolBoxControl::StateChanged ( + + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) + +{ + SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pBox, "Window not found!" ); + + if( eState == SFX_ITEM_DISABLED ) + { + pBox->Disable(); + pBox->SetNoSelection(); + } + else + { + pBox->Enable(); + + if ( eState == SFX_ITEM_AVAILABLE ) + { + if( nSID == SID_ATTR_LINE_STYLE ) + { + delete pStyleItem; + pStyleItem = (XLineStyleItem*)pState->Clone(); + } + else if( nSID == SID_ATTR_LINE_DASH ) + { + delete pDashItem; + pDashItem = (XLineDashItem*)pState->Clone(); + } + + bUpdate = TRUE; + Update( pState ); + } + else if ( nSID != SID_DASH_LIST ) + { + // kein oder uneindeutiger Status + pBox->SetNoSelection(); + } + } +} + +//======================================================================== + +void SvxLineStyleToolBoxControl::Update( const SfxPoolItem* pState ) +{ + if ( pState && bUpdate ) + { + bUpdate = FALSE; + + SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pBox, "Window not found!" ); + + // Da der Timer unerwartet zuschlagen kann, kann es vorkommen, dass + // die LB noch nicht gefuellt ist. Ein ClearCache() am Control im + // DelayHdl() blieb ohne Erfolg. + if( pBox->GetEntryCount() == 0 ) + pBox->FillControl(); + + XLineStyle eXLS; + + if ( pStyleItem ) + eXLS = ( XLineStyle )pStyleItem->GetValue(); + else + eXLS = XLINE_NONE; + + switch( eXLS ) + { + case XLINE_NONE: + pBox->SelectEntryPos( 0 ); + break; + + case XLINE_SOLID: + pBox->SelectEntryPos( 1 ); + break; + + case XLINE_DASH: + { + if( pDashItem ) + { + String aString( pDashItem->GetName() ); + pBox->SelectEntry( aString ); + } + else + pBox->SetNoSelection(); + } + break; + + default: + DBG_ERROR( "Nicht unterstuetzter Linientyp" ); + break; + } + } + + if ( pState && ( pState->ISA( SvxDashListItem ) ) ) + { + // Die Liste der Linienstile hat sich geaendert + SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pBox, "Window not found!" ); + + String aString( pBox->GetSelectEntry() ); + pBox->Clear(); + pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) ); + pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_SOLID) ); + pBox->Fill( ((SvxDashListItem*)pState )->GetDashList() ); + pBox->SelectEntry( aString ); + } +} + +//======================================================================== + +Window* SvxLineStyleToolBoxControl::CreateItemWindow( Window *pParent ) +{ + return new SvxLineBox( pParent, m_xFrame ); +} + +/************************************************************************* +|* +|* SvxLineWidthToolBoxControl +|* +\************************************************************************/ + +SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl( + USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ))); +} + +//======================================================================== + +SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl() +{ +} + +//======================================================================== + +void SvxLineWidthToolBoxControl::StateChanged( + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + SvxMetricField* pFld = (SvxMetricField*) + GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pFld, "Window not found" ); + + if ( nSID == SID_ATTR_METRIC ) + { + pFld->RefreshDlgUnit(); + } + else + { + if ( eState == SFX_ITEM_DISABLED ) + { + pFld->Disable(); + pFld->SetText( String() ); + } + else + { + pFld->Enable(); + + if ( eState == SFX_ITEM_AVAILABLE ) + { + DBG_ASSERT( pState->ISA(XLineWidthItem), "falscher ItemType" ); + + // Core-Unit an MetricField uebergeben + // Darf nicht in CreateItemWin() geschehen! + SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; // CD!!! GetCoreMetric(); + pFld->SetCoreUnit( eUnit ); + + pFld->Update( (const XLineWidthItem*)pState ); + } + else + pFld->Update( NULL ); + } + } +} + +//======================================================================== + +Window* SvxLineWidthToolBoxControl::CreateItemWindow( Window *pParent ) +{ + return( new SvxMetricField( pParent, m_xFrame ) ); +} + +/************************************************************************* +|* +|* SvxLineColorToolBoxControl +|* +\************************************************************************/ + +SvxLineColorToolBoxControl::SvxLineColorToolBoxControl( + USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" ))); +} + +//======================================================================== + +SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl() +{ +} + +//======================================================================== + +void SvxLineColorToolBoxControl::StateChanged( + + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) + +{ + SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pBox, "Window not found" ); + + if ( nSID != SID_COLOR_TABLE ) + { + if ( eState == SFX_ITEM_DISABLED ) + { + pBox->Disable(); + pBox->SetNoSelection(); + } + else + { + pBox->Enable(); + + if ( eState == SFX_ITEM_AVAILABLE ) + { + DBG_ASSERT( pState->ISA(XLineColorItem), "falscher ItemTyoe" ); + pBox->Update( (const XLineColorItem*) pState ); + } + else + pBox->Update( NULL ); + } + } + else + Update( pState ); +} + +//======================================================================== + +void SvxLineColorToolBoxControl::Update( const SfxPoolItem* pState ) +{ + if ( pState && ( pState->ISA( SvxColorTableItem ) ) ) + { + SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() ); + + DBG_ASSERT( pBox, "Window not found" ); + + // Die Liste der Farben (ColorTable) hat sich geaendert: + ::Color aTmpColor( pBox->GetSelectEntryColor() ); + pBox->Clear(); + pBox->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() ); + pBox->SelectEntry( aTmpColor ); + } +} + +//======================================================================== + +Window* SvxLineColorToolBoxControl::CreateItemWindow( Window *pParent ) +{ + return new SvxColorBox( pParent, m_aCommandURL, m_xFrame ); +} + +/************************************************************************* +|* +|* SvxLineEndWindow +|* +\************************************************************************/ + +SvxLineEndWindow::SvxLineEndWindow( + USHORT nSlotId, + const Reference< XFrame >& rFrame, + const String& rWndTitle ) : + SfxPopupWindow( nSlotId, + rFrame, + WinBits( WB_STDPOPUP ) ), + pLineEndList ( NULL ), + aLineEndSet ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ), + nCols ( 2 ), + nLines ( 12 ), + nLineEndWidth ( 400 ), + bPopupMode ( TRUE ), + mbInResize ( false ), + mxFrame ( rFrame ) +{ + SetText( rWndTitle ); + implInit(); +} + +SvxLineEndWindow::SvxLineEndWindow( + USHORT nSlotId, + const Reference< XFrame >& rFrame, + Window* pParentWindow, + const String& rWndTitle ) : + SfxPopupWindow( nSlotId, + rFrame, + pParentWindow, + WinBits( WB_STDPOPUP ) ), + pLineEndList ( NULL ), + aLineEndSet ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ), + nCols ( 2 ), + nLines ( 12 ), + nLineEndWidth ( 400 ), + bPopupMode ( TRUE ), + mbInResize ( false ), + mxFrame ( rFrame ) +{ + SetText( rWndTitle ); + implInit(); +} + +void SvxLineEndWindow::implInit() +{ + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = NULL; + + SetHelpId( HID_POPUP_LINEEND ); + aLineEndSet.SetHelpId( HID_POPUP_LINEEND_CTRL ); + + if ( pDocSh ) + { + pItem = pDocSh->GetItem( SID_LINEEND_LIST ); + if( pItem ) + pLineEndList = ( (SvxLineEndListItem*) pItem )->GetLineEndList(); + + pItem = pDocSh->GetItem( SID_ATTR_LINEEND_WIDTH_DEFAULT ); + if( pItem ) + nLineEndWidth = ( (SfxUInt16Item*) pItem )->GetValue(); + } + DBG_ASSERT( pLineEndList, "LineEndList wurde nicht gefunden" ); + + aLineEndSet.SetSelectHdl( LINK( this, SvxLineEndWindow, SelectHdl ) ); + aLineEndSet.SetColCount( nCols ); + + // ValueSet mit Eintraegen der LineEndList fuellen + FillValueSet(); + + AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndListState" ))); + + //ChangeHelpId( HID_POPUP_LINEENDSTYLE ); + aLineEndSet.Show(); +} + +SfxPopupWindow* SvxLineEndWindow::Clone() const +{ + return new SvxLineEndWindow( GetId(), mxFrame, GetText() ); +} + +// ----------------------------------------------------------------------- + +SvxLineEndWindow::~SvxLineEndWindow() +{ +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxLineEndWindow, SelectHdl, void *, EMPTYARG ) +{ + XLineEndItem* pLineEndItem = NULL; + XLineStartItem* pLineStartItem = NULL; + USHORT nId = aLineEndSet.GetSelectItemId(); + + if( nId == 1 ) + { + pLineStartItem = new XLineStartItem(); + } + else if( nId == 2 ) + { + pLineEndItem = new XLineEndItem(); + } + else if( nId % 2 ) // LinienAnfang + { + XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 ); + pLineStartItem = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ); + } + else // LinienEnde + { + XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 ); + pLineEndItem = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ); + } + + if ( IsInPopupMode() ) + EndPopupMode(); + + Sequence< PropertyValue > aArgs( 1 ); + Any a; + + if ( pLineStartItem ) + { + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStart" )); + pLineStartItem->QueryValue( a ); + aArgs[0].Value = a; + } + else + { + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" )); + pLineEndItem->QueryValue( a ); + aArgs[0].Value = a; + } + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + aLineEndSet.SetNoSelection(); + + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndStyle" )), + aArgs ); + + delete pLineEndItem; + delete pLineStartItem; + + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxLineEndWindow::FillValueSet() +{ + if( pLineEndList ) + { + XLineEndEntry* pEntry = NULL; + Bitmap* pBmp = NULL; + VirtualDevice aVD; + + long nCount = pLineEndList->Count(); + + // Erster Eintrag: kein LinienEnde + // Temporaer wird ein Eintrag hinzugefuegt, um die UI-Bitmap zu erhalten + basegfx::B2DPolyPolygon aNothing; + pLineEndList->Insert( new XLineEndEntry( aNothing, SVX_RESSTR( RID_SVXSTR_NONE ) ) ); + pEntry = pLineEndList->GetLineEnd( nCount ); + pBmp = pLineEndList->GetBitmap( nCount ); + DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" ); + + aBmpSize = pBmp->GetSizePixel(); + aVD.SetOutputSizePixel( aBmpSize, FALSE ); + aBmpSize.Width() = aBmpSize.Width() / 2; + Point aPt0( 0, 0 ); + Point aPt1( aBmpSize.Width(), 0 ); + + aVD.DrawBitmap( Point(), *pBmp ); + aLineEndSet.InsertItem( 1, aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() ); + aLineEndSet.InsertItem( 2, aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() ); + + delete pLineEndList->Remove( nCount ); + + for( long i = 0; i < nCount; i++ ) + { + pEntry = pLineEndList->GetLineEnd( i ); + DBG_ASSERT( pEntry, "Konnte auf LineEndEntry nicht zugreifen" ); + pBmp = pLineEndList->GetBitmap( i ); + DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" ); + + aVD.DrawBitmap( aPt0, *pBmp ); + aLineEndSet.InsertItem( (USHORT)((i+1L)*2L+1L), aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() ); + aLineEndSet.InsertItem( (USHORT)((i+2L)*2L), aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() ); + } + nLines = Min( (USHORT)(nCount + 1), (USHORT) MAX_LINES ); + aLineEndSet.SetLineCount( nLines ); + + SetSize(); + } +} + +// ----------------------------------------------------------------------- + +void SvxLineEndWindow::Resize() +{ + // since we change the size inside this call, check if we + // are called recursive + if( !mbInResize ) + { + mbInResize = true; + if ( !IsRollUp() ) + { + aLineEndSet.SetColCount( nCols ); + aLineEndSet.SetLineCount( nLines ); + + SetSize(); + + Size aSize = GetOutputSizePixel(); + aSize.Width() -= 4; + aSize.Height() -= 4; + aLineEndSet.SetPosSizePixel( Point( 2, 2 ), aSize ); + } + //SfxPopupWindow::Resize(); + mbInResize = false; + } +} + +// ----------------------------------------------------------------------- + +void __EXPORT SvxLineEndWindow::Resizing( Size& rNewSize ) +{ + Size aBitmapSize = aBmpSize; // -> Member + aBitmapSize.Width() += 6; // + aBitmapSize.Height() += 6; // + + Size aItemSize = aLineEndSet.CalcItemSizePixel( aBitmapSize ); // -> Member + //Size aOldSize = GetOutputSizePixel(); // fuer Breite + + USHORT nItemCount = aLineEndSet.GetItemCount(); // -> Member + + // Spalten ermitteln + long nItemW = aItemSize.Width(); + long nW = rNewSize.Width(); + nCols = (USHORT) Max( ( (ULONG)(( nW + nItemW ) / ( nItemW * 2 ) )), + (ULONG) 1L ); + nCols *= 2; + + // Reihen ermitteln + long nItemH = aItemSize.Height(); + long nH = rNewSize.Height(); + nLines = (USHORT) Max( ( ( nH + nItemH / 2 ) / nItemH ), 1L ); + + USHORT nMaxCols = nItemCount / nLines; + if( nItemCount % nLines ) + nMaxCols++; + if( nCols > nMaxCols ) + nCols = nMaxCols; + nW = nItemW * nCols; + + // Keine ungerade Anzahl von Spalten + if( nCols % 2 ) + nCols--; + nCols = Max( nCols, (USHORT) 2 ); + + USHORT nMaxLines = nItemCount / nCols; + if( nItemCount % nCols ) + nMaxLines++; + if( nLines > nMaxLines ) + nLines = nMaxLines; + nH = nItemH * nLines; + + rNewSize.Width() = nW; + rNewSize.Height() = nH; +} +// ----------------------------------------------------------------------- + +void SvxLineEndWindow::StartSelection() +{ + aLineEndSet.StartSelection(); +} + +// ----------------------------------------------------------------------- + +BOOL SvxLineEndWindow::Close() +{ + return SfxPopupWindow::Close(); +} + +// ----------------------------------------------------------------------- + +void SvxLineEndWindow::StateChanged( + USHORT nSID, SfxItemState, const SfxPoolItem* pState ) +{ + if ( nSID == SID_LINEEND_LIST ) + { + // Die Liste der LinienEnden (LineEndList) hat sich geaendert: + if ( pState && pState->ISA( SvxLineEndListItem )) + { + pLineEndList = ((SvxLineEndListItem*)pState)->GetLineEndList(); + DBG_ASSERT( pLineEndList, "LineEndList nicht gefunden" ); + + aLineEndSet.Clear(); + FillValueSet(); + + Size aSize = GetOutputSizePixel(); + Resizing( aSize ); + Resize(); + } + } +} + +// ----------------------------------------------------------------------- + +void SvxLineEndWindow::PopupModeEnd() +{ + if ( IsVisible() ) + { + bPopupMode = FALSE; + SetSize(); + } + SfxPopupWindow::PopupModeEnd(); +} + +// ----------------------------------------------------------------------- + +void SvxLineEndWindow::SetSize() +{ + //if( !bPopupMode ) + if( !IsInPopupMode() ) + { + USHORT nItemCount = aLineEndSet.GetItemCount(); // -> Member + USHORT nMaxLines = nItemCount / nCols; // -> Member ? + if( nItemCount % nCols ) + nMaxLines++; + + WinBits nBits = aLineEndSet.GetStyle(); + if ( nLines == nMaxLines ) + nBits &= ~WB_VSCROLL; + else + nBits |= WB_VSCROLL; + aLineEndSet.SetStyle( nBits ); + } + + Size aSize( aBmpSize ); + aSize.Width() += 6; + aSize.Height() += 6; + aSize = aLineEndSet.CalcWindowSizePixel( aSize ); + aSize.Width() += 4; + aSize.Height() += 4; + SetOutputSizePixel( aSize ); + aSize.Height() = aBmpSize.Height(); + aSize.Height() += 14; + //SetMinOutputSizePixel( aSize ); +} + +void SvxLineEndWindow::GetFocus (void) +{ + SfxPopupWindow::GetFocus(); + // Grab the focus to the line ends value set so that it can be controlled + // with the keyboard. + aLineEndSet.GrabFocus(); +} + +/************************************************************************* +|* +|* SvxLineEndToolBoxControl +|* +\************************************************************************/ + +SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox &rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------- + +SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl() +{ +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxLineEndToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxLineEndToolBoxControl::CreatePopupWindow() +{ + SvxLineEndWindow* pLineEndWin = + new SvxLineEndWindow( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) ); + pLineEndWin->StartPopupMode( &GetToolBox(), TRUE ); + pLineEndWin->StartSelection(); + SetPopupWindow( pLineEndWin ); + return pLineEndWin; +} + +// ----------------------------------------------------------------------- + +void SvxLineEndToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* ) +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/linectrl.src b/svx/source/tbxctrls/linectrl.src new file mode 100644 index 000000000000..0265875adb7f --- /dev/null +++ b/svx/source/tbxctrls/linectrl.src @@ -0,0 +1,34 @@ +/************************************************************************* + * + * 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 "linectrl.hrc" + +Bitmap RID_SVXCTRL_LINECTRL +{ + File = "soliline.bmp" ; +}; + diff --git a/svx/source/tbxctrls/makefile.mk b/svx/source/tbxctrls/makefile.mk new file mode 100644 index 000000000000..a9ea745f3cc0 --- /dev/null +++ b/svx/source/tbxctrls/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# 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=..$/.. + +PRJNAME=svx +TARGET=tbxctrls +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +LIB1TARGET= $(SLB)$/$(TARGET)-core.lib +LIB1OBJFILES= \ + $(SLO)$/fontworkgallery.obj\ + $(SLO)$/extrusioncontrols.obj \ + $(SLO)$/tbcontrl.obj \ + $(SLO)$/tbxcolorupdate.obj + +LIB2TARGET= $(SLB)$/$(TARGET).lib +LIB2OBJFILES= \ + $(SLO)$/formatpaintbrushctrl.obj\ + $(SLO)$/colrctrl.obj \ + $(SLO)$/fillctrl.obj \ + $(SLO)$/grafctrl.obj \ + $(SLO)$/itemwin.obj \ + $(SLO)$/layctrl.obj \ + $(SLO)$/lboxctrl.obj \ + $(SLO)$/linectrl.obj \ + $(SLO)$/tbxalign.obj \ + $(SLO)$/tbxdrctl.obj \ + $(SLO)$/verttexttbxctrl.obj \ + $(SLO)$/subtoolboxcontrol.obj \ + $(SLO)$/tbxcolor.obj \ + $(SLO)$/tbunocontroller.obj \ + $(SLO)$/tbunosearchcontrollers.obj + +SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES) + +SRS1NAME=$(TARGET) +SRC1FILES = \ + fontworkgallery.src \ + extrusioncontrols.src \ + colrctrl.src \ + lboxctrl.src \ + linectrl.src \ + tbcontrl.src \ + tbunosearchcontrollers.src \ + tbxdraw.src \ + grafctrl.src + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/svx/source/tbxctrls/subtoolboxcontrol.cxx b/svx/source/tbxctrls/subtoolboxcontrol.cxx new file mode 100644 index 000000000000..74e9634d5885 --- /dev/null +++ b/svx/source/tbxctrls/subtoolboxcontrol.cxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 <svl/intitem.hxx> + +#include <vcl/toolbox.hxx> +#include <sfx2/app.hxx> +#include <svx/subtoolboxcontrol.hxx> +#include <svx/svxids.hrc> + + +SFX_IMPL_TOOLBOX_CONTROL( SvxSubToolBoxControl, SfxUInt16Item ); + +/********************************************************************** + +**********************************************************************/ + +SvxSubToolBoxControl::SvxSubToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) +: SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); +} + +/********************************************************************** + +**********************************************************************/ + +SvxSubToolBoxControl::~SvxSubToolBoxControl() +{ +} + +/********************************************************************** + +**********************************************************************/ + +SfxPopupWindow* SvxSubToolBoxControl::CreatePopupWindow() +{ + const sal_Char* pResource = 0; + switch( GetSlotId() ) + { + case SID_OPTIMIZE_TABLE: + pResource = "private:resource/toolbar/optimizetablebar"; + break; + } + + if( pResource ) + createAndPositionSubToolBar( rtl::OUString::createFromAscii( pResource ) ); + return NULL; +} + +/********************************************************************** + +**********************************************************************/ + +SfxPopupWindowType SvxSubToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx new file mode 100644 index 000000000000..159489adec0c --- /dev/null +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -0,0 +1,2876 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 --------------------------------------------------------------- + + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headers +#include <tools/shl.hxx> +#include <svl/poolitem.hxx> +#include <svl/eitem.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/bmpacc.hxx> +#include <svtools/valueset.hxx> +#include <svtools/ctrlbox.hxx> +#include <svl/style.hxx> +#include <svtools/ctrltool.hxx> +#include <svtools/borderhelper.hxx> +#include <svl/stritem.hxx> +#include <unotools/pathoptions.hxx> +#include <sfx2/tplpitem.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/docfac.hxx> +#include <sfx2/templdlg.hxx> +#include <svl/isethint.hxx> +#include <sfx2/querystatus.hxx> +#include <sfx2/sfxstatuslistener.hxx> +#include <tools/urlobj.hxx> +#include <sfx2/childwin.hxx> +#include <sfx2/viewfrm.hxx> +#include <unotools/fontoptions.hxx> +#include <vcl/mnemonic.hxx> + +#include <vcl/svapp.hxx> +#include <svl/smplhint.hxx> + +#define _SVX_TBCONTRL_CXX +#include <svtools/colorcfg.hxx> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/status/ItemStatus.hpp> +#include <com/sun/star/frame/status/FontHeight.hpp> + +#include <svx/dialogs.hrc> +#include <svx/svxitems.hrc> +#include "helpid.hrc" +#include "htmlmode.hxx" +#include <svx/xtable.hxx> +#include "editeng/fontitem.hxx" +#include <editeng/fhgtitem.hxx> +#include <editeng/brshitem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/colritem.hxx> +#include "editeng/flstitem.hxx" +#include "editeng/bolnitem.hxx" +#include "drawitem.hxx" +#include <svx/tbcontrl.hxx> +#include "dlgutil.hxx" +#include <svx/dialmgr.hxx> +#include "colorwindow.hxx" +#include <memory> + +#include <svx/framelink.hxx> +#include <svx/tbxcolorupdate.hxx> +#include <editeng/eerdll.hxx> +#include <editeng/editrids.hrc> + +// ------------------------------------------------------------------------ + +#define MAX_MRU_FONTNAME_ENTRIES 5 +#define LOGICAL_EDIT_HEIGHT 12 + +// STATIC DATA ----------------------------------------------------------- + +#ifndef DELETEZ +#define DELETEZ(p) (delete (p), (p)=NULL) +#endif +// don't make more than 15 entries visible at once +#define MAX_STYLES_ENTRIES static_cast< USHORT >( 15 ) + +void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet ); +void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize ); +BOOL lcl_FontChangedHint( const SfxHint &rHint ); + +// namespaces +using ::rtl::OUString; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; + +SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorExtToolBoxControl, SvxColorItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl, SvxColorItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl, SvxColorItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxReloadControllerItem, SfxBoolItem ); +SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem ); + +//======================================================================== +// class SvxStyleBox_Impl ----------------------------------------------------- +//======================================================================== + + +class SvxStyleBox_Impl : public ComboBox +{ + using Window::IsVisible; +public: + SvxStyleBox_Impl( Window* pParent, USHORT nSlot, const OUString& rCommand, SfxStyleFamily eFamily, const Reference< XDispatchProvider >& rDispatchProvider, + const Reference< XFrame >& _xFrame,const String& rClearFormatKey, const String& rMoreKey, BOOL bInSpecialMode ); + ~SvxStyleBox_Impl(); + + void SetFamily( SfxStyleFamily eNewFamily ); + inline BOOL IsVisible() { return bVisible; } + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + + inline void SetVisibilityListener( const Link& aVisListener ) { aVisibilityListener = aVisListener; } + inline void RemoveVisibilityListener() { aVisibilityListener = Link(); } + + void SetDefaultStyle( const ::rtl::OUString& rDefault ) { sDefaultStyle = rDefault; } + DECL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control* ); + +protected: + virtual void Select(); + +private: + USHORT nSlotId; + SfxStyleFamily eStyleFamily; + USHORT nCurSel; + BOOL bRelease; + Size aLogicalSize; + Link aVisibilityListener; + BOOL bVisible; + Reference< XDispatchProvider > m_xDispatchProvider; + Reference< XFrame > m_xFrame; + OUString m_aCommand; + String aClearFormatKey; + String aMoreKey; + String sDefaultStyle; + BOOL bInSpecialMode; + + void ReleaseFocus(); +}; + +//======================================================================== +// class SvxFontNameBox -------------------------------------------------- +//======================================================================== + +class SvxFontNameBox_Impl : public FontNameBox +{ + using Window::Update; +private: + const FontList* pFontList; + ::std::auto_ptr<FontList> m_aOwnFontList; + Font aCurFont; + Size aLogicalSize; + String aCurText; + USHORT nFtCount; + BOOL bRelease; + Reference< XDispatchProvider > m_xDispatchProvider; + Reference< XFrame > m_xFrame; + + void ReleaseFocus_Impl(); + void EnableControls_Impl(); + +protected: + virtual void Select(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +public: + SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame + , WinBits nStyle = WB_SORT + ); + + void FillList(); + void Update( const SvxFontItem* pFontItem ); + USHORT GetListCount() { return nFtCount; } + void Clear() { FontNameBox::Clear(); nFtCount = 0; } + void Fill( const FontList* pList ) + { FontNameBox::Fill( pList ); + nFtCount = pList->GetFontNameCount(); } + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + inline void SetOwnFontList(::std::auto_ptr<FontList> _aOwnFontList) { m_aOwnFontList = _aOwnFontList; } +}; + +//======================================================================== +// class SvxFrameWindow_Impl -------------------------------------------------- +//======================================================================== + +// fuer den SelectHdl werden die Modifier gebraucht, also +// muss man sie im MouseButtonUp besorgen + +class SvxFrmValueSet_Impl : public ValueSet +{ + USHORT nModifier; + virtual void MouseButtonUp( const MouseEvent& rMEvt ); +public: + SvxFrmValueSet_Impl(Window* pParent, WinBits nWinStyle) + : ValueSet(pParent, nWinStyle), nModifier(0) {} + USHORT GetModifier() const {return nModifier;} + +}; + +void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent& rMEvt ) +{ + nModifier = rMEvt.GetModifier(); + ValueSet::MouseButtonUp(rMEvt); +} + +class SvxFrameWindow_Impl : public SfxPopupWindow +{ + using FloatingWindow::StateChanged; + +private: + SvxFrmValueSet_Impl aFrameSet; + ImageList aImgList; + sal_Bool bParagraphMode; + +#if _SOLAR__PRIVATE + DECL_LINK( SelectHdl, void * ); +#endif + +protected: + virtual void Resize(); + virtual BOOL Close(); + virtual Window* GetPreferredKeyInputWindow(); + virtual void GetFocus(); + +public: + SvxFrameWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow ); + ~SvxFrameWindow_Impl(); + void StartSelection(); + + virtual void StateChanged( USHORT nSID, SfxItemState eState, + const SfxPoolItem* pState ); + virtual SfxPopupWindow* Clone() const; + virtual void DataChanged( const DataChangedEvent& rDCEvt ); +}; + +//======================================================================== +// class SvxLineWindow_Impl --------------------------------------------------- +//======================================================================== +class SvxLineWindow_Impl : public SfxPopupWindow +{ +private: + ValueSet aLineSet; + bool m_bIsWriter; + +#if _SOLAR__PRIVATE + void MakeLineBitmap( USHORT nNo, Bitmap& rBmp, const Size& rSize, String& rStr, + const ::Color& rLine, const ::Color& rBack ); + DECL_LINK( SelectHdl, void * ); +#endif + +protected: + virtual void Resize(); + virtual BOOL Close(); + virtual Window* GetPreferredKeyInputWindow(); + virtual void GetFocus(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + void CreateBitmaps( void ); +public: + SvxLineWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow ); + + void StartSelection(); + virtual SfxPopupWindow* Clone() const; +}; + +//######################################################################## +// Hilfsklassen: +//======================================================================== +// class SfxStyleControllerItem ------------------------------------------ +//======================================================================== +class SvxStyleToolBoxControl; + +class SfxStyleControllerItem_Impl : public SfxStatusListener +{ + public: + SfxStyleControllerItem_Impl( const Reference< XDispatchProvider >& rDispatchProvider, + USHORT nSlotId, + const rtl::OUString& rCommand, + SvxStyleToolBoxControl& rTbxCtl ); + + protected: + virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + + private: + SvxStyleToolBoxControl& rControl; +}; + +//======================================================================== +// class SvxStyleBox_Impl ----------------------------------------------------- +//======================================================================== + +SvxStyleBox_Impl::SvxStyleBox_Impl( + Window* pParent, + USHORT nSlot, + const rtl::OUString& rCommand, + SfxStyleFamily eFamily, + const Reference< XDispatchProvider >& rDispatchProvider, + const Reference< XFrame >& _xFrame, + const String& rClearFormatKey, + const String& rMoreKey, + BOOL bInSpec) : + + ComboBox( pParent, SVX_RES( RID_SVXTBX_STYLE ) ), + + nSlotId ( nSlot ), + eStyleFamily( eFamily ), + bRelease ( TRUE ), + bVisible(FALSE), + m_xDispatchProvider( rDispatchProvider ), + m_xFrame(_xFrame), + m_aCommand ( rCommand ), + aClearFormatKey ( rClearFormatKey ), + aMoreKey ( rMoreKey ), + bInSpecialMode ( bInSpec ) +{ + aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT ); + EnableAutocomplete( TRUE ); +} + +SvxStyleBox_Impl::~SvxStyleBox_Impl() +{ +} + +// ----------------------------------------------------------------------- + +void SvxStyleBox_Impl::ReleaseFocus() +{ + if ( !bRelease ) + { + bRelease = TRUE; + return; + } + if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() ) + m_xFrame->getContainerWindow()->setFocus(); +} + +// ----------------------------------------------------------------------- + +void SvxStyleBox_Impl::Select() +{ + // Tell base class about selection so that AT get informed about it. + ComboBox::Select(); + + if ( !IsTravelSelect() ) + { + String aSelEntry( GetText() ); + bool bDoIt = true, bClear = false; + if( bInSpecialMode ) + { + if( aSelEntry == aClearFormatKey && GetSelectEntryPos() == 0 ) + { + aSelEntry = sDefaultStyle; + bClear = true; + //not only apply default style but also call 'ClearFormatting' + Sequence< PropertyValue > aEmptyVals; + SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ResetAttributes"), + aEmptyVals); + } + else if( aSelEntry == aMoreKey && GetSelectEntryPos() == ( GetEntryCount() - 1 ) ) + { + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + DBG_ASSERT( pViewFrm, "SvxStyleBox_Impl::Select(): no viewframe" ); + pViewFrm->ShowChildWindow( SID_STYLE_DESIGNER ); + SfxChildWindow* pChildWin = pViewFrm->GetChildWindow( SID_STYLE_DESIGNER ); + if ( pChildWin && pChildWin->GetWindow() ) + { + static_cast< SfxTemplateDialogWrapper* >( pChildWin )->SetParagraphFamily(); + static_cast< SfxDockingWindow* >( pChildWin->GetWindow() )->AutoShow( sal_True ); + Application::PostUserEvent( + STATIC_LINK( 0, SvxStyleBox_Impl, FocusHdl_Impl ), pChildWin->GetWindow() ); + } + bDoIt = false; + } + } + + // #i36723# after ReleaseFocus() the new entry is included into the List + sal_Bool bCreateNew = GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND; + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + ReleaseFocus(); + + if( bDoIt ) + { + if ( bClear ) + SetText( aSelEntry ); + SaveValue(); + + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Value = makeAny( OUString( aSelEntry ) ); + aArgs[1].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Family")); + aArgs[1].Value = makeAny( sal_Int16( eStyleFamily )); + if( bCreateNew ) + { + aArgs[0].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Param")); + SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:StyleNewByExample"), aArgs); + } + else + { + aArgs[0].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Template")); + SfxToolBoxControl::Dispatch( m_xDispatchProvider, m_aCommand, aArgs ); + } + } + } +} +// ----------------------------------------------------------------------- + +void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily ) +{ + eStyleFamily = eNewFamily; +} + +// ----------------------------------------------------------------------- + +long SvxStyleBox_Impl::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) + nCurSel = GetSelectEntryPos(); + else if ( EVENT_LOSEFOCUS == nType ) + { + // don't handle before our Select() is called + if ( !HasFocus() && !HasChildPathFocus() ) + SetText( GetSavedValue() ); + } + return ComboBox::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = 0; + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); + + switch ( nCode ) + { + case KEY_RETURN: + case KEY_TAB: + { + if ( KEY_TAB == nCode ) + bRelease = FALSE; + else + nHandled = 1; + Select(); + break; + } + + case KEY_ESCAPE: + SelectEntryPos( nCurSel ); + ReleaseFocus(); + nHandled = 1; + break; + } + } + return nHandled ? nHandled : ComboBox::Notify( rNEvt ); +} + +void SvxStyleBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); + Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT); + SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT)); + } + + ComboBox::DataChanged( rDCEvt ); +} + +void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange ) +{ + ComboBox::StateChanged( nStateChange ); + + if ( nStateChange == STATE_CHANGE_VISIBLE ) + { + bVisible = IsReallyVisible(); + if ( aVisibilityListener.IsSet() ) + aVisibilityListener.Call( this ); + } + else if ( nStateChange == STATE_CHANGE_INITSHOW ) + { + bVisible = TRUE; + if ( aVisibilityListener.IsSet() ) + aVisibilityListener.Call( this ); + } +} + +//-------------------------------------------------------------------- + +IMPL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control*, _pCtrl ) +{ + (void)pThis; + if ( _pCtrl ) + _pCtrl->GrabFocus(); + return 0; +} + +// ----------------------------------------------------------------------- + +BOOL GetDocFontList_Impl( const FontList** ppFontList, SvxFontNameBox_Impl* pBox ) +{ + BOOL bChanged = FALSE; + const SfxObjectShell* pDocSh = SfxObjectShell::Current(); + SvxFontListItem* pFontListItem = NULL; + + if ( pDocSh ) + pFontListItem = + (SvxFontListItem*)pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ); + else + { + ::std::auto_ptr<FontList> aFontList(new FontList( pBox )); + *ppFontList = aFontList.get(); + pBox->SetOwnFontList(aFontList); + bChanged = TRUE; + } + + if ( pFontListItem ) + { + const FontList* pNewFontList = pFontListItem->GetFontList(); + DBG_ASSERT( pNewFontList, "Doc-FontList not available!" ); + + // keine alte Liste, aber neue Liste + if ( !*ppFontList && pNewFontList ) + { + // => "ubernehmen + *ppFontList = pNewFontList; + bChanged = TRUE; + } + else + { + // Vergleich der Fontlisten ist nicht vollkommen + // wird die Fontliste am Doc geaendert, kann man hier + // nur ueber die Listbox Aenderungen feststellen, weil + // ppFontList dabei schon upgedatet wurde + bChanged = + ( ( *ppFontList != pNewFontList ) || + pBox->GetListCount() != pNewFontList->GetFontNameCount() ); + HACK(vergleich ist unvollstaendig) + + if ( bChanged ) + *ppFontList = pNewFontList; + } + + if ( pBox ) + pBox->Enable(); + } + else if ( pBox && ( pDocSh || ( !pDocSh && !ppFontList ))) + { + // Disable box only when we have a SfxObjectShell and didn't get a font list OR + // we don't have a SfxObjectShell and no current font list. + // It's possible that we currently have no SfxObjectShell, but a current font list. + // See #i58471: When a user set the focus into the font name combo box and opens + // the help window with F1. After closing the help window, we disable the font name + // combo box. The SfxObjectShell::Current() method returns in that case zero. But the + // font list hasn't changed and therefore the combo box shouldn't be disabled! + pBox->Disable(); + } + + // in die FontBox ggf. auch die neue Liste f"ullen + if ( pBox && bChanged ) + { + if ( *ppFontList ) + pBox->Fill( *ppFontList ); + else + pBox->Clear(); + } + return bChanged; +} + +//======================================================================== +// class SvxFontNameBox_Impl -------------------------------------------------- +//======================================================================== + +SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame, WinBits nStyle ) : + + FontNameBox ( pParent, nStyle | WinBits( WB_DROPDOWN | WB_AUTOHSCROLL ) ), + pFontList ( NULL ), + aLogicalSize ( 75,160 ), + nFtCount ( 0 ), + bRelease ( TRUE ), + m_xDispatchProvider( rDispatchProvider ), + m_xFrame (_xFrame) +{ + SetSizePixel(LogicToPixel( aLogicalSize, MAP_APPFONT )); + EnableControls_Impl(); +} +// ----------------------------------------------------------------------- + +void SvxFontNameBox_Impl::FillList() +{ + // alte Selektion merken, und am Ende wieder setzen + Selection aOldSel = GetSelection(); + // hat sich Doc-Fontlist geaendert? + GetDocFontList_Impl( &pFontList, this ); + aCurText = GetText(); + SetSelection( aOldSel ); +} + +// ----------------------------------------------------------------------- + +void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem ) +{ + if ( pFontItem ) + { + aCurFont.SetName ( pFontItem->GetFamilyName() ); + aCurFont.SetFamily ( pFontItem->GetFamily() ); + aCurFont.SetStyleName ( pFontItem->GetStyleName() ); + aCurFont.SetPitch ( pFontItem->GetPitch() ); + aCurFont.SetCharSet ( pFontItem->GetCharSet() ); + } + String aCurName = aCurFont.GetName(); + if ( GetText() != aCurName ) + SetText( aCurName ); +} + +// ----------------------------------------------------------------------- + +long SvxFontNameBox_Impl::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + + if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType ) + { + EnableControls_Impl(); + FillList(); + } + return FontNameBox::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = 0; + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); + + switch ( nCode ) + { + case KEY_RETURN: + case KEY_TAB: + { + if ( KEY_TAB == nCode ) + bRelease = FALSE; + else + nHandled = 1; + Select(); + break; + } + + case KEY_ESCAPE: + SetText( aCurText ); + ReleaseFocus_Impl(); + break; + } + } + else if ( EVENT_LOSEFOCUS == rNEvt.GetType() ) + { + Window* pFocusWin = Application::GetFocusWindow(); + if ( !HasFocus() && GetSubEdit() != pFocusWin ) + SetText( GetSavedValue() ); + } + + return nHandled ? nHandled : FontNameBox::Notify( rNEvt ); +} + +// --------------------------------------------------------------------------- +void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT)); + Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT); + SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT)); + } + + FontNameBox::DataChanged( rDCEvt ); +} + +// ----------------------------------------------------------------------- + +void SvxFontNameBox_Impl::ReleaseFocus_Impl() +{ + if ( !bRelease ) + { + bRelease = TRUE; + return; + } + if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() ) + m_xFrame->getContainerWindow()->setFocus(); +} + +// ----------------------------------------------------------------------- + +void SvxFontNameBox_Impl::EnableControls_Impl() +{ + SvtFontOptions aFontOpt; + BOOL bEnable = aFontOpt.IsFontHistoryEnabled(); + USHORT nEntries = bEnable ? MAX_MRU_FONTNAME_ENTRIES : 0; + if ( GetMaxMRUCount() != nEntries ) + { + // refill in the next GetFocus-Handler + pFontList = NULL; + Clear(); + SetMaxMRUCount( nEntries ); + } + + bEnable = aFontOpt.IsFontWYSIWYGEnabled(); + EnableWYSIWYG( bEnable ); + EnableSymbols( bEnable ); +} + +// ----------------------------------------------------------------------- + +void SvxFontNameBox_Impl::Select() +{ + FontNameBox::Select(); + + if ( !IsTravelSelect() ) + { + if ( pFontList ) + { + FontInfo aInfo( pFontList->Get( GetText(), + aCurFont.GetWeight(), + aCurFont.GetItalic() ) ); + aCurFont = aInfo; + + SvxFontItem aFontItem( aInfo.GetFamily(), + aInfo.GetName(), + aInfo.GetStyleName(), + aInfo.GetPitch(), + aInfo.GetCharSet(), + SID_ATTR_CHAR_FONT ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" )); + aFontItem.QueryValue( a ); + aArgs[0].Value = a; + + // #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + // This instance may be deleted in the meantime (i.e. when a dialog is opened + // while in Dispatch()), accessing members will crash in this case. + ReleaseFocus_Impl(); + + SfxToolBoxControl::Dispatch( m_xDispatchProvider, + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )), + aArgs ); + } + else + ReleaseFocus_Impl(); + } +} + +//======================================================================== +// class SvxColorWindow_Impl -------------------------------------------------- +//======================================================================== +#ifndef WB_NO_DIRECTSELECT +#define WB_NO_DIRECTSELECT ((WinBits)0x04000000) +#endif + +#define PALETTE_X 10 +#define PALETTE_Y 11 +#define PALETTE_SIZE (PALETTE_X * PALETTE_Y) + +SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, + USHORT nSlotId, + const Reference< XFrame >& rFrame, + const String& rWndTitle, + Window* pParentWindow ) : + + SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ), + + theSlotId( nSlotId ), + aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ), + maCommand( rCommand ) + +{ + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = NULL; + XColorTable* pColorTable = NULL; + BOOL bKillTable = FALSE; + const Size aSize12( 13, 13 ); + + if ( pDocSh ) + if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) + pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); + + if ( !pColorTable ) + { + pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() ); + bKillTable = TRUE; + } + + if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) + { + aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD ); + aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) ); + } + else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId ) + { + SfxPoolItem* pDummy; + + Reference< XDispatchProvider > aDisp( GetFrame()->getController(), UNO_QUERY ); + SfxQueryStatus aQueryStatus( aDisp, + SID_ATTR_AUTO_COLOR_INVALID, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoColorInvalid" ))); + SfxItemState eState = aQueryStatus.QueryState( pDummy ); + if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) ) + { + aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD ); + aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) ); + } + } + + if ( pColorTable ) + { + short i = 0; + long nCount = pColorTable->Count(); + XColorEntry* pEntry = NULL; + ::Color aColWhite( COL_WHITE ); + String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) ); + + if ( nCount > PALETTE_SIZE ) + // Show scrollbar if more than PALLETTE_SIZE colors are available + aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL ); + + for ( i = 0; i < nCount; i++ ) + { + pEntry = pColorTable->GetColor(i); + aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() ); + } + + while ( i < PALETTE_SIZE ) + { + // fill empty elements if less then PALLETTE_SIZE colors are available + aColorSet.InsertItem( i+1, aColWhite, aStrWhite ); + i++; + } + } + + aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) ); + aColorSet.SetColCount( PALETTE_X ); + aColorSet.SetLineCount( PALETTE_Y ); + + lcl_CalcSizeValueSet( *this, aColorSet, aSize12 ); + + SetHelpId( HID_POPUP_COLOR ); + aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL ); + + SetText( rWndTitle ); + aColorSet.Show(); + + AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" ))); + if ( bKillTable ) + delete pColorTable; +} + +SvxColorWindow_Impl::~SvxColorWindow_Impl() +{ +} + +void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt ) +{ + aColorSet.KeyInput(rKEvt); +} + +SfxPopupWindow* SvxColorWindow_Impl::Clone() const +{ + return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent() ); +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxColorWindow_Impl, SelectHdl, void *, EMPTYARG ) +{ + USHORT nItemId = aColorSet.GetSelectItemId(); + SvxColorItem aColorItem( aColorSet.GetItemColor( nItemId ), theSlotId ); + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + aColorSet.SetNoSelection(); + + if ( IsInPopupMode() ) + EndPopupMode(); + + if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) ) + { + Sequence< PropertyValue > aArgs; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), + maCommand, + aArgs ); + } + else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) ) + { + SvxColorItem _aColorItem( COL_AUTO, theSlotId ); + INetURLObject aObj( maCommand ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + _aColorItem.QueryValue( a ); + aArgs[0].Value = a; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), + maCommand, + aArgs ); + } + else + { + INetURLObject aObj( maCommand ); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + aColorItem.QueryValue( a ); + aArgs[0].Value = a; + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), + maCommand, + aArgs ); + } + + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxColorWindow_Impl::Resize() +{ + lcl_ResizeValueSet( *this, aColorSet); +} + +// ----------------------------------------------------------------------- + +void SvxColorWindow_Impl::StartSelection() +{ + aColorSet.StartSelection(); +} + +// ----------------------------------------------------------------------- + +BOOL SvxColorWindow_Impl::Close() +{ + return SfxPopupWindow::Close(); +} + +// ----------------------------------------------------------------------- + +void SvxColorWindow_Impl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + if (( SFX_ITEM_DISABLED != eState ) && pState ) + { + if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorTableItem ))) + { + XColorTable* pColorTable = pState ? ((SvxColorTableItem *)pState)->GetColorTable() : NULL; + + if ( pColorTable ) + { + // Die Liste der Farben (ColorTable) hat sich ge"andert: + short i = 0; + long nCount = pColorTable->Count(); + XColorEntry* pEntry = NULL; + ::Color aColWhite( COL_WHITE ); + String aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE ) ); + + // ScrollBar an oder aus + WinBits nBits = aColorSet.GetStyle(); + if ( nCount > PALETTE_SIZE ) + nBits &= ~WB_VSCROLL; + else + nBits |= WB_VSCROLL; + aColorSet.SetStyle( nBits ); + + for ( i = 0; i < nCount; ++i ) + { + pEntry = pColorTable->GetColor(i); + aColorSet.SetItemColor( i + 1, pEntry->GetColor() ); + aColorSet.SetItemText ( i + 1, pEntry->GetName() ); + } + + while ( i < PALETTE_SIZE ) + { + aColorSet.SetItemColor( i + 1, aColWhite ); + aColorSet.SetItemText ( i + 1, aStrWhite ); + i++; + } + } + } + } +} + +//======================================================================== +// class SvxFrameWindow_Impl -------------------------------------------------- +//======================================================================== + +SvxFrameWindow_Impl::SvxFrameWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) : + + SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ), + aFrameSet ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ), + bParagraphMode(sal_False) + +{ + BindListener(); + String sCommand(String::CreateFromAscii( ".uno:BorderReducedMode" )); + AddStatusListener( sCommand ); + aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) ); + + /* + * 1 2 3 4 + * ------------------------------------- + * NONE LEFT RIGHT LEFTRIGHT + * TOP BOTTOM TOPBOTTOM OUTER + * ------------------------------------- + * HOR HORINNER VERINNER ALL <- kann ueber bParagraphMode + * abgeschaltet werden + */ + + USHORT i = 0; + + for ( i=1; i<9; i++ ) + aFrameSet.InsertItem( i, aImgList.GetImage(i) ); + + //bParagraphMode should have been set in StateChanged + if ( !bParagraphMode ) + for ( i = 9; i < 13; i++ ) + aFrameSet.InsertItem( i, aImgList.GetImage(i) ); + + aFrameSet.SetColCount( 4 ); + aFrameSet.SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) ); + + lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 )); + + SetHelpId( HID_POPUP_FRAME ); + SetText( SVX_RESSTR(RID_SVXSTR_FRAME) ); + aFrameSet.Show(); +} + +SvxFrameWindow_Impl::~SvxFrameWindow_Impl() +{ + UnbindListener(); +} + +SfxPopupWindow* SvxFrameWindow_Impl::Clone() const +{ + //! HACK: wie bekomme ich den Paragraph-Mode ?? + return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() ); +} + +Window* SvxFrameWindow_Impl::GetPreferredKeyInputWindow() +{ + return &aFrameSet; +} + +void SvxFrameWindow_Impl::GetFocus() +{ + aFrameSet.GrabFocus(); +} + +void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + SfxPopupWindow::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) ); + + USHORT nNumOfItems = aFrameSet.GetItemCount(); + + for( USHORT i = 1 ; i <= nNumOfItems ; ++i ) + aFrameSet.SetItemImage( i, aImgList.GetImage( i ) ); + } +} +// ----------------------------------------------------------------------- + +#define FRM_VALID_LEFT 0x01 +#define FRM_VALID_RIGHT 0x02 +#define FRM_VALID_TOP 0x04 +#define FRM_VALID_BOTTOM 0x08 +#define FRM_VALID_HINNER 0x10 +#define FRM_VALID_VINNER 0x20 +#define FRM_VALID_OUTER 0x0f +#define FRM_VALID_ALL 0xff + +// +// Per default bleiben ungesetzte Linien unveraendert +// Mit Shift werden ungesetzte Linien zurueckgsetzt +// +IMPL_LINK( SvxFrameWindow_Impl, SelectHdl, void *, EMPTYARG ) +{ + ::Color aColBlack( COL_BLACK ); + SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER ); + SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER ); + SvxBorderLine theDefLine; + SvxBorderLine *pLeft = 0, + *pRight = 0, + *pTop = 0, + *pBottom = 0; + USHORT nSel = aFrameSet.GetSelectItemId(); + USHORT nModifier = aFrameSet.GetModifier(); + BYTE nValidFlags = 0; + + theDefLine.SetOutWidth( DEF_LINE_WIDTH_0 ); + switch ( nSel ) + { + case 1: nValidFlags |= FRM_VALID_ALL; + break; // NONE + case 2: pLeft = &theDefLine; + nValidFlags |= FRM_VALID_LEFT; + break; // LEFT + case 3: pRight = &theDefLine; + nValidFlags |= FRM_VALID_RIGHT; + break; // RIGHT + case 4: pLeft = pRight = &theDefLine; + nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT; + break; // LEFTRIGHT + case 5: pTop = &theDefLine; + nValidFlags |= FRM_VALID_TOP; + break; // TOP + case 6: pBottom = &theDefLine; + nValidFlags |= FRM_VALID_BOTTOM; + break; // BOTTOM + case 7: pTop = pBottom = &theDefLine; + nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP; + break; // TOPBOTTOM + case 8: pLeft = pRight = pTop = pBottom = &theDefLine; + nValidFlags |= FRM_VALID_OUTER; + break; // OUTER + + // Tabelle innen: + case 9: // HOR + pTop = pBottom = &theDefLine; + aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI ); + aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT ); + nValidFlags |= FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM; + break; + + case 10: // HORINNER + pLeft = pRight = pTop = pBottom = &theDefLine; + aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI ); + aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT ); + nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM; + break; + + case 11: // VERINNER + pLeft = pRight = pTop = pBottom = &theDefLine; + aBorderInner.SetLine( NULL, BOXINFO_LINE_HORI ); + aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT ); + nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_VINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM; + break; + + case 12: // ALL + pLeft = pRight = pTop = pBottom = &theDefLine; + aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI ); + aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT ); + nValidFlags |= FRM_VALID_ALL; + break; + + default: + break; + } + aBorderOuter.SetLine( pLeft, BOX_LINE_LEFT ); + aBorderOuter.SetLine( pRight, BOX_LINE_RIGHT ); + aBorderOuter.SetLine( pTop, BOX_LINE_TOP ); + aBorderOuter.SetLine( pBottom, BOX_LINE_BOTTOM ); + + if(nModifier == KEY_SHIFT) + nValidFlags |= FRM_VALID_ALL; + aBorderInner.SetValid( VALID_TOP, 0 != (nValidFlags&FRM_VALID_TOP )); + aBorderInner.SetValid( VALID_BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM )); + aBorderInner.SetValid( VALID_LEFT, 0 != (nValidFlags&FRM_VALID_LEFT)); + aBorderInner.SetValid( VALID_RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT )); + aBorderInner.SetValid( VALID_HORI, 0 != (nValidFlags&FRM_VALID_HINNER )); + aBorderInner.SetValid( VALID_VERT, 0 != (nValidFlags&FRM_VALID_VINNER)); + aBorderInner.SetValid( VALID_DISTANCE, TRUE ); + aBorderInner.SetValid( VALID_DISABLE, FALSE ); + + if ( IsInPopupMode() ) + EndPopupMode(); + + Any a; + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OuterBorder" )); + aBorderOuter.QueryValue( a ); + aArgs[0].Value = a; + aArgs[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "InnerBorder" )); + aBorderInner.QueryValue( a ); + aArgs[1].Value = a; + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + aFrameSet.SetNoSelection(); + + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SetBorderStyle" )), + aArgs ); + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxFrameWindow_Impl::Resize() +{ + lcl_ResizeValueSet( *this, aFrameSet); +} + +// ----------------------------------------------------------------------- + +void SvxFrameWindow_Impl::StateChanged( + + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) + +{ + if ( pState && nSID == SID_BORDER_REDUCED_MODE) + { + const SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState ); + + if ( pItem ) + { + bParagraphMode = (BOOL)pItem->GetValue(); + //initial calls mustn't insert or remove elements + if(aFrameSet.GetItemCount()) + { + BOOL bTableMode = ( aFrameSet.GetItemCount() == 12 ); + BOOL bResize = FALSE; + + if ( bTableMode && bParagraphMode ) + { + for ( USHORT i = 9; i < 13; i++ ) + aFrameSet.RemoveItem(i); + bResize = TRUE; + } + else if ( !bTableMode && !bParagraphMode ) + { + for ( USHORT i = 9; i < 13; i++ ) + aFrameSet.InsertItem( i, aImgList.GetImage(i) ); + bResize = TRUE; + } + + if ( bResize ) + { + lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 )); + } + } + } + } + SfxPopupWindow::StateChanged( nSID, eState, pState ); +} + +// ----------------------------------------------------------------------- + +void SvxFrameWindow_Impl::StartSelection() +{ + aFrameSet.StartSelection(); +} + +// ----------------------------------------------------------------------- + +BOOL SvxFrameWindow_Impl::Close() +{ + return SfxPopupWindow::Close(); +} + +//======================================================================== +// class SvxLineWindow_Impl -------------------------------------------------- +//======================================================================== + +SvxLineWindow_Impl::SvxLineWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) : + + SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ), + + aLineSet( this, WinBits( WB_3DLOOK | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_NONEFIELD | WB_NO_DIRECTSELECT ) ) +{ + try + { + Reference< lang::XServiceInfo > xServices( rFrame->getController()->getModel(), UNO_QUERY_THROW ); + m_bIsWriter = xServices->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument"))); + } + catch(const uno::Exception& ) + { + } + Size aBmpSize( 55, 12 ); + CreateBitmaps(); + + aLineSet.SetColCount( 2 ); + aLineSet.SetSelectHdl( LINK( this, SvxLineWindow_Impl, SelectHdl ) ); + aLineSet.SetText( SVX_RESSTR(STR_NONE) ); + + lcl_CalcSizeValueSet( *this, aLineSet, aBmpSize ); + + SetHelpId( HID_POPUP_LINE ); + SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE) ); + aLineSet.Show(); +} + +SfxPopupWindow* SvxLineWindow_Impl::Clone() const +{ + return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() ); +} + +// ----------------------------------------------------------------------- + +void SvxLineWindow_Impl::MakeLineBitmap( USHORT nNo, Bitmap& rBmp, const Size& rSize, String& rStr, + const ::Color& rLineCol, const ::Color& rBackCol ) +{ + VirtualDevice aVirDev( *this ); + Rectangle aRect( Point(2,0), Size(rSize.Width()-4,0) ); + + // grau einfaerben und Bitmap sichern: + aVirDev.SetOutputSizePixel( rSize ); + aVirDev.SetLineColor(); + aVirDev.SetFillColor( rBackCol ); + aVirDev.DrawRect( Rectangle( Point(0,0), rSize ) ); + aVirDev.SetFillColor( rLineCol ); + + sal_uInt16 nLineWidth = 0; + switch ( nNo ) + { + case 1: // DEF_LINE_WIDTH_0 + aRect.Top() = 6; + aRect.Bottom() = 6; + aVirDev.DrawRect( aRect ); + break; + + case 2: // DEF_LINE_WIDTH_1 + aRect.Top() = 5; + aRect.Bottom() = 6; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) DEF_LINE_WIDTH_1/20; + break; + + case 3: // DEF_LINE_WIDTH_2 + aRect.Top() = 5; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) DEF_LINE_WIDTH_2/20; + break; + + case 4: // DEF_LINE_WIDTH_3 + aRect.Top() = 4; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + aVirDev.DrawRect( Rectangle( Point(2,4), Point(37,7) ) ); + nLineWidth = (USHORT) DEF_LINE_WIDTH_3/20; + break; + + case 5: // DEF_LINE_WIDTH_4 + aRect.Top() = 4; + aRect.Bottom() = 8; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) DEF_LINE_WIDTH_4/20; + break; + + case 6: // DEF_DOUBLE_LINE0 + aRect.Top() = 5; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 7; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE0_OUT+DEF_DOUBLE_LINE0_IN+DEF_DOUBLE_LINE0_DIST)/20; + break; + + case 7: // DEF_DOUBLE_LINE7 + aRect.Top() = 4; + aRect.Bottom() = 4; + aVirDev.DrawRect( aRect ); + aRect.Top() = 7; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE7_OUT+DEF_DOUBLE_LINE7_IN+DEF_DOUBLE_LINE7_DIST)/20; + break; + + case 8: // DEF_DOUBLE_LINE1 + aRect.Top() = 4; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 7; + aRect.Bottom() = 8; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE1_OUT+DEF_DOUBLE_LINE1_IN+DEF_DOUBLE_LINE1_DIST)/20; + break; + + case 9: // DEF_DOUBLE_LINE2 + aRect.Top() = 3; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 8; + aRect.Bottom() = 10; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE2_OUT+DEF_DOUBLE_LINE2_IN+DEF_DOUBLE_LINE2_DIST)/20; + break; + + case 10: // DEF_DOUBLE_LINE8 + aRect.Top() = 3; + aRect.Bottom() = 4; + aVirDev.DrawRect( aRect ); + aRect.Top() = 7; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE8_OUT+DEF_DOUBLE_LINE8_IN+DEF_DOUBLE_LINE8_DIST)/20; + break; + + case 11: // DEF_DOUBLE_LINE9 + aRect.Top() = 3; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 8; + aRect.Bottom() = 8; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE9_OUT+DEF_DOUBLE_LINE9_IN+DEF_DOUBLE_LINE9_DIST)/20; + break; + + case 12: // DEF_DOUBLE_LINE10 + aRect.Top() = 2; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 8; + aRect.Bottom() = 8; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE10_OUT+DEF_DOUBLE_LINE10_IN+DEF_DOUBLE_LINE10_DIST)/20; + break; + + case 13: // DEF_DOUBLE_LINE3 + aRect.Top() = 4; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 7; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE3_OUT+DEF_DOUBLE_LINE3_IN+DEF_DOUBLE_LINE3_DIST)/20; + break; + + case 14: // DEF_DOUBLE_LINE4 + aRect.Top() = 4; + aRect.Bottom() = 4; + aVirDev.DrawRect( aRect ); + aRect.Top() = 6; + aRect.Bottom() = 7; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE4_OUT+DEF_DOUBLE_LINE4_IN+DEF_DOUBLE_LINE4_DIST)/20; + break; + + case 15: // DEF_DOUBLE_LINE5 + aRect.Top() = 3; + aRect.Bottom() = 5; + aVirDev.DrawRect( aRect ); + aRect.Top() = 8; + aRect.Bottom() = 9; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE5_OUT+DEF_DOUBLE_LINE5_IN+DEF_DOUBLE_LINE5_DIST)/20; + break; + + case 16: // DEF_DOUBLE_LINE6 + aRect.Top() = 3; + aRect.Bottom() = 4; + aVirDev.DrawRect( aRect ); + aRect.Top() = 7; + aRect.Bottom() = 9; + aVirDev.DrawRect( aRect ); + nLineWidth = (USHORT) (DEF_DOUBLE_LINE6_OUT+DEF_DOUBLE_LINE6_IN+DEF_DOUBLE_LINE6_DIST)/20; + break; + case 17: // Dotted line + aRect.Top() = 6; + aRect.Bottom() = 6; + aVirDev.SetLineColor( rLineCol ); + aVirDev.SetFillColor(); + svtools::DrawLine( aVirDev, aRect.LeftCenter(), aRect.RightCenter(), 1, DOTTED ); + break; + + case 18: // Dashed line + aRect.Top() = 6; + aRect.Bottom() = 6; + aVirDev.SetLineColor( rLineCol ); + aVirDev.SetFillColor(); + svtools::DrawLine( aVirDev, aRect.LeftCenter(), aRect.RightCenter(), 1, DASHED ); + break; + + default: + break; + } + if ( nLineWidth ) + { + rStr = String::CreateFromInt32( nLineWidth ); + rStr.AppendAscii(" pt"); + } + rBmp = aVirDev.GetBitmap( Point(0,0), rSize ); +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxLineWindow_Impl, SelectHdl, void *, EMPTYARG ) +{ + SvxLineItem aLineItem( SID_FRAME_LINESTYLE ); + USHORT n1 = 0, + n2 = 0, + n3 = 0; + SvxBorderStyle nStyle = SOLID; + BOOL bSetLine = TRUE; + + switch ( aLineSet.GetSelectItemId() ) + { + case 1: n1 = DEF_LINE_WIDTH_0; break; + case 2: n1 = DEF_LINE_WIDTH_1; break; + case 3: n1 = DEF_LINE_WIDTH_2; break; + case 4: n1 = DEF_LINE_WIDTH_3; break; + case 5: n1 = DEF_LINE_WIDTH_4; break; + + case 6: n1 = DEF_DOUBLE_LINE0_OUT; + n2 = DEF_DOUBLE_LINE0_IN; + n3 = DEF_DOUBLE_LINE0_DIST; break; + case 7: n1 = DEF_DOUBLE_LINE7_OUT; + n2 = DEF_DOUBLE_LINE7_IN; + n3 = DEF_DOUBLE_LINE7_DIST; break; + case 8: n1 = DEF_DOUBLE_LINE1_OUT; + n2 = DEF_DOUBLE_LINE1_IN; + n3 = DEF_DOUBLE_LINE1_DIST; break; + case 9: n1 = DEF_DOUBLE_LINE2_OUT; + n2 = DEF_DOUBLE_LINE2_IN; + n3 = DEF_DOUBLE_LINE2_DIST; break; + case 10: n1 = DEF_DOUBLE_LINE8_OUT; + n2 = DEF_DOUBLE_LINE8_IN; + n3 = DEF_DOUBLE_LINE8_DIST; break; + case 11: n1 = DEF_DOUBLE_LINE9_OUT; + n2 = DEF_DOUBLE_LINE9_IN; + n3 = DEF_DOUBLE_LINE9_DIST; break; + case 12: n1 = DEF_DOUBLE_LINE10_OUT; + n2 = DEF_DOUBLE_LINE10_IN; + n3 = DEF_DOUBLE_LINE10_DIST; break; + case 13: n1 = DEF_DOUBLE_LINE3_OUT; + n2 = DEF_DOUBLE_LINE3_IN; + n3 = DEF_DOUBLE_LINE3_DIST; break; + case 14: n1 = DEF_DOUBLE_LINE4_OUT; + n2 = DEF_DOUBLE_LINE4_IN; + n3 = DEF_DOUBLE_LINE4_DIST; break; + case 15: n1 = DEF_DOUBLE_LINE5_OUT; + n2 = DEF_DOUBLE_LINE5_IN; + n3 = DEF_DOUBLE_LINE5_DIST; break; + case 16: n1 = DEF_DOUBLE_LINE6_OUT; + n2 = DEF_DOUBLE_LINE6_IN; + n3 = DEF_DOUBLE_LINE6_DIST; break; + case 17: + n1 = DEF_LINE_WIDTH_5; + nStyle = DOTTED; + break; + case 18: + n1 = DEF_LINE_WIDTH_5; + nStyle = DASHED; + break; + case 0: + default: + bSetLine = FALSE; + break; + } + if ( bSetLine ) + { + SvxBorderLine aTmp( NULL, n1, n2, n3, nStyle ); + aLineItem.SetLine( &aTmp ); + } + else + aLineItem.SetLine( 0 ); + + if ( IsInPopupMode() ) + EndPopupMode(); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" )); + aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 ); + aArgs[0].Value = a; + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + aLineSet.SetNoSelection(); + + SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineStyle" )), + aArgs ); + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxLineWindow_Impl::Resize() +{ + lcl_ResizeValueSet( *this, aLineSet); +} + +// ----------------------------------------------------------------------- + +void SvxLineWindow_Impl::StartSelection() +{ + aLineSet.StartSelection(); +} + +// ----------------------------------------------------------------------- + +BOOL SvxLineWindow_Impl::Close() +{ + return SfxPopupWindow::Close(); +} + +// ----------------------------------------------------------------------- + +Window* SvxLineWindow_Impl::GetPreferredKeyInputWindow() +{ + return &aLineSet; +} + +// ----------------------------------------------------------------------- + +void SvxLineWindow_Impl::GetFocus() +{ + aLineSet.GrabFocus(); +} + +void SvxLineWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + SfxPopupWindow::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + CreateBitmaps(); + Invalidate(); + } +} + +void SvxLineWindow_Impl::CreateBitmaps( void ) +{ + Size aBmpSize( 55, 12 ); + Bitmap aBmp; + String aStr; + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + svtools::ColorConfig aColorConfig; + ::Color aLineCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); + ::Color aBackCol( rStyleSettings.GetWindowColor() ); + aLineSet.Clear(); + + for( USHORT i = 1 ; i < 19 ; ++i ) + { + MakeLineBitmap( i, aBmp, aBmpSize, aStr, aLineCol, aBackCol ); + aLineSet.InsertItem( i, aBmp, aStr ); + } +} + +// ----------------------------------------------------------------------- + +//######################################################################## +// Hilfsklassen + +//======================================================================== +// class SfxStyleControllerItem_Impl ------------------------------------------ +//======================================================================== + +SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl( + const Reference< XDispatchProvider >& rDispatchProvider, + USHORT nSlotId, // Family-ID + const rtl::OUString& rCommand, // .uno: command bound to this item + SvxStyleToolBoxControl& rTbxCtl ) // Controller-Instanz, dem dieses Item zugeordnet ist. + : SfxStatusListener( rDispatchProvider, nSlotId, rCommand ), + rControl( rTbxCtl ) +{ +} + +// ----------------------------------------------------------------------- + +void SfxStyleControllerItem_Impl::StateChanged( + USHORT, SfxItemState eState, const SfxPoolItem* pState ) +{ + switch ( GetId() ) + { + case SID_STYLE_FAMILY1: + case SID_STYLE_FAMILY2: + case SID_STYLE_FAMILY3: + case SID_STYLE_FAMILY4: + case SID_STYLE_FAMILY5: + { + const USHORT nIdx = GetId() - SID_STYLE_FAMILY_START; + + if ( SFX_ITEM_AVAILABLE == eState ) + { + const SfxTemplateItem* pStateItem = + PTR_CAST( SfxTemplateItem, pState ); + DBG_ASSERT( pStateItem != NULL, "SfxTemplateItem expected" ); + rControl.SetFamilyState( nIdx, pStateItem ); + } + else + rControl.SetFamilyState( nIdx, NULL ); + break; + } + } +} + +//######################################################################## + +//======================================================================== +// class SvxStyleToolBoxControl ------------------------------------------ +//======================================================================== + +struct SvxStyleToolBoxControl::Impl +{ + String aClearForm; + String aMore; + ::std::vector< ::rtl::OUString > aDefaultStyles; + BOOL bListening; + BOOL bSpecModeWriter; + BOOL bSpecModeCalc; + + inline Impl( void ) + :aClearForm ( SVX_RESSTR( RID_SVXSTR_CLEARFORM ) ) + ,aMore ( SVX_RESSTR( RID_SVXSTR_MORE ) ) + ,bListening ( FALSE ) + ,bSpecModeWriter ( FALSE ) + ,bSpecModeCalc ( FALSE ) + { + + + } + void InitializeStyles(Reference < frame::XModel > xModel) + { + //now convert the default style names to the localized names + try + { + Reference< style::XStyleFamiliesSupplier > xStylesSupplier( xModel, UNO_QUERY_THROW ); + Reference< lang::XServiceInfo > xServices( xModel, UNO_QUERY_THROW ); + bSpecModeWriter = xServices->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument"))); + if(bSpecModeWriter) + { + Reference<container::XNameAccess> xParaStyles; + xStylesSupplier->getStyleFamilies()->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles"))) >>= + xParaStyles; + static const sal_Char* aWriterStyles[] = + { + "Standard", + "Heading 1", + "Heading 2", + "Heading 3", + "Text body" + }; + for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle ) + { + try + { + Reference< beans::XPropertySet > xStyle; + xParaStyles->getByName( rtl::OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle; + ::rtl::OUString sName; + xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName"))) >>= sName; + if( sName.getLength() ) + aDefaultStyles.push_back(sName); + } + catch( const uno::Exception& ) + {} + } + + } + else if( 0 != ( + bSpecModeCalc = xServices->supportsService(::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument"))))) + { + static const sal_Char* aCalcStyles[] = + { + "Default", + "Heading 1", + "Heading 2", + "Result", + "Result2" + }; + Reference<container::XNameAccess> xCellStyles; + xStylesSupplier->getStyleFamilies()->getByName( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))) >>= + xCellStyles; + for( sal_uInt32 nStyle = 0; nStyle < sizeof( aCalcStyles ) / sizeof( sal_Char*); ++nStyle ) + { + try + { + Reference< beans::XPropertySet > xStyle; + xCellStyles->getByName( rtl::OUString::createFromAscii( aCalcStyles[nStyle] )) >>= xStyle; + ::rtl::OUString sName; + xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName")))>>= sName; + if( sName.getLength() ) + aDefaultStyles.push_back(sName); + } + catch( const uno::Exception& ) + {} + } + } + } + catch(const uno::Exception& ) + { + DBG_ERROR("error while initializing style names"); + } + } +}; + + +// mapping table from bound items. BE CAREFUL this table must be in the +// same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n +// MAX_FAMILIES must also be correctly set! +static const char* StyleSlotToStyleCommand[MAX_FAMILIES] = +{ + ".uno:CharStyle", + ".uno:ParaStyle", + ".uno:FrameStyle", + ".uno:PageStyle", + ".uno:TemplateFamily5" +}; + +SvxStyleToolBoxControl::SvxStyleToolBoxControl( + USHORT nSlotId, USHORT nId, ToolBox& rTbx ) + : SfxToolBoxControl ( nSlotId, nId, rTbx ), + pStyleSheetPool ( NULL ), + nActFamily ( 0xffff ), + bListening ( FALSE ), + pImpl ( new Impl ) +{ + for ( USHORT i=0; i<MAX_FAMILIES; i++ ) + { + pBoundItems[i] = 0; + m_xBoundItems[i] = Reference< XComponent >(); + pFamilyState[i] = NULL; + } +} + +// ----------------------------------------------------------------------- +SvxStyleToolBoxControl::~SvxStyleToolBoxControl() +{ +} + +// ----------------------------------------------------------------------- +void SAL_CALL SvxStyleToolBoxControl::initialize( const Sequence< Any >& aArguments ) +throw ( Exception, RuntimeException) +{ + SfxToolBoxControl::initialize( aArguments ); + + // After initialize we should have a valid frame member where we can retrieve our + // dispatch provider. + if ( m_xFrame.is() ) + { + pImpl->InitializeStyles(m_xFrame->getController()->getModel()); + Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY ); + for ( USHORT i=0; i<MAX_FAMILIES; i++ ) + { + pBoundItems[i] = new SfxStyleControllerItem_Impl( xDispatchProvider, + SID_STYLE_FAMILY_START + i, + OUString::createFromAscii( StyleSlotToStyleCommand[i] ), + *this ); + m_xBoundItems[i] = Reference< XComponent >( static_cast< OWeakObject* >( pBoundItems[i] ), UNO_QUERY ); + pFamilyState[i] = NULL; + } + } +} + +// XComponent +void SAL_CALL SvxStyleToolBoxControl::dispose() +throw (::com::sun::star::uno::RuntimeException) +{ + SfxToolBoxControl::dispose(); + + for( USHORT i=0; i<MAX_FAMILIES; i++ ) + { + if ( m_xBoundItems[i].is() ) + { + try + { + m_xBoundItems[i]->dispose(); + } + catch ( Exception& ) + { + } + + m_xBoundItems[i].clear(); + pBoundItems[i] = 0; + } + DELETEZ( pFamilyState[i] ); + } + pStyleSheetPool = NULL; + DELETEZ( pImpl ); +} + +// ----------------------------------------------------------------------- +void SAL_CALL SvxStyleToolBoxControl::update() throw (RuntimeException) +{ + // Do nothing, we will start binding our listener when we are visible. + // See link SvxStyleToolBoxControl::VisibilityNotification. + SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() ); + if ( pBox->IsVisible() ) + { + for ( int i=0; i<MAX_FAMILIES; i++ ) + pBoundItems [i]->ReBind(); + + bindListener(); + } +} + +// ----------------------------------------------------------------------- + +SfxStyleFamily SvxStyleToolBoxControl::GetActFamily() +{ + switch ( nActFamily-1 + SID_STYLE_FAMILY_START ) + { + case SID_STYLE_FAMILY1: return SFX_STYLE_FAMILY_CHAR; + case SID_STYLE_FAMILY2: return SFX_STYLE_FAMILY_PARA; + case SID_STYLE_FAMILY3: return SFX_STYLE_FAMILY_FRAME; + case SID_STYLE_FAMILY4: return SFX_STYLE_FAMILY_PAGE; + case SID_STYLE_FAMILY5: return SFX_STYLE_FAMILY_PSEUDO; + default: + DBG_ERROR( "unknown style family" ); + break; + } + return SFX_STYLE_FAMILY_PARA; +} + +// ----------------------------------------------------------------------- + +void SvxStyleToolBoxControl::FillStyleBox() +{ + SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() ); + + DBG_ASSERT( pStyleSheetPool, "StyleSheetPool not found!" ); + DBG_ASSERT( pBox, "Control not found!" ); + + if ( pStyleSheetPool && pBox && nActFamily!=0xffff ) + { + const SfxStyleFamily eFamily = GetActFamily(); + USHORT nCount = pStyleSheetPool->Count(); + USHORT i = 0; + SfxStyleSheetBase* pStyle = NULL; + BOOL bDoFill = FALSE; + + pStyleSheetPool->SetSearchMask( eFamily, SFXSTYLEBIT_USED ); + + //------------------------------ + // Ueberpruefen, ob Fill noetig: + //------------------------------ + + pStyle = pStyleSheetPool->First(); + //!!! TODO: This condition isn't right any longer, because we always show some default entries + //!!! so the list doesn't show the count + if ( nCount != pBox->GetEntryCount() ) + { + bDoFill = TRUE; + } + else + { + while ( pStyle && !bDoFill ) + { + bDoFill = ( pBox->GetEntry(i) != pStyle->GetName() ); + pStyle = pStyleSheetPool->Next(); + i++; + } + } + + if ( bDoFill ) + { + pBox->SetUpdateMode( FALSE ); + pBox->Clear(); + + { + USHORT _i; + sal_uInt32 nCnt = pImpl->aDefaultStyles.size(); + bool bInsert; + + pStyle = pStyleSheetPool->First(); + + if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc ) + { + while ( pStyle ) + { + // sort out default styles + bInsert = true; + ::rtl::OUString aName( pStyle->GetName() ); + for( _i = 0 ; _i < nCnt ; ++_i ) + { + if( pImpl->aDefaultStyles[_i] == aName ) + { + bInsert = false; + break; + } + } + + if( bInsert ) + pBox->InsertEntry( aName ); + pStyle = pStyleSheetPool->Next(); + } + } + else + { + while ( pStyle ) + { + pBox->InsertEntry( pStyle->GetName() ); + pStyle = pStyleSheetPool->Next(); + } + } + } + + if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc ) + { + // insert default styles + USHORT _i; + sal_uInt32 nCnt = pImpl->aDefaultStyles.size(); + USHORT nPos = 1; + for( _i = 0 ; _i < nCnt ; ++_i ) + { + pBox->InsertEntry( pImpl->aDefaultStyles[_i], nPos ); + ++nPos; + } + + // disable sort to preserve special order + WinBits nWinBits = pBox->GetStyle(); + nWinBits &= ~WB_SORT; + pBox->SetStyle( nWinBits ); + + pBox->InsertEntry( pImpl->aClearForm, 0 ); + pBox->SetSeparatorPos( 0 ); + + pBox->InsertEntry( pImpl->aMore ); + + // enable sort again + nWinBits |= WB_SORT; + pBox->SetStyle( nWinBits ); + } + + pBox->SetUpdateMode( TRUE ); + pBox->SetFamily( eFamily ); + + USHORT nLines = Min( pBox->GetEntryCount(), MAX_STYLES_ENTRIES ); + pBox->SetDropDownLineCount( nLines ); + } + } +} + +// ----------------------------------------------------------------------- + +void SvxStyleToolBoxControl::SelectStyle( const String& rStyleName ) +{ + SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() ); + DBG_ASSERT( pBox, "Control not found!" ); + + if ( pBox ) + { +// String aStrSel( pBox->GetSelectEntry() ); + String aStrSel( pBox->GetText() ); + + if ( rStyleName.Len() > 0 ) + { + if ( rStyleName != aStrSel ) +// pBox->SelectEntry( rStyleName ); + pBox->SetText( rStyleName ); + } + else + pBox->SetNoSelection(); + pBox->SaveValue(); + } +} + +// ----------------------------------------------------------------------- + +void SvxStyleToolBoxControl::Update() +{ + SfxStyleSheetBasePool* pPool = NULL; + SfxObjectShell* pDocShell = SfxObjectShell::Current(); + + if ( pDocShell ) + pPool = pDocShell->GetStyleSheetPool(); + + USHORT i; + for ( i=0; i<MAX_FAMILIES; i++ ) + if( pFamilyState[i] ) + break; + + if ( i==MAX_FAMILIES || !pPool ) + { + pStyleSheetPool = pPool; + return; + } + + //-------------------------------------------------------------------- + const SfxTemplateItem* pItem = NULL; + + if ( nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1]) ) + // aktueller Bereich nicht innerhalb der erlaubten Bereiche + // oder Default + { + pStyleSheetPool = pPool; + nActFamily = 2; + + pItem = pFamilyState[nActFamily-1]; + if ( !pItem ) + { + nActFamily++; + pItem = pFamilyState[nActFamily-1]; + } + + if ( !pItem ) + { + DBG_WARNING( "Unknown Family" ); // can happen + } + } + else if ( pPool != pStyleSheetPool ) + pStyleSheetPool = pPool; + + FillStyleBox(); // entscheidet selbst, ob gefuellt werden muss + + if ( pItem ) + SelectStyle( pItem->GetStyleName() ); +} + +// ----------------------------------------------------------------------- + +void SvxStyleToolBoxControl::SetFamilyState( USHORT nIdx, + const SfxTemplateItem* pItem ) +{ + DELETEZ( pFamilyState[nIdx] ); + + if ( pItem ) + pFamilyState[nIdx] = new SfxTemplateItem( *pItem ); + + Update(); +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( SvxStyleToolBoxControl, VisibilityNotification, void*, EMPTYARG ) +{ + + USHORT i; + + // Call ReBind() && UnBind() according to visibility + SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)( GetToolBox().GetItemWindow( GetId() )); + if ( pBox->IsVisible() && !isBound() ) + { + for ( i=0; i<MAX_FAMILIES; i++ ) + pBoundItems [i]->ReBind(); + + bindListener(); + } + else if ( !pBox->IsVisible() && isBound() ) + { + for ( i=0; i<MAX_FAMILIES; i++ ) + pBoundItems[i]->UnBind(); + unbindListener(); + } + + return 0; +} + +// ----------------------------------------------------------------------- + +void SvxStyleToolBoxControl::StateChanged( + + USHORT , SfxItemState eState, const SfxPoolItem* pState ) + +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)(rTbx.GetItemWindow( nId )); + TriState eTri = STATE_NOCHECK; + + DBG_ASSERT( pBox, "Control not found!" ); + + if ( SFX_ITEM_DISABLED == eState ) + pBox->Disable(); + else + pBox->Enable(); + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + + switch ( eState ) + { + case SFX_ITEM_AVAILABLE: + eTri = ((const SfxBoolItem*)pState)->GetValue() + ? STATE_CHECK + : STATE_NOCHECK; + break; + + case SFX_ITEM_DONTCARE: + eTri = STATE_DONTKNOW; + break; + } + + rTbx.SetItemState( nId, eTri ); + + if ( SFX_ITEM_DISABLED != eState ) + Update(); +} + +// ----------------------------------------------------------------------- + +Window* SvxStyleToolBoxControl::CreateItemWindow( Window *pParent ) +{ + SvxStyleBox_Impl* pBox = new SvxStyleBox_Impl( pParent, + SID_STYLE_APPLY, + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StyleApply" )), + SFX_STYLE_FAMILY_PARA, + Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ), + m_xFrame, + pImpl->aClearForm, + pImpl->aMore, + pImpl->bSpecModeWriter || pImpl->bSpecModeCalc ); + if( pImpl->aDefaultStyles.size()) + pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] ); + // Set visibility listener to bind/unbind controller + pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, VisibilityNotification )); + + return pBox; +} + +//======================================================================== +// class SvxFontNameToolBoxControl --------------------------------------- +//======================================================================== + +SvxFontNameToolBoxControl::SvxFontNameToolBoxControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) + + : SfxToolBoxControl( nSlotId, nId, rTbx ) +{ +} + +// ----------------------------------------------------------------------- + +void SvxFontNameToolBoxControl::StateChanged( + + USHORT , SfxItemState eState, const SfxPoolItem* pState ) + +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + SvxFontNameBox_Impl* pBox = (SvxFontNameBox_Impl*)(rTbx.GetItemWindow( nId )); + + DBG_ASSERT( pBox, "Control not found!" ); + + if ( SFX_ITEM_DISABLED == eState ) + { + pBox->Disable(); + pBox->Update( (const SvxFontItem*)NULL ); + } + else + { + pBox->Enable(); + + if ( SFX_ITEM_AVAILABLE == eState ) + { + const SvxFontItem* pFontItem = dynamic_cast< const SvxFontItem* >( pState ); + + DBG_ASSERT( pFontItem, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" ); + if( pFontItem ) + pBox->Update( pFontItem ); + } + else + pBox->SetText( String() ); + pBox->SaveValue(); + } + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); +} + +// ----------------------------------------------------------------------- + +Window* SvxFontNameToolBoxControl::CreateItemWindow( Window *pParent ) +{ + SvxFontNameBox_Impl* pBox = new SvxFontNameBox_Impl( pParent, + Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ), + m_xFrame,0); + return pBox; +} + +//======================================================================== +// class SvxFontColorToolBoxControl -------------------------------------- +//======================================================================== + +SvxFontColorToolBoxControl::SvxFontColorToolBoxControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) + + : SfxToolBoxControl( nSlotId, nId, rTbx ), + pBtnUpdater( new ::svx::ToolboxButtonColorUpdater( + nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW )) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); +} + +// ----------------------------------------------------------------------- + +SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl() +{ + delete pBtnUpdater; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxFontColorToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow() +{ + SvxColorWindow_Impl* pColorWin = + new SvxColorWindow_Impl( + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Color" )), + SID_ATTR_CHAR_COLOR, + m_xFrame, + SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ), + &GetToolBox() ); + + pColorWin->StartPopupMode( &GetToolBox(), + FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); + pColorWin->StartSelection(); + SetPopupWindow( pColorWin ); + return pColorWin; +} + +// ----------------------------------------------------------------------- + +void SvxFontColorToolBoxControl::StateChanged( + + USHORT , SfxItemState eState, const SfxPoolItem* pState ) + +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + const SvxColorItem* pItem = 0; + + if ( SFX_ITEM_DONTCARE != eState ) + pItem = PTR_CAST( SvxColorItem, pState ); + + if ( pItem ) + pBtnUpdater->Update( pItem->GetValue()); + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); +} + +//======================================================================== +// class SvxColorToolBoxControl -------------------------------- +//======================================================================== + +SvxColorToolBoxControl::SvxColorToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + if ( nSlotId == SID_BACKGROUND_COLOR ) + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); + else + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); + pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ); +} + +// ----------------------------------------------------------------------- + +SvxColorToolBoxControl::~SvxColorToolBoxControl() +{ + delete pBtnUpdater; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxColorToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow() +{ + USHORT nResId = GetSlotId() == SID_BACKGROUND_COLOR ? + RID_SVXSTR_BACKGROUND : RID_SVXSTR_COLOR; + SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl( + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" )), + SID_BACKGROUND_COLOR, + m_xFrame, + SVX_RESSTR(nResId), + &GetToolBox() ); + + pColorWin->StartPopupMode( &GetToolBox(), + FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); + pColorWin->StartSelection(); + SetPopupWindow( pColorWin ); + return pColorWin; +} + +// ----------------------------------------------------------------------- + +void SvxColorToolBoxControl::StateChanged( + + USHORT , SfxItemState eState, const SfxPoolItem* pState ) + +{ + const SvxColorItem* pItem = 0; + if ( SFX_ITEM_DONTCARE != eState ) + pItem = PTR_CAST( SvxColorItem, pState ); + + if ( pItem ) + pBtnUpdater->Update( pItem->GetValue() ); + + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); +} + +//======================================================================== +// class SvxFontColorExtToolBoxControl -------------------------------------- +//======================================================================== + +SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) : + + SfxToolBoxControl( nSlotId, nId, rTbx ), + pBtnUpdater(0) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + // The following commands are available at the writer module. + if ( SID_ATTR_CHAR_COLOR2 == nSlotId ) + addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ))); + else + addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ))); + + USHORT nMode = SID_ATTR_CHAR_COLOR2 == nSlotId + ? TBX_UPDATER_MODE_CHAR_COLOR_NEW : TBX_UPDATER_MODE_CHAR_COLOR_NEW; + pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode ); +} + +// ----------------------------------------------------------------------- + +SvxFontColorExtToolBoxControl::~SvxFontColorExtToolBoxControl() +{ + delete pBtnUpdater; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxFontColorExtToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONTIMEOUT; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow() +{ + SvxColorWindow_Impl* pColorWin = + new SvxColorWindow_Impl( + m_aCommandURL, + GetSlotId(), + m_xFrame, + SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ), + &GetToolBox() ); + + if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND ) + pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) ); + + pColorWin->StartPopupMode( &GetToolBox(), + FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); + pColorWin->StartSelection(); + SetPopupWindow( pColorWin ); + return pColorWin; +} + +// ----------------------------------------------------------------------- + +void SvxFontColorExtToolBoxControl::StateChanged( + + USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) + +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + const SvxColorItem* pItem = 0; + + if ( nSID == SID_ATTR_CHAR_COLOR_EXT || + nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) + { + if ( SFX_ITEM_DONTCARE != eState ) + { + const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState ); + rTbx.CheckItem( nId, pBool && pBool->GetValue()); + } + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + } + else + { + if ( SFX_ITEM_DONTCARE != eState ) + pItem = PTR_CAST( SvxColorItem, pState ); + + if ( pItem ) + pBtnUpdater->Update( pItem->GetValue() ); + } +} + +// ----------------------------------------------------------------------- + +void SvxFontColorExtToolBoxControl::Select( BOOL ) +{ + OUString aCommand; + OUString aParamName; + if ( SID_ATTR_CHAR_COLOR2 == GetSlotId() ) + { + aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )); + aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" )); + } + else + { + aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )); + aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" )); + } + + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = aParamName; + aArgs[0].Value = makeAny( GetToolBox().IsItemChecked( GetId() )); + Dispatch( aCommand, aArgs ); +} + +//======================================================================== +// class SvxFrameToolBoxControl ------------------------------------------ +//======================================================================== + +SvxFrameToolBoxControl::SvxFrameToolBoxControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) + + : SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxFrameToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxFrameToolBoxControl::CreatePopupWindow() +{ + SvxFrameWindow_Impl* pFrameWin = new SvxFrameWindow_Impl( + GetSlotId(), m_xFrame, &GetToolBox() ); + + pFrameWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS | FLOATWIN_POPUPMODE_ALLOWTEAROFF ); + pFrameWin->StartSelection(); + SetPopupWindow( pFrameWin ); + + return pFrameWin; +} + +// ----------------------------------------------------------------------- + +void SvxFrameToolBoxControl::StateChanged( + + USHORT, SfxItemState eState, const SfxPoolItem* ) + +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState) + ? STATE_DONTKNOW + : STATE_NOCHECK ); +} + +//======================================================================== +// class SvxFrameLineStyleToolBoxControl --------------------------------- +//======================================================================== + +SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) + + : SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxFrameLineStyleToolBoxControl::CreatePopupWindow() +{ + SvxLineWindow_Impl* pLineWin = new SvxLineWindow_Impl( GetSlotId(), m_xFrame, &GetToolBox() ); + pLineWin->StartPopupMode( &GetToolBox(), TRUE ); + pLineWin->StartSelection(); + SetPopupWindow( pLineWin ); + + return pLineWin; +} + +// ----------------------------------------------------------------------- + +void SvxFrameLineStyleToolBoxControl::StateChanged( + + USHORT , SfxItemState eState, const SfxPoolItem* ) +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState) + ? STATE_DONTKNOW + : STATE_NOCHECK ); +} + +//======================================================================== +// class SvxFrameLineColorToolBoxControl --------------------------------- +//======================================================================== + +SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) : + + SfxToolBoxControl( nSlotId, nId, rTbx ), + pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() )) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); +} + +// ----------------------------------------------------------------------- + +SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl() +{ + + delete pBtnUpdater; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxFrameLineColorToolBoxControl::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +SfxPopupWindow* SvxFrameLineColorToolBoxControl::CreatePopupWindow() +{ + SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl( + OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FrameLineColor" )), + SID_FRAME_LINECOLOR, + m_xFrame, + SVX_RESSTR(RID_SVXSTR_FRAME_COLOR), + &GetToolBox() ); + + pColorWin->StartPopupMode( &GetToolBox(), + FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF ); + pColorWin->StartSelection(); + SetPopupWindow( pColorWin ); + return pColorWin; +} + +// ----------------------------------------------------------------------- + +void SvxFrameLineColorToolBoxControl::StateChanged( + + USHORT , SfxItemState eState, const SfxPoolItem* pState ) + +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); + rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); + + const SvxColorItem* pItem = 0; + if ( SFX_ITEM_DONTCARE != eState ) + { + pItem = PTR_CAST( SvxColorItem, pState ); + if ( pItem ) + pBtnUpdater->Update( pItem->GetValue()); + } +} + +// class SvxReloadControllerItem_Impl ------------------------------------ + +class SvxReloadControllerItem_Impl +{ +public: + Image* pNormalImage; + Image* pSpecialImage; + + SvxReloadControllerItem_Impl() : + pNormalImage( new Image( SVX_RES( RID_SVX_RELOAD_NORMAL ) ) ), pSpecialImage( 0 ) {} + ~SvxReloadControllerItem_Impl() { delete pNormalImage; delete pSpecialImage; } + + Image& GetNormalImage() { return *pNormalImage; } + Image& GetSpecialImage() + { + if ( !pSpecialImage ) + pSpecialImage = new Image( SVX_RES( RID_SVX_RELOAD_SPECIAL ) ); + return *pSpecialImage; + } +}; + +// ----------------------------------------------------------------------- + +SvxReloadControllerItem::SvxReloadControllerItem( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) +: SfxToolBoxControl( nSlotId, nId, rTbx ) +, pImpl( new SvxReloadControllerItem_Impl ) +{ + rTbx.SetItemImage( nId, pImpl->GetNormalImage() ); +} + +// ----------------------------------------------------------------------- + +SvxReloadControllerItem::~SvxReloadControllerItem() +{ + delete pImpl; +} + +// ----------------------------------------------------------------------- + +void SvxReloadControllerItem::StateChanged( + USHORT , SfxItemState eState, const SfxPoolItem* pState ) +{ + SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState ); + ToolBox& rBox = GetToolBox(); + if( pItem ) + { + rBox.SetItemImage( GetId(), + pItem->GetValue() ? pImpl->GetSpecialImage() : + pImpl->GetNormalImage() ); + } + rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED ); +} + +//======================================================================== +// class SvxSimpleUndoRedoController ------------------------------------- +//======================================================================== + +SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) + :SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + aDefaultText = rTbx.GetItemText( nId ); +} + +// ----------------------------------------------------------------------- + +SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController() +{ +} + +// ----------------------------------------------------------------------- + +void SvxSimpleUndoRedoController::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState ) +{ + SfxStringItem* pItem = PTR_CAST( SfxStringItem, pState ); + ToolBox& rBox = GetToolBox(); + if ( pItem && eState != SFX_ITEM_DISABLED ) + { + ::rtl::OUString aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem->GetValue() ) ); + rBox.SetQuickHelpText( GetId(), aNewText ); + } + if ( eState == SFX_ITEM_DISABLED ) + rBox.SetQuickHelpText( GetId(), aDefaultText ); + rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED ); +} + +//======================================================================== + +void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet ) +{ + Size aSize = rWin.GetOutputSizePixel(); + aSize.Width() -= 4; + aSize.Height() -= 4; + rValueSet.SetPosSizePixel( Point(2,2), aSize ); +} + +// ----------------------------------------------------------------------- + +void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize ) +{ + Size aSize = rValueSet.CalcWindowSizePixel( aItemSize ); + aSize.Width() += 4; + aSize.Height() += 4; + rWin.SetOutputSizePixel( aSize ); +} + +// ----------------------------------------------------------------------- + +BOOL lcl_FontChangedHint( const SfxHint &rHint ) +{ + SfxPoolItemHint *pItemHint = PTR_CAST(SfxPoolItemHint, &rHint); + if ( pItemHint ) + { + SfxPoolItem *pItem = pItemHint->GetObject(); + return ( pItem->Which() == SID_ATTR_CHAR_FONTLIST ); + } + else + { + SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, &rHint); + return pSimpleHint && ( SFX_HINT_DATACHANGED == + ( pSimpleHint->GetId() & SFX_HINT_DATACHANGED ) ); + } +} +// ----------------------------------------------------------------------------- +Reference< ::com::sun::star::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible() +{ + FillList(); + return FontNameBox::CreateAccessible(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src new file mode 100644 index 000000000000..acdd4586e619 --- /dev/null +++ b/svx/source/tbxctrls/tbcontrl.src @@ -0,0 +1,162 @@ +/************************************************************************* + * + * 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 --------------------------------------------------------------- +#include <svx/dialogs.hrc> +#include <helpid.hrc> + // pragma ---------------------------------------------------------------- + +/* + * Bitmaps f"ur SvxFrameWindow + */ + +#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; }; + +Image RID_SVX_RELOAD_NORMAL +{ + ImageBitmap = Bitmap { File = "reload.bmp" ; }; + MASKCOLOR +}; + +Image RID_SVX_RELOAD_SPECIAL +{ + ImageBitmap = Bitmap { File = "reloads.bmp" ; }; + MASKCOLOR +}; + +ImageList RID_SVXIL_FRAME +{ + Prefix = "fr"; + IdList = { 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 ; }; + IdCount = { 12 ; }; + MASKCOLOR +}; + +String RID_SVXSTR_TRANSPARENT +{ + Text [ en-US ] = "No Fill" ; +}; +String RID_SVXSTR_FILLPATTERN + +{ + Text [ en-US ] = "Pattern" ; +}; + +String RID_SVXSTR_FRAME +{ + Text [ en-US ] = "Borders" ; +}; + +String RID_SVXSTR_FRAME_STYLE +{ + Text [ en-US ] = "Border Style" ; +}; + +String RID_SVXSTR_FRAME_COLOR +{ + Text [ en-US ] = "Border Color" ; +}; + +ComboBox RID_SVXTBX_STYLE +{ + HelpId = HID_STYLE_LISTBOX ; + Size = MAP_APPFONT ( 67 , 86 ) ; + DropDown = TRUE ; + Sort = TRUE ; + AutoHScroll = TRUE ; + DDExtraWidth = TRUE ; + Border = TRUE ; + Hide = TRUE ; +}; + +String RID_SVXSTR_EXTRAS_CHARBACKGROUND +{ + Text [ en-US ] = "Highlighting" ; +}; + +String RID_SVXSTR_BACKGROUND +{ + Text [ en-US ] = "Background"; +}; + +String RID_SVXSTR_AUTOMATIC +{ + Text [ en-US ] = "Automatic"; +}; + +String RID_SVXSTR_PAGES +{ + Text [ en-US ] = "Pages"; +}; + +Image RID_SVXIMG_GRAF_RED +{ + ImageBitmap = Bitmap { File = "sc10865.bmp" ; }; + MASKCOLOR +}; +Image RID_SVXIMG_GRAF_GREEN +{ + ImageBitmap = Bitmap { File = "sc10866.bmp" ; }; + MASKCOLOR +}; +Image RID_SVXIMG_GRAF_BLUE +{ + ImageBitmap = Bitmap { File = "sc10867.bmp" ; }; + MASKCOLOR +}; +Image RID_SVXIMG_GRAF_LUMINANCE +{ + ImageBitmap = Bitmap { File = "sc10863.bmp" ; }; + MASKCOLOR +}; +Image RID_SVXIMG_GRAF_CONTRAST +{ + ImageBitmap = Bitmap { File = "sc10864.bmp" ; }; + MASKCOLOR +}; +Image RID_SVXIMG_GRAF_GAMMA +{ + ImageBitmap = Bitmap { File = "sc10868.bmp" ; }; + MASKCOLOR +}; +Image RID_SVXIMG_GRAF_TRANSPARENCE +{ + ImageBitmap = Bitmap { File = "sc10869.bmp" ; }; + MASKCOLOR +}; + +String RID_SVXSTR_CLEARFORM +{ + Text [ en-US ] = "Clear formatting"; +}; + +String RID_SVXSTR_MORE +{ + Text [ en-US ] = "More..."; +}; + +// ********************************************************************** EOF + diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx new file mode 100644 index 000000000000..84072d2c07bc --- /dev/null +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -0,0 +1,432 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 "tbunocontroller.hxx" + +#include <com/sun/star/frame/status/FontHeight.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <svtools/ctrltool.hxx> +#include <svtools/ctrlbox.hxx> +#include <osl/mutex.hxx> + +#include <memory> + +#define LOGICAL_EDIT_HEIGHT 12 + +using namespace ::com::sun::star; + +namespace svx +{ + +class FontHeightToolBoxControl; +class SvxFontSizeBox_Impl : public FontSizeBox +{ +public: + SvxFontSizeBox_Impl( Window* pParent, + const uno::Reference< frame::XDispatchProvider >& rDispatchProvider, + const uno::Reference< frame::XFrame >& _xFrame, + FontHeightToolBoxControl& rCtrl ); + + void statusChanged_Impl( long nHeight, bool bErase = false ); + void UpdateFont( const ::com::sun::star::awt::FontDescriptor& rCurrentFont ); + + virtual long Notify( NotifyEvent& rNEvt ); + +protected: + virtual void Select(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +private: + FontHeightToolBoxControl* m_pCtrl; + String m_aCurText; + Size m_aLogicalSize; + BOOL m_bRelease; + uno::Reference< frame::XDispatchProvider > m_xDispatchProvider; + uno::Reference< frame::XFrame > m_xFrame; + uno::Reference< awt::XWindow > m_xOldFocusWindow; + + void ReleaseFocus_Impl(); +}; + +//======================================================================== +// class SvxFontSizeBox_Impl -------------------------------------------------- +//======================================================================== + +SvxFontSizeBox_Impl::SvxFontSizeBox_Impl( + Window* _pParent, + const uno::Reference< frame::XDispatchProvider >& _rDispatchProvider, + const uno::Reference< frame::XFrame >& _xFrame, + FontHeightToolBoxControl& _rCtrl ) : + + FontSizeBox( _pParent, WinBits( WB_DROPDOWN ) ), + + m_pCtrl ( &_rCtrl ), + m_aLogicalSize ( 30,100 ), + m_bRelease ( TRUE ), + m_xDispatchProvider ( _rDispatchProvider ), + m_xFrame ( _xFrame ) +{ + SetSizePixel( LogicToPixel( m_aLogicalSize, MAP_APPFONT )); + SetValue( 0 ); + SetText( String() ); +} + +// ----------------------------------------------------------------------- + +void SvxFontSizeBox_Impl::ReleaseFocus_Impl() +{ + if ( !m_bRelease ) + { + m_bRelease = TRUE; + return; + } + + if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() ) + m_xFrame->getContainerWindow()->setFocus(); +} + +// ----------------------------------------------------------------------- + +void SvxFontSizeBox_Impl::Select() +{ + FontSizeBox::Select(); + + if ( !IsTravelSelect() ) + { + sal_Int64 nSelVal = GetValue(); + float fSelVal = float( nSelVal ) / 10; + + uno::Sequence< beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight.Height" )); + aArgs[0].Value = uno::makeAny( fSelVal ); + + /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. + This instance may be deleted in the meantime (i.e. when a dialog is opened + while in Dispatch()), accessing members will crash in this case. */ + ReleaseFocus_Impl(); + + m_pCtrl->dispatchCommand( aArgs ); + } +} + +// ----------------------------------------------------------------------- + +void SvxFontSizeBox_Impl::statusChanged_Impl( long nPoint, bool bErase ) +{ + if ( !bErase ) + { + // Metric Umrechnen + long nVal = nPoint; + + // ge"andert => neuen Wert setzen + if ( GetValue() != nVal ) + SetValue( nVal ); + } + else + { + // Wert in der Anzeige l"oschen + SetValue( -1L ); + SetText( String() ); + } + SaveValue(); +} + +// ----------------------------------------------------------------------- + +void SvxFontSizeBox_Impl::UpdateFont( const ::com::sun::star::awt::FontDescriptor& rCurrentFont ) +{ + // Sizes-Liste auff"ullen + sal_Int64 nOldVal = GetValue(); // alten Wert merken + const FontList* _pFontList = NULL; + ::std::auto_ptr<FontList> aHold( new FontList( this )); + _pFontList = aHold.get(); + + if ( rCurrentFont.Name.getLength() > 0 ) + { + FontInfo _aFontInfo; + _aFontInfo.SetName( rCurrentFont.Name ); + _aFontInfo.SetStyleName( rCurrentFont.StyleName ); + _aFontInfo.SetHeight( rCurrentFont.Height ); + Fill( &_aFontInfo, _pFontList ); + } + else + { + Fill( NULL, _pFontList ); + } + SetValue( nOldVal ); // alten Wert wiederherstellen + m_aCurText = GetText(); // zum R"ucksetzen bei ESC merken +} + +// ----------------------------------------------------------------------- + +long SvxFontSizeBox_Impl::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = 0; + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); + + switch ( nCode ) + { + case KEY_RETURN: + case KEY_TAB: + { + if ( KEY_TAB == nCode ) + m_bRelease = FALSE; + else + nHandled = 1; + Select(); + break; + } + + case KEY_ESCAPE: + SetText( m_aCurText ); + ReleaseFocus_Impl(); + nHandled = 1; + break; + } + } + else if( EVENT_LOSEFOCUS == rNEvt.GetType() ) + { + Window* pFocusWin = Application::GetFocusWindow(); + if(!HasFocus() && GetSubEdit() != pFocusWin) + SetText(GetSavedValue()); + } + + return nHandled ? nHandled : FontSizeBox::Notify( rNEvt ); +} + +// --------------------------------------------------------------------------- + +void SvxFontSizeBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + SetSizePixel( LogicToPixel( m_aLogicalSize, MAP_APPFONT )); + Size aDropSize( m_aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT ); + SetDropDownSizePixel( LogicToPixel( aDropSize, MAP_APPFONT )); + } + + FontSizeBox::DataChanged( rDCEvt ); +} + +//======================================================================== +// class FontHeightToolBoxControl +//======================================================================== + +FontHeightToolBoxControl::FontHeightToolBoxControl( + const uno::Reference< lang::XMultiServiceFactory >& rServiceManager ) : + svt::ToolboxController( rServiceManager, + uno::Reference< frame::XFrame >(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontHeight" )) ), + m_pBox( NULL ) +{ + addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" ))); +} + +FontHeightToolBoxControl::~FontHeightToolBoxControl() +{ +} + +// XInterface +::com::sun::star::uno::Any SAL_CALL FontHeightToolBoxControl::queryInterface( const ::com::sun::star::uno::Type& aType ) +throw (::com::sun::star::uno::RuntimeException) +{ + uno::Any a = ToolboxController::queryInterface( aType ); + if ( a.hasValue() ) + return a; + + return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this )); +} + +void SAL_CALL FontHeightToolBoxControl::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL FontHeightToolBoxControl::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +sal_Bool SAL_CALL FontHeightToolBoxControl::supportsService( const ::rtl::OUString& ServiceName ) +throw(uno::RuntimeException) +{ + const uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return true; + + return false; +} + +::rtl::OUString SAL_CALL FontHeightToolBoxControl::getImplementationName() +throw( uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL FontHeightToolBoxControl::getSupportedServiceNames( ) +throw( uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +uno::Sequence< ::rtl::OUString > FontHeightToolBoxControl::getSupportedServiceNames_Static() +throw() +{ + uno::Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// XComponent +void SAL_CALL FontHeightToolBoxControl::dispose() +throw (uno::RuntimeException) +{ + svt::ToolboxController::dispose(); + + SolarMutexGuard aSolarMutexGuard; + delete m_pBox; + m_pBox = 0; +} + +// XStatusListener +void SAL_CALL FontHeightToolBoxControl::statusChanged( + const frame::FeatureStateEvent& rEvent ) +throw ( uno::RuntimeException ) +{ + if ( m_pBox ) + { + SolarMutexGuard aSolarMutexGuard; + if ( rEvent.FeatureURL.Path.equalsAscii( "FontHeight" )) + { + if ( rEvent.IsEnabled ) + { + m_pBox->Enable(); + frame::status::FontHeight aFontHeight; + if ( rEvent.State >>= aFontHeight ) + m_pBox->statusChanged_Impl( long( 10. * aFontHeight.Height ), false ); + else + m_pBox->statusChanged_Impl( long( -1 ), true ); + } + else + m_pBox->Disable(); + } + else if ( rEvent.FeatureURL.Path.equalsAscii( "CharFontName" )) + { + if ( rEvent.State >>= m_aCurrentFont ) + m_pBox->UpdateFont( m_aCurrentFont ); + } + } +} + +// XToolbarController +void SAL_CALL FontHeightToolBoxControl::execute( sal_Int16 /*KeyModifier*/ ) +throw (::com::sun::star::uno::RuntimeException) +{ +} + +void SAL_CALL FontHeightToolBoxControl::click() +throw (::com::sun::star::uno::RuntimeException) +{ +} + +void SAL_CALL FontHeightToolBoxControl::doubleClick() +throw (::com::sun::star::uno::RuntimeException) +{ +} + +uno::Reference< awt::XWindow > SAL_CALL FontHeightToolBoxControl::createPopupWindow() +throw (::com::sun::star::uno::RuntimeException) +{ + return uno::Reference< awt::XWindow >(); +} + +uno::Reference< awt::XWindow > SAL_CALL FontHeightToolBoxControl::createItemWindow( + const uno::Reference< awt::XWindow >& Parent ) + throw (::com::sun::star::uno::RuntimeException) +{ + uno::Reference< awt::XWindow > xItemWindow; + uno::Reference< awt::XWindow > xParent( Parent ); + + Window* pParent = VCLUnoHelper::GetWindow( xParent ); + if ( pParent ) + { + SolarMutexGuard aSolarMutexGuard; + m_pBox = new SvxFontSizeBox_Impl( + pParent, + uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), + m_xFrame, + *this ); + xItemWindow = VCLUnoHelper::GetInterface( m_pBox ); + } + + return xItemWindow; +} + +void FontHeightToolBoxControl::dispatchCommand( + const uno::Sequence< beans::PropertyValue >& rArgs ) +{ + uno::Reference< frame::XDispatchProvider > xDispatchProvider( m_xFrame, uno::UNO_QUERY ); + if ( xDispatchProvider.is() ) + { + util::URL aURL; + uno::Reference< frame::XDispatch > xDispatch; + uno::Reference< util::XURLTransformer > xURLTransformer = getURLTransformer(); + + aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontHeight" )); + xURLTransformer->parseStrict( aURL ); + xDispatch = xDispatchProvider->queryDispatch( aURL, ::rtl::OUString(), 0 ); + if ( xDispatch.is() ) + xDispatch->dispatch( aURL, rArgs ); + } +} + +uno::Reference< uno::XInterface > SAL_CALL FontHeightToolBoxControl_createInstance( + const uno::Reference< lang::XMultiServiceFactory >& rSMgr ) +{ + return *new FontHeightToolBoxControl( rSMgr ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx new file mode 100644 index 000000000000..c775a967c112 --- /dev/null +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -0,0 +1,876 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 "tbunosearchcontrollers.hxx" +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/util/URL.hpp> + +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> + +namespace svx +{ + +static const ::rtl::OUString SEARCHITEM_SEARCHSTRING( RTL_CONSTASCII_USTRINGPARAM( "SearchItem.SearchString" ) ); +static const ::rtl::OUString SEARCHITEM_SEARCHBACKWARD( RTL_CONSTASCII_USTRINGPARAM( "SearchItem.Backward" ) ); + +static const ::rtl::OUString COMMAND_EXECUTESEARCH( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExecuteSearch" ) ); +static const ::rtl::OUString COMMAND_FINDTEXT( RTL_CONSTASCII_USTRINGPARAM( ".uno:FindText" ) ); +static const ::rtl::OUString COMMAND_DOWNSEARCH( RTL_CONSTASCII_USTRINGPARAM(".uno:DownSearch") ); +static const ::rtl::OUString COMMAND_UPSEARCH( RTL_CONSTASCII_USTRINGPARAM(".uno:UpSearch") ); +static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY( RTL_CONSTASCII_USTRINGPARAM( "AppendSearchHistory") ); + +static const ::rtl::OUString SERVICENAME_URLTRANSFORMER( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer") ); +static const sal_Int32 REMEMBER_SIZE = 10; + +void impl_executeSearch( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr, const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Sequence< css::beans::PropertyValue >& lArgs ) +{ + css::uno::Reference< css::util::XURLTransformer > xURLTransformer( rSMgr->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY ); + if ( xURLTransformer.is() ) + { + css::util::URL aURL; + aURL.Complete = COMMAND_EXECUTESEARCH; + xURLTransformer->parseStrict(aURL); + + css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY); + if ( xDispatchProvider.is() ) + { + css::uno::Reference< css::frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, ::rtl::OUString(), 0 ); + if ( xDispatch.is() && aURL.Complete.getLength() > 0 ) + xDispatch->dispatch( aURL, lArgs ); + } + } +} + +FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle, + css::uno::Reference< css::frame::XFrame >& xFrame, + css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager) : + ComboBox( pParent, nStyle ), + m_xFrame(xFrame), + m_xServiceManager(xServiceManager), + m_bToClearTextField(sal_True) +{ + InitControls_Impl(); +} + +FindTextFieldControl::~FindTextFieldControl() +{ +} + +void FindTextFieldControl::InitControls_Impl() +{ + SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) ); + SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); + + EnableAutocomplete(TRUE, TRUE); +} + +void FindTextFieldControl::Remember_Impl(const String& rStr) +{ + USHORT nCount = GetEntryCount(); + + for (USHORT i=0; i<nCount; ++i) + { + if ( rStr == GetEntry(i)) + return; + } + + if (nCount == REMEMBER_SIZE) + RemoveEntry(REMEMBER_SIZE-1); + + InsertEntry(rStr, 0); +} + +void FindTextFieldControl::Modify() +{ + ComboBox::Modify(); + + SetControlForeground( GetSettings().GetStyleSettings().GetWindowTextColor() ); +} + +long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) +{ + long nRet= ComboBox::PreNotify( rNEvt ); + + switch ( rNEvt.GetType() ) + { + case EVENT_KEYINPUT: + { + const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); + sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1(); + sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2(); + sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift(); + sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); + + if ( (bCtrl && bAlt && KEY_F == nCode) || KEY_ESCAPE == nCode ) + { + nRet = 1; + GrabFocusToDocument(); + } + + if ( KEY_RETURN == nCode ) + { + Remember_Impl(GetText()); + + ::rtl::OUString sFindText = GetText(); + css::uno::Sequence< css::beans::PropertyValue > lArgs(2); + + lArgs[0].Name = SEARCHITEM_SEARCHSTRING; + lArgs[0].Value <<= sFindText; + + lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + if (bShift) + lArgs[1].Value <<= sal_True; + else + lArgs[1].Value <<= sal_False; + + impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + nRet = 1; + } + break; + } + + case EVENT_GETFOCUS: + if ( m_bToClearTextField ) + { + SetText( String() ); + m_bToClearTextField = sal_False; + } + SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); + break; + + case EVENT_LOSEFOCUS: + if ( GetText().Len() == 0 ) + { + SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) ); + SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor()); + m_bToClearTextField = sal_True; + } + break; + } + + return nRet; +} + + +//----------------------------------------------------------------------------------------------------------- +// SearchToolbarControllersManager + +SearchToolbarControllersManager* SearchToolbarControllersManager::m_pInstance = 0; + +SearchToolbarControllersManager::SearchToolbarControllersManager() +{ +} + +SearchToolbarControllersManager::~SearchToolbarControllersManager() +{ +} + +SearchToolbarControllersManager* SearchToolbarControllersManager::createControllersManager() +{ + if (!m_pInstance) + m_pInstance = new SearchToolbarControllersManager(); + + return m_pInstance; +} + +void SearchToolbarControllersManager::registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ) +{ + SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); + if (pIt == aSearchToolbarControllersMap.end()) + { + SearchToolbarControllersVec lControllers(1); + lControllers[0].Name = sCommandURL; + lControllers[0].Value <<= xStatusListener; + aSearchToolbarControllersMap.insert(SearchToolbarControllersMap::value_type(xFrame, lControllers)); + } + else + { + sal_Int32 nSize = pIt->second.size(); + for (sal_Int32 i=0; i<nSize; ++i) + { + if (pIt->second[i].Name.equals(sCommandURL)) + return; + } + + pIt->second.resize(nSize+1); + pIt->second[nSize].Name = sCommandURL; + pIt->second[nSize].Value <<= xStatusListener; + } +} + +void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& /*xStatusListener*/, const ::rtl::OUString& sCommandURL ) +{ + SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); + if (pIt != aSearchToolbarControllersMap.end()) + { + for (SearchToolbarControllersVec::iterator pItCtrl=pIt->second.begin(); pItCtrl!=pIt->second.end(); ++pItCtrl) + { + if (pItCtrl->Name.equals(sCommandURL)) + { + pIt->second.erase(pItCtrl); + break; + } + } + + if (pIt->second.empty()) + aSearchToolbarControllersMap.erase(pIt); + } +} + +css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManager::findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL ) +{ + css::uno::Reference< css::frame::XStatusListener > xStatusListener; + + SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); + if (pIt != aSearchToolbarControllersMap.end()) + { + for (SearchToolbarControllersVec::iterator pItCtrl =pIt->second.begin(); pItCtrl != pIt->second.end(); ++pItCtrl) + { + if (pItCtrl->Name.equals(sCommandURL)) + { + pItCtrl->Value >>= xStatusListener; + break; + } + } + } + + return xStatusListener; +} + +//----------------------------------------------------------------------------------------------------------- +// FindTextToolbarController + +FindTextToolbarController::FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) + :svt::ToolboxController( rServiceManager, + css::uno::Reference< css::frame::XFrame >(), + COMMAND_FINDTEXT ) +{ +} + +FindTextToolbarController::~FindTextToolbarController() +{ +} + +// XInterface +css::uno::Any SAL_CALL FindTextToolbarController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) +{ + css::uno::Any a = ToolboxController::queryInterface( aType ); + if ( a.hasValue() ) + return a; + + return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) ); +} + +void SAL_CALL FindTextToolbarController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL FindTextToolbarController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL FindTextToolbarController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL FindTextToolbarController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) +{ + const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return true; + + return false; +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL FindTextToolbarController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > FindTextToolbarController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) ); + return aSNS; +} + +// XComponent +void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + + SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + + svt::ToolboxController::dispose(); + delete m_pFindTextFieldControl; + m_pFindTextFieldControl = 0; +} + +// XInitialization +void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException) +{ + svt::ToolboxController::initialize(aArguments); + + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; i<nItemCount; ++i ) + { + ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); + if ( sItemCommand.equals( COMMAND_DOWNSEARCH ) ) + m_nDownSearchId = i; + else if (sItemCommand.equals( COMMAND_UPSEARCH )) + m_nUpSearchId = i; + } + } + + SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); +} + +// XToolbarController +void SAL_CALL FindTextToolbarController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) +{ +} + +css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException ) +{ + css::uno::Reference< css::awt::XWindow > xItemWindow; + + css::uno::Reference< css::awt::XWindow > xParent( Parent ); + Window* pParent = VCLUnoHelper::GetWindow( xParent ); + if ( pParent ) + { + ToolBox* pToolbar = ( ToolBox* )pParent; + m_pFindTextFieldControl = new FindTextFieldControl( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xServiceManager ); + + Size aSize(100, m_pFindTextFieldControl->GetTextHeight() + 200); + m_pFindTextFieldControl->SetSizePixel( aSize ); + m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, EditModifyHdl)); + } + xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl ); + + return xItemWindow; +} + +// XStatusListener +void SAL_CALL FindTextToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + if ( m_bDisposed ) + return; + + ::rtl::OUString aFeatureURL = rEvent.FeatureURL.Complete; + if (aFeatureURL.equalsAscii("AppendSearchHistory")) + { + m_pFindTextFieldControl->Remember_Impl(m_pFindTextFieldControl->GetText()); + } +} + +IMPL_LINK( FindTextToolbarController, EditModifyHdl, void *, EMPTYARG ) +{ + // enable or disable item DownSearch/UpSearch of findbar + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox && m_pFindTextFieldControl ) + { + if (m_pFindTextFieldControl->GetText().Len()>0) + { + if ( !pToolBox->IsItemEnabled(m_nDownSearchId) ) + pToolBox->EnableItem(m_nDownSearchId, sal_True); + if ( !pToolBox->IsItemEnabled(m_nUpSearchId) ) + pToolBox->EnableItem(m_nUpSearchId, sal_True); + } + else + { + if ( pToolBox->IsItemEnabled(m_nDownSearchId) ) + pToolBox->EnableItem(m_nDownSearchId, sal_False); + if ( pToolBox->IsItemEnabled(m_nUpSearchId) ) + pToolBox->EnableItem(m_nUpSearchId, sal_False); + } + } + + return 0; +} + +//----------------------------------------------------------------------------------------------------------- +// class DownSearchToolboxController + +DownSearchToolboxController::DownSearchToolboxController(const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) + : svt::ToolboxController( rServiceManager, + css::uno::Reference< css::frame::XFrame >(), + COMMAND_DOWNSEARCH ) +{ +} + +DownSearchToolboxController::~DownSearchToolboxController() +{ +} + +// XInterface +css::uno::Any SAL_CALL DownSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) +{ + css::uno::Any a = ToolboxController::queryInterface( aType ); + if ( a.hasValue() ) + return a; + + return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) ); +} + +void SAL_CALL DownSearchToolboxController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL DownSearchToolboxController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL DownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL DownSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) +{ + const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return true; + + return false; +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL DownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > DownSearchToolboxController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// XComponent +void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + + SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + + svt::ToolboxController::dispose(); +} + +// XInitialization +void SAL_CALL DownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) +{ + svt::ToolboxController::initialize( aArguments ); + SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); +} + +// XToolbarController +void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException) +{ + if ( m_bDisposed ) + throw css::lang::DisposedException(); + + ::rtl::OUString sFindText; + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; i<nItemCount; ++i ) + { + ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); + if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) + { + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + break; + } + } + } + + css::uno::Sequence< css::beans::PropertyValue > lArgs(2); + lArgs[0].Name = SEARCHITEM_SEARCHSTRING; + lArgs[0].Value <<= sFindText; + lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + lArgs[1].Value <<= sal_False; + + impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY; + css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + if (xStatusListener.is()) + xStatusListener->statusChanged( aEvent ); +} + +// XStatusListener +void SAL_CALL DownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + if ( m_bDisposed ) + return; +} + +//----------------------------------------------------------------------------------------------------------- +// class UpSearchToolboxController + +UpSearchToolboxController::UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ) + :svt::ToolboxController( rServiceManager, + css::uno::Reference< css::frame::XFrame >(), + COMMAND_UPSEARCH ) +{ +} + +UpSearchToolboxController::~UpSearchToolboxController() +{ +} + +// XInterface +css::uno::Any SAL_CALL UpSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) +{ + css::uno::Any a = ToolboxController::queryInterface( aType ); + if ( a.hasValue() ) + return a; + + return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) ); +} + +void SAL_CALL UpSearchToolboxController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL UpSearchToolboxController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL UpSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL UpSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) +{ + const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return true; + + return false; +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL UpSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > UpSearchToolboxController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) ); + return aSNS; +} + +// XComponent +void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + + SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + + svt::ToolboxController::dispose(); +} + +// XInitialization +void SAL_CALL UpSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) +{ + svt::ToolboxController::initialize( aArguments ); + SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); +} + +// XToolbarController +void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) +{ + if ( m_bDisposed ) + throw css::lang::DisposedException(); + + ::rtl::OUString sFindText; + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; i<nItemCount; ++i ) + { + ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); + if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) + { + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + break; + } + } + } + + css::uno::Sequence< css::beans::PropertyValue > lArgs(2); + lArgs[0].Name = SEARCHITEM_SEARCHSTRING; + lArgs[0].Value <<= sFindText; + lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + lArgs[1].Value <<= sal_True; + + impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY; + css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + if (xStatusListener.is()) + xStatusListener->statusChanged( aEvent ); +} + +// XStatusListener +void SAL_CALL UpSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + if ( m_bDisposed ) + return; +} + +//----------------------------------------------------------------------------------------------------------- +// class FindbarDispatcher + +FindbarDispatcher::FindbarDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory) + : m_xFactory( xFactory ) +{ +} + +FindbarDispatcher::~FindbarDispatcher() +{ + m_xFactory = NULL; + m_xFrame = NULL; +} + +// XInterface +css::uno::Any SAL_CALL FindbarDispatcher::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException ) +{ + css::uno::Any aReturn( ::cppu::queryInterface( aType, + static_cast< css::lang::XServiceInfo* >(this), + static_cast< css::lang::XInitialization* >(this), + static_cast< css::frame::XDispatchProvider* >(this), + static_cast< css::frame::XDispatch* >(this)) ); + + if ( aReturn.hasValue() ) + return aReturn; + + return OWeakObject::queryInterface( aType ); +} + +void SAL_CALL FindbarDispatcher::acquire() throw() +{ + OWeakObject::acquire(); +} + +void SAL_CALL FindbarDispatcher::release() throw() +{ + OWeakObject::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL FindbarDispatcher::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL FindbarDispatcher::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) +{ + return ( + ServiceName.equalsAscii("com.sun.star.comp.svx.FindbarDispatcher") || + ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler") + ); +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL FindbarDispatcher::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > FindbarDispatcher::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FindbarDispatcher" )); + aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ProtocolHandler" )); + return aSNS; +} + +// XInitialization +void SAL_CALL FindbarDispatcher::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) +{ + if ( aArguments.getLength() ) + aArguments[0] >>= m_xFrame; +} + +// XDispatchProvider +css::uno::Reference< css::frame::XDispatch > SAL_CALL FindbarDispatcher::queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& /*sTargetFrameName*/, sal_Int32 /*nSearchFlags*/ ) throw( css::uno::RuntimeException ) +{ + css::uno::Reference< css::frame::XDispatch > xDispatch; + + if ( aURL.Protocol.equalsAscii("vnd.sun.star.findbar:") ) + xDispatch = this; + + return xDispatch; +} + +css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL FindbarDispatcher::queryDispatches( const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescripts ) throw( css::uno::RuntimeException ) +{ + sal_Int32 nCount = seqDescripts.getLength(); + css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount ); + + for( sal_Int32 i=0; i<nCount; ++i ) + lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags ); + + return lDispatcher; +} + +// XDispatch +void SAL_CALL FindbarDispatcher::dispatch( const css::util::URL& aURL, const css::uno::Sequence < css::beans::PropertyValue >& /*lArgs*/ ) throw( css::uno::RuntimeException ) +{ + //vnd.sun.star.findbar:FocusToFindbar - set cursor to the FindTextFieldControl of the findbar + if ( aURL.Path.equalsAscii("FocusToFindbar") ) + { + css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY); + if(!xPropSet.is()) + return; + + css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; + css::uno::Any aValue = xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )) ); + aValue >>= xLayoutManager; + if (!xLayoutManager.is()) + return; + + const ::rtl::OUString sResourceURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/findbar" )); + css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL); + if (!xUIElement.is()) + return; + + css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY); + Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; i<nItemCount; ++i ) + { + ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); + if ( sItemCommand.equalsAscii(".uno:FindText") ) + { + Window* pItemWin = pToolBox->GetItemWindow( i ); + if ( pItemWin ) + { + pItemWin->GrabFocus(); + return; + } + } + } + } + + } +} + +void SAL_CALL FindbarDispatcher::addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException ) +{ +} + +void SAL_CALL FindbarDispatcher::removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException ) +{ +} + +//----------------------------------------------------------------------------------------------------------- +// create Instance + +css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new FindTextToolbarController( rSMgr ); +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new DownSearchToolboxController( rSMgr ); +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new UpSearchToolboxController( rSMgr ); +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new FindbarDispatcher( rSMgr ); +} + +//----------------------------------------------------------------------------------------------------------- +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.src b/svx/source/tbxctrls/tbunosearchcontrollers.src new file mode 100644 index 000000000000..9a256ae0cabb --- /dev/null +++ b/svx/source/tbxctrls/tbunosearchcontrollers.src @@ -0,0 +1,33 @@ +/************************************************************************* + * + * 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> + +String RID_SVXSTR_FINDBAR_FIND +{ + Text [ en-US ] = "Find" ; +}; diff --git a/svx/source/tbxctrls/tbxalign.cxx b/svx/source/tbxctrls/tbxalign.cxx new file mode 100644 index 000000000000..a4d528a70eca --- /dev/null +++ b/svx/source/tbxctrls/tbxalign.cxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 <svl/aeitem.hxx> + +#include <svx/dialmgr.hxx> +#include <svx/dialogs.hrc> + +#include "tbxalign.hxx" +#include "tbxdraw.hxx" +#include "tbxdraw.hrc" +#include <tools/shl.hxx> +#include <sfx2/imagemgr.hxx> +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> + +#include <sfx2/app.hxx> +#include <vcl/toolbox.hxx> + +SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign, SfxAllEnumItem); + +/************************************************************************* +|* +|* Klasse fuer SwToolbox +|* +\************************************************************************/ + +SvxTbxCtlAlign::SvxTbxCtlAlign( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) + , m_aSubTbName( RTL_CONSTASCII_USTRINGPARAM( "alignmentbar" )) + , m_aSubTbResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/alignmentbar" )) +{ + rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); + + m_aCommand = m_aCommandURL; +} + +/************************************************************************* +|* +|* Wenn man ein PopupWindow erzeugen will +|* +\************************************************************************/ + +SfxPopupWindowType SvxTbxCtlAlign::GetPopupWindowType() const +{ + return(SFX_POPUPWINDOW_ONCLICK); +} + +/************************************************************************* +|* +|* Hier wird das Fenster erzeugt +|* Lage der Toolbox mit GetToolBox() abfragbar +|* rItemRect sind die Screen-Koordinaten +|* +\************************************************************************/ + +SfxPopupWindow* SvxTbxCtlAlign::CreatePopupWindow() +{ + SolarMutexGuard aGuard; + if ( GetSlotId() == SID_OBJECT_ALIGN ) + createAndPositionSubToolBar( m_aSubTbResName ); + return NULL; +} + +//======================================================================== +// XSubToolbarController +//======================================================================== + +::sal_Bool SAL_CALL SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException) +{ + // We control a sub-toolbar therefor, we have to return true. + return sal_True; +} + +::rtl::OUString SAL_CALL SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException) +{ + // Provide the controlled sub-toolbar name, so we are notified whenever + // this toolbar executes a function. + SolarMutexGuard aGuard; + return m_aSubTbName; +} + +void SAL_CALL SvxTbxCtlAlign::functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException) +{ + // Our sub-toolbar wants to executes a function. We have to change + // the image of our toolbar button to reflect the new function. + SolarMutexGuard aGuard; + if ( !m_bDisposed ) + { + if ( aCommand.getLength() > 0 ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface()); + Image aImage = GetImage( xFrame, aCommand, hasBigImages() ); + if ( !!aImage ) + GetToolBox().SetItemImage( GetId(), aImage ); + } + } +} + +void SAL_CALL SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException) +{ + // We should update the button image of our parent (toolbar). Use the stored + // command to set the correct current image. + SolarMutexGuard aGuard; + if ( m_aCommand.getLength() > 0 ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface()); + Image aImage = GetImage( xFrame, m_aCommand, hasBigImages() ); + if ( !!aImage ) + GetToolBox().SetItemImage( GetId(), aImage ); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbxcolor.cxx b/svx/source/tbxctrls/tbxcolor.cxx new file mode 100644 index 000000000000..ad25cd08a029 --- /dev/null +++ b/svx/source/tbxctrls/tbxcolor.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 "tbxcolor.hxx" +#include <sfx2/viewfrm.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +//........................................................................ +namespace svx +{ +//........................................................................ + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::frame; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::frame; + + #define DECLARE_ASCII(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) + #define TOOLBAR_RESNAME DECLARE_ASCII("private:resource/toolbar/") + #define PROPNAME_LAYOUTMANAGER DECLARE_ASCII("LayoutManager") + + //==================================================================== + //= ToolboxAccess + //==================================================================== + ToolboxAccess::ToolboxAccess( const ::rtl::OUString& rToolboxName ) : + + m_bDocking ( false ), + m_sToolboxResName ( TOOLBAR_RESNAME ) + + { + m_sToolboxResName += rToolboxName; + + // the layout manager + if ( SfxViewFrame::Current() ) + { + try + { + Reference< XFrame > xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + Reference< XPropertySet > xFrameProps( xFrame, UNO_QUERY ); + if ( xFrameProps.is() ) + xFrameProps->getPropertyValue( PROPNAME_LAYOUTMANAGER ) >>= m_xLayouter; + } + catch ( Exception& ) + { + DBG_ERRORFILE( "ToolboxAccess::Ctor(): exception" ); + } + } + } + + //-------------------------------------------------------------------- + void ToolboxAccess::toggleToolbox() const + { + try + { + Reference< XLayoutManager > xManager( m_xLayouter ); + OSL_ENSURE( xManager. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" ); + if ( xManager. is() ) + { + if ( xManager->isElementVisible( m_sToolboxResName ) ) + { + xManager->hideElement( m_sToolboxResName ); + xManager->destroyElement( m_sToolboxResName ); + } + else + { + xManager->createElement( m_sToolboxResName ); + xManager->showElement( m_sToolboxResName ); + ::com::sun::star::awt::Point aPos; + + if ( m_bDocking ) + xManager->dockWindow( m_sToolboxResName, + ::com::sun::star::ui::DockingArea_DOCKINGAREA_BOTTOM, aPos ); + } + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "ToolboxAccess::toggleToolbox: caught an exception!" ); + } + } + + //-------------------------------------------------------------------- + bool ToolboxAccess::isToolboxVisible() const + { + return ( m_xLayouter.is() && m_xLayouter->isElementVisible( m_sToolboxResName ) ); + } + +//........................................................................ +} // namespace svx +//........................................................................ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx new file mode 100644 index 000000000000..bfe372530503 --- /dev/null +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -0,0 +1,211 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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/tbxcolorupdate.hxx> +#include <svx/svxids.hrc> + +#include <vcl/toolbox.hxx> +#include <vcl/bmpacc.hxx> +#include <tools/debug.hxx> + +#define IMAGE_COL_TRANSPARENT COL_LIGHTMAGENTA + +//........................................................................ +namespace svx +{ +//........................................................................ + + //==================================================================== + //= ToolboxButtonColorUpdater + //==================================================================== + + ToolboxButtonColorUpdater::ToolboxButtonColorUpdater( + USHORT nId, + USHORT nTbxBtnId, + ToolBox* ptrTbx, + USHORT nMode ) : + mnDrawMode ( nMode ), + mnBtnId ( nTbxBtnId ), + mnSlotId ( nId ), + mpTbx ( ptrTbx ), + maCurColor ( COL_TRANSPARENT ) + { + if (mnSlotId == SID_BACKGROUND_COLOR) + mnDrawMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW; + DBG_ASSERT( ptrTbx, "ToolBox not found :-(" ); + mbWasHiContrastMode = ptrTbx ? ( ptrTbx->GetSettings().GetStyleSettings().GetHighContrastMode() ) : FALSE; + Update(mnSlotId == SID_ATTR_CHAR_COLOR2 ? COL_BLACK : COL_GRAY); + } + + // ----------------------------------------------------------------------- + + ToolboxButtonColorUpdater::~ToolboxButtonColorUpdater() + { + } + + // ----------------------------------------------------------------------- + + void ToolboxButtonColorUpdater::Update( const Color& rColor ) + { + Image aImage( mpTbx->GetItemImage( mnBtnId ) ); + const bool bSizeChanged = ( maBmpSize != aImage.GetSizePixel() ); + const bool bDisplayModeChanged = ( mbWasHiContrastMode != mpTbx->GetSettings().GetStyleSettings().GetHighContrastMode() ); + Color aColor( rColor ); + + // !!! #109290# Workaround for SetFillColor with COL_AUTO + if( aColor.GetColor() == COL_AUTO ) + aColor = Color( COL_TRANSPARENT ); + + if( ( maCurColor != aColor ) || bSizeChanged || bDisplayModeChanged ) + { + BitmapEx aBmpEx( aImage.GetBitmapEx() ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess(); + + maBmpSize = aBmp.GetSizePixel(); + + if( pBmpAcc ) + { + Bitmap aMsk; + BitmapWriteAccess* pMskAcc; + const Point aNullPnt; + + if( aBmpEx.IsAlpha() ) + pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess(); + else if( aBmpEx.IsTransparent() ) + pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess(); + else + pMskAcc = NULL; + + mbWasHiContrastMode = mpTbx->GetSettings().GetStyleSettings().GetHighContrastMode(); + + if( mnDrawMode == TBX_UPDATER_MODE_CHAR_COLOR_NEW && ( COL_TRANSPARENT != aColor.GetColor() ) ) + pBmpAcc->SetLineColor( aColor ); + else if( mpTbx->GetBackground().GetColor().IsDark() ) + pBmpAcc->SetLineColor( Color( COL_WHITE ) ); + else + pBmpAcc->SetLineColor( Color( COL_BLACK ) ); + + pBmpAcc->SetFillColor( maCurColor = aColor ); + + if( TBX_UPDATER_MODE_CHAR_COLOR_NEW == mnDrawMode || TBX_UPDATER_MODE_NONE == mnDrawMode ) + { + if( TBX_UPDATER_MODE_CHAR_COLOR_NEW == mnDrawMode ) + { + if( maBmpSize.Width() <= 16 ) + maUpdRect = Rectangle( Point( 0,12 ), Size( maBmpSize.Width(), 4 ) ); + else + maUpdRect = Rectangle( Point( 1, maBmpSize.Height() - 7 ), Size( maBmpSize.Width() - 2 ,6 ) ); + } + else + { + if( maBmpSize.Width() <= 16 ) + maUpdRect = Rectangle( Point( 7, 7 ), Size( 8, 8 ) ); + else + maUpdRect = Rectangle( Point( maBmpSize.Width() - 12, maBmpSize.Height() - 12 ), Size( 11, 11 ) ); + } + + pBmpAcc->DrawRect( maUpdRect ); + + if( pMskAcc ) + { + if( COL_TRANSPARENT == aColor.GetColor() ) + { + pMskAcc->SetLineColor( COL_BLACK ); + pMskAcc->SetFillColor( COL_WHITE ); + } + else + pMskAcc->SetFillColor( COL_BLACK ); + + pMskAcc->DrawRect( maUpdRect ); + } + } + else + { + DBG_ERROR( "ToolboxButtonColorUpdater::Update: TBX_UPDATER_MODE_CHAR_COLOR / TBX_UPDATER_MODE_CHAR_BACKGROUND" ); + // !!! DrawChar( aVirDev, aColor ); + } + + aBmp.ReleaseAccess( pBmpAcc ); + + if( pMskAcc ) + aMsk.ReleaseAccess( pMskAcc ); + + if( aBmpEx.IsAlpha() ) + aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) ); + else if( aBmpEx.IsTransparent() ) + aBmpEx = BitmapEx( aBmp, aMsk ); + else + aBmpEx = aBmp; + + mpTbx->SetItemImage( mnBtnId, Image( aBmpEx ) ); + } + } + } + + // ----------------------------------------------------------------------- + + void ToolboxButtonColorUpdater::DrawChar( VirtualDevice& rVirDev, const Color& rCol ) + { + Font aOldFont = rVirDev.GetFont(); + Font aFont = aOldFont; + Size aSz = aFont.GetSize(); + aSz.Height() = maBmpSize.Height(); + aFont.SetSize( aSz ); + aFont.SetWeight( WEIGHT_BOLD ); + + if ( mnDrawMode == TBX_UPDATER_MODE_CHAR_COLOR ) + { + aFont.SetColor( rCol ); + aFont.SetFillColor( Color( IMAGE_COL_TRANSPARENT ) ); + } + else + { + rVirDev.SetLineColor(); + rVirDev.SetFillColor( rCol ); + Rectangle aRect( Point(0,0), maBmpSize ); + rVirDev.DrawRect( aRect ); + aFont.SetFillColor( rCol ); + } + rVirDev.SetFont( aFont ); + Size aTxtSize(rVirDev.GetTextWidth( 'A' ), rVirDev.GetTextHeight()); + Point aPos( ( maBmpSize.Width() - aTxtSize.Width() ) / 2, + ( maBmpSize.Height() - aTxtSize.Height() ) / 2 ); + + rVirDev.DrawText( aPos, 'A' ); + rVirDev.SetFont( aOldFont ); + } + +//........................................................................ +} // namespace svx +//........................................................................ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbxdraw.hrc b/svx/source/tbxctrls/tbxdraw.hrc new file mode 100644 index 000000000000..e7d687468118 --- /dev/null +++ b/svx/source/tbxctrls/tbxdraw.hrc @@ -0,0 +1,31 @@ +/************************************************************************* + * + * 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> +#include <svx/svxids.hrc> + +#define TBX_DRAW 1 +#define TBX_ALIGNMENT SID_OBJECT_ALIGN_LEFT diff --git a/svx/source/tbxctrls/tbxdraw.src b/svx/source/tbxctrls/tbxdraw.src new file mode 100644 index 000000000000..0641ff39e1bf --- /dev/null +++ b/svx/source/tbxctrls/tbxdraw.src @@ -0,0 +1,265 @@ +/************************************************************************* + * + * 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 --------------------------------------------------------------- +#include "tbxdraw.hrc" +#include <svx/dialogs.hrc> +#include "helpid.hrc" +#include <svx/svxids.hrc> + // pragma ---------------------------------------------------------------- + + // ----------------------------------------------------------------------- +#define IMAGE_STDBTN_COLOR Color { Red = 0xC000; Green = 0xC000; Blue = 0xC000; } +FloatingWindow RID_SVXTBX_DRAW +{ + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE ; + SVLook = TRUE ; + HelpID = HID_DRAWTOOL_TBX ; + ToolBox TBX_DRAW + { + HelpId = HID_SVXTBX_DRAW ; + SVLook = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_OBJECT_SELECT ; + HelpID = SID_OBJECT_SELECT ; + RadioCheck = TRUE ; + Text [ en-US ] = "Selection" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_LINE ; + HelpID = SID_DRAW_LINE ; + RadioCheck = TRUE ; + Text [ en-US ] = "Line" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_RECT ; + HelpID = SID_DRAW_RECT ; + RadioCheck = TRUE ; + Text [ en-US ] = "Rectangle" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_ELLIPSE ; + HelpID = SID_DRAW_ELLIPSE ; + RadioCheck = TRUE ; + Text [ en-US ] = "Ellipse" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_POLYGON_NOFILL ; + HelpID = SID_DRAW_POLYGON_NOFILL ; + RadioCheck = TRUE ; + Text [ en-US ] = "Polygon" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_BEZIER_NOFILL ; + HelpID = SID_DRAW_BEZIER_NOFILL ; + RadioCheck = TRUE ; + Text [ en-US ] = "Curve"; + }; + ToolBoxItem + { + Identifier = SID_DRAW_FREELINE_NOFILL ; + HelpID = SID_DRAW_FREELINE_NOFILL ; + RadioCheck = TRUE ; + Text [ en-US ] = "Freeform Line"; + }; + ToolBoxItem + { + Identifier = SID_DRAW_ARC ; + HelpID = SID_DRAW_ARC ; + RadioCheck = TRUE ; + Text [ en-US ] = "Arc" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_PIE ; + HelpID = SID_DRAW_PIE ; + RadioCheck = TRUE ; + Text [ en-US ] = "Ellipse Pie" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_CIRCLECUT ; + HelpID = SID_DRAW_CIRCLECUT ; + RadioCheck = TRUE ; + Text [ en-US ] = "Circle Segment" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_TEXT ; + HelpID = SID_DRAW_TEXT ; + RadioCheck = TRUE ; + Text [ en-US ] = "Text" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_TEXT_VERTICAL ; + HelpID = SID_DRAW_TEXT_VERTICAL ; + RadioCheck = TRUE ; + Text [ en-US ] = "Vertical Text"; + }; + ToolBoxItem + { + Identifier = SID_DRAW_TEXT_MARQUEE ; + HelpID = SID_DRAW_TEXT_MARQUEE ; + RadioCheck = TRUE ; + Text [ en-US ] = "Text Animation" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_CAPTION ; + HelpID = SID_DRAW_CAPTION ; + RadioCheck = TRUE ; + Text [ en-US ] = "Callouts" ; + }; + ToolBoxItem + { + Identifier = SID_DRAW_CAPTION_VERTICAL ; + HelpID = SID_DRAW_CAPTION_VERTICAL ; + RadioCheck = TRUE ; + Text [ en-US ] = "Vertical Callout"; + }; + }; + }; + Text [ en-US ] = "Draw Functions" ; +}; +FloatingWindow RID_SVXTBX_ALIGNMENT +{ + Moveable = TRUE ; + Closeable = TRUE ; + Hide = TRUE ; + HelpID = HID_ALIGN_TBX ; + SVLook = TRUE ; + Text [ en-US ] = "Alignment" ; + ToolBox TBX_ALIGNMENT + { + HelpId = HID_SVXTBX_ALIGNMENT ; + SVLook = TRUE ; + HelpID = SID_OBJECT_ALIGN ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN_LEFT ; + HelpID = SID_OBJECT_ALIGN_LEFT ; + Text [ en-US ] = "Left" ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN_CENTER ; + HelpID = SID_OBJECT_ALIGN_CENTER ; + Text [ en-US ] = "Center" ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN_RIGHT ; + HelpID = SID_OBJECT_ALIGN_RIGHT ; + Text [ en-US ] = "Right" ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN_UP ; + HelpID = SID_OBJECT_ALIGN_UP ; + Text [ en-US ] = "Top" ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN_MIDDLE ; + HelpID = SID_OBJECT_ALIGN_MIDDLE ; + Text [ en-US ] = "Centered" ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN_DOWN ; + HelpID = SID_OBJECT_ALIGN_DOWN ; + Text [ en-US ] = "Bottom" ; + }; + }; + }; +}; + // ********************************************************************** EOF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/svx/source/tbxctrls/tbxdrctl.cxx b/svx/source/tbxctrls/tbxdrctl.cxx new file mode 100644 index 000000000000..a64810196af1 --- /dev/null +++ b/svx/source/tbxctrls/tbxdrctl.cxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 headers + +#include <tools/ref.hxx> +#include <tools/shl.hxx> +#include <svl/aeitem.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewsh.hxx> +#include <sfx2/imagemgr.hxx> +#include <sfx2/viewfrm.hxx> +#include <vcl/toolbox.hxx> + +#include <svx/dialmgr.hxx> +#include <svx/dialogs.hrc> + +#include "tbxctl.hxx" +#include "tbxdraw.hxx" +#include "tbxcolor.hxx" +#include "tbxdraw.hrc" +#include <com/sun/star/frame/XLayoutManager.hpp> + +SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxAllEnumItem); + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; + +// ----------------------------------------------------------------------- + +SvxTbxCtlDraw::SvxTbxCtlDraw( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + + SfxToolBoxControl( nSlotId, nId, rTbx ), + + m_sToolboxName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/drawbar" ) ) + +{ + rTbx.SetItemBits( nId, TIB_CHECKABLE | rTbx.GetItemBits( nId ) ); + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------- + +void SvxTbxCtlDraw::StateChanged( USHORT nSID, SfxItemState eState, + const SfxPoolItem* pState ) +{ + GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) ); + SfxToolBoxControl::StateChanged( nSID, eState, pState ); + + Reference< XLayoutManager > xLayoutMgr = getLayoutManager(); + if ( xLayoutMgr.is() ) + GetToolBox().CheckItem( + GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) != sal_False ); +} + +// ----------------------------------------------------------------------- + +SfxPopupWindowType SvxTbxCtlDraw::GetPopupWindowType() const +{ + return SFX_POPUPWINDOW_ONCLICK; +} + +// ----------------------------------------------------------------------- + +void SvxTbxCtlDraw::toggleToolbox() +{ + Reference< XLayoutManager > xLayoutMgr = getLayoutManager(); + if ( xLayoutMgr.is() ) + { + BOOL bCheck = FALSE; + if ( xLayoutMgr->isElementVisible( m_sToolboxName ) ) + { + xLayoutMgr->hideElement( m_sToolboxName ); + xLayoutMgr->destroyElement( m_sToolboxName ); + } + else + { + bCheck = TRUE; + xLayoutMgr->createElement( m_sToolboxName ); + xLayoutMgr->showElement( m_sToolboxName ); + } + + GetToolBox().CheckItem( GetId(), bCheck ); + } +} + +// ----------------------------------------------------------------------- + +void SvxTbxCtlDraw::Select( BOOL ) +{ + toggleToolbox(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/verttexttbxctrl.cxx b/svx/source/tbxctrls/verttexttbxctrl.cxx new file mode 100644 index 000000000000..1f43c5c0f4d1 --- /dev/null +++ b/svx/source/tbxctrls/verttexttbxctrl.cxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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/dialmgr.hxx> +#include <svx/dialogs.hrc> +#include <verttexttbxctrl.hxx> +#include <svl/languageoptions.hxx> +#include <sfx2/app.hxx> +#include <svl/eitem.hxx> +#include <vcl/toolbox.hxx> +#include <rtl/ustring.hxx> + +SFX_IMPL_TOOLBOX_CONTROL(SvxCTLTextTbxCtrl, SfxBoolItem); +SFX_IMPL_TOOLBOX_CONTROL(SvxVertTextTbxCtrl, SfxBoolItem); + +SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx ) +{ + SetVert(FALSE); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CTLFontState" ))); +} + +SvxVertTextTbxCtrl::SvxVertTextTbxCtrl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx ) +{ + SetVert(TRUE); + addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:VerticalTextState" ))); +} + +/* ---------------------------------------------------------------------------*/ +SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ), + bCheckVertical(sal_True) +{ +} + +SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( ) +{ +} + +void SvxVertCTLTextTbxCtrl::StateChanged( + USHORT nSID, + SfxItemState eState, + const SfxPoolItem* pState ) +{ + SvtLanguageOptions aLangOptions; + BOOL bCalc = sal_False; + BOOL bVisible = GetToolBox().IsItemVisible(GetId()); + sal_Bool bEnabled = sal_False; + if ( nSID == SID_VERTICALTEXT_STATE ) + bEnabled = aLangOptions.IsVerticalTextEnabled(); + else if ( nSID == SID_CTLFONT_STATE ) + bEnabled = aLangOptions.IsCTLFontEnabled(); + else + { + SfxToolBoxControl::StateChanged(nSID, eState, pState); + return; + } + + if(bEnabled) + { + if(!bVisible) + { + GetToolBox().ShowItem( GetId(), TRUE ); + bCalc = sal_True; + } + } + else if(bVisible) + { + GetToolBox().HideItem( GetId() ); + bCalc = sal_True; + } + if(bCalc) + { + ToolBox& rTbx = GetToolBox(); + Window* pParent = rTbx.GetParent(); + WindowType nWinType = pParent->GetType(); + if(WINDOW_FLOATINGWINDOW == nWinType) + { + Size aSize(rTbx.CalcWindowSizePixel()); + rTbx.SetPosSizePixel( Point(), aSize ); + pParent->SetOutputSizePixel( aSize ); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |