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

Generated by: LCOV version 1.10