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