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