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