LCOV - code coverage report
Current view: top level - sd/source/ui/tools - PreviewRenderer.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 130 226 57.5 %
Date: 2014-04-11 Functions: 15 19 78.9 %
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             : 
      21             : #include "PreviewRenderer.hxx"
      22             : 
      23             : #include "DrawDocShell.hxx"
      24             : #include "drawdoc.hxx"
      25             : #include "drawview.hxx"
      26             : #include "sdpage.hxx"
      27             : #include "ViewShell.hxx"
      28             : #include <vcl/virdev.hxx>
      29             : #include <vcl/settings.hxx>
      30             : 
      31             : #include <svx/svdpagv.hxx>
      32             : #include <svx/svdoutl.hxx>
      33             : #include <editeng/eeitem.hxx>
      34             : #include <editeng/editstat.hxx>
      35             : #include <vcl/svapp.hxx>
      36             : #include <tools/diagnose_ex.h>
      37             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      38             : #include <svx/sdr/contact/viewcontact.hxx>
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::com::sun::star::uno;
      42             : 
      43             : 
      44             : namespace sd {
      45             : 
      46             : const int PreviewRenderer::snSubstitutionTextSize = 11;
      47             : const int PreviewRenderer::snFrameWidth = 1;
      48             : 
      49             : namespace {
      50             :     /** This incarnation of the ViewObjectContactRedirector filters away all
      51             :         PageObj objects, unconditionally.
      52             :     */
      53             :     class ViewRedirector : public ::sdr::contact::ViewObjectContactRedirector
      54             :     {
      55             :     public:
      56             :         ViewRedirector (void);
      57             :         virtual ~ViewRedirector (void);
      58             :         virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
      59             :             const sdr::contact::ViewObjectContact& rOriginal,
      60             :                 const sdr::contact::DisplayInfo& rDisplayInfo) SAL_OVERRIDE;
      61             :     };
      62             : }
      63             : 
      64             : 
      65             : 
      66             : 
      67             : //===== PreviewRenderer =======================================================
      68             : 
      69          64 : PreviewRenderer::PreviewRenderer (
      70             :     OutputDevice* pTemplate,
      71             :     const bool bHasFrame)
      72           0 :     : mpPreviewDevice (new VirtualDevice()),
      73             :       mpView(NULL),
      74             :       mpDocShellOfView(NULL),
      75         128 :       maFrameColor (svtools::ColorConfig().GetColorValue(svtools::DOCBOUNDARIES).nColor),
      76         192 :       mbHasFrame(bHasFrame)
      77             : {
      78          64 :     if (pTemplate != NULL)
      79             :     {
      80           0 :         mpPreviewDevice->SetDigitLanguage (pTemplate->GetDigitLanguage());
      81           0 :         mpPreviewDevice->SetBackground(pTemplate->GetBackground());
      82             :     }
      83             :     else
      84             :     {
      85          64 :         mpPreviewDevice->SetBackground(Wallpaper(
      86         128 :             Application::GetSettings().GetStyleSettings().GetWindowColor()));
      87             :     }
      88          64 : }
      89             : 
      90             : 
      91             : 
      92             : 
      93         128 : PreviewRenderer::~PreviewRenderer (void)
      94             : {
      95          64 :     if (mpDocShellOfView != NULL)
      96          62 :         EndListening (*mpDocShellOfView);
      97          64 : }
      98             : 
      99             : 
     100             : 
     101             : 
     102           0 : Image PreviewRenderer::RenderPage (
     103             :     const SdPage* pPage,
     104             :     const sal_Int32 nWidth,
     105             :     const OUString& rSubstitutionText,
     106             :     const bool bObeyHighContrastMode,
     107             :     const bool bDisplayPresentationObjects)
     108             : {
     109           0 :     if (pPage != NULL)
     110             :     {
     111           0 :         const Size aPageModelSize (pPage->GetSize());
     112             :         const double nAspectRatio (
     113           0 :             double(aPageModelSize.Width()) / double(aPageModelSize.Height()));
     114           0 :         const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
     115             :         const sal_Int32 nHeight (sal::static_int_cast<sal_Int32>(
     116           0 :             (nWidth - 2*nFrameWidth) / nAspectRatio + 2*nFrameWidth + 0.5));
     117             :         return RenderPage (
     118             :             pPage,
     119             :             Size(nWidth,nHeight),
     120             :             rSubstitutionText,
     121             :             bObeyHighContrastMode,
     122           0 :             bDisplayPresentationObjects);
     123             :     }
     124             :     else
     125           0 :         return Image();
     126             : }
     127             : 
     128             : 
     129             : 
     130             : 
     131         134 : Image PreviewRenderer::RenderPage (
     132             :     const SdPage* pPage,
     133             :     Size aPixelSize,
     134             :     const OUString& rSubstitutionText,
     135             :     const bool bObeyHighContrastMode,
     136             :     const bool bDisplayPresentationObjects)
     137             : {
     138         134 :     Image aPreview;
     139             : 
     140         134 :     if (pPage != NULL)
     141             :     {
     142             :         try
     143             :         {
     144         134 :             if (Initialize(pPage, aPixelSize, bObeyHighContrastMode))
     145             :             {
     146         134 :                 PaintPage(pPage, bDisplayPresentationObjects);
     147         134 :                 PaintSubstitutionText(rSubstitutionText);
     148         134 :                 PaintFrame();
     149             : 
     150         134 :                 Size aSize (mpPreviewDevice->GetOutputSizePixel());
     151         536 :                 aPreview = Image(mpPreviewDevice->GetBitmap (
     152         268 :                     mpPreviewDevice->PixelToLogic(Point(0,0)),
     153         268 :                     mpPreviewDevice->PixelToLogic(aSize)));
     154             : 
     155         134 :                 Cleanup();
     156             :             }
     157             :         }
     158           0 :         catch (const com::sun::star::uno::Exception&)
     159             :         {
     160             :             DBG_UNHANDLED_EXCEPTION();
     161             :         }
     162             :     }
     163             : 
     164         134 :     return aPreview;
     165             : }
     166             : 
     167             : 
     168             : 
     169             : 
     170           0 : Image PreviewRenderer::RenderSubstitution (
     171             :     const Size& rPreviewPixelSize,
     172             :     const OUString& rSubstitutionText)
     173             : {
     174           0 :     Image aPreview;
     175             : 
     176             :     try
     177             :     {
     178             :         // Set size.
     179           0 :         mpPreviewDevice->SetOutputSizePixel(rPreviewPixelSize);
     180             : 
     181             :         // Adjust contrast mode.
     182             :         const bool bUseContrast (
     183           0 :             Application::GetSettings().GetStyleSettings().GetHighContrastMode());
     184           0 :         mpPreviewDevice->SetDrawMode (bUseContrast
     185             :             ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     186           0 :             : ViewShell::OUTPUT_DRAWMODE_COLOR);
     187             : 
     188             :         // Set a map mode that makes a typical substitution text completely
     189             :         // visible.
     190           0 :         MapMode aMapMode (mpPreviewDevice->GetMapMode());
     191           0 :         aMapMode.SetMapUnit(MAP_100TH_MM);
     192           0 :         const double nFinalScale (25.0 * rPreviewPixelSize.Width() / 28000.0);
     193           0 :         aMapMode.SetScaleX(nFinalScale);
     194           0 :         aMapMode.SetScaleY(nFinalScale);
     195           0 :         const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
     196           0 :         aMapMode.SetOrigin(mpPreviewDevice->PixelToLogic(
     197           0 :             Point(nFrameWidth,nFrameWidth),aMapMode));
     198           0 :         mpPreviewDevice->SetMapMode (aMapMode);
     199             : 
     200             :         // Clear the background.
     201             :         const Rectangle aPaintRectangle (
     202             :             Point(0,0),
     203           0 :             mpPreviewDevice->GetOutputSizePixel());
     204           0 :         mpPreviewDevice->EnableMapMode(false);
     205           0 :         mpPreviewDevice->SetLineColor();
     206           0 :         svtools::ColorConfig aColorConfig;
     207           0 :         mpPreviewDevice->SetFillColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
     208           0 :         mpPreviewDevice->DrawRect (aPaintRectangle);
     209           0 :         mpPreviewDevice->EnableMapMode(true);
     210             : 
     211             :         // Paint substitution text and a frame around it.
     212           0 :         PaintSubstitutionText (rSubstitutionText);
     213           0 :         PaintFrame();
     214             : 
     215           0 :         const Size aSize (mpPreviewDevice->GetOutputSizePixel());
     216           0 :         aPreview = Image(mpPreviewDevice->GetBitmap(
     217           0 :             mpPreviewDevice->PixelToLogic(Point(0,0)),
     218           0 :             mpPreviewDevice->PixelToLogic(aSize)));
     219             :     }
     220           0 :     catch (const com::sun::star::uno::Exception&)
     221             :     {
     222             :         DBG_UNHANDLED_EXCEPTION();
     223             :     }
     224             : 
     225           0 :     return aPreview;
     226             : }
     227             : 
     228             : 
     229             : 
     230             : 
     231         134 : bool PreviewRenderer::Initialize (
     232             :     const SdPage* pPage,
     233             :     const Size& rPixelSize,
     234             :     const bool bObeyHighContrastMode)
     235             : {
     236         134 :     if (pPage == NULL)
     237           0 :         return false;
     238             : 
     239         134 :     SdrModel* pModel = pPage->GetModel();
     240         134 :     if (pModel == NULL)
     241           0 :         return false;
     242             : 
     243         134 :     SetupOutputSize(*pPage, rPixelSize);
     244             : 
     245             :     SdDrawDocument* pDocument
     246         134 :         = static_cast<SdDrawDocument*>(pPage->GetModel());
     247         134 :     DrawDocShell* pDocShell = pDocument->GetDocSh();
     248             : 
     249             :     // Create view
     250         134 :     ProvideView (pDocShell);
     251         134 :     if (mpView.get() == NULL)
     252           0 :         return false;
     253             : 
     254             :     // Adjust contrast mode.
     255             :     bool bUseContrast (bObeyHighContrastMode
     256         134 :         && Application::GetSettings().GetStyleSettings().GetHighContrastMode());
     257         134 :     mpPreviewDevice->SetDrawMode (bUseContrast
     258             :         ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     259         268 :         : ViewShell::OUTPUT_DRAWMODE_COLOR);
     260         134 :     mpPreviewDevice->SetSettings(Application::GetSettings());
     261             : 
     262             :     // Tell the view to show the given page.
     263         134 :     SdPage* pNonConstPage = const_cast<SdPage*>(pPage);
     264         134 :     if (pPage->IsMasterPage())
     265             :     {
     266           5 :         mpView->ShowSdrPage(mpView->GetModel()->GetMasterPage(pPage->GetPageNum()));
     267             :     }
     268             :     else
     269             :     {
     270         129 :         mpView->ShowSdrPage(pNonConstPage);
     271             :     }
     272             : 
     273             :     // Make sure that a page view exists.
     274         134 :     SdrPageView* pPageView = mpView->GetSdrPageView();
     275             : 
     276         134 :     if (pPageView == NULL)
     277           0 :         return false;
     278             : 
     279             :     // #i121224# No need to set SetApplicationBackgroundColor (which is the color
     280             :     // of the area 'behind' the page (formally called 'Wiese') since the page previews
     281             :     // produced exactly cover the page's area, so it would never be visible. What
     282             :     // needs to be set is the ApplicationDocumentColor which is derived from
     283             :     // svtools::DOCCOLOR normally
     284         134 :     Color aApplicationDocumentColor;
     285             : 
     286         134 :     if (pPageView->GetApplicationDocumentColor() == COL_AUTO)
     287             :     {
     288         134 :         svtools::ColorConfig aColorConfig;
     289         134 :         aApplicationDocumentColor = aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor;
     290             :     }
     291             :     else
     292             :     {
     293           0 :         aApplicationDocumentColor = pPageView->GetApplicationDocumentColor();
     294             :     }
     295             : 
     296         134 :     pPageView->SetApplicationDocumentColor(aApplicationDocumentColor);
     297         134 :     SdrOutliner& rOutliner(pDocument->GetDrawOutliner(NULL));
     298         134 :     rOutliner.SetBackgroundColor(aApplicationDocumentColor);
     299         134 :     rOutliner.SetDefaultLanguage(pDocument->GetLanguage(EE_CHAR_LANGUAGE));
     300         134 :     mpPreviewDevice->SetBackground(Wallpaper(aApplicationDocumentColor));
     301         134 :     mpPreviewDevice->Erase();
     302             : 
     303         134 :     return true;
     304             : }
     305             : 
     306             : 
     307             : 
     308             : 
     309         134 : void PreviewRenderer::Cleanup (void)
     310             : {
     311         134 :     mpView->HideSdrPage();
     312         134 : }
     313             : 
     314             : 
     315             : 
     316             : 
     317         134 : void PreviewRenderer::PaintPage (
     318             :     const SdPage* pPage,
     319             :     const bool bDisplayPresentationObjects)
     320             : {
     321             :     // Paint the page.
     322         134 :     Rectangle aPaintRectangle (Point(0,0), pPage->GetSize());
     323         134 :     Region aRegion (aPaintRectangle);
     324             : 
     325             :     // Turn off online spelling and redlining.
     326         134 :     SdrOutliner* pOutliner = NULL;
     327         134 :     sal_uLong nSavedControlWord (0);
     328         134 :     if (mpDocShellOfView!=NULL && mpDocShellOfView->GetDoc()!=NULL)
     329             :     {
     330         134 :         pOutliner = &mpDocShellOfView->GetDoc()->GetDrawOutliner();
     331         134 :         nSavedControlWord = pOutliner->GetControlWord();
     332         134 :         pOutliner->SetControlWord((nSavedControlWord & ~EE_CNTRL_ONLINESPELLING));
     333             :     }
     334             : 
     335             :     // Use a special redirector to prevent PresObj shapes from being painted.
     336         268 :     boost::scoped_ptr<ViewRedirector> pRedirector;
     337         134 :     if ( ! bDisplayPresentationObjects)
     338         134 :         pRedirector.reset(new ViewRedirector());
     339             : 
     340             :     try
     341             :     {
     342         134 :         mpView->CompleteRedraw(mpPreviewDevice.get(), aRegion, pRedirector.get());
     343             :     }
     344           0 :     catch (const ::com::sun::star::uno::Exception&)
     345             :     {
     346             :         DBG_UNHANDLED_EXCEPTION();
     347             :     }
     348             : 
     349             :     // Restore the previous online spelling and redlining states.
     350         134 :     if (pOutliner != NULL)
     351         268 :         pOutliner->SetControlWord(nSavedControlWord);
     352         134 : }
     353             : 
     354             : 
     355             : 
     356             : 
     357         134 : void PreviewRenderer::PaintSubstitutionText (const OUString& rSubstitutionText)
     358             : {
     359         134 :     if (!rSubstitutionText.isEmpty())
     360             :     {
     361             :         // Set the font size.
     362           0 :         const Font& rOriginalFont (mpPreviewDevice->GetFont());
     363           0 :         Font aFont (mpPreviewDevice->GetSettings().GetStyleSettings().GetAppFont());
     364           0 :         sal_Int32 nHeight (mpPreviewDevice->PixelToLogic(Size(0,snSubstitutionTextSize)).Height());
     365           0 :         aFont.SetHeight(nHeight);
     366           0 :         mpPreviewDevice->SetFont (aFont);
     367             : 
     368             :         // Paint the substitution text.
     369             :         Rectangle aTextBox (
     370             :             Point(0,0),
     371           0 :             mpPreviewDevice->PixelToLogic(
     372           0 :                 mpPreviewDevice->GetOutputSizePixel()));
     373             :         sal_uInt16 nTextStyle =
     374             :             TEXT_DRAW_CENTER
     375             :             | TEXT_DRAW_VCENTER
     376             :             | TEXT_DRAW_MULTILINE
     377           0 :             | TEXT_DRAW_WORDBREAK;
     378           0 :         mpPreviewDevice->DrawText (aTextBox, rSubstitutionText, nTextStyle);
     379             : 
     380             :         // Restore the font.
     381           0 :         mpPreviewDevice->SetFont (rOriginalFont);
     382             :     }
     383         134 : }
     384             : 
     385             : 
     386             : 
     387             : 
     388         134 : void PreviewRenderer::PaintFrame (void)
     389             : {
     390         134 :     if (mbHasFrame)
     391             :     {
     392             :         // Paint a frame arround the preview.
     393             :         Rectangle aPaintRectangle (
     394             :             Point(0,0),
     395           0 :             mpPreviewDevice->GetOutputSizePixel());
     396           0 :         mpPreviewDevice->EnableMapMode(false);
     397           0 :         mpPreviewDevice->SetLineColor(maFrameColor);
     398           0 :         mpPreviewDevice->SetFillColor();
     399           0 :         mpPreviewDevice->DrawRect(aPaintRectangle);
     400           0 :         mpPreviewDevice->EnableMapMode(true);
     401             :      }
     402         134 : }
     403             : 
     404             : 
     405             : 
     406             : 
     407         134 : void PreviewRenderer::SetupOutputSize (
     408             :     const SdPage& rPage,
     409             :     const Size& rFramePixelSize)
     410             : {
     411             :     // First set the map mode to some arbitrary scale that is numerically
     412             :     // stable.
     413         134 :     MapMode aMapMode (mpPreviewDevice->GetMapMode());
     414         134 :     aMapMode.SetMapUnit(MAP_PIXEL);
     415             : 
     416             :     // Adapt it to the desired width.
     417         134 :     const Size aPageModelSize (rPage.GetSize());
     418         134 :     if (aPageModelSize.Width()>0 || aPageModelSize.Height()>0)
     419             :     {
     420         134 :         const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
     421             :         aMapMode.SetScaleX(
     422         134 :             Fraction(rFramePixelSize.Width()-2*nFrameWidth-1, aPageModelSize.Width()));
     423             :         aMapMode.SetScaleY(
     424         134 :             Fraction(rFramePixelSize.Height()-2*nFrameWidth-1, aPageModelSize.Height()));
     425         134 :         aMapMode.SetOrigin(mpPreviewDevice->PixelToLogic(Point(nFrameWidth,nFrameWidth),aMapMode));
     426             :     }
     427             :     else
     428             :     {
     429             :         // We should never get here.
     430             :         OSL_ASSERT(false);
     431           0 :         aMapMode.SetScaleX(1.0);
     432           0 :         aMapMode.SetScaleY(1.0);
     433             :     }
     434         134 :     mpPreviewDevice->SetMapMode (aMapMode);
     435         134 :     mpPreviewDevice->SetOutputSizePixel(rFramePixelSize);
     436         134 : }
     437             : 
     438             : 
     439             : 
     440             : 
     441         134 : void PreviewRenderer::ProvideView (DrawDocShell* pDocShell)
     442             : {
     443         134 :     if (pDocShell != mpDocShellOfView)
     444             :     {
     445             :         // Destroy the view that is connected to the current doc shell.
     446          62 :         mpView.reset();
     447             : 
     448             :         // Switch our attention, i.e. listening for DYING events, to
     449             :         // the new doc shell.
     450          62 :         if (mpDocShellOfView != NULL)
     451           0 :             EndListening (*mpDocShellOfView);
     452          62 :         mpDocShellOfView = pDocShell;
     453          62 :         if (mpDocShellOfView != NULL)
     454          62 :             StartListening (*mpDocShellOfView);
     455             :     }
     456         134 :     if (mpView.get() == NULL)
     457             :     {
     458          62 :         mpView.reset (new DrawView (pDocShell, mpPreviewDevice.get(), NULL));
     459             :     }
     460         134 :     mpView->SetPreviewRenderer(true);
     461             : #if 1
     462         134 :     mpView->SetPageVisible(false);
     463         134 :     mpView->SetPageBorderVisible(true);
     464         134 :     mpView->SetBordVisible(false);
     465         134 :     mpView->SetGridVisible(false);
     466         134 :     mpView->SetHlplVisible(false);
     467         134 :     mpView->SetGlueVisible(false);
     468             : 
     469             : #else
     470             :     // This works in the slide sorter but prevents the master page
     471             :     // background being painted in the list of current master pages in the
     472             :     // task manager.
     473             :     mpView->SetPagePaintingAllowed(false);
     474             : #endif
     475         134 : }
     476             : 
     477             : 
     478             : 
     479             : 
     480           0 : Image PreviewRenderer::ScaleBitmap (
     481             :     const BitmapEx& rBitmapEx,
     482             :     int nWidth)
     483             : {
     484           0 :     Image aPreview;
     485             : 
     486             :     do
     487             :     {
     488             :         // Adjust contrast mode.
     489           0 :         bool bUseContrast = Application::GetSettings().GetStyleSettings().
     490           0 :             GetHighContrastMode();
     491           0 :         mpPreviewDevice->SetDrawMode (bUseContrast
     492             :             ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     493           0 :             : ViewShell::OUTPUT_DRAWMODE_COLOR);
     494             : 
     495             :         // Set output size.
     496           0 :         Size aSize (rBitmapEx.GetSizePixel());
     497           0 :         if (aSize.Width() <= 0)
     498           0 :             break;
     499             :         Size aFrameSize (
     500             :             nWidth,
     501           0 :             (long)((nWidth*1.0 * aSize.Height()) / aSize.Width() + 0.5));
     502           0 :         Size aPreviewSize (aFrameSize.Width()-2,aFrameSize.Height()-2);
     503           0 :         MapMode aMapMode (mpPreviewDevice->GetMapMode());
     504           0 :         aMapMode.SetMapUnit(MAP_PIXEL);
     505           0 :         aMapMode.SetOrigin (Point());
     506           0 :         aMapMode.SetScaleX (1.0);
     507           0 :         aMapMode.SetScaleY (1.0);
     508           0 :         mpPreviewDevice->SetMapMode (aMapMode);
     509           0 :         mpPreviewDevice->SetOutputSize (aFrameSize);
     510             : 
     511             :         // Paint a frame arround the preview.
     512           0 :         mpPreviewDevice->SetLineColor (maFrameColor);
     513           0 :         mpPreviewDevice->SetFillColor ();
     514           0 :         mpPreviewDevice->DrawRect (Rectangle(Point(0,0), aFrameSize));
     515             : 
     516             :         // Paint the bitmap scaled to the desired width.
     517           0 :         BitmapEx aScaledBitmap (rBitmapEx.GetBitmap());
     518           0 :         aScaledBitmap.Scale (aPreviewSize, BMP_SCALE_BESTQUALITY);
     519           0 :         mpPreviewDevice->DrawBitmap (
     520             :             Point(1,1),
     521             :             aPreviewSize,
     522           0 :             aScaledBitmap.GetBitmap());
     523             : 
     524             :         // Get the resulting bitmap.
     525           0 :         aPreview = Image(mpPreviewDevice->GetBitmap(Point(0,0), aFrameSize));
     526             :     }
     527             :     while (false);
     528             : 
     529           0 :     return aPreview;
     530             : }
     531             : 
     532             : 
     533             : 
     534             : 
     535        1309 : void PreviewRenderer::Notify(SfxBroadcaster&, const SfxHint& rHint)
     536             : {
     537        2618 :     if (rHint.IsA(TYPE(SfxSimpleHint))
     538        1309 :         && mpDocShellOfView != NULL)
     539             :     {
     540        1232 :         const SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, &rHint);
     541        1232 :         if (pSimpleHint != NULL
     542        1232 :             && pSimpleHint->GetId() == SFX_HINT_DYING)
     543             :         {
     544             :             // The doc shell is dying.  Our view uses its item pool and
     545             :             // has to be destroyed as well.  The next call to
     546             :             // ProvideView will create a new one (for another
     547             :             // doc shell, of course.)
     548           0 :             mpView.reset();
     549           0 :             mpDocShellOfView = NULL;
     550             :         }
     551             :     }
     552        1309 : }
     553             : 
     554             : 
     555             : 
     556             : 
     557             : //===== ViewRedirector ========================================================
     558             : 
     559             : namespace {
     560             : 
     561         134 : ViewRedirector::ViewRedirector (void)
     562             : {
     563         134 : }
     564             : 
     565             : 
     566             : 
     567             : 
     568         268 : ViewRedirector::~ViewRedirector (void)
     569             : {
     570         268 : }
     571             : 
     572             : 
     573             : 
     574             : 
     575         302 : drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedPrimitive2DSequence(
     576             :     const sdr::contact::ViewObjectContact& rOriginal,
     577             :     const sdr::contact::DisplayInfo& rDisplayInfo)
     578             : {
     579         302 :     SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
     580             : 
     581         302 :     if (pObject==NULL || pObject->GetPage() == NULL)
     582             :     {
     583             :         // not a SdrObject visualisation (maybe e.g. page) or no page
     584             :         return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
     585             :             rOriginal,
     586           5 :             rDisplayInfo);
     587             :     }
     588             : 
     589         297 :     const bool bDoCreateGeometry (pObject->GetPage()->checkVisibility( rOriginal, rDisplayInfo, true));
     590             : 
     591         594 :     if ( ! bDoCreateGeometry
     592         297 :         && (pObject->GetObjInventor() != SdrInventor || pObject->GetObjIdentifier() != OBJ_PAGE))
     593             :     {
     594          18 :         return drawinglayer::primitive2d::Primitive2DSequence();
     595             :     }
     596             : 
     597         279 :     if (pObject->IsEmptyPresObj())
     598          36 :         return drawinglayer::primitive2d::Primitive2DSequence();
     599             : 
     600             :     return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
     601             :         rOriginal,
     602         243 :         rDisplayInfo);
     603             : }
     604             : 
     605             : } // end of anonymous namespace
     606             : 
     607             : 
     608             : } // end of namespace ::sd
     609             : 
     610             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10