LCOV - code coverage report
Current view: top level - sd/source/core - sdpage.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 973 1441 67.5 %
Date: 2015-06-13 12:38:46 Functions: 57 67 85.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11