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