diff -uNr old/sc/source/ui/inc/prevwsh.hxx new/sc/source/ui/inc/prevwsh.hxx --- old/sc/source/ui/inc/prevwsh.hxx 2007-07-19 23:46:34.000000000 +0800 +++ new/sc/source/ui/inc/prevwsh.hxx 2008-07-29 15:08:42.000000000 +0800 @@ -76,6 +76,7 @@ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSourceData; // ViewData BYTE nSourceDesignMode; // form design mode from TabView SvxZoomType eZoom; + long nMaxVertPos; SfxBroadcaster* pAccessibilityBroadcaster; 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-29 15:14:24.000000000 +0800 @@ -56,6 +56,9 @@ #include #include #include +#ifndef _SV_HELP_HXX //autogen +#include +#endif #include #include #include @@ -331,66 +334,144 @@ Point aOfs = pPreview->GetOffset(); long nMaxPos; - pHorScroll->SetRange( Range( 0, aPageSize.Width() ) ); - pHorScroll->SetLineSize( aWindowSize.Width() / 16 ); - pHorScroll->SetPageSize( aWindowSize.Width() ); - pHorScroll->SetVisibleSize( aWindowSize.Width() ); - nMaxPos = aPageSize.Width() - aWindowSize.Width(); - if (nMaxPos<0) - { - // page smaller than window -> center (but put scrollbar to 0) - aOfs.X() = 0; - pPreview->SetXOffset( nMaxPos / 2 ); - } - else if (aOfs.X() < 0) - { - // page larger than window -> never use negative offset - aOfs.X() = 0; - pPreview->SetXOffset( 0 ); - } - else if (aOfs.X() > nMaxPos) - { - // limit offset to align with right edge of window - aOfs.X() = nMaxPos; - pPreview->SetXOffset(nMaxPos); - } - pHorScroll->SetThumbPos( aOfs.X() ); + if( pHorScroll ) + { + pHorScroll->SetRange( Range( 0, aPageSize.Width() ) ); + pHorScroll->SetLineSize( aWindowSize.Width() / 16 ); + pHorScroll->SetPageSize( aWindowSize.Width() ); + pHorScroll->SetVisibleSize( aWindowSize.Width() ); + nMaxPos = aPageSize.Width() - aWindowSize.Width(); + if ( nMaxPos<0 ) + { + // page smaller than window -> center (but put scrollbar to 0) + aOfs.X() = 0; + pPreview->SetXOffset( nMaxPos / 2 ); + } + else if (aOfs.X() < 0) + { + // page larger than window -> never use negative offset + aOfs.X() = 0; + pPreview->SetXOffset( 0 ); + } + else if (aOfs.X() > nMaxPos) + { + // limit offset to align with right edge of window + aOfs.X() = nMaxPos; + pPreview->SetXOffset(nMaxPos); + } + pHorScroll->SetThumbPos( aOfs.X() ); + } + if( pVerScroll ) + { + long nPageNo = pPreview->GetPageNo(); + long nTotalPages = pPreview->GetTotalPages(); - pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); - pVerScroll->SetLineSize( aWindowSize.Height() / 16 ); - pVerScroll->SetPageSize( aWindowSize.Height() ); - pVerScroll->SetVisibleSize( aWindowSize.Height() ); - nMaxPos = aPageSize.Height() - aWindowSize.Height(); - if (nMaxPos<0) - { - // page smaller than window -> center (but put scrollbar to 0) - aOfs.Y() = 0; - pPreview->SetYOffset( nMaxPos / 2 ); - } - else if (aOfs.Y() < 0) - { - // page larger than window -> never use negative offset - aOfs.Y() = 0; - pPreview->SetYOffset( 0 ); - } - else if (aOfs.Y() > nMaxPos) - { - // limit offset to align with window bottom - aOfs.Y() = nMaxPos; - pPreview->SetYOffset(nMaxPos); - } - pVerScroll->SetThumbPos( aOfs.Y() ); + nMaxVertPos = aPageSize.Height() - aWindowSize.Height(); + pVerScroll->SetLineSize( aWindowSize.Height() / 16 ); + pVerScroll->SetPageSize( aWindowSize.Height() ); + pVerScroll->SetVisibleSize( aWindowSize.Height() ); + if ( nMaxVertPos < 0 ) + { + // page smaller than window -> center (but put scrollbar to 0) + aOfs.Y() = 0; + pPreview->SetYOffset( nMaxVertPos / 2 ); + pVerScroll->SetThumbPos( nPageNo * aWindowSize.Height() ); + pVerScroll->SetRange( Range( 0, aWindowSize.Height() * nTotalPages )); + } + else if (aOfs.Y() < 0) + { + // page larger than window -> never use negative offset + pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); + aOfs.Y() = 0; + pPreview->SetYOffset( 0 ); + pVerScroll->SetThumbPos( aOfs.Y() ); + } + else if (aOfs.Y() > nMaxVertPos ) + { + // limit offset to align with window bottom + pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); + aOfs.Y() = nMaxVertPos; + pPreview->SetYOffset( nMaxVertPos ); + pVerScroll->SetThumbPos( aOfs.Y() ); + } + } } IMPL_LINK (ScPreviewShell,ScrollHandler, ScrollBar* ,pScroll ) { - long nPos = pScroll->GetThumbPos(); + long nPos = pScroll->GetThumbPos(); + long nDelta = pScroll->GetDelta(); + long nMaxRange = pScroll->GetRangeMax(); + long nTotalPages = pPreview->GetTotalPages(); + long nPageNo = 0; + long nPerPageLength = 0; + BOOL bIsDivide = TRUE; - BOOL bHoriz = ( pScroll == pHorScroll ); - if (bHoriz) - pPreview->SetXOffset( nPos ); - else - pPreview->SetYOffset( nPos ); + if( nTotalPages ) + nPerPageLength = nMaxRange / nTotalPages; + + if( nPerPageLength ) + { + nPageNo = nPos / nPerPageLength; + if( nPos % nPerPageLength ) + { + bIsDivide = FALSE; + nPageNo ++; + } + } + + BOOL bHoriz = ( pScroll == pHorScroll ); + + if( bHoriz ) + pPreview->SetXOffset( nPos ); + else + { + if( nMaxVertPos > 0 ) + pPreview->SetYOffset( nPos ); + else + { + Point aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() ); + Point aPos = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() ); + String aHelpStr; + Rectangle aRect; + USHORT nAlign; + + if( nDelta < 0 ) + { + if ( nTotalPages && nPageNo > 0 && !bIsDivide ) + pPreview->SetPageNo( nPageNo-1 ); + if( bIsDivide ) + pPreview->SetPageNo( nPageNo ); + + aHelpStr = ScGlobal::GetRscString( STR_PAGE ); + aHelpStr += ' '; + aHelpStr += String::CreateFromInt32( nPageNo ); + + aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " )); + aHelpStr += String::CreateFromInt32( nTotalPages ); + } + else if( nDelta > 0 ) + { + BOOL bAllTested = pPreview->AllTested(); + if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) ) + pPreview->SetPageNo( nPageNo ); + + aHelpStr = ScGlobal::GetRscString( STR_PAGE ); + aHelpStr += ' '; + aHelpStr += String::CreateFromInt32( nPageNo+1 ); + + aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " )); + aHelpStr += String::CreateFromInt32( nTotalPages ); + } + + aRect.Left() = aPos.X() - 8; + aRect.Top() = aMousePos.Y(); + aRect.Right() = aRect.Left(); + aRect.Top() = aRect.Top(); + nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER; + Help::ShowQuickHelp( pScroll->GetParent(), aRect, aHelpStr, nAlign ); + } + } return 0; } @@ -918,44 +999,28 @@ aCurPos.Y() = pVerScroll->GetThumbPos(); aPrevPos = aCurPos; - long nThumbPos = pVerScroll->GetThumbPos(); - long nRangeMax = pVerScroll->GetRangeMax(); - switch( nMode ) { - case SID_CURSORUP: - aCurPos.Y() -= nVLine; - break; - case SID_CURSORDOWN: - aCurPos.Y() += nVLine; - break; - case SID_CURSORLEFT: - aCurPos.X() -= nHLine; - break; - case SID_CURSORRIGHT: - aCurPos.X() += nHLine; - break; - case SID_CURSORPAGEUP: - if(nThumbPos==0) - { - long nPage = pPreview->GetPageNo(); + case SID_CURSORUP: + if( nMaxVertPos<0 ) + { + long nPage = pPreview->GetPageNo(); - if( nPage>0 ) - { - SfxViewFrame* pSfxViewFrame = GetViewFrame(); - SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS ); - Execute( aSfxRequest ); - aCurPos.Y() = nVRange; - } - } - else - aCurPos.Y() -= nVPage; - break; - case SID_CURSORPAGEDOWN: - if((abs(nVPage+nThumbPos-nRangeMax)<10)||(nVPage>nRangeMax)) - { - long nPage = pPreview->GetPageNo(); - long nTotal = pPreview->GetTotalPages(); + if( nPage>0 ) + { + SfxViewFrame* pSfxViewFrame = GetViewFrame(); + SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS ); + Execute( aSfxRequest ); + } + } + else + aCurPos.Y() -= nVLine; + break; + case SID_CURSORDOWN: + if( nMaxVertPos<0 ) + { + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); // before testing for last page, make sure all page counts are calculated if ( nPage+1 == nTotal && !pPreview->AllTested() ) @@ -964,33 +1029,109 @@ nTotal = pPreview->GetTotalPages(); } - if( nPageGetPageNo(); + + if( nPage>0 ) + { + SfxViewFrame* pSfxViewFrame = GetViewFrame(); + SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS ); + Execute( aSfxRequest ); + } + } + else + aCurPos.Y() -= nVPage; + break; + case SID_CURSORPAGEDOWN: + if( nMaxVertPos<0 ) + { + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + + // before testing for last page, make sure all page counts are calculated + if ( nPage+1 == nTotal && !pPreview->AllTested() ) + { + pPreview->CalcAll(); + nTotal = pPreview->GetTotalPages(); + } + if( nPageGetPageNo(); + long nTotal = pPreview->GetTotalPages(); + if( nTotal && nPage != 0 ) + { + SfxViewFrame* pSfxViewFrame = GetViewFrame(); + SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_FIRST ); + Execute( aSfxRequest ); + } + } + else + { + aCurPos.Y() = 0; + aCurPos.X() = 0; + } + break; + case SID_CURSOREND: + if( nMaxVertPos<0 ) + { + if( !pPreview->AllTested() ) + pPreview->CalcAll(); + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + if( nTotal && nPage+1 != nTotal ) + { + SfxViewFrame* pSfxViewFrame = GetViewFrame(); + SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_LAST ); + Execute( aSfxRequest ); + } + } + else + { + aCurPos.Y() = nVRange; + aCurPos.X() = nHRange; + } + break; } // nHRange-nHPage kann negativ sein, deshalb Abfrage auf < 0 hinterher - if( aCurPos.Y() > (nVRange-nVPage) ) aCurPos.Y() = (nVRange-nVPage); - if( aCurPos.Y() < 0 ) aCurPos.Y() = 0; - if( aCurPos.X() > (nHRange-nHPage) ) aCurPos.X() = (nHRange-nHPage); - if( aCurPos.X() < 0 ) aCurPos.X() = 0; + if( aCurPos.Y() > (nVRange-nVPage) ) + aCurPos.Y() = (nVRange-nVPage); + if( aCurPos.Y() < 0 ) + aCurPos.Y() = 0; + if( aCurPos.X() > (nHRange-nHPage) ) + aCurPos.X() = (nHRange-nHPage); + if( aCurPos.X() < 0 ) + aCurPos.X() = 0; if( aCurPos.Y() != aPrevPos.Y() ) {