LCOV - code coverage report
Current view: top level - sd/source/ui/view - sdview.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 628 0.0 %
Date: 2014-04-14 Functions: 0 50 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      21             : #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
      22             : 
      23             : #include "View.hxx"
      24             : #include <editeng/unolingu.hxx>
      25             : #include <sfx2/request.hxx>
      26             : #include <svx/obj3d.hxx>
      27             : #include <svx/fmview.hxx>
      28             : #include <editeng/outliner.hxx>
      29             : #include <svx/svxids.hrc>
      30             : #include <svx/svdograf.hxx>
      31             : #include <svx/svdoole2.hxx>
      32             : #include <svx/svdundo.hxx>
      33             : 
      34             : #include <vcl/settings.hxx>
      35             : #include <vcl/msgbox.hxx>
      36             : #include <vcl/settings.hxx>
      37             : 
      38             : #include <sfx2/dispatch.hxx>
      39             : #include <sfx2/app.hxx>
      40             : #include <svx/svdpagv.hxx>
      41             : #include <sfx2/docfile.hxx>
      42             : #include <svx/svdoutl.hxx>
      43             : #include <svx/sdr/contact/displayinfo.hxx>
      44             : 
      45             : #include <svx/svdetc.hxx>
      46             : #include <editeng/editstat.hxx>
      47             : 
      48             : #include <svx/dialogs.hrc>
      49             : #include <sfx2/viewfrm.hxx>
      50             : #include <sfx2/sidebar/EnumContext.hxx>
      51             : #include <svx/svdopage.hxx>
      52             : #include <toolkit/helper/vclunohelper.hxx>
      53             : #include <svx/xlndsit.hxx>
      54             : #include <svx/xlineit0.hxx>
      55             : #include <svx/xlnclit.hxx>
      56             : #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
      57             : #include <vcl/virdev.hxx>
      58             : 
      59             : #include "app.hrc"
      60             : #include "strings.hrc"
      61             : #include "Window.hxx"
      62             : #include "Client.hxx"
      63             : #include "drawdoc.hxx"
      64             : #include "DrawDocShell.hxx"
      65             : #include "sdmod.hxx"
      66             : #include "sdpage.hxx"
      67             : #include "glob.hrc"
      68             : #include "sdresid.hxx"
      69             : #include "DrawViewShell.hxx"
      70             : #include "futext.hxx"
      71             : #include "fuinsfil.hxx"
      72             : #include "slideshow.hxx"
      73             : #include "stlpool.hxx"
      74             : #include "FrameView.hxx"
      75             : #include "ViewClipboard.hxx"
      76             : #include "undo/undomanager.hxx"
      77             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      78             : #include <svx/sdr/contact/viewcontact.hxx>
      79             : #include <svx/svdotable.hxx>
      80             : #include "EventMultiplexer.hxx"
      81             : #include "ViewShellBase.hxx"
      82             : #include "ViewShellManager.hxx"
      83             : 
      84             : #include <basegfx/polygon/b2dpolygontools.hxx>
      85             : #include <basegfx/color/bcolor.hxx>
      86             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      87             : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
      88             : #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
      89             : #include <svx/sdr/contact/objectcontact.hxx>
      90             : #include <svx/sdr/table/tablecontroller.hxx>
      91             : #include <basegfx/matrix/b2dhommatrix.hxx>
      92             : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      93             : #include <svx/unoapi.hxx>
      94             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      95             : #include "DrawController.hxx"
      96             : 
      97             : #include <numeric>
      98             : 
      99             : using namespace com::sun::star;
     100             : using namespace com::sun::star::uno;
     101             : using namespace sdr::table;
     102             : namespace sd {
     103             : 
     104           0 : TYPEINIT1(View, FmFormView);
     105             : 
     106             : 
     107           0 : View::View(SdDrawDocument& rDrawDoc, OutputDevice* pOutDev,
     108             :                ViewShell* pViewShell)
     109             :   : FmFormView(&rDrawDoc, pOutDev),
     110             :     mrDoc(rDrawDoc),
     111           0 :     mpDocSh(rDrawDoc.GetDocSh()),
     112             :     mpViewSh(pViewShell),
     113             :     mpDragSrcMarkList(NULL),
     114             :     mpDropMarkerObj(NULL),
     115             :     mpDropMarker(NULL),
     116             :     mnDragSrcPgNum(SDRPAGE_NOTFOUND),
     117             :     mnAction(DND_ACTION_NONE),
     118             :     mnLockRedrawSmph(0),
     119             :     mbIsDropAllowed(true),
     120             :     maSmartTags(*this),
     121           0 :     mpClipboard (new ViewClipboard (*this))
     122             : {
     123             :     // #i73602# Use default from the configuration
     124           0 :     SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_DrawImpress());
     125             : 
     126             :     // #i74769#, #i75172# Use default from the configuration
     127           0 :     SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_DrawImpress());
     128             : 
     129           0 :     EnableExtendedKeyInputDispatcher(false);
     130           0 :     EnableExtendedMouseEventDispatcher(false);
     131           0 :     EnableExtendedCommandEventDispatcher(false);
     132             : 
     133           0 :     SetUseIncompatiblePathCreateInterface(false);
     134           0 :     SetMarkHdlWhenTextEdit(true);
     135           0 :     EnableTextEditOnObjectsWithoutTextIfTextTool(true);
     136             : 
     137           0 :     SetMinMoveDistancePixel(2);
     138           0 :     SetHitTolerancePixel(2);
     139           0 :     SetMeasureLayer(SD_RESSTR(STR_LAYER_MEASURELINES));
     140             : 
     141             :     // Timer for delayed drop (has to be for MAC)
     142           0 :     maDropErrorTimer.SetTimeoutHdl( LINK(this, View, DropErrorHdl) );
     143           0 :     maDropErrorTimer.SetTimeout(50);
     144           0 :     maDropInsertFileTimer.SetTimeoutHdl( LINK(this, View, DropInsertFileHdl) );
     145           0 :     maDropInsertFileTimer.SetTimeout(50);
     146           0 : }
     147             : 
     148           0 : void View::ImplClearDrawDropMarker()
     149             : {
     150           0 :     if(mpDropMarker)
     151             :     {
     152           0 :         delete mpDropMarker;
     153           0 :         mpDropMarker = 0L;
     154             :     }
     155           0 : }
     156             : 
     157             : 
     158           0 : View::~View()
     159             : {
     160           0 :     maSmartTags.Dispose();
     161             : 
     162             :     // release content of selection clipboard, if we own the content
     163           0 :     UpdateSelectionClipboard( sal_True );
     164             : 
     165           0 :     maDropErrorTimer.Stop();
     166           0 :     maDropInsertFileTimer.Stop();
     167             : 
     168           0 :     ImplClearDrawDropMarker();
     169             : 
     170           0 :     while(PaintWindowCount())
     171             :     {
     172             :         // remove all registered OutDevs
     173           0 :         DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/);
     174             :     }
     175           0 : }
     176             : 
     177             : 
     178             : class ViewRedirector : public ::sdr::contact::ViewObjectContactRedirector
     179             : {
     180             : public:
     181             :     ViewRedirector();
     182             :     virtual ~ViewRedirector();
     183             : 
     184             :     // all default implementations just call the same methods at the original. To do something
     185             :     // different, overload the method and at least do what the method does.
     186             :     virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
     187             :         const sdr::contact::ViewObjectContact& rOriginal,
     188             :         const sdr::contact::DisplayInfo& rDisplayInfo) SAL_OVERRIDE;
     189             : };
     190             : 
     191           0 : ViewRedirector::ViewRedirector()
     192             : {
     193           0 : }
     194             : 
     195           0 : ViewRedirector::~ViewRedirector()
     196             : {
     197           0 : }
     198             : 
     199           0 : drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedPrimitive2DSequence(
     200             :     const sdr::contact::ViewObjectContact& rOriginal,
     201             :     const sdr::contact::DisplayInfo& rDisplayInfo)
     202             : {
     203           0 :     SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
     204           0 :     drawinglayer::primitive2d::Primitive2DSequence xRetval;
     205             : 
     206           0 :     if(pObject && pObject->GetPage())
     207             :     {
     208           0 :         const bool bDoCreateGeometry(pObject->GetPage()->checkVisibility( rOriginal, rDisplayInfo, true ));
     209             : 
     210           0 :         if(!bDoCreateGeometry && !(( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE )) )
     211           0 :             return xRetval;
     212             : 
     213           0 :         PresObjKind eKind(PRESOBJ_NONE);
     214           0 :         const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
     215           0 :         const bool bIsMasterPageObject(pObject->GetPage()->IsMasterPage());
     216           0 :         const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter());
     217           0 :         const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
     218           0 :         const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
     219           0 :         const SdPage* pObjectsSdPage = dynamic_cast< SdPage* >(pObject->GetPage());
     220           0 :         const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
     221             : 
     222             :         // check if we need to draw a placeholder border. Never do it for
     223             :         // objects inside a SdrPageObj and never when printing
     224           0 :         if(!bIsInsidePageObj && !bIsPrinting)
     225             :         {
     226           0 :             bool bCreateOutline(false);
     227             : 
     228           0 :             if( pObject->IsEmptyPresObj() && pObject->ISA(SdrTextObj) )
     229             :             {
     230           0 :                 if( !bSubContentProcessing || !pObject->IsNotVisibleAsMaster() )
     231             :                 {
     232           0 :                     eKind = pObjectsSdPage ? pObjectsSdPage->GetPresObjKind(pObject) : PRESOBJ_NONE;
     233           0 :                     bCreateOutline = true;
     234             :                 }
     235             :             }
     236           0 :             else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_TEXT ) )
     237             :             {
     238           0 :                 if( pObjectsSdPage )
     239             :                 {
     240           0 :                     eKind = pObjectsSdPage->GetPresObjKind(pObject);
     241             : 
     242           0 :                     if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
     243             :                     {
     244           0 :                         if( !bSubContentProcessing )
     245             :                         {
     246             :                             // only draw a boundary for header&footer objects on the masterpage itself
     247           0 :                             bCreateOutline = true;
     248             :                         }
     249             :                     }
     250             :                 }
     251             :             }
     252           0 :             else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE ) )
     253             :             {
     254             :                 // only for handout page, else this frame will be created for each
     255             :                 // page preview object in SlideSorter and PagePane
     256           0 :                 if(pObjectsSdPage && PK_HANDOUT == pObjectsSdPage->GetPageKind())
     257             :                 {
     258           0 :                     bCreateOutline = true;
     259             :                 }
     260             :             }
     261             : 
     262           0 :             if(bCreateOutline)
     263             :             {
     264             :                 // empty presentation objects get a gray frame
     265           0 :                 const svtools::ColorConfig aColorConfig;
     266           0 :                 const svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
     267             : 
     268           0 :                 if( aColor.bIsVisible )
     269             :                 {
     270             :                     // get basic object transformation
     271           0 :                     const basegfx::BColor aRGBColor(Color(aColor.nColor).getBColor());
     272           0 :                     basegfx::B2DHomMatrix aObjectMatrix;
     273           0 :                     basegfx::B2DPolyPolygon aObjectPolyPolygon;
     274           0 :                     pObject->TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
     275             : 
     276             :                     // create dashed border
     277             :                     {
     278             :                         // create object polygon
     279           0 :                         basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
     280           0 :                         aPolygon.transform(aObjectMatrix);
     281             : 
     282             :                         // create line and stroke attribute
     283           0 :                         ::std::vector< double > aDotDashArray;
     284             : 
     285           0 :                         aDotDashArray.push_back(160.0);
     286           0 :                         aDotDashArray.push_back(80.0);
     287             : 
     288           0 :                         const double fFullDotDashLen(::std::accumulate(aDotDashArray.begin(), aDotDashArray.end(), 0.0));
     289           0 :                         const drawinglayer::attribute::LineAttribute aLine(aRGBColor);
     290           0 :                         const drawinglayer::attribute::StrokeAttribute aStroke(aDotDashArray, fFullDotDashLen);
     291             : 
     292             :                         // create primitive and add
     293             :                         const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
     294             :                             aPolygon,
     295             :                             aLine,
     296           0 :                             aStroke));
     297           0 :                         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
     298             :                     }
     299             : 
     300             :                     // now paint the placeholder description, but only when masterpage
     301             :                     // is displayed as page directly (MasterPage view)
     302           0 :                     if(!bSubContentProcessing && bIsMasterPageObject)
     303             :                     {
     304           0 :                         OUString aObjectString;
     305             : 
     306           0 :                         switch( eKind )
     307             :                         {
     308             :                             case PRESOBJ_TITLE:
     309             :                             {
     310           0 :                                 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
     311             :                                 {
     312           0 :                                     static OUString aTitleAreaStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_TITLE));
     313           0 :                                     aObjectString = aTitleAreaStr;
     314             :                                 }
     315             : 
     316           0 :                                 break;
     317             :                             }
     318             :                             case PRESOBJ_OUTLINE:
     319             :                             {
     320           0 :                                 static OUString aOutlineAreaStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_OUTLINE));
     321           0 :                                 aObjectString = aOutlineAreaStr;
     322           0 :                                 break;
     323             :                             }
     324             :                             case PRESOBJ_FOOTER:
     325             :                             {
     326           0 :                                 static OUString aFooterAreaStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_FOOTER));
     327           0 :                                 aObjectString = aFooterAreaStr;
     328           0 :                                 break;
     329             :                             }
     330             :                             case PRESOBJ_HEADER:
     331             :                             {
     332           0 :                                 static OUString aHeaderAreaStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_HEADER));
     333           0 :                                 aObjectString = aHeaderAreaStr;
     334           0 :                                 break;
     335             :                             }
     336             :                             case PRESOBJ_DATETIME:
     337             :                             {
     338           0 :                                 static OUString aDateTimeStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_DATETIME));
     339           0 :                                 aObjectString = aDateTimeStr;
     340           0 :                                 break;
     341             :                             }
     342             :                             case PRESOBJ_NOTES:
     343             :                             {
     344           0 :                                 static OUString aDateTimeStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_NOTES));
     345           0 :                                 aObjectString = aDateTimeStr;
     346           0 :                                 break;
     347             :                             }
     348             :                             case PRESOBJ_SLIDENUMBER:
     349             :                             {
     350           0 :                                 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
     351             :                                 {
     352           0 :                                     static OUString aSlideAreaStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_SLIDE));
     353           0 :                                     aObjectString = aSlideAreaStr;
     354             :                                 }
     355             :                                 else
     356             :                                 {
     357           0 :                                     static OUString aNumberAreaStr(SD_RESSTR(STR_PLACEHOLDER_DESCRIPTION_NUMBER));
     358           0 :                                     aObjectString = aNumberAreaStr;
     359             :                                 }
     360           0 :                                 break;
     361             :                             }
     362             :                             default:
     363             :                             {
     364           0 :                                 break;
     365             :                             }
     366             :                         }
     367             : 
     368           0 :                         if( !aObjectString.isEmpty() )
     369             :                         {
     370             :                             // decompose object matrix to be able to place text correctly
     371           0 :                             basegfx::B2DTuple aScale;
     372           0 :                             basegfx::B2DTuple aTranslate;
     373             :                             double fRotate, fShearX;
     374           0 :                             aObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
     375             : 
     376             :                             // create font
     377           0 :                             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObject );
     378           0 :                             const SdrTextVertAdjust eTVA(pTextObj ? pTextObj->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_CENTER);
     379           0 :                             Font aScaledVclFont;
     380             : 
     381             :                             // use a text size factor to get more reliable text sizes from the text layouter
     382             :                             // (and from vcl), tipp from HDU
     383             :                             static sal_uInt32 nTextSizeFactor(100);
     384             : 
     385             :                             // use a factor to get more linear text size calculations
     386           0 :                             aScaledVclFont.SetHeight( 500 * nTextSizeFactor );
     387             : 
     388             :                             // get basic geometry and get text size
     389           0 :                             drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
     390           0 :                             aTextLayouter.setFont(aScaledVclFont);
     391           0 :                             const sal_Int32 nTextLength(aObjectString.getLength());
     392             : 
     393             :                             // do not forget to use the factor again to get the width for the 500
     394           0 :                             const double fTextWidth(aTextLayouter.getTextWidth(aObjectString, 0, nTextLength) * (1.0 / nTextSizeFactor));
     395           0 :                             const double fTextHeight(aTextLayouter.getTextHeight() * (1.0 / nTextSizeFactor));
     396             : 
     397             :                             // calculate text primitive position. If text is at bottom, use top for
     398             :                             // the extra text and vice versa
     399           0 :                             const double fHorDist(125);
     400           0 :                             const double fVerDist(125);
     401           0 :                             const double fPosX((aTranslate.getX() + aScale.getX()) - fTextWidth - fHorDist);
     402             :                             const double fPosY((SDRTEXTVERTADJUST_BOTTOM == eTVA)
     403           0 :                                 ? aTranslate.getY() - fVerDist + fTextHeight
     404           0 :                                 : (aTranslate.getY() + aScale.getY()) - fVerDist);
     405             : 
     406             :                             // get font attributes; use normally scaled font
     407           0 :                             const basegfx::BColor aFontColor(aRGBColor);
     408           0 :                             Font aVclFont;
     409           0 :                             basegfx::B2DVector aTextSizeAttribute;
     410             : 
     411           0 :                             aVclFont.SetHeight( 500 );
     412             : 
     413             :                             const drawinglayer::attribute::FontAttribute aFontAttribute(
     414             :                                 drawinglayer::primitive2d::getFontAttributeFromVclFont(
     415             :                                     aTextSizeAttribute,
     416             :                                     aVclFont,
     417             :                                     false,
     418           0 :                                     false));
     419             : 
     420             :                             // fill text matrix
     421             :                             const basegfx::B2DHomMatrix aTextMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
     422             :                                 aTextSizeAttribute.getX(), aTextSizeAttribute.getY(),
     423             :                                 fShearX,
     424             :                                 fRotate,
     425           0 :                                 fPosX, fPosY));
     426             : 
     427             :                             // create DXTextArray (can be empty one)
     428           0 :                             const ::std::vector< double > aDXArray;
     429             : 
     430             :                             // create locale; this may need some more information in the future
     431           0 :                             const ::com::sun::star::lang::Locale aLocale;
     432             : 
     433             :                             // create primitive and add
     434             :                             const drawinglayer::primitive2d::Primitive2DReference xRef(
     435             :                                 new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
     436             :                                     aTextMatrix,
     437             :                                     aObjectString,
     438             :                                     0,
     439             :                                     nTextLength,
     440             :                                     aDXArray,
     441             :                                     aFontAttribute,
     442             :                                     aLocale,
     443           0 :                                     aFontColor));
     444           0 :                             drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
     445           0 :                         }
     446           0 :                     }
     447           0 :                 }
     448             :             }
     449             :         }
     450             : 
     451           0 :         if(bDoCreateGeometry)
     452             :         {
     453             :             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
     454             :                 xRetval,
     455             :                 sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
     456             :                     rOriginal,
     457           0 :                     rDisplayInfo));
     458             :         }
     459             :     }
     460             :     else
     461             :     {
     462             :         // not a SdrObject visualisation (maybe e.g. page) or no page
     463           0 :         xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
     464             :     }
     465             : 
     466           0 :     return xRetval;
     467             : }
     468             : 
     469             : /**
     470             :  * The event will be forwarded to the View
     471             :  */
     472           0 : void View::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0L*/)
     473             : {
     474             :     // execute ??
     475           0 :     if (mnLockRedrawSmph == 0)
     476             :     {
     477           0 :         SdrPageView* pPgView = GetSdrPageView();
     478             : 
     479           0 :         if (pPgView)
     480             :         {
     481           0 :             SdPage* pPage = (SdPage*) pPgView->GetPage();
     482           0 :             if( pPage )
     483             :             {
     484           0 :                 SdrOutliner& rOutl = mrDoc.GetDrawOutliner(NULL);
     485           0 :                 bool bScreenDisplay(true);
     486             : 
     487           0 :                 if(bScreenDisplay && pOutDev && OUTDEV_PRINTER == pOutDev->GetOutDevType())
     488             :                 {
     489             :                     // #i75566# printing; suppress AutoColor BackgroundColor generation
     490             :                     // for visibility reasons by giving GetPageBackgroundColor()
     491             :                     // the needed hint
     492           0 :                     bScreenDisplay = false;
     493             :                 }
     494             : 
     495           0 :                 if(bScreenDisplay && pOutDev && pOutDev->GetPDFWriter())
     496             :                 {
     497             :                     // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
     498           0 :                     bScreenDisplay = false;
     499             :                 }
     500             : 
     501             :                 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
     502             :                 // hint value if screen display. Only then the AutoColor mechanisms shall be applied
     503           0 :                 rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, bScreenDisplay) );
     504             :             }
     505             :         }
     506             : 
     507           0 :         ViewRedirector aViewRedirector;
     508           0 :         FmFormView::CompleteRedraw(pOutDev, rReg, pRedirector ? pRedirector : &aViewRedirector);
     509             :     }
     510             :     // or save?
     511             :     else
     512             :     {
     513           0 :         SdViewRedrawRec* pRec = new SdViewRedrawRec;
     514           0 :         pRec->mpOut = pOutDev;
     515           0 :         pRec->aRect = rReg.GetBoundRect();
     516           0 :         maLockedRedraws.push_back(pRec);
     517             :     }
     518           0 : }
     519             : 
     520             : 
     521           0 : void View::MarkListHasChanged()
     522             : {
     523           0 :     FmFormView::MarkListHasChanged();
     524             : 
     525           0 :     if( GetMarkedObjectCount() > 0 )
     526           0 :         maSmartTags.deselect();
     527           0 : }
     528             : 
     529             : 
     530           0 : sal_Bool View::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
     531             : {
     532           0 :     sal_Bool bOk = FmFormView::SetAttributes(rSet, bReplaceAll);
     533           0 :     return (bOk);
     534             : }
     535             : 
     536             : 
     537           0 : sal_Bool View::GetAttributes( SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr ) const
     538             : {
     539           0 :     return( FmFormView::GetAttributes( rTargetSet, bOnlyHardAttr ) );
     540             : }
     541             : 
     542             : 
     543             : /**
     544             :  * Is a presentation object selected?
     545             :  */
     546           0 : sal_Bool View::IsPresObjSelected(sal_Bool bOnPage, sal_Bool bOnMasterPage, sal_Bool bCheckPresObjListOnly, sal_Bool bCheckLayoutOnly) const
     547             : {
     548             :     SdrMarkList* pMarkList;
     549             : 
     550           0 :     if (mnDragSrcPgNum != SDRPAGE_NOTFOUND &&
     551           0 :         mnDragSrcPgNum != GetSdrPageView()->GetPage()->GetPageNum())
     552             :     {
     553             :         /* Drag&Drop is in progress
     554             :            Source and destination page are different:
     555             :            we use the saved mark list */
     556           0 :         pMarkList = mpDragSrcMarkList;
     557             :     }
     558             :     else
     559             :     {
     560             :         // We use the current mark list
     561           0 :         pMarkList = new SdrMarkList(GetMarkedObjectList());
     562             :     }
     563             : 
     564             :     SdrMark* pMark;
     565             :     SdPage* pPage;
     566             :     SdrObject* pObj;
     567             : 
     568           0 :     sal_Bool bSelected = sal_False;
     569           0 :     sal_Bool bMasterPage = sal_False;
     570             :     long nMark;
     571           0 :     long nMarkMax = long(pMarkList->GetMarkCount()) - 1;
     572             : 
     573           0 :     for (nMark = nMarkMax; (nMark >= 0) && !bSelected; nMark--)
     574             :     {
     575             :         // Backwards through mark list
     576           0 :         pMark = pMarkList->GetMark(nMark);
     577           0 :         pObj = pMark->GetMarkedSdrObj();
     578             : 
     579           0 :         if ( pObj && ( bCheckPresObjListOnly || pObj->IsEmptyPresObj() || pObj->GetUserCall() ) )
     580             :         {
     581           0 :             pPage = (SdPage*) pObj->GetPage();
     582           0 :             bMasterPage = pPage && pPage->IsMasterPage();
     583             : 
     584           0 :             if ( (bMasterPage && bOnMasterPage) || (!bMasterPage && bOnPage) )
     585             :             {
     586           0 :                 if ( pPage && pPage->IsPresObj(pObj) )
     587             :                 {
     588           0 :                     if( bCheckLayoutOnly )
     589             :                     {
     590           0 :                         PresObjKind eKind = pPage->GetPresObjKind(pObj);
     591             : 
     592           0 :                         if((eKind != PRESOBJ_FOOTER) && (eKind != PRESOBJ_HEADER) && (eKind != PRESOBJ_DATETIME) && (eKind != PRESOBJ_SLIDENUMBER) )
     593           0 :                             bSelected = sal_True;
     594             :                     }
     595             :                     else
     596             :                     {
     597           0 :                         bSelected = sal_True;
     598             :                     }
     599             :                 }
     600             :             }
     601             :         }
     602             :     }
     603             : 
     604           0 :     if (pMarkList != mpDragSrcMarkList)
     605             :     {
     606           0 :        delete pMarkList;
     607             :     }
     608             : 
     609           0 :     return (bSelected);
     610             : }
     611             : 
     612             : 
     613           0 : void View::SelectAll()
     614             : {
     615           0 :     if ( IsTextEdit() )
     616             :     {
     617           0 :         OutlinerView* pOLV = GetTextEditOutlinerView();
     618           0 :         const ::Outliner* pOutliner = GetTextEditOutliner();
     619           0 :         pOLV->SelectRange( 0, pOutliner->GetParagraphCount() );
     620             :     }
     621             :     else
     622             :     {
     623           0 :         MarkAll();
     624             :     }
     625           0 : }
     626             : 
     627             : 
     628             : 
     629           0 : void View::ModelHasChanged()
     630             : {
     631             :     // First, notify SdrView
     632           0 :     FmFormView::ModelHasChanged();
     633           0 : }
     634             : 
     635             : 
     636           0 : sal_Bool View::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
     637             : {
     638             :     // forward to SdrView
     639           0 :     return FmFormView::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
     640             : }
     641             : 
     642             : 
     643             : /**
     644             :  * Start text input
     645             :  */
     646           0 : static void SetSpellOptions( const SdDrawDocument& rDoc, sal_uLong& rCntrl )
     647             : {
     648           0 :     sal_Bool bOnlineSpell = rDoc.GetOnlineSpell();
     649             : 
     650           0 :     if( bOnlineSpell )
     651           0 :         rCntrl |= EE_CNTRL_ONLINESPELLING;
     652             :     else
     653           0 :         rCntrl &= ~EE_CNTRL_ONLINESPELLING;
     654           0 : }
     655             : 
     656           0 : bool View::SdrBeginTextEdit(
     657             :     SdrObject* pObj, SdrPageView* pPV, ::Window* pWin,
     658             :     bool bIsNewObj,
     659             :     SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
     660             :     bool bDontDeleteOutliner, bool bOnlyOneView, bool bGrabFocus )
     661             : {
     662           0 :     GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
     663           0 :         sd::tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT, (void*)pObj );
     664             : 
     665           0 :     if( pOutl==NULL && pObj )
     666           0 :         pOutl = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, pObj->GetModel() );
     667             : 
     668             :     // make draw&impress specific initialisations
     669           0 :     if( pOutl )
     670             :     {
     671           0 :         pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mrDoc.GetStyleSheetPool());
     672           0 :         pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
     673           0 :         sal_uLong nCntrl = pOutl->GetControlWord();
     674           0 :         nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
     675           0 :         nCntrl |= EE_CNTRL_URLSFXEXECUTE;
     676           0 :         nCntrl |= EE_CNTRL_MARKFIELDS;
     677           0 :         nCntrl |= EE_CNTRL_AUTOCORRECT;
     678             : 
     679           0 :         nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
     680           0 :         if ( mrDoc.IsSummationOfParagraphs() )
     681           0 :             nCntrl |= EE_CNTRL_ULSPACESUMMATION;
     682             : 
     683           0 :         SetSpellOptions( mrDoc, nCntrl );
     684             : 
     685           0 :         pOutl->SetControlWord(nCntrl);
     686             : 
     687           0 :         Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
     688           0 :         if ( xSpellChecker.is() )
     689           0 :             pOutl->SetSpeller( xSpellChecker );
     690             : 
     691           0 :         Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
     692           0 :         if( xHyphenator.is() )
     693           0 :             pOutl->SetHyphenator( xHyphenator );
     694             : 
     695           0 :         pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
     696             :     }
     697             : 
     698             :     sal_Bool bReturn = FmFormView::SdrBeginTextEdit(
     699             :         pObj, pPV, pWin, bIsNewObj, pOutl,
     700             :         pGivenOutlinerView, bDontDeleteOutliner,
     701           0 :         bOnlyOneView, bGrabFocus);
     702             : 
     703           0 :     if ( mpViewSh )
     704             :     {
     705           0 :         mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
     706             :     }
     707             : 
     708           0 :     if (bReturn)
     709             :     {
     710           0 :         ::Outliner* pOL = GetTextEditOutliner();
     711             : 
     712           0 :         if( pObj && pObj->GetPage() )
     713             :         {
     714           0 :             Color aBackground;
     715           0 :             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_TABLE )
     716             :             {
     717           0 :                 aBackground = GetTextEditBackgroundColor(*this);
     718             :             }
     719             :             else
     720             :             {
     721           0 :                 aBackground = pObj->GetPage()->GetPageBackgroundColor(pPV);
     722             :             }
     723           0 :             if (pOL != NULL)
     724           0 :                 pOL->SetBackgroundColor( aBackground  );
     725             :         }
     726             : 
     727           0 :         if (pOL != NULL)
     728             :         {
     729           0 :             pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
     730           0 :             pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
     731             :         }
     732             :     }
     733             : 
     734           0 :     return(bReturn);
     735             : }
     736             : 
     737             : /** ends current text editing */
     738           0 : SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally )
     739             : {
     740           0 :     SdrObjectWeakRef xObj( GetTextEditObject() );
     741             : 
     742           0 :     sal_Bool bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );
     743             : 
     744           0 :     SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
     745             : 
     746           0 :     if( bDefaultTextRestored )
     747             :     {
     748           0 :         if( xObj.is() && !xObj->IsEmptyPresObj() )
     749             :         {
     750           0 :             xObj->SetEmptyPresObj( true );
     751             :         }
     752             :         else
     753             :         {
     754           0 :             eKind = SDRENDTEXTEDIT_UNCHANGED;
     755             :         }
     756             :     }
     757           0 :     else if( xObj.is() && xObj->IsEmptyPresObj() )
     758             :     {
     759           0 :         SdrTextObj* pObj = dynamic_cast< SdrTextObj* >( xObj.get() );
     760           0 :         if( pObj && pObj->HasText() )
     761             :         {
     762           0 :             SdrPage* pPage = pObj->GetPage();
     763           0 :             if( !pPage || !pPage->IsMasterPage() )
     764           0 :                 pObj->SetEmptyPresObj( false );
     765             :         }
     766             :     }
     767             : 
     768           0 :     GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
     769             :         sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT,
     770           0 :         (void*)xObj.get() );
     771             : 
     772           0 :     if( xObj.is() )
     773             :     {
     774           0 :         if ( mpViewSh )
     775             :         {
     776           0 :             mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
     777             :         }
     778             : 
     779           0 :         SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() );
     780           0 :         if( pPage )
     781           0 :             pPage->onEndTextEdit( xObj.get() );
     782             :     }
     783             : 
     784           0 :     return(eKind);
     785             : }
     786             : 
     787             : 
     788             : 
     789             : /** restores the default text if the given text object is currently in edit mode and
     790             :     no text has been entered already. Is only useful just before text edit ends. */
     791           0 : bool View::RestoreDefaultText( SdrTextObj* pTextObj )
     792             : {
     793           0 :     bool bRestored = false;
     794             : 
     795           0 :     if( pTextObj && (pTextObj == GetTextEditObject()) )
     796             :     {
     797           0 :         if( !pTextObj->HasText() )
     798             :         {
     799           0 :             SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
     800             : 
     801           0 :             if(pPage)
     802             :             {
     803           0 :                 bRestored = pPage->RestoreDefaultText( pTextObj );
     804           0 :                 if( bRestored )
     805             :                 {
     806           0 :                     SdrOutliner* pOutliner = GetTextEditOutliner();
     807           0 :                     pTextObj->SetTextEditOutliner( pOutliner );
     808           0 :                     OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
     809           0 :                     if (pOutliner)
     810           0 :                         pOutliner->SetText(*pParaObj);
     811             :                 }
     812             :             }
     813             :         }
     814             :     }
     815             : 
     816           0 :     return bRestored;
     817             : }
     818             : 
     819             : /**
     820             :  * Sets the original size of the marked objects.
     821             :  */
     822           0 : void View::SetMarkedOriginalSize()
     823             : {
     824           0 :     SdrUndoGroup* pUndoGroup = new SdrUndoGroup(mrDoc);
     825           0 :     sal_uLong           nCount = GetMarkedObjectCount();
     826           0 :     sal_Bool            bOK = sal_False;
     827             : 
     828           0 :     for( sal_uInt32 i = 0; i < nCount; i++ )
     829             :     {
     830           0 :         SdrObject* pObj = GetMarkedObjectByIndex(i);
     831             : 
     832           0 :         if( pObj->GetObjInventor() == SdrInventor )
     833             :         {
     834           0 :             if( pObj->GetObjIdentifier() == OBJ_OLE2 )
     835             :             {
     836           0 :                 uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObj)->GetObjRef();
     837           0 :                 if( xObj.is() )
     838             :                 {
     839             :                     // TODO/LEAN: working with VisualArea can switch object to running state
     840             : 
     841           0 :                        sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
     842           0 :                     Size aOleSize;
     843             : 
     844           0 :                     if ( nAspect == embed::Aspects::MSOLE_ICON )
     845             :                     {
     846           0 :                         MapMode aMap100( MAP_100TH_MM );
     847           0 :                         aOleSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMap100 );
     848           0 :                         bOK = sal_True;
     849             :                     }
     850             :                     else
     851             :                     {
     852           0 :                         MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
     853             :                         try
     854             :                         {
     855           0 :                             awt::Size aSz = xObj->getVisualAreaSize( nAspect );
     856           0 :                             aOleSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aUnit, MAP_100TH_MM );
     857           0 :                             bOK = sal_True;
     858             :                         }
     859           0 :                         catch( embed::NoVisualAreaSizeException& )
     860             :                         {}
     861             :                     }
     862             : 
     863           0 :                     if ( bOK )
     864             :                     {
     865           0 :                         Rectangle   aDrawRect( pObj->GetLogicRect() );
     866             : 
     867           0 :                         pUndoGroup->AddAction( mrDoc.GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
     868           0 :                         pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
     869           0 :                                                            Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
     870             :                     }
     871           0 :                 }
     872             :             }
     873           0 :             else if( pObj->GetObjIdentifier() == OBJ_GRAF )
     874             :             {
     875           0 :                 const MapMode   aMap100( MAP_100TH_MM );
     876           0 :                 Size            aSize;
     877             : 
     878           0 :                 if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
     879           0 :                     aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 );
     880             :                 else
     881             :                 {
     882           0 :                     aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(),
     883           0 :                                                         static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(),
     884           0 :                                                         aMap100 );
     885             :                 }
     886             : 
     887           0 :                 pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
     888           0 :                 Rectangle aRect( pObj->GetLogicRect() );
     889           0 :                 aRect.SetSize( aSize );
     890           0 :                 pObj->SetLogicRect( aRect );
     891             : 
     892           0 :                 bOK = sal_True;
     893             :             }
     894             :         }
     895             :     }
     896             : 
     897           0 :     if( bOK )
     898             :     {
     899           0 :         pUndoGroup->SetComment(SD_RESSTR(STR_UNDO_ORIGINALSIZE));
     900           0 :         mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
     901             :     }
     902             :     else
     903           0 :         delete pUndoGroup;
     904           0 : }
     905             : 
     906             : /**
     907             :  * Connect OLE object to client.
     908             :  */
     909           0 : void View::DoConnect(SdrOle2Obj* pObj)
     910             : {
     911           0 :     if (mpViewSh)
     912             :     {
     913           0 :         uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
     914           0 :         if( xObj.is() )
     915             :         {
     916           0 :             ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
     917           0 :             SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
     918           0 :             if ( !pSdClient )
     919             :             {
     920           0 :                 pSdClient = new Client(pObj, mpViewSh, pWindow);
     921           0 :                 Rectangle aRect = pObj->GetLogicRect();
     922             :                 {
     923             :                     // TODO/LEAN: working with visual area can switch object to running state
     924           0 :                     Size aDrawSize = aRect.GetSize();
     925           0 :                     awt::Size aSz;
     926             : 
     927           0 :                     MapMode aMapMode( mrDoc.GetScaleUnit() );
     928           0 :                     Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
     929             : 
     930           0 :                     Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
     931           0 :                     Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
     932           0 :                     aScaleWidth.ReduceInaccurate(10);       // compatible to SdrOle2Obj
     933           0 :                     aScaleHeight.ReduceInaccurate(10);
     934           0 :                     pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
     935             : 
     936             :                     // visible area is only changed in-place!
     937             :                     // the object area must be set after the scaling, since it triggers resize
     938           0 :                     aRect.SetSize(aObjAreaSize);
     939           0 :                     pSdClient->SetObjArea(aRect);
     940             :                 }
     941             :             }
     942           0 :         }
     943             :     }
     944           0 : }
     945             : 
     946           0 : sal_Bool View::IsMorphingAllowed() const
     947             : {
     948           0 :     const SdrMarkList&  rMarkList = GetMarkedObjectList();
     949           0 :     sal_Bool                bRet = sal_False;
     950             : 
     951           0 :     if ( rMarkList.GetMarkCount() == 2 )
     952             :     {
     953           0 :         const SdrObject*    pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     954           0 :         const SdrObject*    pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
     955           0 :         const sal_uInt16        nKind1 = pObj1->GetObjIdentifier();
     956           0 :         const sal_uInt16        nKind2 = pObj2->GetObjIdentifier();
     957             : 
     958           0 :         if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
     959           0 :              ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
     960           0 :              ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
     961           0 :              ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
     962           0 :              ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
     963           0 :              ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
     964           0 :              ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
     965           0 :              ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
     966           0 :              ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
     967           0 :              ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
     968           0 :              ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
     969           0 :              ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
     970           0 :              ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
     971           0 :              ( nKind1 != OBJ_CAPTION && nKind2 !=  OBJ_CAPTION ) &&
     972           0 :              !pObj1->ISA( E3dObject) && !pObj2->ISA( E3dObject) )
     973             :         {
     974           0 :             SfxItemSet      aSet1( mrDoc.GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
     975           0 :             SfxItemSet      aSet2( mrDoc.GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
     976             : 
     977           0 :             aSet1.Put(pObj1->GetMergedItemSet());
     978           0 :             aSet2.Put(pObj2->GetMergedItemSet());
     979             : 
     980           0 :             const XFillStyle    eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
     981           0 :             const XFillStyle    eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
     982             : 
     983           0 :             if( ( eFillStyle1 == XFILL_NONE || eFillStyle1 == XFILL_SOLID ) &&
     984           0 :                 ( eFillStyle2 == XFILL_NONE || eFillStyle2 == XFILL_SOLID ) )
     985           0 :                 bRet = sal_True;
     986             :         }
     987             :     }
     988             : 
     989           0 :     return bRet;
     990             : }
     991             : 
     992           0 : sal_Bool View::IsVectorizeAllowed() const
     993             : {
     994           0 :     const SdrMarkList&  rMarkList = GetMarkedObjectList();
     995           0 :     sal_Bool                bRet = sal_False;
     996             : 
     997           0 :     if( rMarkList.GetMarkCount() == 1 )
     998             :     {
     999           0 :         const SdrGrafObj* pObj = dynamic_cast< const SdrGrafObj* >(rMarkList.GetMark( 0 )->GetMarkedSdrObj());
    1000             : 
    1001           0 :         if(pObj)
    1002             :         {
    1003           0 :             if(GRAPHIC_BITMAP == pObj->GetGraphicType() && !pObj->isEmbeddedSvg())
    1004             :             {
    1005           0 :                 bRet = sal_True;
    1006             :             }
    1007             :         }
    1008             :     }
    1009             : 
    1010           0 :     return bRet;
    1011             : }
    1012             : 
    1013           0 : void View::onAccessibilityOptionsChanged()
    1014             : {
    1015           0 :     if( mpViewSh )
    1016             :     {
    1017           0 :         ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
    1018           0 :         if( pWindow )
    1019             :         {
    1020           0 :             const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
    1021             : 
    1022             :             sal_uInt16 nOutputSlot, nPreviewSlot;
    1023             : 
    1024           0 :             SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
    1025             : 
    1026           0 :             if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
    1027             :             {
    1028           0 :                 if( rStyleSettings.GetHighContrastMode() )
    1029             :                 {
    1030           0 :                     nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
    1031             :                 }
    1032             :                 else
    1033             :                 {
    1034           0 :                     nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
    1035             :                 }
    1036             : 
    1037           0 :                 if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
    1038             :                 {
    1039           0 :                     nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
    1040             :                 }
    1041             :                 else
    1042             :                 {
    1043           0 :                     nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
    1044             :                 }
    1045             : 
    1046           0 :                 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SFX_CALLMODE_ASYNCHRON );
    1047           0 :                 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
    1048             :             }
    1049             : 
    1050           0 :             mpViewSh->Invalidate();
    1051             :         }
    1052             :     }
    1053           0 : }
    1054             : 
    1055           0 : IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner *, pOutliner )
    1056             : {
    1057           0 :     Paragraph* pPara = pOutliner->GetHdlParagraph();
    1058           0 :     SdrObject* pObj = GetTextEditObject();
    1059             : 
    1060           0 :     if( pPara && pObj )
    1061             :     {
    1062           0 :         SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
    1063           0 :         if( pPage )
    1064           0 :             pPage->onParagraphInserted( pOutliner, pPara, pObj );
    1065             :     }
    1066           0 :     return 0;
    1067             : }
    1068             : 
    1069             : /**
    1070             :  * Handler for the deletion of the pages (paragraphs).
    1071             :  */
    1072           0 : IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
    1073             : {
    1074           0 :     Paragraph* pPara = pOutliner->GetHdlParagraph();
    1075           0 :     SdrObject* pObj = GetTextEditObject();
    1076             : 
    1077           0 :     if( pPara && pObj )
    1078             :     {
    1079           0 :         SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
    1080           0 :         if( pPage )
    1081           0 :             pPage->onParagraphRemoving( pOutliner, pPara, pObj );
    1082             :     }
    1083           0 :     return 0;
    1084             : }
    1085             : 
    1086           0 : bool View::isRecordingUndo() const
    1087             : {
    1088           0 :     if( mrDoc.IsUndoEnabled() )
    1089             :     {
    1090           0 :         sd::UndoManager* pUndoManager = mrDoc.GetUndoManager();
    1091           0 :         return pUndoManager && pUndoManager->IsInListAction();
    1092             :     }
    1093             :     else
    1094             :     {
    1095           0 :         return false;
    1096             :     }
    1097             : }
    1098             : 
    1099           0 : void View::AddCustomHdl()
    1100             : {
    1101           0 :     maSmartTags.addCustomHandles( aHdl );
    1102           0 : }
    1103             : 
    1104           0 : void View::updateHandles()
    1105             : {
    1106           0 :     AdjustMarkHdl();
    1107           0 : }
    1108             : 
    1109           0 : SdrViewContext View::GetContext() const
    1110             : {
    1111           0 :     SdrViewContext eContext = SDRCONTEXT_STANDARD;
    1112           0 :     if( maSmartTags.getContext( eContext ) )
    1113           0 :         return eContext;
    1114             :     else
    1115           0 :         return FmFormView::GetContext();
    1116             : }
    1117             : 
    1118           0 : bool View::HasMarkablePoints() const
    1119             : {
    1120           0 :     if( maSmartTags.HasMarkablePoints() )
    1121           0 :         return true;
    1122             :     else
    1123           0 :         return FmFormView::HasMarkablePoints();
    1124             : }
    1125             : 
    1126           0 : sal_uLong View::GetMarkablePointCount() const
    1127             : {
    1128           0 :     sal_uLong nCount = FmFormView::GetMarkablePointCount();
    1129           0 :     nCount += maSmartTags.GetMarkablePointCount();
    1130           0 :     return nCount;
    1131             : }
    1132             : 
    1133           0 : bool View::HasMarkedPoints() const
    1134             : {
    1135           0 :     if( maSmartTags.HasMarkedPoints() )
    1136           0 :         return true;
    1137             :     else
    1138           0 :         return FmFormView::HasMarkedPoints();
    1139             : }
    1140             : 
    1141           0 : sal_uLong View::GetMarkedPointCount() const
    1142             : {
    1143           0 :     sal_uLong nCount = FmFormView::GetMarkedPointCount();
    1144           0 :     nCount += maSmartTags.GetMarkedPointCount();
    1145           0 :     return nCount;
    1146             : }
    1147             : 
    1148           0 : bool View::IsPointMarkable(const SdrHdl& rHdl) const
    1149             : {
    1150           0 :     if( maSmartTags.IsPointMarkable( rHdl ) )
    1151           0 :         return true;
    1152             :     else
    1153           0 :         return FmFormView::IsPointMarkable( rHdl );
    1154             : }
    1155             : 
    1156           0 : bool View::MarkPoint(SdrHdl& rHdl, bool bUnmark )
    1157             : {
    1158           0 :     if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
    1159           0 :         return true;
    1160             :     else
    1161           0 :         return FmFormView::MarkPoint( rHdl, bUnmark );
    1162             : }
    1163             : 
    1164           0 : sal_Bool View::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
    1165             : {
    1166           0 :     if( maSmartTags.MarkPoints( pRect, bUnmark ) )
    1167           0 :         return true;
    1168             :     else
    1169           0 :         return FmFormView::MarkPoints( pRect, bUnmark );
    1170             : }
    1171             : 
    1172           0 : void View::CheckPossibilities()
    1173             : {
    1174           0 :     FmFormView::CheckPossibilities();
    1175           0 :     maSmartTags.CheckPossibilities();
    1176           0 : }
    1177             : 
    1178           0 : void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
    1179             : {
    1180           0 : }
    1181             : 
    1182             : /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
    1183             :     get the correct style sheet. */
    1184           0 : void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
    1185             : {
    1186           0 :     SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
    1187           0 :     SdrOutliner* pOutliner = GetTextEditOutliner();
    1188           0 :     if( pOutliner && pTextObj && pTextObj->GetPage() )
    1189             :     {
    1190           0 :         SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
    1191             : 
    1192           0 :         SfxStyleSheet* pStyleSheet = 0;
    1193             : 
    1194           0 :         const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
    1195           0 :         if( eKind != PRESOBJ_NONE )
    1196           0 :             pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
    1197             :         else
    1198           0 :             pStyleSheet = pTextObj->GetStyleSheet();
    1199             : 
    1200           0 :         if( eKind == PRESOBJ_OUTLINE )
    1201             :         {
    1202             :             // for outline shapes, set the correct outline style sheet for each
    1203             :             // new paragraph, depending on the paragraph depth
    1204           0 :             SfxStyleSheetBasePool* pStylePool = GetDoc().GetStyleSheetPool();
    1205             : 
    1206           0 :             for ( sal_Int32 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
    1207             :             {
    1208           0 :                 sal_Int16 nDepth = pOutliner->GetDepth( nPara );
    1209             : 
    1210           0 :                 SfxStyleSheet* pStyle = 0;
    1211           0 :                 if( nDepth > 0 )
    1212             :                 {
    1213           0 :                     OUString aStyleSheetName( pStyleSheet->GetName() );
    1214           0 :                     if (!aStyleSheetName.isEmpty())
    1215           0 :                         aStyleSheetName = aStyleSheetName.copy(0, aStyleSheetName.getLength() - 1);
    1216           0 :                     aStyleSheetName += OUString::number( nDepth );
    1217           0 :                     pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
    1218           0 :                     DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
    1219             :                 }
    1220             : 
    1221           0 :                 if( !pStyle )
    1222           0 :                     pStyle = pStyleSheet;
    1223             : 
    1224           0 :                 pOutliner->SetStyleSheet( nPara, pStyle );
    1225             :             }
    1226             :         }
    1227             :         else
    1228             :         {
    1229             :             // just put the object style on each new paragraph
    1230           0 :             for ( sal_Int32 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
    1231             :             {
    1232           0 :                 pOutliner->SetStyleSheet( nPara, pStyleSheet );
    1233             :             }
    1234             :         }
    1235             :     }
    1236           0 : }
    1237             : 
    1238           0 : bool View::ShouldToggleOn(
    1239             :     const bool bBulletOnOffMode,
    1240             :     const bool bNormalBullet)
    1241             : {
    1242             :     // If setting bullets/numbering by the dialog, always should toggle on.
    1243           0 :     if (!bBulletOnOffMode)
    1244           0 :         return true;
    1245           0 :     SdrModel* pSdrModel = GetModel();
    1246           0 :     if (!pSdrModel)
    1247           0 :         return false;
    1248             : 
    1249           0 :     sal_Bool bToggleOn = sal_False;
    1250           0 :     SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel);
    1251           0 :     sal_uInt32 nMarkCount = GetMarkedObjectCount();
    1252           0 :     for (sal_uInt32 nIndex = 0; nIndex < nMarkCount && !bToggleOn; nIndex++)
    1253             :     {
    1254           0 :         SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex));
    1255           0 :         if (!pTextObj || pTextObj->IsTextEditActive())
    1256           0 :             continue;
    1257           0 :         if (pTextObj->ISA(SdrTableObj))
    1258             :         {
    1259           0 :             SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj);
    1260           0 :             if (!pTableObj)
    1261           0 :                 continue;
    1262           0 :             CellPos aStart, aEnd;
    1263           0 :             SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get());
    1264           0 :             if (pTableController)
    1265             :             {
    1266           0 :                 pTableController->getSelectedCells(aStart, aEnd);
    1267             :             }
    1268             :             else
    1269             :             {
    1270           0 :                 aStart = pTableObj->getFirstCell();
    1271           0 :                 aEnd = pTableObj->getLastCell();
    1272             :             }
    1273           0 :             sal_Int32 nColCount = pTableObj->getColumnCount();
    1274           0 :             for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow && !bToggleOn; nRow++)
    1275             :             {
    1276           0 :                 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol && !bToggleOn; nCol++)
    1277             :                 {
    1278           0 :                     sal_Int32 nCellIndex = nRow * nColCount + nCol;
    1279           0 :                     SdrText* pText = pTableObj->getText(nCellIndex);
    1280           0 :                     if (!pText || !pText->GetOutlinerParaObject())
    1281           0 :                         continue;
    1282           0 :                     pOutliner->SetText(*(pText->GetOutlinerParaObject()));
    1283           0 :                     sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
    1284           0 :                     bToggleOn = ((bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1)) ? sal_True : bToggleOn;
    1285           0 :                     pOutliner->Clear();
    1286             :                 }
    1287             :             }
    1288             :         }
    1289             :         else
    1290             :         {
    1291           0 :             OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
    1292           0 :             if (!pParaObj)
    1293           0 :                 continue;
    1294           0 :             pOutliner->SetText(*pParaObj);
    1295           0 :             sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
    1296           0 :             bToggleOn = ((bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1)) ? sal_True : bToggleOn;
    1297           0 :             pOutliner->Clear();
    1298             :         }
    1299             :     }
    1300           0 :     delete pOutliner;
    1301           0 :     return bToggleOn;
    1302             : }
    1303             : 
    1304           0 : void View::ChangeMarkedObjectsBulletsNumbering(
    1305             :     const bool bToggle,
    1306             :     const bool bHandleBullets,
    1307             :     const SvxNumRule* pNumRule,
    1308             :     const bool bSwitchOff )
    1309             : {
    1310           0 :     SdrModel* pSdrModel = GetModel();
    1311           0 :     Window* pWindow = dynamic_cast< Window* >(GetFirstOutputDevice());
    1312           0 :     if (!pSdrModel || !pWindow)
    1313           0 :         return;
    1314             : 
    1315           0 :     const bool bUndoEnabled = pSdrModel->IsUndoEnabled();
    1316           0 :     SdrUndoGroup* pUndoGroup = bUndoEnabled ? new SdrUndoGroup(*pSdrModel) : 0;
    1317             : 
    1318             :     const bool bToggleOn =
    1319             :         bSwitchOff
    1320             :         ? false
    1321           0 :         : ShouldToggleOn( bToggle, bHandleBullets );
    1322             : 
    1323           0 :     SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel);
    1324           0 :     OutlinerView* pOutlinerView = new OutlinerView(pOutliner, pWindow);
    1325             : 
    1326           0 :     const sal_uInt32 nMarkCount = GetMarkedObjectCount();
    1327           0 :     for (sal_uInt32 nIndex = 0; nIndex < nMarkCount; nIndex++)
    1328             :     {
    1329           0 :         SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex));
    1330           0 :         if (!pTextObj || pTextObj->IsTextEditActive())
    1331           0 :             continue;
    1332           0 :         if (pTextObj->ISA(SdrTableObj))
    1333             :         {
    1334           0 :             SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj);
    1335           0 :             if (!pTableObj)
    1336           0 :                 continue;
    1337           0 :             CellPos aStart, aEnd;
    1338           0 :             SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get());
    1339           0 :             if (pTableController)
    1340             :             {
    1341           0 :                 pTableController->getSelectedCells(aStart, aEnd);
    1342             :             }
    1343             :             else
    1344             :             {
    1345           0 :                 aStart = pTableObj->getFirstCell();
    1346           0 :                 aEnd = pTableObj->getLastCell();
    1347             :             }
    1348           0 :             sal_Int32 nColCount = pTableObj->getColumnCount();
    1349           0 :             for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
    1350             :             {
    1351           0 :                 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
    1352             :                 {
    1353           0 :                     sal_Int32 nCellIndex = nRow * nColCount + nCol;
    1354           0 :                     SdrText* pText = pTableObj->getText(nCellIndex);
    1355           0 :                     if (!pText || !pText->GetOutlinerParaObject())
    1356           0 :                         continue;
    1357             : 
    1358           0 :                     pOutliner->SetText(*(pText->GetOutlinerParaObject()));
    1359           0 :                     if (bUndoEnabled)
    1360             :                     {
    1361           0 :                         SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nCellIndex));
    1362           0 :                         pUndoGroup->AddAction(pTxtUndo);
    1363             :                     }
    1364           0 :                     if ( !bToggleOn )
    1365             :                     {
    1366           0 :                         pOutlinerView->SwitchOffBulletsNumbering();
    1367             :                     }
    1368             :                     else
    1369             :                     {
    1370           0 :                         pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle );
    1371             :                     }
    1372           0 :                     sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
    1373           0 :                     pText->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount));
    1374           0 :                     pOutliner->Clear();
    1375             :                 }
    1376             :             }
    1377             :             // Broadcast the object change event.
    1378           0 :             if (!pTextObj->AdjustTextFrameWidthAndHeight())
    1379             :             {
    1380           0 :                 pTextObj->SetChanged();
    1381           0 :                 pTextObj->BroadcastObjectChange();
    1382             :             }
    1383             :         }
    1384             :         else
    1385             :         {
    1386           0 :             OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
    1387           0 :             if (!pParaObj)
    1388           0 :                 continue;
    1389           0 :             pOutliner->SetText(*pParaObj);
    1390           0 :             if (bUndoEnabled)
    1391             :             {
    1392           0 :                 SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0));
    1393           0 :                 pUndoGroup->AddAction(pTxtUndo);
    1394             :             }
    1395           0 :             if ( !bToggleOn )
    1396             :             {
    1397           0 :                 pOutlinerView->SwitchOffBulletsNumbering();
    1398             :             }
    1399             :             else
    1400             :             {
    1401           0 :                 pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle );
    1402             :             }
    1403           0 :             sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
    1404           0 :             pTextObj->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount));
    1405           0 :             pOutliner->Clear();
    1406             :         }
    1407             :     }
    1408             : 
    1409           0 :     if ( bUndoEnabled && pUndoGroup->GetActionCount() > 0 )
    1410             :     {
    1411           0 :         pSdrModel->BegUndo();
    1412           0 :         pSdrModel->AddUndo(pUndoGroup);
    1413           0 :         pSdrModel->EndUndo();
    1414             :     }
    1415             :     else
    1416           0 :         delete pUndoGroup;
    1417             : 
    1418           0 :     delete pOutliner;
    1419           0 :     delete pOutlinerView;
    1420             : }
    1421             : 
    1422             : } // end of namespace sd
    1423             : 
    1424             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10