LCOV - code coverage report
Current view: top level - sd/source/ui/view - viewshe3.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 139 0.0 %
Date: 2014-04-14 Functions: 0 4 0.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 "ViewShell.hxx"
      21             : #include "GraphicViewShell.hxx"
      22             : #include "GraphicViewShellBase.hxx"
      23             : 
      24             : #include <sfx2/viewfrm.hxx>
      25             : #include <svtools/svtools.hrc>
      26             : #include <com/sun/star/lang/Locale.hpp>
      27             : #include <svtools/svtresid.hxx>
      28             : #include <utility>
      29             : #include <vector>
      30             : 
      31             : #include "app.hrc"
      32             : #include "strings.hrc"
      33             : #include "res_bmp.hrc"
      34             : #include "glob.hrc"
      35             : #include "sdabstdlg.hxx"
      36             : 
      37             : #include "fupoor.hxx"
      38             : #include <sfx2/dispatch.hxx>
      39             : #include <svx/prtqry.hxx>
      40             : #include <svx/svdopage.hxx>
      41             : #include <sfx2/progress.hxx>
      42             : #include <svx/svdobj.hxx>
      43             : #include <vcl/msgbox.hxx>
      44             : #include <sfx2/bindings.hxx>
      45             : #include <svx/svdpagv.hxx>
      46             : #include <svx/svdetc.hxx>
      47             : #include <editeng/outliner.hxx>
      48             : #include <editeng/editstat.hxx>
      49             : #include <tools/multisel.hxx>
      50             : #include <svl/intitem.hxx>
      51             : #include <svl/style.hxx>
      52             : #include <unotools/localedatawrapper.hxx>
      53             : #include <comphelper/processfactory.hxx>
      54             : #include <rtl/ustrbuf.hxx>
      55             : #include "stlsheet.hxx"
      56             : #include "WindowUpdater.hxx"
      57             : #include "DrawViewShell.hxx"
      58             : #include "OutlineViewShell.hxx"
      59             : #include "drawview.hxx"
      60             : 
      61             : #include "sdattr.hxx"
      62             : #include "drawdoc.hxx"
      63             : #include "sdpage.hxx"
      64             : #include "unoaprms.hxx"
      65             : #include "sdundogr.hxx"
      66             : #include "Window.hxx"
      67             : #include "DrawDocShell.hxx"
      68             : #include "FrameView.hxx"
      69             : #include "framework/FrameworkHelper.hxx"
      70             : #include "optsitem.hxx"
      71             : #include "sdresid.hxx"
      72             : 
      73             : #include <svx/svxids.hrc>
      74             : #include <sfx2/request.hxx>
      75             : #include <svl/aeitem.hxx>
      76             : #include <basic/sbstar.hxx>
      77             : 
      78             : using namespace ::com::sun::star;
      79             : using namespace ::rtl;
      80             : 
      81             : namespace sd {
      82             : 
      83             : /**
      84             :  * set state (enabled/disabled) of Menu SfxSlots
      85             :  */
      86           0 : void  ViewShell::GetMenuState( SfxItemSet &rSet )
      87             : {
      88           0 :     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STYLE_FAMILY ) )
      89             :     {
      90           0 :         sal_uInt16 nFamily = (sal_uInt16)GetDocSh()->GetStyleFamily();
      91             : 
      92           0 :         SdrView* pDrView = GetDrawView();
      93             : 
      94           0 :         if( pDrView->AreObjectsMarked() )
      95             :         {
      96           0 :             SfxStyleSheet* pStyleSheet = pDrView->GetStyleSheet();
      97           0 :             if( pStyleSheet )
      98             :             {
      99           0 :                 if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
     100           0 :                     pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
     101             : 
     102           0 :                 if( pStyleSheet )
     103             :                 {
     104           0 :                     SfxStyleFamily eFamily = pStyleSheet->GetFamily();
     105           0 :                     if(eFamily == SD_STYLE_FAMILY_GRAPHICS)
     106           0 :                         nFamily = 2;
     107           0 :                     else if(eFamily == SD_STYLE_FAMILY_CELL )
     108           0 :                         nFamily = 3;
     109             :                     else // SD_STYLE_FAMILY_PSEUDO
     110           0 :                         nFamily = 5;
     111             : 
     112           0 :                     GetDocSh()->SetStyleFamily(nFamily);
     113             :                 }
     114             :             }
     115             :         }
     116           0 :         rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
     117             :     }
     118             : 
     119           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETUNDOSTRINGS))
     120             :     {
     121           0 :         ImpGetUndoStrings(rSet);
     122             :     }
     123             : 
     124           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETREDOSTRINGS))
     125             :     {
     126           0 :         ImpGetRedoStrings(rSet);
     127             :     }
     128             : 
     129           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_UNDO))
     130             :     {
     131           0 :         ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
     132           0 :         sal_Bool bActivate(sal_False);
     133             : 
     134           0 :         if(pUndoManager)
     135             :         {
     136           0 :             if(pUndoManager->GetUndoActionCount() != 0)
     137             :             {
     138           0 :                 bActivate = sal_True;
     139             :             }
     140             :         }
     141             : 
     142           0 :         if(bActivate)
     143             :         {
     144             :             // Set the necessary string like in
     145             :             // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1072 ff.
     146           0 :             OUString aTmp(SVT_RESSTR(STR_UNDO));
     147           0 :             aTmp += pUndoManager->GetUndoActionComment(0);
     148           0 :             rSet.Put(SfxStringItem(SID_UNDO, aTmp));
     149             :         }
     150             :         else
     151             :         {
     152           0 :             rSet.DisableItem(SID_UNDO);
     153             :         }
     154             :     }
     155             : 
     156           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_REDO))
     157             :     {
     158           0 :         ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
     159           0 :         sal_Bool bActivate(sal_False);
     160             : 
     161           0 :         if(pUndoManager)
     162             :         {
     163           0 :             if(pUndoManager->GetRedoActionCount() != 0)
     164             :             {
     165           0 :                 bActivate = sal_True;
     166             :             }
     167             :         }
     168             : 
     169           0 :         if(bActivate)
     170             :         {
     171             :             // Set the necessary string like in
     172             :             // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1081 ff.
     173           0 :             OUString aTmp(SVT_RESSTR(STR_REDO));
     174           0 :             aTmp += pUndoManager->GetRedoActionComment(0);
     175           0 :             rSet.Put(SfxStringItem(SID_REDO, aTmp));
     176             :         }
     177             :         else
     178             :         {
     179           0 :             rSet.DisableItem(SID_REDO);
     180             :         }
     181             :     }
     182           0 : }
     183             : 
     184             : 
     185             : 
     186             : 
     187             : /** This method consists basically of three parts:
     188             :     1. Process the arguments of the SFX request.
     189             :     2. Use the model to create a new page or duplicate an existing one.
     190             :     3. Update the tab control and switch to the new page.
     191             : */
     192           0 : SdPage* ViewShell::CreateOrDuplicatePage (
     193             :     SfxRequest& rRequest,
     194             :     PageKind ePageKind,
     195             :     SdPage* pPage,
     196             :     const sal_Int32 nInsertPosition)
     197             : {
     198           0 :     sal_uInt16 nSId = rRequest.GetSlot();
     199           0 :     SdDrawDocument* pDocument = GetDoc();
     200           0 :     SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
     201           0 :     sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
     202           0 :     sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
     203           0 :     SetOfByte aVisibleLayers;
     204             :     // Determine the page from which to copy some values, such as layers,
     205             :     // size, master page, to the new page.  This is usually the given page.
     206             :     // When the given page is NULL then use the first page of the document.
     207           0 :     SdPage* pTemplatePage = pPage;
     208           0 :     if (pTemplatePage == NULL)
     209           0 :         pTemplatePage = pDocument->GetSdPage(0, ePageKind);
     210           0 :     if (pTemplatePage != NULL && pTemplatePage->TRG_HasMasterPage())
     211           0 :         aVisibleLayers = pTemplatePage->TRG_GetMasterPageVisibleLayers();
     212             :     else
     213           0 :         aVisibleLayers.SetAll();
     214             : 
     215           0 :     OUString aStandardPageName;
     216           0 :     OUString aNotesPageName;
     217           0 :     AutoLayout eStandardLayout (AUTOLAYOUT_NONE);
     218           0 :     AutoLayout eNotesLayout (AUTOLAYOUT_NOTES);
     219           0 :     sal_Bool bIsPageBack = aVisibleLayers.IsSet(aBckgrnd);
     220           0 :     sal_Bool bIsPageObj = aVisibleLayers.IsSet(aBckgrndObj);
     221             : 
     222             :     // 1. Process the arguments.
     223           0 :     const SfxItemSet* pArgs = rRequest.GetArgs();
     224           0 :     if (! pArgs)
     225             :     {
     226             :         // AutoLayouts must be ready
     227           0 :         pDocument->StopWorkStartupDelay();
     228             : 
     229             :         // Use the layouts of the previous page and notes page as template.
     230           0 :         if (pTemplatePage != NULL)
     231             :         {
     232           0 :             eStandardLayout = pTemplatePage->GetAutoLayout();
     233           0 :             if( eStandardLayout == AUTOLAYOUT_TITLE )
     234           0 :                 eStandardLayout = AUTOLAYOUT_ENUM;
     235             : 
     236           0 :             SdPage* pNotesTemplatePage = static_cast<SdPage*>(pDocument->GetPage(pTemplatePage->GetPageNum()+1));
     237           0 :             if (pNotesTemplatePage != NULL)
     238           0 :                 eNotesLayout = pNotesTemplatePage->GetAutoLayout();
     239             :         }
     240             :     }
     241           0 :     else if (pArgs->Count() == 1)
     242             :     {
     243           0 :         pDocument->StopWorkStartupDelay();
     244           0 :         SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, false);
     245           0 :         if( pLayout )
     246             :         {
     247           0 :             if (ePageKind == PK_NOTES)
     248             :             {
     249           0 :                 eNotesLayout   = (AutoLayout) pLayout->GetValue ();
     250             :             }
     251             :             else
     252             :             {
     253           0 :                 eStandardLayout   = (AutoLayout) pLayout->GetValue ();
     254             :             }
     255             :         }
     256             :     }
     257           0 :     else if (pArgs->Count() == 4)
     258             :     {
     259             :         // AutoLayouts must be ready
     260           0 :         pDocument->StopWorkStartupDelay();
     261             : 
     262           0 :         SFX_REQUEST_ARG (rRequest, pPageName, SfxStringItem, ID_VAL_PAGENAME, false);
     263           0 :         SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, false);
     264           0 :         SFX_REQUEST_ARG (rRequest, pIsPageBack, SfxBoolItem, ID_VAL_ISPAGEBACK, false);
     265           0 :         SFX_REQUEST_ARG (rRequest, pIsPageObj, SfxBoolItem, ID_VAL_ISPAGEOBJ, false);
     266             : 
     267           0 :         if (CHECK_RANGE (AUTOLAYOUT__START, (AutoLayout) pLayout->GetValue (), AUTOLAYOUT__END))
     268             :         {
     269           0 :             if (ePageKind == PK_NOTES)
     270             :             {
     271           0 :                 aNotesPageName = pPageName->GetValue ();
     272           0 :                 eNotesLayout   = (AutoLayout) pLayout->GetValue ();
     273             :             }
     274             :             else
     275             :             {
     276           0 :                 aStandardPageName = pPageName->GetValue ();
     277           0 :                 eStandardLayout   = (AutoLayout) pLayout->GetValue ();
     278             :             }
     279             : 
     280           0 :             bIsPageBack = pIsPageBack->GetValue ();
     281           0 :             bIsPageObj  = pIsPageObj->GetValue ();
     282             :         }
     283             :         else
     284             :         {
     285           0 :             Cancel();
     286             : 
     287           0 :             if(HasCurrentFunction( SID_BEZIER_EDIT ) )
     288           0 :                 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     289             : #ifndef DISABLE_SCRIPTING
     290           0 :             StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     291             : #endif
     292           0 :             rRequest.Ignore ();
     293           0 :             return NULL;
     294             :         }
     295             :     }
     296             :     else
     297             :     {
     298           0 :         Cancel();
     299             : 
     300           0 :         if(HasCurrentFunction(SID_BEZIER_EDIT) )
     301           0 :             GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     302             : #ifndef DISABLE_SCRIPTING
     303           0 :         StarBASIC::FatalError (SbERR_WRONG_ARGS);
     304             : #endif
     305           0 :         rRequest.Ignore ();
     306           0 :         return NULL;
     307             :     }
     308             : 
     309             :     // 2. Create a new page or duplicate an existing one.
     310           0 :     View* pDrView = GetView();
     311           0 :     const bool bUndo = pDrView && pDrView->IsUndoEnabled();
     312           0 :     if( bUndo )
     313           0 :         pDrView->BegUndo(SD_RESSTR(STR_INSERTPAGE));
     314             : 
     315           0 :     sal_uInt16 nNewPageIndex = 0xffff;
     316           0 :     switch (nSId)
     317             :     {
     318             :         case SID_INSERTPAGE:
     319             :         case SID_INSERTPAGE_QUICK:
     320             :         case SID_INSERT_MASTER_PAGE:
     321             :             // There are three cases.  a) pPage is not NULL: we use it as a
     322             :             // template and create a new slide behind it. b) pPage is NULL
     323             :             // but the document is not empty: we use the first slide/notes
     324             :             // page as template, create a new slide after it and move it
     325             :             // then to the head of the document. c) pPage is NULL and the
     326             :             // document is empty: We use CreateFirstPages to create the
     327             :             // first page of the document.
     328           0 :             if (pPage == NULL)
     329           0 :                 if (pTemplatePage == NULL)
     330             :                 {
     331           0 :                     pDocument->CreateFirstPages();
     332           0 :                     nNewPageIndex = 0;
     333             :                 }
     334             :                 else
     335             :                 {
     336             :                     // Create a new page with the first page as template and
     337             :                     // insert it after the first page.
     338             :                     nNewPageIndex = pDocument->CreatePage (
     339             :                         pTemplatePage,
     340             :                         ePageKind,
     341             :                         aStandardPageName,
     342             :                         aNotesPageName,
     343             :                         eStandardLayout,
     344             :                         eNotesLayout,
     345             :                         bIsPageBack,
     346             :                         bIsPageObj,
     347           0 :                         nInsertPosition);
     348             :                     // Select exactly the new page.
     349           0 :                     sal_uInt16 nPageCount (pDocument->GetSdPageCount(ePageKind));
     350           0 :                     for (sal_uInt16 i=0; i<nPageCount; i++)
     351             :                     {
     352             :                         pDocument->GetSdPage(i, PK_STANDARD)->SetSelected(
     353           0 :                             i == nNewPageIndex);
     354             :                         pDocument->GetSdPage(i, PK_NOTES)->SetSelected(
     355           0 :                             i == nNewPageIndex);
     356             :                     }
     357             :                     // Move the selected page to the head of the document
     358           0 :                     pDocument->MovePages ((sal_uInt16)-1);
     359           0 :                     nNewPageIndex = 0;
     360             :                 }
     361             :             else
     362             :                 nNewPageIndex = pDocument->CreatePage (
     363             :                     pPage,
     364             :                     ePageKind,
     365             :                     aStandardPageName,
     366             :                     aNotesPageName,
     367             :                     eStandardLayout,
     368             :                     eNotesLayout,
     369             :                     bIsPageBack,
     370             :                     bIsPageObj,
     371           0 :                     nInsertPosition);
     372           0 :             break;
     373             : 
     374             :         case SID_DUPLICATE_PAGE:
     375             :             // Duplication makes no sense when pPage is NULL.
     376           0 :             if (pPage != NULL)
     377             :                 nNewPageIndex = pDocument->DuplicatePage (
     378             :                     pPage,
     379             :                     ePageKind,
     380             :                     aStandardPageName,
     381             :                     aNotesPageName,
     382             :                     bIsPageBack,
     383             :                     bIsPageObj,
     384           0 :                     nInsertPosition);
     385           0 :             break;
     386             : 
     387             :         default:
     388             :             DBG_WARNING("wrong slot id given to CreateOrDuplicatePage");
     389             :             // Try to handle another slot id gracefully.
     390             :     }
     391           0 :     SdPage* pNewPage = 0;
     392           0 :     if(nNewPageIndex != 0xffff)
     393           0 :         pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
     394             : 
     395           0 :     if( bUndo )
     396             :     {
     397           0 :         if( pNewPage )
     398             :         {
     399           0 :             pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
     400           0 :             pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
     401             :         }
     402             : 
     403           0 :         pDrView->EndUndo();
     404             :     }
     405             : 
     406           0 :     return pNewPage;
     407             : }
     408             : 
     409             : 
     410           0 : } // end of namespace sd
     411             : 
     412             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10