LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - preview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 870 0.1 %
Date: 2012-12-27 Functions: 2 39 5.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : 
      23             : 
      24             : #include <svtools/colorcfg.hxx>
      25             : #include <svx/fmview.hxx>
      26             : #include <editeng/sizeitem.hxx>
      27             : #include <svx/svdpagv.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <sfx2/dispatch.hxx>
      31             : #include <svtools/accessibilityoptions.hxx>
      32             : #include <svl/itemset.hxx>
      33             : #include <tools/multisel.hxx>
      34             : #include <vcl/waitobj.hxx>
      35             : 
      36             : #include "preview.hxx"
      37             : #include "prevwsh.hxx"
      38             : #include "prevloc.hxx"
      39             : #include "docsh.hxx"
      40             : #include "docfunc.hxx"
      41             : #include "printfun.hxx"
      42             : #include "printopt.hxx"
      43             : #include "stlpool.hxx"
      44             : #include "undostyl.hxx"
      45             : #include "drwlayer.hxx"
      46             : #include "scmod.hxx"
      47             : #include "markdata.hxx"
      48             : #include "globstr.hrc"
      49             : #include "sc.hrc"           // for ShellInvalidate
      50             : #include "AccessibleDocumentPagePreview.hxx"
      51             : #include <vcl/lineinfo.hxx>
      52             : #include <svx/algitem.hxx>
      53             : #include <editeng/lrspitem.hxx>
      54             : #include <editeng/ulspitem.hxx>
      55             : #include "attrib.hxx"
      56             : #include "pagepar.hxx"
      57             : #include <com/sun/star/accessibility/XAccessible.hpp>
      58             : #include "AccessibilityHints.hxx"
      59             : #include <vcl/svapp.hxx>
      60             : #include "viewutil.hxx"
      61             : 
      62             : // STATIC DATA -----------------------------------------------------------
      63             : 
      64             : //==================================================================
      65             : 
      66             : #define SC_PREVIEW_SHADOWSIZE   2
      67             : 
      68           0 : static long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, std::vector<long>& nPages )
      69             : {
      70           0 :     long nDisplayStart = 0;
      71           0 :     for (SCTAB i=0; i<nTab; i++)
      72             :     {
      73           0 :         if ( pDoc->NeedPageResetAfterTab(i) )
      74           0 :             nDisplayStart = 0;
      75             :         else
      76           0 :             nDisplayStart += nPages[i];
      77             :     }
      78           0 :     return nDisplayStart;
      79             : }
      80             : 
      81             : 
      82           0 : ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh ) :
      83             :     Window( pParent ),
      84             :     nPageNo( 0 ),
      85             :     nZoom( 100 ),
      86             :     nTabsTested( 0 ),
      87             :     nPages(),
      88             :     nFirstAttr(),
      89             :     nTab( 0 ),
      90             :     nTabStart( 0 ),
      91             :     nDisplayStart( 0 ),
      92             :     aDate( Date::SYSTEM ),
      93             :     aTime( Time::SYSTEM ),
      94             :     nTotalPages( 0 ),
      95             :     pLocationData( NULL ),
      96             :     pDrawView( NULL ),
      97             :     pDocShell( pDocSh ),
      98             :     pViewShell( pViewSh ),
      99             :     bInGetState( false ),
     100             :     bValid( false ),
     101             :     bStateValid( false ),
     102             :     bLocationValid( false ),
     103             :     bInPaint( false ),
     104             :     bInSetZoom( false ),
     105             :     bLeftRulerMove( false ),
     106             :     bRightRulerMove( false ),
     107             :     bTopRulerMove( false ),
     108             :     bBottomRulerMove( false ),
     109             :     bHeaderRulerMove( false ),
     110             :     bFooterRulerMove( false ),
     111             :     bLeftRulerChange( false ),
     112             :     bRightRulerChange( false ),
     113             :     bTopRulerChange( false ),
     114             :     bBottomRulerChange( false ),
     115             :     bHeaderRulerChange( false ),
     116             :     bFooterRulerChange( false ),
     117             :     bPageMargin ( false ),
     118             :     bColRulerMove( false ),
     119             :     mnScale( 0 ),
     120             :     nColNumberButttonDown( 0 ),
     121             :     nHeaderHeight ( 0 ),
     122           0 :     nFooterHeight ( 0 )
     123             : {
     124           0 :     SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW ); //#106611#
     125           0 :     SetBackground();
     126             : 
     127           0 :     SetHelpId( HID_SC_WIN_PREVIEW );
     128           0 :     SetUniqueId( HID_SC_WIN_PREVIEW );
     129             : 
     130           0 :     SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
     131             : 
     132           0 :     for (SCCOL i=0; i<=MAXCOL; i++)
     133           0 :         nRight[i] = 0;                  // initialized with actual positions when markers are drawn
     134           0 : }
     135             : 
     136             : 
     137           0 : ScPreview::~ScPreview()
     138             : {
     139           0 :     delete pDrawView;
     140           0 :     delete pLocationData;
     141           0 : }
     142             : 
     143           0 : void ScPreview::UpdateDrawView()        // nTab must be right
     144             : {
     145           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     146           0 :     ScDrawLayer* pModel = pDoc->GetDrawLayer();     // is not 0
     147             : 
     148             :     // #114135#
     149           0 :     if ( pModel )
     150             :     {
     151           0 :         SdrPage* pPage = pModel->GetPage(nTab);
     152           0 :         if ( pDrawView && ( !pDrawView->GetSdrPageView() || pDrawView->GetSdrPageView()->GetPage() != pPage ) )
     153             :         {
     154             :             //  die angezeigte Page der DrawView umzustellen (s.u.) funktioniert nicht ?!?
     155           0 :             delete pDrawView;
     156           0 :             pDrawView = NULL;
     157             :         }
     158             : 
     159           0 :         if ( !pDrawView )                                   // New Drawing?
     160             :         {
     161           0 :             pDrawView = new FmFormView( pModel, this );
     162             : 
     163             :             // The DrawView takes over the Design-Mode from the Model
     164             :             // (Settings "In opening Draftmode"), therefore to restore here
     165           0 :             pDrawView->SetDesignMode( true );
     166           0 :             pDrawView->SetPrintPreview( true );
     167           0 :             pDrawView->ShowSdrPage(pPage);
     168             :         }
     169             :     }
     170           0 :     else if ( pDrawView )
     171             :     {
     172           0 :         delete pDrawView;           // for this Chart is not needed
     173           0 :         pDrawView = NULL;
     174             :     }
     175           0 : }
     176             : 
     177             : 
     178           0 : void ScPreview::TestLastPage()
     179             : {
     180           0 :     if (nPageNo >= nTotalPages)
     181             :     {
     182           0 :         if (nTotalPages)
     183             :         {
     184           0 :             nPageNo = nTotalPages - 1;
     185           0 :             nTab = static_cast<SCTAB>(nPages.size()) -1;
     186           0 :             while (nTab > 0 && !nPages[nTab])       // not the last empty Table
     187           0 :                 --nTab;
     188             :             OSL_ENSURE(0 < static_cast<SCTAB>(nPages.size()),"are all tables empty?");
     189           0 :             nTabPage = nPages[nTab] - 1;
     190           0 :             nTabStart = 0;
     191           0 :             for (sal_uInt16 i=0; i<nTab; i++)
     192           0 :                 nTabStart += nPages[i];
     193             : 
     194           0 :             ScDocument* pDoc = pDocShell->GetDocument();
     195           0 :             nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
     196             :         }
     197             :         else        // empty Document
     198             :         {
     199           0 :             nTab = 0;
     200           0 :             nPageNo = nTabPage = nTabStart = nDisplayStart = 0;
     201           0 :             aState.nPrintTab = 0;
     202           0 :                         aState.nStartCol = aState.nEndCol = 0;
     203           0 :                         aState.nStartRow = aState.nEndRow = 0;
     204           0 :                         aState.nZoom = 0;
     205           0 :             aState.nPagesX = aState.nPagesY = 0;
     206             :             aState.nTabPages = aState.nTotalPages =
     207           0 :             aState.nPageStart = aState.nDocPages = 0;
     208             :         }
     209             :     }
     210           0 : }
     211             : 
     212             : 
     213           0 : void ScPreview::CalcPages()
     214             : {
     215           0 :     WaitObject aWait( this );
     216             : 
     217           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     218           0 :     nTabCount = pDoc->GetTableCount();
     219             : 
     220           0 :     SCTAB nStart = nTabsTested;
     221           0 :     if (!bValid)
     222             :     {
     223           0 :         nStart = 0;
     224           0 :         nTotalPages = 0;
     225           0 :         nTabsTested = 0;
     226             :     }
     227             : 
     228             :     // update all pending row heights with a single progress bar,
     229             :     // instead of a separate progress for each sheet from ScPrintFunc
     230           0 :     pDocShell->UpdatePendingRowHeights( nTabCount-1, true );
     231             : 
     232             :     //  PrintOptions is passed to PrintFunc for SkipEmpty flag,
     233             :     //  but always all sheets are used (there is no selected sheet)
     234           0 :     ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
     235             : 
     236           0 :     while (nStart > static_cast<SCTAB>(nPages.size()))
     237           0 :         nPages.push_back(0);
     238           0 :     while (nStart > static_cast<SCTAB>(nFirstAttr.size()))
     239           0 :         nFirstAttr.push_back(0);
     240             : 
     241           0 :     for (SCTAB i=nStart; i<nTabCount; i++)
     242             :     {
     243           0 :         if ( i == static_cast<SCTAB>(nPages.size()))
     244           0 :             nPages.push_back(0);
     245           0 :         if ( i == static_cast<SCTAB>(nFirstAttr.size()))
     246           0 :             nFirstAttr.push_back(0);
     247           0 :         if (!aOptions.GetAllSheets() && maSelectedTabs.count(i) == 0)
     248             :         {
     249           0 :             nPages[i] = 0;
     250           0 :             nFirstAttr[i] = 0;
     251           0 :             continue;
     252             :         }
     253             : 
     254           0 :         long nAttrPage = i > 0 ? nFirstAttr[i-1] : 1;
     255             : 
     256           0 :         long nThisStart = nTotalPages;
     257           0 :         ScPrintFunc aPrintFunc( this, pDocShell, i, nAttrPage, 0, NULL, &aOptions );
     258           0 :         long nThisTab = aPrintFunc.GetTotalPages();
     259           0 :         nPages[i] = nThisTab;
     260           0 :         nTotalPages += nThisTab;
     261           0 :         nFirstAttr[i] = aPrintFunc.GetFirstPageNo();    // to keep or from template
     262             : 
     263           0 :         if (nPageNo>=nThisStart && nPageNo<nTotalPages)
     264             :         {
     265           0 :             nTab = i;
     266           0 :             nTabPage = nPageNo - nThisStart;
     267           0 :             nTabStart = nThisStart;
     268             : 
     269           0 :             aPrintFunc.GetPrintState( aState );
     270           0 :             aPageSize = aPrintFunc.GetPageSize();
     271             :         }
     272           0 :     }
     273             : 
     274           0 :     nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
     275             : 
     276           0 :     if (nTabCount > nTabsTested)
     277           0 :         nTabsTested = nTabCount;
     278             : 
     279           0 :     TestLastPage();
     280             : 
     281           0 :     aState.nDocPages = nTotalPages;
     282             : 
     283           0 :     bValid = true;
     284           0 :     bStateValid = true;
     285           0 :     DoInvalidate();
     286           0 : }
     287             : 
     288             : 
     289           0 : void ScPreview::RecalcPages()                   // only nPageNo is changed
     290             : {
     291           0 :     if (!bValid)
     292           0 :         return;                         // then CalcPages is called
     293             : 
     294           0 :     SCTAB nOldTab = nTab;
     295             : 
     296           0 :     bool bDone = false;
     297           0 :     while (nPageNo >= nTotalPages && nTabsTested < nTabCount)
     298             :     {
     299           0 :         CalcPages();
     300           0 :         bDone = true;
     301             :     }
     302             : 
     303           0 :     if (!bDone)
     304             :     {
     305           0 :         long nPartPages = 0;
     306           0 :         for (SCTAB i=0; i<nTabsTested && nTab < static_cast<SCTAB>(nPages.size()); i++)
     307             :         {
     308           0 :             long nThisStart = nPartPages;
     309           0 :             nPartPages += nPages[i];
     310             : 
     311           0 :             if (nPageNo>=nThisStart && nPageNo<nPartPages)
     312             :             {
     313           0 :                 nTab = i;
     314           0 :                 nTabPage = nPageNo - nThisStart;
     315           0 :                 nTabStart = nThisStart;
     316             :             }
     317             :         }
     318             : 
     319           0 :         ScDocument* pDoc = pDocShell->GetDocument();
     320           0 :         nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
     321             :     }
     322             : 
     323           0 :     TestLastPage();         // to test, if after last page
     324             : 
     325           0 :     if ( nTab != nOldTab )
     326           0 :         bStateValid = false;
     327             : 
     328           0 :     DoInvalidate();
     329             : }
     330             : 
     331             : 
     332           0 : void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
     333             : {
     334           0 :     if (!bValid)
     335             :     {
     336           0 :         CalcPages();
     337           0 :         RecalcPages();
     338           0 :         UpdateDrawView();       // Spreedsheet eventually changes
     339             :     }
     340             : 
     341           0 :     Fraction aPreviewZoom( nZoom, 100 );
     342           0 :     Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
     343           0 :     MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
     344             : 
     345           0 :     bool bDoPrint = ( pFillLocation == NULL );
     346           0 :     bool bValidPage = ( nPageNo < nTotalPages );
     347             : 
     348           0 :     ScModule* pScMod = SC_MOD();
     349           0 :     const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
     350           0 :     Color aBackColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
     351             : 
     352           0 :     if ( bDoPrint && ( aOffset.X() < 0 || aOffset.Y() < 0 ) && bValidPage )
     353             :     {
     354           0 :         SetMapMode( aMMMode );
     355           0 :         SetLineColor();
     356           0 :         SetFillColor(aBackColor);
     357             : 
     358           0 :         Size aWinSize = GetOutputSize();
     359           0 :         if ( aOffset.X() < 0 )
     360           0 :             DrawRect(Rectangle( 0, 0, -aOffset.X(), aWinSize.Height() ));
     361           0 :         if ( aOffset.Y() < 0 )
     362           0 :             DrawRect(Rectangle( 0, 0, aWinSize.Width(), -aOffset.Y() ));
     363             :     }
     364             : 
     365           0 :     long   nLeftMargin = 0;
     366           0 :     long   nRightMargin = 0;
     367           0 :     long   nTopMargin = 0;
     368           0 :     long   nBottomMargin = 0;
     369           0 :     bool   bHeaderOn = false;
     370           0 :     bool   bFooterOn = false;
     371             : 
     372           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     373           0 :     bool   bLayoutRTL = pDoc->IsLayoutRTL( nTab );
     374             : 
     375           0 :     Size aLocalPageSize;
     376           0 :     if ( bValidPage )
     377             :     {
     378           0 :         ScPrintOptions aOptions = pScMod->GetPrintOptions();
     379             : 
     380             :         ScPrintFunc* pPrintFunc;
     381           0 :         if (bStateValid)
     382           0 :             pPrintFunc = new ScPrintFunc( this, pDocShell, aState, &aOptions );
     383             :         else
     384           0 :             pPrintFunc = new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
     385             : 
     386           0 :         pPrintFunc->SetOffset(aOffset);
     387           0 :         pPrintFunc->SetManualZoom(nZoom);
     388           0 :         pPrintFunc->SetDateTime(aDate,aTime);
     389           0 :         pPrintFunc->SetClearFlag(true);
     390           0 :         pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() );
     391             : 
     392           0 :         pPrintFunc->SetDrawView( pDrawView );
     393             : 
     394             :         // MultiSelection for the one Page must produce something inconvenient
     395           0 :         Range aPageRange( nPageNo+1, nPageNo+1 );
     396           0 :         MultiSelection aPage( aPageRange );
     397           0 :         aPage.SetTotalRange( Range(0,RANGE_MAX) );
     398           0 :         aPage.Select( aPageRange );
     399             : 
     400           0 :         long nPrinted = pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart, bDoPrint, pFillLocation );
     401             :         OSL_ENSURE(nPrinted<=1, "was'n nu los?");
     402             : 
     403           0 :         SetMapMode(aMMMode);
     404             : 
     405             :         //init nLeftMargin ... in the ScPrintFunc::InitParam!!!
     406           0 :         nLeftMargin = pPrintFunc->GetLeftMargin();
     407           0 :         nRightMargin = pPrintFunc->GetRightMargin();
     408           0 :         nTopMargin = pPrintFunc->GetTopMargin();
     409           0 :         nBottomMargin = pPrintFunc->GetBottomMargin();
     410           0 :         nHeaderHeight = pPrintFunc->GetHeader().nHeight;
     411           0 :         nFooterHeight = pPrintFunc->GetFooter().nHeight;
     412           0 :         bHeaderOn = pPrintFunc->GetHeader().bEnable;
     413           0 :         bFooterOn = pPrintFunc->GetFooter().bEnable;
     414           0 :         mnScale = pPrintFunc->GetZoom();
     415             : 
     416           0 :         if ( bDoPrint && bPageMargin && pLocationData )     // don't make use of pLocationData while filling it
     417             :         {
     418           0 :             Rectangle aPixRect;
     419           0 :             Rectangle aRectCellPosition;
     420           0 :             Rectangle aRectPosition;
     421           0 :             pLocationData->GetMainCellRange( aPageArea, aPixRect );
     422           0 :             if( !bLayoutRTL )
     423             :             {
     424           0 :                 pLocationData->GetCellPosition( aPageArea.aStart, aRectPosition );
     425           0 :                 nLeftPosition = aRectPosition.Left();
     426           0 :                 for( SCCOL i = aPageArea.aStart.Col(); i <= aPageArea.aEnd.Col(); i++ )
     427             :                 {
     428           0 :                     pLocationData->GetCellPosition( ScAddress( i,aPageArea.aStart.Row(),aPageArea.aStart.Tab()),aRectCellPosition );
     429           0 :                     nRight[i] = aRectCellPosition.Right();
     430             :                 }
     431             :             }
     432             :             else
     433             :             {
     434           0 :                 pLocationData->GetCellPosition( aPageArea.aEnd, aRectPosition );
     435           0 :                 nLeftPosition = aRectPosition.Right()+1;
     436             : 
     437           0 :                 pLocationData->GetCellPosition( aPageArea.aStart,aRectCellPosition );
     438           0 :                 nRight[ aPageArea.aEnd.Col() ] = aRectCellPosition.Left();
     439           0 :                 for( SCCOL i = aPageArea.aEnd.Col(); i > aPageArea.aStart.Col(); i-- )
     440             :                 {
     441           0 :                     pLocationData->GetCellPosition( ScAddress( i,aPageArea.aEnd.Row(),aPageArea.aEnd.Tab()),aRectCellPosition );
     442           0 :                     nRight[ i-1 ] = nRight[ i ] + aRectCellPosition.Right() - aRectCellPosition.Left() + 1;
     443             :                 }
     444             :             }
     445             :         }
     446             : 
     447           0 :         if (nPrinted)   // if not, draw everything grey
     448             :         {
     449           0 :             aLocalPageSize = pPrintFunc->GetPageSize();
     450           0 :             aLocalPageSize.Width()  = (long) (aLocalPageSize.Width()  * HMM_PER_TWIPS );
     451           0 :             aLocalPageSize.Height() = (long) (aLocalPageSize.Height() * HMM_PER_TWIPS );
     452             : 
     453           0 :             nLeftMargin = (long) ( nLeftMargin * HMM_PER_TWIPS );
     454           0 :             nRightMargin = (long) ( nRightMargin * HMM_PER_TWIPS );
     455           0 :             nTopMargin = (long) ( nTopMargin * HMM_PER_TWIPS );
     456           0 :             nBottomMargin = (long) ( nBottomMargin * HMM_PER_TWIPS );
     457           0 :             nHeaderHeight = (long) ( nHeaderHeight * HMM_PER_TWIPS * mnScale / 100 + nTopMargin );
     458           0 :             nFooterHeight = (long) ( nFooterHeight * HMM_PER_TWIPS * mnScale / 100 + nBottomMargin );
     459             :         }
     460             : 
     461           0 :         if (!bStateValid)
     462             :         {
     463           0 :             pPrintFunc->GetPrintState( aState );
     464           0 :             aState.nDocPages = nTotalPages;
     465           0 :             bStateValid = true;
     466             :         }
     467           0 :         delete pPrintFunc;
     468             :     }
     469             : 
     470           0 :     if ( bDoPrint )
     471             :     {
     472           0 :         long nPageEndX = aLocalPageSize.Width()  - aOffset.X();
     473           0 :         long nPageEndY = aLocalPageSize.Height() - aOffset.Y();
     474           0 :         if ( !bValidPage )
     475           0 :             nPageEndX = nPageEndY = 0;
     476             : 
     477           0 :         Size aWinSize = GetOutputSize();
     478           0 :         Point aWinEnd( aWinSize.Width(), aWinSize.Height() );
     479           0 :         bool bRight  = nPageEndX <= aWinEnd.X();
     480           0 :         bool bBottom = nPageEndY <= aWinEnd.Y();
     481             : 
     482           0 :         if( bPageMargin && bValidPage )
     483             :         {
     484           0 :             SetMapMode(aMMMode);
     485           0 :             SetLineColor( COL_BLACK );
     486           0 :             DrawInvert( (long)( nTopMargin - aOffset.Y() ), POINTER_VSIZEBAR );
     487           0 :             DrawInvert( (long)(nPageEndY - nBottomMargin ), POINTER_VSIZEBAR );
     488           0 :             DrawInvert( (long)( nLeftMargin - aOffset.X() ), POINTER_HSIZEBAR );
     489           0 :             DrawInvert( (long)( nPageEndX - nRightMargin ) , POINTER_HSIZEBAR );
     490           0 :             if( bHeaderOn )
     491             :             {
     492           0 :                 DrawInvert( nHeaderHeight - aOffset.Y(), POINTER_VSIZEBAR );
     493             :             }
     494           0 :             if( bFooterOn )
     495             :             {
     496           0 :                 DrawInvert( nPageEndY - nFooterHeight, POINTER_VSIZEBAR );
     497             :             }
     498             : 
     499           0 :             SetMapMode( MapMode( MAP_PIXEL ) );
     500           0 :             for( int i= aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
     501             :             {
     502           0 :                 Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
     503           0 :                 SetLineColor( COL_BLACK );
     504           0 :                 SetFillColor( COL_BLACK );
     505           0 :                 DrawRect( Rectangle( Point( nRight[i] - 2, aColumnTop.Y() ),Point( nRight[i] + 2 , 4 + aColumnTop.Y()) ));
     506           0 :                 DrawLine( Point( nRight[i], aColumnTop.Y() ), Point( nRight[i],  10 + aColumnTop.Y()) );
     507             :             }
     508           0 :             SetMapMode( aMMMode );
     509             :         }
     510             : 
     511           0 :         if (bRight || bBottom)
     512             :         {
     513           0 :             SetMapMode(aMMMode);
     514           0 :             SetLineColor();
     515           0 :             SetFillColor(aBackColor);
     516           0 :             if (bRight)
     517           0 :                 DrawRect(Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y()));
     518           0 :             if (bBottom)
     519             :             {
     520           0 :                 if (bRight)
     521           0 :                     DrawRect(Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y()));    // Corner not duplicated
     522             :                 else
     523           0 :                     DrawRect(Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y()));
     524             :             }
     525             :         }
     526             : 
     527           0 :         if ( bValidPage )
     528             :         {
     529           0 :             Color aBorderColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
     530             : 
     531             :             //  draw border
     532             : 
     533           0 :             if ( aOffset.X() <= 0 || aOffset.Y() <= 0 || bRight || bBottom )
     534             :             {
     535           0 :                 SetLineColor( aBorderColor );
     536           0 :                 SetFillColor();
     537             : 
     538           0 :                 Rectangle aPixel( LogicToPixel( Rectangle( -aOffset.X(), -aOffset.Y(), nPageEndX, nPageEndY ) ) );
     539           0 :                 --aPixel.Right();
     540           0 :                 --aPixel.Bottom();
     541           0 :                 DrawRect( PixelToLogic( aPixel ) );
     542             :             }
     543             : 
     544             :             //  draw shadow
     545             : 
     546           0 :             SetLineColor();
     547           0 :             SetFillColor( aBorderColor );
     548             : 
     549           0 :             Rectangle aPixel;
     550             : 
     551           0 :             aPixel = LogicToPixel( Rectangle( nPageEndX, -aOffset.Y(), nPageEndX, nPageEndY ) );
     552           0 :             aPixel.Top() += SC_PREVIEW_SHADOWSIZE;
     553           0 :             aPixel.Right() += SC_PREVIEW_SHADOWSIZE - 1;
     554           0 :             aPixel.Bottom() += SC_PREVIEW_SHADOWSIZE - 1;
     555           0 :             DrawRect( PixelToLogic( aPixel ) );
     556             : 
     557           0 :             aPixel = LogicToPixel( Rectangle( -aOffset.X(), nPageEndY, nPageEndX, nPageEndY ) );
     558           0 :             aPixel.Left() += SC_PREVIEW_SHADOWSIZE;
     559           0 :             aPixel.Right() += SC_PREVIEW_SHADOWSIZE - 1;
     560           0 :             aPixel.Bottom() += SC_PREVIEW_SHADOWSIZE - 1;
     561           0 :             DrawRect( PixelToLogic( aPixel ) );
     562             :         }
     563           0 :     }
     564           0 : }
     565             : 
     566           0 : void ScPreview::Paint( const Rectangle& /* rRect */ )
     567             : {
     568           0 :     bool bWasInPaint = bInPaint;        // nested calls shouldn't be necessary, but allow for now
     569           0 :     bInPaint = true;
     570             : 
     571           0 :     if (bPageMargin)
     572           0 :         GetLocationData();              // fill location data for column positions
     573           0 :     DoPrint( NULL );
     574           0 :     pViewShell->UpdateScrollBars();
     575             : 
     576           0 :     bInPaint = bWasInPaint;
     577           0 : }
     578             : 
     579           0 : void ScPreview::Command( const CommandEvent& rCEvt )
     580             : {
     581           0 :     sal_uInt16 nCmd = rCEvt.GetCommand();
     582           0 :     if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL )
     583             :     {
     584           0 :         bool bDone = pViewShell->ScrollCommand( rCEvt );
     585           0 :         if (!bDone)
     586           0 :             Window::Command(rCEvt);
     587             :     }
     588           0 :     else if ( nCmd == COMMAND_CONTEXTMENU )
     589           0 :         SfxDispatcher::ExecutePopup();
     590             :     else
     591           0 :         Window::Command( rCEvt );
     592           0 : }
     593             : 
     594             : 
     595           0 : void ScPreview::KeyInput( const KeyEvent& rKEvt )
     596             : {
     597             :     //  The + and - keys can't be configured as accelerator entries, so they must be handled directly
     598             :     //  (in ScPreview, not ScPreviewShell -> only if the preview window has the focus)
     599             : 
     600           0 :     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
     601           0 :     sal_uInt16 nKey = rKeyCode.GetCode();
     602           0 :     bool bHandled = false;
     603           0 :     if(!rKeyCode.GetModifier())
     604             :     {
     605           0 :         sal_uInt16 nSlot = 0;
     606           0 :         switch(nKey)
     607             :         {
     608           0 :             case KEY_ADD:      nSlot = SID_PREVIEW_ZOOMIN;  break;
     609           0 :             case KEY_ESCAPE:   nSlot = ScViewUtil::IsFullScreen( *pViewShell ) ? SID_CANCEL : SID_PREVIEW_CLOSE; break;
     610           0 :             case KEY_SUBTRACT: nSlot = SID_PREVIEW_ZOOMOUT; break;
     611             :         }
     612           0 :         if(nSlot)
     613             :         {
     614           0 :             bHandled = true;
     615           0 :             pViewShell->GetViewFrame()->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_ASYNCHRON );
     616             :         }
     617             :     }
     618             : 
     619           0 :     if ( !bHandled && !pViewShell->KeyInput(rKEvt) )
     620           0 :         Window::KeyInput(rKEvt);
     621           0 : }
     622             : 
     623             : 
     624           0 : const ScPreviewLocationData& ScPreview::GetLocationData()
     625             : {
     626           0 :     if ( !pLocationData )
     627             :     {
     628           0 :         pLocationData = new ScPreviewLocationData( pDocShell->GetDocument(), this );
     629           0 :         bLocationValid = false;
     630             :     }
     631           0 :     if ( !bLocationValid )
     632             :     {
     633           0 :         pLocationData->Clear();
     634           0 :         DoPrint( pLocationData );
     635           0 :         bLocationValid = true;
     636             :     }
     637           0 :     return *pLocationData;
     638             : }
     639             : 
     640             : 
     641           0 : void ScPreview::DataChanged(bool bNewTime)
     642             : {
     643           0 :     if (bNewTime)
     644             :     {
     645           0 :         aDate = Date( Date::SYSTEM );
     646           0 :         aTime = Time( Time::SYSTEM );
     647             :     }
     648             : 
     649           0 :     bValid = false;
     650           0 :     InvalidateLocationData( SC_HINT_DATACHANGED );
     651           0 :     Invalidate();
     652           0 : }
     653             : 
     654             : 
     655           0 : String ScPreview::GetPosString()
     656             : {
     657           0 :     if (!bValid)
     658             :     {
     659           0 :         CalcPages();
     660           0 :         UpdateDrawView();       // The table eventually changes
     661             :     }
     662             : 
     663           0 :     String aString( ScGlobal::GetRscString( STR_PAGE ) );
     664           0 :     aString += ' ';
     665           0 :     aString += String::CreateFromInt32(nPageNo+1);
     666             : 
     667           0 :     if (nTabsTested >= nTabCount)
     668             :     {
     669           0 :         aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
     670           0 :         aString += String::CreateFromInt32(nTotalPages);
     671             :     }
     672             : 
     673           0 :     return aString;
     674             : }
     675             : 
     676             : 
     677           0 : void ScPreview::SetZoom(sal_uInt16 nNewZoom)
     678             : {
     679           0 :     if (nNewZoom < 20)
     680           0 :         nNewZoom = 20;
     681           0 :     if (nNewZoom > 400)
     682           0 :         nNewZoom = 400;
     683           0 :     if (nNewZoom != nZoom)
     684             :     {
     685           0 :         nZoom = nNewZoom;
     686             : 
     687             :         //  apply new MapMode and call UpdateScrollBars to update aOffset
     688             : 
     689           0 :         Fraction aPreviewZoom( nZoom, 100 );
     690           0 :         Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
     691           0 :         MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
     692           0 :         SetMapMode( aMMMode );
     693             : 
     694           0 :         bInSetZoom = true;              // don't scroll during SetYOffset in UpdateScrollBars
     695           0 :         pViewShell->UpdateNeededScrollBars(true);
     696           0 :         bInSetZoom = false;
     697             : 
     698           0 :         bStateValid = false;
     699           0 :         InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
     700           0 :         DoInvalidate();
     701           0 :         Invalidate();
     702             :     }
     703           0 : }
     704             : 
     705             : 
     706           0 : void ScPreview::SetPageNo( long nPage )
     707             : {
     708           0 :     nPageNo = nPage;
     709           0 :     RecalcPages();
     710           0 :     UpdateDrawView();       // The table eventually changes
     711           0 :     InvalidateLocationData( SC_HINT_DATACHANGED );
     712           0 :     Invalidate();
     713           0 : }
     714             : 
     715             : 
     716           0 : long ScPreview::GetFirstPage(SCTAB nTabP)
     717             : {
     718           0 :     SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount();
     719           0 :     if (nTabP >= nDocTabCount)
     720           0 :         nTabP = nDocTabCount-1;
     721             : 
     722           0 :     long nPage = 0;
     723           0 :     if (nTabP>0)
     724             :     {
     725           0 :         CalcPages();
     726           0 :         if (nTabP >= static_cast<SCTAB>(nPages.size()) )
     727             :             OSL_FAIL("nPages out ouf bounds, FIX IT");
     728           0 :         UpdateDrawView();       // The table eventually changes
     729             : 
     730           0 :         for (SCTAB i=0; i<nTabP; i++)
     731           0 :             nPage += nPages[i];
     732             : 
     733             :         // An empty Table on the previous Page
     734             : 
     735           0 :         if ( nPages[nTabP]==0 && nPage > 0 )
     736           0 :             --nPage;
     737             :     }
     738             : 
     739           0 :     return nPage;
     740             : }
     741             : 
     742             : 
     743           0 : static Size lcl_GetDocPageSize( ScDocument* pDoc, SCTAB nTab )
     744             : {
     745           0 :     String aName = pDoc->GetPageStyle( nTab );
     746           0 :     ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
     747           0 :     SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aName, SFX_STYLE_FAMILY_PAGE );
     748           0 :     if ( pStyleSheet )
     749             :     {
     750           0 :         SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
     751           0 :         return ((const SvxSizeItem&) rStyleSet.Get(ATTR_PAGE_SIZE)).GetSize();
     752             :     }
     753             :     else
     754             :     {
     755             :         OSL_FAIL( "PageStyle not found" );
     756           0 :         return Size();
     757           0 :     }
     758             : }
     759             : 
     760             : 
     761           0 : sal_uInt16 ScPreview::GetOptimalZoom(bool bWidthOnly)
     762             : {
     763           0 :     double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor();
     764           0 :     double nWinScaleY = ScGlobal::nScreenPPTY;
     765           0 :     Size aWinSize = GetOutputSizePixel();
     766             : 
     767             :     //  desired margin is 0.25cm in default MapMode (like Writer),
     768             :     //  but some additional margin is introduced by integer scale values
     769             :     //  -> add only 0.10cm, so there is some margin in all cases.
     770           0 :     Size aMarginSize( LogicToPixel( Size( 100, 100 ), MAP_100TH_MM ) );
     771           0 :     aWinSize.Width()  -= 2 * aMarginSize.Width();
     772           0 :     aWinSize.Height() -= 2 * aMarginSize.Height();
     773             : 
     774           0 :     Size aLocalPageSize = lcl_GetDocPageSize( pDocShell->GetDocument(), nTab );
     775           0 :     if ( aLocalPageSize.Width() && aLocalPageSize.Height() )
     776             :     {
     777           0 :         long nZoomX = (long) ( aWinSize.Width() * 100  / ( aLocalPageSize.Width() * nWinScaleX ));
     778           0 :         long nZoomY = (long) ( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY ));
     779             : 
     780           0 :         long nOptimal = nZoomX;
     781           0 :         if (!bWidthOnly && nZoomY<nOptimal)
     782           0 :             nOptimal = nZoomY;
     783             : 
     784           0 :         if (nOptimal<20)
     785           0 :             nOptimal = 20;
     786           0 :         if (nOptimal>400)
     787           0 :             nOptimal = 400;
     788             : 
     789           0 :         return (sal_uInt16) nOptimal;
     790             :     }
     791             :     else
     792           0 :         return nZoom;
     793             : }
     794             : 
     795             : 
     796           0 : void ScPreview::SetXOffset( long nX )
     797             : {
     798           0 :     if ( aOffset.X() == nX )
     799           0 :         return;
     800             : 
     801           0 :     if (bValid)
     802             :     {
     803           0 :         long nDif = LogicToPixel(aOffset).X() - LogicToPixel(Point(nX,0)).X();
     804           0 :         aOffset.X() = nX;
     805           0 :         if (nDif && !bInSetZoom)
     806             :         {
     807           0 :             MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL);
     808           0 :             Scroll( nDif, 0 );
     809           0 :             SetMapMode(aOldMode);
     810             :         }
     811             :     }
     812             :     else
     813             :     {
     814           0 :         aOffset.X() = nX;
     815           0 :         if (!bInSetZoom)
     816           0 :             Invalidate();
     817             :     }
     818           0 :     InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
     819           0 :     Paint(Rectangle());
     820             : }
     821             : 
     822             : 
     823           0 : void ScPreview::SetYOffset( long nY )
     824             : {
     825           0 :     if ( aOffset.Y() == nY )
     826           0 :         return;
     827             : 
     828           0 :     if (bValid)
     829             :     {
     830           0 :         long nDif = LogicToPixel(aOffset).Y() - LogicToPixel(Point(0,nY)).Y();
     831           0 :         aOffset.Y() = nY;
     832           0 :         if (nDif && !bInSetZoom)
     833             :         {
     834           0 :             MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL);
     835           0 :             Scroll( 0, nDif );
     836           0 :             SetMapMode(aOldMode);
     837             :         }
     838             :     }
     839             :     else
     840             :     {
     841           0 :         aOffset.Y() = nY;
     842           0 :         if (!bInSetZoom)
     843           0 :             Invalidate();
     844             :     }
     845           0 :     InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
     846           0 :     Paint(Rectangle());
     847             : }
     848             : 
     849             : 
     850           0 : void ScPreview::DoInvalidate()
     851             : {
     852             :     //  If the whole GetState of the shell is called
     853             :     //  The Invalidate must come behind asynchronously
     854             :  
     855           0 :    if (bInGetState)
     856           0 :         Application::PostUserEvent( STATIC_LINK( this, ScPreview, InvalidateHdl ) );
     857             :     else
     858           0 :         StaticInvalidate();     // Immediately
     859           0 : }
     860             : 
     861           0 : void ScPreview::StaticInvalidate()
     862             : {
     863             :     //  static method, because it's called asynchronously
     864             :     //  -> must use current viewframe
     865             : 
     866           0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     867           0 :     if (!pViewFrm)
     868           0 :         return;
     869             : 
     870           0 :     SfxBindings& rBindings = pViewFrm->GetBindings();
     871           0 :     rBindings.Invalidate(SID_STATUS_DOCPOS);
     872           0 :     rBindings.Invalidate(SID_STATUS_PAGESTYLE);
     873           0 :     rBindings.Invalidate(SID_PREVIEW_PREVIOUS);
     874           0 :     rBindings.Invalidate(SID_PREVIEW_NEXT);
     875           0 :     rBindings.Invalidate(SID_PREVIEW_FIRST);
     876           0 :     rBindings.Invalidate(SID_PREVIEW_LAST);
     877           0 :     rBindings.Invalidate(SID_ATTR_ZOOM);
     878           0 :     rBindings.Invalidate(SID_PREVIEW_ZOOMIN);
     879           0 :     rBindings.Invalidate(SID_PREVIEW_ZOOMOUT);
     880           0 :     rBindings.Invalidate(SID_PREVIEW_SCALINGFACTOR);
     881           0 :     rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
     882             : }
     883             : 
     884           0 : IMPL_STATIC_LINK( ScPreview, InvalidateHdl, void*, EMPTYARG )
     885             : {
     886             :     (void)pThis;    // avoid warning
     887             : 
     888           0 :     StaticInvalidate();
     889           0 :     return 0;
     890             : }
     891             : 
     892           0 : void ScPreview::DataChanged( const DataChangedEvent& rDCEvt )
     893             : {
     894           0 :     Window::DataChanged(rDCEvt);
     895             : 
     896           0 :     if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
     897           0 :          (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
     898           0 :          (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     899           0 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     900           0 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     901           0 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     902             :     {
     903           0 :         if ( rDCEvt.GetType() == DATACHANGED_FONTS )
     904           0 :             pDocShell->UpdateFontList();
     905             : 
     906             :         // #i114518# Paint of form controls may modify the window's settings.
     907             :         // Ignore the event if it is called from within Paint.
     908           0 :         if ( !bInPaint )
     909             :         {
     910           0 :             if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
     911           0 :                   (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     912             :             {
     913             :                 //  scroll bar size may have changed
     914           0 :                 pViewShell->InvalidateBorder();     // calls OuterResizePixel
     915             :             }
     916           0 :             Invalidate();
     917           0 :             InvalidateLocationData( SC_HINT_DATACHANGED );
     918             :         }
     919             :     }
     920           0 : }
     921             : 
     922           0 : void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
     923             : {
     924           0 :     Fraction  aPreviewZoom( nZoom, 100 );
     925           0 :     Fraction  aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
     926           0 :     MapMode   aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
     927             : 
     928           0 :     aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
     929           0 :     aButtonDownPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
     930             : 
     931           0 :     CaptureMouse();
     932             : 
     933           0 :     if( rMEvt.IsLeft() && GetPointer() == POINTER_HSIZEBAR )
     934             :     {
     935           0 :         SetMapMode( aMMMode );
     936           0 :         if( bLeftRulerChange )
     937             :         {
     938           0 :            DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
     939           0 :            bLeftRulerMove = true;
     940           0 :            bRightRulerMove = false;
     941             :         }
     942           0 :         else if( bRightRulerChange )
     943             :         {
     944           0 :            DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
     945           0 :            bLeftRulerMove = false;
     946           0 :            bRightRulerMove = true;
     947             :         }
     948             :     }
     949             : 
     950           0 :     if( rMEvt.IsLeft() && GetPointer() == POINTER_VSIZEBAR )
     951             :     {
     952           0 :         SetMapMode( aMMMode );
     953           0 :         if( bTopRulerChange )
     954             :         {
     955           0 :             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
     956           0 :             bTopRulerMove = true;
     957           0 :             bBottomRulerMove = false;
     958             :         }
     959           0 :         else if( bBottomRulerChange )
     960             :         {
     961           0 :             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
     962           0 :             bTopRulerMove = false;
     963           0 :             bBottomRulerMove = true;
     964             :         }
     965           0 :         else if( bHeaderRulerChange )
     966             :         {
     967           0 :             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
     968           0 :             bHeaderRulerMove = true;
     969           0 :             bFooterRulerMove = false;
     970             :         }
     971           0 :         else if( bFooterRulerChange )
     972             :         {
     973           0 :             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
     974           0 :             bHeaderRulerMove = false;
     975           0 :             bFooterRulerMove = true;
     976             :         }
     977             :     }
     978             : 
     979           0 :     if( rMEvt.IsLeft() && GetPointer() == POINTER_HSPLIT )
     980             :     {
     981           0 :         Point  aNowPt = rMEvt.GetPosPixel();
     982           0 :         SCCOL i = 0;
     983           0 :         for( i = aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
     984             :         {
     985           0 :             if( aNowPt.X() < nRight[i] + 2 && aNowPt.X() > nRight[i] - 2 )
     986             :             {
     987           0 :                 nColNumberButttonDown = i;
     988           0 :                 break;
     989             :             }
     990             :         }
     991           0 :         if( i == aPageArea.aEnd.Col()+1 )
     992           0 :             return;
     993             : 
     994           0 :         SetMapMode( aMMMode );
     995           0 :         if( nColNumberButttonDown == aPageArea.aStart.Col() )
     996           0 :             DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,POINTER_HSPLIT );
     997             :         else
     998           0 :             DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
     999             : 
    1000           0 :         DrawInvert( aButtonDownChangePoint.X(), POINTER_HSPLIT );
    1001           0 :         bColRulerMove = true;
    1002           0 :     }
    1003             : }
    1004             : 
    1005           0 : void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
    1006             : {
    1007           0 :         Fraction  aPreviewZoom( nZoom, 100 );
    1008           0 :         Fraction  aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
    1009           0 :         MapMode   aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
    1010             : 
    1011           0 :         aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
    1012             : 
    1013           0 :         long  nWidth = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width();
    1014           0 :         long  nHeight = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height();
    1015             : 
    1016           0 :         if( rMEvt.IsLeft() && GetPointer() == POINTER_HSIZEBAR )
    1017             :         {
    1018           0 :             SetPointer( Pointer( POINTER_ARROW ) );
    1019             : 
    1020           0 :             bool bMoveRulerAction= true;
    1021             : 
    1022           0 :             ScDocument * pDoc = pDocShell->GetDocument();
    1023           0 :             String   aOldName = pDoc->GetPageStyle( nTab );
    1024           0 :             bool bUndo = pDoc->IsUndoEnabled();
    1025           0 :             ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
    1026           0 :             SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
    1027             : 
    1028           0 :             if ( pStyleSheet )
    1029             :             {
    1030           0 :                 ScStyleSaveData aOldData;
    1031           0 :                 if( bUndo )
    1032           0 :                     aOldData.InitFromStyle( pStyleSheet );
    1033             : 
    1034           0 :                 SfxItemSet&  rStyleSet = pStyleSheet->GetItemSet();
    1035             : 
    1036           0 :                 SvxLRSpaceItem aLRItem = ( const SvxLRSpaceItem& ) rStyleSet.Get( ATTR_LRSPACE );
    1037             : 
    1038           0 :                 if(( bLeftRulerChange || bRightRulerChange ) && ( aButtonUpPt.X() <= ( 0 - aOffset.X() ) || aButtonUpPt.X() > nWidth * HMM_PER_TWIPS - aOffset.X() ) )
    1039             :                 {
    1040           0 :                     bMoveRulerAction = false;
    1041           0 :                     Paint(Rectangle(0,0,10000,10000));
    1042             :                 }
    1043           0 :                 else if( bLeftRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS > nWidth - aLRItem.GetRight() - aOffset.X() / HMM_PER_TWIPS ) )
    1044             :                 {
    1045           0 :                     bMoveRulerAction = false;
    1046           0 :                     Paint(Rectangle(0,0,10000,10000));
    1047             :                 }
    1048           0 :                 else if( bRightRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS < aLRItem.GetLeft() - aOffset.X() / HMM_PER_TWIPS ) )
    1049             :                 {
    1050           0 :                     bMoveRulerAction = false;
    1051           0 :                     Paint(Rectangle(0,0,10000,10000));
    1052             :                 }
    1053           0 :                 else if( aButtonDownPt.X() == aButtonUpPt.X() )
    1054             :                 {
    1055           0 :                     bMoveRulerAction = false;
    1056           0 :                     DrawInvert( aButtonUpPt.X(), POINTER_HSIZEBAR );
    1057             :                 }
    1058           0 :                 if( bMoveRulerAction )
    1059             :                 {
    1060           0 :                     ScDocShellModificator aModificator( *pDocShell );
    1061           0 :                     if( bLeftRulerChange && bLeftRulerMove )
    1062             :                     {
    1063           0 :                        aLRItem.SetLeft( (long)( aButtonUpPt.X() / HMM_PER_TWIPS + aOffset.X() / HMM_PER_TWIPS ));
    1064           0 :                        rStyleSet.Put( aLRItem );
    1065           0 :                        pDocShell->SetModified(true);
    1066             :                     }
    1067           0 :                     else if( bRightRulerChange && bRightRulerMove )
    1068             :                     {
    1069           0 :                         aLRItem.SetRight( (long)( nWidth - aButtonUpPt.X() / HMM_PER_TWIPS - aOffset.X() / HMM_PER_TWIPS ));
    1070           0 :                         rStyleSet.Put( aLRItem );
    1071           0 :                         pDocShell->SetModified(true);
    1072             :                     }
    1073             : 
    1074           0 :                     ScStyleSaveData aNewData;
    1075           0 :                     aNewData.InitFromStyle( pStyleSheet );
    1076           0 :                     if( bUndo )
    1077             :                     {
    1078           0 :                         pDocShell->GetUndoManager()->AddUndoAction(
    1079             :                             new ScUndoModifyStyle( pDocShell, SFX_STYLE_FAMILY_PAGE,
    1080           0 :                             aOldData, aNewData ) );
    1081             :                     }
    1082             : 
    1083           0 :                     if ( ValidTab( nTab ) )
    1084             :                     {
    1085           0 :                         ScPrintFunc aPrintFunc( this, pDocShell, nTab );
    1086           0 :                         aPrintFunc.UpdatePages();
    1087             :                     }
    1088             : 
    1089           0 :                     Rectangle aRect(0,0,10000,10000);
    1090           0 :                     Paint( aRect );
    1091           0 :                     aModificator.SetDocumentModified();
    1092           0 :                     bLeftRulerChange = false;
    1093           0 :                     bRightRulerChange = false;
    1094           0 :                 }
    1095             :             }
    1096           0 :             bLeftRulerMove = false;
    1097           0 :             bRightRulerMove = false;
    1098             :         }
    1099             : 
    1100           0 :         if( rMEvt.IsLeft() && GetPointer() == POINTER_VSIZEBAR )
    1101             :         {
    1102           0 :             SetPointer( POINTER_ARROW );
    1103             : 
    1104           0 :             bool bMoveRulerAction = true;
    1105           0 :             if( ( bTopRulerChange || bBottomRulerChange || bHeaderRulerChange || bFooterRulerChange ) && ( aButtonUpPt.Y() <= ( 0 - aOffset.Y() ) || aButtonUpPt.Y() > nHeight * HMM_PER_TWIPS -aOffset.Y() ) )
    1106             :             {
    1107           0 :                 bMoveRulerAction = false;
    1108           0 :                 Paint( Rectangle(0,0,10000,10000) );
    1109             :             }
    1110           0 :             else if( aButtonDownPt.Y() == aButtonUpPt.Y() )
    1111             :             {
    1112           0 :                 bMoveRulerAction = false;
    1113           0 :                 DrawInvert( aButtonUpPt.Y(), POINTER_VSIZEBAR );
    1114             :             }
    1115           0 :             if( bMoveRulerAction )
    1116             :             {
    1117           0 :                 ScDocument * pDoc = pDocShell->GetDocument();
    1118           0 :                 bool bUndo = pDoc->IsUndoEnabled();
    1119           0 :                 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
    1120           0 :                 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
    1121             :                 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
    1122           0 :                 if ( pStyleSheet )
    1123             :                 {
    1124           0 :                     ScDocShellModificator aModificator( *pDocShell );
    1125           0 :                     ScStyleSaveData aOldData;
    1126           0 :                     if( bUndo )
    1127           0 :                         aOldData.InitFromStyle( pStyleSheet );
    1128             : 
    1129           0 :                     SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
    1130             : 
    1131           0 :                     SvxULSpaceItem aULItem = ( const SvxULSpaceItem&)rStyleSet.Get( ATTR_ULSPACE );
    1132             : 
    1133           0 :                     if( bTopRulerMove && bTopRulerChange )
    1134             :                     {
    1135           0 :                         aULItem.SetUpperValue( (sal_uInt16)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS ) );
    1136           0 :                         rStyleSet.Put( aULItem );
    1137           0 :                         pDocShell->SetModified(true);
    1138             :                     }
    1139           0 :                     else if( bBottomRulerMove && bBottomRulerChange )
    1140             :                     {
    1141           0 :                         aULItem.SetLowerValue( (sal_uInt16)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS ) );
    1142           0 :                         rStyleSet.Put( aULItem );
    1143           0 :                         pDocShell->SetModified(true);
    1144             :                     }
    1145           0 :                     else if( bHeaderRulerMove && bHeaderRulerChange )
    1146             :                     {
    1147           0 :                         const SfxPoolItem* pItem = NULL;
    1148           0 :                         if ( rStyleSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SFX_ITEM_SET )
    1149             :                         {
    1150           0 :                             SfxItemSet& pHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
    1151           0 :                             Size  aHeaderSize = ((const SvxSizeItem&)pHeaderSet.Get(ATTR_PAGE_SIZE)).GetSize();
    1152           0 :                             aHeaderSize.Height() = (long)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS - aULItem.GetUpper());
    1153           0 :                             aHeaderSize.Height() = aHeaderSize.Height() * 100 / mnScale;
    1154           0 :                             SvxSetItem  aNewHeader( (const SvxSetItem&)rStyleSet.Get(ATTR_PAGE_HEADERSET) );
    1155           0 :                             aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aHeaderSize ) );
    1156           0 :                             rStyleSet.Put( aNewHeader );
    1157           0 :                             pDocShell->SetModified(true);
    1158           0 :                         }
    1159             :                     }
    1160           0 :                     else if( bFooterRulerMove && bFooterRulerChange )
    1161             :                     {
    1162           0 :                         const SfxPoolItem* pItem = NULL;
    1163           0 :                         if( rStyleSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SFX_ITEM_SET )
    1164             :                         {
    1165           0 :                             SfxItemSet& pFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
    1166           0 :                             Size aFooterSize = ((const SvxSizeItem&)pFooterSet.Get(ATTR_PAGE_SIZE)).GetSize();
    1167           0 :                             aFooterSize.Height() = (long)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS - aULItem.GetLower() );
    1168           0 :                             aFooterSize.Height() = aFooterSize.Height() * 100 / mnScale;
    1169           0 :                             SvxSetItem  aNewFooter( (const SvxSetItem&)rStyleSet.Get(ATTR_PAGE_FOOTERSET) );
    1170           0 :                             aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aFooterSize ) );
    1171           0 :                             rStyleSet.Put( aNewFooter );
    1172           0 :                             pDocShell->SetModified(true);
    1173             :                         }
    1174             :                     }
    1175             : 
    1176           0 :                     ScStyleSaveData aNewData;
    1177           0 :                     aNewData.InitFromStyle( pStyleSheet );
    1178           0 :                     if( bUndo )
    1179             :                     {
    1180           0 :                         pDocShell->GetUndoManager()->AddUndoAction(
    1181             :                             new ScUndoModifyStyle( pDocShell, SFX_STYLE_FAMILY_PAGE,
    1182           0 :                             aOldData, aNewData ) );
    1183             :                     }
    1184             : 
    1185           0 :                     if ( ValidTab( nTab ) )
    1186             :                     {
    1187           0 :                         ScPrintFunc aPrintFunc( this, pDocShell, nTab );
    1188           0 :                         aPrintFunc.UpdatePages();
    1189             :                     }
    1190             : 
    1191           0 :                     Rectangle  aRect(0,0,10000,10000);
    1192           0 :                     Paint( aRect );
    1193           0 :                     aModificator.SetDocumentModified();
    1194           0 :                     bTopRulerChange = false;
    1195           0 :                     bBottomRulerChange = false;
    1196           0 :                     bHeaderRulerChange = false;
    1197           0 :                     bFooterRulerChange = false;
    1198             :                  }
    1199             :               }
    1200           0 :               bTopRulerMove = false;
    1201           0 :               bBottomRulerMove = false;
    1202           0 :               bHeaderRulerMove = false;
    1203           0 :               bFooterRulerMove = false;
    1204             :         }
    1205           0 :         if( rMEvt.IsLeft() && GetPointer() == POINTER_HSPLIT )
    1206             :         {
    1207           0 :             SetPointer(POINTER_ARROW);
    1208           0 :             ScDocument* pDoc = pDocShell->GetDocument();
    1209           0 :             bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
    1210           0 :             bool bMoveRulerAction = true;
    1211           0 :             if( aButtonDownPt.X() == aButtonUpPt.X() )
    1212             :             {
    1213           0 :                 bMoveRulerAction = false;
    1214           0 :                 if( nColNumberButttonDown == aPageArea.aStart.Col() )
    1215           0 :                     DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,POINTER_HSPLIT );
    1216             :                 else
    1217           0 :                     DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
    1218           0 :                 DrawInvert( aButtonUpPt.X(), POINTER_HSPLIT );
    1219             :             }
    1220           0 :             if( bMoveRulerAction )
    1221             :             {
    1222           0 :                 long  nNewColWidth = 0;
    1223           0 :                 SCCOLROW nCols[2] = { nColNumberButttonDown, nColNumberButttonDown };
    1224             : 
    1225           0 :                 if( !bLayoutRTL )
    1226             :                 {
    1227           0 :                     nNewColWidth = (long) ( PixelToLogic( Point( rMEvt.GetPosPixel().X() - nRight[ nColNumberButttonDown ], 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
    1228           0 :                     nNewColWidth += pDocShell->GetDocument()->GetColWidth( nColNumberButttonDown, nTab );
    1229             :                 }
    1230             :                 else
    1231             :                 {
    1232             : 
    1233           0 :                     nNewColWidth = (long) ( PixelToLogic( Point( nRight[ nColNumberButttonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
    1234           0 :                     nNewColWidth += pDocShell->GetDocument()->GetColWidth( nColNumberButttonDown, nTab );
    1235             :                 }
    1236             : 
    1237           0 :                 if( nNewColWidth >= 0 )
    1238             :                 {
    1239           0 :                     pDocShell->GetDocFunc().SetWidthOrHeight(
    1240             :                                                 true, 1,nCols, nTab, SC_SIZE_DIRECT,
    1241           0 :                                                 (sal_uInt16)nNewColWidth, true, true);
    1242           0 :                     pDocShell->SetModified(true);
    1243             :                 }
    1244           0 :                 if ( ValidTab( nTab ) )
    1245             :                 {
    1246           0 :                     ScPrintFunc aPrintFunc( this, pDocShell, nTab );
    1247           0 :                     aPrintFunc.UpdatePages();
    1248             :                 }
    1249           0 :                 Rectangle  nRect(0,0,10000,10000);
    1250           0 :                 Paint( nRect );
    1251             :             }
    1252           0 :             bColRulerMove = false;
    1253             :         }
    1254           0 :         ReleaseMouse();
    1255           0 : }
    1256             : 
    1257           0 : void ScPreview::MouseMove( const MouseEvent& rMEvt )
    1258             : {
    1259           0 :     Fraction aPreviewZoom( nZoom, 100 );
    1260           0 :     Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
    1261           0 :     MapMode  aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
    1262           0 :     Point    aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode );
    1263             : 
    1264           0 :     long    nLeftMargin = 0;
    1265           0 :     long    nRightMargin = 0;
    1266           0 :     long    nTopMargin = 0;
    1267           0 :     long    nBottomMargin = 0;
    1268           0 :     Size    PageSize;
    1269             : 
    1270           0 :     long    nWidth = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width();
    1271           0 :     long    nHeight = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height();
    1272             : 
    1273           0 :     if ( nPageNo < nTotalPages )
    1274             :     {
    1275           0 :         ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
    1276             : 
    1277             :         ScPrintFunc* pPrintFunc;
    1278             : 
    1279           0 :         if (bStateValid)
    1280           0 :             pPrintFunc = new ScPrintFunc( this, pDocShell, aState, &aOptions );
    1281             :         else
    1282           0 :             pPrintFunc = new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
    1283             : 
    1284           0 :         nLeftMargin = (long)( pPrintFunc->GetLeftMargin() * HMM_PER_TWIPS - aOffset.X() );
    1285           0 :         nRightMargin = (long)( pPrintFunc->GetRightMargin() * HMM_PER_TWIPS );
    1286           0 :         nRightMargin = (long)( nWidth * HMM_PER_TWIPS - nRightMargin - aOffset.X() );
    1287           0 :         nTopMargin = (long)( pPrintFunc->GetTopMargin() * HMM_PER_TWIPS - aOffset.Y() );
    1288           0 :         nBottomMargin = (long)( pPrintFunc->GetBottomMargin() * HMM_PER_TWIPS );
    1289           0 :         nBottomMargin = (long)( nHeight * HMM_PER_TWIPS - nBottomMargin - aOffset.Y() );
    1290           0 :         if( mnScale > 0 )
    1291             :         {
    1292           0 :             nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS * mnScale / 100 );
    1293           0 :             nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS * mnScale / 100 );
    1294             :         }
    1295             :         else
    1296             :         {
    1297           0 :             nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS );
    1298           0 :             nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS );
    1299             :         }
    1300           0 :         delete pPrintFunc;
    1301             :     }
    1302             : 
    1303           0 :     Point   aPixPt( rMEvt.GetPosPixel() );
    1304           0 :     Point   aLeftTop = LogicToPixel( Point( nLeftMargin, -aOffset.Y() ) , aMMMode );
    1305           0 :     Point   aLeftBottom = LogicToPixel( Point( nLeftMargin ,(long)(nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
    1306           0 :     Point   aRightTop = LogicToPixel( Point( nRightMargin, -aOffset.Y() ), aMMMode );
    1307           0 :     Point   aTopLeft = LogicToPixel( Point( -aOffset.X(), nTopMargin ), aMMMode );
    1308           0 :     Point   aTopRight = LogicToPixel( Point( (long)(nWidth * HMM_PER_TWIPS - aOffset.X()), nTopMargin ), aMMMode );
    1309           0 :     Point   aBottomLeft = LogicToPixel( Point( -aOffset.X(), nBottomMargin ), aMMMode );
    1310           0 :     Point   aHeaderLeft = LogicToPixel( Point(  -aOffset.X(), nHeaderHeight ), aMMMode );
    1311           0 :     Point   aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode );
    1312             : 
    1313           0 :     bool bOnColRulerChange = false;
    1314             : 
    1315           0 :     for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
    1316             :     {
    1317           0 :         Point   aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
    1318           0 :         Point   aColumnBottom = LogicToPixel( Point( 0, (long)( nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
    1319           0 :         if( aPixPt.X() < ( nRight[i] + 2 ) && ( aPixPt.X() > ( nRight[i] - 2 ) ) && ( aPixPt.X() < aRightTop.X() ) && ( aPixPt.X() > aLeftTop.X() )
    1320           0 :             && ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove
    1321           0 :             && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
    1322             :         {
    1323           0 :             bOnColRulerChange = true;
    1324           0 :             if( !rMEvt.GetButtons() && GetPointer() == POINTER_HSPLIT )
    1325           0 :                 nColNumberButttonDown = i;
    1326             :             break;
    1327             :         }
    1328             :     }
    1329             : 
    1330           0 :     if( aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 ) && !bRightRulerMove )
    1331             :     {
    1332           0 :         bLeftRulerChange = true;
    1333           0 :         bRightRulerChange = false;
    1334             :     }
    1335           0 :     else if( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) && !bLeftRulerMove )
    1336             :     {
    1337           0 :         bLeftRulerChange = false;
    1338           0 :         bRightRulerChange = true;
    1339             :     }
    1340           0 :     else if( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
    1341             :     {
    1342           0 :         bTopRulerChange = true;
    1343           0 :         bBottomRulerChange = false;
    1344           0 :         bHeaderRulerChange = false;
    1345           0 :         bFooterRulerChange = false;
    1346             :     }
    1347           0 :     else if( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) && !bTopRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
    1348             :     {
    1349           0 :         bTopRulerChange = false;
    1350           0 :         bBottomRulerChange = true;
    1351           0 :         bHeaderRulerChange = false;
    1352           0 :         bFooterRulerChange = false;
    1353             :     }
    1354           0 :     else if( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bFooterRulerMove )
    1355             :     {
    1356           0 :         bTopRulerChange = false;
    1357           0 :         bBottomRulerChange = false;
    1358           0 :         bHeaderRulerChange = true;
    1359           0 :         bFooterRulerChange = false;
    1360             :     }
    1361           0 :     else if( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove )
    1362             :     {
    1363           0 :         bTopRulerChange = false;
    1364           0 :         bBottomRulerChange = false;
    1365           0 :         bHeaderRulerChange = false;
    1366           0 :         bFooterRulerChange = true;
    1367             :     }
    1368             : 
    1369           0 :     if( bPageMargin )
    1370             :     {
    1371           0 :         if(( (aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 )) || bLeftRulerMove ||
    1372           0 :             ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) || bRightRulerMove || bOnColRulerChange || bColRulerMove )
    1373           0 :             && aPixPt.Y() > aLeftTop.Y() && aPixPt.Y() < aLeftBottom.Y() )
    1374             :         {
    1375           0 :             if( bOnColRulerChange || bColRulerMove )
    1376             :             {
    1377           0 :                 SetPointer( Pointer( POINTER_HSPLIT ) );
    1378           0 :                 if( bColRulerMove )
    1379             :                 {
    1380           0 :                     if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
    1381           0 :                        DragMove( aMouseMovePoint.X(), POINTER_HSPLIT );
    1382             :                 }
    1383             :             }
    1384             :             else
    1385             :             {
    1386           0 :                 if( bLeftRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
    1387             :                 {
    1388           0 :                     SetPointer( Pointer( POINTER_HSIZEBAR ) );
    1389           0 :                     if( bLeftRulerMove )
    1390             :                     {
    1391           0 :                        if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
    1392           0 :                            DragMove( aMouseMovePoint.X(), POINTER_HSIZEBAR );
    1393             :                     }
    1394             :                 }
    1395           0 :                 else if( bRightRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
    1396             :                 {
    1397           0 :                     SetPointer( Pointer( POINTER_HSIZEBAR ) );
    1398           0 :                     if( bRightRulerMove )
    1399             :                     {
    1400           0 :                        if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
    1401           0 :                            DragMove( aMouseMovePoint.X(), POINTER_HSIZEBAR );
    1402             :                     }
    1403             :                 }
    1404             :             }
    1405             :         }
    1406             :         else
    1407             :         {
    1408           0 :             if( ( ( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) ) || bTopRulerMove ||
    1409           0 :                 ( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) ) || bBottomRulerMove ||
    1410           0 :                 ( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) ) || bHeaderRulerMove ||
    1411           0 :                 ( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) ) || bFooterRulerMove )
    1412           0 :                 && aPixPt.X() > aTopLeft.X() && aPixPt.X() < aTopRight.X() )
    1413             :             {
    1414           0 :                 if( bTopRulerChange )
    1415             :                 {
    1416           0 :                     SetPointer( Pointer( POINTER_VSIZEBAR ) );
    1417           0 :                     if( bTopRulerMove )
    1418             :                     {
    1419           0 :                         if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
    1420           0 :                             DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
    1421             :                     }
    1422             :                 }
    1423           0 :                 else if( bBottomRulerChange )
    1424             :                 {
    1425           0 :                     SetPointer( Pointer( POINTER_VSIZEBAR ) );
    1426           0 :                     if( bBottomRulerMove )
    1427             :                     {
    1428           0 :                         if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
    1429           0 :                             DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
    1430             :                     }
    1431             :                 }
    1432           0 :                 else if( bHeaderRulerChange )
    1433             :                 {
    1434           0 :                     SetPointer( Pointer( POINTER_VSIZEBAR ) );
    1435           0 :                     if( bHeaderRulerMove )
    1436             :                     {
    1437           0 :                         if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
    1438           0 :                             DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
    1439             :                     }
    1440             :                 }
    1441           0 :                 else if( bFooterRulerChange )
    1442             :                 {
    1443           0 :                     SetPointer( Pointer( POINTER_VSIZEBAR ) );
    1444           0 :                     if( bFooterRulerMove )
    1445             :                     {
    1446           0 :                         if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
    1447           0 :                             DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
    1448             :                     }
    1449             :                 }
    1450             :             }
    1451             :             else
    1452           0 :                 SetPointer( Pointer( POINTER_ARROW ) );
    1453             :         }
    1454           0 :     }
    1455           0 : }
    1456             : 
    1457           0 : void ScPreview::InvalidateLocationData(sal_uLong nId)
    1458             : {
    1459           0 :     bLocationValid = false;
    1460           0 :     if (pViewShell->HasAccessibilityObjects())
    1461           0 :         pViewShell->BroadcastAccessibility( SfxSimpleHint( nId ) );
    1462           0 : }
    1463             : 
    1464           0 : void ScPreview::GetFocus()
    1465             : {
    1466           0 :     if (pViewShell->HasAccessibilityObjects())
    1467           0 :         pViewShell->BroadcastAccessibility( ScAccWinFocusGotHint(GetAccessible()) );
    1468           0 : }
    1469             : 
    1470           0 : void ScPreview::LoseFocus()
    1471             : {
    1472           0 :     if (pViewShell->HasAccessibilityObjects())
    1473           0 :         pViewShell->BroadcastAccessibility( ScAccWinFocusLostHint(GetAccessible()) );
    1474           0 : }
    1475             : 
    1476           0 : com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> ScPreview::CreateAccessible()
    1477             : {
    1478             :     ScAccessibleDocumentPagePreview* pAccessible =
    1479           0 :         new ScAccessibleDocumentPagePreview( GetAccessibleParentWindow()->GetAccessible(), pViewShell );
    1480           0 :     com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xAccessible = pAccessible;
    1481           0 :     pAccessible->Init();
    1482           0 :     return xAccessible;
    1483             : }
    1484             : 
    1485           0 : void ScPreview::DragMove( long nDragMovePos, sal_uInt16 nFlags )
    1486             : {
    1487           0 :     Fraction aPreviewZoom( nZoom, 100 );
    1488           0 :     Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
    1489           0 :     MapMode  aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
    1490           0 :     SetMapMode( aMMMode );
    1491           0 :     long  nPos = nDragMovePos;
    1492           0 :     if( nFlags == POINTER_HSIZEBAR || nFlags == POINTER_HSPLIT )
    1493             :     {
    1494           0 :         if( nDragMovePos != aButtonDownChangePoint.X() )
    1495             :         {
    1496           0 :             DrawInvert( aButtonDownChangePoint.X(), nFlags );
    1497           0 :             aButtonDownChangePoint.X() = nPos;
    1498           0 :             DrawInvert( aButtonDownChangePoint.X(), nFlags );
    1499             :         }
    1500             :     }
    1501           0 :     else if( nFlags == POINTER_VSIZEBAR )
    1502             :     {
    1503           0 :         if( nDragMovePos != aButtonDownChangePoint.Y() )
    1504             :         {
    1505           0 :             DrawInvert( aButtonDownChangePoint.Y(), nFlags );
    1506           0 :             aButtonDownChangePoint.Y() = nPos;
    1507           0 :             DrawInvert( aButtonDownChangePoint.Y(), nFlags );
    1508             :         }
    1509           0 :     }
    1510           0 : }
    1511             : 
    1512           0 : void ScPreview::DrawInvert( long nDragPos, sal_uInt16 nFlags )
    1513             : {
    1514           0 :     long  nHeight = (long) lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ).Height();
    1515           0 :     long  nWidth = (long) lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ).Width();
    1516           0 :     if( nFlags == POINTER_HSIZEBAR || nFlags == POINTER_HSPLIT )
    1517             :     {
    1518           0 :         Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,(long)( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y()));
    1519           0 :         Invert( aRect,INVERT_50 );
    1520             :     }
    1521           0 :     else if( nFlags == POINTER_VSIZEBAR )
    1522             :     {
    1523           0 :         Rectangle aRect( -aOffset.X(), nDragPos,(long)( ( nWidth * HMM_PER_TWIPS ) - aOffset.X() ), nDragPos + 1 );
    1524           0 :         Invert( aRect,INVERT_50 );
    1525             :     }
    1526           0 : }
    1527             : 
    1528           0 : void ScPreview::SetSelectedTabs(const ScMarkData& rMark)
    1529             : {
    1530           0 :     maSelectedTabs = rMark.GetSelectedTabs();
    1531           0 : }
    1532             : 
    1533           0 : const ScMarkData::MarkedTabsType& ScPreview::GetSelectedTabs() const
    1534             : {
    1535           0 :     return maSelectedTabs;
    1536          15 : }
    1537             : 
    1538             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10