LCOV - code coverage report
Current view: top level - sw/source/core/uibase/uiview - viewdlg2.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 89 0.0 %
Date: 2014-04-14 Functions: 0 5 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 <sfx2/request.hxx>
      21             : #include <sfx2/viewfrm.hxx>
      22             : #include <sfx2/objface.hxx>
      23             : #include <fldmgr.hxx>
      24             : #include <expfld.hxx>
      25             : #include <modcfg.hxx>
      26             : 
      27             : #include <tools/shl.hxx>
      28             : 
      29             : #include "swmodule.hxx"
      30             : #include "view.hxx"
      31             : #include "wview.hxx"
      32             : #include "wrtsh.hxx"
      33             : #include "cmdid.h"
      34             : #include "caption.hxx"
      35             : #include "poolfmt.hxx"
      36             : #include "edtwin.hxx"
      37             : #include <SwStyleNameMapper.hxx>
      38             : 
      39             : #include "initui.hxx"
      40             : #include "swabstdlg.hxx"
      41             : #include "frmui.hrc"
      42             : #include "misc.hrc"
      43             : 
      44             : #include "view.hrc"
      45             : 
      46             : #include <boost/scoped_ptr.hpp>
      47             : 
      48           0 : void SwView::ExecDlgExt(SfxRequest &rReq)
      49             : {
      50           0 :     Window *pMDI = &GetViewFrame()->GetWindow();
      51             : 
      52           0 :     switch ( rReq.GetSlot() )
      53             :     {
      54             :         case FN_INSERT_CAPTION:
      55             :         {
      56           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      57             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
      58             : 
      59           0 :             boost::scoped_ptr<VclAbstractDialog> pDialog(pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION ));
      60             :             OSL_ENSURE(pDialog, "Dialogdiet fail!");
      61           0 :             if ( pDialog )
      62             :             {
      63           0 :                 pDialog->Execute();
      64             :             }
      65           0 :             break;
      66             :         }
      67             :         case  FN_EDIT_FOOTNOTE:
      68             :         {
      69           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      70             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
      71             :             boost::scoped_ptr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg(
      72           0 :                 pMDI, *m_pWrtShell, sal_True));
      73             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
      74             : 
      75           0 :             pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
      76           0 :             pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
      77           0 :             pDlg->Execute();
      78           0 :             break;
      79             :         }
      80             :     }
      81           0 : }
      82             : 
      83           0 : void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
      84             : {
      85           0 :     SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
      86             : 
      87           0 :     sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
      88           0 :     if (pModOpt->IsInsWithCaption(bWeb))
      89             :     {
      90           0 :         const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId);
      91           0 :         if (pOpt && pOpt->UseCaption() == sal_True)
      92           0 :             InsertCaption(pOpt);
      93             :     }
      94           0 : }
      95             : 
      96           0 : void SwView::InsertCaption(const InsCaptionOpt *pOpt)
      97             : {
      98           0 :     if (!pOpt)
      99           0 :         return;
     100             : 
     101           0 :     const OUString &rName = pOpt->GetCategory();
     102             : 
     103             :     // Is there a pool template with the same name?
     104           0 :     SwWrtShell &rSh = GetWrtShell();
     105           0 :     if(!rName.isEmpty())
     106             :     {
     107           0 :         sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
     108           0 :         if( USHRT_MAX != nPoolId )
     109           0 :             rSh.GetTxtCollFromPool(nPoolId);
     110             :             // Pool template does not exist: Does it exist on the document?
     111           0 :         else if( !rSh.GetParaStyle(rName) )
     112             :         {
     113             :             // It also does not exist in the document: generate
     114           0 :             SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL);
     115           0 :             rSh.MakeTxtFmtColl(rName, pDerivedFrom);
     116             :         }
     117             :     }
     118             : 
     119           0 :     SelectionType eType = rSh.GetSelectionType();
     120           0 :     if (eType & nsSelectionType::SEL_OLE)
     121           0 :         eType = nsSelectionType::SEL_GRF;
     122             : 
     123           0 :     const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE :
     124           0 :                       eType & nsSelectionType::SEL_FRM ? LTYPE_FLY :
     125             :                       eType == nsSelectionType::SEL_TXT ? LTYPE_FLY :
     126           0 :                       eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW :
     127           0 :                                                     LTYPE_OBJECT;
     128             : 
     129           0 :     SwFldMgr aMgr(&rSh);
     130             :     SwSetExpFieldType* pFldType =
     131           0 :             (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
     132           0 :     if (!pFldType && !rName.isEmpty() )
     133             :     {
     134             :         // Create new field types
     135           0 :         SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
     136           0 :         aMgr.InsertFldType(aSwSetExpFieldType);
     137           0 :         pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
     138             :     }
     139             : 
     140           0 :     if (!pOpt->IgnoreSeqOpts())
     141             :     {
     142           0 :         if (pFldType)
     143             :         {
     144           0 :             pFldType->SetDelimiter(pOpt->GetSeparator());
     145           0 :             pFldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) );
     146             :         }
     147             :     }
     148             : 
     149           0 :     sal_uInt16       nID    = USHRT_MAX;
     150           0 :     SwFieldType* pType  = 0;
     151           0 :     const sal_uInt16 nCount = aMgr.GetFldTypeCount();
     152           0 :     if( !rName.isEmpty() )
     153             :     {
     154           0 :         for (sal_uInt16 i = 0; i < nCount; ++i)
     155             :         {
     156           0 :             pType = aMgr.GetFldType(USHRT_MAX, i);
     157           0 :             OUString aTmpName( pType->GetName() );
     158           0 :             if (aTmpName == rName && pType->Which() == RES_SETEXPFLD)
     159             :             {
     160           0 :                 nID = i;
     161           0 :                 break;
     162             :             }
     163           0 :         }
     164             :     }
     165           0 :     rSh.StartAllAction();
     166             : 
     167           0 :     GetWrtShell().InsertLabel( eT,
     168           0 :                                 pOpt->GetCaption(),
     169           0 :                                 !pOpt->IgnoreSeqOpts() ? OUString() : pOpt->GetSeparator(),
     170           0 :                                 pOpt->GetNumSeparator(),
     171           0 :                                 !pOpt->GetPos(),
     172             :                                 nID,
     173           0 :                                 pOpt->GetCharacterStyle(),
     174           0 :                                 pOpt->CopyAttributes() );
     175             :     // Set Number Format
     176           0 :     if(pType)
     177           0 :         ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType());
     178             : 
     179           0 :     rSh.UpdateExpFlds( sal_True );
     180             : 
     181           0 :     rSh.EndAllAction();
     182             : 
     183           0 :     if ( rSh.IsFrmSelected() )
     184             :     {
     185           0 :         GetEditWin().StopInsFrm();
     186           0 :         rSh.EnterSelFrmMode();
     187             :     }
     188             : 
     189             :     // rember category
     190           0 :     if (eType & nsSelectionType::SEL_GRF)
     191           0 :         SetOldGrfCat(rName);
     192           0 :     else if( eType & nsSelectionType::SEL_TBL)
     193           0 :         SetOldTabCat(rName);
     194           0 :     else if( eType & nsSelectionType::SEL_FRM)
     195           0 :         SetOldFrmCat(rName);
     196           0 :     else if( eType == nsSelectionType::SEL_TXT)
     197           0 :         SetOldFrmCat(rName);
     198           0 :     else if( eType & nsSelectionType::SEL_DRW)
     199           0 :         SetOldDrwCat(rName);
     200           0 : }
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10