LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fuprlout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 98 1.0 %
Date: 2013-07-09 Functions: 2 10 20.0 %
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 "fuprlout.hxx"
      21             : #include <vcl/wrkwin.hxx>
      22             : #include <sfx2/dispatch.hxx>
      23             : #include <svl/smplhint.hxx>
      24             : #include <svl/itempool.hxx>
      25             : #include <sot/storage.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <svx/svdundo.hxx>
      28             : 
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <sfx2/request.hxx>
      31             : 
      32             : #include "drawdoc.hxx"
      33             : #include "sdpage.hxx"
      34             : #include "pres.hxx"
      35             : #include "DrawViewShell.hxx"
      36             : #include "FrameView.hxx"
      37             : #include "stlpool.hxx"
      38             : #include "View.hxx"
      39             : #include "glob.hrc"
      40             : #include "glob.hxx"
      41             : #include "strings.hrc"
      42             : #include "strmname.h"
      43             : #include "app.hrc"
      44             : #include "DrawDocShell.hxx"
      45             : #include "unprlout.hxx"
      46             : #include "unchss.hxx"
      47             : #include "unmovss.hxx"
      48             : #include "sdattr.hxx"
      49             : #include "sdresid.hxx"
      50             : #include "drawview.hxx"
      51             : #include <editeng/outliner.hxx>
      52             : #include <editeng/editdata.hxx>
      53             : #include "sdabstdlg.hxx"
      54             : 
      55             : namespace sd
      56             : {
      57             : 
      58           0 : TYPEINIT1( FuPresentationLayout, FuPoor );
      59             : 
      60             : #define DOCUMENT_TOKEN (sal_Unicode('#'))
      61             : 
      62           0 : FuPresentationLayout::FuPresentationLayout (
      63             :     ViewShell* pViewSh,
      64             :     ::sd::Window* pWin,
      65             :     ::sd::View* pView,
      66             :     SdDrawDocument* pDoc,
      67             :     SfxRequest& rReq)
      68           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      69             : {
      70           0 : }
      71             : 
      72           0 : FunctionReference FuPresentationLayout::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      73             : {
      74           0 :     FunctionReference xFunc( new FuPresentationLayout( pViewSh, pWin, pView, pDoc, rReq ) );
      75           0 :     xFunc->DoExecute(rReq);
      76           0 :     return xFunc;
      77             : }
      78             : 
      79           0 : void FuPresentationLayout::DoExecute( SfxRequest& rReq )
      80             : {
      81             :     // prevent selected objects or objects which are under editing from disappearing
      82           0 :     mpView->SdrEndTextEdit();
      83             : 
      84           0 :     if(mpView->GetSdrPageView())
      85             :     {
      86           0 :         mpView->UnmarkAll();
      87             :     }
      88             : 
      89           0 :     sal_Bool bError = sal_False;
      90             : 
      91             :     // determine the active page
      92           0 :     sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND;
      93           0 :     for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++)
      94             :     {
      95           0 :         if (mpDoc->GetSdPage(nPage, PK_STANDARD)->IsSelected())
      96             :         {
      97           0 :             nSelectedPage = nPage;
      98           0 :             break;
      99             :         }
     100             :     }
     101             : 
     102             :     DBG_ASSERT(nSelectedPage != SDRPAGE_NOTFOUND, "no selected page");
     103           0 :     SdPage* pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD);
     104           0 :     String aOldPageLayoutName(pSelectedPage->GetLayoutName());
     105           0 :     String aOldLayoutName(aOldPageLayoutName);
     106           0 :     aOldLayoutName.Erase(aOldLayoutName.SearchAscii(SD_LT_SEPARATOR));
     107             : 
     108             :     /* if we are on a master page, the changes apply for all pages and notes-
     109             :        pages who are using the relevant layout */
     110           0 :     sal_Bool bOnMaster = sal_False;
     111           0 :     if( mpViewShell && mpViewShell->ISA(DrawViewShell))
     112             :     {
     113             :         EditMode eEditMode =
     114           0 :             static_cast<DrawViewShell*>(mpViewShell)->GetEditMode();
     115           0 :         if (eEditMode == EM_MASTERPAGE)
     116           0 :             bOnMaster = sal_True;
     117             :     }
     118           0 :     sal_Bool bMasterPage = bOnMaster;
     119           0 :     sal_Bool bCheckMasters = sal_False;
     120             : 
     121             :     // call dialog
     122           0 :     sal_Bool   bLoad = sal_False;           // appear the new master pages?
     123           0 :     String aFile;
     124             : 
     125           0 :     SfxItemSet aSet(mpDoc->GetPool(), ATTR_PRESLAYOUT_START, ATTR_PRESLAYOUT_END);
     126             : 
     127           0 :     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD, bLoad));
     128           0 :     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE, bMasterPage ) );
     129           0 :     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_CHECK_MASTERS, bCheckMasters ) );
     130           0 :     aSet.Put( SfxStringItem( ATTR_PRESLAYOUT_NAME, aOldLayoutName));
     131             : 
     132             : 
     133             : 
     134           0 :     const SfxItemSet *pArgs = rReq.GetArgs ();
     135             : 
     136           0 :     if (pArgs)
     137             :     {
     138           0 :         if (pArgs->GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET)
     139           0 :             bLoad = ((SfxBoolItem&)pArgs->Get(ATTR_PRESLAYOUT_LOAD)).GetValue();
     140           0 :         if( pArgs->GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET )
     141           0 :             bMasterPage = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue();
     142           0 :         if( pArgs->GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET )
     143           0 :             bCheckMasters = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue();
     144           0 :         if (pArgs->GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET)
     145           0 :             aFile = ((SfxStringItem&)pArgs->Get(ATTR_PRESLAYOUT_NAME)).GetValue();
     146             :     }
     147             :     else
     148             :     {
     149           0 :         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     150           0 :         AbstractSdPresLayoutDlg* pDlg = pFact ? pFact->CreateSdPresLayoutDlg(mpDocSh, NULL, aSet ) : 0;
     151             : 
     152           0 :         sal_uInt16 nResult = pDlg ? pDlg->Execute() : static_cast<short>(RET_CANCEL);
     153             : 
     154           0 :         switch (nResult)
     155             :         {
     156             :             case RET_OK:
     157             :             {
     158           0 :                 pDlg->GetAttr(aSet);
     159           0 :                 if (aSet.GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET)
     160           0 :                     bLoad = ((SfxBoolItem&)aSet.Get(ATTR_PRESLAYOUT_LOAD)).GetValue();
     161           0 :                 if( aSet.GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET )
     162           0 :                     bMasterPage = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue();
     163           0 :                 if( aSet.GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET )
     164           0 :                     bCheckMasters = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue();
     165           0 :                 if (aSet.GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET)
     166           0 :                     aFile = ((SfxStringItem&)aSet.Get(ATTR_PRESLAYOUT_NAME)).GetValue();
     167             :             }
     168           0 :             break;
     169             : 
     170             :             default:
     171           0 :                 bError = sal_True;
     172             :         }
     173           0 :         delete pDlg;
     174             :     }
     175             : 
     176           0 :     if (!bError)
     177             :     {
     178           0 :         mpDocSh->SetWaitCursor( sal_True );
     179             : 
     180             :         /* Here, we only exchange masterpages, therefore the current page
     181             :            remains the current page. To prevent calling PageOrderChangedHint
     182             :            during insertion and extraction of the masterpages, we block. */
     183             :         /* That isn't quitely right. If the masterpageview is active and you are
     184             :            removing a masterpage, it's possible that you are removing the
     185             :            current masterpage. So you have to call ResetActualPage ! */
     186           0 :         if( mpViewShell->ISA(DrawViewShell) && !bCheckMasters )
     187           0 :             static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_True);
     188             : 
     189           0 :         if (bLoad)
     190             :         {
     191           0 :             String aFileName = aFile.GetToken( 0, DOCUMENT_TOKEN );
     192           0 :             SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName );
     193             : 
     194             :             // #69581: If I chosed the standard-template I got no filename and so I get no
     195             :             //         SdDrawDocument-Pointer. But the method SetMasterPage is able to handle
     196             :             //         a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage )
     197           0 :             String aLayoutName;
     198           0 :             if( pTempDoc )
     199           0 :                 aLayoutName = aFile.GetToken( 1, DOCUMENT_TOKEN );
     200             : 
     201           0 :             mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters);
     202           0 :             mpDoc->CloseBookmarkDoc();
     203             :         }
     204             :         else
     205             :         {
     206             :             // use master page with the layout name aFile from current Doc
     207           0 :             mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters);
     208             :         }
     209             : 
     210             :         // remove blocking
     211           0 :         if (mpViewShell->ISA(DrawViewShell) && !bCheckMasters )
     212           0 :             static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_False);
     213             : 
     214             :         // if the master page was visible, show it again
     215           0 :         if (!bError && nSelectedPage != SDRPAGE_NOTFOUND)
     216             :         {
     217           0 :             if (bOnMaster)
     218             :             {
     219           0 :                 if (mpViewShell->ISA(DrawViewShell))
     220             :                 {
     221             :                     ::sd::View* pView =
     222           0 :                           static_cast<DrawViewShell*>(mpViewShell)->GetView();
     223           0 :                     sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum();
     224             : 
     225           0 :                     if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PK_NOTES)
     226           0 :                         nPgNum++;
     227             : 
     228           0 :                     pView->HideSdrPage();
     229           0 :                     pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum));
     230             :                 }
     231             : 
     232             :                 // force update of TabBar
     233           0 :                 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     234             :             }
     235             :             else
     236             :             {
     237           0 :                 pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout());
     238             :             }
     239             :         }
     240             : 
     241             :         // fake a mode change to repaint the page tab bar
     242           0 :         if( mpViewShell && mpViewShell->ISA( DrawViewShell ) )
     243             :         {
     244             :             DrawViewShell* pDrawViewSh =
     245           0 :                 static_cast<DrawViewShell*>(mpViewShell);
     246           0 :             EditMode eMode = pDrawViewSh->GetEditMode();
     247           0 :             sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
     248           0 :             pDrawViewSh->ChangeEditMode( eMode, !bLayer );
     249           0 :             pDrawViewSh->ChangeEditMode( eMode, bLayer );
     250             :         }
     251             : 
     252           0 :         mpDocSh->SetWaitCursor( sal_False );
     253           0 :     }
     254           0 : }
     255             : 
     256          33 : } // end of namespace sd
     257             : 
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10