diff -uNr old/sc/source/ui/inc/preview.hxx new/sc/source/ui/inc/preview.hxx --- old/sc/source/ui/inc/preview.hxx 2007-02-27 21:25:30.000000000 +0800 +++ new/sc/source/ui/inc/preview.hxx 2007-01-05 22:05:38.000000000 +0800 @@ -4,9 +4,9 @@ * * $RCSfile: preview.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.8 $ * - * last change: $Author: vg $ $Date: 2007/02/27 13:25:29 $ + * last change: $Author: rt $ $Date: 2005/09/08 21:44:51 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -79,17 +79,53 @@ ScDocShell* pDocShell; ScPreviewShell* pViewShell; + //FUNC0031# RedOffice comment from chenp + BOOL bLeftRulerMove; + BOOL bRightRulerMove; + BOOL bTopRulerMove; + BOOL bBottomRulerMove; + BOOL bHeaderRulerMove; + BOOL bFooterRulerMove; + + BOOL bLeftRulerChange; + BOOL bRightRulerChange; + BOOL bTopRulerChange; + BOOL bBottomRulerChange; + BOOL bHeaderRulerChange; + BOOL bFooterRulerChange; + + Point LeftRulerChangePt; + Point RightRulerChangePt; + Point TopRulerChangePt; + Point BottomRulerChangePt; + Point HeaderRulerChangePt; + Point FooterRulerChangePt; + + Point PointerChangeAndButtonNotDownPt; + Point LastPointerChangeAndButtonNotDownPt; + BOOL bColRulerMove; + BOOL bColHeader; + BOOL bHorCenter; + ULONG nColOffset[MAXCOL+1]; + ULONG nColWidth[MAXCOL+1]; + + ScRange aPageArea; + + ULONG nColNumberButttonDown; + USHORT nLeftMarginForFirstCol; + Point ButtonDownPt; + Point ButtonUpPt; + //RedOffice comment end void TestLastPage(); void CalcPages( SCTAB nToWhichTab ); void RecalcPages(); void UpdateDrawView(); void DoPrint( ScPreviewLocationData* pFillLocation ); + void RoPaint( Rectangle* pRect ); //FUNC0031# RedOffice comment from chenp void InvalidateLocationData( ULONG nId ); - using Window::SetZoom; - protected: virtual void Paint( const Rectangle& rRect ); virtual void Command( const CommandEvent& rCEvt ); @@ -136,6 +172,12 @@ DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* ); static void StaticInvalidate(); + //FUNC0031# RedOffice comment from chenp + void MouseMove( const MouseEvent& rMEvt ); + void MouseButtonDown( const MouseEvent& rMEvt ); + void MouseButtonUp( const MouseEvent& rMEvt ); + //RedOffice comment end + FmFormView* GetDrawView() { return pDrawView; } }; diff -uNr old/sc/source/ui/inc/printfun.hxx new/sc/source/ui/inc/printfun.hxx --- old/sc/source/ui/inc/printfun.hxx 2005-09-09 05:45:38.000000000 +0800 +++ new/sc/source/ui/inc/printfun.hxx 2007-01-05 22:05:38.000000000 +0800 @@ -265,6 +265,16 @@ const ScPrintState& rState, const ScPrintOptions* pOptions ); + //FUNC0031# RedOffice comment from chenp + ScPrintFunc( ScDocShell* pShell, Window* pWindow, SCTAB nTab, + long nPage = 0, long nDocP = 0, + const ScRange* pArea = NULL, + const ScPrintOptions* pOptions = NULL ); + + ScPrintFunc( ScDocShell* pShell, Window* pWindow, + const ScPrintState& rState, + const ScPrintOptions* pOptions ); + //RedOffice comment end ~ScPrintFunc(); static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor, @@ -284,8 +294,12 @@ void ApplyPrintSettings(); // aus DoPrint() schon gerufen long DoPrint( const MultiSelection& rPageRanges, - long nStartPage, long nDisplayStart, BOOL bDoPrint, - SfxProgress* pProgress, ScPreviewLocationData* pLocationData ); + //FUNC0031# RedOffice comment from chenp + /*long nStartPage, long nDisplayStart, BOOL bDoPrint, + SfxProgress* pProgress, ScPreviewLocationData* pLocationData );*/ + long nStartPage, long nDisplayStart, BOOL bDoPrint = TRUE, + SfxProgress* pProgress = NULL, ScPreviewLocationData* pLocationData = NULL); + //RedOffice comment end // Werte abfragen - sofort @@ -306,6 +320,22 @@ void GetPrintState( ScPrintState& rState ); BOOL GetLastSourceRange( ScRange& rRange ) const; + //FUNC0031# RedOffice comment from chenp + USHORT GetLeftMargin() const{return nLeftMargin;} + USHORT GetRightMargin() const{return nRightMargin;} + USHORT GetTopMargin() const{return nTopMargin;} + USHORT GetBottomMargin() const{return nBottomMargin;} + void SetLeftMargin(USHORT nRulerLeftDistance){nLeftMargin=nRulerLeftDistance;} + void SetRightMargin(USHORT nRulerRightDistance){nRightMargin=nRulerRightDistance;} + void SetTopMargin(USHORT nRulerTopDistance){nTopMargin=nRulerTopDistance;} + void SetBottomMargin(USHORT nRulerBottomDistance){nBottomMargin=nRulerBottomDistance;} + ScPrintHFParam GetHeader(){return aHdr;} + ScPrintHFParam GetFooter(){return aFtr;} + USHORT GetEndCol(){return nEndCol;} + USHORT GetEndRow(){return nEndRow;} + ScRange GetRange(USHORT nTabPage, USHORT nTab); + //RedOffice comment end + private: void Construct( const ScPrintOptions* pOptions ); void InitParam( const ScPrintOptions* pOptions ); diff -uNr old/sc/source/ui/view/preview.cxx new/sc/source/ui/view/preview.cxx --- old/sc/source/ui/view/preview.cxx 2007-02-27 21:54:44.000000000 +0800 +++ new/sc/source/ui/view/preview.cxx 2007-01-05 22:05:38.000000000 +0800 @@ -4,9 +4,9 @@ * * $RCSfile: preview.cxx,v $ * - * $Revision: 1.31 $ + * $Revision: 1.28 $ * - * last change: $Author: vg $ $Date: 2007/02/27 13:54:43 $ + * last change: $Author: kz $ $Date: 2006/07/21 15:06:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -69,6 +68,16 @@ #include "globstr.hrc" #include "sc.hrc" // fuer ShellInvalidate #include "AccessibleDocumentPagePreview.hxx" +//FUNC0031# RedOffice comment from guj +#include "vcl/msgbox.hxx" +#include "vcl/lineinfo.hxx" +#include +#include +#include +#include +#include"attrib.hxx" +#include"pagepar.hxx" +//RedOffice comment end #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_ #include #endif @@ -76,10 +85,6 @@ #include "AccessibilityHints.hxx" #endif -#ifndef _SV_SVAPP_HXX //autogen -#include -#endif - // STATIC DATA ----------------------------------------------------------- //================================================================== @@ -99,26 +104,245 @@ return nDisplayStart; } +//FUNC0031# RedOffice comment from chenp +//start 2004-02-13 +void ScPreview::RoPaint( Rectangle* pRect ) +{ + if (!bValid) + { + CalcPages(0); + RecalcPages(); + UpdateDrawView(); // Tabelle evtl. geaendert + } + + Fraction aPreviewZoom( nZoom, 100 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); + + ScModule* pScMod = SC_MOD(); + const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig(); + Color aBackColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor ); + + if ( aOffset.X() < 0 || aOffset.Y() < 0 ) + { + SetMapMode( aMMMode ); + SetLineColor(); + SetFillColor(aBackColor); + + Size aWinSize = GetOutputSize(); + if ( aOffset.X() < 0 ) + DrawRect(Rectangle( 0, 0, -aOffset.X(), aWinSize.Height() )); + if ( aOffset.Y() < 0 ) + DrawRect(Rectangle( 0, 0, aWinSize.Width(), -aOffset.Y() )); + } + + USHORT nLeftMargin=0; + USHORT nRightMargin=0; + USHORT nTopMargin=0; + USHORT nBottomMargin=0; + ULONG nOffset=0; + ULONG nColCountOfTable=0; + long nHeaderHeight=0; + long nFooterHeight=0; + + Size aPageSize; + if ( nPageNo < nTotalPages ) + { + ScPrintOptions aOptions = SC_MOD()->GetPrintOptions(); + + ScPrintFunc* pPrintFunc; + if ( bStateValid ) + pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions ); + else + pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions ); + + pPrintFunc->SetOffset(aOffset); + pPrintFunc->SetManualZoom(nZoom); + pPrintFunc->SetDateTime(aDate,aTime); + pPrintFunc->SetClearFlag(TRUE); + pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() ); + pPrintFunc->SetDrawView( pDrawView ); + + // MultiSelection fuer die eine Seite muss etwas umstaendlich erzeugt werden... + Range aPageRange( nPageNo+1, nPageNo+1 ); + MultiSelection aPage( aPageRange ); + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( aPageRange ); + + long nPrinted = pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart ); + DBG_ASSERT(nPrinted<=1, "was'n nu los?"); + + SetMapMode(aMMMode); + //init nLeftMargin ... in the ScPrintFunc::InitParam!!! + nLeftMargin = pPrintFunc->GetLeftMargin(); + nRightMargin = pPrintFunc->GetRightMargin(); + nTopMargin = pPrintFunc->GetTopMargin(); + nBottomMargin = pPrintFunc->GetBottomMargin(); + nHeaderHeight = pPrintFunc->GetHeader().nHeight; + nFooterHeight = pPrintFunc->GetFooter().nHeight; + nColCountOfTable = pPrintFunc->GetEndCol(); + aPageArea = pPrintFunc->GetRange(nTabPage, nTab); + + for( int i=0; i<=nColCountOfTable+1;i++ ) + { + if( i>0 ) + { + if( pDocShell->GetDocument()->GetColFlags( i-1, nTab ) ) + nOffset = pDocShell->GetDocument()->GetColOffset( i-1, nTab ); + } + nColOffset[i]=(ULONG)((pDocShell->GetDocument()->GetColOffset(i, nTab)-nOffset)*HMM_PER_TWIPS); + nColWidth[i]=(ULONG)(pDocShell->GetDocument()->GetColWidth(i, nTab)*HMM_PER_TWIPS); + } + + if (nPrinted) // wenn nichts, alles grau zeichnen + { + aPageSize = pPrintFunc->GetPageSize(); + aPageSize.Width() = (long) (aPageSize.Width() * HMM_PER_TWIPS ); + aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS ); + + nLeftMargin=(USHORT)(nLeftMargin*HMM_PER_TWIPS); + nRightMargin=(USHORT)(nRightMargin*HMM_PER_TWIPS); + nTopMargin=(USHORT)(nTopMargin*HMM_PER_TWIPS); + nBottomMargin=(USHORT)(nBottomMargin*HMM_PER_TWIPS); + nHeaderHeight=(long)(nHeaderHeight*HMM_PER_TWIPS+nTopMargin); + nFooterHeight=(long)(nFooterHeight*HMM_PER_TWIPS+nBottomMargin); + } + + if (!bStateValid) + { + pPrintFunc->GetPrintState( aState ); + aState.nDocPages = nTotalPages; + bStateValid = TRUE; + } + + delete pPrintFunc; + } + + + long nPageEndX = aPageSize.Width() - aOffset.X(); + long nPageEndY = aPageSize.Height() - aOffset.Y(); + Size aWinSize = GetOutputSize(); //can not be deleted!!! + Point aWinEnd( aWinSize.Width(), aWinSize.Height() ); + BOOL bRight = nPageEndX <= aWinEnd.X(); + BOOL bBottom = nPageEndY <= aWinEnd.Y(); + +//QQQ from here! + ScDocument* pDoc = pDocShell->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nTab ), + SFX_STYLE_FAMILY_PAGE ); + + + if ( pStyleSheet ) + { + SfxItemSet* pParamSet = &pStyleSheet->GetItemSet(); + + bColHeader=((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_HEADERS)).GetValue(); + bHorCenter=((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_HORCENTER)).GetValue(); + } + long nRoFromHorPos; + long nRoFromColPos; + nRoFromHorPos = (aWinSize.Width() - aPageSize.Width())/2; + nRoFromColPos = (aWinSize.Height() - aPageSize.Height())/2; + //Because of the preview page in center,so modify the rulers' position! + SetLineColor(COL_GRAY); + LineInfo rLineInfo(LINE_SOLID,1); + DrawLine(Point(nRoFromHorPos,nTopMargin-aOffset.Y()),Point(nPageEndX,nTopMargin-aOffset.Y())); + DrawLine(Point(nRoFromHorPos,nPageEndY-nBottomMargin),Point(nPageEndX,nPageEndY-nBottomMargin)); + DrawLine(Point(nLeftMargin-aOffset.X(),nRoFromColPos),Point(nLeftMargin-aOffset.X(),nPageEndY)); + DrawLine(Point(nPageEndX-nRightMargin,nRoFromColPos),Point(nPageEndX-nRightMargin,nPageEndY)); + SetLineColor(COL_RED); + DrawLine(Point(nRoFromHorPos,nHeaderHeight-aOffset.Y()),Point(nPageEndX,nHeaderHeight-aOffset.Y())); + DrawLine(Point(nRoFromHorPos,nPageEndY-nFooterHeight),Point(nPageEndX,nPageEndY-nFooterHeight)); + SetLineColor(COL_BLACK); + SetFillColor(COL_BLACK); + //start 2004-02-13 + if( bColHeader ) //do not delete!!!!!!!!!!!!! + { + if( !bHorCenter ) + nLeftMargin+=PRINT_HEADER_WIDTH*HMM_PER_TWIPS; + else + { + long nAddOffset=(nPageEndX-nLeftMargin-nRightMargin-nColOffset[aPageArea.aEnd.Col()-1]-(PRINT_HEADER_WIDTH)*HMM_PER_TWIPS)/2; + nLeftMargin+=(PRINT_HEADER_WIDTH*HMM_PER_TWIPS+nAddOffset); + } + } + else if ( bHorCenter ) + { + long nAddOffset=(nPageEndX-nLeftMargin-nRightMargin-(nColOffset[aPageArea.aEnd.Col()-1]))/2; + nLeftMargin+=nAddOffset; + } + + if( aOffset.Y()<600 ) + { + for( int i=aPageArea.aStart.Col();iGetDocument(); @@ -143,8 +368,7 @@ // #114135# if ( pModel ) { - SdrPage* pPage = pModel->GetPage(nTab); - if ( pDrawView && ( !pDrawView->GetSdrPageView() || pDrawView->GetSdrPageView()->GetPage() != pPage ) ) + if ( pDrawView && !pDrawView->GetPageViewPgNum(static_cast(nTab)) ) { // die angezeigte Page der DrawView umzustellen (s.u.) funktioniert nicht ?!? delete pDrawView; @@ -158,13 +382,13 @@ // (Einstellung "Im Entwurfsmodus oeffnen"), darum hier zuruecksetzen pDrawView->SetDesignMode( TRUE ); pDrawView->SetPrintPreview( TRUE ); - pDrawView->ShowSdrPage(pPage); + pDrawView->ShowPagePgNum( static_cast(nTab), Point() ); } #if 0 - else if ( !pDrawView->GetSdrPageView()) // angezeigte Page umstellen + else if ( !pDrawView->GetPageViewPgNum(nTab) ) // angezeigte Page umstellen { - pDrawView->HideSdrPage(); - pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab)); + pDrawView->HideAllPages(); + pDrawView->ShowPagePgNum( nTab, Point() ); } #endif } @@ -349,7 +573,7 @@ DrawRect(Rectangle( 0, 0, aWinSize.Width(), -aOffset.Y() )); } - Size aLocalPageSize; + Size aPageSize; if ( bValidPage ) { ScPrintOptions aOptions = pScMod->GetPrintOptions(); @@ -382,9 +606,9 @@ if (nPrinted) // wenn nichts, alles grau zeichnen { - aLocalPageSize = pPrintFunc->GetPageSize(); - aLocalPageSize.Width() = (long) (aLocalPageSize.Width() * HMM_PER_TWIPS ); - aLocalPageSize.Height() = (long) (aLocalPageSize.Height() * HMM_PER_TWIPS ); + aPageSize = pPrintFunc->GetPageSize(); + aPageSize.Width() = (long) (aPageSize.Width() * HMM_PER_TWIPS ); + aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS ); } if (!bStateValid) @@ -398,8 +622,8 @@ if ( bDoPrint ) { - long nPageEndX = aLocalPageSize.Width() - aOffset.X(); - long nPageEndY = aLocalPageSize.Height() - aOffset.Y(); + long nPageEndX = aPageSize.Width() - aOffset.X(); + long nPageEndY = aPageSize.Height() - aOffset.Y(); if ( !bValidPage ) nPageEndX = nPageEndY = 0; @@ -462,9 +686,12 @@ } -void __EXPORT ScPreview::Paint( const Rectangle& /* rRect */ ) +void __EXPORT ScPreview::Paint( const Rectangle& rRect ) { - DoPrint( NULL ); + //FUNC0031# RedOffice comment from chenp + //DoPrint( NULL ); + RoPaint( NULL ); + //RedOffice comment end pViewShell->UpdateScrollBars(); } @@ -575,6 +802,7 @@ nNewZoom = 400; if (nNewZoom != nZoom) { + double nFact = nNewZoom / (double) nZoom; nZoom = nNewZoom; // apply new MapMode and call UpdateScrollBars to update aOffset @@ -606,24 +834,24 @@ } -long ScPreview::GetFirstPage(SCTAB nTabP) +long ScPreview::GetFirstPage(SCTAB nTab) { - SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount(); - if (nTabP >= nDocTabCount) - nTabP = nDocTabCount-1; + SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); + if (nTab >= nTabCount) + nTab = nTabCount-1; long nPage = 0; - if (nTabP>0) + if (nTab>0) { - CalcPages( nTabP ); + CalcPages( nTab ); UpdateDrawView(); // Tabelle evtl. geaendert - for (SCTAB i=0; i 0 ) + if ( nPages[nTab]==0 && nPage > 0 ) --nPage; } @@ -662,11 +890,11 @@ aWinSize.Width() -= 2 * aMarginSize.Width(); aWinSize.Height() -= 2 * aMarginSize.Height(); - Size aLocalPageSize = lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ); - if ( aLocalPageSize.Width() && aLocalPageSize.Height() ) + Size aPageSize = lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ); + if ( aPageSize.Width() && aPageSize.Height() ) { - long nZoomX = (long) ( aWinSize.Width() * 100 / ( aLocalPageSize.Width() * nWinScaleX )); - long nZoomY = (long) ( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY )); + long nZoomX = (long) ( aWinSize.Width() * 100 / ( aPageSize.Width() * nWinScaleX )); + long nZoomY = (long) ( aWinSize.Height() * 100 / ( aPageSize.Height() * nWinScaleY )); long nOptimal = nZoomX; if (!bWidthOnly && nZoomYGetOutputFactor(); + PointerChangeAndButtonNotDownPt.X() *= fFactor1; + + + + int nLeftMargin;// when offset is big enough, nLeftMargin can be negative + USHORT nRightMargin; + USHORT nTopMargin; + USHORT nBottomMargin; + long nHeaderHeight; + long nFooterHeight; + ULONG nOffset=0; + ULONG nColCountOfTable=0; + Size PageSize; + + + if ( nPageNo < nTotalPages ) + { + ScPrintOptions aOptions = SC_MOD()->GetPrintOptions(); + + ScPrintFunc* pPrintFunc; + + if (bStateValid) + pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions ); + else + pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions ); + + nLeftMargin=pPrintFunc->GetLeftMargin()-aOffset.X()/HMM_PER_TWIPS-1; + nRightMargin=pPrintFunc->GetRightMargin(); + nRightMargin=lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Width()-nRightMargin-aOffset.X()/HMM_PER_TWIPS-1; + nTopMargin=pPrintFunc->GetTopMargin()-aOffset.Y()/HMM_PER_TWIPS-1; + nBottomMargin=pPrintFunc->GetBottomMargin(); + nBottomMargin=lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-nBottomMargin-aOffset.Y()/HMM_PER_TWIPS-1; + nHeaderHeight=nTopMargin+pPrintFunc->GetHeader().nHeight; + nFooterHeight=nBottomMargin-pPrintFunc->GetFooter().nHeight; + nColCountOfTable=pPrintFunc->GetEndCol(); + aPageArea=pPrintFunc->GetRange(nTabPage, nTab); + + for(int i=0;i<=nColCountOfTable+1;i++) + { + if(i>0) + { + if(pDocShell->GetDocument()->GetColFlags(i-1, nTab)) + nOffset=pDocShell->GetDocument()->GetColOffset(i-1, nTab); + } + nColOffset[i]=(pDocShell->GetDocument()->GetColOffset(i, nTab)-nOffset); + nColWidth[i]=pDocShell->GetDocument()->GetColWidth(i, nTab); + + } + delete pPrintFunc; + } + + Point aPixPt( rMEvt.GetPosPixel() ); + aPixPt.X()=(long)(aPixPt.X()*TWIPS_PER_PIXEL*100/nZoom); + aPixPt.Y()=(long)(aPixPt.Y()*TWIPS_PER_PIXEL*100/nZoom); + BOOL bOnColRuler=FALSE; + double fFactor = pDocShell->GetOutputFactor(); + aPixPt.X() *= fFactor; + int nNewLeftMargin=nLeftMargin;//for first col offset + + if(bColHeader) + { + if(!bHorCenter) + nNewLeftMargin+=PRINT_HEADER_WIDTH; + else + { + long nAddOffset=(nRightMargin-nLeftMargin-nColOffset[aPageArea.aEnd.Col()-1]-(PRINT_HEADER_WIDTH))/2; + nNewLeftMargin+=PRINT_HEADER_WIDTH+nAddOffset; + } + } + else + { + if(bHorCenter) + { + long nAddOffset=(nRightMargin-nLeftMargin-(nColOffset[aPageArea.aEnd.Col()-1]))/2; + nNewLeftMargin+=nAddOffset; + + } + } + + for(int i=aPageArea.aStart.Col();i(nColOffset[i]+nNewLeftMargin-30))&& + (aPixPt.X()nLeftMargin) + &&(aPixPt.Y()>(0-aOffset.Y()/HMM_PER_TWIPS))&&(aPixPt.Y()<(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS))) + { + bOnColRuler=TRUE; + if(!rMEvt.GetButtons()&&GetPointer()==POINTER_HSPLIT)//11-15 + nColNumberButttonDown=i;//11-15 + break; + } + } + if((aPixPt.X()<(nLeftMargin+30)&&aPixPt.X()>(nLeftMargin-30)&&aPixPt.Y()>(0-aOffset.Y()/HMM_PER_TWIPS)&&aPixPt.Y()GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)||bLeftRulerMove|| + (aPixPt.X()<(nRightMargin+30)&&aPixPt.X()>(nRightMargin-30)&&aPixPt.Y()>(0-aOffset.Y()/HMM_PER_TWIPS)&&aPixPt.Y()GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)||bRightRulerMove || + bOnColRuler||bColRulerMove) + { + if((bOnColRuler||bColRulerMove)) + {if(!bRightRulerMove&&!bLeftRulerMove&&!bTopRulerMove + &&!bBottomRulerMove&&!bHeaderRulerMove&&!bFooterRulerMove) + SetPointer(POINTER_HSPLIT);} + else + { + if(!bRightRulerMove&&!bLeftRulerMove&&!bTopRulerMove + &&!bBottomRulerMove&&!bHeaderRulerMove&&!bFooterRulerMove) + { + SetPointer(POINTER_HSIZEBAR); + if(aPixPt.X()<(nLeftMargin+30)&&aPixPt.X()>(nLeftMargin-30)&&(!bRightRulerMove))//!RightRulerMove 使得一旦鼠标按下,要转换的标尺不会改变 + {bLeftRulerChange=TRUE;bRightRulerChange=FALSE;} + if(aPixPt.X()<(nRightMargin+30)&&aPixPt.X()>(nRightMargin-30)&&(!bLeftRulerMove))//!bLeft RulerMove同上 + {bRightRulerChange=TRUE;bLeftRulerChange=FALSE;} + } + } + } + else + { + if(((aPixPt.Y()<(nTopMargin+30)&&aPixPt.Y()>(nTopMargin-30))||bTopRulerMove|| + (aPixPt.Y()<(nBottomMargin+30)&&aPixPt.Y()>(nBottomMargin-30))||bBottomRulerMove|| + (aPixPt.Y()<(nHeaderHeight+30)&&aPixPt.Y()>(nHeaderHeight-30))||bHeaderRulerMove|| + (aPixPt.Y()<(nFooterHeight+30)&&aPixPt.Y()>(nFooterHeight-30))||bFooterRulerMove) + &&aPixPt.X()>(0-aOffset.X()/HMM_PER_TWIPS)&&aPixPt.X()GetDocument(), nTab).Width()-aOffset.X()/HMM_PER_TWIPS + ) + { + SetPointer(POINTER_VSIZEBAR); + if(aPixPt.Y()<(nTopMargin+30)&&aPixPt.Y()>(nTopMargin-30)&&(!bHeaderRulerMove)&&(!bFooterRulerMove)&&(!bBottomRulerMove)) + {bTopRulerChange=TRUE;bBottomRulerChange=FALSE; + bHeaderRulerChange=FALSE;bFooterRulerChange=FALSE;} + if(aPixPt.Y()<(nBottomMargin+30)&&aPixPt.Y()>(nBottomMargin-30)&&(!bFooterRulerMove)&&(!bHeaderRulerMove)&&(!bTopRulerMove)) + {bTopRulerChange=FALSE;bBottomRulerChange=TRUE; + bHeaderRulerChange=FALSE;bFooterRulerChange=FALSE;} + if(aPixPt.Y()<(nHeaderHeight+30)&&aPixPt.Y()>(nHeaderHeight-30)&&(!bTopRulerMove)&&(!bFooterRulerMove)&&(!bBottomRulerMove)) + {bTopRulerChange=FALSE;bBottomRulerChange=FALSE; + bHeaderRulerChange=TRUE;bFooterRulerChange=FALSE;} + if(aPixPt.Y()<(nFooterHeight+30)&&aPixPt.Y()>(nFooterHeight-30)&&(!bBottomRulerMove)&&(!bHeaderRulerMove)&&(!bTopRulerMove)) + {bTopRulerChange=FALSE;bBottomRulerChange=FALSE; + bHeaderRulerChange=FALSE;bFooterRulerChange=TRUE;} + + } + else + SetPointer(POINTER_ARROW); + } + + +} +void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) +{ + ButtonDownPt=rMEvt.GetPosPixel(); + + double fFactor = pDocShell->GetOutputFactor(); + ButtonDownPt.X() *= fFactor; + + CaptureMouse(); + + if(rMEvt.GetButtons()==MOUSE_LEFT&&GetPointer()==POINTER_HSIZEBAR) + { + if(bLeftRulerChange) + {bLeftRulerMove=TRUE;bRightRulerMove=FALSE;} + if(bRightRulerChange) + {bRightRulerMove=TRUE;bLeftRulerMove=FALSE;} + + Point aPixPt( rMEvt.GetPosPixel() ); + aPixPt.X() *= fFactor; + USHORT nLeftMargin; + USHORT nRightMargin; + if ( nPageNo < nTotalPages ) + { + ScPrintOptions aOptions = SC_MOD()->GetPrintOptions(); + + ScPrintFunc* pPrintFunc; + if (bStateValid) + pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions ); + else + pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions ); + + nLeftMargin=pPrintFunc->GetLeftMargin()-aOffset.X()/HMM_PER_TWIPS-1; + nRightMargin=pPrintFunc->GetRightMargin()+aOffset.X()/HMM_PER_TWIPS+1; + + delete pPrintFunc; + } + SetLineColor(COL_BLUE); + if(bLeftRulerChange) + DrawLine(Point(nLeftMargin*nZoom/100,(0-aOffset.Y()/HMM_PER_TWIPS)*nZoom/100),Point(nLeftMargin*nZoom/100,(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100)); + if(bRightRulerChange) + DrawLine(Point((lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width()-nRightMargin)*nZoom/100,(0-aOffset.Y()/HMM_PER_TWIPS)*nZoom/100),Point((lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width()-nRightMargin)*nZoom/100,(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100)); + } + + if(rMEvt.GetButtons()==MOUSE_LEFT&&GetPointer()==POINTER_VSIZEBAR) + { + if(bTopRulerChange) + bTopRulerMove=TRUE; + if(bBottomRulerChange) + bBottomRulerMove=TRUE; + if(bHeaderRulerChange) + {bHeaderRulerMove=TRUE;bFooterRulerMove=FALSE;} + if(bFooterRulerChange) + {bFooterRulerMove=TRUE;bHeaderRulerMove=FALSE;} + Point aPixPt( rMEvt.GetPosPixel() ); + + aPixPt.X() *= fFactor; + USHORT nTopMargin; + USHORT nBottomMargin; + long nHeaderHeight; + long nFooterHeight; + if ( nPageNo < nTotalPages ) + { + ScPrintOptions aOptions = SC_MOD()->GetPrintOptions(); + + ScPrintFunc* pPrintFunc; + if (bStateValid) + pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions ); + else + pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions ); + nTopMargin=pPrintFunc->GetTopMargin()-aOffset.Y()/HMM_PER_TWIPS-1; + nBottomMargin=pPrintFunc->GetBottomMargin()+aOffset.Y()/HMM_PER_TWIPS+1; + nHeaderHeight=pPrintFunc->GetHeader().nHeight; + nHeaderHeight+=nTopMargin; + nFooterHeight=pPrintFunc->GetFooter().nHeight; + nFooterHeight+=nBottomMargin; + delete pPrintFunc; + } + SetLineColor(COL_BLUE); + if(bTopRulerChange) + DrawLine(Point((0-aOffset.X()/HMM_PER_TWIPS*nZoom/100),nTopMargin*nZoom/100),Point((lcl_GetDocPageSize( pDocShell->GetDocument(),nTab).Width()-aOffset.X()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100, nTopMargin*nZoom/100)); + if(bBottomRulerChange) + DrawLine(Point((0-aOffset.X()/HMM_PER_TWIPS*nZoom/100),(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-nBottomMargin)*nZoom/100),Point((lcl_GetDocPageSize( pDocShell->GetDocument(),nTab).Width()-aOffset.X()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100,(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-nBottomMargin)*nZoom/100)); + if(bHeaderRulerChange) + DrawLine(Point((0-aOffset.X()/HMM_PER_TWIPS*nZoom/100),nHeaderHeight*nZoom/100),Point((lcl_GetDocPageSize( pDocShell->GetDocument(),nTab).Width()-aOffset.X()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100, nHeaderHeight*nZoom/100)); + if(bFooterRulerChange) + DrawLine(Point((0-aOffset.X()/HMM_PER_TWIPS*nZoom/100),(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-nFooterHeight)*nZoom/100),Point((lcl_GetDocPageSize( pDocShell->GetDocument(),nTab).Width()-aOffset.X()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100,(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-nFooterHeight)*nZoom/100)); + } + + if(rMEvt.GetButtons()==MOUSE_LEFT&&GetPointer()==POINTER_HSPLIT) + { + int nLeftMargin;//when offset big enougn, it can be negative + USHORT nRightMargin; + USHORT nColCountOfTable=0; + ULONG nOffset=0; + + if ( nPageNo < nTotalPages ) + { + ScPrintOptions aOptions = SC_MOD()->GetPrintOptions(); + + ScPrintFunc* pPrintFunc; + if (bStateValid) + pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions ); + else + pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions ); + nLeftMargin=pPrintFunc->GetLeftMargin(); + nRightMargin=pPrintFunc->GetRightMargin(); + nColCountOfTable=pPrintFunc->GetEndCol(); + aPageArea=pPrintFunc->GetRange(nTabPage, nTab); + delete pPrintFunc; + } + bColRulerMove=TRUE; + SetLineColor(COL_LIGHTGRAY); + Point MousePt(rMEvt.GetPosPixel()); + + MousePt.X() *= fFactor; + Point zero(0,0); + if(PointerChangeAndButtonNotDownPt==zero) + PointerChangeAndButtonNotDownPt=MousePt; + int i=0; + for( i=0;i<=nColCountOfTable+1;i++) + { + if(i>0) + { + if(pDocShell->GetDocument()->GetColFlags(i-1, nTab)) + nOffset=pDocShell->GetDocument()->GetColOffset(i-1, nTab); + } + nColOffset[i]=(pDocShell->GetDocument()->GetColOffset(i, nTab)-nOffset); + nColWidth[i]=pDocShell->GetDocument()->GetColWidth(i, nTab); + + } + USHORT nPageEndX=lcl_GetDocPageSize( pDocShell->GetDocument(),nTab).Width(); + if(bColHeader) + { + if(!bHorCenter) + nLeftMargin+=PRINT_HEADER_WIDTH; + else + { + long nAddOffset=(nPageEndX-nRightMargin-nLeftMargin-nColOffset[aPageArea.aEnd.Col()-1]-(PRINT_HEADER_WIDTH))/2; + nLeftMargin+=PRINT_HEADER_WIDTH+nAddOffset; + } + } + else + { + if(bHorCenter) + { + long nAddOffset=(nPageEndX-nRightMargin-nLeftMargin-(nColOffset[aPageArea.aEnd.Col()-1]))/2; + nLeftMargin+=nAddOffset; + + } + } + nLeftMargin-=aOffset.X()/HMM_PER_TWIPS;//11-25 + //**************用按下鼠标的位置来计算11-18 + Point NowPt(rMEvt.GetPosPixel()); + NowPt.X() *= fFactor; //0514 + + int j=0; + for(/*int*/ j=aPageArea.aStart.Col();jnColOffset[j]+nLeftMargin-100 + )break; + } + if(j==aPageArea.aEnd.Col())return; + nColNumberButttonDown=j; + //**************end 11-18 + SetLineColor(COL_BLUE); + i=nColNumberButttonDown;//11-15 + if(i==aPageArea.aStart.Col())nColOffset[i-1]=0; + DrawLine(Point((nColOffset[i-1]+nLeftMargin)*nZoom/100,(0-aOffset.Y()/HMM_PER_TWIPS*nZoom/100)),Point((nColOffset[i-1]+nLeftMargin)*nZoom/100,(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100)); + DrawLine(Point((nColOffset[i]+nLeftMargin)*nZoom/100,(0-aOffset.Y()/HMM_PER_TWIPS*nZoom/100)),Point((nColOffset[i]+nLeftMargin)*nZoom/100,(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)*nZoom/100-100*nZoom/100)); + + } + +} +void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) +{ + ButtonUpPt=rMEvt.GetPosPixel(); + + double fFactor = pDocShell->GetOutputFactor(); + ButtonUpPt.X() *= fFactor; + if(rMEvt.GetButtons()==MOUSE_LEFT&&GetPointer()==POINTER_HSIZEBAR) + { + bLeftRulerMove=FALSE; + bRightRulerMove=FALSE; + SetPointer(POINTER_ARROW); + if(bLeftRulerChange) + LeftRulerChangePt=ButtonUpPt; //0514 + if(bRightRulerChange) + RightRulerChangePt=ButtonUpPt;//0514 + + ////////////////////////////////////////////////// + BOOL bMoveRulerAction=TRUE; + { + if( + (bLeftRulerChange&&(LeftRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom<=(0-aOffset.X())/HMM_PER_TWIPS||LeftRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom>lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Width()-aOffset.X()/HMM_PER_TWIPS))|| + (bRightRulerChange&&(RightRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom<=(0-aOffset.X())/HMM_PER_TWIPS||RightRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom>lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Width()-aOffset.X()/HMM_PER_TWIPS)) + ) + { bMoveRulerAction=FALSE; + ByteString RoErr("溢出边界!"); + String aRoStr(RoErr, RTL_TEXTENCODING_GBK); + InfoBox(0, aRoStr).Execute(); + Rectangle rect(0,0,10000,10000); + Paint(rect); + } + else{ + if( + (bLeftRulerChange&&(LeftRulerChangePt.X()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom<(0-aOffset.X())*CM_PER_TWIPS/HMM_PER_TWIPS+0.5||LeftRulerChangePt.X()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom>(lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Width()-aOffset.X()/HMM_PER_TWIPS)*CM_PER_TWIPS-0.5))|| + (bRightRulerChange&&(RightRulerChangePt.X()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom<(0-aOffset.X())*CM_PER_TWIPS/HMM_PER_TWIPS+0.5||RightRulerChangePt.X()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom>(lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Width()-aOffset.X()/HMM_PER_TWIPS)*CM_PER_TWIPS-0.5)) + + ) + { + ByteString RoErr("设定有误!\n\n 是否继续接受这个设定?"); + String aRoStr(RoErr, RTL_TEXTENCODING_GBK); + QueryBox aBox( NULL, + WinBits(WB_YES_NO|WB_DEF_NO), + aRoStr ); + USHORT nRetVal = aBox.Execute(); + + if ( nRetVal == RET_YES ) + bMoveRulerAction= TRUE; + else if ( nRetVal == RET_NO ) + { bMoveRulerAction= FALSE;Rectangle rect(0,0,10000,10000);Paint(rect);} + + + } + } + } + if(bMoveRulerAction) + { + ScDocument * pDoc=pDocShell->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nTab ), + SFX_STYLE_FAMILY_PAGE ); + + SfxItemSet* pParamSet ; + if (pStyleSheet) + pParamSet = &pStyleSheet->GetItemSet(); + + SvxLRSpaceItem* pLRItem = ( SvxLRSpaceItem*) &pParamSet->Get( ATTR_LRSPACE ); + //left>right then ... + ByteString RoErr("不正确的页边距调整!"); + String aRoStr(RoErr, RTL_TEXTENCODING_GBK); + if(bLeftRulerChange&&((LeftRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom+aOffset.X()/HMM_PER_TWIPS)>aPageSize.Width()-pLRItem->GetRight())) + { InfoBox(0,aRoStr).Execute(); + Paint(Rectangle(0,0,0,0)); + return;} + if(bRightRulerChange&&(RightRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom+aOffset.X()/HMM_PER_TWIPSGetLeft())) + { InfoBox(0,aRoStr).Execute(); + Paint(Rectangle(0,0,0,0)); + return;} + if(ButtonDownPt!=ButtonUpPt&&bLeftRulerChange) + pLRItem->SetLeft(LeftRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom+aOffset.X()/HMM_PER_TWIPS+1,100); + if(ButtonDownPt!=ButtonUpPt&&bRightRulerChange) + pLRItem->SetRight(lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Width()-RightRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom-aOffset.X()/HMM_PER_TWIPS-1,100); + + Rectangle rRect(0,0,10000,10000); + Paint(rRect); + bLeftRulerChange=FALSE; + bRightRulerChange=FALSE; + } + } + + if(rMEvt.GetButtons()==MOUSE_LEFT&&GetPointer()==POINTER_VSIZEBAR) + { + bTopRulerMove=FALSE; + bBottomRulerMove=FALSE; + bHeaderRulerMove=FALSE; + bFooterRulerMove=FALSE; + SetPointer(POINTER_ARROW); + if(bTopRulerChange) + TopRulerChangePt=rMEvt.GetPosPixel(); + if(bBottomRulerChange) + BottomRulerChangePt=rMEvt.GetPosPixel(); + if(bHeaderRulerChange) + HeaderRulerChangePt=rMEvt.GetPosPixel(); + if(bFooterRulerChange) + FooterRulerChangePt=rMEvt.GetPosPixel(); + + BOOL bMoveRulerAction=TRUE; + { + if( + (bTopRulerChange&&(TopRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom<=(0-aOffset.Y())/HMM_PER_TWIPS||TopRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom>lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS))|| + (bBottomRulerChange&&(BottomRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom<=(0-aOffset.Y())/HMM_PER_TWIPS||BottomRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom>lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS))|| + (bHeaderRulerChange&&(HeaderRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom<=(0-aOffset.Y())/HMM_PER_TWIPS||HeaderRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom>lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS))|| + (bFooterRulerChange&&(FooterRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom<=(0-aOffset.Y())/HMM_PER_TWIPS||FooterRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom>lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS))//|| + ) + + { bMoveRulerAction=FALSE; + ByteString RoErr("溢出边界!"); + String aRoStr(RoErr, RTL_TEXTENCODING_GBK); + InfoBox(0,aRoStr).Execute(); + Rectangle rect(0,0,10000,10000); + Paint(rect); + } + else{ + if( + (bTopRulerChange&&(TopRulerChangePt.Y()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom<(0-aOffset.Y())*CM_PER_TWIPS/HMM_PER_TWIPS+0.5||TopRulerChangePt.Y()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom>(lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)*CM_PER_TWIPS-0.5))|| + (bBottomRulerChange&&(BottomRulerChangePt.Y()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom<(0-aOffset.Y())*CM_PER_TWIPS/HMM_PER_TWIPS+0.5||BottomRulerChangePt.Y()*CM_PER_TWIPS*TWIPS_PER_PIXEL*100/nZoom>(lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-aOffset.Y()/HMM_PER_TWIPS)*CM_PER_TWIPS-0.5))//|| + ) + { + ByteString RoErr("设定有误!\n\n 是否继续接受这个设定?"); + String aRoStr(RoErr, RTL_TEXTENCODING_GBK); + QueryBox aBox( NULL, + WinBits(WB_YES_NO|WB_DEF_NO), + aRoStr); + USHORT nRetVal = aBox.Execute(); + + if ( nRetVal == RET_YES ) + bMoveRulerAction= TRUE; + else if ( nRetVal == RET_NO ) + {bMoveRulerAction= FALSE;Rectangle rect(0,0,10000,10000);Paint(rect);} + + + } + } + } + if(bMoveRulerAction) + { + ScDocument * pDoc=pDocShell->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nTab ), + SFX_STYLE_FAMILY_PAGE ); + + SfxItemSet* pParamSet ; + if (pStyleSheet) + pParamSet = &pStyleSheet->GetItemSet(); + + SvxULSpaceItem* pULItem = ( SvxULSpaceItem*) &pParamSet->Get( ATTR_ULSPACE ); + if(ButtonDownPt!=ButtonUpPt&&bTopRulerChange) + pULItem->SetUpper(TopRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom+aOffset.Y()/HMM_PER_TWIPS+1,100); + if(ButtonDownPt!=ButtonUpPt&&bBottomRulerChange) + pULItem->SetLower(lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-BottomRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom-aOffset.Y()/HMM_PER_TWIPS-1,100); + if(ButtonDownPt!=ButtonUpPt&&bHeaderRulerChange) + { + SvxSetItem* pHeaderSetItem; + SfxItemSet* pHeaderSet = NULL; + if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, FALSE, + (const SfxPoolItem**)&pHeaderSetItem ) == SFX_ITEM_SET ) + { + pHeaderSet = &pHeaderSetItem->GetItemSet(); + Size HeaderSize; + HeaderSize=((SvxSizeItem&) pHeaderSet->Get(ATTR_PAGE_SIZE)).GetSize(); + HeaderSize.Height()=(HeaderRulerChangePt.Y())*TWIPS_PER_PIXEL*100/nZoom+aOffset.Y()/HMM_PER_TWIPS+1-pULItem->GetUpper(); + SvxSetItem aNewHeader( (const SvxSetItem&)pParamSet->Get(ATTR_PAGE_HEADERSET) ); + aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, HeaderSize ) ); + pParamSet->Put( aNewHeader ); + + + } + } + if(ButtonDownPt!=ButtonUpPt&&bFooterRulerChange) + { + SvxSetItem* pFooterSetItem; + SfxItemSet* pFooterSet = NULL; + if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, FALSE, + (const SfxPoolItem**)&pFooterSetItem ) == SFX_ITEM_SET ) + { + pFooterSet = &pFooterSetItem->GetItemSet(); + Size FooterSize; + FooterSize=((SvxSizeItem&) pFooterSet->Get(ATTR_PAGE_SIZE)).GetSize(); + FooterSize.Height()=lcl_GetDocPageSize( pDocShell->GetDocument(), nTab).Height()-FooterRulerChangePt.Y()*TWIPS_PER_PIXEL*100/nZoom-aOffset.Y()/HMM_PER_TWIPS-1-pULItem->GetLower(); + SvxSetItem aNewFooter( (const SvxSetItem&)pParamSet->Get(ATTR_PAGE_FOOTERSET) ); + aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, FooterSize ) ); + pParamSet->Put( aNewFooter ); + } + } + Rectangle rRect(0,0,100,100); + Paint(rRect); + bTopRulerChange=FALSE; + bBottomRulerChange=FALSE; + bHeaderRulerChange=FALSE; + bFooterRulerChange=FALSE; + } + + } + + + if(rMEvt.GetButtons()==MOUSE_LEFT&&GetPointer()==POINTER_HSPLIT) + { + SetPointer(POINTER_ARROW); + ScDocument * pDoc=pDocShell->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nTab ), + SFX_STYLE_FAMILY_PAGE ); + + SfxItemSet* pParamSet ; + if (pStyleSheet) + pParamSet = &pStyleSheet->GetItemSet(); + + + SvxLRSpaceItem* pLRItem = ( SvxLRSpaceItem*) &pParamSet->Get( ATTR_LRSPACE ); + int nLeftMargin=pLRItem->GetLeft();//when offset is big enough, it can be negative + USHORT nRightMargin=pLRItem->GetRight(); + int i; + USHORT nPageEndX=lcl_GetDocPageSize( pDocShell->GetDocument(),nTab).Width(); + if(bColHeader) + { + if(!bHorCenter) + nLeftMargin+=PRINT_HEADER_WIDTH; + else + { + long nAddOffset=(nPageEndX-nRightMargin-nLeftMargin-nColOffset[aPageArea.aEnd.Col()-1]-(PRINT_HEADER_WIDTH))/2; + nLeftMargin+=PRINT_HEADER_WIDTH+nAddOffset; + } + } + else + { + if(bHorCenter) + { + long nAddOffset=(nPageEndX-nRightMargin-nLeftMargin-(nColOffset[aPageArea.aEnd.Col()-1]))/2; + nLeftMargin+=nAddOffset; + + } + } + + Rectangle rect(0,0,100,100); + Point ColRulerChangePt=ButtonUpPt;//0514 + USHORT nNewColWidth=0; + i=nColNumberButttonDown;//11-15 + if(ColRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom-(pDocShell->GetDocument()->GetColOffset(i-1, nTab)-pDocShell->GetDocument()->GetColOffset(aPageArea.aStart.Col()-1, nTab))-nLeftMargin+aOffset.X()/HMM_PER_TWIPS+1>0) + nNewColWidth=ColRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom-(pDocShell->GetDocument()->GetColOffset(i-1, nTab)-pDocShell->GetDocument()->GetColOffset(aPageArea.aStart.Col()-1, nTab))-nLeftMargin+aOffset.X()/HMM_PER_TWIPS+1; + if(ColRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom>nLeftMargin+(0-aOffset.X())/HMM_PER_TWIPS+100&&ColRulerChangePt.X()*TWIPS_PER_PIXEL*100/nZoom<(lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width()-aOffset.X()/HMM_PER_TWIPS)-nRightMargin-100) + { + if(ButtonDownPt!=ButtonUpPt) + pDocShell->GetDocument()->SetColWidth(i-1, nTab, nNewColWidth); + } + Paint(rect); + bColRulerMove=FALSE; + Point zero(0,0); + LastPointerChangeAndButtonNotDownPt=PointerChangeAndButtonNotDownPt; + PointerChangeAndButtonNotDownPt=zero; + + } + ReleaseMouse(); + } +//RedOffice comment end + void ScPreview::InvalidateLocationData(ULONG nId) { bLocationValid = FALSE; diff -uNr old/sc/source/ui/view/printfun.cxx new/sc/source/ui/view/printfun.cxx --- old/sc/source/ui/view/printfun.cxx 2007-02-27 21:55:28.000000000 +0800 +++ new/sc/source/ui/view/printfun.cxx 2007-01-05 22:05:38.000000000 +0800 @@ -4,9 +4,9 @@ * * $RCSfile: printfun.cxx,v $ * - * $Revision: 1.49 $ + * $Revision: 1.46 $ * - * last change: $Author: vg $ $Date: 2007/02/27 13:55:28 $ + * last change: $Author: kz $ $Date: 2006/07/21 15:07:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -102,8 +102,11 @@ #include "drwlayer.hxx" #include "fillinfo.hxx" - - +//FUNC0031# Redoffice comment from guj +#include "vcl/msgbox.hxx" +#include "vcl/lineinfo.hxx" +#include +//RedOffice comment end #define ZOOM_MIN 10 #define GET_BOOL(set,which) ((const SfxBoolItem&)(set)->Get((which))).GetValue() @@ -256,13 +259,13 @@ nPageStart ( nPage ), nDocPages ( nDocP ), pUserArea ( pArea ), + pPageData ( pData ), + nTotalPages ( 0 ), + nTabPages ( 0 ), bState ( FALSE ), - bSourceRangeValid ( FALSE ), bPrintCurrentTable ( FALSE ), bMultiArea ( FALSE ), - nTabPages ( 0 ), - nTotalPages ( 0 ), - pPageData ( pData ) + bSourceRangeValid ( FALSE ) { pDev = pPrinter; aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM ); @@ -279,13 +282,13 @@ nPageStart ( nPage ), nDocPages ( nDocP ), pUserArea ( pArea ), + pPageData ( NULL ), + nTotalPages ( 0 ), + nTabPages ( 0 ), bState ( FALSE ), - bSourceRangeValid ( FALSE ), bPrintCurrentTable ( FALSE ), bMultiArea ( FALSE ), - nTabPages ( 0 ), - nTotalPages ( 0 ), - pPageData ( NULL ) + bSourceRangeValid ( FALSE ) { pDev = pOutDev; Construct( pOptions ); @@ -297,10 +300,10 @@ pPrinter ( NULL ), pDrawView ( NULL ), pUserArea ( NULL ), - bSourceRangeValid ( FALSE ), + pPageData ( NULL ), bPrintCurrentTable ( FALSE ), bMultiArea ( FALSE ), - pPageData ( NULL ) + bSourceRangeValid ( FALSE ) { pDev = pOutDev; @@ -320,6 +323,58 @@ Construct( pOptions ); } +//FUNC0031# Redoffice comment from guj + +ScPrintFunc::ScPrintFunc( ScDocShell* pShell, Window* pWindow, SCTAB nTab, + long nPage, long nDocP, const ScRange* pArea, + const ScPrintOptions* pOptions ) + : pDocShell ( pShell ), + pPrinter ( NULL ), + pDrawView ( NULL ), + nPrintTab ( nTab ), + nPageStart ( nPage ), + nDocPages ( nDocP ), + pUserArea ( pArea ), + pPageData ( NULL ), + nTotalPages ( 0 ), + nTabPages ( 0 ), + bState ( FALSE ), + bPrintCurrentTable ( FALSE ), + bMultiArea ( FALSE ) +{ + pDev = pWindow; + Construct( pOptions ); +} + +ScPrintFunc::ScPrintFunc( ScDocShell* pShell, Window* pWindow, + const ScPrintState& rState, const ScPrintOptions* pOptions ) + : pDocShell ( pShell ), + pPrinter ( NULL ), + pDrawView ( NULL ), + pUserArea ( NULL ), + pPageData ( NULL ), + bPrintCurrentTable ( FALSE ), + bMultiArea ( FALSE ) +{ + pDev = pWindow; + + nPrintTab = rState.nPrintTab; + nStartCol = rState.nStartCol; + nStartRow = rState.nStartRow; + nEndCol = rState.nEndCol; + nEndRow = rState.nEndRow; + nZoom = rState.nZoom; + nPagesX = rState.nPagesX; + nPagesY = rState.nPagesY; + nTabPages = rState.nTabPages; + nTotalPages = rState.nTotalPages; + nPageStart = rState.nPageStart; + nDocPages = rState.nDocPages; + bState = TRUE; + + Construct( pOptions ); +} +//RedOffice comment end void ScPrintFunc::GetPrintState( ScPrintState& rState ) { @@ -347,7 +402,7 @@ { if (pPageData) { - USHORT nCount = sal::static_int_cast( pPageData->GetCount() ); + USHORT nCount = pPageData->GetCount(); ScPrintRangeData& rData = pPageData->GetData(nCount); // hochzaehlen rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab, @@ -417,7 +472,7 @@ // - Ole-Object (DocShell::Draw) // - Vorschau bei Vorlagen -void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPrintFactor */, +void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor, const Rectangle& rBound, ScViewData* pViewData, BOOL bMetaFile ) { //! nPrintFactor auswerten !!! @@ -486,7 +541,7 @@ Rectangle aLines; ScRange aRange( nX1,nY1,nTab, nX2,nY2,nTab ); -// BOOL bAddLines = pDoc->HasLines( aRange, aLines ); + BOOL bAddLines = pDoc->HasLines( aRange, aLines ); long nTwipsSizeX = 0; for (SCCOL i=nX1; i<=nX2; i++) @@ -546,7 +601,7 @@ if( pModel ) { pDrawView = new FmFormView( pModel, pDev ); - pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab)); + pDrawView->ShowPagePgNum( static_cast(nTab), Point() ); pDrawView->SetPrintPreview( TRUE ); aOutputData.SetDrawView( pDrawView ); } @@ -568,10 +623,8 @@ // #109985# // Use a PaintMode which paints all SDRPAINTMODE_SC_ flags sal_uInt16 nAllPaintMode(0); - - // #i72502# - const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY)); - aOutputData.PrintDrawingLayer(SC_LAYER_BACK, nAllPaintMode, aMMOffset); + aOutputData.DrawingLayer(SC_LAYER_BACK, nAllPaintMode, nLogStX, nLogStY); + //aOutputData.DrawingLayer(SC_LAYER_BACK,SC_OBJECTS_ALL,nLogStX,nLogStY); if (!bMetaFile && pViewData) pDev->SetMapMode(aMode); @@ -625,11 +678,12 @@ pDev->DrawLine( Point(nScrX,nScrY), Point(nRight,nScrY) ); } - // #i72502# + // #109985# // USe a paint mode which draws all SDRPAINTMODE_SC_ flags - aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, nAllPaintMode, aMMOffset); - aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, nAllPaintMode, aMMOffset); - aOutputData.PostPrintDrawingLayer(); + aOutputData.DrawingLayer(SC_LAYER_FRONT, nAllPaintMode, nLogStX, nLogStY); + aOutputData.DrawingLayer(SC_LAYER_INTERN, nAllPaintMode, nLogStX, nLogStY); + //aOutputData.DrawingLayer(SC_LAYER_FRONT,SC_OBJECTS_ALL,nLogStX,nLogStY); + //aOutputData.DrawingLayer(SC_LAYER_INTERN,SC_OBJECTS_ALL,nLogStX,nLogStY); // #114135# delete pDrawView; @@ -1167,7 +1221,7 @@ ePos = GPOS_NONE; Point aPos; - Size aDrawSize = aGrfSize; + Size aSize = aGrfSize; FASTBOOL bDraw = TRUE; // FASTBOOL bRetouche = TRUE; @@ -1204,7 +1258,7 @@ case GPOS_AREA: aPos = rOrg.TopLeft(); - aDrawSize = rOrg.GetSize(); + aSize = rOrg.GetSize(); // bRetouche = FALSE; break; case GPOS_TILED: @@ -1265,7 +1319,7 @@ default: DBG_ASSERT( !pOut, "new Graphic position?" ); } - Rectangle aGrf( aPos,aDrawSize ); + Rectangle aGrf( aPos,aSize ); if ( bDraw && aGrf.IsOver( rOut ) ) { lcl_DrawGraphic( *pGraphic, pOut, aGrf, rOut ); @@ -1385,10 +1439,6 @@ aFrameRect.Right(), aFrameRect.Top()+nShadowY, aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) ); break; - default: - { - // added to avoid warnings - } } } @@ -1556,19 +1606,19 @@ long nScrX, long nScrY, BOOL bRepCol, BOOL bRepRow, ScPreviewLocationData& rLocationData ) { - // get MapMode for drawing objects (same MapMode as in ScOutputData::PrintDrawingLayer) + // get MapMode for drawing objects (same MapMode as in ScOutputData::DrawingLayer) Point aLogPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode); long nLogStX = aLogPos.X(); long nLogStY = aLogPos.Y(); SCCOL nCol; - Point aTwipOffset; + Point aOffset; for (nCol=0; nColGetColWidth( nCol, nPrintTab ); - aTwipOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nPrintTab ); + aOffset.X() -= pDoc->GetColWidth( nCol, nPrintTab ); + aOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nPrintTab ); - Point aMMOffset( aTwipOffset ); + Point aMMOffset( aOffset ); aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS); aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS); aMMOffset += Point( nLogStX, nLogStY ); @@ -1637,15 +1687,15 @@ // test if all paint parts are hidden, then a paint is not necessary at all //if (nObjectFlags) const sal_uInt16 nPaintModeHideAll(SDRPAINTMODE_SC_HIDE_OLE|SDRPAINTMODE_SC_HIDE_CHART|SDRPAINTMODE_SC_HIDE_DRAW); - const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY)); if(nPaintModeHideAll != (mnPaintMode & nPaintModeHideAll)) { pDev->SetMapMode(aLogicMode); // hier kein Clipping setzen (Mapmode wird verschoben) - // #i72502# - aOutputData.PrintDrawingLayer(SC_LAYER_BACK, mnPaintMode, aMMOffset); + // #109985# + //aOutputData.DrawingLayer(SC_LAYER_BACK,nObjectFlags,nLogStX,nLogStY); + aOutputData.DrawingLayer(SC_LAYER_BACK, mnPaintMode, nLogStX, nLogStY); } pDev->SetMapMode(aOffsetMode); @@ -1709,23 +1759,23 @@ //if (nObjectFlags) if(nPaintModeHideAll != (mnPaintMode & nPaintModeHideAll)) { - // #i72502# - aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, mnPaintMode, aMMOffset); + // #109985# + //aOutputData.DrawingLayer(SC_LAYER_FRONT,nObjectFlags,nLogStX,nLogStY); + aOutputData.DrawingLayer(SC_LAYER_FRONT, mnPaintMode, nLogStX, nLogStY); } // #109985# // Use a PaintMode which paints all SDRPAINTMODE_SC_ flags sal_uInt16 nPaintMode(0); - // #i72502# - aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, nPaintMode, aMMOffset); - aOutputData.PostPrintDrawingLayer(); + //aOutputData.DrawingLayer(SC_LAYER_INTERN,SC_OBJECTS_ALL,nLogStX,nLogStY); + aOutputData.DrawingLayer(SC_LAYER_INTERN, nPaintMode, nLogStX, nLogStY); //if ( pDrawView && (nObjectFlags & SC_OBJECTS_DRAWING) ) // #109985# if(pDrawView && !(mnPaintMode & SDRPAINTMODE_SC_HIDE_DRAW)) { - SdrPageView* pPV = pDrawView->GetSdrPageView(); + SdrPageView* pPV = pDrawView->GetPageViewPgNum(static_cast(nPrintTab)); DBG_ASSERT(pPV, "keine PageView fuer gedruckte Tabelle"); if (pPV) { @@ -1736,9 +1786,7 @@ pDev->SetMapMode( aControlMode ); pDev->SetClipRegion( aLogicRect ); // single controls may extend beyond the page - // Region aDrawRegion(aLogicRect); - // pPV->DrawLayer( SC_LAYER_CONTROLS, aDrawRegion); - pPV->DrawLayer( SC_LAYER_CONTROLS); + pPV->DrawLayer( SC_LAYER_CONTROLS, aLogicRect ); pDev->SetClipRegion(); } @@ -3121,6 +3169,78 @@ } } +//FUNC0031# Redoffice comment from guj +ScRange ScPrintFunc::GetRange(USHORT nTabPage, USHORT nTab) +{ + BYTE nFlags; + USHORT nHorizontalPageCount=1; + USHORT nVerticalPageCount=1; + + int nCol=0; + int nRow=0; + for( /*int*/ nCol=0;nColGetDocument()->GetColFlags( nCol, nTab ); + nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); + if(nFlags) + nHorizontalPageCount++; + } + //InfoBox(0,String::CreateFromInt32(nHorizontalPageCount)).Execute(); + for(/*int*/ nRow=0;nRowGetDocument()->GetRowFlags( nRow, nTab ); + nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); + if(nFlags) + nVerticalPageCount++; + } + BOOL bTop2Down=((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_TOPDOWN)).GetValue(); + USHORT nModNumber; + + if(bTop2Down) + { nModNumber=nVerticalPageCount; + if(nModNumber!=1) + nTabPage=(nTabPage)/nModNumber; + } + else + { nModNumber=nHorizontalPageCount; + if(nModNumber!=1) + nTabPage=(nTabPage)%nModNumber; + } + + + USHORT nPgCount=0; + for(nCol=0;nColGetDocument()->GetColFlags( nCol, nTab ); + nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); + if(nFlags) + nPgCount++; + } + + } + ScAddress aStart(nCol,0,nTab); + while(nColGetDocument()->GetColFlags( nCol, nTab ); + nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); + if(nFlags) + break; + else + nCol++; + + } + ScAddress aEnd(nCol+1,0,nTab); + if(aStart.Col()==0) + aStart.SetCol(1); + ScRange aTabPageArea(aStart,aEnd); + return aTabPageArea; +} +//RedOffice comment end + //------------------------------------------------------------------------ // class ScJobSetup //------------------------------------------------------------------------