diff -cNr old/sc/inc/sc.hrc new/sc/inc/sc.hrc *** old/sc/inc/sc.hrc Tue Mar 11 18:43:02 2008 --- new/sc/inc/sc.hrc Wed May 7 13:26:20 2008 *************** *** 920,925 **** --- 920,926 ---- #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_ZOOMSLIDER (SID_PREVIEW_START+9) #define SID_PREVIEW_END (SID_PREVIEW_START+20) //aus sfx: #define SID_KEYFUNC_START (SID_PREVIEW_END+5) diff -cNr old/sc/sdi/prevwsh.sdi new/sc/sdi/prevwsh.sdi *** old/sc/sdi/prevwsh.sdi Thu Feb 14 18:18:00 2008 --- new/sc/sdi/prevwsh.sdi Wed May 7 13:26:42 2008 *************** *** 47,52 **** --- 47,53 ---- 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_ZOOMSLIDER [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SfxVoidItem GoUpBlock SID_CURSORPAGEUP ( diff -cNr old/sc/sdi/scalc.sdi new/sc/sdi/scalc.sdi *** old/sc/sdi/scalc.sdi Fri Mar 7 23:10:24 2008 --- new/sc/sdi/scalc.sdi Wed May 7 13:27:12 2008 *************** *** 7630,7635 **** --- 7630,7659 ---- ] //-------------------------------------------------------------------------- + SvxZoomSliderItem ZoomSlider SID_PREVIEW_ZOOMSLIDER + [ + /* 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_VIEW; + ] + + //-------------------------------------------------------------------------- SfxVoidItem SelectTables SID_SELECT_TABLES (SfxIntegerListItem Tables SID_SELECT_TABLES) [ diff -cNr old/sc/source/ui/app/scdll.cxx new/sc/source/ui/app/scdll.cxx *** old/sc/source/ui/app/scdll.cxx Wed Feb 6 02:41:52 2008 --- new/sc/source/ui/app/scdll.cxx Wed May 7 16:12:30 2008 *************** *** 126,132 **** #endif #include #include "tbinsert.hxx" ! #include // Child-Windows #include "reffact.hxx" --- 126,132 ---- #endif #include #include "tbinsert.hxx" ! #include "tbzoomsliderctrl.hxx" #include // Child-Windows #include "reffact.hxx" *************** *** 234,239 **** --- 234,240 ---- ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSERT, pMod); ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSCELLS, pMod); ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSOBJ, pMod); + ScZoomSliderControl ::RegisterControl(SID_PREVIEW_ZOOMSLIDER, pMod); // Svx-Toolbox-Controller SvxTbxCtlDraw ::RegisterControl(SID_INSERT_DRAW, pMod); diff -cNr old/sc/source/ui/app/typemap.cxx new/sc/source/ui/app/typemap.cxx *** old/sc/source/ui/app/typemap.cxx Sun May 13 16:26:58 2007 --- new/sc/source/ui/app/typemap.cxx Wed May 7 16:18:56 2008 *************** *** 40,46 **** #include #include "sc.hrc" #include "scitems.hxx" ! #define ITEMID_DBTYPE 0 --- 40,48 ---- #include #include "sc.hrc" #include "scitems.hxx" ! #ifndef _SVX_ZOOMSLIDERITEM_HXX ! #include ! #endif #define ITEMID_DBTYPE 0 diff -cNr old/sc/source/ui/cctrl/makefile.mk new/sc/source/ui/cctrl/makefile.mk *** old/sc/source/ui/cctrl/makefile.mk Fri Mar 7 23:10:50 2008 --- new/sc/source/ui/cctrl/makefile.mk Wed May 7 13:35:44 2008 *************** *** 52,64 **** $(SLO)$/popmenu.obj \ $(SLO)$/tbinsert.obj \ $(SLO)$/cbuttonw.obj \ ! $(SLO)$/editfield.obj LIB1TARGET=$(SLB)$/$(TARGET).lib LIB1OBJFILES= \ $(SLO)$/popmenu.obj \ $(SLO)$/tbinsert.obj \ ! $(SLO)$/cbuttonw.obj # --- Tagets ------------------------------------------------------- --- 52,66 ---- $(SLO)$/popmenu.obj \ $(SLO)$/tbinsert.obj \ $(SLO)$/cbuttonw.obj \ ! $(SLO)$/editfield.obj \ ! $(SLO)$/tbzoomsliderctrl.obj LIB1TARGET=$(SLB)$/$(TARGET).lib LIB1OBJFILES= \ $(SLO)$/popmenu.obj \ $(SLO)$/tbinsert.obj \ ! $(SLO)$/cbuttonw.obj \ ! $(SLO)$/tbzoomsliderctrl.obj # --- Tagets ------------------------------------------------------- diff -cNr old/sc/source/ui/cctrl/tbzoomsliderctrl.cxx new/sc/source/ui/cctrl/tbzoomsliderctrl.cxx *** old/sc/source/ui/cctrl/tbzoomsliderctrl.cxx Thu Jan 1 08:00:00 1970 --- new/sc/source/ui/cctrl/tbzoomsliderctrl.cxx Wed May 21 17:11:02 2008 *************** *** 0 **** --- 1,539 ---- + /************************************************************************* + * + * 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 + #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 ) ) + { + pBox->Disable(); + pBox->Update( ( SvxZoomSliderItem* )NULL ); + } + 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(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pViewFrame->GetFrame()->GetFrameInterface(); + ScDocShell* pDocShell = (ScDocShell*)pViewFrame->GetObjectShell(); + SCTAB nTab = ScDocShell::GetCurTab(); + const USHORT nCurrentZoom = ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).GetZoom(); + 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 ); + 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( "ZoomSlider" )); + aArgs[0].Value = a; + + SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ZoomSlider"), 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( "ZoomSlider" )); + aArgs[0].Value = a; + + SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ZoomSlider"), 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; + + Color aOldLineColor = pVDev->GetLineColor(); + Color aOldFillColor = pVDev->GetFillColor(); + + 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(); + + pVDev->SetLineColor( Color(238,236,221) ); + pVDev->SetFillColor( Color(238,236,221) ); + pVDev->DrawRect( aRect ); + + // draw slider + pVDev->SetLineColor( Color ( COL_WHITE ) ); + pVDev->SetFillColor( Color ( COL_WHITE ) ); + pVDev->DrawRect( aSecondLine ); + pVDev->DrawRect( aRight ); + + pVDev->SetLineColor( Color( COL_GRAY ) ); + pVDev->SetFillColor( 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 ) ); + pVDev->SetFillColor( 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 -cNr old/sc/source/ui/inc/tbzoomsliderctrl.hxx new/sc/source/ui/inc/tbzoomsliderctrl.hxx *** old/sc/source/ui/inc/tbzoomsliderctrl.hxx Thu Jan 1 08:00:00 1970 --- new/sc/source/ui/inc/tbzoomsliderctrl.hxx Wed May 21 17:03:28 2008 *************** *** 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 -cNr old/sc/source/ui/view/preview.cxx new/sc/source/ui/view/preview.cxx *** old/sc/source/ui/view/preview.cxx Thu Feb 14 18:18:32 2008 --- new/sc/source/ui/view/preview.cxx Wed May 21 17:02:10 2008 *************** *** 974,979 **** --- 974,980 ---- rBindings.Invalidate(SID_ATTR_ZOOM); rBindings.Invalidate(SID_PREVIEW_ZOOMIN); rBindings.Invalidate(SID_PREVIEW_ZOOMOUT); + rBindings.Invalidate(SID_PREVIEW_ZOOMSLIDER); } IMPL_STATIC_LINK( ScPreview, InvalidateHdl, void*, EMPTYARG ) diff -cNr old/sc/source/ui/view/prevwsh.cxx new/sc/source/ui/view/prevwsh.cxx *** old/sc/source/ui/view/prevwsh.cxx Fri Mar 7 23:11:14 2008 --- new/sc/source/ui/view/prevwsh.cxx Wed May 21 17:01:10 2008 *************** *** 60,67 **** --- 60,71 ---- #include #include + #ifndef _SVX_ZOOMSLIDERITEM_HXX + #include + #endif #include "prevwsh.hxx" #include "preview.hxx" + #include "printfun.hxx" #include "scmod.hxx" #include "inputhdl.hxx" #include "docsh.hxx" *************** *** 95,100 **** --- 99,106 ---- #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,723 **** --- 724,750 ---- rReq.Done(); } break; + case SID_PREVIEW_ZOOMSLIDER: + { + 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_ZOOMSLIDER, 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,798 **** --- 820,838 ---- rSet.Put( aZoom ); } break; + case SID_PREVIEW_ZOOMSLIDER: + { + if( pDocShell->IsReadOnly() ) + rSet.DisableItem( nWhich ); + else + { + const USHORT nCurrentZoom = ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).GetZoom(); + SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM_SLIDER, MAXZOOM_SLIDER, SID_PREVIEW_ZOOMSLIDER ); + aZoomSliderItem.AddSnappingPoint( 100 ); + rSet.Put( aZoomSliderItem ); + } + } + break; case SID_STATUS_DOCPOS: rSet.Put( SfxStringItem( nWhich, pPreview->GetPosString() ) ); break; diff -cNr old/sc/uiconfig/scalc/toolbar/previewbar.xml new/sc/uiconfig/scalc/toolbar/previewbar.xml *** old/sc/uiconfig/scalc/toolbar/previewbar.xml Thu Feb 14 18:18:34 2008 --- new/sc/uiconfig/scalc/toolbar/previewbar.xml Wed May 7 13:28:00 2008 *************** *** 16,20 **** --- 16,22 ---- + + \ No newline at end of file diff -cNr old/svx/inc/svx/svxids.hrc new/svx/inc/svx/svxids.hrc *** old/svx/inc/svx/svxids.hrc Fri Mar 7 23:17:20 2008 --- new/svx/inc/svx/svxids.hrc Wed May 21 16:54:54 2008 *************** *** 143,148 **** --- 143,150 ---- #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 -cNr old/svx/sdi/svxitems.sdi new/svx/sdi/svxitems.sdi *** old/svx/sdi/svxitems.sdi Fri Mar 7 23:17:26 2008 --- new/svx/sdi/svxitems.sdi Wed May 21 16:55:18 2008 *************** *** 701,706 **** --- 701,708 ---- { INT16 CurrentZoom MID_ZOOMSLIDER_CURRENTZOOM; Points SnappingPoints MID_ZOOMSLIDER_SNAPPINGPOINTS; + INT16 SvxMinZoom MID_ZOOMSLIDER_MINZOOM; + INT16 SvxMaxZoom MID_ZOOMSLIDER_MAXZOOM; }; item ZoomSlider SvxZoomSliderItem; diff -cNr old/svx/source/items/zoomslideritem.cxx new/svx/source/items/zoomslideritem.cxx *** old/svx/source/items/zoomslideritem.cxx Fri Mar 7 23:18:22 2008 --- new/svx/source/items/zoomslideritem.cxx Wed May 21 16:57:26 2008 *************** *** 52,58 **** #define ZOOMSLIDER_PARAM_CURRENTZOOM "Columns" #define ZOOMSLIDER_PARAM_SNAPPINGPOINTS "SnappingPoints" ! #define ZOOMSLIDER_PARAMS 2 // ----------------------------------------------------------------------- --- 52,60 ---- #define ZOOMSLIDER_PARAM_CURRENTZOOM "Columns" #define ZOOMSLIDER_PARAM_SNAPPINGPOINTS "SnappingPoints" ! #define ZOOMSLIDER_PARAM_MINZOOM "MinZoom" ! #define ZOOMSLIDER_PARAM_MAXZOOM "MaxZoom" ! #define ZOOMSLIDER_PARAMS 4 // ----------------------------------------------------------------------- *************** *** 65,71 **** SvxZoomSliderItem::SvxZoomSliderItem( const SvxZoomSliderItem& rOrig ) : SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ), ! maValues( rOrig.maValues ) { } --- 67,73 ---- SvxZoomSliderItem::SvxZoomSliderItem( const SvxZoomSliderItem& rOrig ) : SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ), ! maValues( rOrig.maValues ), mnMinZoom( rOrig.mnMinZoom ), mnMaxZoom( rOrig.mnMaxZoom ) { } *************** *** 114,121 **** SvxZoomSliderItem& rItem = (SvxZoomSliderItem&)rAttr; ! return ( GetValue() == rItem.GetValue() && ! maValues == rItem.maValues ); } sal_Bool SvxZoomSliderItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const --- 116,123 ---- SvxZoomSliderItem& rItem = (SvxZoomSliderItem&)rAttr; ! 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,144 **** 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; ! case MID_ZOOMSLIDER_CURRENTZOOM : rVal <<= (sal_Int32) GetValue(); break; case MID_ZOOMSLIDER_SNAPPINGPOINTS: { ! rVal <<= maValues; break; } default: DBG_ERROR("svx::SvxZoomSliderItem::QueryValue(), Wrong MemberId!"); return sal_False; --- 126,165 ---- 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; ! 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_SNAPPINGPOINTS: { ! 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,218 **** 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; ! 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 )) { ! bAllConverted &= ( aSeq[i].Value >>= nCurrentZoom ); ! ++nConvertedCount; } ! else if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_SNAPPINGPOINTS )) { ! bAllConverted &= ( aSeq[i].Value >>= aValues ); ! ++nConvertedCount; } } ! if ( bAllConverted && nConvertedCount == ZOOMSLIDER_PARAMS ) ! { ! SetValue( (UINT16)nCurrentZoom ); ! maValues = aValues; ! return sal_True; ! } } - return sal_False; - } - case MID_ZOOMSLIDER_CURRENTZOOM: - { - sal_Int32 nVal = 0; - if ( rVal >>= nVal ) { ! SetValue( (UINT16)nVal ); ! return sal_True; } - else - return sal_False; - } case MID_ZOOMSLIDER_SNAPPINGPOINTS: - { - com::sun::star::uno::Sequence < sal_Int32 > aValues; - if ( rVal >>= aValues ) { ! maValues = aValues; ! return sal_True; } - else - return sal_False; - } - default: DBG_ERROR("svx::SvxZoomSliderItem::PutValue(), Wrong MemberId!"); return sal_False; --- 175,274 ---- 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; ! sal_Int32 nMinZoom( 0 ); ! sal_Int32 nMaxZoom( 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 )) ! { ! 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; ! } } ! ! if ( bAllConverted && nConvertedCount == ZOOMSLIDER_PARAMS ) { ! SetValue( (UINT16)nCurrentZoom ); ! maValues = aValues; ! mnMinZoom = (UINT16)nMinZoom; ! mnMaxZoom = (UINT16)nMaxZoom; ! return sal_True; } } ! return sal_False; } case MID_ZOOMSLIDER_CURRENTZOOM: { ! sal_Int32 nVal = 0; ! if ( rVal >>= nVal ) ! { ! SetValue( (UINT16)nVal ); ! return sal_True; ! } ! else ! return sal_False; } case MID_ZOOMSLIDER_SNAPPINGPOINTS: { ! 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; } default: DBG_ERROR("svx::SvxZoomSliderItem::PutValue(), Wrong MemberId!"); return sal_False;