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