1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <comphelper/classids.hxx>
25 #include <vcl/svapp.hxx>
26 #include <editeng/outliner.hxx>
27 #include <editeng/eeitem.hxx>
28 #include <svx/svdoutl.hxx>
29 #include <editeng/editdata.hxx>
30 #include <svx/pageitem.hxx>
31 #include <editeng/lrspitem.hxx>
32 #include <editeng/bulletitem.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <editeng/fhgtitem.hxx>
35 #include <editeng/outlobj.hxx>
36 #include <svx/svdoole2.hxx>
37 #include <svx/svdograf.hxx>
38 #include <svx/svdopage.hxx>
39 #include <sfx2/printer.hxx>
40 #include <basic/basmgr.hxx>
41 #include <editeng/pbinitem.hxx>
42 #include <svx/svdundo.hxx>
43 #include <svl/smplhint.hxx>
44 #include <editeng/adjustitem.hxx>
45 #include <editeng/editobj.hxx>
46 #include <editeng/scripttypeitem.hxx>
47 #include <svx/unopage.hxx>
48 #include <editeng/flditem.hxx>
49 #include <svx/sdr/contact/displayinfo.hxx>
50 #include <svx/svditer.hxx>
52 #include "../ui/inc/DrawDocShell.hxx"
53 #include "Outliner.hxx"
55 #include "drawdoc.hxx"
58 #include "sdresid.hxx"
59 #include "stlsheet.hxx"
63 #include "anminfo.hxx"
64 #include "undo/undomanager.hxx"
65 #include "undo/undoobjects.hxx"
66 #include <svx/sdr/contact/viewobjectcontact.hxx>
67 #include <svx/sdr/contact/viewcontact.hxx>
68 #include <svx/sdr/contact/objectcontact.hxx>
69 #include <svx/unoapi.hxx>
74 using namespace ::com::sun::star
;
76 TYPEINIT2( SdPage
, FmFormPage
, SdrObjUserCall
);
78 /*************************************************************************
82 \************************************************************************/
84 SdPage::SdPage(SdDrawDocument
& rNewDoc
, StarBASIC
* pBasic
, sal_Bool bMasterPage
)
85 : FmFormPage(rNewDoc
, pBasic
, bMasterPage
)
87 , mePageKind(PK_STANDARD
)
88 , meAutoLayout(AUTOLAYOUT_NONE
)
89 , mbSelected(sal_False
)
90 , mePresChange(PRESCHANGE_MANUAL
)
92 , mbSoundOn(sal_False
)
93 , mbExcluded(sal_False
)
94 , mbLoopSound(sal_False
)
95 , mbStopSound(sal_False
)
96 , mbScaleObjects(sal_True
)
97 , mbBackgroundFullSize( sal_False
)
98 , meCharSet(osl_getThreadTextEncoding())
99 , mnPaperBin(PAPERBIN_PRINTER_SETTINGS
)
102 , mnTransitionType(0)
103 , mnTransitionSubtype(0)
104 , mbTransitionDirection(sal_True
)
105 , mnTransitionFadeColor(0)
106 , mfTransitionDuration(2.0)
109 // The name of the layout of the page is used by SVDRAW to determine the
110 // presentation template of the outline objects. Therefore, it already
111 // contains the designator for the outline (STR_LAYOUT_OUTLINE).
112 OUStringBuffer
aBuf(SdResId(STR_LAYOUT_DEFAULT_NAME
).toString());
113 aBuf
.append(SD_LT_SEPARATOR
).append(SdResId(STR_LAYOUT_OUTLINE
).toString());
114 maLayoutName
= aBuf
.makeStringAndClear();
116 Size
aPageSize(GetSize());
118 if (aPageSize
.Width() > aPageSize
.Height())
120 meOrientation
= ORIENTATION_LANDSCAPE
;
124 meOrientation
= ORIENTATION_PORTRAIT
;
128 /*************************************************************************
132 \************************************************************************/
138 EndListenOutlineText();
146 bool operator()( SdrObject
* p1
, SdrObject
* p2
)
148 return p1
->GetOrdNum() < p2
->GetOrdNum();
152 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
153 SdrObject
* SdPage::GetPresObj(PresObjKind eObjKind
, int nIndex
, bool bFuzzySearch
/* = false */ )
155 // first sort all matching shapes with z-order
156 std::vector
< SdrObject
* > aMatches
;
159 while( (pObj
= maPresentationShapeList
.getNextShape(pObj
)) != 0 )
161 SdAnimationInfo
* pInfo
= SdDrawDocument::GetShapeUserData(*pObj
);
165 if( pInfo
->mePresObjKind
== eObjKind
)
169 else if( bFuzzySearch
&& (eObjKind
== PRESOBJ_OUTLINE
) )
171 switch( pInfo
->mePresObjKind
)
173 case PRESOBJ_GRAPHIC
:
176 case PRESOBJ_ORGCHART
:
189 aMatches
.push_back( pObj
);
194 if( aMatches
.size() > 1 )
196 OrdNumSorter aSortHelper
;
197 std::sort( aMatches
.begin(), aMatches
.end(), aSortHelper
);
203 if( (nIndex
>= 0) && ( aMatches
.size() > static_cast<unsigned int>(nIndex
)) )
204 return aMatches
[nIndex
];
209 /** create background properties */
210 void SdPage::EnsureMasterPageDefaultBackground()
214 // no hard attributes on MasterPage attributes
215 getSdrPageProperties().ClearItem();
216 SfxStyleSheet
* pSheetForPresObj
= GetStyleSheetForMasterPageBackground();
220 // set StyleSheet for background fill attributes
221 getSdrPageProperties().SetStyleSheet(pSheetForPresObj
);
225 // no style found, assert and set at least XFILL_NONE
226 OSL_FAIL("No Style for MasterPageBackground fill found (!)");
227 getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE
));
232 /** creates a presentation object with the given PresObjKind on this page. A user call will be set
234 SdrObject
* SdPage::CreatePresObj(PresObjKind eObjKind
, sal_Bool bVertical
, const Rectangle
& rRect
, sal_Bool
/* bInsert */ )
236 ::svl::IUndoManager
* pUndoManager
= pModel
? static_cast<SdDrawDocument
*>(pModel
)->GetUndoManager() : 0;
237 const bool bUndo
= pUndoManager
&& pUndoManager
->IsInListAction() && IsInserted();
239 SdrObject
* pSdrObj
= NULL
;
241 bool bForceText
= false; // forces the shape text to be set even if its empty
242 bool bEmptyPresObj
= true;
248 pSdrObj
= new SdrRectObj(OBJ_TITLETEXT
);
252 pSdrObj
->SetNotVisibleAsMaster(sal_True
);
257 case PRESOBJ_OUTLINE
:
259 pSdrObj
= new SdrRectObj(OBJ_OUTLINETEXT
);
263 pSdrObj
->SetNotVisibleAsMaster(sal_True
);
270 pSdrObj
= new SdrRectObj(OBJ_TEXT
);
274 pSdrObj
->SetNotVisibleAsMaster(sal_True
);
281 pSdrObj
= new SdrRectObj(OBJ_TEXT
);
285 case PRESOBJ_GRAPHIC
:
287 BitmapEx
aBmpEx( SdResId( BMP_PRESOBJ_GRAPHIC
) );
288 Graphic
aGraphic( aBmpEx
);
289 OutputDevice
&aOutDev
= *Application::GetDefaultDevice();
292 aOutDev
.SetMapMode( aGraphic
.GetPrefMapMode() );
293 Size aSizePix
= aOutDev
.LogicToPixel( aGraphic
.GetPrefSize() );
294 aOutDev
.SetMapMode(MAP_100TH_MM
);
296 Size aSize
= aOutDev
.PixelToLogic(aSizePix
);
298 Rectangle
aRect (aPnt
, aSize
);
299 pSdrObj
= new SdrGrafObj(aGraphic
, aRect
);
307 pSdrObj
= new SdrOle2Obj();
308 BitmapEx
aBmpEx( SdResId( BMP_PRESOBJ_OBJECT
) );
309 Graphic
aGraphic( aBmpEx
);
310 ( (SdrOle2Obj
*) pSdrObj
)->SetGraphic(&aGraphic
);
316 pSdrObj
= new SdrOle2Obj();
317 ( (SdrOle2Obj
*) pSdrObj
)->SetProgName( OUString( "StarChart" ) );
318 BitmapEx
aBmpEx( SdResId( BMP_PRESOBJ_CHART
) );
319 Graphic
aGraphic( aBmpEx
);
320 ( (SdrOle2Obj
*) pSdrObj
)->SetGraphic(&aGraphic
);
324 case PRESOBJ_ORGCHART
:
326 pSdrObj
= new SdrOle2Obj();
327 ( (SdrOle2Obj
*) pSdrObj
)->SetProgName( OUString( "StarOrg" ) );
328 BitmapEx
aBmpEx( SdResId( BMP_PRESOBJ_ORGCHART
) );
329 Graphic
aGraphic( aBmpEx
);
330 ( (SdrOle2Obj
*) pSdrObj
)->SetGraphic(&aGraphic
);
337 pSdrObj
= new SdrOle2Obj();
338 ( (SdrOle2Obj
*) pSdrObj
)->SetProgName( OUString( "StarCalc" ) );
339 BitmapEx
aBmpEx( SdResId( BMP_PRESOBJ_TABLE
) );
340 Graphic
aGraphic( aBmpEx
);
341 ( (SdrOle2Obj
*) pSdrObj
)->SetGraphic(&aGraphic
);
345 case PRESOBJ_HANDOUT
:
347 // Save the first standard page at SdrPageObj
348 // #i105146# We want no content to be displayed for PK_HANDOUT,
349 // so just never set a page as content
350 pSdrObj
= new SdrPageObj(0);
356 // Save note pages at SdrPageObj
357 sal_uInt16
nDestPageNum(GetPageNum());
361 // decrement only when != 0, else we get a 0xffff
365 if(nDestPageNum
< pModel
->GetPageCount())
367 pSdrObj
= new SdrPageObj(pModel
->GetPage(nDestPageNum
));
371 pSdrObj
= new SdrPageObj();
374 pSdrObj
->SetResizeProtect(sal_True
);
380 case PRESOBJ_DATETIME
:
381 case PRESOBJ_SLIDENUMBER
:
383 pSdrObj
= new SdrRectObj(OBJ_TEXT
);
384 bEmptyPresObj
= false;
394 pSdrObj
->SetEmptyPresObj(bEmptyPresObj
);
395 pSdrObj
->SetLogicRect(rRect
);
397 InsertObject(pSdrObj
);
399 if ( pSdrObj
->ISA(SdrTextObj
) )
401 // Tell the object EARLY that it is vertical to have the
402 // defaults for AutoGrowWidth/Height reversed
404 ((SdrTextObj
*)pSdrObj
)->SetVerticalWriting(sal_True
);
406 SfxItemSet
aTempAttr( ((SdDrawDocument
*) pModel
)->GetPool() );
408 aTempAttr
.Put( SdrTextMinFrameWidthItem( rRect
.GetSize().Width() ) );
410 aTempAttr
.Put( SdrTextMinFrameHeightItem( rRect
.GetSize().Height() ) );
414 // The size of presentation objects on the master page have to
415 // be freely selectable by the user.
417 // potential problem: This action was still NOT
418 // adapted for vertical text. This sure needs to be done.
420 aTempAttr
.Put(SdrTextAutoGrowWidthItem(sal_False
));
422 aTempAttr
.Put(SdrTextAutoGrowHeightItem(sal_False
));
425 // check if we need another vertical adjustement than the default
426 SdrTextVertAdjust eV
= SDRTEXTVERTADJUST_TOP
;
428 if( (eObjKind
== PRESOBJ_FOOTER
) && (mePageKind
!= PK_STANDARD
) )
430 eV
= SDRTEXTVERTADJUST_BOTTOM
;
432 else if( (eObjKind
== PRESOBJ_SLIDENUMBER
) && (mePageKind
!= PK_STANDARD
) )
434 eV
= SDRTEXTVERTADJUST_BOTTOM
;
437 if( eV
!= SDRTEXTVERTADJUST_TOP
)
438 aTempAttr
.Put(SdrTextVertAdjustItem(eV
));
440 pSdrObj
->SetMergedItemSet(aTempAttr
);
442 pSdrObj
->SetLogicRect(rRect
);
445 String aString
= GetPresObjText(eObjKind
);
446 if( (aString
.Len() || bForceText
) && pSdrObj
->ISA(SdrTextObj
) )
448 SdrOutliner
* pOutliner
= ( (SdDrawDocument
*) GetModel() )->GetInternalOutliner();
450 sal_uInt16 nOutlMode
= pOutliner
->GetMode();
451 pOutliner
->Init( OUTLINERMODE_TEXTOBJECT
);
452 pOutliner
->SetStyleSheet( 0, NULL
);
453 pOutliner
->SetVertical( bVertical
);
455 SetObjText( (SdrTextObj
*) pSdrObj
, (SdrOutliner
*)pOutliner
, eObjKind
, aString
);
457 pOutliner
->Init( nOutlMode
);
458 pOutliner
->SetStyleSheet( 0, NULL
);
461 if( (eObjKind
== PRESOBJ_HEADER
) || (eObjKind
== PRESOBJ_FOOTER
) || (eObjKind
== PRESOBJ_SLIDENUMBER
) || (eObjKind
== PRESOBJ_DATETIME
) )
463 SfxItemSet
aTempAttr( ((SdDrawDocument
*) pModel
)->GetPool() );
464 aTempAttr
.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT
) );
465 aTempAttr
.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL
) );
466 aTempAttr
.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK
) );
468 SvxAdjust eH
= SVX_ADJUST_LEFT
;
470 if( (eObjKind
== PRESOBJ_DATETIME
) && (mePageKind
!= PK_STANDARD
) )
472 eH
= SVX_ADJUST_RIGHT
;
474 else if( (eObjKind
== PRESOBJ_FOOTER
) && (mePageKind
== PK_STANDARD
) )
476 eH
= SVX_ADJUST_CENTER
;
478 else if( eObjKind
== PRESOBJ_SLIDENUMBER
)
480 eH
= SVX_ADJUST_RIGHT
;
483 if( eH
!= SVX_ADJUST_LEFT
)
484 aTempAttr
.Put(SvxAdjustItem(eH
, EE_PARA_JUST
));
486 pSdrObj
->SetMergedItemSet(aTempAttr
);
491 SdrLayerAdmin
& rLayerAdmin
= pModel
->GetLayerAdmin();
493 // background objects of the master page
494 pSdrObj
->SetLayer( rLayerAdmin
.
495 GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), sal_False
) );
498 // Subscribe object at the style sheet
499 // Set style only when one was found (as in 5.2)
500 if( mePageKind
!= PK_HANDOUT
)
502 SfxStyleSheet
* pSheetForPresObj
= GetStyleSheetForPresObj(eObjKind
);
504 pSdrObj
->SetStyleSheet(pSheetForPresObj
, sal_False
);
507 if (eObjKind
== PRESOBJ_OUTLINE
)
509 for (sal_uInt16 nLevel
= 1; nLevel
< 10; nLevel
++)
511 String
aName(maLayoutName
);
512 aName
+= sal_Unicode( ' ' );
513 aName
+= OUString::number( nLevel
);
514 SfxStyleSheet
* pSheet
= (SfxStyleSheet
*)pModel
->GetStyleSheetPool()->Find(aName
, SD_STYLE_FAMILY_MASTERPAGE
);
515 DBG_ASSERT(pSheet
, "StyleSheet for outline object not found");
517 pSdrObj
->StartListening(*pSheet
);
521 if ( eObjKind
== PRESOBJ_OBJECT
||
522 eObjKind
== PRESOBJ_CHART
||
523 eObjKind
== PRESOBJ_ORGCHART
||
524 eObjKind
== PRESOBJ_CALC
||
525 eObjKind
== PRESOBJ_GRAPHIC
)
527 SfxItemSet
aSet( ((SdDrawDocument
*) pModel
)->GetPool() );
528 aSet
.Put( SdrTextContourFrameItem( sal_True
) );
529 aSet
.Put( SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
) );
531 pSdrObj
->SetMergedItemSet(aSet
);
536 pUndoManager
->AddUndoAction(pModel
->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj
));
541 pUndoManager
->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj
) );
542 pUndoManager
->AddUndoAction( new UndoObjectUserCall(*pSdrObj
) );
545 InsertPresObj(pSdrObj
, eObjKind
);
546 pSdrObj
->SetUserCall(this);
548 pSdrObj
->RecalcBoundRect();
554 /*************************************************************************
556 |* Creates presentation objects on the master page.
557 |* All presentation objects get a UserCall to the page.
559 \************************************************************************/
561 SfxStyleSheet
* SdPage::GetStyleSheetForMasterPageBackground() const
563 String
aName(GetLayoutName());
564 String
aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR
));
565 sal_uInt16 nPos
= aName
.Search(aSep
);
567 if (nPos
!= STRING_NOTFOUND
)
569 nPos
= nPos
+ aSep
.Len();
573 aName
+= String(SdResId(STR_LAYOUT_BACKGROUND
));
575 SfxStyleSheetBasePool
* pStShPool
= pModel
->GetStyleSheetPool();
576 SfxStyleSheetBase
* pResult
= pStShPool
->Find(aName
, SD_STYLE_FAMILY_MASTERPAGE
);
577 return (SfxStyleSheet
*)pResult
;
580 SfxStyleSheet
* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind
) const
582 String
aName(GetLayoutName());
583 String
aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR
));
584 sal_uInt16 nPos
= aName
.Search(aSep
);
585 if (nPos
!= STRING_NOTFOUND
)
587 nPos
= nPos
+ aSep
.Len();
593 case PRESOBJ_OUTLINE
:
595 aName
= GetLayoutName();
596 aName
+= sal_Unicode( ' ' );
597 aName
+= OUString::number( 1 );
602 aName
+= String(SdResId(STR_LAYOUT_TITLE
));
606 aName
+= String(SdResId(STR_LAYOUT_NOTES
));
610 aName
+= String(SdResId(STR_LAYOUT_SUBTITLE
));
615 case PRESOBJ_DATETIME
:
616 case PRESOBJ_SLIDENUMBER
:
617 aName
+= String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS
));
624 SfxStyleSheetBasePool
* pStShPool
= pModel
->GetStyleSheetPool();
625 SfxStyleSheetBase
* pResult
= pStShPool
->Find(aName
, SD_STYLE_FAMILY_MASTERPAGE
);
626 return (SfxStyleSheet
*)pResult
;
629 /** returns the presentation style with the given helpid from this masterpage or this
631 SdStyleSheet
* SdPage::getPresentationStyle( sal_uInt32 nHelpId
) const
633 String
aStyleName( pPage
->GetLayoutName() );
634 const String
aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR
));
635 aStyleName
.Erase(aStyleName
.Search(aSep
) + aSep
.Len());
640 case HID_PSEUDOSHEET_TITLE
: nNameId
= STR_LAYOUT_TITLE
; break;
641 case HID_PSEUDOSHEET_SUBTITLE
: nNameId
= STR_LAYOUT_SUBTITLE
; break;
642 case HID_PSEUDOSHEET_OUTLINE1
:
643 case HID_PSEUDOSHEET_OUTLINE2
:
644 case HID_PSEUDOSHEET_OUTLINE3
:
645 case HID_PSEUDOSHEET_OUTLINE4
:
646 case HID_PSEUDOSHEET_OUTLINE5
:
647 case HID_PSEUDOSHEET_OUTLINE6
:
648 case HID_PSEUDOSHEET_OUTLINE7
:
649 case HID_PSEUDOSHEET_OUTLINE8
:
650 case HID_PSEUDOSHEET_OUTLINE9
: nNameId
= STR_LAYOUT_OUTLINE
; break;
651 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS
: nNameId
= STR_LAYOUT_BACKGROUNDOBJECTS
; break;
652 case HID_PSEUDOSHEET_BACKGROUND
: nNameId
= STR_LAYOUT_BACKGROUND
; break;
653 case HID_PSEUDOSHEET_NOTES
: nNameId
= STR_LAYOUT_NOTES
; break;
656 OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
659 aStyleName
.Append( String( SdResId( nNameId
) ) );
660 if( nNameId
== STR_LAYOUT_OUTLINE
)
662 aStyleName
.Append( sal_Unicode( ' ' ));
663 aStyleName
.Append( OUString::number( sal_Int32( nHelpId
- HID_PSEUDOSHEET_OUTLINE
)));
666 SfxStyleSheetBasePool
* pStShPool
= pModel
->GetStyleSheetPool();
667 SfxStyleSheetBase
* pResult
= pStShPool
->Find(aStyleName
, SD_STYLE_FAMILY_MASTERPAGE
);
668 return dynamic_cast<SdStyleSheet
*>(pResult
);
671 /*************************************************************************
673 |* The presentation object rObj has changed and is no longer referenzed by the
674 |* presentation object of the master page.
675 |* The UserCall is deleted.
677 \************************************************************************/
679 void SdPage::Changed(const SdrObject
& rObj
, SdrUserCallType eType
, const Rectangle
& )
681 if (!maLockAutoLayoutArrangement
.isLocked())
685 case SDRUSERCALL_MOVEONLY
:
686 case SDRUSERCALL_RESIZE
:
688 if( pModel
->isLocked() )
691 SdrObject
* pObj
= (SdrObject
*) &rObj
;
697 if( pObj
->GetUserCall() )
699 ::svl::IUndoManager
* pUndoManager
= pModel
? static_cast<SdDrawDocument
*>(pModel
)->GetUndoManager() : 0;
700 const bool bUndo
= pUndoManager
&& pUndoManager
->IsInListAction() && IsInserted();
703 pUndoManager
->AddUndoAction( new UndoObjectUserCall(*pObj
) );
705 // Objekt was resized by user and does not listen to its slide anymore
706 pObj
->SetUserCall(0);
711 // Object of the master page changed, therefore adjust
712 // object on all pages
713 sal_uInt16 nPageCount
= ((SdDrawDocument
*) pModel
)->GetSdPageCount(mePageKind
);
715 for (sal_uInt16 i
= 0; i
< nPageCount
; i
++)
717 SdPage
* pLoopPage
= ((SdDrawDocument
*) pModel
)->GetSdPage(i
, mePageKind
);
719 if (pLoopPage
&& this == &(pLoopPage
->TRG_GetMasterPage()))
721 // Page listens to this master page, therefore
723 pLoopPage
->SetAutoLayout(pLoopPage
->GetAutoLayout());
731 case SDRUSERCALL_DELETE
:
732 case SDRUSERCALL_REMOVED
:
739 /*************************************************************************
741 |* Creates on a master page: background, title- and layout area
743 \************************************************************************/
745 void SdPage::CreateTitleAndLayout(sal_Bool bInit
, sal_Bool bCreate
)
747 ::svl::IUndoManager
* pUndoManager
= pModel
? static_cast<SdDrawDocument
*>(pModel
)->GetUndoManager() : 0;
748 const bool bUndo
= pUndoManager
&& pUndoManager
->IsInListAction() && IsInserted();
750 SdPage
* pMasterPage
= this;
754 pMasterPage
= (SdPage
*)(&(TRG_GetMasterPage()));
762 /**************************************************************************
763 * create background, title- and layout area
764 **************************************************************************/
765 if( mePageKind
== PK_STANDARD
)
767 pMasterPage
->EnsureMasterPageDefaultBackground();
770 if( ( (SdDrawDocument
*) GetModel() )->GetDocumentType() == DOCUMENT_TYPE_IMPRESS
)
772 if( mePageKind
== PK_HANDOUT
&& bInit
)
776 // delete all available handout presentation objects
777 SdrObject
*pObj
=NULL
;
778 while( (pObj
= pMasterPage
->GetPresObj(PRESOBJ_HANDOUT
)) != 0 )
780 pMasterPage
->RemoveObject(pObj
->GetOrdNum());
784 pUndoManager
->AddUndoAction(pModel
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj
));
788 SdrObject::Free( pObj
);
792 std::vector
< Rectangle
> aAreas
;
793 CalculateHandoutAreas( *static_cast< SdDrawDocument
* >(GetModel() ), pMasterPage
->GetAutoLayout(), false, aAreas
);
795 const bool bSkip
= pMasterPage
->GetAutoLayout() == AUTOLAYOUT_HANDOUT3
;
796 std::vector
< Rectangle
>::iterator
iter( aAreas
.begin() );
798 while( iter
!= aAreas
.end() )
800 SdrPageObj
* pPageObj
= static_cast<SdrPageObj
*>(pMasterPage
->CreatePresObj(PRESOBJ_HANDOUT
, sal_False
, (*iter
++), sal_True
) );
801 // #i105146# We want no content to be displayed for PK_HANDOUT,
802 // so just never set a page as content
803 pPageObj
->SetReferencedPage(0L);
805 if( bSkip
&& iter
!= aAreas
.end() )
810 if( mePageKind
!= PK_HANDOUT
)
812 SdrObject
* pMasterTitle
= pMasterPage
->GetPresObj( PRESOBJ_TITLE
);
813 if( pMasterTitle
== NULL
)
814 pMasterPage
->CreateDefaultPresObj(PRESOBJ_TITLE
, true);
816 SdrObject
* pMasterOutline
= pMasterPage
->GetPresObj( mePageKind
==PK_NOTES
? PRESOBJ_NOTES
: PRESOBJ_OUTLINE
);
817 if( pMasterOutline
== NULL
)
818 pMasterPage
->CreateDefaultPresObj( mePageKind
== PK_STANDARD
? PRESOBJ_OUTLINE
: PRESOBJ_NOTES
, true );
821 // create header&footer objects
825 if( mePageKind
!= PK_STANDARD
)
827 SdrObject
* pHeader
= pMasterPage
->GetPresObj( PRESOBJ_HEADER
);
828 if( pHeader
== NULL
)
829 pMasterPage
->CreateDefaultPresObj( PRESOBJ_HEADER
, true );
832 SdrObject
* pDate
= pMasterPage
->GetPresObj( PRESOBJ_DATETIME
);
834 pMasterPage
->CreateDefaultPresObj( PRESOBJ_DATETIME
, true );
836 SdrObject
* pFooter
= pMasterPage
->GetPresObj( PRESOBJ_FOOTER
);
837 if( pFooter
== NULL
)
838 pMasterPage
->CreateDefaultPresObj( PRESOBJ_FOOTER
, true );
840 SdrObject
* pNumber
= pMasterPage
->GetPresObj( PRESOBJ_SLIDENUMBER
);
841 if( pNumber
== NULL
)
842 pMasterPage
->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER
, true );
847 SdrObject
* SdPage::CreateDefaultPresObj(PresObjKind eObjKind
, bool bInsert
)
849 if( eObjKind
== PRESOBJ_TITLE
)
851 Rectangle
aTitleRect( GetTitleRect() );
852 return CreatePresObj(PRESOBJ_TITLE
, sal_False
, aTitleRect
, bInsert
);
854 else if( eObjKind
== PRESOBJ_OUTLINE
)
856 Rectangle
aLayoutRect( GetLayoutRect() );
857 return CreatePresObj( PRESOBJ_OUTLINE
, sal_False
, aLayoutRect
, bInsert
);
859 else if( eObjKind
== PRESOBJ_NOTES
)
861 Rectangle
aLayoutRect( GetLayoutRect() );
862 return CreatePresObj( PRESOBJ_NOTES
, sal_False
, aLayoutRect
, bInsert
);
864 else if( (eObjKind
== PRESOBJ_FOOTER
) || (eObjKind
== PRESOBJ_DATETIME
) || (eObjKind
== PRESOBJ_SLIDENUMBER
) || (eObjKind
== PRESOBJ_HEADER
) )
866 // create footer objects for standard master page
867 if( mePageKind
== PK_STANDARD
)
869 const long nLftBorder
= GetLftBorder();
870 const long nUppBorder
= GetUppBorder();
872 Size
aPageSize ( GetSize() );
873 aPageSize
.Width() -= nLftBorder
+ GetRgtBorder();
874 aPageSize
.Height() -= nUppBorder
+ GetLwrBorder();
876 const int Y
= long(nUppBorder
+ aPageSize
.Height() * 0.911);
877 const int W1
= long(aPageSize
.Width() * 0.233);
878 const int W2
= long(aPageSize
.Width() * 0.317);
879 const int H
= long(aPageSize
.Height() * 0.069);
881 if( eObjKind
== PRESOBJ_DATETIME
)
883 Point
aPos( long(nLftBorder
+(aPageSize
.Width()*0.05)), Y
);
885 Rectangle
aRect( aPos
, aSize
);
886 return CreatePresObj( PRESOBJ_DATETIME
, sal_False
, aRect
, bInsert
);
888 else if( eObjKind
== PRESOBJ_FOOTER
)
890 Point
aPos( long(nLftBorder
+ aPageSize
.Width() * 0.342), Y
);
892 Rectangle
aRect( aPos
, aSize
);
893 return CreatePresObj( PRESOBJ_FOOTER
, sal_False
, aRect
, bInsert
);
895 else if( eObjKind
== PRESOBJ_SLIDENUMBER
)
897 Point
aPos( long(nLftBorder
+(aPageSize
.Width()*0.717)), Y
);
899 Rectangle
aRect( aPos
, aSize
);
900 return CreatePresObj( PRESOBJ_SLIDENUMBER
, sal_False
, aRect
, bInsert
);
904 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" );
910 // create header&footer objects for handout and notes master
911 Size
aPageSize ( GetSize() );
912 aPageSize
.Width() -= GetLftBorder() + GetRgtBorder();
913 aPageSize
.Height() -= GetUppBorder() + GetLwrBorder();
916 const int NOTES_HEADER_FOOTER_WIDTH
= long(aPageSize
.Width() * 0.434);
917 const int NOTES_HEADER_FOOTER_HEIGHT
= long(aPageSize
.Height() * 0.05);
919 Size
aSize( NOTES_HEADER_FOOTER_WIDTH
, NOTES_HEADER_FOOTER_HEIGHT
);
921 const int X1
= GetLftBorder();
922 const int X2
= GetLftBorder() + long(aPageSize
.Width() - NOTES_HEADER_FOOTER_WIDTH
);
923 const int Y1
= GetUppBorder();
924 const int Y2
= GetUppBorder() + long(aPageSize
.Height() - NOTES_HEADER_FOOTER_HEIGHT
);
926 if( eObjKind
== PRESOBJ_HEADER
)
928 Point
aPos( X1
, Y1
);
929 Rectangle
aRect( aPos
, aSize
);
930 return CreatePresObj( PRESOBJ_HEADER
, sal_False
, aRect
, bInsert
);
932 else if( eObjKind
== PRESOBJ_DATETIME
)
934 Point
aPos( X2
, Y1
);
935 Rectangle
aRect( aPos
, aSize
);
936 return CreatePresObj( PRESOBJ_DATETIME
, sal_False
, aRect
, bInsert
);
938 else if( eObjKind
== PRESOBJ_FOOTER
)
940 Point
aPos( X1
, Y2
);
941 Rectangle
aRect( aPos
, aSize
);
942 return CreatePresObj( PRESOBJ_FOOTER
, sal_False
, aRect
, bInsert
);
944 else if( eObjKind
== PRESOBJ_SLIDENUMBER
)
946 Point
aPos( X2
, Y2
);
947 Rectangle
aRect( aPos
, aSize
);
948 return CreatePresObj( PRESOBJ_SLIDENUMBER
, sal_False
, aRect
, bInsert
);
951 OSL_FAIL("SdPage::CreateDefaultPresObj() - this should not happen!");
957 OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
962 /*************************************************************************
966 \************************************************************************/
968 Rectangle
SdPage::GetTitleRect() const
970 Rectangle aTitleRect
;
972 if (mePageKind
!= PK_HANDOUT
)
974 /******************************************************************
975 * standard- or note page: title area
976 ******************************************************************/
977 Point
aTitlePos ( GetLftBorder(), GetUppBorder() );
978 Size
aTitleSize ( GetSize() );
979 aTitleSize
.Width() -= GetLftBorder() + GetRgtBorder();
980 aTitleSize
.Height() -= GetUppBorder() + GetLwrBorder();
982 if (mePageKind
== PK_STANDARD
)
984 aTitlePos
.X() += long( aTitleSize
.Width() * 0.05 );
985 aTitlePos
.Y() += long( aTitleSize
.Height() * 0.0399 );
986 aTitleSize
.Width() = long( aTitleSize
.Width() * 0.9 );
987 aTitleSize
.Height() = long( aTitleSize
.Height() * 0.167 );
989 else if (mePageKind
== PK_NOTES
)
991 Point aPos
= aTitlePos
;
992 aPos
.Y() += long( aTitleSize
.Height() * 0.076 );
995 aTitleSize
.Height() = (long) (aTitleSize
.Height() * 0.375);
997 Size aPartArea
= aTitleSize
;
999 sal_uInt16
nDestPageNum(GetPageNum());
1000 SdrPage
* pRefPage
= 0L;
1004 // only decrement if != 0, else we get 0xffff
1008 if(nDestPageNum
< pModel
->GetPageCount())
1010 pRefPage
= pModel
->GetPage(nDestPageNum
);
1015 // scale actually page size into handout rectangle
1016 double fH
= (double) aPartArea
.Width() / pRefPage
->GetWdt();
1017 double fV
= (double) aPartArea
.Height() / pRefPage
->GetHgt();
1021 aSize
.Width() = (long) (fH
* pRefPage
->GetWdt());
1022 aSize
.Height() = (long) (fH
* pRefPage
->GetHgt());
1024 aPos
.X() += (aPartArea
.Width() - aSize
.Width()) / 2;
1025 aPos
.Y() += (aPartArea
.Height()- aSize
.Height())/ 2;
1032 aTitleRect
.SetPos(aTitlePos
);
1033 aTitleRect
.SetSize(aTitleSize
);
1040 /*************************************************************************
1042 |* return outline area
1044 \************************************************************************/
1046 Rectangle
SdPage::GetLayoutRect() const
1048 Rectangle aLayoutRect
;
1050 if (mePageKind
!= PK_HANDOUT
)
1052 Point
aLayoutPos ( GetLftBorder(), GetUppBorder() );
1053 Size
aLayoutSize ( GetSize() );
1054 aLayoutSize
.Width() -= GetLftBorder() + GetRgtBorder();
1055 aLayoutSize
.Height() -= GetUppBorder() + GetLwrBorder();
1057 if (mePageKind
== PK_STANDARD
)
1059 aLayoutPos
.X() += long( aLayoutSize
.Width() * 0.05 );
1060 aLayoutPos
.Y() += long( aLayoutSize
.Height() * 0.234 );
1061 aLayoutSize
.Width() = long( aLayoutSize
.Width() * 0.9 );
1062 aLayoutSize
.Height() = long( aLayoutSize
.Height() * 0.58 );
1063 aLayoutRect
.SetPos(aLayoutPos
);
1064 aLayoutRect
.SetSize(aLayoutSize
);
1066 else if (mePageKind
== PK_NOTES
)
1068 aLayoutPos
.X() += long( aLayoutSize
.Width() * 0.1 );
1069 aLayoutPos
.Y() += long( aLayoutSize
.Height() * 0.475 );
1070 aLayoutSize
.Width() = long( aLayoutSize
.Width() * 0.8 );
1071 aLayoutSize
.Height() = long( aLayoutSize
.Height() * 0.45 );
1072 aLayoutRect
.SetPos(aLayoutPos
);
1073 aLayoutRect
.SetSize(aLayoutSize
);
1081 /**************************************************************************
1083 |* assign a AutoLayout
1085 \*************************************************************************/
1087 const int MAX_PRESOBJS
= 7; // maximum number of presentation objects per layout
1088 const int VERTICAL
= 0x8000;
1090 struct LayoutDescriptor
1093 PresObjKind meKind
[MAX_PRESOBJS
];
1094 bool mbVertical
[MAX_PRESOBJS
];
1096 LayoutDescriptor( int nLayout
, int k0
= 0, int k1
= 0, int k2
= 0, int k3
= 0, int k4
= 0, int k5
= 0, int k6
= 0 );
1099 LayoutDescriptor::LayoutDescriptor( int nLayout
, int k0
, int k1
, int k2
, int k3
, int k4
, int k5
, int k6
)
1100 : mnLayout( nLayout
)
1102 meKind
[0] = static_cast<PresObjKind
>(k0
& (~VERTICAL
)); mbVertical
[0] = (k0
& VERTICAL
) == VERTICAL
;
1103 meKind
[1] = static_cast<PresObjKind
>(k1
& (~VERTICAL
)); mbVertical
[1] = (k1
& VERTICAL
) == VERTICAL
;
1104 meKind
[2] = static_cast<PresObjKind
>(k2
& (~VERTICAL
)); mbVertical
[2] = (k2
& VERTICAL
) == VERTICAL
;
1105 meKind
[3] = static_cast<PresObjKind
>(k3
& (~VERTICAL
)); mbVertical
[3] = (k3
& VERTICAL
) == VERTICAL
;
1106 meKind
[4] = static_cast<PresObjKind
>(k4
& (~VERTICAL
)); mbVertical
[4] = (k4
& VERTICAL
) == VERTICAL
;
1107 meKind
[5] = static_cast<PresObjKind
>(k5
& (~VERTICAL
)); mbVertical
[5] = (k5
& VERTICAL
) == VERTICAL
;
1108 meKind
[6] = static_cast<PresObjKind
>(k6
& (~VERTICAL
)); mbVertical
[6] = (k6
& VERTICAL
) == VERTICAL
;
1111 static const LayoutDescriptor
& GetLayoutDescriptor( AutoLayout eLayout
)
1113 static LayoutDescriptor aLayouts
[AUTOLAYOUT__END
-AUTOLAYOUT__START
] =
1115 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_TEXT
), // AUTOLAYOUT_TITLE
1116 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_ENUM
1117 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_CHART
1118 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_2TEXT
1119 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TEXTCHART
1120 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_ORG
1121 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TEXTCLbIP
1122 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_CHARTTEXT
1123 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TAB
1124 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_CLIPTEXT
1125 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TEXTOBJ
1126 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_OBJECT
), // AUTOLAYOUT_OBJ
1127 LayoutDescriptor( 2, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TEXT2OBJ
1128 LayoutDescriptor( 1, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TEXTOBJ
1129 LayoutDescriptor( 4, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_OBJOVERTEXT
1130 LayoutDescriptor( 3, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_2OBJTEXT
1131 LayoutDescriptor( 5, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_2OBJOVERTEXT
1132 LayoutDescriptor( 4, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
), // AUTOLAYOUT_TEXTOVEROBJ
1133 LayoutDescriptor( 6, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, // AUTOLAYOUT_4OBJ
1134 PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
),
1135 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_NONE
), // AUTOLAYOUT_ONLY_TITLE
1136 LayoutDescriptor( 0, PRESOBJ_NONE
), // AUTOLAYOUT_NONE
1137 LayoutDescriptor( 0, PRESOBJ_PAGE
, PRESOBJ_NOTES
), // AUTOLAYOUT_NOTES
1138 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT1
1139 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT2
1140 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT3
1141 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT4
1142 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT6
1143 LayoutDescriptor( 7, PRESOBJ_TITLE
|VERTICAL
, PRESOBJ_OUTLINE
|VERTICAL
, PRESOBJ_OUTLINE
),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1144 LayoutDescriptor( 8, PRESOBJ_TITLE
|VERTICAL
, PRESOBJ_OUTLINE
|VERTICAL
), // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1145 LayoutDescriptor( 0, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
|VERTICAL
), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1146 LayoutDescriptor( 9, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
|VERTICAL
, PRESOBJ_OUTLINE
|VERTICAL
), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1147 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT9
1148 LayoutDescriptor( 10, PRESOBJ_TEXT
, PRESOBJ_NONE
), // AUTOLAYOUT_ONLY_TEXT
1149 LayoutDescriptor( 6, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, // AUTOLAYOUT_4CLIPART
1150 PRESOBJ_GRAPHIC
, PRESOBJ_GRAPHIC
),
1151 LayoutDescriptor( 11, PRESOBJ_TITLE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, // AUTOLAYOUT_6CLIPART
1152 PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
, PRESOBJ_OUTLINE
)
1155 if( (eLayout
< AUTOLAYOUT__START
) || (eLayout
>= AUTOLAYOUT__END
) )
1156 eLayout
= AUTOLAYOUT_NONE
;
1158 return aLayouts
[ eLayout
- AUTOLAYOUT__START
];
1161 static void CalcAutoLayoutRectangles( SdPage
& rPage
, int nLayout
, Rectangle
* rRectangle
)
1163 Rectangle aTitleRect
;
1164 Rectangle aLayoutRect
;
1166 if( rPage
.GetPageKind() != PK_HANDOUT
)
1168 SdPage
& rMasterPage
= static_cast<SdPage
&>(rPage
.TRG_GetMasterPage());
1169 SdrObject
* pMasterTitle
= rMasterPage
.GetPresObj( PRESOBJ_TITLE
);
1170 SdrObject
* pMasterOutline
= rMasterPage
.GetPresObj( rPage
.GetPageKind()==PK_NOTES
? PRESOBJ_NOTES
: PRESOBJ_OUTLINE
);
1173 aTitleRect
= pMasterTitle
->GetLogicRect();
1175 if (aTitleRect
.IsEmpty() )
1176 aTitleRect
= rPage
.GetTitleRect();
1178 if( pMasterOutline
)
1179 aLayoutRect
= pMasterOutline
->GetLogicRect();
1181 if (aLayoutRect
.IsEmpty() )
1182 aLayoutRect
= rPage
.GetLayoutRect();
1185 rRectangle
[0] = aTitleRect
;
1188 for( i
= 1; i
< MAX_PRESOBJS
; i
++ )
1189 rRectangle
[i
] = aLayoutRect
;
1191 Point
aTitlePos( aTitleRect
.TopLeft() );
1192 Size
aLayoutSize( aLayoutRect
.GetSize() );
1193 Point
aLayoutPos( aLayoutRect
.TopLeft() );
1197 sal_Bool bRightToLeft
= ( rPage
.GetModel() && static_cast< SdDrawDocument
* >( rPage
.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB
);
1201 case 0: // default layout using only the title and layout area
1202 break; // do nothing
1203 case 1: // title, 2 shapes
1204 case 9: // title, 2 vertical shapes
1205 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1206 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1208 aLayoutPos
.X() = long (aLayoutPos
.X() + aLayoutSize
.Width() * 1.05);
1209 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1211 if( bRightToLeft
&& (nLayout
!= 9) )
1212 ::std::swap( rRectangle
[1], rRectangle
[2] );
1214 case 2: // title, shape, 2 shapes
1215 aTempPnt
= aLayoutPos
;
1216 aTempSize
= aLayoutSize
;
1217 aLayoutSize
.Height() = long (aLayoutSize
.Height() * 0.477);
1218 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1219 aLayoutPos
.X() = long (aLayoutPos
.X() + aLayoutSize
.Width() * 1.05);
1220 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1222 aLayoutPos
.Y() = long (aLayoutPos
.Y() + aLayoutSize
.Height() * 1.095);
1223 rRectangle
[3] = Rectangle (aLayoutPos
, aLayoutSize
);
1225 aLayoutPos
= aTempPnt
;
1226 aLayoutSize
= aTempSize
;
1227 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1228 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1232 ::std::swap( rRectangle
[1].Left(), rRectangle
[2].Left() );
1233 rRectangle
[3].Left() = rRectangle
[2].Left();
1236 case 3: // title, 2 shapes, shape
1237 aTempPnt
= aLayoutPos
;
1238 aTempSize
= aLayoutSize
;
1239 aLayoutSize
.Height() = long (aLayoutSize
.Height() * 0.477);
1240 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1241 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1243 aLayoutPos
.Y() = long (aLayoutPos
.Y() + aLayoutSize
.Height() * 1.095);
1244 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1246 aLayoutPos
= aTempPnt
;
1247 aLayoutSize
= aTempSize
;
1248 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1249 aLayoutPos
.X() = long (aLayoutPos
.X() + aLayoutSize
.Width() * 1.05);
1250 rRectangle
[3] = Rectangle (aLayoutPos
, aLayoutSize
);
1254 ::std::swap( rRectangle
[1].Left(), rRectangle
[2].Left() );
1255 rRectangle
[3].Left() = rRectangle
[2].Left();
1258 case 4: // title, shape above shape
1259 aLayoutSize
.Height() = long (aLayoutSize
.Height() * 0.477);
1260 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1262 aLayoutPos
.Y() = long (aLayoutPos
.Y() + aLayoutSize
.Height() * 1.095);
1263 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1266 case 5: // title, 2 shapes above shape
1267 aLayoutSize
.Height() = long (aLayoutSize
.Height() * 0.477);
1268 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1269 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1271 aTempPnt
= aLayoutPos
;
1272 aLayoutPos
.X() = long (aLayoutPos
.X() + aLayoutSize
.Width() * 1.05);
1273 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1275 aLayoutPos
.X() = aTempPnt
.X();
1276 aLayoutPos
.Y() = long (aLayoutPos
.Y() + aLayoutSize
.Height() * 1.095);
1277 aLayoutSize
.Width() = long (aLayoutSize
.Width() / 0.488);
1278 rRectangle
[3] = Rectangle (aLayoutPos
, aLayoutSize
);
1280 case 6: // title, 4 shapes
1282 sal_uLong nX
= long (aLayoutPos
.X());
1284 aLayoutSize
.Height() = long (aLayoutSize
.Height() * 0.477);
1285 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.488);
1286 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1288 aLayoutPos
.X() = long (nX
+ aLayoutSize
.Width() * 1.05);
1289 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1291 aLayoutPos
.Y() = long (aLayoutPos
.Y() + aLayoutSize
.Height() * 1.095);
1292 rRectangle
[3] = Rectangle (aLayoutPos
, aLayoutSize
);
1294 aLayoutPos
.X() = nX
;
1295 rRectangle
[4] = Rectangle (aLayoutPos
, aLayoutSize
);
1298 case 7: // vertical title, shape above shape
1300 Size
aSize( rRectangle
[0].GetSize().Height(), rRectangle
[1].BottomLeft().Y() - rRectangle
[0].TopLeft().Y() );
1301 rRectangle
[0].SetSize( aSize
);
1302 rRectangle
[0].SetPos( aTitleRect
.TopRight() - Point( aSize
.Width(), 0 ) );
1304 Size
aPageSize ( rPage
.GetSize() );
1305 aPageSize
.Height() -= rPage
.GetUppBorder() + rPage
.GetLwrBorder();
1306 aSize
.Height() = long ( rRectangle
[0].GetSize().Height() * 0.47 );
1307 aSize
.Width() = long( aPageSize
.Width() * 0.7 );
1308 rRectangle
[1].SetPos( aTitleRect
.TopLeft() );
1309 rRectangle
[1].SetSize( aSize
);
1311 aSize
.Height() = rRectangle
[0].GetSize().Height();
1312 Point
aPos( aTitleRect
.TopLeft() );
1313 aPos
.Y() += long ( aSize
.Height() * 0.53 );
1314 rRectangle
[2].SetPos( aPos
);
1315 aSize
.Height() = long ( rRectangle
[0].GetSize().Height() * 0.47 );
1316 rRectangle
[2].SetSize( aSize
);
1319 case 8: // vertical title, shape
1321 Size
aSize( rRectangle
[0].GetSize().Height(), rRectangle
[1].BottomLeft().Y() - rRectangle
[0].TopLeft().Y() );
1322 rRectangle
[0].SetSize( aSize
);
1323 rRectangle
[0].SetPos( aTitleRect
.TopRight() - Point( aSize
.Width(), 0 ) );
1325 Size
aPageSize ( rPage
.GetSize() );
1326 aPageSize
.Height() -= rPage
.GetUppBorder() + rPage
.GetLwrBorder();
1327 aSize
.Height() = rRectangle
[0].GetSize().Height();
1328 aSize
.Width() = long( aPageSize
.Width() * 0.7 );
1329 rRectangle
[1].SetPos( aTitleRect
.TopLeft() );
1330 rRectangle
[1].SetSize( aSize
);
1333 case 10: // onlytext
1335 Size
aSize( rRectangle
[0].GetSize().Width(), rRectangle
[1].BottomLeft().Y() - rRectangle
[0].TopLeft().Y() );
1336 rRectangle
[0].SetSize( aSize
);
1337 rRectangle
[0].SetPos( aTitlePos
);
1340 case 11: // title, 6 shapes
1342 sal_uLong nX
= long (aLayoutPos
.X());
1344 aLayoutSize
.Height() = long (aLayoutSize
.Height() * 0.477);
1345 aLayoutSize
.Width() = long (aLayoutSize
.Width() * 0.322);
1346 rRectangle
[1] = Rectangle (aLayoutPos
, aLayoutSize
);
1348 aLayoutPos
.X() = long (nX
+ aLayoutSize
.Width() * 1.05);
1349 rRectangle
[2] = Rectangle (aLayoutPos
, aLayoutSize
);
1351 aLayoutPos
.X() = long (nX
+ aLayoutSize
.Width() * 2 * 1.05);
1352 rRectangle
[3] = Rectangle (aLayoutPos
, aLayoutSize
);
1354 aLayoutPos
.Y() = long (aLayoutPos
.Y() + aLayoutSize
.Height() * 1.095);
1355 rRectangle
[4] = Rectangle (aLayoutPos
, aLayoutSize
);
1357 aLayoutPos
.X() = long (nX
+ aLayoutSize
.Width() * 1.05);
1358 rRectangle
[5] = Rectangle (aLayoutPos
, aLayoutSize
);
1360 aLayoutPos
.X() = nX
;
1361 rRectangle
[6] = Rectangle (aLayoutPos
, aLayoutSize
);
1370 void findAutoLayoutShapesImpl( SdPage
& rPage
, const LayoutDescriptor
& rDescriptor
, std::vector
< SdrObject
* >& rShapes
, bool bInit
, bool bSwitchLayout
)
1374 // init list of indexes for each presentation shape kind
1375 // this is used to find subsequent shapes with the same presentation shape kind
1376 int PresObjIndex
[PRESOBJ_MAX
];
1377 for( i
= 0; i
< PRESOBJ_MAX
; i
++ ) PresObjIndex
[i
] = 1;
1379 bool bMissing
= false;
1381 // for each entry in the layoutdescriptor, arrange a presentation shape
1382 for (i
= 0; (i
< MAX_PRESOBJS
) && (rDescriptor
.meKind
[i
] != PRESOBJ_NONE
); i
++)
1384 PresObjKind eKind
= rDescriptor
.meKind
[i
];
1385 SdrObject
* pObj
= 0;
1386 while( (pObj
= rPage
.GetPresObj( eKind
, PresObjIndex
[eKind
], true )) != 0 )
1388 PresObjIndex
[eKind
]++; // on next search for eKind, find next shape with same eKind
1390 if( !bSwitchLayout
|| !pObj
->IsEmptyPresObj() )
1401 if( bMissing
&& bInit
)
1403 // for each entry in the layoutdescriptor, look for an alternative shape
1404 for (i
= 0; (i
< MAX_PRESOBJS
) && (rDescriptor
.meKind
[i
] != PRESOBJ_NONE
); i
++)
1409 PresObjKind eKind
= rDescriptor
.meKind
[i
];
1411 SdrObject
* pObj
= 0;
1412 bool bFound
= false;
1414 const int nShapeCount
= rPage
.GetObjCount();
1415 int nShapeIndex
= 0;
1416 while((nShapeIndex
< nShapeCount
) && !bFound
)
1418 pObj
= rPage
.GetObj(nShapeIndex
++);
1420 if( pObj
->IsEmptyPresObj() )
1423 if( pObj
->GetObjInventor() != SdrInventor
)
1426 // do not reuse shapes that are already part of the layout
1427 if( std::find( rShapes
.begin(), rShapes
.end(), pObj
) != rShapes
.end() )
1430 bool bPresStyle
= pObj
->GetStyleSheet() && (pObj
->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE
);
1431 SdrObjKind eSdrObjKind
= static_cast< SdrObjKind
>( pObj
->GetObjIdentifier() );
1436 bFound
= eSdrObjKind
== OBJ_TITLETEXT
;
1439 bFound
= eSdrObjKind
== OBJ_TABLE
;
1442 bFound
= eSdrObjKind
== OBJ_MEDIA
;
1444 case PRESOBJ_OUTLINE
:
1445 bFound
= (eSdrObjKind
== OBJ_OUTLINETEXT
) ||
1446 ((eSdrObjKind
== OBJ_TEXT
) && bPresStyle
) ||
1447 (eSdrObjKind
== OBJ_TABLE
) || (eSdrObjKind
== OBJ_MEDIA
) || (eSdrObjKind
== OBJ_GRAF
) || (eSdrObjKind
== OBJ_OLE2
);
1449 case PRESOBJ_GRAPHIC
:
1450 bFound
= eSdrObjKind
== OBJ_GRAF
;
1452 case PRESOBJ_OBJECT
:
1453 if( eSdrObjKind
== OBJ_OLE2
)
1455 SdrOle2Obj
* pOle2
= dynamic_cast< SdrOle2Obj
* >( pObj
);
1458 if( pOle2
->IsEmpty() )
1460 else if( rPage
.GetModel() )
1462 SdrModel
* pSdrModel
= rPage
.GetModel();
1463 ::comphelper::IEmbeddedHelper
*pPersist
= pSdrModel
->GetPersist();
1466 uno::Reference
< embed::XEmbeddedObject
> xObject
= pPersist
->getEmbeddedObjectContainer().
1467 GetEmbeddedObject( static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() );
1469 // TODO CL->KA: Why is this not working anymore?
1472 SvGlobalName
aClassId( xObject
->getClassID() );
1474 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
1475 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
1476 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
1478 if( aPluginClassId
!= aClassId
&& aAppletClassId
!= aClassId
&& aIFrameClassId
!= aClassId
)
1490 if( eSdrObjKind
== OBJ_OLE2
)
1492 SdrOle2Obj
* pOle2
= dynamic_cast< SdrOle2Obj
* >( pObj
);
1496 ((eKind
== PRESOBJ_CHART
) &&
1497 ( pOle2
->GetProgName().EqualsAscii( "StarChart" ) || pOle2
->IsChart() ) )
1499 ((eKind
== PRESOBJ_CALC
) &&
1500 ( pOle2
->GetProgName().EqualsAscii( "StarCalc" ) || pOle2
->IsCalc() ) ) )
1507 else if( eSdrObjKind
== OBJ_TABLE
)
1513 case PRESOBJ_HANDOUT
:
1514 bFound
= eSdrObjKind
== OBJ_PAGE
;
1518 bFound
= (bPresStyle
&& (eSdrObjKind
== OBJ_TEXT
)) || (eSdrObjKind
== OBJ_OUTLINETEXT
);
1531 void SdPage::SetAutoLayout(AutoLayout eLayout
, sal_Bool bInit
, sal_Bool bCreate
)
1533 sd::ScopeLockGuard
aGuard( maLockAutoLayoutArrangement
);
1535 const bool bSwitchLayout
= eLayout
!= GetAutoLayout();
1537 ::svl::IUndoManager
* pUndoManager
= pModel
? static_cast<SdDrawDocument
*>(pModel
)->GetUndoManager() : 0;
1538 const bool bUndo
= pUndoManager
&& pUndoManager
->IsInListAction() && IsInserted();
1540 meAutoLayout
= eLayout
;
1542 // if needed, creates and initialises the presentation shapes on this slides master page
1543 CreateTitleAndLayout(bInit
, bCreate
);
1545 if((meAutoLayout
== AUTOLAYOUT_NONE
&& maPresentationShapeList
.isEmpty()) || mbMaster
)
1547 // MasterPage or no layout and no presentation shapes available, noting to do
1551 Rectangle aRectangle
[MAX_PRESOBJS
];
1552 const LayoutDescriptor
& aDescriptor
= GetLayoutDescriptor( meAutoLayout
);
1553 CalcAutoLayoutRectangles( *this, aDescriptor
.mnLayout
, aRectangle
);
1555 std::set
< SdrObject
* > aUsedPresentationObjects
;
1558 std::vector
< SdrObject
* > aLayoutShapes(PRESOBJ_MAX
, 0);
1559 findAutoLayoutShapesImpl( *this, aDescriptor
, aLayoutShapes
, bInit
, bSwitchLayout
);
1563 // for each entry in the layoutdescriptor, arrange a presentation shape
1564 for (i
= 0; (i
< MAX_PRESOBJS
) && (aDescriptor
.meKind
[i
] != PRESOBJ_NONE
); i
++)
1566 PresObjKind eKind
= aDescriptor
.meKind
[i
];
1567 SdrObject
* pObj
= InsertAutoLayoutShape( aLayoutShapes
[i
], eKind
, aDescriptor
.mbVertical
[i
], aRectangle
[i
], bInit
);
1569 aUsedPresentationObjects
.insert(pObj
); // remember that we used this empty shape
1572 // now delete all empty presentation objects that are no longer used by the new layout
1575 SdrObject
* pObj
= maPresentationShapeList
.getNextShape(0);
1579 SdrObject
* pNext
= maPresentationShapeList
.getNextShape(pObj
);
1580 if( aUsedPresentationObjects
.count(pObj
) == 0 )
1583 if( pObj
->IsEmptyPresObj() )
1586 pUndoManager
->AddUndoAction(pModel
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj
));
1588 RemoveObject( pObj
->GetOrdNum() );
1591 SdrObject::Free( pObj
);
1593 /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
1600 /*************************************************************************
1604 \************************************************************************/
1606 void SdPage::NbcInsertObject(SdrObject
* pObj
, sal_uLong nPos
, const SdrInsertReason
* pReason
)
1608 FmFormPage::NbcInsertObject(pObj
, nPos
, pReason
);
1610 ((SdDrawDocument
*) pModel
)->InsertObject(pObj
, this);
1612 SdrLayerID nId
= pObj
->GetLayer();
1616 pObj
->NbcSetLayer( 2 ); // wrong layer. corrected to BackgroundObj layer
1621 pObj
->NbcSetLayer( 0 ); // wrong layer. corrected to layout layer
1625 /*************************************************************************
1629 \************************************************************************/
1631 SdrObject
* SdPage::RemoveObject(sal_uLong nObjNum
)
1633 onRemoveObject(GetObj( nObjNum
));
1634 return FmFormPage::RemoveObject(nObjNum
);
1637 /*************************************************************************
1639 |* remove object without broadcast
1641 \************************************************************************/
1643 SdrObject
* SdPage::NbcRemoveObject(sal_uLong nObjNum
)
1645 onRemoveObject(GetObj( nObjNum
));
1646 return FmFormPage::NbcRemoveObject(nObjNum
);
1649 // Also overload ReplaceObject methods to realize when
1650 // objects are removed with this mechanism instead of RemoveObject
1651 SdrObject
* SdPage::NbcReplaceObject(SdrObject
* pNewObj
, sal_uLong nObjNum
)
1653 onRemoveObject(GetObj( nObjNum
));
1654 return FmFormPage::NbcReplaceObject(pNewObj
, nObjNum
);
1657 // Also overload ReplaceObject methods to realize when
1658 // objects are removed with this mechanism instead of RemoveObject
1659 SdrObject
* SdPage::ReplaceObject(SdrObject
* pNewObj
, sal_uLong nObjNum
)
1661 onRemoveObject(GetObj( nObjNum
));
1662 return FmFormPage::ReplaceObject(pNewObj
, nObjNum
);
1665 // -------------------------------------------------------------------------
1667 // called after a shape is removed or replaced from this slide
1669 void SdPage::onRemoveObject( SdrObject
* pObject
)
1673 RemovePresObj(pObject
);
1676 static_cast<SdDrawDocument
*>(pModel
)->RemoveObject(pObject
, this);
1678 removeAnimations( pObject
);
1682 void SdPage::SetSize(const Size
& aSize
)
1684 Size aOldSize
= GetSize();
1686 if (aSize
!= aOldSize
)
1688 FmFormPage::SetSize(aSize
);
1690 if (aOldSize
.Height() == 10 && aOldSize
.Width() == 10)
1692 // this page gets a valid size for the first time. Therefore
1693 // we initialize the orientation.
1694 if (aSize
.Width() > aSize
.Height())
1696 meOrientation
= ORIENTATION_LANDSCAPE
;
1700 meOrientation
= ORIENTATION_PORTRAIT
;
1706 void SdPage::SetBorder(sal_Int32 nLft
, sal_Int32 nUpp
, sal_Int32 nRgt
, sal_Int32 nLwr
)
1708 if (nLft
!= GetLftBorder() || nUpp
!= GetUppBorder() ||
1709 nRgt
!= GetRgtBorder() || nLwr
!= GetLwrBorder() )
1711 FmFormPage::SetBorder(nLft
, nUpp
, nRgt
, nLwr
);
1715 void SdPage::SetLftBorder(sal_Int32 nBorder
)
1717 if (nBorder
!= GetLftBorder() )
1719 FmFormPage::SetLftBorder(nBorder
);
1723 void SdPage::SetRgtBorder(sal_Int32 nBorder
)
1725 if (nBorder
!= GetRgtBorder() )
1727 FmFormPage::SetRgtBorder(nBorder
);
1731 void SdPage::SetUppBorder(sal_Int32 nBorder
)
1733 if (nBorder
!= GetUppBorder() )
1735 FmFormPage::SetUppBorder(nBorder
);
1739 void SdPage::SetLwrBorder(sal_Int32 nBorder
)
1741 if (nBorder
!= GetLwrBorder() )
1743 FmFormPage::SetLwrBorder(nBorder
);
1747 /*************************************************************************
1749 |* Sets BackgroundFullSize and then calls AdjustBackground
1751 \************************************************************************/
1753 void SdPage::SetBackgroundFullSize( sal_Bool bIn
)
1755 if( bIn
!= mbBackgroundFullSize
)
1757 mbBackgroundFullSize
= bIn
;
1761 /*************************************************************************
1763 |* Adjust all objects to new page size.
1765 |* bScaleAllObj: all objects are scaled into the new area within the page
1766 |* margins. We scale the position and size. For presentation objects on the
1767 |* master page, we also scale the font height of the presentation template.
1769 \************************************************************************/
1771 void SdPage::ScaleObjects(const Size
& rNewPageSize
, const Rectangle
& rNewBorderRect
, sal_Bool bScaleAllObj
)
1773 sd::ScopeLockGuard
aGuard( maLockAutoLayoutArrangement
);
1775 mbScaleObjects
= bScaleAllObj
;
1776 SdrObject
* pObj
= NULL
;
1777 Point
aRefPnt(0, 0);
1778 Size
aNewPageSize(rNewPageSize
);
1779 sal_Int32 nLeft
= rNewBorderRect
.Left();
1780 sal_Int32 nRight
= rNewBorderRect
.Right();
1781 sal_Int32 nUpper
= rNewBorderRect
.Top();
1782 sal_Int32 nLower
= rNewBorderRect
.Bottom();
1784 // negative values are fixed values
1785 // -> use up to date values
1786 if (aNewPageSize
.Width() < 0)
1788 aNewPageSize
.Width() = GetWdt();
1790 if (aNewPageSize
.Height() < 0)
1792 aNewPageSize
.Height() = GetHgt();
1796 nLeft
= GetLftBorder();
1800 nRight
= GetRgtBorder();
1804 nUpper
= GetUppBorder();
1808 nLower
= GetLwrBorder();
1811 Point
aBackgroundPos(nLeft
, nUpper
);
1812 Size
aBackgroundSize(aNewPageSize
);
1813 Rectangle
aBorderRect (aBackgroundPos
, aBackgroundSize
);
1817 aBackgroundSize
.Width() -= nLeft
+ nRight
;
1818 aBackgroundSize
.Height() -= nUpper
+ nLower
;
1819 aBorderRect
.SetSize(aBackgroundSize
);
1820 aNewPageSize
= aBackgroundSize
;
1823 long nOldWidth
= GetWdt() - GetLftBorder() - GetRgtBorder();
1824 long nOldHeight
= GetHgt() - GetUppBorder() - GetLwrBorder();
1826 Fraction aFractX
= Fraction(aNewPageSize
.Width(), nOldWidth
);
1827 Fraction aFractY
= Fraction(aNewPageSize
.Height(), nOldHeight
);
1829 sal_uLong nObjCnt
= (mbScaleObjects
? GetObjCount() : 0);
1831 for (sal_uLong nObj
= 0; nObj
< nObjCnt
; nObj
++)
1833 sal_Bool bIsPresObjOnMaster
= sal_False
;
1836 pObj
= GetObj(nObj
);
1838 if (mbMaster
&& IsPresObj(pObj
))
1840 // There is a presentation object on the master page
1841 bIsPresObjOnMaster
= sal_True
;
1846 // remember aTopLeft as original TopLeft
1847 Point
aTopLeft(pObj
->GetCurrentBoundRect().TopLeft());
1849 if (!pObj
->IsEdgeObj())
1851 /**************************************************************
1853 **************************************************************/
1856 // use aTopLeft as original TopLeft
1860 pObj
->Resize(aRefPnt
, aFractX
, aFractY
);
1864 SdrObjKind eObjKind
= (SdrObjKind
) pObj
->GetObjIdentifier();
1866 if (bIsPresObjOnMaster
)
1868 /**********************************************************
1869 * presentation template: adjust test height
1870 **********************************************************/
1871 sal_uInt16 nIndexTitle
= 0;
1872 sal_uInt16 nIndexOutline
= 0;
1873 sal_uInt16 nIndexNotes
= 0;
1875 if (pObj
== GetPresObj(PRESOBJ_TITLE
, nIndexTitle
))
1877 SfxStyleSheet
* pTitleSheet
= GetStyleSheetForPresObj(PRESOBJ_TITLE
);
1881 SfxItemSet
& rSet
= pTitleSheet
->GetItemSet();
1883 SvxFontHeightItem
& rOldHgt
= (SvxFontHeightItem
&) rSet
.Get(EE_CHAR_FONTHEIGHT
);
1884 sal_uLong nFontHeight
= rOldHgt
.GetHeight();
1885 nFontHeight
= long(nFontHeight
* (double) aFractY
);
1886 rSet
.Put(SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT
));
1888 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( EE_CHAR_FONTHEIGHT_CJK
) )
1890 rOldHgt
= (SvxFontHeightItem
&) rSet
.Get(EE_CHAR_FONTHEIGHT_CJK
);
1891 nFontHeight
= rOldHgt
.GetHeight();
1892 nFontHeight
= long(nFontHeight
* (double) aFractY
);
1893 rSet
.Put(SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT_CJK
));
1896 if( SFX_ITEM_AVAILABLE
== rSet
.GetItemState( EE_CHAR_FONTHEIGHT_CTL
) )
1898 rOldHgt
= (SvxFontHeightItem
&) rSet
.Get(EE_CHAR_FONTHEIGHT_CTL
);
1899 nFontHeight
= rOldHgt
.GetHeight();
1900 nFontHeight
= long(nFontHeight
* (double) aFractY
);
1901 rSet
.Put(SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT_CTL
));
1904 pTitleSheet
->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
1907 else if (pObj
== GetPresObj(PRESOBJ_OUTLINE
, nIndexOutline
))
1909 String
aName(GetLayoutName());
1910 aName
+= sal_Unicode( ' ' );
1912 for (sal_uInt16 i
=1; i
<=9; i
++)
1914 String
sLayoutName(aName
);
1915 sLayoutName
+= OUString::number( (sal_Int32
)i
);
1916 SfxStyleSheet
* pOutlineSheet
= (SfxStyleSheet
*)((SdDrawDocument
*) pModel
)->GetStyleSheetPool()->Find(sLayoutName
, SD_STYLE_FAMILY_MASTERPAGE
);
1920 // Calculate new font height
1921 SfxItemSet
aTempSet(pOutlineSheet
->GetItemSet());
1923 SvxFontHeightItem
& rOldHgt
= (SvxFontHeightItem
&) aTempSet
.Get(EE_CHAR_FONTHEIGHT
);
1924 sal_uLong nFontHeight
= rOldHgt
.GetHeight();
1925 nFontHeight
= long(nFontHeight
* (double) aFractY
);
1926 aTempSet
.Put(SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT
));
1928 if( SFX_ITEM_AVAILABLE
== aTempSet
.GetItemState( EE_CHAR_FONTHEIGHT_CJK
) )
1930 rOldHgt
= (SvxFontHeightItem
&) aTempSet
.Get(EE_CHAR_FONTHEIGHT_CJK
);
1931 nFontHeight
= rOldHgt
.GetHeight();
1932 nFontHeight
= long(nFontHeight
* (double) aFractY
);
1933 aTempSet
.Put(SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT_CJK
));
1936 if( SFX_ITEM_AVAILABLE
== aTempSet
.GetItemState( EE_CHAR_FONTHEIGHT_CTL
) )
1938 rOldHgt
= (SvxFontHeightItem
&) aTempSet
.Get(EE_CHAR_FONTHEIGHT_CTL
);
1939 nFontHeight
= rOldHgt
.GetHeight();
1940 nFontHeight
= long(nFontHeight
* (double) aFractY
);
1941 aTempSet
.Put(SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT_CTL
));
1945 ((SdStyleSheet
*) pOutlineSheet
)->AdjustToFontHeight(aTempSet
, sal_False
);
1947 // Special treatment: reset the INVALIDS to
1948 // NULL pointer (otherwise we have INVALID's
1949 // or pointer to the DefaultItems in the
1950 // template; both would suppress the
1951 // attribute inheritance)
1952 aTempSet
.ClearInvalidItems();
1954 // Special treatment: only the valid parts
1955 // of the BulletItems
1956 if (aTempSet
.GetItemState(EE_PARA_BULLET
) == SFX_ITEM_AVAILABLE
)
1958 SvxBulletItem
aOldBulItem((SvxBulletItem
&) pOutlineSheet
->GetItemSet().Get(EE_PARA_BULLET
));
1959 SvxBulletItem
& rNewBulItem
= (SvxBulletItem
&) aTempSet
.Get(EE_PARA_BULLET
);
1960 aOldBulItem
.CopyValidProperties(rNewBulItem
);
1961 aTempSet
.Put(aOldBulItem
);
1964 pOutlineSheet
->GetItemSet().Put(aTempSet
);
1965 pOutlineSheet
->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
1969 else if (pObj
== GetPresObj(PRESOBJ_NOTES
, nIndexNotes
))
1971 SfxStyleSheet
* pNotesSheet
= GetStyleSheetForPresObj(PRESOBJ_NOTES
);
1975 sal_uLong nHeight
= pObj
->GetLogicRect().GetSize().Height();
1976 sal_uLong nFontHeight
= (sal_uLong
) (nHeight
* 0.0741);
1977 SfxItemSet
& rSet
= pNotesSheet
->GetItemSet();
1978 rSet
.Put( SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT
));
1979 rSet
.Put( SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT_CJK
));
1980 rSet
.Put( SvxFontHeightItem(nFontHeight
, 100, EE_CHAR_FONTHEIGHT_CTL
));
1981 pNotesSheet
->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
1985 else if ( eObjKind
!= OBJ_TITLETEXT
&&
1986 eObjKind
!= OBJ_OUTLINETEXT
&&
1987 pObj
->ISA(SdrTextObj
) &&
1988 pObj
->GetOutlinerParaObject() )
1990 /******************************************************
1991 * normal text object: adjust text height
1992 ******************************************************/
1993 sal_uLong nScriptType
= pObj
->GetOutlinerParaObject()->GetTextObject().GetScriptType();
1994 sal_uInt16 nWhich
= EE_CHAR_FONTHEIGHT
;
1995 if ( nScriptType
== SCRIPTTYPE_ASIAN
)
1996 nWhich
= EE_CHAR_FONTHEIGHT_CJK
;
1997 else if ( nScriptType
== SCRIPTTYPE_COMPLEX
)
1998 nWhich
= EE_CHAR_FONTHEIGHT_CTL
;
2000 // use more modern method to scale the text height
2001 sal_uInt32 nFontHeight
= ((SvxFontHeightItem
&)pObj
->GetMergedItem(nWhich
)).GetHeight();
2002 sal_uInt32 nNewFontHeight
= sal_uInt32((double)nFontHeight
* (double)aFractY
);
2004 pObj
->SetMergedItem(SvxFontHeightItem(nNewFontHeight
, 100, nWhich
));
2009 if (mbScaleObjects
&& !pObj
->IsEdgeObj())
2011 /**************************************************************
2012 * scale object position
2013 **************************************************************/
2016 // corrected scaling; only distances may be scaled
2017 // use aTopLeft as original TopLeft
2018 aNewPos
.X() = long((aTopLeft
.X() - GetLftBorder()) * (double)aFractX
) + nLeft
;
2019 aNewPos
.Y() = long((aTopLeft
.Y() - GetUppBorder()) * (double)aFractY
) + nUpper
;
2021 Size
aVec(aNewPos
.X() - aTopLeft
.X(), aNewPos
.Y() - aTopLeft
.Y());
2023 if (aVec
.Height() != 0 || aVec
.Width() != 0)
2025 pObj
->NbcMove(aVec
);
2029 pObj
->BroadcastObjectChange();
2035 SdrObject
* convertPresentationObjectImpl( SdPage
& rPage
, SdrObject
* pSourceObj
, PresObjKind
& eObjKind
, bool bVertical
, Rectangle aRect
)
2037 SdDrawDocument
* pModel
= static_cast< SdDrawDocument
* >( rPage
.GetModel() );
2038 DBG_ASSERT( pModel
, "sd::convertPresentationObjectImpl(), no model on page!" );
2039 if( !pModel
|| !pSourceObj
)
2042 ::svl::IUndoManager
* pUndoManager
= static_cast<SdDrawDocument
*>(pModel
)->GetUndoManager();
2043 const bool bUndo
= pUndoManager
&& pUndoManager
->IsInListAction() && rPage
.IsInserted();
2045 SdrObject
* pNewObj
= pSourceObj
;
2046 if((eObjKind
== PRESOBJ_OUTLINE
) && (pSourceObj
->GetObjIdentifier() == OBJ_TEXT
) )
2048 pNewObj
= rPage
.CreatePresObj(PRESOBJ_OUTLINE
, bVertical
, aRect
);
2050 // Set text of the subtitle into PRESOBJ_OUTLINE
2051 OutlinerParaObject
* pOutlParaObj
= pSourceObj
->GetOutlinerParaObject();
2056 ::sd::Outliner
* pOutl
= pModel
->GetInternalOutliner( sal_True
);
2058 pOutl
->SetText( *pOutlParaObj
);
2059 pOutlParaObj
= pOutl
->CreateParaObject();
2060 pNewObj
->SetOutlinerParaObject( pOutlParaObj
);
2062 pNewObj
->SetEmptyPresObj(sal_False
);
2064 for (sal_uInt16 nLevel
= 1; nLevel
< 10; nLevel
++)
2066 // assign new template
2067 String
aName(rPage
.GetLayoutName());
2068 aName
+= sal_Unicode( ' ' );
2069 aName
+= OUString::number( nLevel
);
2070 SfxStyleSheet
* pSheet
= static_cast<SfxStyleSheet
*>( pModel
->GetStyleSheetPool()->Find(aName
, SD_STYLE_FAMILY_MASTERPAGE
) );
2076 SfxStyleSheet
* pSubtitleSheet
= rPage
.GetStyleSheetForPresObj(PRESOBJ_TEXT
);
2079 pOutlParaObj
->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE
, pSubtitleSheet
->GetName(), pSheet
->GetName());
2082 pNewObj
->StartListening(*pSheet
);
2086 // Remove LRSpace item
2087 SfxItemSet
aSet(pModel
->GetPool(), EE_PARA_LRSPACE
, EE_PARA_LRSPACE
);
2089 aSet
.Put(pNewObj
->GetMergedItemSet());
2091 aSet
.ClearItem(EE_PARA_LRSPACE
);
2093 pNewObj
->SetMergedItemSet(aSet
);
2096 pUndoManager
->AddUndoAction( pModel
->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj
) );
2098 // Remove outline shape from page
2099 rPage
.RemoveObject( pSourceObj
->GetOrdNum() );
2102 SdrObject::Free( pSourceObj
);
2105 else if((eObjKind
== PRESOBJ_TEXT
) && (pSourceObj
->GetObjIdentifier() == OBJ_OUTLINETEXT
) )
2107 // is there an outline shape we can use to replace empty subtitle shape?
2108 pNewObj
= rPage
.CreatePresObj(PRESOBJ_TEXT
, bVertical
, aRect
);
2110 // Set text of the outline object into PRESOBJ_TITLE
2111 OutlinerParaObject
* pOutlParaObj
= pSourceObj
->GetOutlinerParaObject();
2116 ::sd::Outliner
* pOutl
= pModel
->GetInternalOutliner();
2118 pOutl
->SetText( *pOutlParaObj
);
2119 pOutlParaObj
= pOutl
->CreateParaObject();
2120 pNewObj
->SetOutlinerParaObject( pOutlParaObj
);
2122 pNewObj
->SetEmptyPresObj(sal_False
);
2124 // reset left indent
2125 SfxItemSet
aSet(pModel
->GetPool(), EE_PARA_LRSPACE
, EE_PARA_LRSPACE
);
2127 aSet
.Put(pNewObj
->GetMergedItemSet());
2129 const SvxLRSpaceItem
& rLRItem
= (const SvxLRSpaceItem
&) aSet
.Get(EE_PARA_LRSPACE
);
2130 SvxLRSpaceItem
aNewLRItem(rLRItem
);
2131 aNewLRItem
.SetTxtLeft(0);
2132 aSet
.Put(aNewLRItem
);
2134 pNewObj
->SetMergedItemSet(aSet
);
2136 SfxStyleSheet
* pSheet
= rPage
.GetStyleSheetForPresObj(PRESOBJ_TEXT
);
2138 pNewObj
->SetStyleSheet(pSheet
, sal_True
);
2140 // Remove subtitle shape from page
2142 pUndoManager
->AddUndoAction(pModel
->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj
));
2144 rPage
.RemoveObject( pSourceObj
->GetOrdNum() );
2147 SdrObject::Free( pSourceObj
);
2150 else if((eObjKind
== PRESOBJ_OUTLINE
) && (pSourceObj
->GetObjIdentifier() != OBJ_OUTLINETEXT
) )
2152 switch( pSourceObj
->GetObjIdentifier() )
2154 case OBJ_TABLE
: eObjKind
= PRESOBJ_TABLE
; break;
2155 case OBJ_MEDIA
: eObjKind
= PRESOBJ_MEDIA
; break;
2156 case OBJ_GRAF
: eObjKind
= PRESOBJ_GRAPHIC
; break;
2157 case OBJ_OLE2
: eObjKind
= PRESOBJ_OBJECT
; break;
2164 /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2167 The kind of presentation shape we like to have
2169 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2170 looking for an existing presentation shape
2172 If true, the shape is created vertical if bInit is true
2174 The rectangle that should be used to transform the shape
2176 If true the shape is created if not found
2178 A presentation shape that was either found or created with the given parameters
2180 SdrObject
* SdPage::InsertAutoLayoutShape( SdrObject
* pObj
, PresObjKind eObjKind
, bool bVertical
, Rectangle aRect
, bool bInit
)
2182 ::svl::IUndoManager
* pUndoManager
= pModel
? static_cast<SdDrawDocument
*>(pModel
)->GetUndoManager() : 0;
2183 const bool bUndo
= pUndoManager
&& pUndoManager
->IsInListAction() && IsInserted();
2187 pObj
= CreatePresObj(eObjKind
, bVertical
, aRect
);
2189 else if ( pObj
&& (pObj
->GetUserCall() || bInit
) )
2191 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2193 pObj
= convertPresentationObjectImpl( *this, pObj
, eObjKind
, bVertical
, aRect
);
2197 pUndoManager
->AddUndoAction( pModel
->GetSdrUndoFactory().CreateUndoGeoObject( *pObj
) );
2198 pUndoManager
->AddUndoAction( pModel
->GetSdrUndoFactory().CreateUndoAttrObject( *pObj
, sal_True
, sal_True
) );
2199 pUndoManager
->AddUndoAction( new UndoObjectUserCall( *pObj
) );
2202 ( /*(SdrGrafObj*)*/ pObj
)->AdjustToMaxRect( aRect
);
2204 pObj
->SetUserCall(this);
2206 SdrTextObj
* pTextObject
= dynamic_cast< SdrTextObj
* >(pObj
);
2209 if( pTextObject
->IsVerticalWriting() != (bVertical
? sal_True
: sal_False
) )
2211 pTextObject
->SetVerticalWriting( bVertical
);
2213 // here make sure the correct anchoring is used when the object
2214 // is re-used but orientation is changed
2215 if(PRESOBJ_OUTLINE
== eObjKind
)
2216 pTextObject
->SetMergedItem(SdrTextHorzAdjustItem( bVertical
? SDRTEXTHORZADJUST_RIGHT
: SDRTEXTHORZADJUST_BLOCK
));
2219 if( !mbMaster
&& (pTextObject
->GetObjIdentifier() != OBJ_TABLE
) )
2221 if ( pTextObject
->IsAutoGrowHeight() )
2223 // switch off AutoGrowHeight, set new MinHeight
2224 SfxItemSet
aTempAttr( ((SdDrawDocument
*) pModel
)->GetPool() );
2225 SdrTextMinFrameHeightItem
aMinHeight( aRect
.GetSize().Height() );
2226 aTempAttr
.Put( aMinHeight
);
2227 aTempAttr
.Put( SdrTextAutoGrowHeightItem(sal_False
) );
2228 pTextObject
->SetMergedItemSet(aTempAttr
);
2229 pTextObject
->SetLogicRect(aRect
);
2231 // switch on AutoGrowHeight
2232 SfxItemSet
aAttr( ((SdDrawDocument
*) pModel
)->GetPool() );
2233 aAttr
.Put( SdrTextAutoGrowHeightItem(sal_True
) );
2235 pTextObject
->SetMergedItemSet(aAttr
);
2238 if ( pTextObject
->IsAutoGrowWidth() )
2240 // switch off AutoGrowWidth , set new MinWidth
2241 SfxItemSet
aTempAttr( ((SdDrawDocument
*) pModel
)->GetPool() );
2242 SdrTextMinFrameWidthItem
aMinWidth( aRect
.GetSize().Width() );
2243 aTempAttr
.Put( aMinWidth
);
2244 aTempAttr
.Put( SdrTextAutoGrowWidthItem(sal_False
) );
2245 pTextObject
->SetMergedItemSet(aTempAttr
);
2246 pTextObject
->SetLogicRect(aRect
);
2248 // switch on AutoGrowWidth
2249 SfxItemSet
aAttr( ((SdDrawDocument
*) pModel
)->GetPool() );
2250 aAttr
.Put( SdrTextAutoGrowWidthItem(sal_True
) );
2251 pTextObject
->SetMergedItemSet(aAttr
);
2259 if( !IsPresObj( pObj
) )
2262 pUndoManager
->AddUndoAction( new UndoObjectPresentationKind( *pObj
) );
2264 InsertPresObj( pObj
, eObjKind
);
2267 // make adjustments for vertical title and outline shapes
2268 if( bVertical
&& (( eObjKind
== PRESOBJ_TITLE
) || (eObjKind
== PRESOBJ_OUTLINE
)))
2270 SfxItemSet
aNewSet(pObj
->GetMergedItemSet());
2271 aNewSet
.Put( SdrTextAutoGrowWidthItem(sal_True
) );
2272 aNewSet
.Put( SdrTextAutoGrowHeightItem(sal_False
) );
2273 if( eObjKind
== PRESOBJ_OUTLINE
)
2275 aNewSet
.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
) );
2276 aNewSet
.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
) );
2278 pObj
->SetMergedItemSet(aNewSet
);
2282 if ( pObj
&& (pObj
->GetUserCall() || bInit
) && ( pObj
->IsEmptyPresObj() || !pObj
->ISA(SdrGrafObj
) ) )
2283 pObj
->AdjustToMaxRect( aRect
);
2289 /*************************************************************************
2291 |* Returns the PresObjKind of a object
2293 \************************************************************************/
2295 PresObjKind
SdPage::GetPresObjKind(SdrObject
* pObj
) const
2297 PresObjKind eKind
= PRESOBJ_NONE
;
2298 if( (pObj
!= 0) && (maPresentationShapeList
.hasShape(*pObj
)) )
2300 SdAnimationInfo
* pInfo
= SdDrawDocument::GetShapeUserData(*pObj
);
2302 eKind
= pInfo
->mePresObjKind
;
2308 bool SdPage::IsPresObj(const SdrObject
* pObj
)
2310 return pObj
&& maPresentationShapeList
.hasShape( const_cast<SdrObject
&>(*pObj
) );
2313 void SdPage::RemovePresObj(const SdrObject
* pObj
)
2315 if( pObj
&& maPresentationShapeList
.hasShape(const_cast<SdrObject
&>(*pObj
)) )
2317 SdAnimationInfo
* pInfo
= SdDrawDocument::GetShapeUserData(const_cast<SdrObject
&>(*pObj
));
2319 pInfo
->mePresObjKind
= PRESOBJ_NONE
;
2320 maPresentationShapeList
.removeShape(const_cast<SdrObject
&>(*pObj
));
2324 void SdPage::InsertPresObj(SdrObject
* pObj
, PresObjKind eKind
)
2326 DBG_ASSERT( pObj
, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2327 DBG_ASSERT( !IsPresObj(pObj
), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2330 SdAnimationInfo
* pInfo
= SdDrawDocument::GetShapeUserData(*pObj
, true);
2332 pInfo
->mePresObjKind
= eKind
;
2333 maPresentationShapeList
.addShape(*pObj
);
2337 /*************************************************************************
2339 |* Set the text of a object
2341 \************************************************************************/
2343 void SdPage::SetObjText(SdrTextObj
* pObj
, SdrOutliner
* pOutliner
, PresObjKind eObjKind
, const String
& rString
)
2347 DBG_ASSERT( pObj
->ISA(SdrTextObj
), "SetObjText: No SdrTextObj!" );
2348 ::Outliner
* pOutl
= pOutliner
;
2352 SfxItemPool
* pPool
= ((SdDrawDocument
*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
2353 pOutl
= new ::Outliner( pPool
, OUTLINERMODE_OUTLINEOBJECT
);
2354 pOutl
->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument
*) GetModel() )->GetDocSh() ) );
2355 pOutl
->SetEditTextObjectPool(pPool
);
2356 pOutl
->SetStyleSheetPool((SfxStyleSheetPool
*)GetModel()->GetStyleSheetPool());
2357 pOutl
->EnableUndo(sal_False
);
2358 pOutl
->SetUpdateMode( sal_False
);
2361 sal_uInt16 nOutlMode
= pOutl
->GetMode();
2362 Size aPaperSize
= pOutl
->GetPaperSize();
2363 sal_Bool bUpdateMode
= pOutl
->GetUpdateMode();
2364 pOutl
->SetUpdateMode(sal_False
);
2365 pOutl
->SetParaAttribs( 0, pOutl
->GetEmptyItemSet() );
2367 // Always set the object's StyleSheet at the Outliner to
2368 // use the current objects StyleSheet. Thus it's the same as in
2370 // Moved this implementation from where SetObjText(...) was called
2371 // to inside this method to work even when outliner is fetched here.
2372 pOutl
->SetStyleSheet(0, pObj
->GetStyleSheet());
2378 case PRESOBJ_OUTLINE
:
2380 pOutl
->Init( OUTLINERMODE_OUTLINEOBJECT
);
2387 pOutl
->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind
) );
2388 aString
+= "\n\t\t";
2389 aString
+= SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER2
);
2391 aString
+= "\n\t\t\t";
2392 aString
+= SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER3
);
2394 aString
+= "\n\t\t\t\t";
2395 aString
+= SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER4
);
2397 aString
+= "\n\t\t\t\t\t";
2398 aString
+= SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER5
);
2400 aString
+= "\n\t\t\t\t\t\t";
2401 aString
+= SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER6
);
2403 aString
+= "\n\t\t\t\t\t\t\t";
2404 aString
+= SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER7
);
2412 pOutl
->Init( OUTLINERMODE_TITLEOBJECT
);
2419 pOutl
->Init( OUTLINERMODE_TEXTOBJECT
);
2422 // check if we need to add a text field
2423 SvxFieldData
* pData
= NULL
;
2427 case PRESOBJ_HEADER
:
2428 pData
= new SvxHeaderField();
2430 case PRESOBJ_FOOTER
:
2431 pData
= new SvxFooterField();
2433 case PRESOBJ_SLIDENUMBER
:
2434 pData
= new SvxPageField();
2436 case PRESOBJ_DATETIME
:
2437 pData
= new SvxDateTimeField();
2446 SvxFieldItem
aField( *pData
, EE_FEATURE_FIELD
);
2447 pOutl
->QuickInsertField(aField
,e
);
2454 pOutl
->SetPaperSize( pObj
->GetLogicRect().GetSize() );
2456 if( !aString
.isEmpty() )
2457 pOutl
->SetText( aString
, pOutl
->GetParagraph( 0 ) );
2459 ( (SdrTextObj
*) pObj
)->SetOutlinerParaObject( pOutl
->CreateParaObject() );
2468 // Outliner restaurieren
2469 pOutl
->Init( nOutlMode
);
2470 pOutl
->SetParaAttribs( 0, pOutl
->GetEmptyItemSet() );
2471 pOutl
->SetUpdateMode( bUpdateMode
);
2472 pOutl
->SetPaperSize( aPaperSize
);
2477 /*************************************************************************
2479 |* Set the name of the layout
2481 \************************************************************************/
2482 void SdPage::SetLayoutName(OUString aName
)
2484 maLayoutName
= aName
;
2488 OUString
aSep(SD_LT_SEPARATOR
);
2489 sal_Int32 nPos
= maLayoutName
.indexOf(aSep
);
2491 FmFormPage::SetName(maLayoutName
.copy(0, nPos
));
2496 /*************************************************************************
2498 |* Return the page name and generates it if necessary
2500 \************************************************************************/
2502 const String
& SdPage::GetName() const
2504 String
aCreatedPageName( maCreatedPageName
);
2505 if (GetRealName().Len() == 0)
2507 if ((mePageKind
== PK_STANDARD
|| mePageKind
== PK_NOTES
) && !mbMaster
)
2509 // default name for handout pages
2510 sal_uInt16 nNum
= (GetPageNum() + 1) / 2;
2512 aCreatedPageName
= String(SdResId(STR_PAGE
));
2513 aCreatedPageName
+= sal_Unicode( ' ' );
2514 if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE
)
2516 // if the document has number none as a formating
2517 // for page numbers we still default to arabic numbering
2518 // to keep the default page names unique
2519 aCreatedPageName
+= OUString::number( (sal_Int32
)nNum
);
2523 aCreatedPageName
+= ((SdDrawDocument
*) GetModel())->CreatePageNumValue(nNum
);
2528 /******************************************************************
2529 * default name for note pages
2530 ******************************************************************/
2531 aCreatedPageName
= String(SdResId(STR_LAYOUT_DEFAULT_NAME
));
2536 aCreatedPageName
= GetRealName();
2539 if (mePageKind
== PK_NOTES
)
2541 aCreatedPageName
+= sal_Unicode( ' ' );
2542 aCreatedPageName
+= String(SdResId(STR_NOTES
));
2544 else if (mePageKind
== PK_HANDOUT
&& mbMaster
)
2546 aCreatedPageName
+= OUString(" (");
2547 aCreatedPageName
+= SdResId(STR_HANDOUT
).toString();
2548 aCreatedPageName
+= sal_Unicode( ')' );
2551 const_cast< SdPage
* >(this)->maCreatedPageName
= aCreatedPageName
;
2552 return maCreatedPageName
;
2555 void SdPage::SetOrientation( Orientation eOrient
)
2557 meOrientation
= eOrient
;
2560 Orientation
SdPage::GetOrientation() const
2562 return meOrientation
;
2565 /*************************************************************************
2567 |* returns the default text of a PresObjektes
2569 \************************************************************************/
2571 String
SdPage::GetPresObjText(PresObjKind eObjKind
) const
2575 if (eObjKind
== PRESOBJ_TITLE
)
2579 if (mePageKind
!= PK_NOTES
)
2581 aString
= String ( SdResId( STR_PRESOBJ_MPTITLE
) );
2585 aString
= String ( SdResId( STR_PRESOBJ_MPNOTESTITLE
) );
2590 aString
= String ( SdResId( STR_PRESOBJ_TITLE
) );
2593 else if (eObjKind
== PRESOBJ_OUTLINE
)
2597 aString
= String ( SdResId( STR_PRESOBJ_MPOUTLINE
) );
2601 aString
= String ( SdResId( STR_PRESOBJ_OUTLINE
) );
2604 else if (eObjKind
== PRESOBJ_NOTES
)
2608 aString
= String ( SdResId( STR_PRESOBJ_MPNOTESTEXT
) );
2612 aString
= String ( SdResId( STR_PRESOBJ_NOTESTEXT
) );
2615 else if (eObjKind
== PRESOBJ_TEXT
)
2617 aString
= String ( SdResId( STR_PRESOBJ_TEXT
) );
2619 else if (eObjKind
== PRESOBJ_GRAPHIC
)
2621 aString
= String ( SdResId( STR_PRESOBJ_GRAPHIC
) );
2623 else if (eObjKind
== PRESOBJ_OBJECT
)
2625 aString
= String ( SdResId( STR_PRESOBJ_OBJECT
) );
2627 else if (eObjKind
== PRESOBJ_CHART
)
2629 aString
= String ( SdResId( STR_PRESOBJ_CHART
) );
2631 else if (eObjKind
== PRESOBJ_ORGCHART
)
2633 aString
= String ( SdResId( STR_PRESOBJ_ORGCHART
) );
2635 else if (eObjKind
== PRESOBJ_CALC
)
2637 aString
= String ( SdResId( STR_PRESOBJ_TABLE
) );
2643 extern uno::Reference
< uno::XInterface
> createUnoPageImpl( SdPage
* pPage
);
2645 uno::Reference
< uno::XInterface
> SdPage::createUnoPage()
2647 return createUnoPageImpl( this );
2650 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2651 SdPage
* SdPage::getImplementation( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& xPage
)
2655 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XUnoTunnel
> xUnoTunnel( xPage
, ::com::sun::star::uno::UNO_QUERY
);
2656 if( xUnoTunnel
.is() )
2658 SvxDrawPage
* pUnoPage
= reinterpret_cast<SvxDrawPage
*>(sal::static_int_cast
<sal_uIntPtr
>(xUnoTunnel
->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
2660 return static_cast< SdPage
* >( pUnoPage
->GetSdrPage() );
2663 catch( ::com::sun::star::uno::Exception
& )
2665 OSL_FAIL("sd::SdPage::getImplementation(), exception caught!" );
2671 void SdPage::SetName (const String
& rName
)
2673 String aOldName
= GetName();
2674 FmFormPage::SetName (rName
);
2675 static_cast<SdDrawDocument
*>(pModel
)->UpdatePageRelativeURLs(aOldName
, rName
);
2679 const HeaderFooterSettings
& SdPage::getHeaderFooterSettings() const
2681 if( mePageKind
== PK_HANDOUT
&& !mbMaster
)
2683 return (((SdPage
&)TRG_GetMasterPage()).maHeaderFooterSettings
);
2687 return maHeaderFooterSettings
;
2691 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings
& rNewSettings
)
2693 if( mePageKind
== PK_HANDOUT
&& !mbMaster
)
2695 (((SdPage
&)TRG_GetMasterPage()).maHeaderFooterSettings
) = rNewSettings
;
2699 maHeaderFooterSettings
= rNewSettings
;
2703 if(TRG_HasMasterPage())
2705 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2709 bool SdPage::checkVisibility(
2710 const sdr::contact::ViewObjectContact
& rOriginal
,
2711 const sdr::contact::DisplayInfo
& rDisplayInfo
,
2714 if( !FmFormPage::checkVisibility( rOriginal
, rDisplayInfo
, bEdit
) )
2717 SdrObject
* pObj
= rOriginal
.GetViewContact().TryToGetSdrObject();
2721 const SdrPage
* pVisualizedPage
= GetSdrPageFromXDrawPage(rOriginal
.GetObjectContact().getViewInformation2D().getVisualizedPage());
2722 const bool bIsPrinting(rOriginal
.GetObjectContact().isOutputToPrinter() || rOriginal
.GetObjectContact().isOutputToPDFFile());
2723 const SdrPageView
* pPageView
= rOriginal
.GetObjectContact().TryToGetSdrPageView();
2724 const bool bIsInsidePageObj(pPageView
&& pPageView
->GetPage() != pVisualizedPage
);
2726 // empty presentation objects only visible during edit mode
2727 if( (bIsPrinting
|| !bEdit
|| bIsInsidePageObj
) && pObj
->IsEmptyPresObj() )
2729 if( (pObj
->GetObjInventor() != SdrInventor
) || ( (pObj
->GetObjIdentifier() != OBJ_RECT
) && (pObj
->GetObjIdentifier() != OBJ_PAGE
) ) )
2733 if( ( pObj
->GetObjInventor() == SdrInventor
) && ( pObj
->GetObjIdentifier() == OBJ_TEXT
) )
2735 const SdPage
* pCheckPage
= dynamic_cast< const SdPage
* >(pObj
->GetPage());
2739 PresObjKind eKind
= pCheckPage
->GetPresObjKind(pObj
);
2741 if((eKind
== PRESOBJ_FOOTER
) || (eKind
== PRESOBJ_HEADER
) || (eKind
== PRESOBJ_DATETIME
) || (eKind
== PRESOBJ_SLIDENUMBER
) )
2743 const bool bSubContentProcessing(rDisplayInfo
.GetSubContentActive());
2745 if( bSubContentProcessing
|| ( pCheckPage
->GetPageKind() == PK_HANDOUT
&& bIsPrinting
) )
2747 // use the page that is currently processed
2748 const SdPage
* pVisualizedSdPage
= dynamic_cast< const SdPage
* >(pVisualizedPage
);
2750 if( pVisualizedSdPage
)
2752 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2753 const sd::HeaderFooterSettings
& rSettings
= pVisualizedSdPage
->getHeaderFooterSettings();
2757 case PRESOBJ_FOOTER
:
2758 return rSettings
.mbFooterVisible
;
2759 case PRESOBJ_HEADER
:
2760 return rSettings
.mbHeaderVisible
;
2761 case PRESOBJ_DATETIME
:
2762 return rSettings
.mbDateTimeVisible
;
2763 case PRESOBJ_SLIDENUMBER
:
2764 return rSettings
.mbSlideNumberVisible
;
2770 } // check for placeholders on master
2771 else if( (eKind
!= PRESOBJ_NONE
) && pCheckPage
->IsMasterPage() && ( pVisualizedPage
!= pCheckPage
) )
2773 // presentation objects on master slide are always invisible if slide is shown.
2779 // i63977, do not print SdrpageObjs from master pages
2780 if( ( pObj
->GetObjInventor() == SdrInventor
) && ( pObj
->GetObjIdentifier() == OBJ_PAGE
) )
2782 if( pObj
->GetPage() && pObj
->GetPage()->IsMasterPage() )
2789 bool SdPage::RestoreDefaultText( SdrObject
* pObj
)
2793 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( pObj
);
2797 PresObjKind ePresObjKind
= GetPresObjKind(pTextObj
);
2799 if (ePresObjKind
== PRESOBJ_TITLE
||
2800 ePresObjKind
== PRESOBJ_OUTLINE
||
2801 ePresObjKind
== PRESOBJ_NOTES
||
2802 ePresObjKind
== PRESOBJ_TEXT
)
2804 String
aString( GetPresObjText(ePresObjKind
) );
2808 sal_Bool bVertical
= sal_False
;
2809 OutlinerParaObject
* pOldPara
= pTextObj
->GetOutlinerParaObject();
2811 bVertical
= pOldPara
->IsVertical(); // is old para object vertical?
2813 SetObjText( pTextObj
, 0, ePresObjKind
, aString
);
2817 // Here, only the vertical flag for the
2818 // OutlinerParaObjects needs to be changed. The
2819 // AutoGrowWidth/Height items still exist in the
2820 // not changed object.
2822 && pTextObj
->GetOutlinerParaObject()
2823 && pTextObj
->GetOutlinerParaObject()->IsVertical() != (bool)bVertical
)
2825 Rectangle aObjectRect
= pTextObj
->GetSnapRect();
2826 pTextObj
->GetOutlinerParaObject()->SetVertical(bVertical
);
2827 pTextObj
->SetSnapRect(aObjectRect
);
2831 pTextObj
->SetTextEditOutliner( NULL
); // to make stylesheet settings work
2832 pTextObj
->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind
), sal_True
);
2833 pTextObj
->SetEmptyPresObj(sal_True
);
2841 void SdPage::CalculateHandoutAreas( SdDrawDocument
& rModel
, AutoLayout eLayout
, bool bHorizontal
, std::vector
< Rectangle
>& rAreas
)
2843 SdPage
& rHandoutMaster
= *rModel
.GetMasterSdPage( 0, PK_HANDOUT
);
2845 if( eLayout
== AUTOLAYOUT_NONE
)
2847 // use layout from handout master
2848 SdrObjListIter
aShapeIter (rHandoutMaster
);
2849 while (aShapeIter
.IsMore())
2851 SdrPageObj
* pPageObj
= dynamic_cast<SdrPageObj
*>(aShapeIter
.Next());
2853 rAreas
.push_back( pPageObj
->GetCurrentBoundRect() );
2858 Size aArea
= rHandoutMaster
.GetSize();
2860 const long nGapW
= 1000; // gap is 1cm
2861 const long nGapH
= 1000;
2863 long nLeftBorder
= rHandoutMaster
.GetLftBorder();
2864 long nRightBorder
= rHandoutMaster
.GetRgtBorder();
2865 long nTopBorder
= rHandoutMaster
.GetUppBorder();
2866 long nBottomBorder
= rHandoutMaster
.GetLwrBorder();
2868 const long nHeaderFooterHeight
= static_cast< long >( (aArea
.Height() - nTopBorder
- nLeftBorder
) * 0.05 );
2870 nTopBorder
+= nHeaderFooterHeight
;
2871 nBottomBorder
+= nHeaderFooterHeight
;
2873 long nX
= nGapW
+ nLeftBorder
;
2874 long nY
= nGapH
+ nTopBorder
;
2876 aArea
.Width() -= nGapW
* 2 + nLeftBorder
+ nRightBorder
;
2877 aArea
.Height() -= nGapH
* 2 + nTopBorder
+ nBottomBorder
;
2879 const bool bLandscape
= aArea
.Width() > aArea
.Height();
2881 static sal_uInt16 aOffsets
[5][9] =
2883 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2884 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2885 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2886 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2887 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2890 sal_uInt16
* pOffsets
= aOffsets
[0];
2891 sal_uInt16 nColCnt
= 0, nRowCnt
= 0;
2894 case AUTOLAYOUT_HANDOUT1
:
2895 nColCnt
= 1; nRowCnt
= 1;
2898 case AUTOLAYOUT_HANDOUT2
:
2901 nColCnt
= 2; nRowCnt
= 1;
2905 nColCnt
= 1; nRowCnt
= 2;
2909 case AUTOLAYOUT_HANDOUT3
:
2912 nColCnt
= 3; nRowCnt
= 2;
2916 nColCnt
= 2; nRowCnt
= 3;
2918 pOffsets
= aOffsets
[ bLandscape
? 1 : 0 ];
2921 case AUTOLAYOUT_HANDOUT4
:
2922 nColCnt
= 2; nRowCnt
= 2;
2923 pOffsets
= aOffsets
[ bHorizontal
? 0 : 2 ];
2926 case AUTOLAYOUT_HANDOUT6
:
2929 nColCnt
= 3; nRowCnt
= 2;
2933 nColCnt
= 2; nRowCnt
= 3;
2936 pOffsets
= aOffsets
[ bLandscape
? 1 : 3 ];
2940 case AUTOLAYOUT_HANDOUT9
:
2941 nColCnt
= 3; nRowCnt
= 3;
2944 pOffsets
= aOffsets
[4];
2948 rAreas
.resize( nColCnt
* nRowCnt
);
2950 Size aPartArea
, aSize
;
2951 aPartArea
.Width() = ((aArea
.Width() - ((nColCnt
-1) * nGapW
) ) / nColCnt
);
2952 aPartArea
.Height() = ((aArea
.Height() - ((nRowCnt
-1) * nGapH
) ) / nRowCnt
);
2954 SdrPage
* pFirstPage
= rModel
.GetMasterSdPage(0, PK_STANDARD
);
2957 // scale actual size into handout rect
2958 double fScale
= (double)aPartArea
.Width() / (double)pFirstPage
->GetWdt();
2960 aSize
.Height() = (long)(fScale
* pFirstPage
->GetHgt() );
2961 if( aSize
.Height() > aPartArea
.Height() )
2963 fScale
= (double)aPartArea
.Height() / (double)pFirstPage
->GetHgt();
2964 aSize
.Height() = aPartArea
.Height();
2965 aSize
.Width() = (long)(fScale
* pFirstPage
->GetWdt());
2969 aSize
.Width() = aPartArea
.Width();
2972 nX
+= (aPartArea
.Width() - aSize
.Width()) / 2;
2973 nY
+= (aPartArea
.Height()- aSize
.Height())/ 2;
2980 Point
aPos( nX
, nY
);
2982 const bool bRTL
= rModel
.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB
;
2984 const long nOffsetX
= (aPartArea
.Width() + nGapW
) * (bRTL
? -1 : 1);
2985 const long nOffsetY
= aPartArea
.Height() + nGapH
;
2986 const long nStartX
= bRTL
? nOffsetX
*(1 - nColCnt
) + nX
: nX
;
2988 for(sal_uInt16 nRow
= 0; nRow
< nRowCnt
; nRow
++)
2991 for(sal_uInt16 nCol
= 0; nCol
< nColCnt
; nCol
++)
2993 rAreas
[*pOffsets
++] = Rectangle(aPos
, aSize
);
2994 aPos
.X() += nOffsetX
;
2997 aPos
.Y() += nOffsetY
;
3005 void SdPage::SetPrecious (const bool bIsPrecious
)
3007 mbIsPrecious
= bIsPrecious
;
3013 bool SdPage::IsPrecious (void) const
3015 return mbIsPrecious
;
3021 HeaderFooterSettings::HeaderFooterSettings()
3023 mbHeaderVisible
= true;
3024 mbFooterVisible
= true;
3025 mbSlideNumberVisible
= false;
3026 mbDateTimeVisible
= true;
3027 mbDateTimeIsFixed
= true;
3028 meDateTimeFormat
= SVXDATEFORMAT_A
;
3031 bool HeaderFooterSettings::operator==( const HeaderFooterSettings
& rSettings
) const
3033 return (mbHeaderVisible
== rSettings
.mbHeaderVisible
) &&
3034 (maHeaderText
== rSettings
.maHeaderText
) &&
3035 (mbFooterVisible
== rSettings
.mbFooterVisible
) &&
3036 (maFooterText
== rSettings
.maFooterText
) &&
3037 (mbSlideNumberVisible
== rSettings
.mbSlideNumberVisible
) &&
3038 (mbDateTimeVisible
== rSettings
.mbDateTimeVisible
) &&
3039 (mbDateTimeIsFixed
== rSettings
.mbDateTimeIsFixed
) &&
3040 (meDateTimeFormat
== rSettings
.meDateTimeFormat
) &&
3041 (maDateTimeText
== rSettings
.maDateTimeText
);
3044 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */