LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/func - fuprlout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 98 1.0 %
Date: 2012-12-27 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 "eetext.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             : /*************************************************************************
      63             : |*
      64             : |* Konstruktor
      65             : |*
      66             : \************************************************************************/
      67             : 
      68           0 : FuPresentationLayout::FuPresentationLayout (
      69             :     ViewShell* pViewSh,
      70             :     ::sd::Window* pWin,
      71             :     ::sd::View* pView,
      72             :     SdDrawDocument* pDoc,
      73             :     SfxRequest& rReq)
      74           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      75             : {
      76           0 : }
      77             : 
      78           0 : FunctionReference FuPresentationLayout::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      79             : {
      80           0 :     FunctionReference xFunc( new FuPresentationLayout( pViewSh, pWin, pView, pDoc, rReq ) );
      81           0 :     xFunc->DoExecute(rReq);
      82           0 :     return xFunc;
      83             : }
      84             : 
      85           0 : void FuPresentationLayout::DoExecute( SfxRequest& rReq )
      86             : {
      87             :     // damit nicht Objekte, die gerade editiert werden oder selektiert
      88             :     // sind , verschwinden
      89           0 :     mpView->SdrEndTextEdit();
      90             : 
      91           0 :     if(mpView->GetSdrPageView())
      92             :     {
      93           0 :         mpView->UnmarkAll();
      94             :     }
      95             : 
      96           0 :     sal_Bool bError = sal_False;
      97             : 
      98             :     // die aktive Seite ermitteln
      99           0 :     sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND;
     100           0 :     for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++)
     101             :     {
     102           0 :         if (mpDoc->GetSdPage(nPage, PK_STANDARD)->IsSelected())
     103             :         {
     104           0 :             nSelectedPage = nPage;
     105           0 :             break;
     106             :         }
     107             :     }
     108             : 
     109             :     DBG_ASSERT(nSelectedPage != SDRPAGE_NOTFOUND, "keine selektierte Seite");
     110           0 :     SdPage* pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD);
     111           0 :     String aOldPageLayoutName(pSelectedPage->GetLayoutName());
     112           0 :     String aOldLayoutName(aOldPageLayoutName);
     113           0 :     aOldLayoutName.Erase(aOldLayoutName.SearchAscii(SD_LT_SEPARATOR));
     114             : 
     115             :     // wenn wir auf einer Masterpage sind, gelten die Aenderungen fuer alle
     116             :     // Seiten und Notizseiten, die das betreffende Layout benutzen
     117           0 :     sal_Bool bOnMaster = sal_False;
     118           0 :     if( mpViewShell && mpViewShell->ISA(DrawViewShell))
     119             :     {
     120             :         EditMode eEditMode =
     121           0 :             static_cast<DrawViewShell*>(mpViewShell)->GetEditMode();
     122           0 :         if (eEditMode == EM_MASTERPAGE)
     123           0 :             bOnMaster = sal_True;
     124             :     }
     125           0 :     sal_Bool bMasterPage = bOnMaster;
     126           0 :     sal_Bool bCheckMasters = sal_False;
     127             : 
     128             :     // Dialog aufrufen
     129           0 :     sal_Bool   bLoad = sal_False;           // tauchen neue Masterpages auf?
     130           0 :     String aFile;
     131             : 
     132           0 :     SfxItemSet aSet(mpDoc->GetPool(), ATTR_PRESLAYOUT_START, ATTR_PRESLAYOUT_END);
     133             : 
     134           0 :     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD, bLoad));
     135           0 :     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE, bMasterPage ) );
     136           0 :     aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_CHECK_MASTERS, bCheckMasters ) );
     137           0 :     aSet.Put( SfxStringItem( ATTR_PRESLAYOUT_NAME, aOldLayoutName));
     138             : 
     139             : 
     140             : 
     141           0 :     const SfxItemSet *pArgs = rReq.GetArgs ();
     142             : 
     143           0 :     if (pArgs)
     144             :     {
     145           0 :         if (pArgs->GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET)
     146           0 :             bLoad = ((SfxBoolItem&)pArgs->Get(ATTR_PRESLAYOUT_LOAD)).GetValue();
     147           0 :         if( pArgs->GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET )
     148           0 :             bMasterPage = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue();
     149           0 :         if( pArgs->GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET )
     150           0 :             bCheckMasters = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue();
     151           0 :         if (pArgs->GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET)
     152           0 :             aFile = ((SfxStringItem&)pArgs->Get(ATTR_PRESLAYOUT_NAME)).GetValue();
     153             :     }
     154             :     else
     155             :     {
     156           0 :         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     157           0 :         AbstractSdPresLayoutDlg* pDlg = pFact ? pFact->CreateSdPresLayoutDlg(mpDocSh, NULL, aSet ) : 0;
     158             : 
     159           0 :         sal_uInt16 nResult = pDlg ? pDlg->Execute() : RET_CANCEL;
     160             : 
     161           0 :         switch (nResult)
     162             :         {
     163             :             case RET_OK:
     164             :             {
     165           0 :                 pDlg->GetAttr(aSet);
     166           0 :                 if (aSet.GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET)
     167           0 :                     bLoad = ((SfxBoolItem&)aSet.Get(ATTR_PRESLAYOUT_LOAD)).GetValue();
     168           0 :                 if( aSet.GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET )
     169           0 :                     bMasterPage = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue();
     170           0 :                 if( aSet.GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET )
     171           0 :                     bCheckMasters = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue();
     172           0 :                 if (aSet.GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET)
     173           0 :                     aFile = ((SfxStringItem&)aSet.Get(ATTR_PRESLAYOUT_NAME)).GetValue();
     174             :             }
     175           0 :             break;
     176             : 
     177             :             default:
     178           0 :                 bError = sal_True;
     179             :         }
     180           0 :         delete pDlg;
     181             :     }
     182             : 
     183           0 :     if (!bError)
     184             :     {
     185           0 :         mpDocSh->SetWaitCursor( sal_True );
     186             : 
     187             :         // Hier werden nur Masterpages ausgewechselt, d.h. die aktuelle Seite
     188             :         // bleibt aktuell. Damit beim Ein- und Ausfuegen der Masterpages nicht
     189             :         // dauernd via PageOrderChangedHint die Methode ResetActualPage gerufen
     190             :         // wird, wird jetzt blockiert.
     191             :         // That isn't quitely right. If the masterpageview is active and you are
     192             :         // removing a masterpage, it's possible that you are removing the
     193             :         // current masterpage. So you have to call ResetActualPage !
     194           0 :         if( mpViewShell->ISA(DrawViewShell) && !bCheckMasters )
     195           0 :             static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_True);
     196             : 
     197           0 :         if (bLoad)
     198             :         {
     199           0 :             String aFileName = aFile.GetToken( 0, DOCUMENT_TOKEN );
     200           0 :             SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName );
     201             : 
     202             :             // #69581: If I chosed the standard-template I got no filename and so I get no
     203             :             //         SdDrawDocument-Pointer. But the method SetMasterPage is able to handle
     204             :             //         a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage )
     205           0 :             String aLayoutName;
     206           0 :             if( pTempDoc )
     207           0 :                 aLayoutName = aFile.GetToken( 1, DOCUMENT_TOKEN );
     208             : 
     209           0 :             mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters);
     210           0 :             mpDoc->CloseBookmarkDoc();
     211             :         }
     212             :         else
     213             :         {
     214             :             // MasterPage mit dem LayoutNamen aFile aus aktuellem Doc verwenden
     215           0 :             mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters);
     216             :         }
     217             : 
     218             :         // Blockade wieder aufheben
     219           0 :         if (mpViewShell->ISA(DrawViewShell) && !bCheckMasters )
     220           0 :             static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_False);
     221             : 
     222             :         /*************************************************************************
     223             :         |* Falls dargestellte Masterpage sichtbar war, neu darstellen
     224             :         \************************************************************************/
     225           0 :         if (!bError && nSelectedPage != SDRPAGE_NOTFOUND)
     226             :         {
     227           0 :             if (bOnMaster)
     228             :             {
     229           0 :                 if (mpViewShell->ISA(DrawViewShell))
     230             :                 {
     231             :                     ::sd::View* pView =
     232           0 :                           static_cast<DrawViewShell*>(mpViewShell)->GetView();
     233           0 :                     sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum();
     234             : 
     235           0 :                     if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PK_NOTES)
     236           0 :                         nPgNum++;
     237             : 
     238           0 :                     pView->HideSdrPage();
     239           0 :                     pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum));
     240             :                 }
     241             : 
     242             :                 // damit TabBar aktualisiert wird
     243           0 :                 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     244             :             }
     245             :             else
     246             :             {
     247           0 :                 pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout());
     248             :             }
     249             :         }
     250             : 
     251             :         // fake a mode change to repaint the page tab bar
     252           0 :         if( mpViewShell && mpViewShell->ISA( DrawViewShell ) )
     253             :         {
     254             :             DrawViewShell* pDrawViewSh =
     255           0 :                 static_cast<DrawViewShell*>(mpViewShell);
     256           0 :             EditMode eMode = pDrawViewSh->GetEditMode();
     257           0 :             sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
     258           0 :             pDrawViewSh->ChangeEditMode( eMode, !bLayer );
     259           0 :             pDrawViewSh->ChangeEditMode( eMode, bLayer );
     260             :         }
     261             : 
     262           0 :         mpDocSh->SetWaitCursor( sal_False );
     263           0 :     }
     264           0 : }
     265             : 
     266           9 : } // end of namespace sd
     267             : 
     268             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10