LCOV - code coverage report
Current view: top level - sd/source/ui/view - sdwindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 224 410 54.6 %
Date: 2012-08-25 Functions: 36 53 67.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 129 436 29.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "Window.hxx"
      31                 :            : #include <sfx2/dispatch.hxx>
      32                 :            : #include <sfx2/request.hxx>
      33                 :            : 
      34                 :            : #include <sfx2/viewfrm.hxx>
      35                 :            : #include <svx/svxids.hrc>
      36                 :            : 
      37                 :            : #include <editeng/outliner.hxx>
      38                 :            : #include <editeng/editview.hxx>
      39                 :            : 
      40                 :            : #include "app.hrc"
      41                 :            : #include "helpids.h"
      42                 :            : #include "ViewShell.hxx"
      43                 :            : #include "DrawViewShell.hxx"
      44                 :            : #include "View.hxx"
      45                 :            : #include "FrameView.hxx"
      46                 :            : #include "OutlineViewShell.hxx"
      47                 :            : #include "drawdoc.hxx"
      48                 :            : #include "AccessibleDrawDocumentView.hxx"
      49                 :            : #include "WindowUpdater.hxx"
      50                 :            : 
      51                 :            : namespace sd {
      52                 :            : 
      53                 :            : #define SCROLL_LINE_FACT   0.05     // Faktor fuer Zeilenscrolling
      54                 :            : #define SCROLL_PAGE_FACT   0.5      // Faktor fuer Seitenscrolling
      55                 :            : #define SCROLL_SENSITIVE   20       // Sensitiver Bereich (Pixel)
      56                 :            : #define ZOOM_MULTIPLICATOR 10000    // Multiplikator um Rundungsfehler zu vermeiden
      57                 :            : #define MIN_ZOOM           5        // Minimaler Zoomfaktor
      58                 :            : #define MAX_ZOOM           3000     // Maximaler Zoomfaktor
      59                 :            : 
      60                 :            : 
      61                 :            : /*************************************************************************
      62                 :            : |*
      63                 :            : |* Konstruktor
      64                 :            : |*
      65                 :            : \************************************************************************/
      66                 :            : 
      67                 :        286 : Window::Window(::Window* pParent)
      68                 :            :     : ::Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
      69                 :            :       DropTargetHelper( this ),
      70                 :            :       mpShareWin(NULL),
      71                 :            :       maWinPos(0, 0),           // vorsichtshalber; die Werte sollten aber
      72                 :            :       maViewOrigin(0, 0),       // vom Besitzer des Fensters neu gesetzt
      73                 :            :       maViewSize(1000, 1000),   // werden
      74                 :            :       maPrevSize(-1,-1),
      75                 :            :       mnMinZoom(MIN_ZOOM),
      76                 :            :       mnMaxZoom(MAX_ZOOM),
      77                 :            :       mbMinZoomAutoCalc(false),
      78                 :            :       mbCalcMinZoomByMinSide(true),
      79                 :            :       mbCenterAllowed(true),
      80                 :            :       mnTicks (0),
      81                 :            :       mbDraggedFrom(false),
      82                 :            :       mpViewShell(NULL),
      83         [ +  - ]:        286 :       mbUseDropScroll (true)
      84                 :            : {
      85         [ +  - ]:        286 :     SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
      86                 :            : 
      87         [ +  - ]:        286 :     MapMode aMap(GetMapMode());
      88         [ +  - ]:        286 :     aMap.SetMapUnit(MAP_100TH_MM);
      89         [ +  - ]:        286 :     SetMapMode(aMap);
      90                 :            : 
      91                 :            :     // Damit im Diamodus die ::WindowColor genommen wird
      92 [ +  - ][ +  - ]:        286 :     SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
                 [ +  - ]
      93                 :            : 
      94                 :            :     // adjust contrast mode initially
      95                 :        286 :     bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
      96                 :            :     SetDrawMode( bUseContrast
      97                 :            :         ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
      98 [ +  - ][ -  + ]:        286 :         : ViewShell::OUTPUT_DRAWMODE_COLOR );
      99                 :            : 
     100                 :            :     // Hilfe-ID setzen
     101                 :            :     // SetHelpId(HID_SD_WIN_DOCUMENT);
     102         [ +  - ]:        286 :     SetUniqueId(HID_SD_WIN_DOCUMENT);
     103                 :            : 
     104                 :            :     // #i78183# Added after discussed with AF
     105 [ +  - ][ +  - ]:        286 :     EnableRTL(sal_False);
     106                 :        286 : }
     107                 :            : 
     108                 :            : /*************************************************************************
     109                 :            : |*
     110                 :            : |* Destruktor
     111                 :            : |*
     112                 :            : \************************************************************************/
     113                 :            : 
     114         [ +  - ]:        286 : Window::~Window (void)
     115                 :            : {
     116         [ -  + ]:        286 :     if (mpViewShell != NULL)
     117                 :            :     {
     118         [ #  # ]:          0 :         WindowUpdater* pWindowUpdater = mpViewShell->GetWindowUpdater();
     119         [ #  # ]:          0 :         if (pWindowUpdater != NULL)
     120         [ #  # ]:          0 :             pWindowUpdater->UnregisterWindow (this);
     121                 :            :     }
     122         [ -  + ]:        572 : }
     123                 :            : 
     124                 :            : 
     125                 :            : 
     126                 :            : 
     127                 :        702 : void Window::SetViewShell (ViewShell* pViewSh)
     128                 :            : {
     129                 :        702 :     WindowUpdater* pWindowUpdater = NULL;
     130                 :            :     // Unregister at device updater of old view shell.
     131         [ +  + ]:        702 :     if (mpViewShell != NULL)
     132                 :            :     {
     133                 :        416 :         pWindowUpdater = mpViewShell->GetWindowUpdater();
     134         [ +  - ]:        416 :         if (pWindowUpdater != NULL)
     135                 :        416 :             pWindowUpdater->UnregisterWindow (this);
     136                 :            :     }
     137                 :            : 
     138                 :        702 :     mpViewShell = pViewSh;
     139                 :            : 
     140                 :            :     // Register at device updater of new view shell
     141         [ +  + ]:        702 :     if (mpViewShell != NULL)
     142                 :            :     {
     143                 :        416 :         pWindowUpdater = mpViewShell->GetWindowUpdater();
     144         [ +  - ]:        416 :         if (pWindowUpdater != NULL)
     145                 :        416 :             pWindowUpdater->RegisterWindow (this);
     146                 :            :     }
     147                 :        702 : }
     148                 :            : 
     149                 :       1956 : void Window::CalcMinZoom()
     150                 :            : {
     151                 :            :     // Are we entitled to change the minimal zoom factor?
     152         [ -  + ]:       1956 :     if ( mbMinZoomAutoCalc )
     153                 :            :     {
     154                 :            :         // Get current zoom factor.
     155                 :          0 :         long nZoom = GetZoom();
     156                 :            : 
     157         [ #  # ]:          0 :         if ( mpShareWin )
     158                 :            :         {
     159                 :          0 :             mpShareWin->CalcMinZoom();
     160                 :          0 :             mnMinZoom = mpShareWin->mnMinZoom;
     161                 :            :         }
     162                 :            :         else
     163                 :            :         {
     164                 :            :             // Get the rectangle of the output area in logical coordinates
     165                 :            :             // and calculate the scaling factors that would lead to the view
     166                 :            :             // area (also called application area) to completely fill the
     167                 :            :             // window.
     168         [ #  # ]:          0 :             Size aWinSize = PixelToLogic(GetOutputSizePixel());
     169                 :          0 :             sal_uLong nX = (sal_uLong) ((double) aWinSize.Width()
     170                 :          0 :                 * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Width());
     171                 :          0 :             sal_uLong nY = (sal_uLong) ((double) aWinSize.Height()
     172                 :          0 :                 * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Height());
     173                 :            : 
     174                 :            :             // Decide whether to take the larger or the smaller factor.
     175                 :            :             sal_uLong nFact;
     176         [ #  # ]:          0 :             if (mbCalcMinZoomByMinSide)
     177                 :          0 :                 nFact = Min(nX, nY);
     178                 :            :             else
     179                 :          0 :                 nFact = Max(nX, nY);
     180                 :            : 
     181                 :            :             // The factor is tansfomed according to the current zoom factor.
     182                 :          0 :             nFact = nFact * nZoom / ZOOM_MULTIPLICATOR;
     183                 :          0 :             mnMinZoom = Max((sal_uInt16) MIN_ZOOM, (sal_uInt16) nFact);
     184                 :            :         }
     185                 :            :         // If the current zoom factor is smaller than the calculated minimal
     186                 :            :         // zoom factor then set the new minimal factor as the current zoom
     187                 :            :         // factor.
     188         [ #  # ]:          0 :         if ( nZoom < (long) mnMinZoom )
     189                 :          0 :             SetZoomFactor(mnMinZoom);
     190                 :            :     }
     191                 :       1956 : }
     192                 :            : 
     193                 :            : 
     194                 :            : 
     195                 :            : 
     196                 :          0 : void Window::SetMinZoom (long int nMin)
     197                 :            : {
     198                 :          0 :     mnMinZoom = (sal_uInt16) nMin;
     199                 :          0 : }
     200                 :            : 
     201                 :            : 
     202                 :            : 
     203                 :            : 
     204                 :        248 : long Window::GetMinZoom (void) const
     205                 :            : {
     206                 :        248 :     return mnMinZoom;
     207                 :            : }
     208                 :            : 
     209                 :            : 
     210                 :            : 
     211                 :            : 
     212                 :          0 : void Window::SetMaxZoom (long int nMax)
     213                 :            : {
     214                 :          0 :     mnMaxZoom = (sal_uInt16) nMax;
     215                 :          0 : }
     216                 :            : 
     217                 :            : 
     218                 :            : 
     219                 :            : 
     220                 :        248 : long Window::GetMaxZoom (void) const
     221                 :            : {
     222                 :        248 :     return mnMaxZoom;
     223                 :            : }
     224                 :            : 
     225                 :            : 
     226                 :            : 
     227                 :            : 
     228                 :       2207 : long Window::GetZoom (void) const
     229                 :            : {
     230         [ +  - ]:       2207 :     if( GetMapMode().GetScaleX().GetDenominator() )
     231                 :            :     {
     232                 :       2207 :         return GetMapMode().GetScaleX().GetNumerator() * 100L
     233                 :       2207 :             / GetMapMode().GetScaleX().GetDenominator();
     234                 :            :     }
     235                 :            :     else
     236                 :            :     {
     237                 :       2207 :         return 0;
     238                 :            :     }
     239                 :            : }
     240                 :            : 
     241                 :            : 
     242                 :            : 
     243                 :            : 
     244                 :            : /*************************************************************************
     245                 :            : |*
     246                 :            : |* Resize event
     247                 :            : |*
     248                 :            : \************************************************************************/
     249                 :            : 
     250                 :       1059 : void Window::Resize()
     251                 :            : {
     252                 :       1059 :     ::Window::Resize();
     253                 :       1059 :     CalcMinZoom();
     254                 :            : 
     255 [ +  - ][ +  - ]:       1059 :     if( mpViewShell && mpViewShell->GetViewFrame() )
                 [ +  - ]
     256                 :       1059 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
     257                 :       1059 : }
     258                 :            : 
     259                 :            : /*************************************************************************
     260                 :            : |*
     261                 :            : |* PrePaint event
     262                 :            : |*
     263                 :            : \************************************************************************/
     264                 :            : 
     265                 :       2947 : void Window::PrePaint()
     266                 :            : {
     267         [ +  - ]:       2947 :     if ( mpViewShell )
     268                 :       2947 :         mpViewShell->PrePaint();
     269                 :       2947 : }
     270                 :            : 
     271                 :            : /*************************************************************************
     272                 :            : |*
     273                 :            : |* Paint event
     274                 :            : |*
     275                 :            : \************************************************************************/
     276                 :            : 
     277                 :       1608 : void Window::Paint(const Rectangle& rRect)
     278                 :            : {
     279         [ +  - ]:       1608 :     if ( mpViewShell )
     280                 :       1608 :         mpViewShell->Paint(rRect, this);
     281                 :       1608 : }
     282                 :            : 
     283                 :            : /*************************************************************************
     284                 :            : |*
     285                 :            : |* Keyboard event
     286                 :            : |*
     287                 :            : \************************************************************************/
     288                 :            : 
     289                 :          0 : void Window::KeyInput(const KeyEvent& rKEvt)
     290                 :            : {
     291 [ #  # ][ #  # ]:          0 :     if (!(mpViewShell && mpViewShell->KeyInput(rKEvt, this)))
                 [ #  # ]
     292                 :            :     {
     293 [ #  # ][ #  # ]:          0 :         if (mpViewShell && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
                 [ #  # ]
     294                 :            :         {
     295                 :          0 :             mpViewShell->GetViewShell()->Escape();
     296                 :            :         }
     297                 :            :         else
     298                 :            :         {
     299                 :          0 :             ::Window::KeyInput(rKEvt);
     300                 :            :         }
     301                 :            :     }
     302                 :          0 : }
     303                 :            : 
     304                 :            : /*************************************************************************
     305                 :            : |*
     306                 :            : |* MouseButtonDown event
     307                 :            : |*
     308                 :            : \************************************************************************/
     309                 :            : 
     310                 :          0 : void Window::MouseButtonDown(const MouseEvent& rMEvt)
     311                 :            : {
     312         [ #  # ]:          0 :     if ( mpViewShell )
     313                 :          0 :         mpViewShell->MouseButtonDown(rMEvt, this);
     314                 :          0 : }
     315                 :            : 
     316                 :            : /*************************************************************************
     317                 :            : |*
     318                 :            : |* MouseMove event
     319                 :            : |*
     320                 :            : \************************************************************************/
     321                 :            : 
     322                 :          0 : void Window::MouseMove(const MouseEvent& rMEvt)
     323                 :            : {
     324         [ #  # ]:          0 :     if ( mpViewShell )
     325                 :          0 :         mpViewShell->MouseMove(rMEvt, this);
     326                 :          0 : }
     327                 :            : 
     328                 :            : /*************************************************************************
     329                 :            : |*
     330                 :            : |* MouseButtonUp event
     331                 :            : |*
     332                 :            : \************************************************************************/
     333                 :            : 
     334                 :          0 : void Window::MouseButtonUp(const MouseEvent& rMEvt)
     335                 :            : {
     336                 :          0 :     mnTicks = 0;
     337                 :            : 
     338         [ #  # ]:          0 :     if ( mpViewShell )
     339                 :          0 :         mpViewShell->MouseButtonUp(rMEvt, this);
     340                 :          0 : }
     341                 :            : 
     342                 :            : /*************************************************************************
     343                 :            : |*
     344                 :            : |* Command event
     345                 :            : |*
     346                 :            : \************************************************************************/
     347                 :            : 
     348                 :          0 : void Window::Command(const CommandEvent& rCEvt)
     349                 :            : {
     350         [ #  # ]:          0 :     if ( mpViewShell )
     351                 :          0 :         mpViewShell->Command(rCEvt, this);
     352                 :          0 : }
     353                 :            : 
     354                 :        797 : long Window::Notify( NotifyEvent& rNEvt )
     355                 :            : {
     356                 :        797 :     long nResult = sal_False;
     357         [ +  - ]:        797 :     if ( mpViewShell )
     358                 :            :     {
     359                 :        797 :         nResult = mpViewShell->Notify(rNEvt, this);
     360                 :            :     }
     361         [ +  - ]:        797 :     if( !nResult )
     362                 :        797 :         ::Window::Notify( rNEvt );
     363                 :            : 
     364                 :        797 :     return nResult;
     365                 :            : }
     366                 :            : 
     367                 :            : 
     368                 :            : /*************************************************************************
     369                 :            : |*
     370                 :            : |* RequestHelp event
     371                 :            : |*
     372                 :            : \************************************************************************/
     373                 :            : 
     374                 :          0 : void Window::RequestHelp(const HelpEvent& rEvt)
     375                 :            : {
     376         [ #  # ]:          0 :     if ( mpViewShell )
     377                 :            :     {
     378         [ #  # ]:          0 :         if( !mpViewShell->RequestHelp( rEvt, this) )
     379                 :          0 :             ::Window::RequestHelp( rEvt );
     380                 :            :     }
     381                 :            :     else
     382                 :          0 :         ::Window::RequestHelp( rEvt );
     383                 :          0 : }
     384                 :            : 
     385                 :            : 
     386                 :            : 
     387                 :            : 
     388                 :        894 : Point Window::GetWinViewPos (void) const
     389                 :            : {
     390                 :        894 :     return maWinPos;
     391                 :            : }
     392                 :            : 
     393                 :            : 
     394                 :            : 
     395                 :            : 
     396                 :         72 : Point Window::GetViewOrigin (void) const
     397                 :            : {
     398                 :         72 :     return maViewOrigin;
     399                 :            : }
     400                 :            : 
     401                 :            : 
     402                 :            : 
     403                 :            : 
     404                 :         72 : Size Window::GetViewSize (void) const
     405                 :            : {
     406                 :         72 :     return maViewSize;
     407                 :            : }
     408                 :            : 
     409                 :            : 
     410                 :            : 
     411                 :            : 
     412                 :            : /*************************************************************************
     413                 :            : |*
     414                 :            : |* Position der linken oberen Ecke des im Fenster sichtbaren Bereichs
     415                 :            : |* setzen
     416                 :            : |*
     417                 :            : \************************************************************************/
     418                 :            : 
     419                 :        613 : void Window::SetWinViewPos(const Point& rPnt)
     420                 :            : {
     421                 :        613 :     maWinPos = rPnt;
     422                 :        613 : }
     423                 :            : 
     424                 :            : /*************************************************************************
     425                 :            : |*
     426                 :            : |* Ursprung der Darstellung in Bezug zur gesamten Arbeitsflaeche setzen
     427                 :            : |*
     428                 :            : \************************************************************************/
     429                 :            : 
     430                 :        897 : void Window::SetViewOrigin(const Point& rPnt)
     431                 :            : {
     432                 :        897 :     maViewOrigin = rPnt;
     433                 :        897 : }
     434                 :            : 
     435                 :            : /*************************************************************************
     436                 :            : |*
     437                 :            : |* Groesse der gesamten Arbeitsflaeche, die mit dem Fenster betrachtet
     438                 :            : |* werden kann, setzen
     439                 :            : |*
     440                 :            : \************************************************************************/
     441                 :            : 
     442                 :        897 : void Window::SetViewSize(const Size& rSize)
     443                 :            : {
     444                 :        897 :     maViewSize = rSize;
     445                 :        897 :     CalcMinZoom();
     446                 :        897 : }
     447                 :            : 
     448                 :            : 
     449                 :            : 
     450                 :            : 
     451                 :        442 : void Window::SetCenterAllowed (bool bIsAllowed)
     452                 :            : {
     453                 :        442 :     mbCenterAllowed = bIsAllowed;
     454                 :        442 : }
     455                 :            : 
     456                 :            : 
     457                 :            : 
     458                 :            : 
     459                 :        894 : long Window::SetZoomFactor(long nZoom)
     460                 :            : {
     461                 :            :     // Clip the zoom factor to the valid range marked by nMinZoom as
     462                 :            :     // calculated by CalcMinZoom() and the constant MAX_ZOOM.
     463         [ -  + ]:        894 :     if ( nZoom > MAX_ZOOM )
     464                 :          0 :         nZoom = MAX_ZOOM;
     465         [ -  + ]:        894 :     if ( nZoom < (long) mnMinZoom )
     466                 :          0 :         nZoom = mnMinZoom;
     467                 :            : 
     468                 :            :     // Set the zoom factor at the window's map mode.
     469         [ +  - ]:        894 :     MapMode aMap(GetMapMode());
     470 [ +  - ][ +  - ]:        894 :     aMap.SetScaleX(Fraction(nZoom, 100));
     471 [ +  - ][ +  - ]:        894 :     aMap.SetScaleY(Fraction(nZoom, 100));
     472         [ +  - ]:        894 :     SetMapMode(aMap);
     473                 :            : 
     474                 :            :     // invalidate previous size - it was relative to the old scaling
     475                 :        894 :     maPrevSize = Size(-1,-1);
     476                 :            : 
     477                 :            :     // Update the map mode's origin (to what effect?).
     478         [ +  - ]:        894 :     UpdateMapOrigin();
     479                 :            : 
     480                 :            :     // Update the view's snapping to the the new zoom factor.
     481 [ +  - ][ +  - ]:        894 :     if ( mpViewShell && mpViewShell->ISA(DrawViewShell) )
         [ +  - ][ +  - ]
                 [ +  - ]
     482                 :        894 :         ((DrawViewShell*) mpViewShell)->GetView()->
     483         [ +  - ]:        894 :                                         RecalcLogicSnapMagnetic(*this);
     484                 :            : 
     485                 :            :     // Return the zoom factor just in case it has been changed above to lie
     486                 :            :     // inside the valid range.
     487         [ +  - ]:        894 :     return nZoom;
     488                 :            : }
     489                 :            : 
     490                 :        447 : void Window::SetZoomIntegral(long nZoom)
     491                 :            : {
     492                 :            :     // Clip the zoom factor to the valid range marked by nMinZoom as
     493                 :            :     // previously calculated by <member>CalcMinZoom()</member> and the
     494                 :            :     // MAX_ZOOM constant.
     495         [ -  + ]:        447 :     if ( nZoom > MAX_ZOOM )
     496                 :          0 :         nZoom = MAX_ZOOM;
     497         [ -  + ]:        447 :     if ( nZoom < (long) mnMinZoom )
     498                 :          0 :         nZoom = mnMinZoom;
     499                 :            : 
     500                 :            :     // Calculate the window's new origin.
     501         [ +  - ]:        447 :     Size aSize = PixelToLogic(GetOutputSizePixel());
     502                 :        447 :     long nW = aSize.Width()  * GetZoom() / nZoom;
     503                 :        447 :     long nH = aSize.Height() * GetZoom() / nZoom;
     504                 :        447 :     maWinPos.X() += (aSize.Width()  - nW) / 2;
     505                 :        447 :     maWinPos.Y() += (aSize.Height() - nH) / 2;
     506         [ -  + ]:        447 :     if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
     507         [ -  + ]:        447 :     if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
     508                 :            : 
     509                 :            :     // Finally update this window's map mode to the given zoom factor that
     510                 :            :     // has been clipped to the valid range.
     511         [ +  - ]:        447 :     SetZoomFactor(nZoom);
     512                 :        447 : }
     513                 :            : 
     514                 :        248 : long Window::GetZoomForRect( const Rectangle& rZoomRect )
     515                 :            : {
     516                 :        248 :     long nRetZoom = 100;
     517                 :            : 
     518 [ +  - ][ +  - ]:        248 :     if( (rZoomRect.GetWidth() != 0) && (rZoomRect.GetHeight() != 0))
                 [ +  - ]
     519                 :            :     {
     520                 :            :         // Calculate the scale factors which will lead to the given
     521                 :            :         // rectangle being fully visible (when translated accordingly) as
     522                 :            :         // large as possible in the output area independently in both
     523                 :            :         // coordinate directions .
     524                 :        248 :         sal_uLong nX(0L);
     525                 :        248 :         sal_uLong nY(0L);
     526                 :            : 
     527         [ +  - ]:        248 :         const Size aWinSize( PixelToLogic(GetOutputSizePixel()) );
     528 [ +  - ][ +  - ]:        248 :         if(rZoomRect.GetHeight())
     529                 :            :         {
     530                 :        248 :             nX = (sal_uLong) ((double) aWinSize.Height()
     531         [ +  - ]:        248 :                * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
     532                 :            :         }
     533                 :            : 
     534 [ +  - ][ +  - ]:        248 :         if(rZoomRect.GetWidth())
     535                 :            :         {
     536                 :        248 :             nY = (sal_uLong) ((double) aWinSize.Width()
     537         [ +  - ]:        248 :                 * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
     538                 :            :         }
     539                 :            : 
     540                 :            :         // Use the smaller one of both so that the zoom rectangle will be
     541                 :            :         // fully visible with respect to both coordinate directions.
     542                 :        248 :         sal_uLong nFact = Min(nX, nY);
     543                 :            : 
     544                 :            :         // Transform the current zoom factor so that it leads to the desired
     545                 :            :         // scaling.
     546                 :        248 :         nRetZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
     547                 :            : 
     548                 :            :         // Calculate the new origin.
     549         [ +  + ]:        248 :         if ( nFact == 0 )
     550                 :            :         {
     551                 :            :             // Don't change anything if the scale factor is degenrate.
     552                 :        122 :             nRetZoom = GetZoom();
     553                 :            :         }
     554                 :            :         else
     555                 :            :         {
     556                 :            :             // Clip the zoom factor to the valid range marked by nMinZoom as
     557                 :            :             // previously calculated by <member>CalcMinZoom()</member> and the
     558                 :            :             // MAX_ZOOM constant.
     559         [ -  + ]:        126 :             if ( nRetZoom > MAX_ZOOM )
     560                 :          0 :                 nRetZoom = MAX_ZOOM;
     561         [ -  + ]:        126 :             if ( nRetZoom < (long) mnMinZoom )
     562                 :        248 :                 nRetZoom = mnMinZoom;
     563                 :            :        }
     564                 :            :     }
     565                 :            : 
     566                 :        248 :     return nRetZoom;
     567                 :            : }
     568                 :            : 
     569                 :            : /** Recalculate the zoom factor and translation so that the given rectangle
     570                 :            :     is displayed centered and as large as possible while still being fully
     571                 :            :     visible in the window.
     572                 :            : */
     573                 :        447 : long Window::SetZoomRect (const Rectangle& rZoomRect)
     574                 :            : {
     575                 :        447 :     long nNewZoom = 100;
     576                 :            : 
     577 [ +  - ][ -  + ]:        447 :     if (rZoomRect.GetWidth() == 0 || rZoomRect.GetHeight() == 0)
                 [ -  + ]
     578                 :            :     {
     579                 :            :         // The given rectangle is degenerate.  Use the default zoom factor
     580                 :            :         // (above) of 100%.
     581                 :          0 :         SetZoomIntegral(nNewZoom);
     582                 :            :     }
     583                 :            :     else
     584                 :            :     {
     585                 :        447 :         Point aPos = rZoomRect.TopLeft();
     586                 :            :         // Transform the output area from pixel coordinates into logical
     587                 :            :         // coordinates.
     588         [ +  - ]:        447 :         Size aWinSize = PixelToLogic(GetOutputSizePixel());
     589                 :            :         // Paranoia!  The degenerate case of zero width or height has been
     590                 :            :         // taken care of above.
     591                 :            :         DBG_ASSERT(rZoomRect.GetWidth(), "ZoomRect-Breite = 0!");
     592                 :            :         DBG_ASSERT(rZoomRect.GetHeight(), "ZoomRect-Hoehe = 0!");
     593                 :            : 
     594                 :            :         // Calculate the scale factors which will lead to the given
     595                 :            :         // rectangle being fully visible (when translated accordingly) as
     596                 :            :         // large as possible in the output area independently in both
     597                 :            :         // coordinate directions .
     598                 :        447 :         sal_uLong nX(0L);
     599                 :        447 :         sal_uLong nY(0L);
     600                 :            : 
     601 [ +  - ][ +  - ]:        447 :         if(rZoomRect.GetHeight())
     602                 :            :         {
     603                 :        447 :             nX = (sal_uLong) ((double) aWinSize.Height()
     604         [ +  - ]:        447 :                * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
     605                 :            :         }
     606                 :            : 
     607 [ +  - ][ +  - ]:        447 :         if(rZoomRect.GetWidth())
     608                 :            :         {
     609                 :        447 :             nY = (sal_uLong) ((double) aWinSize.Width()
     610         [ +  - ]:        447 :                 * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
     611                 :            :         }
     612                 :            : 
     613                 :            :         // Use the smaller one of both so that the zoom rectangle will be
     614                 :            :         // fully visible with respect to both coordinate directions.
     615                 :        447 :         sal_uLong nFact = Min(nX, nY);
     616                 :            : 
     617                 :            :         // Transform the current zoom factor so that it leads to the desired
     618                 :            :         // scaling.
     619                 :        447 :         long nZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
     620                 :            : 
     621                 :            :         // Calculate the new origin.
     622         [ -  + ]:        447 :         if ( nFact == 0 )
     623                 :            :         {
     624                 :            :             // Don't change anything if the scale factor is degenrate.
     625                 :          0 :             nNewZoom = GetZoom();
     626                 :            :         }
     627                 :            :         else
     628                 :            :         {
     629                 :            :             // Calculate the new window position that centers the given
     630                 :            :             // rectangle on the screen.
     631         [ -  + ]:        447 :             if ( nZoom > MAX_ZOOM )
     632                 :          0 :                 nFact = nFact * MAX_ZOOM / nZoom;
     633                 :            : 
     634                 :        447 :             maWinPos = maViewOrigin + aPos;
     635                 :            : 
     636                 :        447 :             aWinSize.Width() = (long) ((double) aWinSize.Width() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
     637         [ +  - ]:        447 :             maWinPos.X() += (rZoomRect.GetWidth() - aWinSize.Width()) / 2;
     638                 :        447 :             aWinSize.Height() = (long) ((double) aWinSize.Height() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
     639         [ +  - ]:        447 :             maWinPos.Y() += (rZoomRect.GetHeight() - aWinSize.Height()) / 2;
     640                 :            : 
     641         [ -  + ]:        447 :             if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
     642         [ -  + ]:        447 :             if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
     643                 :            : 
     644                 :            :             // Adapt the window's map mode to the new zoom factor.
     645         [ +  - ]:        447 :             nNewZoom = SetZoomFactor(nZoom);
     646                 :            :         }
     647                 :            :     }
     648                 :            : 
     649                 :        447 :     return(nNewZoom);
     650                 :            : }
     651                 :            : 
     652                 :            : 
     653                 :            : 
     654                 :            : 
     655                 :          0 : void Window::SetMinZoomAutoCalc (bool bAuto)
     656                 :            : {
     657                 :          0 :     mbMinZoomAutoCalc = bAuto;
     658                 :          0 : }
     659                 :            : 
     660                 :            : 
     661                 :            : 
     662                 :            : 
     663                 :            : /*************************************************************************
     664                 :            : |*
     665                 :            : |* Neuen MapMode-Origin berechnen und setzen; wenn aWinPos.X()/Y()
     666                 :            : |* gleich -1 ist, wird die entsprechende Position zentriert
     667                 :            : |* (z.B. fuer Initialisierung)
     668                 :            : |*
     669                 :            : \************************************************************************/
     670                 :            : 
     671                 :       1858 : void Window::UpdateMapOrigin(sal_Bool bInvalidate)
     672                 :            : {
     673                 :       1858 :     sal_Bool       bChanged = sal_False;
     674         [ +  - ]:       1858 :     const Size aWinSize = PixelToLogic(GetOutputSizePixel());
     675                 :            : 
     676         [ +  + ]:       1858 :     if ( mbCenterAllowed )
     677                 :            :     {
     678         [ +  + ]:       1828 :         if( maPrevSize != Size(-1,-1) )
     679                 :            :         {
     680                 :            :             // keep view centered around current pos, when window
     681                 :            :             // resizes
     682                 :        804 :             maWinPos.X() -= (aWinSize.Width() - maPrevSize.Width()) / 2;
     683                 :        804 :             maWinPos.Y() -= (aWinSize.Height() - maPrevSize.Height()) / 2;
     684                 :        804 :             bChanged = sal_True;
     685                 :            :         }
     686                 :            : 
     687         [ -  + ]:       1828 :         if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() )
     688                 :            :         {
     689                 :          0 :             maWinPos.X() = maViewSize.Width() - aWinSize.Width();
     690                 :          0 :             bChanged = sal_True;
     691                 :            :         }
     692         [ -  + ]:       1828 :         if ( maWinPos.Y() > maViewSize.Height() - aWinSize.Height() )
     693                 :            :         {
     694                 :          0 :             maWinPos.Y() = maViewSize.Height() - aWinSize.Height();
     695                 :          0 :             bChanged = sal_True;
     696                 :            :         }
     697 [ +  - ][ +  + ]:       1828 :         if ( aWinSize.Width() > maViewSize.Width() || maWinPos.X() < 0 )
                 [ +  + ]
     698                 :            :         {
     699                 :        166 :             maWinPos.X() = maViewSize.Width()  / 2 - aWinSize.Width()  / 2;
     700                 :        166 :             bChanged = sal_True;
     701                 :            :         }
     702 [ +  - ][ +  + ]:       1828 :         if ( aWinSize.Height() > maViewSize.Height() || maWinPos.Y() < 0 )
                 [ +  + ]
     703                 :            :         {
     704                 :        166 :             maWinPos.Y() = maViewSize.Height() / 2 - aWinSize.Height() / 2;
     705                 :        166 :             bChanged = sal_True;
     706                 :            :         }
     707                 :            :     }
     708                 :            : 
     709         [ +  - ]:       1858 :     UpdateMapMode ();
     710                 :            : 
     711                 :       1858 :     maPrevSize = aWinSize;
     712                 :            : 
     713 [ +  + ][ +  + ]:       1858 :     if (bChanged && bInvalidate)
     714         [ +  - ]:        930 :         Invalidate();
     715                 :       1858 : }
     716                 :            : 
     717                 :            : 
     718                 :            : 
     719                 :            : 
     720                 :       1858 : void Window::UpdateMapMode (void)
     721                 :            : {
     722                 :       1858 :     maWinPos -= maViewOrigin;
     723                 :       1858 :     Size aPix(maWinPos.X(), maWinPos.Y());
     724         [ +  - ]:       1858 :     aPix = LogicToPixel(aPix);
     725                 :            :     // Groesse muss vielfaches von BRUSH_SIZE sein, damit Muster
     726                 :            :     // richtig dargestellt werden
     727                 :            :     // #i2237#
     728                 :            :     // removed old stuff here which still forced zoom to be
     729                 :            :     // %BRUSH_SIZE which is outdated now
     730                 :            : 
     731 [ +  - ][ +  - ]:       1858 :     if (mpViewShell && mpViewShell->ISA(DrawViewShell))
         [ +  - ][ +  + ]
                 [ +  + ]
     732                 :            :     {
     733                 :            :         // Seite soll nicht am Fensterrand "kleben"
     734         [ -  + ]:       1828 :         if (aPix.Width() == 0)
     735                 :            :         {
     736                 :            :             // #i2237#
     737                 :            :             // Since BRUSH_SIZE alignment is outdated now, i use the
     738                 :            :             // former constant here directly
     739                 :          0 :             aPix.Width() -= 8;
     740                 :            :         }
     741         [ -  + ]:       1828 :         if (aPix.Height() == 0)
     742                 :            :         {
     743                 :            :             // #i2237#
     744                 :            :             // Since BRUSH_SIZE alignment is outdated now, i use the
     745                 :            :             // former constant here directly
     746                 :          0 :             aPix.Height() -= 8;
     747                 :            :         }
     748                 :            :     }
     749                 :            : 
     750         [ +  - ]:       1858 :     aPix = PixelToLogic(aPix);
     751                 :       1858 :     maWinPos.X() = aPix.Width();
     752                 :       1858 :     maWinPos.Y() = aPix.Height();
     753                 :       1858 :     Point aNewOrigin (-maWinPos.X(), -maWinPos.Y());
     754                 :       1858 :     maWinPos += maViewOrigin;
     755                 :            : 
     756         [ +  - ]:       1858 :     MapMode aMap(GetMapMode());
     757         [ +  - ]:       1858 :     aMap.SetOrigin(aNewOrigin);
     758 [ +  - ][ +  - ]:       1858 :     SetMapMode(aMap);
     759                 :       1858 : }
     760                 :            : 
     761                 :            : 
     762                 :            : 
     763                 :            : 
     764                 :            : /*************************************************************************
     765                 :            : |*
     766                 :            : |* X-Position des sichtbaren Bereichs als Bruchteil (< 1)
     767                 :            : |* der gesamten Arbeitsbereichbreite zuruegeben
     768                 :            : |*
     769                 :            : \************************************************************************/
     770                 :            : 
     771                 :       1232 : double Window::GetVisibleX()
     772                 :            : {
     773                 :       1232 :     return ((double) maWinPos.X() / maViewSize.Width());
     774                 :            : }
     775                 :            : 
     776                 :            : /*************************************************************************
     777                 :            : |*
     778                 :            : |* Y-Position des sichtbaren Bereichs als Bruchteil (< 1)
     779                 :            : |* der gesamten Arbeitsbereichhoehe zuruegeben
     780                 :            : |*
     781                 :            : \************************************************************************/
     782                 :            : 
     783                 :       1232 : double Window::GetVisibleY()
     784                 :            : {
     785                 :       1232 :     return ((double) maWinPos.Y() / maViewSize.Height());
     786                 :            : }
     787                 :            : 
     788                 :            : /*************************************************************************
     789                 :            : |*
     790                 :            : |* X- und Y-Position des sichtbaren Bereichs als Bruchteile (< 1)
     791                 :            : |* der gesamten Arbeitsbereichgroesse setzen
     792                 :            : |* negative Werte werden ignoriert
     793                 :            : |*
     794                 :            : \************************************************************************/
     795                 :            : 
     796                 :          4 : void Window::SetVisibleXY(double fX, double fY)
     797                 :            : {
     798                 :          4 :     long nOldX = maWinPos.X();
     799                 :          4 :     long nOldY = maWinPos.Y();
     800                 :            : 
     801         [ +  - ]:          4 :     if ( fX >= 0 )
     802                 :          4 :         maWinPos.X() = (long) (fX * maViewSize.Width());
     803         [ -  + ]:          4 :     if ( fY >= 0 )
     804                 :          0 :         maWinPos.Y() = (long) (fY * maViewSize.Height());
     805                 :          4 :     UpdateMapOrigin(sal_False);
     806                 :          4 :     Scroll(nOldX - maWinPos.X(), nOldY - maWinPos.Y(), SCROLL_CHILDREN);
     807                 :          4 :     Update();
     808                 :          4 : }
     809                 :            : 
     810                 :            : /*************************************************************************
     811                 :            : |*
     812                 :            : |* Breite des sichtbaren Bereichs im Verhaeltnis zur
     813                 :            : |* gesamten Arbeitsbereichbreite zuruegeben
     814                 :            : |*
     815                 :            : \************************************************************************/
     816                 :            : 
     817                 :       2790 : double Window::GetVisibleWidth()
     818                 :            : {
     819         [ +  - ]:       2790 :     Size aWinSize = PixelToLogic(GetOutputSizePixel());
     820         [ -  + ]:       2790 :     if ( aWinSize.Width() > maViewSize.Width() )
     821                 :          0 :         aWinSize.Width() = maViewSize.Width();
     822                 :       2790 :     return ((double) aWinSize.Width() / maViewSize.Width());
     823                 :            : }
     824                 :            : 
     825                 :            : /*************************************************************************
     826                 :            : |*
     827                 :            : |* Hoehe des sichtbaren Bereichs im Verhaeltnis zur
     828                 :            : |* gesamten Arbeitsbereichhoehe zuruegeben
     829                 :            : |*
     830                 :            : \************************************************************************/
     831                 :            : 
     832                 :       3720 : double Window::GetVisibleHeight()
     833                 :            : {
     834         [ +  - ]:       3720 :     Size aWinSize = PixelToLogic(GetOutputSizePixel());
     835         [ -  + ]:       3720 :     if ( aWinSize.Height() > maViewSize.Height() )
     836                 :          0 :         aWinSize.Height() = maViewSize.Height();
     837                 :       3720 :     return ((double) aWinSize.Height() / maViewSize.Height());
     838                 :            : }
     839                 :            : 
     840                 :            : /*************************************************************************
     841                 :            : |*
     842                 :            : |* Breite einer Scrollspalte im Verhaeltnis zur gesamten
     843                 :            : |* Arbeitsbereichbreite zuruegeben
     844                 :            : |*
     845                 :            : \************************************************************************/
     846                 :            : 
     847                 :        930 : double Window::GetScrlLineWidth()
     848                 :            : {
     849                 :        930 :     return (GetVisibleWidth() * SCROLL_LINE_FACT);
     850                 :            : }
     851                 :            : 
     852                 :            : /*************************************************************************
     853                 :            : |*
     854                 :            : |* Breite einer Scrollspalte im Verhaeltnis zur gesamten
     855                 :            : |* Arbeitsbereichhoehe zuruegeben
     856                 :            : |*
     857                 :            : \************************************************************************/
     858                 :            : 
     859                 :        930 : double Window::GetScrlLineHeight()
     860                 :            : {
     861                 :        930 :     return (GetVisibleHeight() * SCROLL_LINE_FACT);
     862                 :            : }
     863                 :            : 
     864                 :            : /*************************************************************************
     865                 :            : |*
     866                 :            : |* Breite einer Scrollpage im Verhaeltnis zur gesamten
     867                 :            : |* Arbeitsbereichbreite zuruegeben
     868                 :            : |*
     869                 :            : \************************************************************************/
     870                 :            : 
     871                 :        930 : double Window::GetScrlPageWidth()
     872                 :            : {
     873                 :        930 :     return (GetVisibleWidth() * SCROLL_PAGE_FACT);
     874                 :            : }
     875                 :            : 
     876                 :            : /*************************************************************************
     877                 :            : |*
     878                 :            : |* Breite einer Scrollpage im Verhaeltnis zur gesamten
     879                 :            : |* Arbeitsbereichhoehe zuruegeben
     880                 :            : |*
     881                 :            : \************************************************************************/
     882                 :            : 
     883                 :        930 : double Window::GetScrlPageHeight()
     884                 :            : {
     885                 :        930 :     return (GetVisibleHeight() * SCROLL_PAGE_FACT);
     886                 :            : }
     887                 :            : 
     888                 :            : /*************************************************************************
     889                 :            : |*
     890                 :            : |* Fenster deaktivieren
     891                 :            : |*
     892                 :            : \************************************************************************/
     893                 :            : 
     894                 :          0 : void Window::LoseFocus()
     895                 :            : {
     896                 :          0 :     mnTicks = 0;
     897                 :          0 :     ::Window::LoseFocus ();
     898                 :          0 : }
     899                 :            : 
     900                 :            : /*************************************************************************
     901                 :            : |*
     902                 :            : |* Fenster aktivieren
     903                 :            : |*
     904                 :            : \************************************************************************/
     905                 :            : 
     906                 :          0 : void Window::GrabFocus()
     907                 :            : {
     908                 :          0 :     mnTicks      = 0;
     909                 :          0 :     ::Window::GrabFocus ();
     910                 :          0 : }
     911                 :            : 
     912                 :            : 
     913                 :            : /*************************************************************************
     914                 :            : |*
     915                 :            : |* DataChanged
     916                 :            : |*
     917                 :            : \************************************************************************/
     918                 :            : 
     919                 :          0 : void Window::DataChanged( const DataChangedEvent& rDCEvt )
     920                 :            : {
     921                 :          0 :     ::Window::DataChanged( rDCEvt );
     922                 :            : 
     923                 :            :     // PRINTER bei allen Dokumenten weglassen, die keinen Printer benutzen.
     924                 :            :     // FONTS und FONTSUBSTITUTION weglassen, wenn keine Textausgaben
     925                 :            :     // vorhanden sind, bzw. wenn das Dokument keinen Text zulaesst.
     926                 :            : 
     927 [ #  # ][ #  #  :          0 :     if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     928                 :          0 :          (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
     929                 :          0 :          (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     930                 :          0 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     931                 :          0 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     932                 :          0 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     933                 :            :     {
     934   [ #  #  #  # ]:          0 :         if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
                 [ #  # ]
     935                 :          0 :              (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     936                 :            :         {
     937                 :            :             // When the screen zoom factor has changed then reset the zoom
     938                 :            :             // factor of the frame to allways display the whole page.
     939                 :          0 :             const AllSettings* pOldSettings = rDCEvt.GetOldSettings ();
     940                 :          0 :             const AllSettings& rNewSettings = GetSettings ();
     941         [ #  # ]:          0 :             if (pOldSettings)
     942         [ #  # ]:          0 :                 if (pOldSettings->GetStyleSettings().GetScreenZoom()
     943                 :          0 :                     != rNewSettings.GetStyleSettings().GetScreenZoom())
     944                 :            :                     mpViewShell->GetViewFrame()->GetDispatcher()->
     945                 :          0 :                         Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     946                 :            : 
     947                 :            :             // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
     948                 :            :             // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
     949                 :            :             // Resize-Handler aber auch die Groesse der ScrollBars aus
     950                 :            :             // den Settings abgefragt werden.
     951                 :          0 :             Resize();
     952                 :            : 
     953                 :            :             // Daten neu Setzen, die aus den Systemeinstellungen bzw. aus
     954                 :            :             // den Settings uebernommen werden. Evtl. weitere Daten neu
     955                 :            :             // berechnen, da sich auch die Aufloesung hierdurch geaendert
     956                 :            :             // haben kann.
     957         [ #  # ]:          0 :             if( mpViewShell )
     958                 :            :             {
     959                 :          0 :                 const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
     960         [ #  # ]:          0 :                 SvtAccessibilityOptions aAccOptions;
     961                 :            :                 sal_uLong                   nOutputMode;
     962                 :            :                 sal_uInt16                  nPreviewSlot;
     963                 :            : 
     964         [ #  # ]:          0 :                 if( rStyleSettings.GetHighContrastMode() )
     965                 :          0 :                     nOutputMode = ViewShell::OUTPUT_DRAWMODE_CONTRAST;
     966                 :            :                 else
     967                 :          0 :                     nOutputMode = ViewShell::OUTPUT_DRAWMODE_COLOR;
     968                 :            : 
     969 [ #  # ][ #  # ]:          0 :                 if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
         [ #  # ][ #  # ]
     970                 :          0 :                     nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
     971                 :            :                 else
     972                 :          0 :                     nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
     973                 :            : 
     974 [ #  # ][ #  # ]:          0 :                 if( mpViewShell->ISA( DrawViewShell ) )
                 [ #  # ]
     975                 :            :                 {
     976         [ #  # ]:          0 :                     SetDrawMode( nOutputMode );
     977         [ #  # ]:          0 :                     mpViewShell->GetFrameView()->SetDrawMode( nOutputMode );
     978         [ #  # ]:          0 :                     Invalidate();
     979                 :            :                 }
     980                 :            : 
     981                 :            :                 // Overwrite window color for OutlineView
     982 [ #  # ][ #  # ]:          0 :                 if( mpViewShell->ISA(OutlineViewShell ) )
                 [ #  # ]
     983                 :            :                 {
     984         [ #  # ]:          0 :                     svtools::ColorConfig aColorConfig;
     985         [ #  # ]:          0 :                     const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
     986 [ #  # ][ #  # ]:          0 :                     SetBackground( Wallpaper( aDocColor ) );
         [ #  # ][ #  # ]
     987                 :            :                 }
     988                 :            : 
     989 [ #  # ][ #  # ]:          0 :                 SfxRequest aReq( nPreviewSlot, 0, mpViewShell->GetDocSh()->GetDoc()->GetItemPool() );
                 [ #  # ]
     990         [ #  # ]:          0 :                 mpViewShell->ExecReq( aReq );
     991         [ #  # ]:          0 :                 mpViewShell->Invalidate();
     992         [ #  # ]:          0 :                 mpViewShell->ArrangeGUIElements();
     993                 :            : 
     994                 :            :                 // re-create handles to show new outfit
     995 [ #  # ][ #  # ]:          0 :                 if(mpViewShell->ISA(DrawViewShell))
                 [ #  # ]
     996                 :            :                 {
     997         [ #  # ]:          0 :                     mpViewShell->GetView()->AdjustMarkHdl();
     998 [ #  # ][ #  # ]:          0 :                 }
     999                 :            :             }
    1000                 :            :         }
    1001                 :            : 
    1002   [ #  #  #  #  :          0 :         if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
                   #  # ]
    1003                 :          0 :              ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1004                 :          0 :               (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    1005                 :            :         {
    1006                 :            :             // Virtuelle Device die auch von der Aufloesung oder von
    1007                 :            :             // Systemeinstellungen abhaengen, sollten geupdatet werden.
    1008                 :            :             // Ansonsten sollte zumindest bei DATACHANGED_DISPLAY
    1009                 :            :             // die virtuellen Devices geupdatet werden, da es einige
    1010                 :            :             // Systeme erlauben die Aufloesung und Farbtiefe waehrend
    1011                 :            :             // der Laufzeit zu aendern oder eben bei Palettenaenderungen
    1012                 :            :             // die virtuellen Device geupdatet werden muessen, da bei
    1013                 :            :             // Ausgaben ein anderes Farbmatching stattfinden kann.
    1014                 :            :         }
    1015                 :            : 
    1016                 :          0 :         if ( rDCEvt.GetType() == DATACHANGED_FONTS )
    1017                 :            :         {
    1018                 :            :             // Wenn das Dokument Font-AuswahlBoxen anbietet, muessen
    1019                 :            :             // diese geupdatet werden. Wie dies genau aussehen muss,
    1020                 :            :             // weiss ich leider auch nicht. Aber evtl. kann man das
    1021                 :            :             // ja global handeln. Dies muessten wir evtl. mal
    1022                 :            :             // mit PB absprechen, aber der ist derzeit leider Krank.
    1023                 :            :             // Also bevor dies hier gehandelt wird, vorher mit
    1024                 :            :             // PB und mir absprechen.
    1025                 :            :         }
    1026                 :            : 
    1027         [ #  # ]:          0 :         if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
           [ #  #  #  # ]
    1028                 :          0 :              (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) )
    1029                 :            :         {
    1030                 :            :             // Formatierung neu durchfuehren, da Fonts die im Dokument
    1031                 :            :             // vorkommen, nicht mehr vorhanden sein muessen oder
    1032                 :            :             // jetzt vorhanden sind oder durch andere ersetzt wurden
    1033                 :            :             // sind.
    1034         [ #  # ]:          0 :             if( mpViewShell )
    1035                 :            :             {
    1036                 :          0 :                 DrawDocShell* pDocSh = mpViewShell->GetDocSh();
    1037         [ #  # ]:          0 :                 if( pDocSh )
    1038                 :          0 :                     pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
    1039                 :            :             }
    1040                 :            :         }
    1041                 :            : 
    1042         [ #  # ]:          0 :         if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
    1043                 :            :         {
    1044                 :            :             // Wie hier die Behandlung aussehen soll, weiss ich leider
    1045                 :            :             // selbst noch nicht. Evtl. mal einen Printer loeschen und
    1046                 :            :             // schauen was gemacht werden muss. Evtl. muesste ich in
    1047                 :            :             // VCL dafuer noch etwas einbauen, wenn der benutze Printer
    1048                 :            :             // geloescht wird. Ansonsten wuerde ich hier evtl. die
    1049                 :            :             // Formatierung neu berechnen, wenn der aktuelle Drucker
    1050                 :            :             // zerstoert wurde.
    1051         [ #  # ]:          0 :             if( mpViewShell )
    1052                 :            :             {
    1053                 :          0 :                 DrawDocShell* pDocSh = mpViewShell->GetDocSh();
    1054         [ #  # ]:          0 :                 if( pDocSh )
    1055                 :          0 :                     pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
    1056                 :            :             }
    1057                 :            :         }
    1058                 :            : 
    1059                 :            :         // Alles neu ausgeben
    1060                 :          0 :         Invalidate();
    1061                 :            :     }
    1062                 :          0 : }
    1063                 :            : 
    1064                 :            : 
    1065                 :            : 
    1066                 :            : 
    1067                 :            : /*************************************************************************
    1068                 :            : |*
    1069                 :            : |* DropTargetHelper::AcceptDrop
    1070                 :            : |*
    1071                 :            : \************************************************************************/
    1072                 :            : 
    1073                 :          0 : sal_Int8 Window::AcceptDrop( const AcceptDropEvent& rEvt )
    1074                 :            : {
    1075                 :          0 :     sal_Int8 nRet = DND_ACTION_NONE;
    1076                 :            : 
    1077 [ #  # ][ #  # ]:          0 :     if( mpViewShell && !mpViewShell->GetDocSh()->IsReadOnly() )
                 [ #  # ]
    1078                 :            :     {
    1079         [ #  # ]:          0 :         if( mpViewShell )
    1080                 :          0 :             nRet = mpViewShell->AcceptDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
    1081                 :            : 
    1082 [ #  # ][ #  # ]:          0 :         if (mbUseDropScroll && ! mpViewShell->ISA(OutlineViewShell))
                 [ #  # ]
    1083                 :          0 :             DropScroll( rEvt.maPosPixel );
    1084                 :            :     }
    1085                 :            : 
    1086                 :          0 :     return nRet;
    1087                 :            : }
    1088                 :            : 
    1089                 :            : /*************************************************************************
    1090                 :            : |*
    1091                 :            : |* DropTargetHelper::ExecuteDrop
    1092                 :            : |*
    1093                 :            : \************************************************************************/
    1094                 :            : 
    1095                 :          0 : sal_Int8 Window::ExecuteDrop( const ExecuteDropEvent& rEvt )
    1096                 :            : {
    1097                 :          0 :     sal_Int8 nRet = DND_ACTION_NONE;
    1098                 :            : 
    1099         [ #  # ]:          0 :     if( mpViewShell )
    1100                 :            :     {
    1101                 :          0 :         nRet = mpViewShell->ExecuteDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
    1102                 :            :     }
    1103                 :            : 
    1104                 :          0 :     return nRet;
    1105                 :            : }
    1106                 :            : 
    1107                 :            : 
    1108                 :            : 
    1109                 :            : 
    1110                 :        130 : void Window::SetUseDropScroll (bool bUseDropScroll)
    1111                 :            : {
    1112                 :        130 :     mbUseDropScroll = bUseDropScroll;
    1113                 :        130 : }
    1114                 :            : 
    1115                 :            : 
    1116                 :            : 
    1117                 :            : 
    1118                 :            : /*************************************************************************
    1119                 :            : |*
    1120                 :            : |* Scrolling bei AcceptDrop-Events
    1121                 :            : |*
    1122                 :            : \************************************************************************/
    1123                 :            : 
    1124                 :          0 : void Window::DropScroll(const Point& rMousePos)
    1125                 :            : {
    1126                 :          0 :     short nDx = 0;
    1127                 :          0 :     short nDy = 0;
    1128                 :            : 
    1129                 :          0 :     Size aSize = GetOutputSizePixel();
    1130                 :            : 
    1131         [ #  # ]:          0 :     if (aSize.Width() > SCROLL_SENSITIVE * 3)
    1132                 :            :     {
    1133         [ #  # ]:          0 :         if ( rMousePos.X() < SCROLL_SENSITIVE )
    1134                 :            :         {
    1135                 :          0 :             nDx = -1;
    1136                 :            :         }
    1137                 :            : 
    1138         [ #  # ]:          0 :         if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE )
    1139                 :            :         {
    1140                 :          0 :             nDx = 1;
    1141                 :            :         }
    1142                 :            :     }
    1143                 :            : 
    1144         [ #  # ]:          0 :     if (aSize.Height() > SCROLL_SENSITIVE * 3)
    1145                 :            :     {
    1146         [ #  # ]:          0 :         if ( rMousePos.Y() < SCROLL_SENSITIVE )
    1147                 :            :         {
    1148                 :          0 :             nDy = -1;
    1149                 :            :         }
    1150                 :            : 
    1151         [ #  # ]:          0 :         if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE )
    1152                 :            :         {
    1153                 :          0 :             nDy = 1;
    1154                 :            :         }
    1155                 :            :     }
    1156                 :            : 
    1157 [ #  # ][ #  # ]:          0 :     if ( (nDx || nDy) && (rMousePos.X()!=0 || rMousePos.Y()!=0 ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1158                 :            :     {
    1159         [ #  # ]:          0 :         if (mnTicks > 20)
    1160         [ #  # ]:          0 :             mpViewShell->ScrollLines(nDx, nDy);
    1161                 :            :         else
    1162                 :          0 :             mnTicks ++;
    1163                 :            :     }
    1164                 :          0 : }
    1165                 :            : 
    1166                 :            : 
    1167                 :            : 
    1168                 :            : 
    1169                 :            : ::com::sun::star::uno::Reference<
    1170                 :            :     ::com::sun::star::accessibility::XAccessible>
    1171                 :         32 :     Window::CreateAccessible (void)
    1172                 :            : {
    1173         [ +  - ]:         32 :     if (mpViewShell != NULL)
    1174                 :         32 :         return mpViewShell->CreateAccessibleDocumentView (this);
    1175                 :            :     else
    1176                 :            :     {
    1177                 :            :         OSL_TRACE ("::sd::Window::CreateAccessible: no view shell");
    1178                 :         32 :         return ::Window::CreateAccessible ();
    1179                 :            :     }
    1180                 :            : }
    1181                 :            : 
    1182                 :          0 : rtl::OUString Window::GetSurroundingText() const
    1183                 :            : {
    1184         [ #  # ]:          0 :     if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
    1185                 :          0 :         return rtl::OUString();
    1186         [ #  # ]:          0 :     else if ( mpViewShell->GetView()->IsTextEdit() )
    1187                 :            :     {
    1188                 :          0 :         OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
    1189         [ #  # ]:          0 :         return pOLV->GetEditView().GetSurroundingText();
    1190                 :            :     }
    1191                 :          0 :     return rtl::OUString();
    1192                 :            : }
    1193                 :            : 
    1194                 :          0 : Selection Window::GetSurroundingTextSelection() const
    1195                 :            : {
    1196         [ #  # ]:          0 :     if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
    1197                 :            :     {
    1198                 :          0 :         return Selection( 0, 0 );
    1199                 :            :     }
    1200         [ #  # ]:          0 :     else if ( mpViewShell->GetView()->IsTextEdit() )
    1201                 :            :     {
    1202                 :          0 :         OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
    1203                 :          0 :         return pOLV->GetEditView().GetSurroundingTextSelection();
    1204                 :            :     }
    1205                 :            :     else
    1206                 :            :     {
    1207                 :          0 :         return Selection( 0, 0 );
    1208                 :            :     }
    1209                 :            : }
    1210                 :            : 
    1211                 :            : } // end of namespace sd
    1212                 :            : 
    1213                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10