LCOV - code coverage report
Current view: top level - sd/source/ui/func - fupage.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 267 0.4 %
Date: 2015-06-13 12:38:46 Functions: 2 17 11.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11