LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fuprobjs.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 65 1.5 %
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             : 
      21             : #include "fuprobjs.hxx"
      22             : 
      23             : #include <vcl/msgbox.hxx>
      24             : #include <svl/style.hxx>
      25             : #include <editeng/outliner.hxx>
      26             : #include <svl/smplhint.hxx>
      27             : 
      28             : 
      29             : #include "app.hrc"
      30             : #include "res_bmp.hrc"
      31             : #include "strings.hrc"
      32             : #include "glob.hrc"
      33             : #include "prltempl.hrc"
      34             : 
      35             : #include "sdresid.hxx"
      36             : #include "drawdoc.hxx"
      37             : #include "OutlineViewShell.hxx"
      38             : #include "ViewShell.hxx"
      39             : #include "Window.hxx"
      40             : #include "glob.hxx"
      41             : #include "prlayout.hxx"
      42             : #include "unchss.hxx"
      43             : #include "sdabstdlg.hxx"
      44             : namespace sd {
      45             : 
      46           0 : TYPEINIT1( FuPresentationObjects, FuPoor );
      47             : 
      48             : 
      49           0 : FuPresentationObjects::FuPresentationObjects (
      50             :     ViewShell* pViewSh,
      51             :     ::sd::Window* pWin,
      52             :     ::sd::View* pView,
      53             :     SdDrawDocument* pDoc,
      54             :     SfxRequest& rReq)
      55           0 :      : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      56             : {
      57           0 : }
      58             : 
      59           0 : FunctionReference FuPresentationObjects::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      60             : {
      61           0 :     FunctionReference xFunc( new FuPresentationObjects( pViewSh, pWin, pView, pDoc, rReq ) );
      62           0 :     xFunc->DoExecute(rReq);
      63           0 :     return xFunc;
      64             : }
      65             : 
      66           0 : void FuPresentationObjects::DoExecute( SfxRequest& )
      67             : {
      68           0 :     OutlineViewShell* pOutlineViewShell = dynamic_cast< OutlineViewShell* >( mpViewShell );
      69             :     DBG_ASSERT( pOutlineViewShell, "sd::FuPresentationObjects::DoExecute(), does not work without an OutlineViewShell!");
      70           0 :     if( !pOutlineViewShell )
      71           0 :         return;
      72             : 
      73             :     /* does the selections end in a unique presentation layout?
      74             :        if not, it is not allowed to edit the templates */
      75           0 :     SfxItemSet aSet(mpDoc->GetItemPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
      76           0 :     pOutlineViewShell->GetStatusBarState( aSet );
      77           0 :     String aLayoutName = (((SfxStringItem&)aSet.Get(SID_STATUS_LAYOUT)).GetValue());
      78             :     DBG_ASSERT(aLayoutName.Len(), "Layout not defined");
      79             : 
      80           0 :     sal_Bool    bUnique = sal_False;
      81             :     sal_Int16   nDepth, nTmp;
      82           0 :     OutlineView* pOlView = static_cast<OutlineView*>(pOutlineViewShell->GetView());
      83           0 :     OutlinerView* pOutlinerView = pOlView->GetViewByWindow( (Window*) mpWindow );
      84           0 :     ::Outliner* pOutl = pOutlinerView->GetOutliner();
      85             : 
      86           0 :     std::vector<Paragraph*> aSelList;
      87           0 :     pOutlinerView->CreateSelectionList(aSelList);
      88             : 
      89           0 :     std::vector<Paragraph*>::const_iterator iter = aSelList.begin();
      90           0 :     Paragraph* pPara = aSelList.empty() ? NULL : *iter;
      91             : 
      92           0 :     nDepth = pOutl->GetDepth(pOutl->GetAbsPos( pPara ) );
      93           0 :     bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE );
      94             : 
      95           0 :     while( iter != aSelList.end() )
      96             :     {
      97           0 :         pPara = *iter;
      98             : 
      99           0 :         nTmp = pOutl->GetDepth( pOutl->GetAbsPos( pPara ) );
     100             : 
     101           0 :         if( nDepth != nTmp )
     102             :         {
     103           0 :             bUnique = sal_False;
     104           0 :             break;
     105             :         }
     106             : 
     107           0 :         if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) != bPage )
     108             :         {
     109           0 :             bUnique = sal_False;
     110           0 :             break;
     111             :         }
     112           0 :         bUnique = sal_True;
     113           0 :         ++iter;
     114             :     }
     115             : 
     116           0 :     if( bUnique )
     117             :     {
     118           0 :         OUString aStyleName = aLayoutName;
     119           0 :         aStyleName += SD_LT_SEPARATOR ;
     120           0 :         sal_uInt16 nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
     121             :         PresentationObjects ePO;
     122             : 
     123           0 :         if( bPage )
     124             :         {
     125           0 :             ePO = PO_TITLE;
     126           0 :             String aStr(SdResId( STR_LAYOUT_TITLE ));
     127           0 :             aStyleName += aStr ;
     128             :         }
     129             :         else
     130             :         {
     131           0 :             ePO = (PresentationObjects) ( PO_OUTLINE_1 + nDepth - 1 );
     132           0 :             String aStr(SdResId( STR_LAYOUT_OUTLINE ));
     133           0 :             aStyleName += aStr ;
     134           0 :             aStyleName += OUString(' ') ;
     135           0 :             aStyleName += OUString::number( nDepth ) ;
     136             :         }
     137             : 
     138           0 :         SfxStyleSheetBasePool* pStyleSheetPool = mpDocSh->GetStyleSheetPool();
     139           0 :         SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->Find( aStyleName, SD_STYLE_FAMILY_MASTERPAGE );
     140             :         DBG_ASSERT(pStyleSheet, "StyleSheet missing");
     141             : 
     142           0 :         if( pStyleSheet )
     143             :         {
     144           0 :             SfxStyleSheetBase& rStyleSheet = *pStyleSheet;
     145             : 
     146           0 :             SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     147           0 :             SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId( nDlgId ), rStyleSheet, ePO, pStyleSheetPool ) : 0;
     148           0 :             if( pDlg && (pDlg->Execute() == RET_OK) )
     149             :             {
     150           0 :                 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
     151             :                 // Undo-Action
     152             :                 StyleSheetUndoAction* pAction = new StyleSheetUndoAction
     153             :                                                 (mpDoc, (SfxStyleSheet*)pStyleSheet,
     154           0 :                                                     pOutSet);
     155           0 :                 mpDocSh->GetUndoManager()->AddUndoAction(pAction);
     156             : 
     157           0 :                 pStyleSheet->GetItemSet().Put( *pOutSet );
     158           0 :                 ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     159             :             }
     160           0 :             delete( pDlg );
     161           0 :         }
     162           0 :     }
     163             : }
     164             : 
     165          33 : } // end of namespace sd
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10