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