LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/uiview - viewdlg2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 93 1.1 %
Date: 2012-12-27 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             : 
      21             : #include <sfx2/request.hxx>
      22             : #include <sfx2/viewfrm.hxx>
      23             : #include <sfx2/objface.hxx>
      24             : #include <fldmgr.hxx>
      25             : #include <expfld.hxx>
      26             : #include <modcfg.hxx>
      27             : 
      28             : #include <tools/shl.hxx>
      29             : 
      30             : #include "swmodule.hxx"
      31             : #include "view.hxx"
      32             : #include "wview.hxx"
      33             : #include "wrtsh.hxx"
      34             : #include "cmdid.h"
      35             : #include "caption.hxx"
      36             : #include "poolfmt.hxx"
      37             : #include "edtwin.hxx"
      38             : #include <SwStyleNameMapper.hxx>
      39             : 
      40             : #include "swabstdlg.hxx"
      41             : #include "frmui.hrc"
      42             : #include "misc.hrc"
      43             : 
      44             : #include "view.hrc"
      45             : 
      46             : extern String* pOldGrfCat;
      47             : extern String* pOldTabCat;
      48             : extern String* pOldFrmCat;
      49             : extern String* pOldDrwCat;
      50             : 
      51           0 : void SwView::ExecDlgExt(SfxRequest &rReq)
      52             : {
      53           0 :     Window *pMDI = &GetViewFrame()->GetWindow();
      54             : 
      55           0 :     switch ( rReq.GetSlot() )
      56             :     {
      57             :         case FN_INSERT_CAPTION:
      58             :         {
      59           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      60             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
      61             : 
      62           0 :             VclAbstractDialog* pDialog = pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION );
      63             :             OSL_ENSURE(pDialog, "Dialogdiet fail!");
      64           0 :             if ( pDialog )
      65             :             {
      66           0 :                 pDialog->Execute();
      67           0 :                 delete pDialog;
      68             :             }
      69           0 :             break;
      70             :         }
      71             :         case  FN_EDIT_FOOTNOTE:
      72             :         {
      73           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      74             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
      75             :             AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg(
      76           0 :                 pMDI, *pWrtShell, sal_True);
      77             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
      78             : 
      79           0 :             pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
      80           0 :             pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
      81           0 :             pDlg->Execute();
      82           0 :             delete pDlg;
      83           0 :             break;
      84             :         }
      85             :     }
      86           0 : }
      87             : 
      88           0 : void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
      89             : {
      90           0 :     SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
      91             : 
      92           0 :     sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
      93           0 :     if (pModOpt->IsInsWithCaption(bWeb))
      94             :     {
      95           0 :         const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId);
      96           0 :         if (pOpt && pOpt->UseCaption() == sal_True)
      97           0 :             InsertCaption(pOpt);
      98             :     }
      99           0 : }
     100             : 
     101           0 : void SwView::InsertCaption(const InsCaptionOpt *pOpt)
     102             : {
     103           0 :     if (!pOpt)
     104           0 :         return;
     105             : 
     106           0 :     const String &rName = pOpt->GetCategory();
     107             : 
     108             :     // Existiert Pool-Vorlage gleichen Namens?
     109           0 :     SwWrtShell &rSh = GetWrtShell();
     110           0 :     if(rName.Len())
     111             :     {
     112           0 :         sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
     113           0 :         if( USHRT_MAX != nPoolId )
     114           0 :             rSh.GetTxtCollFromPool(nPoolId);
     115             :             // Pool-Vorlage existiert nicht: Existiert sie am Dokument?
     116           0 :         else if( !rSh.GetParaStyle(rName) )
     117             :         {
     118             :             // Sie existiert auch nicht am Dokument: erzeugen
     119           0 :             SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL);
     120           0 :             rSh.MakeTxtFmtColl(rName, pDerivedFrom);
     121             :         }
     122             :     }
     123             : 
     124           0 :     SelectionType eType = rSh.GetSelectionType();
     125           0 :     if (eType & nsSelectionType::SEL_OLE)
     126           0 :         eType = nsSelectionType::SEL_GRF;
     127             : 
     128             :     // SwLabelType
     129             :     const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE :
     130             :                       eType & nsSelectionType::SEL_FRM ? LTYPE_FLY :
     131             :                       eType == nsSelectionType::SEL_TXT ? LTYPE_FLY :
     132             :                       eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW :
     133           0 :                                                     LTYPE_OBJECT;
     134             : 
     135           0 :     SwFldMgr aMgr(&rSh);
     136             :     SwSetExpFieldType* pFldType =
     137           0 :             (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
     138           0 :     if (!pFldType && rName.Len() )
     139             :     {
     140             :         // Neuen Feldtypen erzeugen
     141           0 :         SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
     142           0 :         aMgr.InsertFldType(aSwSetExpFieldType);
     143           0 :         pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
     144             :     }
     145             : 
     146           0 :     if (!pOpt->IgnoreSeqOpts())
     147             :     {
     148           0 :         if (pFldType)
     149             :         {
     150           0 :             pFldType->SetDelimiter(pOpt->GetSeparator());
     151           0 :             pFldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) );
     152             :         }
     153             :     }
     154             : 
     155           0 :     sal_uInt16       nID    = USHRT_MAX;
     156           0 :     SwFieldType* pType  = 0;
     157           0 :     const sal_uInt16 nCount = aMgr.GetFldTypeCount();
     158           0 :     if( rName.Len() )
     159             :     {
     160           0 :         for (sal_uInt16 i = 0; i < nCount; ++i)
     161             :         {
     162           0 :             pType = aMgr.GetFldType(USHRT_MAX, i);
     163           0 :             String aTmpName( pType->GetName() );
     164           0 :             if (aTmpName == rName && pType->Which() == RES_SETEXPFLD)
     165             :             {
     166           0 :                 nID = i;
     167             :                 break;
     168             :             }
     169           0 :         }
     170             :     }
     171           0 :     rSh.StartAllAction();
     172             : 
     173           0 :     GetWrtShell().InsertLabel( eT,
     174           0 :                                 pOpt->GetCaption(),
     175           0 :                                 !pOpt->IgnoreSeqOpts() ? aEmptyStr : pOpt->GetSeparator(),
     176           0 :                                 pOpt->GetNumSeparator(),
     177           0 :                                 !pOpt->GetPos(),
     178             :                                 nID,
     179           0 :                                 pOpt->GetCharacterStyle(),
     180           0 :                                 pOpt->CopyAttributes() );
     181             :     // Nummernformat setzen
     182           0 :     if(pType)
     183           0 :         ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType());
     184             : 
     185           0 :     rSh.UpdateExpFlds( sal_True );
     186             : 
     187           0 :     rSh.EndAllAction();
     188             : 
     189           0 :     if ( rSh.IsFrmSelected() )
     190             :     {
     191           0 :         GetEditWin().StopInsFrm();
     192           0 :         rSh.EnterSelFrmMode();
     193             :     }
     194             : 
     195             :     // Kategorie merken
     196           0 :     String** ppStr = 0;
     197           0 :     if (eType & nsSelectionType::SEL_GRF)
     198           0 :         ppStr = &pOldGrfCat;
     199           0 :     else if( eType & nsSelectionType::SEL_TBL)
     200           0 :         ppStr = &pOldTabCat;
     201           0 :     else if( eType & nsSelectionType::SEL_FRM)
     202           0 :         ppStr = &pOldFrmCat;
     203           0 :     else if( eType == nsSelectionType::SEL_TXT)
     204           0 :         ppStr = &pOldFrmCat;
     205           0 :     else if( eType & nsSelectionType::SEL_DRW)
     206           0 :         ppStr = &pOldDrwCat;
     207             : 
     208           0 :     if( ppStr )
     209             :     {
     210           0 :         if( !*ppStr )
     211           0 :             *ppStr = new String( rName );
     212             :         else
     213           0 :             **ppStr = rName;
     214           0 :     }
     215          30 : }
     216             : 
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10