xref: /aoo42x/main/sd/source/ui/func/fupage.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include "fupage.hxx"
33 
34 #include <sfx2/viewfrm.hxx>
35 
36 // Seite einrichten Tab-Page
37 
38 #include <svx/svxids.hrc>
39 #include <svx/dialogs.hrc>
40 #include <svl/itempool.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <sfx2/request.hxx>
43 #include <svl/stritem.hxx>
44 #include <vcl/prntypes.hxx>
45 #include <svl/style.hxx>
46 #include <stlsheet.hxx>
47 #include <svx/svdorect.hxx>
48 #include <svx/svdundo.hxx>
49 #include <editeng/eeitem.hxx>
50 #include <editeng/frmdiritem.hxx>
51 #include <svx/xbtmpit.hxx>
52 #include <svx/xsetit.hxx>
53 #include <svl/itempool.hxx>
54 #include <editeng/ulspitem.hxx>
55 #include <editeng/lrspitem.hxx>
56 #include <svx/sdr/properties/properties.hxx>
57 
58 #include "glob.hrc"
59 #include <editeng/shaditem.hxx>
60 #include <editeng/boxitem.hxx>
61 #include <editeng/sizeitem.hxx>
62 #include <editeng/ulspitem.hxx>
63 #include <editeng/lrspitem.hxx>
64 #include <editeng/pbinitem.hxx>
65 #include <sfx2/app.hxx>
66 #include <sfx2/opengrf.hxx>
67 
68 #include "strings.hrc"
69 #include "sdpage.hxx"
70 #include "View.hxx"
71 #include "Window.hxx"
72 #include "pres.hxx"
73 #include "drawdoc.hxx"
74 #include "DrawDocShell.hxx"
75 #include "ViewShell.hxx"
76 #include "DrawViewShell.hxx"
77 #include "app.hrc"
78 #include "unchss.hxx"
79 #include "undoback.hxx"
80 #include "sdabstdlg.hxx"
81 #include "sdresid.hxx"
82 #include "sdundogr.hxx"
83 #include "helpids.h"
84 
85 namespace sd {
86 
87 class Window;
88 
89 // 50 cm 28350
90 // erstmal vom Writer uebernommen
91 #define MAXHEIGHT 28350
92 #define MAXWIDTH  28350
93 
94 
95 TYPEINIT1( FuPage, FuPoor );
96 
97 void mergeItemSetsImpl( SfxItemSet& rTarget, const SfxItemSet& rSource )
98 {
99 	const sal_uInt16* pPtr = rSource.GetRanges();
100 	sal_uInt16 p1, p2;
101 	while( *pPtr )
102 	{
103 		p1 = pPtr[0];
104 		p2 = pPtr[1];
105 
106 		// make ranges discret
107 		while(pPtr[2] && (pPtr[2] - p2 == 1))
108 		{
109 			p2 = pPtr[3];
110 			pPtr += 2;
111 		}
112 		rTarget.MergeRange( p1, p2 );
113 		pPtr += 2;
114 	}
115 
116 	rTarget.Put(rSource);
117 }
118 
119 /*************************************************************************
120 |*
121 |* Konstruktor
122 |*
123 \************************************************************************/
124 
125 FuPage::FuPage( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
126 				 SdDrawDocument* pDoc, SfxRequest& rReq )
127 :	FuPoor(pViewSh, pWin, pView, pDoc, rReq),
128 	mrReq(rReq),
129 	mpArgs( rReq.GetArgs() ),
130     mpBackgroundObjUndoAction( 0 ),
131 	mbPageBckgrdDeleted( false ),
132 	mbMasterPage( false ),
133 	mbDisplayBackgroundTabPage( true ),
134 	mpPage(0)
135 {
136 }
137 
138 FunctionReference FuPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
139 {
140 	FunctionReference xFunc( new FuPage( pViewSh, pWin, pView, pDoc, rReq ) );
141 	xFunc->DoExecute(rReq);
142 	return xFunc;
143 }
144 
145 void FuPage::DoExecute( SfxRequest& )
146 {
147 	mpDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
148 	DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a current DrawViewShell!" );
149 	if( mpDrawViewShell )
150 	{
151 		mbMasterPage = mpDrawViewShell->GetEditMode() == EM_MASTERPAGE;
152 		mbDisplayBackgroundTabPage = (mpDrawViewShell->GetPageKind() == PK_STANDARD);
153 		mpPage = mpDrawViewShell->getCurrentPage();
154 	}
155 
156 	if( mpPage )
157 	{
158 		// if there are no arguments given, open the dialog
159 		if( !mpArgs )
160 		{
161 			mpView->SdrEndTextEdit();
162 			mpArgs = ExecuteDialog(mpWindow);
163 		}
164 
165 		// if we now have arguments, apply them to current page
166 		if( mpArgs )
167 			ApplyItemSet( mpArgs );
168 	}
169 }
170 
171 FuPage::~FuPage()
172 {
173 	delete mpBackgroundObjUndoAction;
174 }
175 
176 void FuPage::Activate()
177 {
178 }
179 
180 void FuPage::Deactivate()
181 {
182 }
183 
184 const SfxItemSet* FuPage::ExecuteDialog( Window* pParent )
185 {
186 	PageKind ePageKind = mpDrawViewShell->GetPageKind();
187 
188 	SfxItemSet aNewAttr(mpDoc->GetPool(),
189 						mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE),
190 						mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE),
191 						SID_ATTR_PAGE, SID_ATTR_PAGE_BSP,
192 						SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_OUTER,
193 						SID_ATTR_BORDER_SHADOW, SID_ATTR_BORDER_SHADOW,
194 						XATTR_FILL_FIRST, XATTR_FILL_LAST,
195 						EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
196 						0);
197 
198 	///////////////////////////////////////////////////////////////////////
199 	// Retrieve additional data for dialog
200 
201     SvxShadowItem aShadowItem(SID_ATTR_BORDER_SHADOW);
202 	aNewAttr.Put( aShadowItem );
203     SvxBoxItem aBoxItem( SID_ATTR_BORDER_OUTER );
204 	aNewAttr.Put( aBoxItem );
205 
206     aNewAttr.Put( SvxFrameDirectionItem(
207         mpDoc->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP,
208         EE_PARA_WRITINGDIR ) );
209 
210 	///////////////////////////////////////////////////////////////////////
211 	// Retrieve page-data for dialog
212 
213     SvxPageItem aPageItem( SID_ATTR_PAGE );
214 	aPageItem.SetDescName( mpPage->GetName() );
215 	aPageItem.SetPageUsage( (SvxPageUsage) SVX_PAGE_ALL );
216 	aPageItem.SetLandscape( mpPage->GetOrientation() == ORIENTATION_LANDSCAPE ? sal_True: sal_False );
217 	aPageItem.SetNumType( mpDoc->GetPageNumType() );
218 	aNewAttr.Put( aPageItem );
219 
220 	// size
221 	maSize = mpPage->GetSize();
222 	SvxSizeItem aSizeItem( SID_ATTR_PAGE_SIZE, maSize );
223 	aNewAttr.Put( aSizeItem );
224 
225 	// Max size
226 	SvxSizeItem aMaxSizeItem( SID_ATTR_PAGE_MAXSIZE, Size( MAXWIDTH, MAXHEIGHT ) );
227 	aNewAttr.Put( aMaxSizeItem );
228 
229 	// paperbin
230 	SvxPaperBinItem aPaperBinItem( SID_ATTR_PAGE_PAPERBIN, (const sal_uInt8)mpPage->GetPaperBin() );
231 	aNewAttr.Put( aPaperBinItem );
232 
233 	SvxLRSpaceItem aLRSpaceItem( (sal_uInt16)mpPage->GetLftBorder(), (sal_uInt16)mpPage->GetRgtBorder(), 0, 0, mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE));
234 	aNewAttr.Put( aLRSpaceItem );
235 
236 	SvxULSpaceItem aULSpaceItem( (sal_uInt16)mpPage->GetUppBorder(), (sal_uInt16)mpPage->GetLwrBorder(), mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE));
237 	aNewAttr.Put( aULSpaceItem );
238 
239 	// Applikation
240 	bool bScale = mpDoc->GetDocumentType() != DOCUMENT_TYPE_DRAW;
241 	aNewAttr.Put( SfxBoolItem( SID_ATTR_PAGE_EXT1, bScale ? sal_True : sal_False ) );
242 
243 	sal_Bool bFullSize = mpPage->IsMasterPage() ?
244 		mpPage->IsBackgroundFullSize() : ((SdPage&)mpPage->TRG_GetMasterPage()).IsBackgroundFullSize();
245 
246 	aNewAttr.Put( SfxBoolItem( SID_ATTR_PAGE_EXT2, bFullSize ) );
247 
248 	///////////////////////////////////////////////////////////////////////
249 	// Merge ItemSet for dialog
250 
251 	const sal_uInt16* pPtr = aNewAttr.GetRanges();
252 	sal_uInt16 p1 = pPtr[0], p2 = pPtr[1];
253 	while(pPtr[2] && (pPtr[2] - p2 == 1))
254 	{
255 		p2 = pPtr[3];
256 		pPtr += 2;
257 	}
258 	pPtr += 2;
259 	SfxItemSet aMergedAttr( *aNewAttr.GetPool(), p1, p2 );
260 
261 	mergeItemSetsImpl( aMergedAttr, aNewAttr );
262 
263 	SdStyleSheet* pStyleSheet = mpPage->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND);
264 
265 	// merge page background filling to the dialogs input set
266 	if( mbDisplayBackgroundTabPage )
267 	{
268 		if( mbMasterPage )
269 		{
270 			if(pStyleSheet)
271 				mergeItemSetsImpl( aMergedAttr, pStyleSheet->GetItemSet() );
272 		}
273 		else
274 		{
275             // Only this page, get attributes for background fill
276             const SfxItemSet& rBackgroundAttributes = mpPage->getSdrPageProperties().GetItemSet();
277 
278             if(XFILL_NONE != ((const XFillStyleItem&)rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue())
279             {
280                 // page attributes are used, take them
281     			aMergedAttr.Put(rBackgroundAttributes);
282             }
283             else
284             {
285 				if(pStyleSheet
286                     && XFILL_NONE != ((const XFillStyleItem&)pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
287                 {
288     				// if the page has no fill style, use the settings from the
289 					// background stylesheet (if used)
290 					mergeItemSetsImpl(aMergedAttr, pStyleSheet->GetItemSet());
291                 }
292 				else
293                 {
294                     // no fill style from page, start with no fill style
295 					aMergedAttr.Put(XFillStyleItem(XFILL_NONE));
296                 }
297             }
298 		}
299 	}
300 
301 	std::auto_ptr< SfxItemSet > pTempSet;
302 
303 	if( GetSlotID() == SID_SELECT_BACKGROUND )
304 	{
305 	    SvxOpenGraphicDialog	aDlg(SdResId(STR_SET_BACKGROUND_PICTURE));
306 
307 	    if( aDlg.Execute() == GRFILTER_OK )
308 	    {
309 			Graphic		aGraphic;
310 			int nError = aDlg.GetGraphic(aGraphic);
311 			if( nError == GRFILTER_OK )
312 			{
313 				pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0) );
314 
315 				pTempSet->Put( XFillStyleItem( XFILL_BITMAP ) );
316 
317 				// MigrateItemSet makes sure the XFillBitmapItem will have a unique name
318 				SfxItemSet aMigrateSet( mpDoc->GetPool(), XATTR_FILLBITMAP, XATTR_FILLBITMAP );
319 				aMigrateSet.Put( XFillBitmapItem( String(RTL_CONSTASCII_USTRINGPARAM("background")), XOBitmap(aGraphic) ) );
320 				mpDoc->MigrateItemSet( &aMigrateSet, pTempSet.get(), NULL );
321 
322 				pTempSet->Put( XFillBmpStretchItem( sal_True ));
323 				pTempSet->Put( XFillBmpTileItem( sal_False ));
324 			}
325 		}
326 	}
327 	else
328 	{
329 		// create the dialog
330 		SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
331 		std::auto_ptr<SfxAbstractTabDialog> pDlg( pFact ? pFact->CreateSdTabPageDialog(NULL, &aMergedAttr, mpDocSh, mbDisplayBackgroundTabPage ) : 0 );
332 		if( pDlg.get() && pDlg->Execute() == RET_OK )
333 			pTempSet.reset( new SfxItemSet(*pDlg->GetOutputItemSet()) );
334 	}
335 
336 	if( pTempSet.get() )
337 	{
338 		pStyleSheet->AdjustToFontHeight(*pTempSet);
339 
340 		if( mbDisplayBackgroundTabPage )
341 		{
342 			// if some fillstyle-items are not set in the dialog, then
343 			// try to use the items before
344 			sal_Bool bChanges = sal_False;
345 			for( sal_uInt16 i=XATTR_FILL_FIRST; i<XATTR_FILL_LAST; i++ )
346 			{
347 				if( aMergedAttr.GetItemState( i ) != SFX_ITEM_DEFAULT )
348 				{
349 					if( pTempSet->GetItemState( i ) == SFX_ITEM_DEFAULT )
350 						pTempSet->Put( aMergedAttr.Get( i ) );
351 					else
352 						if( aMergedAttr.GetItem( i ) != pTempSet->GetItem( i ) )
353 							bChanges = sal_True;
354 				}
355 			}
356 
357 			// if the background for this page was set to invisible, the background-object has to be deleted, too.
358 			if( ( ( (XFillStyleItem*) pTempSet->GetItem( XATTR_FILLSTYLE ) )->GetValue() == XFILL_NONE ) ||
359 				( ( pTempSet->GetItemState( XATTR_FILLSTYLE ) == SFX_ITEM_DEFAULT ) &&
360 					( ( (XFillStyleItem*) aMergedAttr.GetItem( XATTR_FILLSTYLE ) )->GetValue() == XFILL_NONE ) ) )
361 				mbPageBckgrdDeleted = sal_True;
362 
363 			bool bSetToAllPages = false;
364 
365 			// Ask, wether the setting are for the background-page or for the current page
366 			if( !mbMasterPage && bChanges )
367 			{
368 				// But don't ask in notice-view, because we can't change the background of
369 				// notice-masterpage (at the moment)
370 				if( ePageKind != PK_NOTES )
371 				{
372 					String aTit(SdResId( STR_PAGE_BACKGROUND_TITLE ));
373 					String aTxt(SdResId( STR_PAGE_BACKGROUND_TXT ));
374 					MessBox aQuestionBox (
375                         pParent,
376                         WB_YES_NO | WB_DEF_YES,
377                         aTit,
378                         aTxt );
379 					aQuestionBox.SetImage( QueryBox::GetStandardImage() );
380 					bSetToAllPages = ( RET_YES == aQuestionBox.Execute() );
381 				}
382 
383                 if( mbPageBckgrdDeleted )
384 				{
385                     mpBackgroundObjUndoAction = new SdBackgroundObjUndoAction(
386                         *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet());
387 
388                     if(!mpPage->IsMasterPage())
389                     {
390                         // on normal pages, switch off fill attribute usage
391 						SdrPageProperties& rPageProperties = mpPage->getSdrPageProperties();
392 						rPageProperties.ClearItem( XATTR_FILLBITMAP );
393 						rPageProperties.ClearItem( XATTR_FILLGRADIENT );
394 						rPageProperties.ClearItem( XATTR_FILLHATCH );
395                         rPageProperties.PutItem(XFillStyleItem(XFILL_NONE));
396                     }
397 				}
398 			}
399 
400 			// Sonderbehandlung: die INVALIDS auf NULL-Pointer
401 			// zurueckgesetzen (sonst landen INVALIDs oder
402 			// Pointer auf die DefaultItems in der Vorlage;
403 			// beides wuerde die Attribut-Vererbung unterbinden)
404 			pTempSet->ClearInvalidItems();
405 
406 			if( mbMasterPage )
407 			{
408 				StyleSheetUndoAction* pAction = new StyleSheetUndoAction(mpDoc, (SfxStyleSheet*)pStyleSheet, &(*pTempSet.get()));
409 				mpDocSh->GetUndoManager()->AddUndoAction(pAction);
410 				pStyleSheet->GetItemSet().Put( *(pTempSet.get()) );
411 				sdr::properties::CleanupFillProperties( pStyleSheet->GetItemSet() );
412 				pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
413 			}
414 			else if( bSetToAllPages )
415 			{
416 				String aComment(SdResId(STR_UNDO_CHANGE_PAGEFORMAT));
417 				::svl::IUndoManager* pUndoMgr = mpDocSh->GetUndoManager();
418 				pUndoMgr->EnterListAction(aComment, aComment);
419 				SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc);
420 				pUndoGroup->SetComment(aComment);
421 
422 				//Set background on all master pages
423 				sal_uInt16 nMasterPageCount = mpDoc->GetMasterSdPageCount(ePageKind);
424 				for (sal_uInt16 i = 0; i < nMasterPageCount; ++i)
425 				{
426 					SdPage *pMasterPage = mpDoc->GetMasterSdPage(i, ePageKind);
427 					SdStyleSheet *pStyle =
428 						pMasterPage->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND);
429 					StyleSheetUndoAction* pAction =
430 						new StyleSheetUndoAction(mpDoc, (SfxStyleSheet*)pStyle, &(*pTempSet.get()));
431 					pUndoGroup->AddAction(pAction);
432 					pStyle->GetItemSet().Put( *(pTempSet.get()) );
433 					sdr::properties::CleanupFillProperties( pStyleSheet->GetItemSet() );
434 					pStyle->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
435 				}
436 
437 				//Remove background from all pages to reset to the master bg
438 				sal_uInt16 nPageCount(mpDoc->GetSdPageCount(ePageKind));
439 				for(sal_uInt16 i=0; i<nPageCount; ++i)
440 				{
441 					SdPage *pPage = mpDoc->GetSdPage(i, ePageKind);
442 
443 					const SfxItemSet& rFillAttributes = pPage->getSdrPageProperties().GetItemSet();
444    					if(XFILL_NONE != ((const XFillStyleItem&)rFillAttributes.Get(XATTR_FILLSTYLE)).GetValue())
445 				    {
446 						SdBackgroundObjUndoAction *pBackgroundObjUndoAction = new SdBackgroundObjUndoAction(*mpDoc, *pPage, rFillAttributes);
447 						pUndoGroup->AddAction(pBackgroundObjUndoAction);
448 
449 						SdrPageProperties& rPageProperties = pPage->getSdrPageProperties();
450 						rPageProperties.ClearItem( XATTR_FILLBITMAP );
451 						rPageProperties.ClearItem( XATTR_FILLGRADIENT );
452 						rPageProperties.ClearItem( XATTR_FILLHATCH );
453                         rPageProperties.PutItem(XFillStyleItem(XFILL_NONE));
454 
455 						pPage->ActionChanged();
456 					}
457 				}
458 
459 				pUndoMgr->AddUndoAction(pUndoGroup);
460 				pUndoMgr->LeaveListAction();
461 
462 			}
463 
464 			// if background filling is set to master pages then clear from page set
465 			if( mbMasterPage || bSetToAllPages )
466 			{
467 				for( sal_uInt16 nWhich = XATTR_FILL_FIRST; nWhich <= XATTR_FILL_LAST; nWhich++ )
468 				{
469 					pTempSet->ClearItem( nWhich );
470 				}
471 				pTempSet->Put(XFillStyleItem(XFILL_NONE));
472 			}
473 
474 			const SfxPoolItem *pItem;
475 			if( SFX_ITEM_SET == pTempSet->GetItemState( EE_PARA_WRITINGDIR, sal_False, &pItem ) )
476 			{
477 				sal_uInt32 nVal = ((SvxFrameDirectionItem*)pItem)->GetValue();
478 				mpDoc->SetDefaultWritingMode( nVal == FRMDIR_HORI_RIGHT_TOP ? ::com::sun::star::text::WritingMode_RL_TB : ::com::sun::star::text::WritingMode_LR_TB );
479 			}
480 
481 			mpDoc->SetChanged(sal_True);
482 
483 			// BackgroundFill of Masterpage: no hard attributes allowed
484             SdrPage& rUsedMasterPage = mpPage->IsMasterPage() ? *mpPage : mpPage->TRG_GetMasterPage();
485             OSL_ENSURE(rUsedMasterPage.IsMasterPage(), "No MasterPage (!)");
486             rUsedMasterPage.getSdrPageProperties().ClearItem();
487             OSL_ENSURE(0 != rUsedMasterPage.getSdrPageProperties().GetStyleSheet(),
488                 "MasterPage without StyleSheet detected (!)");
489 		}
490 
491 		aNewAttr.Put(*(pTempSet.get()));
492 		mrReq.Done( aNewAttr );
493 
494 		return mrReq.GetArgs();
495 	}
496 	else
497 	{
498 		return 0;
499 	}
500 }
501 
502 void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
503 {
504 	if( !pArgs )
505 		return;
506 
507 	///////////////////////////////////////////////////////////////////////////
508 	// Set new page-attributes
509 	PageKind ePageKind = mpDrawViewShell->GetPageKind();
510 	const SfxPoolItem*  pPoolItem;
511 	sal_Bool                bSetPageSizeAndBorder = sal_False;
512 	Size                aNewSize(maSize);
513 	sal_Int32	            nLeft  = -1, nRight = -1, nUpper = -1, nLower = -1;
514 	sal_Bool	            bScaleAll = sal_True;
515 	Orientation         eOrientation = mpPage->GetOrientation();
516 	SdPage*				pMasterPage = mpPage->IsMasterPage() ? mpPage : &(SdPage&)(mpPage->TRG_GetMasterPage());
517 	sal_Bool                bFullSize = pMasterPage->IsBackgroundFullSize();
518 	sal_uInt16              nPaperBin = mpPage->GetPaperBin();
519 
520 	if( pArgs->GetItemState(SID_ATTR_PAGE, sal_True, &pPoolItem) == SFX_ITEM_SET )
521 	{
522 		mpDoc->SetPageNumType(((const SvxPageItem*) pPoolItem)->GetNumType());
523 
524 		eOrientation = (((const SvxPageItem*) pPoolItem)->IsLandscape() == ORIENTATION_LANDSCAPE) ?
525 			ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT;
526 
527 		if( mpPage->GetOrientation() != eOrientation )
528 			bSetPageSizeAndBorder = sal_True;
529 
530 		mpDrawViewShell->ResetActualPage();
531 	}
532 
533 	if( pArgs->GetItemState(SID_ATTR_PAGE_SIZE, sal_True, &pPoolItem) == SFX_ITEM_SET )
534 	{
535 		aNewSize = ((const SvxSizeItem*) pPoolItem)->GetSize();
536 
537 		if( mpPage->GetSize() != aNewSize )
538 			bSetPageSizeAndBorder = sal_True;
539 	}
540 
541 	if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE),
542 							sal_True, &pPoolItem) == SFX_ITEM_SET )
543 	{
544 		nLeft = ((const SvxLRSpaceItem*) pPoolItem)->GetLeft();
545 		nRight = ((const SvxLRSpaceItem*) pPoolItem)->GetRight();
546 
547 		if( mpPage->GetLftBorder() != nLeft || mpPage->GetRgtBorder() != nRight )
548 			bSetPageSizeAndBorder = sal_True;
549 
550 	}
551 
552 	if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE),
553 							sal_True, &pPoolItem) == SFX_ITEM_SET )
554 	{
555 		nUpper = ((const SvxULSpaceItem*) pPoolItem)->GetUpper();
556 		nLower = ((const SvxULSpaceItem*) pPoolItem)->GetLower();
557 
558 		if( mpPage->GetUppBorder() != nUpper || mpPage->GetLwrBorder() != nLower )
559 			bSetPageSizeAndBorder = sal_True;
560 	}
561 
562 	if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_PAGE_EXT1), sal_True, &pPoolItem) == SFX_ITEM_SET )
563 	{
564 		bScaleAll = ((const SfxBoolItem*) pPoolItem)->GetValue();
565 	}
566 
567 	if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_PAGE_EXT2), sal_True, &pPoolItem) == SFX_ITEM_SET )
568 	{
569 		bFullSize = ((const SfxBoolItem*) pPoolItem)->GetValue();
570 
571 		if(pMasterPage->IsBackgroundFullSize() != bFullSize )
572 			bSetPageSizeAndBorder = sal_True;
573 	}
574 
575 	// Papierschacht (PaperBin)
576 	if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_PAGE_PAPERBIN), sal_True, &pPoolItem) == SFX_ITEM_SET )
577 	{
578 		nPaperBin = ((const SvxPaperBinItem*) pPoolItem)->GetValue();
579 
580 		if( mpPage->GetPaperBin() != nPaperBin )
581 			bSetPageSizeAndBorder = sal_True;
582 	}
583 
584 	if (nLeft == -1 && nUpper != -1)
585 	{
586 		bSetPageSizeAndBorder = sal_True;
587 		nLeft  = mpPage->GetLftBorder();
588 		nRight = mpPage->GetRgtBorder();
589 	}
590 	else if (nLeft != -1 && nUpper == -1)
591 	{
592 		bSetPageSizeAndBorder = sal_True;
593 		nUpper = mpPage->GetUppBorder();
594 		nLower = mpPage->GetLwrBorder();
595 	}
596 
597 	if( bSetPageSizeAndBorder || !mbMasterPage )
598 		mpDrawViewShell->SetPageSizeAndBorder(ePageKind, aNewSize, nLeft, nRight, nUpper, nLower, bScaleAll, eOrientation, nPaperBin, bFullSize );
599 
600 	////////////////////////////////////////////////////////////////////////////////
601 	//
602 	// if bMasterPage==sal_False then create a background-object for this page with the
603 	// properties set in the dialog before, but if mbPageBckgrdDeleted==sal_True then
604 	// the background of this page was set to invisible, so it would be a mistake
605 	// to create a new background-object for this page !
606 	//
607 
608 	if( mbDisplayBackgroundTabPage )
609 	{
610 		if( !mbMasterPage && !mbPageBckgrdDeleted )
611 		{
612 			// Only this page
613 			delete mpBackgroundObjUndoAction;
614 			mpBackgroundObjUndoAction = new SdBackgroundObjUndoAction(
615                 *mpDoc, *mpPage, mpPage->getSdrPageProperties().GetItemSet());
616 			SfxItemSet aSet( *pArgs );
617 			sdr::properties::CleanupFillProperties(aSet);
618 			mpPage->getSdrPageProperties().ClearItem();
619             mpPage->getSdrPageProperties().PutItemSet(aSet);
620 		}
621 	}
622 
623 	// add undo action for background object
624 	if( mpBackgroundObjUndoAction )
625 	{
626 		// set merge flag, because a SdUndoGroupAction could have been inserted before
627 		mpDocSh->GetUndoManager()->AddUndoAction( mpBackgroundObjUndoAction, sal_True );
628 		mpBackgroundObjUndoAction = 0;
629 	}
630 
631 	///////////////////////////////////////////////////////////////////////////
632 	//
633 	// Objekte koennen max. so gross wie die ViewSize werden
634 	//
635 	Size aPageSize = mpDoc->GetSdPage(0, ePageKind)->GetSize();
636 	Size aViewSize = Size(aPageSize.Width() * 3, aPageSize.Height() * 2);
637 	mpDoc->SetMaxObjSize(aViewSize);
638 
639 	///////////////////////////////////////////////////////////////////////////
640 	//
641 	// ggfs. Preview den neuen Kontext mitteilen
642 	//
643 	mpDrawViewShell->UpdatePreview( mpDrawViewShell->GetActualPage() );
644 }
645 
646 } // end of namespace sd
647