LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/core - sdpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 876 1419 61.7 %
Date: 2013-07-09 Functions: 55 65 84.6 %
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 <algorithm>
      22             : 
      23             : #include <comphelper/classids.hxx>
      24             : 
      25             : #include <vcl/svapp.hxx>
      26             : #include <editeng/outliner.hxx>
      27             : #include <editeng/eeitem.hxx>
      28             : #include <svx/svdoutl.hxx>
      29             : #include <editeng/editdata.hxx>
      30             : #include <svx/pageitem.hxx>
      31             : #include <editeng/lrspitem.hxx>
      32             : #include <editeng/bulletitem.hxx>
      33             : #include <svx/svdpagv.hxx>
      34             : #include <editeng/fhgtitem.hxx>
      35             : #include <editeng/outlobj.hxx>
      36             : #include <svx/svdoole2.hxx>
      37             : #include <svx/svdograf.hxx>
      38             : #include <svx/svdopage.hxx>
      39             : #include <sfx2/printer.hxx>
      40             : #include <basic/basmgr.hxx>
      41             : #include <editeng/pbinitem.hxx>
      42             : #include <svx/svdundo.hxx>
      43             : #include <svl/smplhint.hxx>
      44             : #include <editeng/adjustitem.hxx>
      45             : #include <editeng/editobj.hxx>
      46             : #include <editeng/scripttypeitem.hxx>
      47             : #include <svx/unopage.hxx>
      48             : #include <editeng/flditem.hxx>
      49             : #include <svx/sdr/contact/displayinfo.hxx>
      50             : #include <svx/svditer.hxx>
      51             : 
      52             : #include "../ui/inc/DrawDocShell.hxx"
      53             : #include "Outliner.hxx"
      54             : #include "app.hrc"
      55             : #include "drawdoc.hxx"
      56             : #include "sdpage.hxx"
      57             : #include "pglink.hxx"
      58             : #include "sdresid.hxx"
      59             : #include "stlsheet.hxx"
      60             : #include "glob.hrc"
      61             : #include "glob.hxx"
      62             : #include "helpids.h"
      63             : #include "anminfo.hxx"
      64             : #include "undo/undomanager.hxx"
      65             : #include "undo/undoobjects.hxx"
      66             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      67             : #include <svx/sdr/contact/viewcontact.hxx>
      68             : #include <svx/sdr/contact/objectcontact.hxx>
      69             : #include <svx/unoapi.hxx>
      70             : 
      71             : #include <set>
      72             : 
      73             : using namespace ::sd;
      74             : using namespace ::com::sun::star;
      75             : 
      76       15164 : TYPEINIT2( SdPage, FmFormPage, SdrObjUserCall );
      77             : 
      78             : /*************************************************************************
      79             : |*
      80             : |*      Ctor
      81             : |*
      82             : \************************************************************************/
      83             : 
      84         598 : SdPage::SdPage(SdDrawDocument& rNewDoc, StarBASIC* pBasic, sal_Bool bMasterPage)
      85             : :   FmFormPage(rNewDoc, pBasic, bMasterPage)
      86             : ,   SdrObjUserCall()
      87             : ,   mePageKind(PK_STANDARD)
      88             : ,   meAutoLayout(AUTOLAYOUT_NONE)
      89             : ,   mbSelected(sal_False)
      90             : ,   mePresChange(PRESCHANGE_MANUAL)
      91             : ,   mfTime(1.0)
      92             : ,   mbSoundOn(sal_False)
      93             : ,   mbExcluded(sal_False)
      94             : ,   mbLoopSound(sal_False)
      95             : ,   mbStopSound(sal_False)
      96             : ,   mbScaleObjects(sal_True)
      97             : ,   mbBackgroundFullSize( sal_False )
      98         598 : ,   meCharSet(osl_getThreadTextEncoding())
      99             : ,   mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
     100             : ,   mpPageLink(NULL)
     101             : ,   mpItems(NULL)
     102             : ,   mnTransitionType(0)
     103             : ,   mnTransitionSubtype(0)
     104             : ,   mbTransitionDirection(sal_True)
     105             : ,   mnTransitionFadeColor(0)
     106             : ,   mfTransitionDuration(2.0)
     107        1196 : ,   mbIsPrecious(true)
     108             : {
     109             :     // The name of the layout of the page is used by SVDRAW to determine the
     110             :     // presentation template of the outline objects. Therefore, it already
     111             :     // contains the designator for the outline (STR_LAYOUT_OUTLINE).
     112         598 :     OUStringBuffer aBuf(SdResId(STR_LAYOUT_DEFAULT_NAME).toString());
     113         598 :     aBuf.append(SD_LT_SEPARATOR).append(SdResId(STR_LAYOUT_OUTLINE).toString());
     114         598 :     maLayoutName = aBuf.makeStringAndClear();
     115             : 
     116         598 :     Size aPageSize(GetSize());
     117             : 
     118         598 :     if (aPageSize.Width() > aPageSize.Height())
     119             :     {
     120           0 :         meOrientation = ORIENTATION_LANDSCAPE;
     121             :     }
     122             :     else
     123             :     {
     124         598 :         meOrientation = ORIENTATION_PORTRAIT;
     125         598 :     }
     126         598 : }
     127             : 
     128             : /*************************************************************************
     129             : |*
     130             : |* Dtor
     131             : |*
     132             : \************************************************************************/
     133             : 
     134        1743 : SdPage::~SdPage()
     135             : {
     136         581 :     DisconnectLink();
     137             : 
     138         581 :     EndListenOutlineText();
     139             : 
     140         581 :     if( mpItems )
     141           0 :         delete mpItems;
     142        1162 : }
     143             : 
     144             : struct OrdNumSorter
     145             : {
     146         120 :     bool operator()( SdrObject* p1, SdrObject* p2 )
     147             :     {
     148         120 :         return p1->GetOrdNum() < p2->GetOrdNum();
     149             :     }
     150             : };
     151             : 
     152             : /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
     153        2299 : SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
     154             : {
     155             :     // first sort all matching shapes with z-order
     156        2299 :     std::vector< SdrObject* > aMatches;
     157             : 
     158        2299 :     SdrObject* pObj = 0;
     159        2299 :     maPresentationShapeList.seekShape(0);
     160             : 
     161       10841 :     while( (pObj = maPresentationShapeList.getNextShape()) )
     162             :     {
     163        6243 :         SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
     164        6243 :         if( pInfo )
     165             :         {
     166        6243 :             bool bFound = false;
     167        6243 :             if( pInfo->mePresObjKind == eObjKind )
     168             :             {
     169         759 :                 bFound = true;
     170             :             }
     171        5484 :             else if( bFuzzySearch && (eObjKind == PRESOBJ_OUTLINE) )
     172             :             {
     173          39 :                 switch( pInfo->mePresObjKind )
     174             :                 {
     175             :                 case PRESOBJ_GRAPHIC:
     176             :                 case PRESOBJ_OBJECT:
     177             :                 case PRESOBJ_CHART:
     178             :                 case PRESOBJ_ORGCHART:
     179             :                 case PRESOBJ_TABLE:
     180             :                 case PRESOBJ_CALC:
     181             :                 case PRESOBJ_IMAGE:
     182             :                 case PRESOBJ_MEDIA:
     183           0 :                     bFound = sal_True;
     184           0 :                     break;
     185             :                 default:
     186          39 :                     break;
     187             :                 }
     188             :             }
     189        6243 :             if( bFound )
     190             :             {
     191         759 :                 aMatches.push_back( pObj );
     192             :             }
     193             :         }
     194             :     }
     195             : 
     196        2299 :     if( aMatches.size() > 1 )
     197             :     {
     198             :         OrdNumSorter aSortHelper;
     199          20 :         std::sort( aMatches.begin(), aMatches.end(), aSortHelper );
     200             :     }
     201             : 
     202        2299 :     if( nIndex > 0 )
     203        2299 :         nIndex--;
     204             : 
     205        2299 :     if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) )
     206         684 :         return aMatches[nIndex];
     207             : 
     208        1615 :     return 0;
     209             : }
     210             : 
     211             : /** create background properties */
     212         149 : void SdPage::EnsureMasterPageDefaultBackground()
     213             : {
     214         149 :     if(mbMaster)
     215             :     {
     216             :         // no hard attributes on MasterPage attributes
     217         149 :         getSdrPageProperties().ClearItem();
     218         149 :         SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground();
     219             : 
     220         149 :         if(pSheetForPresObj)
     221             :         {
     222             :             // set StyleSheet for background fill attributes
     223         149 :             getSdrPageProperties().SetStyleSheet(pSheetForPresObj);
     224             :         }
     225             :         else
     226             :         {
     227             :             // no style found, assert and set at least XFILL_NONE
     228             :             OSL_FAIL("No Style for MasterPageBackground fill found (!)");
     229           0 :             getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
     230             :         }
     231             :     }
     232         149 : }
     233             : 
     234             : /** creates a presentation object with the given PresObjKind on this page. A user call will be set
     235             : */
     236        1014 : SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, sal_Bool bVertical, const Rectangle& rRect, sal_Bool /* bInsert */ )
     237             : {
     238        1014 :     ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
     239        1014 :     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
     240             : 
     241        1014 :     SdrObject* pSdrObj = NULL;
     242             : 
     243        1014 :     bool bForceText = false;    // forces the shape text to be set even if its empty
     244        1014 :     bool bEmptyPresObj = true;
     245             : 
     246        1014 :     switch( eObjKind )
     247             :     {
     248             :         case PRESOBJ_TITLE:
     249             :         {
     250         111 :             pSdrObj = new SdrRectObj(OBJ_TITLETEXT);
     251             : 
     252         111 :             if (mbMaster)
     253             :             {
     254          66 :                 pSdrObj->SetNotVisibleAsMaster(sal_True);
     255             :             }
     256             :         }
     257         111 :         break;
     258             : 
     259             :         case PRESOBJ_OUTLINE:
     260             :         {
     261          46 :             pSdrObj = new SdrRectObj(OBJ_OUTLINETEXT);
     262             : 
     263          46 :             if (mbMaster)
     264             :             {
     265          35 :                 pSdrObj->SetNotVisibleAsMaster(sal_True);
     266             :             }
     267             :         }
     268          46 :         break;
     269             : 
     270             :         case PRESOBJ_NOTES:
     271             :         {
     272         151 :             pSdrObj = new SdrRectObj(OBJ_TEXT);
     273             : 
     274         151 :             if (mbMaster)
     275             :             {
     276          31 :                 pSdrObj->SetNotVisibleAsMaster(sal_True);
     277             :             }
     278             :         }
     279         151 :         break;
     280             : 
     281             :         case PRESOBJ_TEXT:
     282             :         {
     283          28 :             pSdrObj = new SdrRectObj(OBJ_TEXT);
     284             :         }
     285          28 :         break;
     286             : 
     287             :         case PRESOBJ_GRAPHIC:
     288             :         {
     289           1 :             BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_GRAPHIC ) );
     290           2 :             Graphic  aGraphic( aBmpEx );
     291           1 :             OutputDevice &aOutDev = *Application::GetDefaultDevice();
     292           1 :             aOutDev.Push();
     293             : 
     294           1 :             aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
     295           1 :             Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
     296           1 :             aOutDev.SetMapMode(MAP_100TH_MM);
     297             : 
     298           1 :             Size aSize = aOutDev.PixelToLogic(aSizePix);
     299           1 :             Point aPnt (0, 0);
     300           1 :             Rectangle aRect (aPnt, aSize);
     301           1 :             pSdrObj = new SdrGrafObj(aGraphic, aRect);
     302           2 :             aOutDev.Pop();
     303             :         }
     304           1 :         break;
     305             : 
     306             :         case PRESOBJ_MEDIA:
     307             :         case PRESOBJ_OBJECT:
     308             :         {
     309           2 :             pSdrObj = new SdrOle2Obj();
     310           2 :             BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_OBJECT ) );
     311           4 :             Graphic aGraphic( aBmpEx );
     312           4 :             ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
     313             :         }
     314           2 :         break;
     315             : 
     316             :         case PRESOBJ_CHART:
     317             :         {
     318           0 :             pSdrObj = new SdrOle2Obj();
     319           0 :             ( (SdrOle2Obj*) pSdrObj)->SetProgName( OUString( "StarChart" ) );
     320           0 :             BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_CHART ) );
     321           0 :             Graphic aGraphic( aBmpEx );
     322           0 :             ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
     323             :         }
     324           0 :         break;
     325             : 
     326             :         case PRESOBJ_ORGCHART:
     327             :         {
     328           0 :             pSdrObj = new SdrOle2Obj();
     329           0 :             ( (SdrOle2Obj*) pSdrObj)->SetProgName( OUString( "StarOrg" ) );
     330           0 :             BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_ORGCHART ) );
     331           0 :             Graphic aGraphic( aBmpEx );
     332           0 :             ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
     333             :         }
     334           0 :         break;
     335             : 
     336             :         case PRESOBJ_TABLE:
     337             :         case PRESOBJ_CALC:
     338             :         {
     339           0 :             pSdrObj = new SdrOle2Obj();
     340           0 :             ( (SdrOle2Obj*) pSdrObj)->SetProgName( OUString( "StarCalc" ) );
     341           0 :             BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_TABLE ) );
     342           0 :             Graphic aGraphic( aBmpEx );
     343           0 :             ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
     344             :         }
     345           0 :         break;
     346             : 
     347             :         case PRESOBJ_HANDOUT:
     348             :         {
     349             :             // Save the first standard page at SdrPageObj
     350             :             // #i105146# We want no content to be displayed for PK_HANDOUT,
     351             :             // so just never set a page as content
     352         228 :             pSdrObj = new SdrPageObj(0);
     353             :         }
     354         228 :         break;
     355             : 
     356             :         case PRESOBJ_PAGE:
     357             :         {
     358             :             // Save note pages at SdrPageObj
     359         120 :             sal_uInt16 nDestPageNum(GetPageNum());
     360             : 
     361         120 :             if(nDestPageNum)
     362             :             {
     363             :                 // decrement only when != 0, else we get a 0xffff
     364         106 :                 nDestPageNum -= 1;
     365             :             }
     366             : 
     367         120 :             if(nDestPageNum < pModel->GetPageCount())
     368             :             {
     369         120 :                 pSdrObj = new SdrPageObj(pModel->GetPage(nDestPageNum));
     370             :             }
     371             :             else
     372             :             {
     373           0 :                 pSdrObj = new SdrPageObj();
     374             :             }
     375             : 
     376         120 :             pSdrObj->SetResizeProtect(sal_True);
     377             :         }
     378         120 :         break;
     379             : 
     380             :         case PRESOBJ_HEADER:
     381             :         case PRESOBJ_FOOTER:
     382             :         case PRESOBJ_DATETIME:
     383             :         case PRESOBJ_SLIDENUMBER:
     384             :         {
     385         327 :             pSdrObj = new SdrRectObj(OBJ_TEXT);
     386         327 :             bEmptyPresObj = false;
     387         327 :             bForceText = true;
     388             :         }
     389         327 :         break;
     390             :         default:
     391           0 :             break;
     392             :     }
     393             : 
     394        1014 :     if (pSdrObj)
     395             :     {
     396        1014 :         pSdrObj->SetEmptyPresObj(bEmptyPresObj);
     397        1014 :         pSdrObj->SetLogicRect(rRect);
     398             : 
     399        1014 :         InsertObject(pSdrObj);
     400             : 
     401        1014 :         if ( pSdrObj->ISA(SdrTextObj) )
     402             :         {
     403             :             // Tell the object EARLY that it is vertical to have the
     404             :             // defaults for AutoGrowWidth/Height reversed
     405         666 :             if(bVertical)
     406           0 :                 ((SdrTextObj*)pSdrObj)->SetVerticalWriting(sal_True);
     407             : 
     408         666 :             SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
     409         666 :             if( bVertical )
     410           0 :                 aTempAttr.Put( SdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
     411             :             else
     412         666 :                 aTempAttr.Put( SdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
     413             : 
     414         666 :             if (mbMaster)
     415             :             {
     416             :                 // The size of presentation objects on the master page have to
     417             :                 // be freely selectable by the user.
     418             : 
     419             :                 // potential problem: This action was still NOT
     420             :                 // adapted for vertical text. This sure needs to be done.
     421         456 :                 if(bVertical)
     422           0 :                     aTempAttr.Put(SdrTextAutoGrowWidthItem(sal_False));
     423             :                 else
     424         456 :                     aTempAttr.Put(SdrTextAutoGrowHeightItem(sal_False));
     425             :             }
     426             : 
     427             :             // check if we need another vertical adjustement than the default
     428         666 :             SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
     429             : 
     430         666 :             if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PK_STANDARD) )
     431             :             {
     432          58 :                 eV = SDRTEXTVERTADJUST_BOTTOM;
     433             :             }
     434         608 :             else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PK_STANDARD) )
     435             :             {
     436          60 :                 eV = SDRTEXTVERTADJUST_BOTTOM;
     437             :             }
     438             : 
     439         666 :             if( eV != SDRTEXTVERTADJUST_TOP )
     440         118 :                 aTempAttr.Put(SdrTextVertAdjustItem(eV));
     441             : 
     442         666 :             pSdrObj->SetMergedItemSet(aTempAttr);
     443             : 
     444         666 :             pSdrObj->SetLogicRect(rRect);
     445             :         }
     446             : 
     447        1014 :         String aString = GetPresObjText(eObjKind);
     448        1014 :         if( (aString.Len() || bForceText) && pSdrObj->ISA(SdrTextObj) )
     449             :         {
     450         666 :             SdrOutliner* pOutliner = ( (SdDrawDocument*) GetModel() )->GetInternalOutliner();
     451             : 
     452         666 :             sal_uInt16 nOutlMode = pOutliner->GetMode();
     453         666 :             pOutliner->Init( OUTLINERMODE_TEXTOBJECT );
     454         666 :             pOutliner->SetStyleSheet( 0, NULL );
     455         666 :             pOutliner->SetVertical( bVertical );
     456             : 
     457         666 :             SetObjText( (SdrTextObj*) pSdrObj, (SdrOutliner*)pOutliner, eObjKind, aString );
     458             : 
     459         666 :             pOutliner->Init( nOutlMode );
     460         666 :             pOutliner->SetStyleSheet( 0, NULL );
     461             :         }
     462             : 
     463        1014 :         if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
     464             :         {
     465         327 :             SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
     466         327 :             aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
     467         327 :             aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
     468         327 :             aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
     469             : 
     470         327 :             SvxAdjust eH = SVX_ADJUST_LEFT;
     471             : 
     472         327 :             if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PK_STANDARD ) )
     473             :             {
     474          58 :                 eH = SVX_ADJUST_RIGHT;
     475             :             }
     476         269 :             else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PK_STANDARD ) )
     477             :             {
     478          31 :                 eH = SVX_ADJUST_CENTER;
     479             :             }
     480         238 :             else if( eObjKind == PRESOBJ_SLIDENUMBER )
     481             :             {
     482          92 :                 eH = SVX_ADJUST_RIGHT;
     483             :             }
     484             : 
     485         327 :             if( eH != SVX_ADJUST_LEFT )
     486         181 :                 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
     487             : 
     488         327 :             pSdrObj->SetMergedItemSet(aTempAttr);
     489             :         }
     490             : 
     491        1014 :         if (mbMaster)
     492             :         {
     493         684 :             SdrLayerAdmin& rLayerAdmin = pModel->GetLayerAdmin();
     494             : 
     495             :             // background objects of the master page
     496             :             pSdrObj->SetLayer( rLayerAdmin.
     497         684 :                 GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False) );
     498             :         }
     499             : 
     500             :         // Subscribe object at the style sheet
     501             :         // Set style only when one was found (as in 5.2)
     502        1014 :         if( mePageKind != PK_HANDOUT )
     503             :         {
     504         662 :             SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
     505         662 :             if(pSheetForPresObj)
     506         539 :                 pSdrObj->SetStyleSheet(pSheetForPresObj, sal_False);
     507             :         }
     508             : 
     509        1014 :         if (eObjKind == PRESOBJ_OUTLINE)
     510             :         {
     511         460 :             for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
     512             :             {
     513         414 :                 String aName(maLayoutName);
     514         414 :                 aName += sal_Unicode( ' ' );
     515         414 :                 aName += OUString::number( nLevel );
     516         414 :                 SfxStyleSheet* pSheet = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
     517             :                 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
     518         414 :                 if (pSheet)
     519         414 :                     pSdrObj->StartListening(*pSheet);
     520         414 :             }
     521             :         }
     522             : 
     523        1014 :         if ( eObjKind == PRESOBJ_OBJECT   ||
     524        1012 :              eObjKind == PRESOBJ_CHART    ||
     525        1012 :              eObjKind == PRESOBJ_ORGCHART ||
     526        1012 :              eObjKind == PRESOBJ_CALC    ||
     527             :              eObjKind == PRESOBJ_GRAPHIC )
     528             :         {
     529           3 :             SfxItemSet aSet( ((SdDrawDocument*) pModel)->GetPool() );
     530           3 :             aSet.Put( SdrTextContourFrameItem( sal_True ) );
     531           3 :             aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
     532             : 
     533           3 :             pSdrObj->SetMergedItemSet(aSet);
     534             :         }
     535             : 
     536        1014 :         if( bUndo )
     537             :         {
     538           0 :             pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
     539             :         }
     540             : 
     541        1014 :         if( bUndo )
     542             :         {
     543           0 :             pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) );
     544           0 :             pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) );
     545             :         }
     546             : 
     547        1014 :         InsertPresObj(pSdrObj, eObjKind);
     548        1014 :         pSdrObj->SetUserCall(this);
     549             : 
     550        1014 :         pSdrObj->RecalcBoundRect();
     551             :     }
     552             : 
     553        1014 :     return(pSdrObj);
     554             : }
     555             : 
     556             : /*************************************************************************
     557             : |*
     558             : |* Creates presentation objects on the master page.
     559             : |* All presentation objects get a UserCall to the page.
     560             : |*
     561             : \************************************************************************/
     562             : 
     563         157 : SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
     564             : {
     565         157 :     String aName(GetLayoutName());
     566         314 :     String aSep( SD_LT_SEPARATOR );
     567         157 :     sal_uInt16 nPos = aName.Search(aSep);
     568             : 
     569         157 :     if (nPos != STRING_NOTFOUND)
     570             :     {
     571         157 :         nPos = nPos + aSep.Len();
     572         157 :         aName.Erase(nPos);
     573             :     }
     574             : 
     575         157 :     aName += String(SdResId(STR_LAYOUT_BACKGROUND));
     576             : 
     577         157 :     SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
     578         157 :     SfxStyleSheetBase*     pResult   = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
     579         314 :     return (SfxStyleSheet*)pResult;
     580             : }
     581             : 
     582         858 : SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
     583             : {
     584         858 :     String aName(GetLayoutName());
     585        1716 :     String aSep( SD_LT_SEPARATOR );
     586         858 :     sal_uInt16 nPos = aName.Search(aSep);
     587         858 :     if (nPos != STRING_NOTFOUND)
     588             :     {
     589         858 :         nPos = nPos + aSep.Len();
     590         858 :         aName.Erase(nPos);
     591             :     }
     592             : 
     593         858 :     switch (eObjKind)
     594             :     {
     595             :         case PRESOBJ_OUTLINE:
     596             :         {
     597         100 :             aName = GetLayoutName();
     598         100 :             aName += sal_Unicode( ' ' );
     599         100 :             aName += OUString::number( 1 );
     600             :         }
     601         100 :         break;
     602             : 
     603             :         case PRESOBJ_TITLE:
     604         181 :             aName += String(SdResId(STR_LAYOUT_TITLE));
     605         181 :             break;
     606             : 
     607             :         case PRESOBJ_NOTES:
     608         188 :             aName += String(SdResId(STR_LAYOUT_NOTES));
     609         188 :             break;
     610             : 
     611             :         case PRESOBJ_TEXT:
     612          43 :             aName += String(SdResId(STR_LAYOUT_SUBTITLE));
     613          43 :             break;
     614             : 
     615             :         case PRESOBJ_HEADER:
     616             :         case PRESOBJ_FOOTER:
     617             :         case PRESOBJ_DATETIME:
     618             :         case PRESOBJ_SLIDENUMBER:
     619         221 :             aName += String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
     620         221 :             break;
     621             : 
     622             :         default:
     623         125 :             break;
     624             :     }
     625             : 
     626         858 :     SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
     627         858 :     SfxStyleSheetBase*     pResult   = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
     628        1716 :     return (SfxStyleSheet*)pResult;
     629             : }
     630             : 
     631             : /** returns the presentation style with the given helpid from this masterpage or this
     632             :     slides masterpage */
     633           0 : SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
     634             : {
     635           0 :     String aStyleName( pPage->GetLayoutName() );
     636           0 :     const String aSep( SD_LT_SEPARATOR );
     637           0 :     aStyleName.Erase(aStyleName.Search(aSep) + aSep.Len());
     638             : 
     639             :     sal_uInt16 nNameId;
     640           0 :     switch( nHelpId )
     641             :     {
     642           0 :     case HID_PSEUDOSHEET_TITLE:             nNameId = STR_LAYOUT_TITLE;             break;
     643           0 :     case HID_PSEUDOSHEET_SUBTITLE:          nNameId = STR_LAYOUT_SUBTITLE;          break;
     644             :     case HID_PSEUDOSHEET_OUTLINE1:
     645             :     case HID_PSEUDOSHEET_OUTLINE2:
     646             :     case HID_PSEUDOSHEET_OUTLINE3:
     647             :     case HID_PSEUDOSHEET_OUTLINE4:
     648             :     case HID_PSEUDOSHEET_OUTLINE5:
     649             :     case HID_PSEUDOSHEET_OUTLINE6:
     650             :     case HID_PSEUDOSHEET_OUTLINE7:
     651             :     case HID_PSEUDOSHEET_OUTLINE8:
     652           0 :     case HID_PSEUDOSHEET_OUTLINE9:          nNameId = STR_LAYOUT_OUTLINE;           break;
     653           0 :     case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
     654           0 :     case HID_PSEUDOSHEET_BACKGROUND:        nNameId = STR_LAYOUT_BACKGROUND;        break;
     655           0 :     case HID_PSEUDOSHEET_NOTES:             nNameId = STR_LAYOUT_NOTES;             break;
     656             : 
     657             :     default:
     658             :         OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
     659           0 :         return 0;
     660             :     }
     661           0 :     aStyleName.Append( String( SdResId( nNameId ) ) );
     662           0 :     if( nNameId == STR_LAYOUT_OUTLINE )
     663             :     {
     664           0 :         aStyleName.Append( sal_Unicode( ' ' ));
     665           0 :         aStyleName.Append( OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE )));
     666             :     }
     667             : 
     668           0 :     SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
     669           0 :     SfxStyleSheetBase*     pResult   = pStShPool->Find(aStyleName, SD_STYLE_FAMILY_MASTERPAGE);
     670           0 :     return dynamic_cast<SdStyleSheet*>(pResult);
     671             : }
     672             : 
     673             : /*************************************************************************
     674             : |*
     675             : |* The presentation object rObj has changed and is no longer referenzed by the
     676             : |* presentation object of the master page.
     677             : |* The UserCall is deleted.
     678             : |*
     679             : \************************************************************************/
     680             : 
     681        9980 : void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& )
     682             : {
     683        9980 :     if (!maLockAutoLayoutArrangement.isLocked())
     684             :     {
     685        9603 :         switch (eType)
     686             :         {
     687             :             case SDRUSERCALL_MOVEONLY:
     688             :             case SDRUSERCALL_RESIZE:
     689             :             {
     690         167 :                 if( pModel->isLocked() )
     691         167 :                     break;
     692             : 
     693           0 :                 SdrObject* pObj = (SdrObject*) &rObj;
     694             : 
     695           0 :                 if (pObj)
     696             :                 {
     697           0 :                     if (!mbMaster)
     698             :                     {
     699           0 :                         if( pObj->GetUserCall() )
     700             :                         {
     701           0 :                             ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
     702           0 :                             const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
     703             : 
     704           0 :                             if( bUndo )
     705           0 :                                 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) );
     706             : 
     707             :                             // Objekt was resized by user and does not listen to its slide anymore
     708           0 :                             pObj->SetUserCall(0);
     709             :                         }
     710             :                     }
     711           0 :                     else if (pModel)
     712             :                     {
     713             :                         // Object of the master page changed, therefore adjust
     714             :                         // object on all pages
     715           0 :                         sal_uInt16 nPageCount = ((SdDrawDocument*) pModel)->GetSdPageCount(mePageKind);
     716             : 
     717           0 :                         for (sal_uInt16 i = 0; i < nPageCount; i++)
     718             :                         {
     719           0 :                             SdPage* pLoopPage = ((SdDrawDocument*) pModel)->GetSdPage(i, mePageKind);
     720             : 
     721           0 :                             if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
     722             :                             {
     723             :                                 // Page listens to this master page, therefore
     724             :                                 // adjust AutoLayout
     725           0 :                                 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
     726             :                             }
     727             :                         }
     728             :                     }
     729             :                 }
     730             :             }
     731           0 :             break;
     732             : 
     733             :             case SDRUSERCALL_DELETE:
     734             :             case SDRUSERCALL_REMOVED:
     735             :             default:
     736        9436 :                 break;
     737             :         }
     738             :     }
     739        9980 : }
     740             : 
     741             : /*************************************************************************
     742             : |*
     743             : |* Creates on a master page: background, title- and layout area
     744             : |*
     745             : \************************************************************************/
     746             : 
     747         366 : void SdPage::CreateTitleAndLayout(sal_Bool bInit, sal_Bool bCreate )
     748             : {
     749         366 :     ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
     750         366 :     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
     751             : 
     752         366 :     SdPage* pMasterPage = this;
     753             : 
     754         366 :     if (!mbMaster)
     755             :     {
     756         272 :         pMasterPage = (SdPage*)(&(TRG_GetMasterPage()));
     757             :     }
     758             : 
     759         366 :     if (!pMasterPage)
     760             :     {
     761         366 :         return;
     762             :     }
     763             : 
     764             :     /**************************************************************************
     765             :     * create background, title- and layout area
     766             :     **************************************************************************/
     767         366 :     if( mePageKind == PK_STANDARD )
     768             :     {
     769         144 :         pMasterPage->EnsureMasterPageDefaultBackground();
     770             :     }
     771             : 
     772         366 :     if( ( (SdDrawDocument*) GetModel() )->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
     773             :     {
     774         190 :         if( mePageKind == PK_HANDOUT && bInit )
     775             :         {
     776             :             // handout template
     777             : 
     778             :             // delete all available handout presentation objects
     779          34 :             SdrObject *pObj=NULL;
     780          92 :             while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != 0 )
     781             :             {
     782          24 :                 pMasterPage->RemoveObject(pObj->GetOrdNum());
     783             : 
     784          24 :                 if( bUndo )
     785             :                 {
     786           0 :                     pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
     787             :                 }
     788             :                 else
     789             :                 {
     790          24 :                     SdrObject::Free( pObj );
     791             :                 }
     792             :             }
     793             : 
     794          34 :             std::vector< Rectangle > aAreas;
     795          34 :             CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas );
     796             : 
     797          34 :             const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
     798          34 :             std::vector< Rectangle >::iterator iter( aAreas.begin() );
     799             : 
     800         272 :             while( iter != aAreas.end() )
     801             :             {
     802         204 :                 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, sal_False, (*iter++), sal_True) );
     803             :                 // #i105146# We want no content to be displayed for PK_HANDOUT,
     804             :                 // so just never set a page as content
     805         204 :                 pPageObj->SetReferencedPage(0L);
     806             : 
     807         204 :                 if( bSkip && iter != aAreas.end() )
     808           0 :                     ++iter;
     809          34 :             }
     810             :         }
     811             : 
     812         190 :         if( mePageKind != PK_HANDOUT )
     813             :         {
     814         156 :             SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
     815         156 :             if( pMasterTitle == NULL )
     816          52 :                 pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE, true);
     817             : 
     818         156 :             SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
     819         156 :             if( pMasterOutline == NULL )
     820          56 :                 pMasterPage->CreateDefaultPresObj( mePageKind == PK_STANDARD ? PRESOBJ_OUTLINE : PRESOBJ_NOTES, true );
     821             :         }
     822             : 
     823             :         // create header&footer objects
     824             : 
     825         190 :         if( bCreate )
     826             :         {
     827          77 :             if( mePageKind != PK_STANDARD )
     828             :             {
     829          54 :                 SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
     830          54 :                 if( pHeader == NULL )
     831          52 :                     pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER, true );
     832             :             }
     833             : 
     834          77 :             SdrObject* pDate   = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
     835          77 :             if( pDate == NULL )
     836          75 :                 pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME, true );
     837             : 
     838          77 :             SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
     839          77 :             if( pFooter == NULL )
     840          75 :                 pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER, true );
     841             : 
     842          77 :             SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
     843          77 :             if( pNumber == NULL )
     844          75 :                 pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER, true );
     845             :         }
     846             :     }
     847             : }
     848             : 
     849         385 : SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
     850             : {
     851         385 :     if( eObjKind == PRESOBJ_TITLE )
     852             :     {
     853          52 :         Rectangle aTitleRect( GetTitleRect() );
     854          52 :         return CreatePresObj(PRESOBJ_TITLE, sal_False, aTitleRect, bInsert);
     855             :     }
     856         333 :     else if( eObjKind == PRESOBJ_OUTLINE )
     857             :     {
     858          29 :         Rectangle aLayoutRect( GetLayoutRect() );
     859          29 :         return CreatePresObj( PRESOBJ_OUTLINE, sal_False, aLayoutRect, bInsert);
     860             :     }
     861         304 :     else if( eObjKind == PRESOBJ_NOTES )
     862             :     {
     863          27 :         Rectangle aLayoutRect( GetLayoutRect() );
     864          27 :         return CreatePresObj( PRESOBJ_NOTES, sal_False, aLayoutRect, bInsert);
     865             :     }
     866         277 :     else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
     867             :     {
     868             :         // create footer objects for standard master page
     869         277 :         if( mePageKind == PK_STANDARD )
     870             :         {
     871          69 :             const long nLftBorder = GetLftBorder();
     872          69 :             const long nUppBorder = GetUppBorder();
     873             : 
     874          69 :             Size aPageSize ( GetSize() );
     875          69 :             aPageSize.Width()  -= nLftBorder + GetRgtBorder();
     876          69 :             aPageSize.Height() -= nUppBorder + GetLwrBorder();
     877             : 
     878          69 :             const int Y = long(nUppBorder + aPageSize.Height() * 0.911);
     879          69 :             const int W1 = long(aPageSize.Width() * 0.233);
     880          69 :             const int W2 = long(aPageSize.Width() * 0.317);
     881          69 :             const int H = long(aPageSize.Height() * 0.069);
     882             : 
     883          69 :             if( eObjKind == PRESOBJ_DATETIME )
     884             :             {
     885          23 :                 Point aPos( long(nLftBorder+(aPageSize.Width()*0.05)), Y );
     886          23 :                 Size aSize( W1, H );
     887          23 :                 Rectangle aRect( aPos, aSize );
     888          23 :                 return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
     889             :             }
     890          46 :             else if( eObjKind == PRESOBJ_FOOTER )
     891             :             {
     892          23 :                 Point aPos( long(nLftBorder+ aPageSize.Width() * 0.342), Y );
     893          23 :                 Size aSize( W2, H );
     894          23 :                 Rectangle aRect( aPos, aSize );
     895          23 :                 return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
     896             :             }
     897          23 :             else if( eObjKind == PRESOBJ_SLIDENUMBER )
     898             :             {
     899          23 :                 Point aPos( long(nLftBorder+(aPageSize.Width()*0.717)), Y );
     900          23 :                 Size aSize( W1, H );
     901          23 :                 Rectangle aRect( aPos, aSize );
     902          23 :                 return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
     903             :             }
     904             :             else
     905             :             {
     906             :                 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" );
     907           0 :                 return NULL;
     908             :             }
     909             :         }
     910             :         else
     911             :         {
     912             :             // create header&footer objects for handout and notes master
     913         208 :             Size aPageSize ( GetSize() );
     914         208 :             aPageSize.Width()  -= GetLftBorder() + GetRgtBorder();
     915         208 :             aPageSize.Height() -= GetUppBorder() + GetLwrBorder();
     916             : 
     917             : 
     918         208 :             const int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * 0.434);
     919         208 :             const int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * 0.05);
     920             : 
     921         208 :             Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
     922             : 
     923         208 :             const int X1 = GetLftBorder();
     924         208 :             const int X2 = GetLftBorder() + long(aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH);
     925         208 :             const int Y1 = GetUppBorder();
     926         208 :             const int Y2 = GetUppBorder() + long(aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT );
     927             : 
     928         208 :             if( eObjKind == PRESOBJ_HEADER )
     929             :             {
     930          52 :                 Point aPos( X1, Y1 );
     931          52 :                 Rectangle aRect( aPos, aSize );
     932          52 :                 return CreatePresObj( PRESOBJ_HEADER, sal_False, aRect, bInsert );
     933             :             }
     934         156 :             else if( eObjKind == PRESOBJ_DATETIME )
     935             :             {
     936          52 :                 Point aPos( X2, Y1 );
     937          52 :                 Rectangle aRect( aPos, aSize );
     938          52 :                 return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
     939             :             }
     940         104 :             else if( eObjKind == PRESOBJ_FOOTER )
     941             :             {
     942          52 :                 Point aPos( X1, Y2 );
     943          52 :                 Rectangle aRect( aPos, aSize );
     944          52 :                 return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
     945             :             }
     946          52 :             else if( eObjKind == PRESOBJ_SLIDENUMBER )
     947             :             {
     948          52 :                 Point aPos( X2, Y2 );
     949          52 :                 Rectangle aRect( aPos, aSize );
     950          52 :                 return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
     951             :             }
     952             : 
     953             :             OSL_FAIL("SdPage::CreateDefaultPresObj() - this should not happen!");
     954           0 :             return NULL;
     955             :         }
     956             :     }
     957             :     else
     958             :     {
     959             :         OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
     960           0 :         return NULL;
     961             :     }
     962             : }
     963             : 
     964             : /*************************************************************************
     965             : |*
     966             : |* return title area
     967             : |*
     968             : \************************************************************************/
     969             : 
     970         132 : Rectangle SdPage::GetTitleRect() const
     971             : {
     972         132 :     Rectangle aTitleRect;
     973             : 
     974         132 :     if (mePageKind != PK_HANDOUT)
     975             :     {
     976             :         /******************************************************************
     977             :         * standard- or note page: title area
     978             :         ******************************************************************/
     979         132 :         Point aTitlePos ( GetLftBorder(), GetUppBorder() );
     980         132 :         Size aTitleSize ( GetSize() );
     981         132 :         aTitleSize.Width()  -= GetLftBorder() + GetRgtBorder();
     982         132 :         aTitleSize.Height() -= GetUppBorder() + GetLwrBorder();
     983             : 
     984         132 :         if (mePageKind == PK_STANDARD)
     985             :         {
     986          38 :             aTitlePos.X() += long( aTitleSize.Width() * 0.05 );
     987          38 :             aTitlePos.Y() += long( aTitleSize.Height() * 0.0399 );
     988          38 :             aTitleSize.Width() = long( aTitleSize.Width() * 0.9 );
     989          38 :             aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
     990             :         }
     991          94 :         else if (mePageKind == PK_NOTES)
     992             :         {
     993          94 :             Point aPos = aTitlePos;
     994          94 :             aPos.Y() += long( aTitleSize.Height() * 0.076 );
     995             : 
     996             :             // limit height
     997          94 :             aTitleSize.Height() = (long) (aTitleSize.Height() * 0.375);
     998             : 
     999          94 :             Size aPartArea = aTitleSize;
    1000          94 :             Size aSize;
    1001          94 :             sal_uInt16 nDestPageNum(GetPageNum());
    1002          94 :             SdrPage* pRefPage = 0L;
    1003             : 
    1004          94 :             if(nDestPageNum)
    1005             :             {
    1006             :                 // only decrement if != 0, else we get 0xffff
    1007          91 :                 nDestPageNum -= 1;
    1008             :             }
    1009             : 
    1010          94 :             if(nDestPageNum < pModel->GetPageCount())
    1011             :             {
    1012          91 :                 pRefPage = pModel->GetPage(nDestPageNum);
    1013             :             }
    1014             : 
    1015          94 :             if ( pRefPage )
    1016             :             {
    1017             :                 // scale actually page size into handout rectangle
    1018          91 :                 double fH = (double) aPartArea.Width()  / pRefPage->GetWdt();
    1019          91 :                 double fV = (double) aPartArea.Height() / pRefPage->GetHgt();
    1020             : 
    1021          91 :                 if ( fH > fV )
    1022          91 :                     fH = fV;
    1023          91 :                 aSize.Width()  = (long) (fH * pRefPage->GetWdt());
    1024          91 :                 aSize.Height() = (long) (fH * pRefPage->GetHgt());
    1025             : 
    1026          91 :                 aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
    1027          91 :                 aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
    1028             :             }
    1029             : 
    1030          94 :             aTitlePos = aPos;
    1031          94 :             aTitleSize = aSize;
    1032             :         }
    1033             : 
    1034         132 :         aTitleRect.SetPos(aTitlePos);
    1035         132 :         aTitleRect.SetSize(aTitleSize);
    1036             :     }
    1037             : 
    1038         132 :     return aTitleRect;
    1039             : }
    1040             : 
    1041             : 
    1042             : /*************************************************************************
    1043             : |*
    1044             : |* return outline area
    1045             : |*
    1046             : \************************************************************************/
    1047             : 
    1048         231 : Rectangle SdPage::GetLayoutRect() const
    1049             : {
    1050         231 :     Rectangle aLayoutRect;
    1051             : 
    1052         231 :     if (mePageKind != PK_HANDOUT)
    1053             :     {
    1054         195 :         Point aLayoutPos ( GetLftBorder(), GetUppBorder() );
    1055         195 :         Size aLayoutSize ( GetSize() );
    1056         195 :         aLayoutSize.Width()  -= GetLftBorder() + GetRgtBorder();
    1057         195 :         aLayoutSize.Height() -= GetUppBorder() + GetLwrBorder();
    1058             : 
    1059         195 :         if (mePageKind == PK_STANDARD)
    1060             :         {
    1061          64 :             aLayoutPos.X() += long( aLayoutSize.Width() * 0.05 );
    1062          64 :             aLayoutPos.Y() += long( aLayoutSize.Height() * 0.234 );
    1063          64 :             aLayoutSize.Width() = long( aLayoutSize.Width() * 0.9 );
    1064          64 :             aLayoutSize.Height() = long( aLayoutSize.Height() * 0.58 );
    1065          64 :             aLayoutRect.SetPos(aLayoutPos);
    1066          64 :             aLayoutRect.SetSize(aLayoutSize);
    1067             :         }
    1068         131 :         else if (mePageKind == PK_NOTES)
    1069             :         {
    1070         131 :             aLayoutPos.X() += long( aLayoutSize.Width() * 0.1 );
    1071         131 :             aLayoutPos.Y() += long( aLayoutSize.Height() * 0.475 );
    1072         131 :             aLayoutSize.Width() = long( aLayoutSize.Width() * 0.8 );
    1073         131 :             aLayoutSize.Height() = long( aLayoutSize.Height() * 0.45 );
    1074         131 :             aLayoutRect.SetPos(aLayoutPos);
    1075         131 :             aLayoutRect.SetSize(aLayoutSize);
    1076             :         }
    1077             :     }
    1078             : 
    1079         231 :     return aLayoutRect;
    1080             : }
    1081             : 
    1082             : 
    1083             : /**************************************************************************
    1084             : |*
    1085             : |* assign a AutoLayout
    1086             : |*
    1087             : \*************************************************************************/
    1088             : 
    1089             : const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
    1090             : const int VERTICAL = 0x8000;
    1091             : 
    1092             : struct LayoutDescriptor
    1093             : {
    1094             :     int mnLayout;
    1095             :     PresObjKind meKind[MAX_PRESOBJS];
    1096             :     bool mbVertical[MAX_PRESOBJS];
    1097             : 
    1098             :     LayoutDescriptor( int nLayout, int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
    1099             : };
    1100             : 
    1101         350 : LayoutDescriptor::LayoutDescriptor( int nLayout, int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
    1102         350 : : mnLayout( nLayout )
    1103             : {
    1104         350 :     meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
    1105         350 :     meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
    1106         350 :     meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
    1107         350 :     meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
    1108         350 :     meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
    1109         350 :     meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
    1110         350 :     meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6 & VERTICAL) == VERTICAL;
    1111         350 : }
    1112             : 
    1113         202 : static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
    1114             : {
    1115             :     static LayoutDescriptor aLayouts[AUTOLAYOUT__END-AUTOLAYOUT__START] =
    1116             :     {
    1117             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TEXT ),                                 // AUTOLAYOUT_TITLE
    1118             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),                              // AUTOLAYOUT_ENUM
    1119             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),                              // AUTOLAYOUT_CHART
    1120             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_2TEXT
    1121             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_TEXTCHART
    1122             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),                              // AUTOLAYOUT_ORG
    1123             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_TEXTCLbIP
    1124             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_CHARTTEXT
    1125             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),                              // AUTOLAYOUT_TAB
    1126             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_CLIPTEXT
    1127             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_TEXTOBJ
    1128             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OBJECT ),                               // AUTOLAYOUT_OBJ
    1129             :         LayoutDescriptor( 2, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),    // AUTOLAYOUT_TEXT2OBJ
    1130             :         LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_TEXTOBJ
    1131             :         LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_OBJOVERTEXT
    1132             :         LayoutDescriptor( 3, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),    // AUTOLAYOUT_2OBJTEXT
    1133             :         LayoutDescriptor( 5, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),    // AUTOLAYOUT_2OBJOVERTEXT
    1134             :         LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),             // AUTOLAYOUT_TEXTOVEROBJ
    1135             :         LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,                   // AUTOLAYOUT_4OBJ
    1136             :             PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),
    1137             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_NONE ),                                 // AUTOLAYOUT_ONLY_TITLE
    1138             :         LayoutDescriptor( 0, PRESOBJ_NONE ),                                                // AUTOLAYOUT_NONE
    1139             :         LayoutDescriptor( 0, PRESOBJ_PAGE, PRESOBJ_NOTES ),                                 // AUTOLAYOUT_NOTES
    1140             :         LayoutDescriptor( 0 ),                                                              // AUTOLAYOUT_HANDOUT1
    1141             :         LayoutDescriptor( 0 ),                                                              // AUTOLAYOUT_HANDOUT2
    1142             :         LayoutDescriptor( 0 ),                                                              // AUTOLAYOUT_HANDOUT3
    1143             :         LayoutDescriptor( 0 ),                                                              // AUTOLAYOUT_HANDOUT4
    1144             :         LayoutDescriptor( 0 ),                                                              // AUTOLAYOUT_HANDOUT6
    1145             :         LayoutDescriptor( 7, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
    1146             :         LayoutDescriptor( 8, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ),            // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
    1147             :         LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ),                     // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
    1148             :         LayoutDescriptor( 9, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ),   // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
    1149             :         LayoutDescriptor( 0 ),                                                              // AUTOLAYOUT_HANDOUT9
    1150             :         LayoutDescriptor( 10, PRESOBJ_TEXT, PRESOBJ_NONE ),                                 // AUTOLAYOUT_ONLY_TEXT
    1151             :         LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,               // AUTOLAYOUT_4CLIPART
    1152             :             PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
    1153             :         LayoutDescriptor( 11, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,              // AUTOLAYOUT_6CLIPART
    1154             :             PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE )
    1155         202 :     };
    1156             : 
    1157         202 :     if( (eLayout < AUTOLAYOUT__START) || (eLayout >= AUTOLAYOUT__END) )
    1158           0 :         eLayout = AUTOLAYOUT_NONE;
    1159             : 
    1160         202 :     return aLayouts[ eLayout - AUTOLAYOUT__START ];
    1161             : }
    1162             : 
    1163         202 : static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle )
    1164             : {
    1165         202 :     Rectangle aTitleRect;
    1166         202 :     Rectangle aLayoutRect;
    1167             : 
    1168         202 :     if( rPage.GetPageKind() != PK_HANDOUT )
    1169             :     {
    1170         202 :         SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
    1171         202 :         SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
    1172         202 :         SdrObject* pMasterSubTitle = rMasterPage.GetPresObj( PRESOBJ_TEXT );
    1173         202 :         SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
    1174             : 
    1175         202 :         if( pMasterTitle )
    1176         142 :             aTitleRect = pMasterTitle->GetLogicRect();
    1177             : 
    1178         202 :         if (aTitleRect.IsEmpty() )
    1179          63 :             aTitleRect = rPage.GetTitleRect();
    1180         202 :         if( pMasterSubTitle )
    1181           0 :             aLayoutRect = pMasterSubTitle->GetLogicRect();
    1182         202 :         else if( pMasterOutline )
    1183         142 :             aLayoutRect = pMasterOutline->GetLogicRect();
    1184             : 
    1185         202 :         if (aLayoutRect.IsEmpty() )
    1186          60 :             aLayoutRect = rPage.GetLayoutRect();
    1187             :     }
    1188             : 
    1189         202 :     rRectangle[0] = aTitleRect;
    1190             : 
    1191             :     int i;
    1192        1414 :     for( i = 1; i < MAX_PRESOBJS; i++ )
    1193        1212 :         rRectangle[i] = aLayoutRect;
    1194             : 
    1195         202 :     Point       aTitlePos( aTitleRect.TopLeft() );
    1196         202 :     Size        aLayoutSize( aLayoutRect.GetSize() );
    1197         202 :     Point       aLayoutPos( aLayoutRect.TopLeft() );
    1198         202 :     Size        aTempSize;
    1199         202 :     Point       aTempPnt;
    1200             : 
    1201         202 :     sal_Bool    bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB );
    1202             : 
    1203         202 :     switch( nLayout )
    1204             :     {
    1205             :     case 0: // default layout using only the title and layout area
    1206         198 :         break; // do nothing
    1207             :     case 1: // title, 2 shapes
    1208             :     case 9: // title, 2 vertical shapes
    1209           1 :         aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.488);
    1210           1 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1211             : 
    1212           1 :         aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
    1213           1 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1214             : 
    1215           1 :         if( bRightToLeft && (nLayout != 9) )
    1216           0 :             ::std::swap( rRectangle[1], rRectangle[2] );
    1217           1 :         break;
    1218             :     case 2: // title, shape, 2 shapes
    1219           3 :         aTempPnt = aLayoutPos;
    1220           3 :         aTempSize = aLayoutSize;
    1221           3 :         aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
    1222           3 :         aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
    1223           3 :         aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
    1224           3 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1225             : 
    1226           3 :         aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
    1227           3 :         rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
    1228             : 
    1229           3 :         aLayoutPos = aTempPnt;
    1230           3 :         aLayoutSize = aTempSize;
    1231           3 :         aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
    1232           3 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1233             : 
    1234           3 :         if( bRightToLeft )
    1235             :         {
    1236           0 :             ::std::swap( rRectangle[1].Left(), rRectangle[2].Left() );
    1237           0 :             rRectangle[3].Left() = rRectangle[2].Left();
    1238             :         }
    1239           3 :         break;
    1240             :     case 3: // title, 2 shapes, shape
    1241           0 :         aTempPnt = aLayoutPos;
    1242           0 :         aTempSize = aLayoutSize;
    1243           0 :         aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
    1244           0 :         aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
    1245           0 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1246             : 
    1247           0 :         aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
    1248           0 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1249             : 
    1250           0 :         aLayoutPos = aTempPnt;
    1251           0 :         aLayoutSize = aTempSize;
    1252           0 :         aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
    1253           0 :         aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
    1254           0 :         rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
    1255             : 
    1256           0 :         if( bRightToLeft )
    1257             :         {
    1258           0 :             ::std::swap( rRectangle[1].Left(), rRectangle[2].Left() );
    1259           0 :             rRectangle[3].Left() = rRectangle[2].Left();
    1260             :         }
    1261           0 :         break;
    1262             :     case 4: // title, shape above shape
    1263           0 :         aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
    1264           0 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1265             : 
    1266           0 :         aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
    1267           0 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1268           0 :         break;
    1269             : 
    1270             :     case 5: // title, 2 shapes above shape
    1271           0 :         aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
    1272           0 :         aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
    1273           0 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1274             : 
    1275           0 :         aTempPnt = aLayoutPos;
    1276           0 :         aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
    1277           0 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1278             : 
    1279           0 :         aLayoutPos.X() = aTempPnt.X();
    1280           0 :         aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
    1281           0 :         aLayoutSize.Width() = long (aLayoutSize.Width() / 0.488);
    1282           0 :         rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
    1283           0 :         break;
    1284             :     case 6: // title, 4 shapes
    1285             :     {
    1286           0 :         sal_uLong nX = long (aLayoutPos.X());
    1287             : 
    1288           0 :         aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
    1289           0 :         aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.488);
    1290           0 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1291             : 
    1292           0 :         aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
    1293           0 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1294             : 
    1295           0 :         aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
    1296           0 :         rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
    1297             : 
    1298           0 :         aLayoutPos.X() = nX;
    1299           0 :         rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
    1300           0 :         break;
    1301             :     }
    1302             :     case 7: // vertical title, shape above shape
    1303             :     {
    1304           0 :         Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
    1305           0 :         rRectangle[0].SetSize( aSize );
    1306           0 :         rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
    1307             : 
    1308           0 :         Size aPageSize ( rPage.GetSize() );
    1309           0 :         aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
    1310           0 :         aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
    1311           0 :         aSize.Width() = long( aPageSize.Width() * 0.7 );
    1312           0 :         rRectangle[1].SetPos( aTitleRect.TopLeft() );
    1313           0 :         rRectangle[1].SetSize( aSize );
    1314             : 
    1315           0 :         aSize.Height() = rRectangle[0].GetSize().Height();
    1316           0 :         Point aPos( aTitleRect.TopLeft() );
    1317           0 :         aPos.Y() += long ( aSize.Height() * 0.53 );
    1318           0 :         rRectangle[2].SetPos( aPos );
    1319           0 :         aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
    1320           0 :         rRectangle[2].SetSize( aSize );
    1321           0 :         break;
    1322             :     }
    1323             :     case 8: // vertical title, shape
    1324             :     {
    1325           0 :         Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
    1326           0 :         rRectangle[0].SetSize( aSize );
    1327           0 :         rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
    1328             : 
    1329           0 :         Size aPageSize ( rPage.GetSize() );
    1330           0 :         aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
    1331           0 :         aSize.Height() = rRectangle[0].GetSize().Height();
    1332           0 :         aSize.Width() = long( aPageSize.Width() * 0.7 );
    1333           0 :         rRectangle[1].SetPos( aTitleRect.TopLeft() );
    1334           0 :         rRectangle[1].SetSize( aSize );
    1335           0 :         break;
    1336             :     }
    1337             :     case 10: // onlytext
    1338             :     {
    1339           0 :         Size aSize( rRectangle[0].GetSize().Width(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
    1340           0 :         rRectangle[0].SetSize( aSize );
    1341           0 :         rRectangle[0].SetPos( aTitlePos);
    1342           0 :         break;
    1343             :     }
    1344             :     case 11: // title, 6 shapes
    1345             :     {
    1346           0 :         sal_uLong nX = long (aLayoutPos.X());
    1347             : 
    1348           0 :         aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
    1349           0 :         aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.322);
    1350           0 :         rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
    1351             : 
    1352           0 :         aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
    1353           0 :         rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
    1354             : 
    1355           0 :         aLayoutPos.X() = long (nX + aLayoutSize.Width() * 2 * 1.05);
    1356           0 :         rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
    1357             : 
    1358           0 :         aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
    1359           0 :         rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
    1360             : 
    1361           0 :         aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
    1362           0 :         rRectangle[5] = Rectangle (aLayoutPos, aLayoutSize);
    1363             : 
    1364           0 :         aLayoutPos.X() = nX;
    1365           0 :         rRectangle[6] = Rectangle (aLayoutPos, aLayoutSize);
    1366             : 
    1367           0 :         break;
    1368             :     }
    1369             : 
    1370             :     }
    1371         202 : }
    1372             : 
    1373             : 
    1374         202 : void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout )
    1375             : {
    1376             :     int i;
    1377             : 
    1378             :     // init list of indexes for each presentation shape kind
    1379             :     // this is used to find subsequent shapes with the same presentation shape kind
    1380             :     int PresObjIndex[PRESOBJ_MAX];
    1381         202 :     for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
    1382             : 
    1383         202 :     bool bMissing = false;
    1384             : 
    1385             :     // for each entry in the layoutdescriptor, arrange a presentation shape
    1386         606 :     for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
    1387             :     {
    1388         404 :         PresObjKind eKind = rDescriptor.meKind[i];
    1389         404 :         SdrObject* pObj = 0;
    1390         818 :         while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != 0 )
    1391             :         {
    1392          87 :             PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
    1393             : 
    1394          87 :             if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
    1395             :             {
    1396          77 :                 rShapes[i] = pObj;
    1397          77 :                 break;
    1398             :             }
    1399             :         }
    1400             : 
    1401         404 :         if( !pObj )
    1402         327 :             bMissing = true;
    1403             :     }
    1404             : 
    1405         202 :     if( bMissing && bInit )
    1406             :     {
    1407             :         // for each entry in the layoutdescriptor, look for an alternative shape
    1408         425 :         for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
    1409             :         {
    1410         283 :             if( rShapes[i] )
    1411           0 :                 continue;
    1412             : 
    1413         283 :             PresObjKind eKind = rDescriptor.meKind[i];
    1414             : 
    1415         283 :             SdrObject* pObj = 0;
    1416         283 :             bool bFound = false;
    1417             : 
    1418         283 :             const int nShapeCount = rPage.GetObjCount();
    1419         283 :             int nShapeIndex = 0;
    1420         580 :             while((nShapeIndex < nShapeCount) && !bFound )
    1421             :             {
    1422          14 :                 pObj = rPage.GetObj(nShapeIndex++);
    1423             : 
    1424          14 :                 if( pObj->IsEmptyPresObj() )
    1425          14 :                     continue;
    1426             : 
    1427           0 :                 if( pObj->GetObjInventor() != SdrInventor )
    1428           0 :                     continue;
    1429             : 
    1430             :                 // do not reuse shapes that are already part of the layout
    1431           0 :                 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
    1432           0 :                     continue;
    1433             : 
    1434           0 :                 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE);
    1435           0 :                 SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
    1436             : 
    1437           0 :                 switch( eKind )
    1438             :                 {
    1439             :                 case PRESOBJ_TITLE:
    1440           0 :                     bFound = eSdrObjKind == OBJ_TITLETEXT;
    1441           0 :                     break;
    1442             :                 case PRESOBJ_TABLE:
    1443           0 :                     bFound = eSdrObjKind == OBJ_TABLE;
    1444           0 :                     break;
    1445             :                 case PRESOBJ_MEDIA:
    1446           0 :                     bFound = eSdrObjKind == OBJ_MEDIA;
    1447           0 :                     break;
    1448             :                 case PRESOBJ_OUTLINE:
    1449           0 :                     bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
    1450           0 :                              ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
    1451           0 :                              (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
    1452           0 :                     break;
    1453             :                 case PRESOBJ_GRAPHIC:
    1454           0 :                     bFound = eSdrObjKind == OBJ_GRAF;
    1455           0 :                     break;
    1456             :                 case PRESOBJ_OBJECT:
    1457           0 :                     if( eSdrObjKind == OBJ_OLE2 )
    1458             :                     {
    1459           0 :                         SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
    1460           0 :                         if( pOle2 )
    1461             :                         {
    1462           0 :                             if( pOle2->IsEmpty() )
    1463           0 :                                 bFound = true;
    1464           0 :                             else if( rPage.GetModel() )
    1465             :                             {
    1466           0 :                                 SdrModel* pSdrModel = rPage.GetModel();
    1467           0 :                                 ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
    1468           0 :                                 if( pPersist )
    1469             :                                 {
    1470           0 :                                     uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
    1471           0 :                                             GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
    1472             : 
    1473             :                                     // TODO CL->KA: Why is this not working anymore?
    1474           0 :                                     if( xObject.is() )
    1475             :                                     {
    1476           0 :                                         SvGlobalName aClassId( xObject->getClassID() );
    1477             : 
    1478           0 :                                         const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
    1479           0 :                                         const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
    1480           0 :                                         const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
    1481             : 
    1482           0 :                                         if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
    1483             :                                         {
    1484           0 :                                             bFound = true;
    1485           0 :                                         }
    1486           0 :                                     }
    1487             :                                 }
    1488             :                              }
    1489             :                          }
    1490             :                     }
    1491           0 :                     break;
    1492             :                 case PRESOBJ_CHART:
    1493             :                 case PRESOBJ_CALC:
    1494           0 :                     if( eSdrObjKind == OBJ_OLE2 )
    1495             :                     {
    1496           0 :                         SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
    1497           0 :                         if( pOle2 )
    1498             :                         {
    1499           0 :                             if(
    1500           0 :                                 ((eKind == PRESOBJ_CHART) &&
    1501           0 :                                     ( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) )
    1502           0 :                                 ||
    1503           0 :                                 ((eKind == PRESOBJ_CALC) &&
    1504           0 :                                     ( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) )
    1505             :                             {
    1506           0 :                                 bFound = true;
    1507             :                             }
    1508             :                         }
    1509           0 :                         break;
    1510             :                     }
    1511           0 :                     else if( eSdrObjKind == OBJ_TABLE )
    1512             :                     {
    1513           0 :                         bFound = true;
    1514             :                     }
    1515           0 :                     break;
    1516             :                 case PRESOBJ_PAGE:
    1517             :                 case PRESOBJ_HANDOUT:
    1518           0 :                     bFound = eSdrObjKind == OBJ_PAGE;
    1519           0 :                     break;
    1520             :                 case PRESOBJ_NOTES:
    1521             :                 case PRESOBJ_TEXT:
    1522           0 :                     bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
    1523           0 :                     break;
    1524             :                 default:
    1525           0 :                     break;
    1526             :                 }
    1527             :             }
    1528             : 
    1529         283 :             if( bFound )
    1530           0 :                 rShapes[i] = pObj;
    1531             :         }
    1532             :     }
    1533         202 : }
    1534             : 
    1535         366 : void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate )
    1536             : {
    1537         366 :     sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
    1538             : 
    1539         366 :     const bool bSwitchLayout = eLayout != GetAutoLayout();
    1540             : 
    1541         366 :     ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
    1542         366 :     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
    1543             : 
    1544         366 :     meAutoLayout = eLayout;
    1545             : 
    1546             :     // if needed, creates and initialises the presentation shapes on this slides master page
    1547         366 :     CreateTitleAndLayout(bInit, bCreate);
    1548             : 
    1549         366 :     if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
    1550             :     {
    1551             :         // MasterPage or no layout and no presentation shapes available, nothing to do
    1552         530 :         return;
    1553             :     }
    1554             : 
    1555         202 :     Rectangle aRectangle[MAX_PRESOBJS];
    1556         202 :     const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
    1557         202 :     CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle );
    1558             : 
    1559         404 :     std::set< SdrObject* > aUsedPresentationObjects;
    1560             : 
    1561             : 
    1562         404 :     std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, 0);
    1563         202 :     findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
    1564             : 
    1565             :     int i;
    1566             : 
    1567             :     // for each entry in the layoutdescriptor, arrange a presentation shape
    1568         606 :     for (i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++)
    1569             :     {
    1570         404 :         PresObjKind eKind = aDescriptor.meKind[i];
    1571         404 :         SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
    1572         404 :         if( pObj )
    1573         360 :             aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
    1574             :     }
    1575             : 
    1576             :     // now delete all empty presentation objects that are no longer used by the new layout
    1577         202 :     if( bInit )
    1578             :     {
    1579         148 :         SdrObject* pObj = 0;
    1580         148 :         maPresentationShapeList.seekShape(0);
    1581             : 
    1582         599 :         while( (pObj = maPresentationShapeList.getNextShape()) )
    1583             :         {
    1584         303 :             if( aUsedPresentationObjects.count(pObj) == 0 )
    1585             :             {
    1586             : 
    1587          14 :                 if( pObj->IsEmptyPresObj() )
    1588             :                 {
    1589          14 :                     if( bUndo )
    1590           0 :                         pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
    1591             : 
    1592          14 :                     RemoveObject( pObj->GetOrdNum() );
    1593             : 
    1594          14 :                     if( !bUndo )
    1595          14 :                         SdrObject::Free( pObj );
    1596             :                 }
    1597             : /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
    1598             :             }
    1599             :         }
    1600         202 :     }
    1601             : }
    1602             : 
    1603             : /*************************************************************************
    1604             : |*
    1605             : |* insert object
    1606             : |*
    1607             : \************************************************************************/
    1608             : 
    1609        1641 : void SdPage::NbcInsertObject(SdrObject* pObj, sal_uLong nPos, const SdrInsertReason* pReason)
    1610             : {
    1611        1641 :     FmFormPage::NbcInsertObject(pObj, nPos, pReason);
    1612             : 
    1613        1641 :     ((SdDrawDocument*) pModel)->InsertObject(pObj, this);
    1614             : 
    1615        1641 :     SdrLayerID nId = pObj->GetLayer();
    1616        1641 :     if( mbMaster )
    1617             :     {
    1618         806 :         if( nId == 0 )
    1619         706 :             pObj->NbcSetLayer( 2 );     // wrong layer. corrected to BackgroundObj layer
    1620             :     }
    1621             :     else
    1622             :     {
    1623         835 :         if( nId == 2 )
    1624           0 :             pObj->NbcSetLayer( 0 );     // wrong layer. corrected to layout layer
    1625             :     }
    1626        1641 : }
    1627             : 
    1628             : /*************************************************************************
    1629             : |*
    1630             : |* remove object
    1631             : |*
    1632             : \************************************************************************/
    1633             : 
    1634         289 : SdrObject* SdPage::RemoveObject(sal_uLong nObjNum)
    1635             : {
    1636         289 :     onRemoveObject(GetObj( nObjNum ));
    1637         289 :     return FmFormPage::RemoveObject(nObjNum);
    1638             : }
    1639             : 
    1640             : /*************************************************************************
    1641             : |*
    1642             : |* remove object without broadcast
    1643             : |*
    1644             : \************************************************************************/
    1645             : 
    1646           0 : SdrObject* SdPage::NbcRemoveObject(sal_uLong nObjNum)
    1647             : {
    1648           0 :     onRemoveObject(GetObj( nObjNum ));
    1649           0 :     return FmFormPage::NbcRemoveObject(nObjNum);
    1650             : }
    1651             : 
    1652             : // Also overload ReplaceObject methods to realize when
    1653             : // objects are removed with this mechanism instead of RemoveObject
    1654           0 : SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
    1655             : {
    1656           0 :     onRemoveObject(GetObj( nObjNum ));
    1657           0 :     return FmFormPage::NbcReplaceObject(pNewObj, nObjNum);
    1658             : }
    1659             : 
    1660             : // Also overload ReplaceObject methods to realize when
    1661             : // objects are removed with this mechanism instead of RemoveObject
    1662          20 : SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
    1663             : {
    1664          20 :     onRemoveObject(GetObj( nObjNum ));
    1665          20 :     return FmFormPage::ReplaceObject(pNewObj, nObjNum);
    1666             : }
    1667             : 
    1668             : // -------------------------------------------------------------------------
    1669             : 
    1670             : // called after a shape is removed or replaced from this slide
    1671             : 
    1672         309 : void SdPage::onRemoveObject( SdrObject* pObject )
    1673             : {
    1674         309 :     if( pObject )
    1675             :     {
    1676         309 :         RemovePresObj(pObject);
    1677             : 
    1678         309 :         if( pModel )
    1679         309 :             static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject, this);
    1680             : 
    1681         309 :         removeAnimations( pObject );
    1682             :     }
    1683         309 : }
    1684             : 
    1685         715 : void SdPage::SetSize(const Size& aSize)
    1686             : {
    1687         715 :     Size aOldSize = GetSize();
    1688             : 
    1689         715 :     if (aSize != aOldSize)
    1690             :     {
    1691         692 :         FmFormPage::SetSize(aSize);
    1692             : 
    1693         692 :         if (aOldSize.Height() == 10 && aOldSize.Width() == 10)
    1694             :         {
    1695             :             // this page gets a valid size for the first time. Therefore
    1696             :             // we initialize the orientation.
    1697         596 :             if (aSize.Width() > aSize.Height())
    1698             :             {
    1699         100 :                 meOrientation = ORIENTATION_LANDSCAPE;
    1700             :             }
    1701             :             else
    1702             :             {
    1703         496 :                 meOrientation = ORIENTATION_PORTRAIT;
    1704             :             }
    1705             :         }
    1706             :     }
    1707         715 : }
    1708             : 
    1709         519 : void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
    1710             : {
    1711        1844 :     if (nLft != GetLftBorder() || nUpp != GetUppBorder() ||
    1712        1325 :         nRgt != GetRgtBorder() || nLwr != GetLwrBorder() )
    1713             :     {
    1714         116 :         FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
    1715             :     }
    1716         519 : }
    1717             : 
    1718          22 : void SdPage::SetLftBorder(sal_Int32 nBorder)
    1719             : {
    1720          22 :     if (nBorder != GetLftBorder() )
    1721             :     {
    1722          22 :         FmFormPage::SetLftBorder(nBorder);
    1723             :     }
    1724          22 : }
    1725             : 
    1726          22 : void SdPage::SetRgtBorder(sal_Int32 nBorder)
    1727             : {
    1728          22 :     if (nBorder != GetRgtBorder() )
    1729             :     {
    1730          22 :         FmFormPage::SetRgtBorder(nBorder);
    1731             :     }
    1732          22 : }
    1733             : 
    1734          22 : void SdPage::SetUppBorder(sal_Int32 nBorder)
    1735             : {
    1736          22 :     if (nBorder != GetUppBorder() )
    1737             :     {
    1738          22 :         FmFormPage::SetUppBorder(nBorder);
    1739             :     }
    1740          22 : }
    1741             : 
    1742          22 : void SdPage::SetLwrBorder(sal_Int32 nBorder)
    1743             : {
    1744          22 :     if (nBorder != GetLwrBorder() )
    1745             :     {
    1746          22 :         FmFormPage::SetLwrBorder(nBorder);
    1747             :     }
    1748          22 : }
    1749             : 
    1750             : /*************************************************************************
    1751             : |*
    1752             : |* Sets BackgroundFullSize and then calls AdjustBackground
    1753             : |*
    1754             : \************************************************************************/
    1755             : 
    1756           9 : void SdPage::SetBackgroundFullSize( sal_Bool bIn )
    1757             : {
    1758           9 :     if( bIn != mbBackgroundFullSize )
    1759             :     {
    1760           2 :         mbBackgroundFullSize = bIn;
    1761             :     }
    1762           9 : }
    1763             : 
    1764             : /*************************************************************************
    1765             : |*
    1766             : |* Adjust all objects to new page size.
    1767             : |*
    1768             : |* bScaleAllObj: all objects are scaled into the new area within the page
    1769             : |* margins. We scale the position and size. For presentation objects on the
    1770             : |* master page, we also scale the font height of the presentation template.
    1771             : |*
    1772             : \************************************************************************/
    1773             : 
    1774           0 : void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect, sal_Bool bScaleAllObj)
    1775             : {
    1776           0 :     sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
    1777             : 
    1778           0 :     mbScaleObjects = bScaleAllObj;
    1779           0 :     SdrObject* pObj = NULL;
    1780           0 :     Point aRefPnt(0, 0);
    1781           0 :     Size aNewPageSize(rNewPageSize);
    1782           0 :     sal_Int32 nLeft  = rNewBorderRect.Left();
    1783           0 :     sal_Int32 nRight = rNewBorderRect.Right();
    1784           0 :     sal_Int32 nUpper = rNewBorderRect.Top();
    1785           0 :     sal_Int32 nLower = rNewBorderRect.Bottom();
    1786             : 
    1787             :     // negative values are fixed values
    1788             :     // -> use up to date values
    1789           0 :     if (aNewPageSize.Width() < 0)
    1790             :     {
    1791           0 :         aNewPageSize.Width() = GetWdt();
    1792             :     }
    1793           0 :     if (aNewPageSize.Height() < 0)
    1794             :     {
    1795           0 :         aNewPageSize.Height() = GetHgt();
    1796             :     }
    1797           0 :     if (nLeft < 0)
    1798             :     {
    1799           0 :         nLeft = GetLftBorder();
    1800             :     }
    1801           0 :     if (nRight < 0)
    1802             :     {
    1803           0 :         nRight = GetRgtBorder();
    1804             :     }
    1805           0 :     if (nUpper < 0)
    1806             :     {
    1807           0 :         nUpper = GetUppBorder();
    1808             :     }
    1809           0 :     if (nLower < 0)
    1810             :     {
    1811           0 :         nLower = GetLwrBorder();
    1812             :     }
    1813             : 
    1814           0 :     Point aBackgroundPos(nLeft, nUpper);
    1815           0 :     Size aBackgroundSize(aNewPageSize);
    1816           0 :     Rectangle aBorderRect (aBackgroundPos, aBackgroundSize);
    1817             : 
    1818           0 :     if (mbScaleObjects)
    1819             :     {
    1820           0 :         aBackgroundSize.Width()  -= nLeft  + nRight;
    1821           0 :         aBackgroundSize.Height() -= nUpper + nLower;
    1822           0 :         aBorderRect.SetSize(aBackgroundSize);
    1823           0 :         aNewPageSize = aBackgroundSize;
    1824             :     }
    1825             : 
    1826           0 :     long nOldWidth  = GetWdt() - GetLftBorder() - GetRgtBorder();
    1827           0 :     long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder();
    1828             : 
    1829           0 :     Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth);
    1830           0 :     Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight);
    1831             : 
    1832           0 :     sal_uLong nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
    1833             : 
    1834           0 :     for (sal_uLong nObj = 0; nObj < nObjCnt; nObj++)
    1835             :     {
    1836           0 :         sal_Bool bIsPresObjOnMaster = sal_False;
    1837             : 
    1838             :         // all Objects
    1839           0 :         pObj = GetObj(nObj);
    1840             : 
    1841           0 :         if (mbMaster && IsPresObj(pObj))
    1842             :         {
    1843             :             // There is a presentation object on the master page
    1844           0 :             bIsPresObjOnMaster = sal_True;
    1845             :         }
    1846             : 
    1847           0 :         if (pObj)
    1848             :         {
    1849             :             // remember aTopLeft as original TopLeft
    1850           0 :             Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
    1851             : 
    1852           0 :             if (!pObj->IsEdgeObj())
    1853             :             {
    1854             :                 /**************************************************************
    1855             :                 * Scale objects
    1856             :                 **************************************************************/
    1857           0 :                 if (mbScaleObjects)
    1858             :                 {
    1859             :                     // use aTopLeft as original TopLeft
    1860           0 :                     aRefPnt = aTopLeft;
    1861             :                 }
    1862             : 
    1863           0 :                 pObj->Resize(aRefPnt, aFractX, aFractY);
    1864             : 
    1865           0 :                 if (mbScaleObjects)
    1866             :                 {
    1867           0 :                     SdrObjKind eObjKind = (SdrObjKind) pObj->GetObjIdentifier();
    1868             : 
    1869           0 :                     if (bIsPresObjOnMaster)
    1870             :                     {
    1871             :                         /**********************************************************
    1872             :                         * presentation template: adjust test height
    1873             :                         **********************************************************/
    1874           0 :                         sal_uInt16 nIndexTitle = 0;
    1875           0 :                         sal_uInt16 nIndexOutline = 0;
    1876           0 :                         sal_uInt16 nIndexNotes = 0;
    1877             : 
    1878           0 :                         if (pObj == GetPresObj(PRESOBJ_TITLE, nIndexTitle))
    1879             :                         {
    1880           0 :                             SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
    1881             : 
    1882           0 :                             if (pTitleSheet)
    1883             :                             {
    1884           0 :                                 SfxItemSet& rSet = pTitleSheet->GetItemSet();
    1885             : 
    1886           0 :                                 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT);
    1887           0 :                                 sal_uLong nFontHeight = rOldHgt.GetHeight();
    1888           0 :                                 nFontHeight = long(nFontHeight * (double) aFractY);
    1889           0 :                                 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
    1890             : 
    1891           0 :                                 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
    1892             :                                 {
    1893           0 :                                     rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
    1894           0 :                                     nFontHeight = rOldHgt.GetHeight();
    1895           0 :                                     nFontHeight = long(nFontHeight * (double) aFractY);
    1896           0 :                                     rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
    1897             :                                 }
    1898             : 
    1899           0 :                                 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
    1900             :                                 {
    1901           0 :                                     rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
    1902           0 :                                     nFontHeight = rOldHgt.GetHeight();
    1903           0 :                                     nFontHeight = long(nFontHeight * (double) aFractY);
    1904           0 :                                     rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
    1905             :                                 }
    1906             : 
    1907           0 :                                 pTitleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
    1908             :                             }
    1909             :                         }
    1910           0 :                         else if (pObj == GetPresObj(PRESOBJ_OUTLINE, nIndexOutline))
    1911             :                         {
    1912           0 :                             String aName(GetLayoutName());
    1913           0 :                             aName += sal_Unicode( ' ' );
    1914             : 
    1915           0 :                             for (sal_uInt16 i=1; i<=9; i++)
    1916             :                             {
    1917           0 :                                 String sLayoutName(aName);
    1918           0 :                                 sLayoutName += OUString::number( (sal_Int32)i );
    1919           0 :                                 SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)((SdDrawDocument*) pModel)->GetStyleSheetPool()->Find(sLayoutName, SD_STYLE_FAMILY_MASTERPAGE);
    1920             : 
    1921           0 :                                 if (pOutlineSheet)
    1922             :                                 {
    1923             :                                     // Calculate new font height
    1924           0 :                                     SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
    1925             : 
    1926           0 :                                     SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT);
    1927           0 :                                     sal_uLong nFontHeight = rOldHgt.GetHeight();
    1928           0 :                                     nFontHeight = long(nFontHeight * (double) aFractY);
    1929           0 :                                     aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
    1930             : 
    1931           0 :                                     if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
    1932             :                                     {
    1933           0 :                                         rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
    1934           0 :                                         nFontHeight = rOldHgt.GetHeight();
    1935           0 :                                         nFontHeight = long(nFontHeight * (double) aFractY);
    1936           0 :                                         aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
    1937             :                                     }
    1938             : 
    1939           0 :                                     if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
    1940             :                                     {
    1941           0 :                                         rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
    1942           0 :                                         nFontHeight = rOldHgt.GetHeight();
    1943           0 :                                         nFontHeight = long(nFontHeight * (double) aFractY);
    1944           0 :                                         aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
    1945             :                                     }
    1946             : 
    1947             :                                     // adjust bullet
    1948           0 :                                     ((SdStyleSheet*) pOutlineSheet)->AdjustToFontHeight(aTempSet, sal_False);
    1949             : 
    1950             :                                     // Special treatment: reset the INVALIDS to
    1951             :                                     // NULL pointer (otherwise we have INVALID's
    1952             :                                     // or pointer to the DefaultItems in the
    1953             :                                     // template; both would suppress the
    1954             :                                     // attribute inheritance)
    1955           0 :                                     aTempSet.ClearInvalidItems();
    1956             : 
    1957             :                                     // Special treatment: only the valid parts
    1958             :                                     // of the BulletItems
    1959           0 :                                     if (aTempSet.GetItemState(EE_PARA_BULLET) == SFX_ITEM_AVAILABLE)
    1960             :                                     {
    1961           0 :                                         SvxBulletItem aOldBulItem((SvxBulletItem&) pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET));
    1962           0 :                                         SvxBulletItem& rNewBulItem = (SvxBulletItem&) aTempSet.Get(EE_PARA_BULLET);
    1963           0 :                                         aOldBulItem.CopyValidProperties(rNewBulItem);
    1964           0 :                                         aTempSet.Put(aOldBulItem);
    1965             :                                     }
    1966             : 
    1967           0 :                                     pOutlineSheet->GetItemSet().Put(aTempSet);
    1968           0 :                                     pOutlineSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
    1969             :                                 }
    1970           0 :                             }
    1971             :                         }
    1972           0 :                         else if (pObj == GetPresObj(PRESOBJ_NOTES, nIndexNotes))
    1973             :                         {
    1974           0 :                             SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
    1975             : 
    1976           0 :                             if (pNotesSheet)
    1977             :                             {
    1978           0 :                                 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
    1979           0 :                                 sal_uLong nFontHeight = (sal_uLong) (nHeight * 0.0741);
    1980           0 :                                 SfxItemSet& rSet = pNotesSheet->GetItemSet();
    1981           0 :                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
    1982           0 :                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
    1983           0 :                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
    1984           0 :                                 pNotesSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
    1985             :                             }
    1986             :                         }
    1987             :                     }
    1988           0 :                     else if ( eObjKind != OBJ_TITLETEXT   &&
    1989           0 :                               eObjKind != OBJ_OUTLINETEXT &&
    1990           0 :                               pObj->ISA(SdrTextObj)       &&
    1991           0 :                               pObj->GetOutlinerParaObject() )
    1992             :                     {
    1993             :                         /******************************************************
    1994             :                         * normal text object: adjust text height
    1995             :                         ******************************************************/
    1996           0 :                         sal_uLong nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
    1997           0 :                         sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
    1998           0 :                         if ( nScriptType == SCRIPTTYPE_ASIAN )
    1999           0 :                             nWhich = EE_CHAR_FONTHEIGHT_CJK;
    2000           0 :                         else if ( nScriptType == SCRIPTTYPE_COMPLEX )
    2001           0 :                             nWhich = EE_CHAR_FONTHEIGHT_CTL;
    2002             : 
    2003             :                         // use more modern method to scale the text height
    2004           0 :                         sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight();
    2005           0 :                         sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY);
    2006             : 
    2007           0 :                         pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
    2008             :                     }
    2009             :                 }
    2010             :             }
    2011             : 
    2012           0 :             if (mbScaleObjects && !pObj->IsEdgeObj())
    2013             :             {
    2014             :                 /**************************************************************
    2015             :                 * scale object position
    2016             :                 **************************************************************/
    2017           0 :                 Point aNewPos;
    2018             : 
    2019             :                 // corrected scaling; only distances may be scaled
    2020             :                 // use aTopLeft as original TopLeft
    2021           0 :                 aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft;
    2022           0 :                 aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper;
    2023             : 
    2024           0 :                 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
    2025             : 
    2026           0 :                 if (aVec.Height() != 0 || aVec.Width() != 0)
    2027             :                 {
    2028           0 :                     pObj->NbcMove(aVec);
    2029             :                 }
    2030             : 
    2031           0 :                 pObj->SetChanged();
    2032           0 :                 pObj->BroadcastObjectChange();
    2033             :             }
    2034             :         }
    2035           0 :     }
    2036           0 : }
    2037             : 
    2038           6 : SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, Rectangle aRect )
    2039             : {
    2040           6 :     SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() );
    2041             :     DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" );
    2042           6 :     if( !pModel || !pSourceObj )
    2043           0 :         return pSourceObj;
    2044             : 
    2045           6 :     ::svl::IUndoManager* pUndoManager = static_cast<SdDrawDocument*>(pModel)->GetUndoManager();
    2046           6 :     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
    2047             : 
    2048           6 :     SdrObject* pNewObj = pSourceObj;
    2049           6 :     if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
    2050             :     {
    2051           0 :         pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, aRect);
    2052             : 
    2053             :         // Set text of the subtitle into PRESOBJ_OUTLINE
    2054           0 :         OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
    2055             : 
    2056           0 :         if(pOutlParaObj)
    2057             :         {
    2058             :             // assign text
    2059           0 :             ::sd::Outliner* pOutl = pModel->GetInternalOutliner( sal_True );
    2060           0 :             pOutl->Clear();
    2061           0 :             pOutl->SetText( *pOutlParaObj );
    2062           0 :             pOutlParaObj = pOutl->CreateParaObject();
    2063           0 :             pNewObj->SetOutlinerParaObject( pOutlParaObj );
    2064           0 :             pOutl->Clear();
    2065           0 :             pNewObj->SetEmptyPresObj(sal_False);
    2066             : 
    2067           0 :             for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
    2068             :             {
    2069             :                 // assign new template
    2070           0 :                 String aName(rPage.GetLayoutName());
    2071           0 :                 aName += sal_Unicode( ' ' );
    2072           0 :                 aName += OUString::number( nLevel );
    2073           0 :                 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) );
    2074             : 
    2075           0 :                 if (pSheet)
    2076             :                 {
    2077           0 :                     if (nLevel == 1)
    2078             :                     {
    2079           0 :                         SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
    2080             : 
    2081           0 :                         if (pSubtitleSheet)
    2082           0 :                             pOutlParaObj->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE, pSubtitleSheet->GetName(), pSheet->GetName());
    2083             :                     }
    2084             : 
    2085           0 :                     pNewObj->StartListening(*pSheet);
    2086             :                 }
    2087           0 :             }
    2088             : 
    2089             :             // Remove LRSpace item
    2090           0 :             SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
    2091             : 
    2092           0 :             aSet.Put(pNewObj->GetMergedItemSet());
    2093             : 
    2094           0 :             aSet.ClearItem(EE_PARA_LRSPACE);
    2095             : 
    2096           0 :             pNewObj->SetMergedItemSet(aSet);
    2097             : 
    2098           0 :             if( bUndo )
    2099           0 :                 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
    2100             : 
    2101             :             // Remove outline shape from page
    2102           0 :             rPage.RemoveObject( pSourceObj->GetOrdNum() );
    2103             : 
    2104           0 :             if( !bUndo )
    2105           0 :                 SdrObject::Free( pSourceObj );
    2106             :         }
    2107             :     }
    2108           6 :     else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
    2109             :     {
    2110             :         // is there an outline shape we can use to replace empty subtitle shape?
    2111           0 :         pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, aRect);
    2112             : 
    2113             :         // Set text of the outline object into PRESOBJ_TITLE
    2114           0 :         OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
    2115             : 
    2116           0 :         if(pOutlParaObj)
    2117             :         {
    2118             :             // assign text
    2119           0 :             ::sd::Outliner* pOutl = pModel->GetInternalOutliner();
    2120           0 :             pOutl->Clear();
    2121           0 :             pOutl->SetText( *pOutlParaObj );
    2122           0 :             pOutlParaObj = pOutl->CreateParaObject();
    2123           0 :             pNewObj->SetOutlinerParaObject( pOutlParaObj );
    2124           0 :             pOutl->Clear();
    2125           0 :             pNewObj->SetEmptyPresObj(sal_False);
    2126             : 
    2127             :             // reset left indent
    2128           0 :             SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
    2129             : 
    2130           0 :             aSet.Put(pNewObj->GetMergedItemSet());
    2131             : 
    2132           0 :             const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&) aSet.Get(EE_PARA_LRSPACE);
    2133           0 :             SvxLRSpaceItem aNewLRItem(rLRItem);
    2134           0 :             aNewLRItem.SetTxtLeft(0);
    2135           0 :             aSet.Put(aNewLRItem);
    2136             : 
    2137           0 :             pNewObj->SetMergedItemSet(aSet);
    2138             : 
    2139           0 :             SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
    2140           0 :             if (pSheet)
    2141           0 :                 pNewObj->SetStyleSheet(pSheet, sal_True);
    2142             : 
    2143             :             // Remove subtitle shape from page
    2144           0 :             if( bUndo )
    2145           0 :                 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
    2146             : 
    2147           0 :             rPage.RemoveObject( pSourceObj->GetOrdNum() );
    2148             : 
    2149           0 :             if( !bUndo )
    2150           0 :                 SdrObject::Free( pSourceObj );
    2151             :         }
    2152             :     }
    2153           6 :     else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
    2154             :     {
    2155           0 :         switch( pSourceObj->GetObjIdentifier() )
    2156             :         {
    2157           0 :         case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break;
    2158           0 :         case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break;
    2159           0 :         case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break;
    2160           0 :         case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break;
    2161             :         }
    2162             :     }
    2163             : 
    2164           6 :     return pNewObj;
    2165             : }
    2166             : 
    2167             : /** reuses or creates a presentation shape for an auto layout that fits the given parameter
    2168             : 
    2169             :     @param  eObjKind
    2170             :         The kind of presentation shape we like to have
    2171             :     @param  nIndex
    2172             :         If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
    2173             :         looking for an existing presentation shape
    2174             :     @param  bVertical
    2175             :         If true, the shape is created vertical if bInit is true
    2176             :     @param  aRect
    2177             :         The rectangle that should be used to transform the shape
    2178             :     @param  bInit
    2179             :         If true the shape is created if not found
    2180             :     @returns
    2181             :         A presentation shape that was either found or created with the given parameters
    2182             : */
    2183         404 : SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit )
    2184             : {
    2185         404 :     ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
    2186         404 :     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
    2187             : 
    2188         404 :     if (!pObj && bInit)
    2189             :     {
    2190         283 :         pObj = CreatePresObj(eObjKind, bVertical, aRect);
    2191             :     }
    2192         121 :     else if ( pObj && (pObj->GetUserCall() || bInit) )
    2193             :     {
    2194             :         // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
    2195           6 :         if( bInit )
    2196           6 :             pObj = convertPresentationObjectImpl( *this, pObj, eObjKind, bVertical, aRect );
    2197             : 
    2198           6 :         if( bUndo )
    2199             :         {
    2200           0 :             pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
    2201           0 :             pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, sal_True, sal_True ) );
    2202           0 :             pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
    2203             :         }
    2204             : 
    2205           6 :             ( /*(SdrGrafObj*)*/ pObj)->AdjustToMaxRect( aRect );
    2206             : 
    2207           6 :         pObj->SetUserCall(this);
    2208             : 
    2209           6 :         SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
    2210           6 :         if( pTextObject )
    2211             :         {
    2212           6 :             if( pTextObject->IsVerticalWriting() != (bVertical ? sal_True : sal_False) )
    2213             :             {
    2214           0 :                 pTextObject->SetVerticalWriting( bVertical );
    2215             : 
    2216             :                 // here make sure the correct anchoring is used when the object
    2217             :                 // is re-used but orientation is changed
    2218           0 :                 if(PRESOBJ_OUTLINE == eObjKind)
    2219           0 :                     pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
    2220             :             }
    2221             : 
    2222           6 :             if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
    2223             :             {
    2224           6 :                 if ( pTextObject->IsAutoGrowHeight() )
    2225             :                 {
    2226             :                     // switch off AutoGrowHeight, set new MinHeight
    2227           6 :                     SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
    2228          12 :                     SdrTextMinFrameHeightItem aMinHeight( aRect.GetSize().Height() );
    2229           6 :                     aTempAttr.Put( aMinHeight );
    2230           6 :                     aTempAttr.Put( SdrTextAutoGrowHeightItem(sal_False) );
    2231           6 :                     pTextObject->SetMergedItemSet(aTempAttr);
    2232           6 :                     pTextObject->SetLogicRect(aRect);
    2233             : 
    2234             :                     // switch on AutoGrowHeight
    2235          12 :                     SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
    2236           6 :                     aAttr.Put( SdrTextAutoGrowHeightItem(sal_True) );
    2237             : 
    2238          12 :                     pTextObject->SetMergedItemSet(aAttr);
    2239             :                 }
    2240             : 
    2241           6 :                 if ( pTextObject->IsAutoGrowWidth() )
    2242             :                 {
    2243             :                     // switch off AutoGrowWidth , set new MinWidth
    2244           0 :                     SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
    2245           0 :                     SdrTextMinFrameWidthItem aMinWidth( aRect.GetSize().Width() );
    2246           0 :                     aTempAttr.Put( aMinWidth );
    2247           0 :                     aTempAttr.Put( SdrTextAutoGrowWidthItem(sal_False) );
    2248           0 :                     pTextObject->SetMergedItemSet(aTempAttr);
    2249           0 :                     pTextObject->SetLogicRect(aRect);
    2250             : 
    2251             :                     // switch on AutoGrowWidth
    2252           0 :                     SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
    2253           0 :                     aAttr.Put( SdrTextAutoGrowWidthItem(sal_True) );
    2254           0 :                     pTextObject->SetMergedItemSet(aAttr);
    2255             :                 }
    2256             :             }
    2257             :         }
    2258             :     }
    2259             : 
    2260         404 :     if(pObj && bInit )
    2261             :     {
    2262         289 :         if( !IsPresObj( pObj ) )
    2263             :         {
    2264           0 :             if( bUndo )
    2265           0 :                 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
    2266             : 
    2267           0 :             InsertPresObj( pObj, eObjKind );
    2268             :         }
    2269             : 
    2270             :         // make adjustments for vertical title and outline shapes
    2271         289 :         if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
    2272             :         {
    2273           0 :             SfxItemSet aNewSet(pObj->GetMergedItemSet());
    2274           0 :             aNewSet.Put( SdrTextAutoGrowWidthItem(sal_True) );
    2275           0 :             aNewSet.Put( SdrTextAutoGrowHeightItem(sal_False) );
    2276           0 :             if( eObjKind == PRESOBJ_OUTLINE )
    2277             :             {
    2278           0 :                 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
    2279           0 :                 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
    2280             :             }
    2281           0 :             pObj->SetMergedItemSet(aNewSet);
    2282             :         }
    2283             :     }
    2284             : 
    2285         404 :     if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) )
    2286         289 :         pObj->AdjustToMaxRect( aRect );
    2287             : 
    2288         404 :     return pObj;
    2289             : }
    2290             : 
    2291             : 
    2292             : /*************************************************************************
    2293             : |*
    2294             : |* Returns the PresObjKind of a object
    2295             : |*
    2296             : \************************************************************************/
    2297             : 
    2298        4580 : PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
    2299             : {
    2300        4580 :     PresObjKind eKind = PRESOBJ_NONE;
    2301        4580 :     if( (pObj != 0) && (maPresentationShapeList.hasShape(*pObj)) )
    2302             :     {
    2303        1179 :         SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
    2304        1179 :         if( pInfo )
    2305        1179 :             eKind = pInfo->mePresObjKind;
    2306             :     }
    2307             : 
    2308        4580 :     return eKind;
    2309             : }
    2310             : 
    2311         484 : bool SdPage::IsPresObj(const SdrObject* pObj)
    2312             : {
    2313         484 :     return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
    2314             : }
    2315             : 
    2316         511 : void SdPage::RemovePresObj(const SdrObject* pObj)
    2317             : {
    2318         511 :     if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
    2319             :     {
    2320         225 :         SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
    2321         225 :         if( pInfo )
    2322         225 :             pInfo->mePresObjKind = PRESOBJ_NONE;
    2323         225 :         maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
    2324             :     }
    2325         511 : }
    2326             : 
    2327        1158 : void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
    2328             : {
    2329             :     DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
    2330             :     DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
    2331        1158 :     if( pObj )
    2332             :     {
    2333        1158 :         SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
    2334        1158 :         if( pInfo )
    2335        1158 :             pInfo->mePresObjKind = eKind;
    2336        1158 :         maPresentationShapeList.addShape(*pObj);
    2337             :     }
    2338        1158 : }
    2339             : 
    2340             : /*************************************************************************
    2341             : |*
    2342             : |* Set the text of a object
    2343             : |*
    2344             : \************************************************************************/
    2345             : 
    2346         692 : void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const String& rString )
    2347             : {
    2348         692 :     if ( pObj )
    2349             :     {
    2350             :         DBG_ASSERT( pObj->ISA(SdrTextObj), "SetObjText: No SdrTextObj!" );
    2351         692 :         ::Outliner* pOutl = pOutliner;
    2352             : 
    2353         692 :         if (!pOutliner)
    2354             :         {
    2355          16 :             SfxItemPool* pPool = ((SdDrawDocument*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
    2356          16 :             pOutl = new ::Outliner( pPool, OUTLINERMODE_OUTLINEOBJECT );
    2357          16 :             pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument*) GetModel() )->GetDocSh() ) );
    2358          16 :             pOutl->SetEditTextObjectPool(pPool);
    2359          16 :             pOutl->SetStyleSheetPool((SfxStyleSheetPool*)GetModel()->GetStyleSheetPool());
    2360          16 :             pOutl->EnableUndo(sal_False);
    2361          16 :             pOutl->SetUpdateMode( sal_False );
    2362             :         }
    2363             : 
    2364         692 :         sal_uInt16 nOutlMode = pOutl->GetMode();
    2365         692 :         Size aPaperSize = pOutl->GetPaperSize();
    2366         692 :         sal_Bool bUpdateMode = pOutl->GetUpdateMode();
    2367         692 :         pOutl->SetUpdateMode(sal_False);
    2368         692 :         pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
    2369             : 
    2370             :         // Always set the object's StyleSheet at the Outliner to
    2371             :         // use the current objects StyleSheet. Thus it's the same as in
    2372             :         // SetText(...).
    2373             :         // Moved this implementation from where SetObjText(...) was called
    2374             :         // to inside this method to work even when outliner is fetched here.
    2375         692 :         pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
    2376             : 
    2377         692 :         OUString aString;
    2378             : 
    2379         692 :         switch( eObjKind )
    2380             :         {
    2381             :             case PRESOBJ_OUTLINE:
    2382             :             {
    2383          54 :                 pOutl->Init( OUTLINERMODE_OUTLINEOBJECT );
    2384             : 
    2385          54 :                 aString += "\t";
    2386          54 :                 aString += rString;
    2387             : 
    2388          54 :                 if (mbMaster)
    2389             :                 {
    2390          43 :                     pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
    2391          43 :                     aString += "\n\t\t";
    2392          43 :                     aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER2);
    2393             : 
    2394          43 :                     aString += "\n\t\t\t";
    2395          43 :                     aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER3);
    2396             : 
    2397          43 :                     aString += "\n\t\t\t\t";
    2398          43 :                     aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER4);
    2399             : 
    2400          43 :                     aString += "\n\t\t\t\t\t";
    2401          43 :                     aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER5);
    2402             : 
    2403          43 :                     aString += "\n\t\t\t\t\t\t";
    2404          43 :                     aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER6);
    2405             : 
    2406          43 :                     aString += "\n\t\t\t\t\t\t\t";
    2407          43 :                     aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER7);
    2408             : 
    2409             :                 }
    2410             :             }
    2411          54 :             break;
    2412             : 
    2413             :             case PRESOBJ_TITLE:
    2414             :             {
    2415         124 :                 pOutl->Init( OUTLINERMODE_TITLEOBJECT );
    2416         124 :                 aString += rString;
    2417             :             }
    2418         124 :             break;
    2419             : 
    2420             :             default:
    2421             :             {
    2422         514 :                 pOutl->Init( OUTLINERMODE_TEXTOBJECT );
    2423         514 :                 aString += rString;
    2424             : 
    2425             :                 // check if we need to add a text field
    2426         514 :                 SvxFieldData* pData = NULL;
    2427             : 
    2428         514 :                 switch( eObjKind )
    2429             :                 {
    2430             :                 case PRESOBJ_HEADER:
    2431          58 :                     pData = new SvxHeaderField();
    2432          58 :                     break;
    2433             :                 case PRESOBJ_FOOTER:
    2434          89 :                     pData = new SvxFooterField();
    2435          89 :                     break;
    2436             :                 case PRESOBJ_SLIDENUMBER:
    2437          92 :                     pData = new SvxPageField();
    2438          92 :                     break;
    2439             :                 case PRESOBJ_DATETIME:
    2440          88 :                     pData = new SvxDateTimeField();
    2441          88 :                     break;
    2442             :                 default:
    2443         187 :                     break;
    2444             :                 }
    2445             : 
    2446         514 :                 if( pData )
    2447             :                 {
    2448         327 :                     ESelection e;
    2449         327 :                     SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
    2450         327 :                     pOutl->QuickInsertField(aField,e);
    2451         327 :                     delete pData;
    2452             :                 }
    2453             :             }
    2454         514 :             break;
    2455             :         }
    2456             : 
    2457         692 :         pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
    2458             : 
    2459         692 :         if( !aString.isEmpty() )
    2460         365 :             pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
    2461             : 
    2462         692 :         ( (SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() );
    2463             : 
    2464         692 :         if (!pOutliner)
    2465             :         {
    2466          16 :             delete pOutl;
    2467          16 :             pOutl = NULL;
    2468             :         }
    2469             :         else
    2470             :         {
    2471             :             // Outliner restaurieren
    2472         676 :             pOutl->Init( nOutlMode );
    2473         676 :             pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
    2474         676 :             pOutl->SetUpdateMode( bUpdateMode );
    2475         676 :             pOutl->SetPaperSize( aPaperSize );
    2476         692 :         }
    2477             :     }
    2478         692 : }
    2479             : 
    2480             : /*************************************************************************
    2481             : |*
    2482             : |* Set the name of the layout
    2483             : |*
    2484             : \************************************************************************/
    2485         227 : void SdPage::SetLayoutName(OUString aName)
    2486             : {
    2487         227 :     maLayoutName = aName;
    2488             : 
    2489         227 :     if( mbMaster )
    2490             :     {
    2491          59 :         OUString aSep(SD_LT_SEPARATOR);
    2492          59 :         sal_Int32 nPos = maLayoutName.indexOf(aSep);
    2493          59 :         if (nPos != -1)
    2494          59 :             FmFormPage::SetName(maLayoutName.copy(0, nPos));
    2495             :     }
    2496         227 : }
    2497             : 
    2498             : 
    2499             : /*************************************************************************
    2500             : |*
    2501             : |* Return the page name and generates it if necessary
    2502             : |*
    2503             : \************************************************************************/
    2504             : 
    2505        1399 : const String& SdPage::GetName() const
    2506             : {
    2507        1399 :     String aCreatedPageName( maCreatedPageName );
    2508        1399 :     if (GetRealName().Len() == 0)
    2509             :     {
    2510        1330 :         if ((mePageKind == PK_STANDARD || mePageKind == PK_NOTES) && !mbMaster)
    2511             :         {
    2512             :             // default name for handout pages
    2513        1123 :             sal_uInt16  nNum = (GetPageNum() + 1) / 2;
    2514             : 
    2515        1123 :             aCreatedPageName = String(SdResId(STR_PAGE));
    2516        1123 :             aCreatedPageName += sal_Unicode( ' ' );
    2517        1123 :             if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE )
    2518             :             {
    2519             :                 // if the document has number none as a formating
    2520             :                 // for page numbers we still default to arabic numbering
    2521             :                 // to keep the default page names unique
    2522           0 :                 aCreatedPageName += OUString::number( (sal_Int32)nNum );
    2523             :             }
    2524             :             else
    2525             :             {
    2526        1123 :                 aCreatedPageName += ((SdDrawDocument*) GetModel())->CreatePageNumValue(nNum);
    2527        1123 :             }
    2528             :         }
    2529             :         else
    2530             :         {
    2531             :             /******************************************************************
    2532             :             * default name for note pages
    2533             :             ******************************************************************/
    2534         207 :             aCreatedPageName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
    2535             :         }
    2536             :     }
    2537             :     else
    2538             :     {
    2539          69 :         aCreatedPageName = GetRealName();
    2540             :     }
    2541             : 
    2542        1399 :     if (mePageKind == PK_NOTES)
    2543             :     {
    2544          92 :         aCreatedPageName += sal_Unicode( ' ' );
    2545          92 :         aCreatedPageName += String(SdResId(STR_NOTES));
    2546             :     }
    2547        1307 :     else if (mePageKind == PK_HANDOUT && mbMaster)
    2548             :     {
    2549          29 :         aCreatedPageName += OUString(" (");
    2550          29 :         aCreatedPageName += SdResId(STR_HANDOUT).toString();
    2551          29 :         aCreatedPageName += sal_Unicode( ')' );
    2552             :     }
    2553             : 
    2554        1399 :     const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
    2555        1399 :     return maCreatedPageName;
    2556             : }
    2557             : 
    2558          81 : void SdPage::SetOrientation( Orientation eOrient)
    2559             : {
    2560          81 :     meOrientation = eOrient;
    2561          81 : }
    2562             : 
    2563         114 : Orientation SdPage::GetOrientation() const
    2564             : {
    2565         114 :     return meOrientation;
    2566             : }
    2567             : 
    2568             : /*************************************************************************
    2569             : |*
    2570             : |* returns the default text of a PresObjektes
    2571             : |*
    2572             : \************************************************************************/
    2573             : 
    2574        1040 : String SdPage::GetPresObjText(PresObjKind eObjKind) const
    2575             : {
    2576        1040 :     String aString;
    2577             : 
    2578        1040 :     if (eObjKind == PRESOBJ_TITLE)
    2579             :     {
    2580         124 :         if (mbMaster)
    2581             :         {
    2582          79 :             if (mePageKind != PK_NOTES)
    2583             :             {
    2584          43 :                 aString = String ( SdResId( STR_PRESOBJ_MPTITLE ) );
    2585             :             }
    2586             :             else
    2587             :             {
    2588          36 :                 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTITLE ) );
    2589             :             }
    2590             :         }
    2591             :         else
    2592             :         {
    2593          45 :             aString = String ( SdResId( STR_PRESOBJ_TITLE ) );
    2594             :         }
    2595             :     }
    2596         916 :     else if (eObjKind == PRESOBJ_OUTLINE)
    2597             :     {
    2598          54 :         if (mbMaster)
    2599             :         {
    2600          43 :             aString = String ( SdResId( STR_PRESOBJ_MPOUTLINE ) );
    2601             :         }
    2602             :         else
    2603             :         {
    2604          11 :             aString = String ( SdResId( STR_PRESOBJ_OUTLINE ) );
    2605             :         }
    2606             :     }
    2607         862 :     else if (eObjKind == PRESOBJ_NOTES)
    2608             :     {
    2609         156 :         if (mbMaster)
    2610             :         {
    2611          36 :             aString = String ( SdResId( STR_PRESOBJ_MPNOTESTEXT ) );
    2612             :         }
    2613             :         else
    2614             :         {
    2615         120 :             aString = String ( SdResId( STR_PRESOBJ_NOTESTEXT ) );
    2616             :         }
    2617             :     }
    2618         706 :     else if (eObjKind == PRESOBJ_TEXT)
    2619             :     {
    2620          28 :         aString = String ( SdResId( STR_PRESOBJ_TEXT ) );
    2621             :     }
    2622         678 :     else if (eObjKind == PRESOBJ_GRAPHIC)
    2623             :     {
    2624           1 :         aString = String ( SdResId( STR_PRESOBJ_GRAPHIC ) );
    2625             :     }
    2626         677 :     else if (eObjKind == PRESOBJ_OBJECT)
    2627             :     {
    2628           2 :         aString = String ( SdResId( STR_PRESOBJ_OBJECT ) );
    2629             :     }
    2630         675 :     else if (eObjKind == PRESOBJ_CHART)
    2631             :     {
    2632           0 :         aString = String ( SdResId( STR_PRESOBJ_CHART ) );
    2633             :     }
    2634         675 :     else if (eObjKind == PRESOBJ_ORGCHART)
    2635             :     {
    2636           0 :         aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) );
    2637             :     }
    2638         675 :     else if (eObjKind == PRESOBJ_CALC)
    2639             :     {
    2640           0 :         aString = String ( SdResId( STR_PRESOBJ_TABLE ) );
    2641             :     }
    2642             : 
    2643        1040 :     return(aString);
    2644             : }
    2645             : 
    2646             : extern uno::Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage );
    2647             : 
    2648         328 : uno::Reference< uno::XInterface > SdPage::createUnoPage()
    2649             : {
    2650         328 :     return createUnoPageImpl( this );
    2651             : }
    2652             : 
    2653             : /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
    2654           0 : SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage )
    2655             : {
    2656             :     try
    2657             :     {
    2658           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( xPage, ::com::sun::star::uno::UNO_QUERY );
    2659           0 :         if( xUnoTunnel.is() )
    2660             :         {
    2661           0 :             SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
    2662           0 :             if( pUnoPage )
    2663           0 :                 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
    2664           0 :         }
    2665             :     }
    2666           0 :     catch( ::com::sun::star::uno::Exception& )
    2667             :     {
    2668             :         OSL_FAIL("sd::SdPage::getImplementation(), exception caught!" );
    2669             :     }
    2670             : 
    2671           0 :     return 0;
    2672             : }
    2673             : 
    2674         225 : void SdPage::SetName (const String& rName)
    2675             : {
    2676         225 :     String aOldName = GetName();
    2677         225 :     FmFormPage::SetName (rName);
    2678         225 :     static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName);
    2679         225 :     ActionChanged();
    2680         225 : }
    2681             : 
    2682         841 : const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
    2683             : {
    2684         841 :     if( mePageKind == PK_HANDOUT && !mbMaster )
    2685             :     {
    2686           0 :         return (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings);
    2687             :     }
    2688             :     else
    2689             :     {
    2690         841 :         return maHeaderFooterSettings;
    2691             :     }
    2692             : }
    2693             : 
    2694         250 : void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
    2695             : {
    2696         250 :     if( mePageKind == PK_HANDOUT && !mbMaster )
    2697             :     {
    2698           0 :         (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings) = rNewSettings;
    2699             :     }
    2700             :     else
    2701             :     {
    2702         250 :         maHeaderFooterSettings = rNewSettings;
    2703             :     }
    2704             : 
    2705         250 :     SetChanged();
    2706         250 :     if(TRG_HasMasterPage())
    2707             :     {
    2708         249 :         TRG_GetMasterPageDescriptorViewContact().ActionChanged();
    2709             :     }
    2710         250 : }
    2711             : 
    2712        1165 : bool SdPage::checkVisibility(
    2713             :     const sdr::contact::ViewObjectContact& rOriginal,
    2714             :     const sdr::contact::DisplayInfo& rDisplayInfo,
    2715             :     bool bEdit )
    2716             : {
    2717        1165 :     if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
    2718           0 :         return false;
    2719             : 
    2720        1165 :     SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
    2721        1165 :     if( pObj == NULL )
    2722           0 :         return false;
    2723             : 
    2724        1165 :     const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
    2725        1165 :     const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
    2726        1165 :     const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
    2727        1165 :     const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
    2728             : 
    2729             :     // empty presentation objects only visible during edit mode
    2730        1165 :     if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
    2731             :     {
    2732           0 :         if( (pObj->GetObjInventor() != SdrInventor) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
    2733           0 :             return false;
    2734             :     }
    2735             : 
    2736        1165 :     if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
    2737             :     {
    2738         521 :            const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage());
    2739             : 
    2740         521 :         if( pCheckPage )
    2741             :         {
    2742         521 :             PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
    2743             : 
    2744         521 :             if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
    2745             :             {
    2746         205 :                 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
    2747             : 
    2748         205 :                 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PK_HANDOUT && bIsPrinting ) )
    2749             :                 {
    2750             :                     // use the page that is currently processed
    2751         205 :                     const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
    2752             : 
    2753         205 :                     if( pVisualizedSdPage )
    2754             :                     {
    2755             :                         // if we are not on a masterpage, see if we have to draw this header&footer object at all
    2756         205 :                         const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
    2757             : 
    2758         205 :                         switch( eKind )
    2759             :                         {
    2760             :                         case PRESOBJ_FOOTER:
    2761          68 :                             return rSettings.mbFooterVisible;
    2762             :                         case PRESOBJ_HEADER:
    2763           1 :                             return rSettings.mbHeaderVisible;
    2764             :                         case PRESOBJ_DATETIME:
    2765          68 :                             return rSettings.mbDateTimeVisible;
    2766             :                         case PRESOBJ_SLIDENUMBER:
    2767          68 :                             return rSettings.mbSlideNumberVisible;
    2768             :                         default:
    2769           0 :                             break;
    2770             :                         }
    2771             :                     }
    2772           0 :                 }
    2773             :             } // check for placeholders on master
    2774         316 :             else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
    2775             :             {
    2776             :                 // presentation objects on master slide are always invisible if slide is shown.
    2777           0 :                 return false;
    2778             :             }
    2779             :         }
    2780             :     }
    2781             : 
    2782             :     // i63977, do not print SdrpageObjs from master pages
    2783         960 :     if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
    2784             :     {
    2785           6 :         if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() )
    2786           0 :             return false;
    2787             :     }
    2788             : 
    2789         960 :     return true;
    2790             : }
    2791             : 
    2792           0 : bool SdPage::RestoreDefaultText( SdrObject* pObj )
    2793             : {
    2794           0 :     bool bRet = false;
    2795             : 
    2796           0 :     SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
    2797             : 
    2798           0 :     if( pTextObj )
    2799             :     {
    2800           0 :         PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
    2801             : 
    2802           0 :         if (ePresObjKind == PRESOBJ_TITLE   ||
    2803           0 :             ePresObjKind == PRESOBJ_OUTLINE ||
    2804           0 :             ePresObjKind == PRESOBJ_NOTES   ||
    2805             :             ePresObjKind == PRESOBJ_TEXT)
    2806             :         {
    2807           0 :             String aString( GetPresObjText(ePresObjKind) );
    2808             : 
    2809           0 :             if (aString.Len())
    2810             :             {
    2811           0 :                 sal_Bool bVertical = sal_False;
    2812           0 :                 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
    2813           0 :                 if( pOldPara )
    2814           0 :                     bVertical = pOldPara->IsVertical();  // is old para object vertical?
    2815             : 
    2816           0 :                 SetObjText( pTextObj, 0, ePresObjKind, aString );
    2817             : 
    2818           0 :                 if( pOldPara )
    2819             :                 {
    2820             :                     // Here, only the vertical flag for the
    2821             :                     // OutlinerParaObjects needs to be changed. The
    2822             :                     // AutoGrowWidth/Height items still exist in the
    2823             :                     // not changed object.
    2824           0 :                     if(pTextObj
    2825           0 :                         && pTextObj->GetOutlinerParaObject()
    2826           0 :                         && pTextObj->GetOutlinerParaObject()->IsVertical() != (bool)bVertical)
    2827             :                     {
    2828           0 :                         Rectangle aObjectRect = pTextObj->GetSnapRect();
    2829           0 :                         pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
    2830           0 :                         pTextObj->SetSnapRect(aObjectRect);
    2831             :                     }
    2832             :                 }
    2833             : 
    2834           0 :                 pTextObj->SetTextEditOutliner( NULL );  // to make stylesheet settings work
    2835           0 :                 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), sal_True );
    2836           0 :                 pTextObj->SetEmptyPresObj(sal_True);
    2837           0 :                 bRet = true;
    2838           0 :             }
    2839             :         }
    2840             :     }
    2841           0 :     return bRet;
    2842             : }
    2843             : 
    2844          34 : void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas )
    2845             : {
    2846          34 :     SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PK_HANDOUT );
    2847             : 
    2848          34 :     if( eLayout == AUTOLAYOUT_NONE )
    2849             :     {
    2850             :         // use layout from handout master
    2851           0 :         SdrObjListIter aShapeIter (rHandoutMaster);
    2852           0 :         while (aShapeIter.IsMore())
    2853             :         {
    2854           0 :             SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
    2855           0 :             if (pPageObj)
    2856           0 :                 rAreas.push_back( pPageObj->GetCurrentBoundRect() );
    2857           0 :         }
    2858             :     }
    2859             :     else
    2860             :     {
    2861          34 :         Size    aArea = rHandoutMaster.GetSize();
    2862             : 
    2863          34 :         const long nGapW = 1000; // gap is 1cm
    2864          34 :         const long nGapH = 1000;
    2865             : 
    2866          34 :         long nLeftBorder = rHandoutMaster.GetLftBorder();
    2867          34 :         long nRightBorder = rHandoutMaster.GetRgtBorder();
    2868          34 :         long nTopBorder = rHandoutMaster.GetUppBorder();
    2869          34 :         long nBottomBorder = rHandoutMaster.GetLwrBorder();
    2870             : 
    2871          34 :         const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05  );
    2872             : 
    2873          34 :         nTopBorder += nHeaderFooterHeight;
    2874          34 :         nBottomBorder += nHeaderFooterHeight;
    2875             : 
    2876          34 :         long nX = nGapW + nLeftBorder;
    2877          34 :         long nY = nGapH + nTopBorder;
    2878             : 
    2879          34 :         aArea.Width() -= nGapW * 2 + nLeftBorder + nRightBorder;
    2880          34 :         aArea.Height() -= nGapH * 2 + nTopBorder + nBottomBorder;
    2881             : 
    2882          34 :         const bool bLandscape = aArea.Width() > aArea.Height();
    2883             : 
    2884             :         static sal_uInt16 aOffsets[5][9] =
    2885             :         {
    2886             :             { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
    2887             :             { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
    2888             :             { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
    2889             :             { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
    2890             :             { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
    2891             :         };
    2892             : 
    2893          34 :         sal_uInt16* pOffsets = aOffsets[0];
    2894          34 :         sal_uInt16  nColCnt = 0, nRowCnt = 0;
    2895          34 :         switch ( eLayout )
    2896             :         {
    2897             :             case AUTOLAYOUT_HANDOUT1:
    2898           0 :                 nColCnt = 1; nRowCnt = 1;
    2899           0 :                 break;
    2900             : 
    2901             :             case AUTOLAYOUT_HANDOUT2:
    2902           0 :                 if( bLandscape )
    2903             :                 {
    2904           0 :                     nColCnt = 2; nRowCnt = 1;
    2905             :                 }
    2906             :                 else
    2907             :                 {
    2908           0 :                     nColCnt = 1; nRowCnt = 2;
    2909             :                 }
    2910           0 :                 break;
    2911             : 
    2912             :             case AUTOLAYOUT_HANDOUT3:
    2913           0 :                 if( bLandscape )
    2914             :                 {
    2915           0 :                     nColCnt = 3; nRowCnt = 2;
    2916             :                 }
    2917             :                 else
    2918             :                 {
    2919           0 :                     nColCnt = 2; nRowCnt = 3;
    2920             :                 }
    2921           0 :                 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
    2922           0 :                 break;
    2923             : 
    2924             :             case AUTOLAYOUT_HANDOUT4:
    2925           0 :                 nColCnt = 2; nRowCnt = 2;
    2926           0 :                 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
    2927           0 :                 break;
    2928             : 
    2929             :             case AUTOLAYOUT_HANDOUT6:
    2930          34 :                 if( bLandscape )
    2931             :                 {
    2932           0 :                     nColCnt = 3; nRowCnt = 2;
    2933             :                 }
    2934             :                 else
    2935             :                 {
    2936          34 :                     nColCnt = 2; nRowCnt = 3;
    2937             :                 }
    2938          34 :                 if( !bHorizontal )
    2939          34 :                     pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
    2940          34 :                 break;
    2941             : 
    2942             :             default:
    2943             :             case AUTOLAYOUT_HANDOUT9:
    2944           0 :                 nColCnt = 3; nRowCnt = 3;
    2945             : 
    2946           0 :                 if( !bHorizontal )
    2947           0 :                     pOffsets = aOffsets[4];
    2948           0 :                 break;
    2949             :         }
    2950             : 
    2951          34 :         rAreas.resize( nColCnt * nRowCnt );
    2952             : 
    2953          34 :         Size aPartArea, aSize;
    2954          34 :         aPartArea.Width()  = ((aArea.Width()  - ((nColCnt-1) * nGapW) ) / nColCnt);
    2955          34 :         aPartArea.Height() = ((aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt);
    2956             : 
    2957          34 :         SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PK_STANDARD);
    2958          34 :         if ( pFirstPage )
    2959             :         {
    2960             :             // scale actual size into handout rect
    2961          34 :             double fScale = (double)aPartArea.Width() / (double)pFirstPage->GetWdt();
    2962             : 
    2963          34 :             aSize.Height() = (long)(fScale * pFirstPage->GetHgt() );
    2964          34 :             if( aSize.Height() > aPartArea.Height() )
    2965             :             {
    2966           0 :                 fScale = (double)aPartArea.Height() / (double)pFirstPage->GetHgt();
    2967           0 :                 aSize.Height() = aPartArea.Height();
    2968           0 :                 aSize.Width() = (long)(fScale * pFirstPage->GetWdt());
    2969             :             }
    2970             :             else
    2971             :             {
    2972          34 :                 aSize.Width() = aPartArea.Width();
    2973             :             }
    2974             : 
    2975          34 :             nX += (aPartArea.Width() - aSize.Width()) / 2;
    2976          34 :             nY += (aPartArea.Height()- aSize.Height())/ 2;
    2977             :         }
    2978             :         else
    2979             :         {
    2980           0 :             aSize = aPartArea;
    2981             :         }
    2982             : 
    2983          34 :         Point aPos( nX, nY );
    2984             : 
    2985          34 :         const bool bRTL = rModel.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
    2986             : 
    2987          34 :         const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
    2988          34 :         const long nOffsetY = aPartArea.Height() + nGapH;
    2989          34 :         const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) + nX : nX;
    2990             : 
    2991         136 :         for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
    2992             :         {
    2993         102 :             aPos.X() = nStartX;
    2994         306 :             for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
    2995             :             {
    2996         204 :                 rAreas[*pOffsets++] = Rectangle(aPos, aSize);
    2997         204 :                 aPos.X() += nOffsetX;
    2998             :             }
    2999             : 
    3000         102 :             aPos.Y() += nOffsetY;
    3001             :         }
    3002             :     }
    3003          34 : }
    3004             : 
    3005             : 
    3006             : 
    3007             : 
    3008           0 : void SdPage::SetPrecious (const bool bIsPrecious)
    3009             : {
    3010           0 :     mbIsPrecious = bIsPrecious;
    3011           0 : }
    3012             : 
    3013             : 
    3014             : 
    3015             : 
    3016           0 : bool SdPage::IsPrecious (void) const
    3017             : {
    3018           0 :     return mbIsPrecious;
    3019             : }
    3020             : 
    3021             : 
    3022             : 
    3023             : 
    3024         599 : HeaderFooterSettings::HeaderFooterSettings()
    3025             : {
    3026         599 :     mbHeaderVisible = true;
    3027         599 :     mbFooterVisible = true;
    3028         599 :     mbSlideNumberVisible = false;
    3029         599 :     mbDateTimeVisible = true;
    3030         599 :     mbDateTimeIsFixed = true;
    3031         599 :     meDateTimeFormat = SVXDATEFORMAT_A;
    3032         599 : }
    3033             : 
    3034         118 : bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
    3035             : {
    3036         233 :     return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
    3037         230 :            (maHeaderText == rSettings.maHeaderText) &&
    3038         219 :            (mbFooterVisible == rSettings.mbFooterVisible) &&
    3039         208 :            (maFooterText == rSettings.maFooterText) &&
    3040         208 :            (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
    3041         197 :            (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
    3042         186 :            (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
    3043         304 :            (meDateTimeFormat == rSettings.meDateTimeFormat) &&
    3044         211 :            (maDateTimeText == rSettings.maDateTimeText);
    3045          33 : }
    3046             : 
    3047             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10