diff -uNr old/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu new/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu --- old/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu 2008-03-07 23:03:00.000000000 +0800 +++ new/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu 2008-07-01 13:35:14.000000000 +0800 @@ -218,6 +218,11 @@ Margins + + + Scaling Factor + + Close Preview diff -uNr old/sc/inc/sc.hrc new/sc/inc/sc.hrc --- old/sc/inc/sc.hrc 2008-03-11 18:43:02.000000000 +0800 +++ new/sc/inc/sc.hrc 2008-07-01 13:35:54.000000000 +0800 @@ -919,7 +919,8 @@ #define SID_PREVIEW_ZOOMIN (SID_PREVIEW_START+5) #define SID_PREVIEW_ZOOMOUT (SID_PREVIEW_START+6) #define SID_PREVIEW_CLOSE (SID_PREVIEW_START+7) -#define SID_PREVIEW_MARGIN (SID_PREVIEW_START+8) +#define SID_PREVIEW_MARGIN (SID_PREVIEW_START+8) +#define SID_PREVIEW_SCALINGFACTOR (SID_PREVIEW_START+9) #define SID_PREVIEW_END (SID_PREVIEW_START+20) //aus sfx: #define SID_KEYFUNC_START (SID_PREVIEW_END+5) diff -uNr old/sc/sdi/prevwsh.sdi new/sc/sdi/prevwsh.sdi --- old/sc/sdi/prevwsh.sdi 2008-02-14 18:18:00.000000000 +0800 +++ new/sc/sdi/prevwsh.sdi 2008-07-01 13:36:26.000000000 +0800 @@ -46,7 +46,8 @@ SID_PREVIEW_PREVIOUS [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SID_PREVIEW_FIRST [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SID_PREVIEW_LAST [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] - SID_PREVIEW_MARGIN [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_PREVIEW_MARGIN [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_PREVIEW_SCALINGFACTOR [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SfxVoidItem GoUpBlock SID_CURSORPAGEUP ( diff -uNr old/sc/sdi/scalc.sdi new/sc/sdi/scalc.sdi --- old/sc/sdi/scalc.sdi 2008-03-07 23:10:24.000000000 +0800 +++ new/sc/sdi/scalc.sdi 2008-07-01 13:36:38.000000000 +0800 @@ -7630,6 +7630,30 @@ ] //-------------------------------------------------------------------------- +SvxZoomSliderItem ScalingFactor SID_PREVIEW_SCALINGFACTOR +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = TRUE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_FORMAT; +] + +//-------------------------------------------------------------------------- SfxVoidItem SelectTables SID_SELECT_TABLES (SfxIntegerListItem Tables SID_SELECT_TABLES) [ diff -uNr old/sc/source/ui/app/scdll.cxx new/sc/source/ui/app/scdll.cxx --- old/sc/source/ui/app/scdll.cxx 2008-02-06 02:41:52.000000000 +0800 +++ new/sc/source/ui/app/scdll.cxx 2008-07-01 13:37:08.000000000 +0800 @@ -126,7 +126,7 @@ #endif #include #include "tbinsert.hxx" - +#include "tbzoomsliderctrl.hxx" #include // Child-Windows #include "reffact.hxx" @@ -234,6 +234,7 @@ ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSERT, pMod); ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSCELLS, pMod); ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSOBJ, pMod); + ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod); // Svx-Toolbox-Controller SvxTbxCtlDraw ::RegisterControl(SID_INSERT_DRAW, pMod); diff -uNr old/sc/source/ui/app/typemap.cxx new/sc/source/ui/app/typemap.cxx --- old/sc/source/ui/app/typemap.cxx 2007-05-13 16:26:58.000000000 +0800 +++ new/sc/source/ui/app/typemap.cxx 2008-05-07 16:18:56.000000000 +0800 @@ -40,7 +40,9 @@ #include #include "sc.hrc" #include "scitems.hxx" - +#ifndef _SVX_ZOOMSLIDERITEM_HXX +#include +#endif #define ITEMID_DBTYPE 0 diff -uNr old/sc/source/ui/cctrl/makefile.mk new/sc/source/ui/cctrl/makefile.mk --- old/sc/source/ui/cctrl/makefile.mk 2008-03-07 23:10:50.000000000 +0800 +++ new/sc/source/ui/cctrl/makefile.mk 2008-05-07 13:35:44.000000000 +0800 @@ -52,13 +52,15 @@ $(SLO)$/popmenu.obj \ $(SLO)$/tbinsert.obj \ $(SLO)$/cbuttonw.obj \ - $(SLO)$/editfield.obj + $(SLO)$/editfield.obj \ + $(SLO)$/tbzoomsliderctrl.obj LIB1TARGET=$(SLB)$/$(TARGET).lib LIB1OBJFILES= \ $(SLO)$/popmenu.obj \ $(SLO)$/tbinsert.obj \ - $(SLO)$/cbuttonw.obj + $(SLO)$/cbuttonw.obj \ + $(SLO)$/tbzoomsliderctrl.obj # --- Tagets ------------------------------------------------------- diff -uNr old/sc/source/ui/cctrl/tbzoomsliderctrl.cxx new/sc/source/ui/cctrl/tbzoomsliderctrl.cxx --- old/sc/source/ui/cctrl/tbzoomsliderctrl.cxx 1970-01-01 08:00:00.000000000 +0800 +++ new/sc/source/ui/cctrl/tbzoomsliderctrl.cxx 2008-07-01 13:49:30.000000000 +0800 @@ -0,0 +1,558 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: tbzoomsliderctrl.cxx,v $ +* +* $Revision: 1.1 $ +* +* last change: $Author: maoyg $ $Date: 2008/04/25 10:08:08 $ +* +* The Contents of this file are made available subject to +* the terms of GNU Lesser General Public License Version 2.1. +* +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2005 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library 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 for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +************************************************************************/ +#include "precompiled_sc.hxx" +#ifndef _SC_ZOOMSLIDERTBCONTRL_HXX +#include "tbzoomsliderctrl.hxx" +#endif +#ifndef _SV_IMAGE_HXX +#include +#endif +#ifndef _SV_TOOLBOX_HXX +#include +#endif +#ifndef _SV_SVAPP_HXX +#include +#endif +#ifndef _SV_GRADIENT_HXX +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include "docsh.hxx" +#include "stlpool.hxx" +#include "scitems.hxx" +#include "printfun.hxx" + +//======================================================================== +// class ScZoomSliderControl --------------------------------------- +//======================================================================== + +// ----------------------------------------------------------------------- + +SFX_IMPL_TOOLBOX_CONTROL( ScZoomSliderControl, SvxZoomSliderItem ); + +// ----------------------------------------------------------------------- + +ScZoomSliderControl::ScZoomSliderControl( + USHORT nSlotId, + USHORT nId, + ToolBox& rTbx ) + :SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------- + +__EXPORT ScZoomSliderControl::~ScZoomSliderControl() +{ + +} + +// ----------------------------------------------------------------------- + +void ScZoomSliderControl::StateChanged( USHORT /*nSID*/, SfxItemState eState, + const SfxPoolItem* pState ) +{ + USHORT nId = GetId(); + ToolBox& rTbx = GetToolBox(); + ScZoomSliderWnd* pBox = (ScZoomSliderWnd*)(rTbx.GetItemWindow( nId )); + DBG_ASSERT( pBox ,"Control not found!" ); + + if ( SFX_ITEM_AVAILABLE != eState || pState->ISA( SfxVoidItem ) ) + { + SvxZoomSliderItem aZoomSliderItem( 100 ); + pBox->Disable(); + pBox->Update( &aZoomSliderItem ); + } + else + { + pBox->Enable(); + DBG_ASSERT( pState->ISA( SvxZoomSliderItem ), "invalid item type" ); + const SvxZoomSliderItem* pZoomSliderItem = dynamic_cast< const SvxZoomSliderItem* >( pState ); + + DBG_ASSERT( pZoomSliderItem, "Sc::ScZoomSliderControl::StateChanged(), wrong item type!" ); + if( pZoomSliderItem ) + pBox->Update( pZoomSliderItem ); + } +} + +// ----------------------------------------------------------------------- + +Window* ScZoomSliderControl::CreateItemWindow( Window *pParent ) +{ + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + ScDocShell* pDocShell = (ScDocShell*)pViewFrame->GetObjectShell(); + SCTAB nTab = ScDocShell::GetCurTab(); + ScDocument* pDoc = pDocShell->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ); + USHORT nCurrentZoom = 0; + if ( pStyleSheet ) + { + SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); + nCurrentZoom = ((const SfxUInt16Item&)rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue(); + } + ScZoomSliderWnd* pSlider = new ScZoomSliderWnd( pParent, + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >( m_xFrame->getController(), + ::com::sun::star::uno::UNO_QUERY ), m_xFrame, nCurrentZoom ? nCurrentZoom : 100 ); + return pSlider; +} + +// ----------------------------------------------------------------------- + +struct ScZoomSliderWnd::ScZoomSliderWnd_Impl +{ + USHORT mnCurrentZoom; + USHORT mnMinZoom; + USHORT mnMaxZoom; + USHORT mnSliderCenter; + std::vector< long > maSnappingPointOffsets; + std::vector< USHORT > maSnappingPointZooms; + Image maSliderButton; + Image maIncreaseButton; + Image maDecreaseButton; + bool mbValuesSet; + bool mbOmitPaint; + + ScZoomSliderWnd_Impl( USHORT nCurrentZoom ) : + mnCurrentZoom( nCurrentZoom ), + mnMinZoom( 10 ), + mnMaxZoom( 400 ), + mnSliderCenter( 100 ), + maSnappingPointOffsets(), + maSnappingPointZooms(), + maSliderButton(), + maIncreaseButton(), + maDecreaseButton(), + mbValuesSet( true ), + mbOmitPaint( false ) + { + + } +}; + +// ----------------------------------------------------------------------- + +const long nButtonWidth = 10; +const long nButtonHeight = 10; +const long nIncDecWidth = 11; +const long nIncDecHeight = 11; +const long nSliderHeight = 2; // +const long nSliderWidth = 4; // +const long nSnappingHeight = 4; +const long nSliderXOffset = 20; +const long nSnappingEpsilon = 5; // snapping epsilon in pixels +const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points + + +// ----------------------------------------------------------------------- + +USHORT ScZoomSliderWnd::Offset2Zoom( long nOffset ) const +{ + Size aSliderWindowSize = GetOutputSizePixel(); + const long nControlWidth = aSliderWindowSize.Width(); + USHORT nRet = 0; + + if( nOffset < nSliderXOffset ) + return mpImpl->mnMinZoom; + if( nOffset > nControlWidth - nSliderXOffset ) + return mpImpl->mnMaxZoom; + + // check for snapping points: + USHORT nCount = 0; + std::vector< long >::iterator aSnappingPointIter; + for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin(); + aSnappingPointIter != mpImpl->maSnappingPointOffsets.end(); + ++aSnappingPointIter ) + { + const long nCurrent = *aSnappingPointIter; + if ( Abs(nCurrent - nOffset) < nSnappingEpsilon ) + { + nOffset = nCurrent; + nRet = mpImpl->maSnappingPointZooms[ nCount ]; + break; + } + ++nCount; + } + + if( 0 == nRet ) + { + if( nOffset < nControlWidth / 2 ) + { + // first half of slider + const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom; + const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; + const long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth; + const long nOffsetToSliderLeft = nOffset - nSliderXOffset; + nRet = mpImpl->mnMinZoom + USHORT( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 ); + } + else + { + // second half of slider + const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter; + const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; + const long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth; + const long nOffsetToSliderCenter = nOffset - nControlWidth/2; + nRet = mpImpl->mnSliderCenter + USHORT( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 ); + } + } + + if( nRet < mpImpl->mnMinZoom ) + return mpImpl->mnMinZoom; + + else if( nRet > mpImpl->mnMaxZoom ) + return mpImpl->mnMaxZoom; + + return nRet; +} + +// ----------------------------------------------------------------------- + +long ScZoomSliderWnd::Zoom2Offset( USHORT nCurrentZoom ) const +{ + Size aSliderWindowSize = GetOutputSizePixel(); + const long nControlWidth = aSliderWindowSize.Width(); + long nRect = nSliderXOffset; + + const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; + if( nCurrentZoom <= mpImpl->mnSliderCenter ) + { + nCurrentZoom = nCurrentZoom - mpImpl->mnMinZoom; + const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom; + const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange; + const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000; + nRect += nOffset; + } + else + { + nCurrentZoom = nCurrentZoom - mpImpl->mnSliderCenter; + const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter; + const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange; + const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000; + nRect += nHalfSliderWidth + nOffset; + } + return nRect; +} + +// ----------------------------------------------------------------------- + + +ScZoomSliderWnd::ScZoomSliderWnd( Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame , USHORT nCurrentZoom ): + Window( pParent ), + mpImpl( new ScZoomSliderWnd_Impl( nCurrentZoom ) ), + m_xDispatchProvider( rDispatchProvider ), + m_xFrame( _xFrame ), + aLogicalSize( 115, 40 ) +{ + BOOL bIsDark = GetSettings().GetStyleSettings().GetFaceColor().IsDark(); + mpImpl->maSliderButton = Image( SVX_RES( bIsDark ? RID_SVXBMP_SLIDERBUTTON_HC : RID_SVXBMP_SLIDERBUTTON ) ); + mpImpl->maIncreaseButton = Image( SVX_RES( bIsDark ? RID_SVXBMP_SLIDERINCREASE_HC : RID_SVXBMP_SLIDERINCREASE ) ); + mpImpl->maDecreaseButton = Image( SVX_RES( bIsDark ? RID_SVXBMP_SLIDERDECREASE_HC : RID_SVXBMP_SLIDERDECREASE ) ); + Size aSliderSize = LogicToPixel( Size( aLogicalSize), MapMode( MAP_10TH_MM ) ); + SetSizePixel( Size( aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight ) ); +} + +// ----------------------------------------------------------------------- + +ScZoomSliderWnd::~ScZoomSliderWnd() +{ + delete mpImpl; +} + +// ----------------------------------------------------------------------- + +void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( !mpImpl->mbValuesSet ) + return ; + Size aSliderWindowSize = GetOutputSizePixel(); + + const Point aPoint = rMEvt.GetPosPixel(); + + const long nButtonLeftOffset = ( nSliderXOffset - nIncDecWidth )/2; + const long nButtonRightOffset = ( nSliderXOffset + nIncDecWidth )/2; + + const long nOldZoom = mpImpl->mnCurrentZoom; + + // click to - button + if ( aPoint.X() >= nButtonLeftOffset && aPoint.X() <= nButtonRightOffset ) + { + mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom - 5; + } + // click to + button + else if ( aPoint.X() >= aSliderWindowSize.Width() - nSliderXOffset + nButtonLeftOffset && + aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset + nButtonRightOffset ) + { + mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom + 5; + } + else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset ) + { + mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() ); + } + + if( mpImpl->mnCurrentZoom < mpImpl->mnMinZoom ) + mpImpl->mnCurrentZoom = mpImpl->mnMinZoom; + else if( mpImpl->mnCurrentZoom > mpImpl->mnMaxZoom ) + mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom; + + if( nOldZoom == mpImpl->mnCurrentZoom ) + return ; + + Rectangle aRect( Point( 0, 0 ), aSliderWindowSize ); + + Paint( aRect ); + mpImpl->mbOmitPaint = true; + + SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom ); + + ::com::sun::star::uno::Any a; + aZoomSliderItem.QueryValue( a ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScalingFactor" )); + aArgs[0].Value = a; + + SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ScalingFactor"), aArgs ); + + mpImpl->mbOmitPaint = false; +} + +// ----------------------------------------------------------------------- + +void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt ) +{ + if ( !mpImpl->mbValuesSet ) + return ; + + Size aSliderWindowSize = GetOutputSizePixel(); + const long nControlWidth = aSliderWindowSize.Width(); + const short nButtons = rMEvt.GetButtons(); + + // check mouse move with button pressed + if ( 1 == nButtons ) + { + const Point aPoint = rMEvt.GetPosPixel(); + + if ( aPoint.X() >= nSliderXOffset && aPoint.X() <= nControlWidth - nSliderXOffset ) + { + mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() ); + + Rectangle aRect( Point( 0, 0 ), aSliderWindowSize ); + Paint( aRect ); + + mpImpl->mbOmitPaint = true; // optimization: paint before executing command, + + // commit state change + SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom ); + + ::com::sun::star::uno::Any a; + aZoomSliderItem.QueryValue( a ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScalingFactor" )); + aArgs[0].Value = a; + + SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ScalingFactor"), aArgs ); + + mpImpl->mbOmitPaint = false; + } + } +} + +// ----------------------------------------------------------------------- + +void ScZoomSliderWnd::Update( const SvxZoomSliderItem* pZoomSliderItem ) +{ + if( pZoomSliderItem ) + { + mpImpl->mnCurrentZoom = pZoomSliderItem->GetValue(); + mpImpl->mnMinZoom = pZoomSliderItem->GetMinZoom(); + mpImpl->mnMaxZoom = pZoomSliderItem->GetMaxZoom(); + + DBG_ASSERT( mpImpl->mnMinZoom <= mpImpl->mnCurrentZoom && + mpImpl->mnMinZoom < mpImpl->mnSliderCenter && + mpImpl->mnMaxZoom >= mpImpl->mnCurrentZoom && + mpImpl->mnMaxZoom > mpImpl->mnSliderCenter, + "Looks like the zoom slider item is corrupted" ) + const com::sun::star::uno::Sequence < sal_Int32 > rSnappingPoints = pZoomSliderItem->GetSnappingPoints(); + mpImpl->maSnappingPointOffsets.clear(); + mpImpl->maSnappingPointZooms.clear(); + + // get all snapping points: + std::set< USHORT > aTmpSnappingPoints; + for ( USHORT j = 0; j < rSnappingPoints.getLength(); ++j ) + { + const sal_Int32 nSnappingPoint = rSnappingPoints[j]; + aTmpSnappingPoints.insert( (USHORT)nSnappingPoint ); + } + + // remove snapping points that are to close to each other: + std::set< USHORT >::iterator aSnappingPointIter; + long nLastOffset = 0; + + for ( aSnappingPointIter = aTmpSnappingPoints.begin(); aSnappingPointIter != aTmpSnappingPoints.end(); ++aSnappingPointIter ) + { + const USHORT nCurrent = *aSnappingPointIter; + const long nCurrentOffset = Zoom2Offset( nCurrent ); + + if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist ) + { + mpImpl->maSnappingPointOffsets.push_back( nCurrentOffset ); + mpImpl->maSnappingPointZooms.push_back( nCurrent ); + nLastOffset = nCurrentOffset; + } + } + } + + Size aSliderWindowSize = GetOutputSizePixel(); + Rectangle aRect( Point( 0, 0 ), aSliderWindowSize ); + + if ( !mpImpl->mbOmitPaint ) + Paint(aRect); +} + +// ----------------------------------------------------------------------- + +void ScZoomSliderWnd::Paint( const Rectangle& rRect ) +{ + DoPaint( rRect ); +} + +// ----------------------------------------------------------------------- + +void ScZoomSliderWnd::DoPaint( const Rectangle& /*rRect*/ ) +{ + if( mpImpl->mbOmitPaint ) + return; + + Size aSliderWindowSize = GetOutputSizePixel(); + Rectangle aRect( Point( 0, 0 ), aSliderWindowSize ); + + VirtualDevice* pVDev = new VirtualDevice( *this ); + pVDev->SetOutputSizePixel( aSliderWindowSize ); + + Rectangle aSlider = aRect; + + aSlider.Top() += ( aSliderWindowSize.Height() - nSliderHeight )/2 - 1; + aSlider.Bottom() = aSlider.Top() + nSliderHeight; + aSlider.Left() += nSliderXOffset; + aSlider.Right() -= nSliderXOffset; + + Rectangle aFirstLine( aSlider ); + aFirstLine.Bottom() = aFirstLine.Top(); + + Rectangle aSecondLine( aSlider ); + aSecondLine.Top() = aSecondLine.Bottom(); + + Rectangle aLeft( aSlider ); + aLeft.Right() = aLeft.Left(); + + Rectangle aRight( aSlider ); + aRight.Left() = aRight.Right(); + + // draw VirtualDevice's background color + Color aStartColor,aEndColor; + aStartColor = GetSettings().GetStyleSettings().GetFaceColor(); + aEndColor = GetSettings().GetStyleSettings().GetFaceColor(); + if( aEndColor.IsDark() ) + aStartColor = aEndColor; + + Gradient g; + g.SetAngle( 0 ); + g.SetStyle( GRADIENT_LINEAR ); + + g.SetStartColor( aStartColor ); + g.SetEndColor( aEndColor ); + pVDev->DrawGradient( aRect, g ); + + // draw slider + pVDev->SetLineColor( Color ( COL_WHITE ) ); + pVDev->DrawRect( aSecondLine ); + pVDev->DrawRect( aRight ); + + pVDev->SetLineColor( Color( COL_GRAY ) ); + pVDev->DrawRect( aFirstLine ); + pVDev->DrawRect( aLeft ); + + // draw snapping points: + std::vector< long >::iterator aSnappingPointIter; + for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin(); + aSnappingPointIter != mpImpl->maSnappingPointOffsets.end(); + ++aSnappingPointIter ) + { + pVDev->SetLineColor( Color( COL_GRAY ) ); + Rectangle aSnapping( aRect ); + aSnapping.Bottom() = aSlider.Top(); + aSnapping.Top() = aSnapping.Bottom() - nSnappingHeight; + aSnapping.Left() += *aSnappingPointIter; + aSnapping.Right() = aSnapping.Left(); + pVDev->DrawRect( aSnapping ); + + aSnapping.Top() += nSnappingHeight + nSliderHeight; + aSnapping.Bottom() += nSnappingHeight + nSliderHeight; + pVDev->DrawRect( aSnapping ); + } + + // draw slider button + Point aImagePoint = aRect.TopLeft(); + aImagePoint.X() += Zoom2Offset( mpImpl->mnCurrentZoom ); + aImagePoint.X() -= nButtonWidth/2; + aImagePoint.Y() += ( aSliderWindowSize.Height() - nButtonHeight)/2; + pVDev->DrawImage( aImagePoint, mpImpl->maSliderButton ); + + // draw decrease button + aImagePoint = aRect.TopLeft(); + aImagePoint.X() += (nSliderXOffset - nIncDecWidth)/2; + aImagePoint.Y() += ( aSliderWindowSize.Height() - nIncDecHeight)/2; + pVDev->DrawImage( aImagePoint, mpImpl->maDecreaseButton ); + + // draw increase button + aImagePoint.X() = aRect.TopLeft().X() + aSliderWindowSize.Width() - nIncDecWidth - (nSliderXOffset - nIncDecWidth)/2; + pVDev->DrawImage( aImagePoint, mpImpl->maIncreaseButton ); + + DrawOutDev( Point(0, 0), aSliderWindowSize, Point(0, 0), aSliderWindowSize, *pVDev ); + + delete pVDev; + +} + +// ----------------------------------------------------------------------- diff -uNr old/sc/source/ui/inc/tbzoomsliderctrl.hxx new/sc/source/ui/inc/tbzoomsliderctrl.hxx --- old/sc/source/ui/inc/tbzoomsliderctrl.hxx 1970-01-01 08:00:00.000000000 +0800 +++ new/sc/source/ui/inc/tbzoomsliderctrl.hxx 2008-06-11 13:19:14.000000000 +0800 @@ -0,0 +1,95 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: tbzoomsliderctrl.hxx,v $ +* +* $Revision: 1.1 $ +* +* last change: $Author: maoyg $ $Date: 2008/04/25 10:08:08 $ +* +* The Contents of this file are made available subject to +* the terms of GNU Lesser General Public License Version 2.1. +* +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2005 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library 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 for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +************************************************************************/ +#ifndef _SC_ZOOMSLIDERTBCONTRL_HXX +#define _SC_ZOOMSLIDERTBCONTRL_HXX + +#ifndef _WINDOW_HXX //autogen +#include +#endif +#ifndef _SFXPOOLITEM_HXX //autogen +#include +#endif +#ifndef _SFXTBXCTRL_HXX //autogen +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include +#endif +#include + + +//class ScZoomSliderControl define +class ScZoomSliderControl: public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + ScZoomSliderControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ); + ~ScZoomSliderControl(); + + virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual Window* CreateItemWindow( Window *pParent ); +}; + +//======================================================================== +// class ScZoomSliderWnd define--------------------------------------- +//======================================================================== +class ScZoomSliderWnd: public Window +{ +private: + struct ScZoomSliderWnd_Impl; + ScZoomSliderWnd_Impl* mpImpl; + Size aLogicalSize; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; + + USHORT Offset2Zoom( long nOffset ) const; + long Zoom2Offset( USHORT nZoom ) const; + void DoPaint( const Rectangle& rRect ); + +public: + ScZoomSliderWnd( Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame , USHORT nCurrentZoom ); + ~ScZoomSliderWnd(); + void Update( const SvxZoomSliderItem* pZoomSliderItem ); + +protected: + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void Paint( const Rectangle& rRect ); +}; +#endif \ No newline at end of file diff -uNr old/sc/source/ui/view/preview.cxx new/sc/source/ui/view/preview.cxx --- old/sc/source/ui/view/preview.cxx 2008-02-14 18:18:32.000000000 +0800 +++ new/sc/source/ui/view/preview.cxx 2008-07-01 13:38:12.000000000 +0800 @@ -974,6 +974,7 @@ rBindings.Invalidate(SID_ATTR_ZOOM); rBindings.Invalidate(SID_PREVIEW_ZOOMIN); rBindings.Invalidate(SID_PREVIEW_ZOOMOUT); + rBindings.Invalidate(SID_PREVIEW_SCALINGFACTOR); } IMPL_STATIC_LINK( ScPreview, InvalidateHdl, void*, EMPTYARG ) diff -uNr old/sc/source/ui/view/prevwsh.cxx new/sc/source/ui/view/prevwsh.cxx --- old/sc/source/ui/view/prevwsh.cxx 2008-03-07 23:11:14.000000000 +0800 +++ new/sc/source/ui/view/prevwsh.cxx 2008-07-01 13:39:32.000000000 +0800 @@ -60,8 +60,13 @@ #include #include +#ifndef _SVX_ZOOMSLIDERITEM_HXX +#include +#endif #include "prevwsh.hxx" #include "preview.hxx" +#include "printfun.hxx" +#include "attrib.hxx" #include "scmod.hxx" #include "inputhdl.hxx" #include "docsh.hxx" @@ -95,6 +100,8 @@ #include "scabstdlg.hxx" //CHINA001 // fuer Rad-Maus #define SC_DELTA_ZOOM 10 +#define MINZOOM_SLIDER 10 +#define MAXZOOM_SLIDER 400 #define SC_USERDATA_SEP ';' @@ -718,6 +725,27 @@ rReq.Done(); } break; + case SID_PREVIEW_SCALINGFACTOR: + { + const SfxPoolItem* pItem; + SCTAB nTab = pPreview->GetTab(); + String aOldName = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() ); + ScStyleSheetPool* pStylePool = pDocShell->GetDocument()->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE ); + DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" ); + + if ( pReqArgs && pStyleSheet && SFX_ITEM_SET == pReqArgs->GetItemState( SID_PREVIEW_SCALINGFACTOR, TRUE, &pItem ) ) + { + const USHORT nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue(); + SfxItemSet& rSet = pStyleSheet->GetItemSet(); + rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nCurrentZoom ) ); + ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ); + aPrintFunc.UpdatePages(); + rReq.Done(); + } + GetViewFrame()->GetBindings().Invalidate( nSlot ); + } + break; case SID_PRINTPREVIEW: case SID_PREVIEW_CLOSE: // print preview is now always in the same frame as the tab view @@ -793,6 +821,33 @@ rSet.Put( aZoom ); } break; + case SID_PREVIEW_SCALINGFACTOR: + { + if( pDocShell->IsReadOnly() ) + rSet.DisableItem( nWhich ); + else + { + String aOldName = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() ); + ScStyleSheetPool* pStylePool = pDocShell->GetDocument()->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE ); + DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" ); + + if ( pStyleSheet ) + { + SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); + USHORT nCurrentZoom = ((const SfxUInt16Item&)rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue(); + if( nCurrentZoom ) + { + SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM_SLIDER, MAXZOOM_SLIDER, SID_PREVIEW_SCALINGFACTOR ); + aZoomSliderItem.AddSnappingPoint( 100 ); + rSet.Put( aZoomSliderItem ); + } + else + rSet.DisableItem( nWhich ); + } + } + } + break; case SID_STATUS_DOCPOS: rSet.Put( SfxStringItem( nWhich, pPreview->GetPosString() ) ); break; diff -uNr old/sc/uiconfig/scalc/toolbar/previewbar.xml new/sc/uiconfig/scalc/toolbar/previewbar.xml --- old/sc/uiconfig/scalc/toolbar/previewbar.xml 2008-02-14 18:18:34.000000000 +0800 +++ new/sc/uiconfig/scalc/toolbar/previewbar.xml 2008-07-01 13:40:08.000000000 +0800 @@ -16,5 +16,7 @@ + + \ No newline at end of file diff -uNr old/svx/inc/svx/svxids.hrc new/svx/inc/svx/svxids.hrc --- old/svx/inc/svx/svxids.hrc 2008-03-07 23:17:20.000000000 +0800 +++ new/svx/inc/svx/svxids.hrc 2008-05-21 16:54:54.000000000 +0800 @@ -143,6 +143,8 @@ #define MID_ZOOMSLIDER_CURRENTZOOM 0x79 #define MID_ZOOMSLIDER_SNAPPINGPOINTS 0x7a +#define MID_ZOOMSLIDER_MINZOOM 0x7b +#define MID_ZOOMSLIDER_MAXZOOM 0x7c #define MID_ADR_FATHERSNAME 0x80 #define MID_ADR_APARTMENT 0x81 diff -uNr old/svx/sdi/svxitems.sdi new/svx/sdi/svxitems.sdi --- old/svx/sdi/svxitems.sdi 2008-03-07 23:17:26.000000000 +0800 +++ new/svx/sdi/svxitems.sdi 2008-05-21 16:55:18.000000000 +0800 @@ -701,6 +701,8 @@ { INT16 CurrentZoom MID_ZOOMSLIDER_CURRENTZOOM; Points SnappingPoints MID_ZOOMSLIDER_SNAPPINGPOINTS; + INT16 SvxMinZoom MID_ZOOMSLIDER_MINZOOM; + INT16 SvxMaxZoom MID_ZOOMSLIDER_MAXZOOM; }; item ZoomSlider SvxZoomSliderItem; diff -uNr old/svx/source/items/zoomslideritem.cxx new/svx/source/items/zoomslideritem.cxx --- old/svx/source/items/zoomslideritem.cxx 2008-03-07 23:18:22.000000000 +0800 +++ new/svx/source/items/zoomslideritem.cxx 2008-05-21 16:57:26.000000000 +0800 @@ -52,7 +52,9 @@ #define ZOOMSLIDER_PARAM_CURRENTZOOM "Columns" #define ZOOMSLIDER_PARAM_SNAPPINGPOINTS "SnappingPoints" -#define ZOOMSLIDER_PARAMS 2 +#define ZOOMSLIDER_PARAM_MINZOOM "MinZoom" +#define ZOOMSLIDER_PARAM_MAXZOOM "MaxZoom" +#define ZOOMSLIDER_PARAMS 4 // ----------------------------------------------------------------------- @@ -65,7 +67,7 @@ SvxZoomSliderItem::SvxZoomSliderItem( const SvxZoomSliderItem& rOrig ) : SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ), - maValues( rOrig.maValues ) + maValues( rOrig.maValues ), mnMinZoom( rOrig.mnMinZoom ), mnMaxZoom( rOrig.mnMaxZoom ) { } @@ -114,8 +116,8 @@ SvxZoomSliderItem& rItem = (SvxZoomSliderItem&)rAttr; - return ( GetValue() == rItem.GetValue() && - maValues == rItem.maValues ); + return ( GetValue() == rItem.GetValue() && maValues == rItem.maValues && + mnMinZoom == rItem.mnMinZoom && mnMaxZoom == rItem.mnMaxZoom ); } sal_Bool SvxZoomSliderItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const @@ -124,21 +126,40 @@ switch ( nMemberId ) { case 0 : - { - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOMSLIDER_PARAMS ); - aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_CURRENTZOOM )); - aSeq[0].Value <<= sal_Int32( GetValue() ); - aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_SNAPPINGPOINTS )); - aSeq[1].Value <<= maValues; - rVal <<= aSeq; - } - break; + { + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOMSLIDER_PARAMS ); + aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_CURRENTZOOM )); + aSeq[0].Value <<= sal_Int32( GetValue() ); + aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_SNAPPINGPOINTS )); + aSeq[1].Value <<= maValues; + aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_MINZOOM ) ); + aSeq[2].Value <<= mnMinZoom; + aSeq[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_MAXZOOM ) ); + aSeq[3].Value <<= mnMaxZoom; + rVal <<= aSeq; + } + break; - case MID_ZOOMSLIDER_CURRENTZOOM : rVal <<= (sal_Int32) GetValue(); break; + case MID_ZOOMSLIDER_CURRENTZOOM : + { + rVal <<= (sal_Int32) GetValue(); + } + break; case MID_ZOOMSLIDER_SNAPPINGPOINTS: { - rVal <<= maValues; break; + rVal <<= maValues; + } + break; + case MID_ZOOMSLIDER_MINZOOM: + { + rVal <<= mnMinZoom; + } + break; + case MID_ZOOMSLIDER_MAXZOOM: + { + rVal <<= mnMaxZoom; } + break; default: DBG_ERROR("svx::SvxZoomSliderItem::QueryValue(), Wrong MemberId!"); return sal_False; @@ -154,65 +175,100 @@ switch ( nMemberId ) { case 0 : - { - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq; - if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOMSLIDER_PARAMS )) { - sal_Int32 nCurrentZoom( 0 ); - com::sun::star::uno::Sequence < sal_Int32 > aValues; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq; + if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOMSLIDER_PARAMS )) + { + sal_Int32 nCurrentZoom( 0 ); + com::sun::star::uno::Sequence < sal_Int32 > aValues; + sal_Int32 nMinZoom( 0 ); + sal_Int32 nMaxZoom( 0 ); - sal_Bool bAllConverted( sal_True ); - sal_Int16 nConvertedCount( 0 ); + sal_Bool bAllConverted( sal_True ); + sal_Int16 nConvertedCount( 0 ); - for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) - { - if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_CURRENTZOOM )) + for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) { - bAllConverted &= ( aSeq[i].Value >>= nCurrentZoom ); - ++nConvertedCount; + if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_CURRENTZOOM )) + { + bAllConverted &= ( aSeq[i].Value >>= nCurrentZoom ); + ++nConvertedCount; + } + else if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_SNAPPINGPOINTS )) + { + bAllConverted &= ( aSeq[i].Value >>= aValues ); + ++nConvertedCount; + } + else if( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_MINZOOM ) ) + { + bAllConverted &= ( aSeq[i].Value >>= nMinZoom ); + ++nConvertedCount; + } + else if( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_MAXZOOM ) ) + { + bAllConverted &= ( aSeq[i].Value >>= nMaxZoom ); + ++nConvertedCount; + } } - else if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_SNAPPINGPOINTS )) + + if ( bAllConverted && nConvertedCount == ZOOMSLIDER_PARAMS ) { - bAllConverted &= ( aSeq[i].Value >>= aValues ); - ++nConvertedCount; + SetValue( (UINT16)nCurrentZoom ); + maValues = aValues; + mnMinZoom = (UINT16)nMinZoom; + mnMaxZoom = (UINT16)nMaxZoom; + return sal_True; } } - if ( bAllConverted && nConvertedCount == ZOOMSLIDER_PARAMS ) - { - SetValue( (UINT16)nCurrentZoom ); - maValues = aValues; - return sal_True; - } + return sal_False; } - return sal_False; - } - case MID_ZOOMSLIDER_CURRENTZOOM: - { - sal_Int32 nVal = 0; - if ( rVal >>= nVal ) { - SetValue( (UINT16)nVal ); - return sal_True; + sal_Int32 nVal = 0; + if ( rVal >>= nVal ) + { + SetValue( (UINT16)nVal ); + return sal_True; + } + else + return sal_False; } - else - return sal_False; - } case MID_ZOOMSLIDER_SNAPPINGPOINTS: - { - com::sun::star::uno::Sequence < sal_Int32 > aValues; - if ( rVal >>= aValues ) { - maValues = aValues; - return sal_True; + com::sun::star::uno::Sequence < sal_Int32 > aValues; + if ( rVal >>= aValues ) + { + maValues = aValues; + return sal_True; + } + else + return sal_False; + } + case MID_ZOOMSLIDER_MINZOOM: + { + sal_Int32 nVal = 0; + if( rVal >>= nVal ) + { + mnMinZoom = (UINT16)nVal; + return sal_True; + } + else + return sal_False; + } + case MID_ZOOMSLIDER_MAXZOOM: + { + sal_Int32 nVal = 0; + if( rVal >>= nVal ) + { + mnMaxZoom = (UINT16)nVal; + return sal_True; + } + else + return sal_False; } - else - return sal_False; - } - default: DBG_ERROR("svx::SvxZoomSliderItem::PutValue(), Wrong MemberId!"); return sal_False;