LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuprlout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 98 1.0 %
Date: 2012-08-25 Functions: 2 10 20.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 260 0.8 %

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

Generated by: LCOV version 1.10