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