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