LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuprobjs.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 63 0.0 %
Date: 2014-04-14 Functions: 0 10 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             : 
      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 : rtl::Reference<FuPoor> FuPresentationObjects::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      60             : {
      61           0 :     rtl::Reference<FuPoor> 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 :     OUString aLayoutName = ((SfxStringItem&)aSet.Get(SID_STATUS_LAYOUT)).GetValue();
      78             :     DBG_ASSERT(!aLayoutName.isEmpty(), "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 :             aStyleName += SD_RESSTR(STR_LAYOUT_TITLE);
     127             :         }
     128             :         else
     129             :         {
     130           0 :             ePO = (PresentationObjects) ( PO_OUTLINE_1 + nDepth - 1 );
     131           0 :             aStyleName += SD_RESSTR(STR_LAYOUT_OUTLINE);
     132           0 :             aStyleName += OUString(' ') ;
     133           0 :             aStyleName += OUString::number( nDepth ) ;
     134             :         }
     135             : 
     136           0 :         SfxStyleSheetBasePool* pStyleSheetPool = mpDocSh->GetStyleSheetPool();
     137           0 :         SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->Find( aStyleName, SD_STYLE_FAMILY_MASTERPAGE );
     138             :         DBG_ASSERT(pStyleSheet, "StyleSheet missing");
     139             : 
     140           0 :         if( pStyleSheet )
     141             :         {
     142           0 :             SfxStyleSheetBase& rStyleSheet = *pStyleSheet;
     143             : 
     144           0 :             SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     145           0 :             SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId( nDlgId ), rStyleSheet, ePO, pStyleSheetPool ) : 0;
     146           0 :             if( pDlg && (pDlg->Execute() == RET_OK) )
     147             :             {
     148           0 :                 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
     149             :                 // Undo-Action
     150             :                 StyleSheetUndoAction* pAction = new StyleSheetUndoAction
     151             :                                                 (mpDoc, (SfxStyleSheet*)pStyleSheet,
     152           0 :                                                     pOutSet);
     153           0 :                 mpDocSh->GetUndoManager()->AddUndoAction(pAction);
     154             : 
     155           0 :                 pStyleSheet->GetItemSet().Put( *pOutSet );
     156           0 :                 ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     157             :             }
     158           0 :             delete( pDlg );
     159           0 :         }
     160           0 :     }
     161             : }
     162             : 
     163           0 : } // end of namespace sd
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10