1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewdlg2.cxx,v $
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>
43 #include <tools/shl.hxx>
45 #include "swmodule.hxx"
50 #include "caption.hxx"
51 #include "poolfmt.hxx"
53 #include <SwStyleNameMapper.hxx>
55 #include "swabstdlg.hxx"
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!");
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
) );
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
)
124 /* -----------------06.11.98 12:58-------------------
126 * --------------------------------------------------*/
128 void SwView::InsertCaption(const InsCaptionOpt
*pOpt
)
133 const String
&rName
= pOpt
->GetCategory();
135 // Existiert Pool-Vorlage gleichen Namens?
136 SwWrtShell
&rSh
= GetWrtShell();
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
;
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
:
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())
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();
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
)
198 rSh
.StartAllAction();
200 GetWrtShell().InsertLabel( eT
,
202 !pOpt
->IgnoreSeqOpts() ? aEmptyStr
: pOpt
->GetSeparator(),
203 pOpt
->GetNumSeparator(),
206 pOpt
->GetCharacterStyle(),
207 pOpt
->CopyAttributes() );
208 // Nummernformat setzen
210 ((SwSetExpFieldType
*)pType
)->SetSeqFormat(pOpt
->GetNumType());
212 rSh
.UpdateExpFlds( TRUE
);
216 if ( rSh
.IsFrmSelected() )
218 GetEditWin().StopInsFrm();
219 rSh
.EnterSelFrmMode();
224 if (eType
& nsSelectionType::SEL_GRF
)
226 else if( eType
& nsSelectionType::SEL_TBL
)
228 else if( eType
& nsSelectionType::SEL_FRM
)
230 else if( eType
== nsSelectionType::SEL_TXT
)
232 else if( eType
& nsSelectionType::SEL_DRW
)
238 *ppStr
= new String( rName
);