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

Generated by: LCOV version 1.10