LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/view - viewshe3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 139 0.7 %
Date: 2012-12-27 Functions: 2 4 50.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"                 // Undo-Action
      65             : #include "sdundogr.hxx"                 // Undo Gruppe
      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             : |*
      85             : |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
      86             : |*
      87             : \************************************************************************/
      88             : 
      89           0 : void  ViewShell::GetMenuState( SfxItemSet &rSet )
      90             : {
      91           0 :     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STYLE_FAMILY ) )
      92             :     {
      93           0 :         sal_uInt16 nFamily = (sal_uInt16)GetDocSh()->GetStyleFamily();
      94             : 
      95           0 :         SdrView* pDrView = GetDrawView();
      96             : 
      97           0 :         if( pDrView->AreObjectsMarked() )
      98             :         {
      99           0 :             SfxStyleSheet* pStyleSheet = pDrView->GetStyleSheet();
     100           0 :             if( pStyleSheet )
     101             :             {
     102           0 :                 if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
     103           0 :                     pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
     104             : 
     105           0 :                 if( pStyleSheet )
     106             :                 {
     107           0 :                     SfxStyleFamily eFamily = pStyleSheet->GetFamily();
     108           0 :                     if(eFamily == SD_STYLE_FAMILY_GRAPHICS)
     109           0 :                         nFamily = 2;
     110           0 :                     else if(eFamily == SD_STYLE_FAMILY_CELL )
     111           0 :                         nFamily = 3;
     112             :                     else // SD_STYLE_FAMILY_PSEUDO
     113           0 :                         nFamily = 5;
     114             : 
     115           0 :                     GetDocSh()->SetStyleFamily(nFamily);
     116             :                 }
     117             :             }
     118             :         }
     119           0 :         rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
     120             :     }
     121             : 
     122           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETUNDOSTRINGS))
     123             :     {
     124           0 :         ImpGetUndoStrings(rSet);
     125             :     }
     126             : 
     127           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETREDOSTRINGS))
     128             :     {
     129           0 :         ImpGetRedoStrings(rSet);
     130             :     }
     131             : 
     132           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_UNDO))
     133             :     {
     134           0 :         ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
     135           0 :         sal_Bool bActivate(sal_False);
     136             : 
     137           0 :         if(pUndoManager)
     138             :         {
     139           0 :             if(pUndoManager->GetUndoActionCount() != 0)
     140             :             {
     141           0 :                 bActivate = sal_True;
     142             :             }
     143             :         }
     144             : 
     145           0 :         if(bActivate)
     146             :         {
     147             :             // Set the necessary string like in
     148             :             // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1072 ff.
     149           0 :             String aTmp( SvtResId( STR_UNDO ) );
     150           0 :             aTmp += pUndoManager->GetUndoActionComment(0);
     151           0 :             rSet.Put(SfxStringItem(SID_UNDO, aTmp));
     152             :         }
     153             :         else
     154             :         {
     155           0 :             rSet.DisableItem(SID_UNDO);
     156             :         }
     157             :     }
     158             : 
     159           0 :     if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_REDO))
     160             :     {
     161           0 :         ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
     162           0 :         sal_Bool bActivate(sal_False);
     163             : 
     164           0 :         if(pUndoManager)
     165             :         {
     166           0 :             if(pUndoManager->GetRedoActionCount() != 0)
     167             :             {
     168           0 :                 bActivate = sal_True;
     169             :             }
     170             :         }
     171             : 
     172           0 :         if(bActivate)
     173             :         {
     174             :             // Set the necessary string like in
     175             :             // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1081 ff.
     176           0 :             String aTmp(SvtResId(STR_REDO));
     177           0 :             aTmp += pUndoManager->GetRedoActionComment(0);
     178           0 :             rSet.Put(SfxStringItem(SID_REDO, aTmp));
     179             :         }
     180             :         else
     181             :         {
     182           0 :             rSet.DisableItem(SID_REDO);
     183             :         }
     184             :     }
     185           0 : }
     186             : 
     187             : 
     188             : 
     189             : 
     190             : /** This method consists basically of three parts:
     191             :     1. Process the arguments of the SFX request.
     192             :     2. Use the model to create a new page or duplicate an existing one.
     193             :     3. Update the tab control and switch to the new page.
     194             : */
     195           0 : SdPage* ViewShell::CreateOrDuplicatePage (
     196             :     SfxRequest& rRequest,
     197             :     PageKind ePageKind,
     198             :     SdPage* pPage,
     199             :     const sal_Int32 nInsertPosition)
     200             : {
     201           0 :     sal_uInt16 nSId = rRequest.GetSlot();
     202           0 :     SdDrawDocument* pDocument = GetDoc();
     203           0 :     SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
     204           0 :     sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
     205           0 :     sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
     206           0 :     SetOfByte aVisibleLayers;
     207             :     // Determine the page from which to copy some values, such as layers,
     208             :     // size, master page, to the new page.  This is usually the given page.
     209             :     // When the given page is NULL then use the first page of the document.
     210           0 :     SdPage* pTemplatePage = pPage;
     211           0 :     if (pTemplatePage == NULL)
     212           0 :         pTemplatePage = pDocument->GetSdPage(0, ePageKind);
     213           0 :     if (pTemplatePage != NULL && pTemplatePage->TRG_HasMasterPage())
     214           0 :         aVisibleLayers = pTemplatePage->TRG_GetMasterPageVisibleLayers();
     215             :     else
     216           0 :         aVisibleLayers.SetAll();
     217             : 
     218           0 :     String aStandardPageName;
     219           0 :     String aNotesPageName;
     220           0 :     AutoLayout eStandardLayout (AUTOLAYOUT_NONE);
     221           0 :     AutoLayout eNotesLayout (AUTOLAYOUT_NOTES);
     222           0 :     sal_Bool bIsPageBack = aVisibleLayers.IsSet(aBckgrnd);
     223           0 :     sal_Bool bIsPageObj = aVisibleLayers.IsSet(aBckgrndObj);
     224             : 
     225             :     // 1. Process the arguments.
     226           0 :     const SfxItemSet* pArgs = rRequest.GetArgs();
     227           0 :     if (! pArgs)
     228             :     {
     229             :         // AutoLayouts muessen fertig sein
     230           0 :         pDocument->StopWorkStartupDelay();
     231             : 
     232             :         // Use the layouts of the previous page and notes page as template.
     233           0 :         if (pTemplatePage != NULL)
     234             :         {
     235           0 :             eStandardLayout = pTemplatePage->GetAutoLayout();
     236           0 :             if( eStandardLayout == AUTOLAYOUT_TITLE )
     237           0 :                 eStandardLayout = AUTOLAYOUT_ENUM;
     238             : 
     239           0 :             SdPage* pNotesTemplatePage = static_cast<SdPage*>(pDocument->GetPage(pTemplatePage->GetPageNum()+1));
     240           0 :             if (pNotesTemplatePage != NULL)
     241           0 :                 eNotesLayout = pNotesTemplatePage->GetAutoLayout();
     242             :         }
     243             :     }
     244           0 :     else if (pArgs->Count() == 1)
     245             :     {
     246           0 :         pDocument->StopWorkStartupDelay();
     247           0 :         SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
     248           0 :         if( pLayout )
     249             :         {
     250           0 :             if (ePageKind == PK_NOTES)
     251             :             {
     252           0 :                 eNotesLayout   = (AutoLayout) pLayout->GetValue ();
     253             :             }
     254             :             else
     255             :             {
     256           0 :                 eStandardLayout   = (AutoLayout) pLayout->GetValue ();
     257             :             }
     258             :         }
     259             :     }
     260           0 :     else if (pArgs->Count() == 4)
     261             :     {
     262             :         // AutoLayouts muessen fertig sein
     263           0 :         pDocument->StopWorkStartupDelay();
     264             : 
     265           0 :         SFX_REQUEST_ARG (rRequest, pPageName, SfxStringItem, ID_VAL_PAGENAME, sal_False);
     266           0 :         SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
     267           0 :         SFX_REQUEST_ARG (rRequest, pIsPageBack, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False);
     268           0 :         SFX_REQUEST_ARG (rRequest, pIsPageObj, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False);
     269             : 
     270           0 :         if (CHECK_RANGE (AUTOLAYOUT__START, (AutoLayout) pLayout->GetValue (), AUTOLAYOUT__END))
     271             :         {
     272           0 :             if (ePageKind == PK_NOTES)
     273             :             {
     274           0 :                 aNotesPageName = pPageName->GetValue ();
     275           0 :                 eNotesLayout   = (AutoLayout) pLayout->GetValue ();
     276             :             }
     277             :             else
     278             :             {
     279           0 :                 aStandardPageName = pPageName->GetValue ();
     280           0 :                 eStandardLayout   = (AutoLayout) pLayout->GetValue ();
     281             :             }
     282             : 
     283           0 :             bIsPageBack = pIsPageBack->GetValue ();
     284           0 :             bIsPageObj  = pIsPageObj->GetValue ();
     285             :         }
     286             :         else
     287             :         {
     288           0 :             Cancel();
     289             : 
     290           0 :             if(HasCurrentFunction( SID_BEZIER_EDIT ) )
     291           0 :                 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     292             : #ifndef DISABLE_SCRIPTING
     293           0 :             StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     294             : #endif
     295           0 :             rRequest.Ignore ();
     296           0 :             return NULL;
     297             :         }
     298             :     }
     299             :     else
     300             :     {
     301           0 :         Cancel();
     302             : 
     303           0 :         if(HasCurrentFunction(SID_BEZIER_EDIT) )
     304           0 :             GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     305             : #ifndef DISABLE_SCRIPTING
     306           0 :         StarBASIC::FatalError (SbERR_WRONG_ARGS);
     307             : #endif
     308           0 :         rRequest.Ignore ();
     309           0 :         return NULL;
     310             :     }
     311             : 
     312             :     // 2. Create a new page or duplicate an existing one.
     313           0 :     View* pDrView = GetView();
     314           0 :     const bool bUndo = pDrView && pDrView->IsUndoEnabled();
     315           0 :     if( bUndo )
     316           0 :         pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) );
     317             : 
     318           0 :     sal_uInt16 nNewPageIndex = 0xffff;
     319           0 :     switch (nSId)
     320             :     {
     321             :         case SID_INSERTPAGE:
     322             :         case SID_INSERTPAGE_QUICK:
     323             :         case SID_INSERT_MASTER_PAGE:
     324             :             // There are three cases.  a) pPage is not NULL: we use it as a
     325             :             // template and create a new slide behind it. b) pPage is NULL
     326             :             // but the document is not empty: we use the first slide/notes
     327             :             // page as template, create a new slide after it and move it
     328             :             // then to the head of the document. c) pPage is NULL and the
     329             :             // document is empty: We use CreateFirstPages to create the
     330             :             // first page of the document.
     331           0 :             if (pPage == NULL)
     332           0 :                 if (pTemplatePage == NULL)
     333             :                 {
     334           0 :                     pDocument->CreateFirstPages();
     335           0 :                     nNewPageIndex = 0;
     336             :                 }
     337             :                 else
     338             :                 {
     339             :                     // Create a new page with the first page as template and
     340             :                     // insert it after the first page.
     341             :                     nNewPageIndex = pDocument->CreatePage (
     342             :                         pTemplatePage,
     343             :                         ePageKind,
     344             :                         aStandardPageName,
     345             :                         aNotesPageName,
     346             :                         eStandardLayout,
     347             :                         eNotesLayout,
     348             :                         bIsPageBack,
     349             :                         bIsPageObj,
     350           0 :                         nInsertPosition);
     351             :                     // Select exactly the new page.
     352           0 :                     sal_uInt16 nPageCount (pDocument->GetSdPageCount(ePageKind));
     353           0 :                     for (sal_uInt16 i=0; i<nPageCount; i++)
     354             :                     {
     355             :                         pDocument->GetSdPage(i, PK_STANDARD)->SetSelected(
     356           0 :                             i == nNewPageIndex);
     357             :                         pDocument->GetSdPage(i, PK_NOTES)->SetSelected(
     358           0 :                             i == nNewPageIndex);
     359             :                     }
     360             :                     // Move the selected page to the head of the document
     361           0 :                     pDocument->MovePages ((sal_uInt16)-1);
     362           0 :                     nNewPageIndex = 0;
     363             :                 }
     364             :             else
     365             :                 nNewPageIndex = pDocument->CreatePage (
     366             :                     pPage,
     367             :                     ePageKind,
     368             :                     aStandardPageName,
     369             :                     aNotesPageName,
     370             :                     eStandardLayout,
     371             :                     eNotesLayout,
     372             :                     bIsPageBack,
     373             :                     bIsPageObj,
     374           0 :                     nInsertPosition);
     375           0 :             break;
     376             : 
     377             :         case SID_DUPLICATE_PAGE:
     378             :             // Duplication makes no sense when pPage is NULL.
     379           0 :             if (pPage != NULL)
     380             :                 nNewPageIndex = pDocument->DuplicatePage (
     381             :                     pPage,
     382             :                     ePageKind,
     383             :                     aStandardPageName,
     384             :                     aNotesPageName,
     385             :                     bIsPageBack,
     386             :                     bIsPageObj,
     387           0 :                     nInsertPosition);
     388           0 :             break;
     389             : 
     390             :         default:
     391             :             DBG_WARNING("wrong slot id given to CreateOrDuplicatePage");
     392             :             // Try to handle another slot id gracefully.
     393             :     }
     394           0 :     SdPage* pNewPage = 0;
     395           0 :     if(nNewPageIndex != 0xffff)
     396           0 :         pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
     397             : 
     398           0 :     if( bUndo )
     399             :     {
     400           0 :         if( pNewPage )
     401             :         {
     402           0 :             pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
     403           0 :             pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
     404             :         }
     405             : 
     406           0 :         pDrView->EndUndo();
     407             :     }
     408             : 
     409           0 :     return pNewPage;
     410             : }
     411             : 
     412             : 
     413           9 : } // end of namespace sd
     414             : 
     415             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10