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

Generated by: LCOV version 1.10