update dev300-m58
[ooovba.git] / sw / source / ui / uiview / viewdlg2.cxx
blobbc772202ce28cf444fa62aa2290038cb106186fc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewdlg2.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <sfx2/request.hxx>
36 #include <sfx2/viewfrm.hxx>
39 #include <fldmgr.hxx>
40 #include <expfld.hxx>
41 #include <modcfg.hxx>
43 #include <tools/shl.hxx>
45 #include "swmodule.hxx"
46 #include "view.hxx"
47 #include "wview.hxx"
48 #include "wrtsh.hxx"
49 #include "cmdid.h"
50 #include "caption.hxx"
51 #include "poolfmt.hxx"
52 #include "edtwin.hxx"
53 #include <SwStyleNameMapper.hxx>
55 #include "swabstdlg.hxx"
56 #include "frmui.hrc"
57 #include "misc.hrc"
59 #include "view.hrc"
61 extern String* pOldGrfCat;
62 extern String* pOldTabCat;
63 extern String* pOldFrmCat;
64 extern String* pOldDrwCat;
66 /* -----------------06.11.98 13:45-------------------
68 * --------------------------------------------------*/
70 void SwView::ExecDlgExt(SfxRequest &rReq)
72 Window *pMDI = &GetViewFrame()->GetWindow();
74 switch ( rReq.GetSlot() )
76 case FN_INSERT_CAPTION:
78 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
79 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
81 VclAbstractDialog* pDialog = pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION );
82 DBG_ASSERT(pDialog, "Dialogdiet fail!");
83 if ( pDialog )
85 pDialog->Execute();
86 delete pDialog;
88 break;
90 case FN_EDIT_FOOTNOTE:
92 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
93 DBG_ASSERT(pFact, "Dialogdiet fail!");
94 AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE,
95 pMDI, *pWrtShell, TRUE );
96 DBG_ASSERT(pDlg, "Dialogdiet fail!");
98 pDlg->SetHelpId(FN_EDIT_FOOTNOTE);
99 pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
100 pDlg->Execute();
101 delete pDlg;
102 break;
107 /* -----------------06.11.98 14:53-------------------
109 * --------------------------------------------------*/
111 void SwView::AutoCaption(const USHORT nType, const SvGlobalName *pOleId)
113 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
115 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
116 if (pModOpt->IsInsWithCaption(bWeb))
118 const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId);
119 if (pOpt && pOpt->UseCaption() == TRUE)
120 InsertCaption(pOpt);
124 /* -----------------06.11.98 12:58-------------------
126 * --------------------------------------------------*/
128 void SwView::InsertCaption(const InsCaptionOpt *pOpt)
130 if (!pOpt)
131 return;
133 const String &rName = pOpt->GetCategory();
135 // Existiert Pool-Vorlage gleichen Namens?
136 SwWrtShell &rSh = GetWrtShell();
137 if(rName.Len())
139 USHORT nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
140 if( USHRT_MAX != nPoolId )
141 rSh.GetTxtCollFromPool(nPoolId);
142 // Pool-Vorlage existiert nicht: Existiert sie am Dokument?
143 else if( !rSh.GetParaStyle(rName) )
145 // Sie existiert auch nicht am Dokument: erzeugen
146 SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL);
147 rSh.MakeTxtFmtColl(rName, pDerivedFrom);
151 SelectionType eType = rSh.GetSelectionType();
152 if (eType & nsSelectionType::SEL_OLE)
153 eType = nsSelectionType::SEL_GRF;
155 // SwLabelType
156 const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE :
157 eType & nsSelectionType::SEL_FRM ? LTYPE_FLY :
158 eType == nsSelectionType::SEL_TXT ? LTYPE_FLY :
159 eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW :
160 LTYPE_OBJECT;
162 SwFldMgr aMgr(&rSh);
163 SwSetExpFieldType* pFldType =
164 (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
165 if (!pFldType && rName.Len() )
167 // Neuen Feldtypen erzeugen
168 SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
169 aMgr.InsertFldType(aSwSetExpFieldType);
170 pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
173 if (!pOpt->IgnoreSeqOpts())
175 if (pFldType)
177 pFldType->SetDelimiter(pOpt->GetSeparator());
178 pFldType->SetOutlineLvl( static_cast< BYTE >(pOpt->GetLevel()) );
182 USHORT nID = USHRT_MAX;
183 SwFieldType* pType = 0;
184 const USHORT nCount = aMgr.GetFldTypeCount();
185 if( rName.Len() )
187 for (USHORT i = 0; i < nCount; ++i)
189 pType = aMgr.GetFldType(USHRT_MAX, i);
190 String aTmpName( pType->GetName() );
191 if (aTmpName == rName && pType->Which() == RES_SETEXPFLD)
193 nID = i;
194 break;
198 rSh.StartAllAction();
200 GetWrtShell().InsertLabel( eT,
201 pOpt->GetCaption(),
202 !pOpt->IgnoreSeqOpts() ? aEmptyStr : pOpt->GetSeparator(),
203 pOpt->GetNumSeparator(),
204 !pOpt->GetPos(),
205 nID,
206 pOpt->GetCharacterStyle(),
207 pOpt->CopyAttributes() );
208 // Nummernformat setzen
209 if(pType)
210 ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType());
212 rSh.UpdateExpFlds( TRUE );
214 rSh.EndAllAction();
216 if ( rSh.IsFrmSelected() )
218 GetEditWin().StopInsFrm();
219 rSh.EnterSelFrmMode();
222 // Kategorie merken
223 String** ppStr = 0;
224 if (eType & nsSelectionType::SEL_GRF)
225 ppStr = &pOldGrfCat;
226 else if( eType & nsSelectionType::SEL_TBL)
227 ppStr = &pOldTabCat;
228 else if( eType & nsSelectionType::SEL_FRM)
229 ppStr = &pOldFrmCat;
230 else if( eType == nsSelectionType::SEL_TXT)
231 ppStr = &pOldFrmCat;
232 else if( eType & nsSelectionType::SEL_DRW)
233 ppStr = &pOldDrwCat;
235 if( ppStr )
237 if( !*ppStr )
238 *ppStr = new String( rName );
239 else
240 **ppStr = rName;