1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <sfx2/request.hxx> 33*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 34*cdf0e10cSrcweir #include <sfx2/objface.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <fldmgr.hxx> 37*cdf0e10cSrcweir #include <expfld.hxx> 38*cdf0e10cSrcweir #include <modcfg.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <tools/shl.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include "swmodule.hxx" 43*cdf0e10cSrcweir #include "view.hxx" 44*cdf0e10cSrcweir #include "wview.hxx" 45*cdf0e10cSrcweir #include "wrtsh.hxx" 46*cdf0e10cSrcweir #include "cmdid.h" 47*cdf0e10cSrcweir #include "caption.hxx" 48*cdf0e10cSrcweir #include "poolfmt.hxx" 49*cdf0e10cSrcweir #include "edtwin.hxx" 50*cdf0e10cSrcweir #include <SwStyleNameMapper.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include "swabstdlg.hxx" 53*cdf0e10cSrcweir #include "frmui.hrc" 54*cdf0e10cSrcweir #include "misc.hrc" 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #include "view.hrc" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir extern String* pOldGrfCat; 59*cdf0e10cSrcweir extern String* pOldTabCat; 60*cdf0e10cSrcweir extern String* pOldFrmCat; 61*cdf0e10cSrcweir extern String* pOldDrwCat; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir /* -----------------06.11.98 13:45------------------- 64*cdf0e10cSrcweir * 65*cdf0e10cSrcweir * --------------------------------------------------*/ 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir void SwView::ExecDlgExt(SfxRequest &rReq) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir Window *pMDI = &GetViewFrame()->GetWindow(); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir switch ( rReq.GetSlot() ) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir case FN_INSERT_CAPTION: 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 76*cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir VclAbstractDialog* pDialog = pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION ); 79*cdf0e10cSrcweir DBG_ASSERT(pDialog, "Dialogdiet fail!"); 80*cdf0e10cSrcweir if ( pDialog ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir pDialog->Execute(); 83*cdf0e10cSrcweir delete pDialog; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir break; 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir case FN_EDIT_FOOTNOTE: 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 90*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 91*cdf0e10cSrcweir AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE, 92*cdf0e10cSrcweir pMDI, *pWrtShell, sal_True ); 93*cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand()); 96*cdf0e10cSrcweir pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) ); 97*cdf0e10cSrcweir pDlg->Execute(); 98*cdf0e10cSrcweir delete pDlg; 99*cdf0e10cSrcweir break; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir /* -----------------06.11.98 14:53------------------- 105*cdf0e10cSrcweir * 106*cdf0e10cSrcweir * --------------------------------------------------*/ 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this); 113*cdf0e10cSrcweir if (pModOpt->IsInsWithCaption(bWeb)) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId); 116*cdf0e10cSrcweir if (pOpt && pOpt->UseCaption() == sal_True) 117*cdf0e10cSrcweir InsertCaption(pOpt); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir /* -----------------06.11.98 12:58------------------- 122*cdf0e10cSrcweir * 123*cdf0e10cSrcweir * --------------------------------------------------*/ 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void SwView::InsertCaption(const InsCaptionOpt *pOpt) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir if (!pOpt) 128*cdf0e10cSrcweir return; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir const String &rName = pOpt->GetCategory(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // Existiert Pool-Vorlage gleichen Namens? 133*cdf0e10cSrcweir SwWrtShell &rSh = GetWrtShell(); 134*cdf0e10cSrcweir if(rName.Len()) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL); 137*cdf0e10cSrcweir if( USHRT_MAX != nPoolId ) 138*cdf0e10cSrcweir rSh.GetTxtCollFromPool(nPoolId); 139*cdf0e10cSrcweir // Pool-Vorlage existiert nicht: Existiert sie am Dokument? 140*cdf0e10cSrcweir else if( !rSh.GetParaStyle(rName) ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir // Sie existiert auch nicht am Dokument: erzeugen 143*cdf0e10cSrcweir SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL); 144*cdf0e10cSrcweir rSh.MakeTxtFmtColl(rName, pDerivedFrom); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir SelectionType eType = rSh.GetSelectionType(); 149*cdf0e10cSrcweir if (eType & nsSelectionType::SEL_OLE) 150*cdf0e10cSrcweir eType = nsSelectionType::SEL_GRF; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // SwLabelType 153*cdf0e10cSrcweir const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE : 154*cdf0e10cSrcweir eType & nsSelectionType::SEL_FRM ? LTYPE_FLY : 155*cdf0e10cSrcweir eType == nsSelectionType::SEL_TXT ? LTYPE_FLY : 156*cdf0e10cSrcweir eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW : 157*cdf0e10cSrcweir LTYPE_OBJECT; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir SwFldMgr aMgr(&rSh); 160*cdf0e10cSrcweir SwSetExpFieldType* pFldType = 161*cdf0e10cSrcweir (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName); 162*cdf0e10cSrcweir if (!pFldType && rName.Len() ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir // Neuen Feldtypen erzeugen 165*cdf0e10cSrcweir SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ); 166*cdf0e10cSrcweir aMgr.InsertFldType(aSwSetExpFieldType); 167*cdf0e10cSrcweir pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName); 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir if (!pOpt->IgnoreSeqOpts()) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir if (pFldType) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir pFldType->SetDelimiter(pOpt->GetSeparator()); 175*cdf0e10cSrcweir pFldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) ); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_uInt16 nID = USHRT_MAX; 180*cdf0e10cSrcweir SwFieldType* pType = 0; 181*cdf0e10cSrcweir const sal_uInt16 nCount = aMgr.GetFldTypeCount(); 182*cdf0e10cSrcweir if( rName.Len() ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount; ++i) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir pType = aMgr.GetFldType(USHRT_MAX, i); 187*cdf0e10cSrcweir String aTmpName( pType->GetName() ); 188*cdf0e10cSrcweir if (aTmpName == rName && pType->Which() == RES_SETEXPFLD) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir nID = i; 191*cdf0e10cSrcweir break; 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir rSh.StartAllAction(); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir GetWrtShell().InsertLabel( eT, 198*cdf0e10cSrcweir pOpt->GetCaption(), 199*cdf0e10cSrcweir !pOpt->IgnoreSeqOpts() ? aEmptyStr : pOpt->GetSeparator(), 200*cdf0e10cSrcweir pOpt->GetNumSeparator(), 201*cdf0e10cSrcweir !pOpt->GetPos(), 202*cdf0e10cSrcweir nID, 203*cdf0e10cSrcweir pOpt->GetCharacterStyle(), 204*cdf0e10cSrcweir pOpt->CopyAttributes() ); 205*cdf0e10cSrcweir // Nummernformat setzen 206*cdf0e10cSrcweir if(pType) 207*cdf0e10cSrcweir ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType()); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir rSh.UpdateExpFlds( sal_True ); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir rSh.EndAllAction(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir if ( rSh.IsFrmSelected() ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir GetEditWin().StopInsFrm(); 216*cdf0e10cSrcweir rSh.EnterSelFrmMode(); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // Kategorie merken 220*cdf0e10cSrcweir String** ppStr = 0; 221*cdf0e10cSrcweir if (eType & nsSelectionType::SEL_GRF) 222*cdf0e10cSrcweir ppStr = &pOldGrfCat; 223*cdf0e10cSrcweir else if( eType & nsSelectionType::SEL_TBL) 224*cdf0e10cSrcweir ppStr = &pOldTabCat; 225*cdf0e10cSrcweir else if( eType & nsSelectionType::SEL_FRM) 226*cdf0e10cSrcweir ppStr = &pOldFrmCat; 227*cdf0e10cSrcweir else if( eType == nsSelectionType::SEL_TXT) 228*cdf0e10cSrcweir ppStr = &pOldFrmCat; 229*cdf0e10cSrcweir else if( eType & nsSelectionType::SEL_DRW) 230*cdf0e10cSrcweir ppStr = &pOldDrwCat; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if( ppStr ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir if( !*ppStr ) 235*cdf0e10cSrcweir *ppStr = new String( rName ); 236*cdf0e10cSrcweir else 237*cdf0e10cSrcweir **ppStr = rName; 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir 242