1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <sfx2/request.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <sfx2/objface.hxx>
28 #include <tools/shl.hxx>
30 #include "swmodule.hxx"
35 #include "caption.hxx"
36 #include "poolfmt.hxx"
38 #include <SwStyleNameMapper.hxx>
40 #include "swabstdlg.hxx"
46 extern String
* pOldGrfCat
;
47 extern String
* pOldTabCat
;
48 extern String
* pOldFrmCat
;
49 extern String
* pOldDrwCat
;
51 void SwView::ExecDlgExt(SfxRequest
&rReq
)
53 Window
*pMDI
= &GetViewFrame()->GetWindow();
55 switch ( rReq
.GetSlot() )
57 case FN_INSERT_CAPTION
:
59 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
60 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
62 VclAbstractDialog
* pDialog
= pFact
->CreateSwCaptionDialog( pMDI
, *this, DLG_CAPTION
);
63 OSL_ENSURE(pDialog
, "Dialogdiet fail!");
71 case FN_EDIT_FOOTNOTE
:
73 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
74 OSL_ENSURE(pFact
, "Dialogdiet fail!");
75 AbstractInsFootNoteDlg
* pDlg
= pFact
->CreateInsFootNoteDlg(
76 pMDI
, *m_pWrtShell
, sal_True
);
77 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
79 pDlg
->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE
)->GetCommand());
80 pDlg
->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE
) );
88 void SwView::AutoCaption(const sal_uInt16 nType
, const SvGlobalName
*pOleId
)
90 SwModuleOptions
* pModOpt
= SW_MOD()->GetModuleConfig();
92 sal_Bool bWeb
= 0 != PTR_CAST(SwWebView
, this);
93 if (pModOpt
->IsInsWithCaption(bWeb
))
95 const InsCaptionOpt
*pOpt
= pModOpt
->GetCapOption(bWeb
, (SwCapObjType
)nType
, pOleId
);
96 if (pOpt
&& pOpt
->UseCaption() == sal_True
)
101 void SwView::InsertCaption(const InsCaptionOpt
*pOpt
)
106 const String
&rName
= pOpt
->GetCategory();
108 // Existiert Pool-Vorlage gleichen Namens?
109 SwWrtShell
&rSh
= GetWrtShell();
112 sal_uInt16 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
113 if( USHRT_MAX
!= nPoolId
)
114 rSh
.GetTxtCollFromPool(nPoolId
);
115 // Pool-Vorlage existiert nicht: Existiert sie am Dokument?
116 else if( !rSh
.GetParaStyle(rName
) )
118 // Sie existiert auch nicht am Dokument: erzeugen
119 SwTxtFmtColl
* pDerivedFrom
= rSh
.GetTxtCollFromPool(RES_POOLCOLL_LABEL
);
120 rSh
.MakeTxtFmtColl(rName
, pDerivedFrom
);
124 SelectionType eType
= rSh
.GetSelectionType();
125 if (eType
& nsSelectionType::SEL_OLE
)
126 eType
= nsSelectionType::SEL_GRF
;
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
:
136 SwSetExpFieldType
* pFldType
=
137 (SwSetExpFieldType
*)aMgr
.GetFldType(RES_SETEXPFLD
, rName
);
138 if (!pFldType
&& rName
.Len() )
140 // Neuen Feldtypen erzeugen
141 SwSetExpFieldType
aSwSetExpFieldType(rSh
.GetDoc(), rName
, nsSwGetSetExpType::GSE_SEQ
);
142 aMgr
.InsertFldType(aSwSetExpFieldType
);
143 pFldType
= (SwSetExpFieldType
*)aMgr
.GetFldType(RES_SETEXPFLD
, rName
);
146 if (!pOpt
->IgnoreSeqOpts())
150 pFldType
->SetDelimiter(pOpt
->GetSeparator());
151 pFldType
->SetOutlineLvl( static_cast< sal_uInt8
>(pOpt
->GetLevel()) );
155 sal_uInt16 nID
= USHRT_MAX
;
156 SwFieldType
* pType
= 0;
157 const sal_uInt16 nCount
= aMgr
.GetFldTypeCount();
160 for (sal_uInt16 i
= 0; i
< nCount
; ++i
)
162 pType
= aMgr
.GetFldType(USHRT_MAX
, i
);
163 String
aTmpName( pType
->GetName() );
164 if (aTmpName
== rName
&& pType
->Which() == RES_SETEXPFLD
)
171 rSh
.StartAllAction();
173 GetWrtShell().InsertLabel( eT
,
175 !pOpt
->IgnoreSeqOpts() ? aEmptyStr
: pOpt
->GetSeparator(),
176 pOpt
->GetNumSeparator(),
179 pOpt
->GetCharacterStyle(),
180 pOpt
->CopyAttributes() );
181 // Nummernformat setzen
183 ((SwSetExpFieldType
*)pType
)->SetSeqFormat(pOpt
->GetNumType());
185 rSh
.UpdateExpFlds( sal_True
);
189 if ( rSh
.IsFrmSelected() )
191 GetEditWin().StopInsFrm();
192 rSh
.EnterSelFrmMode();
197 if (eType
& nsSelectionType::SEL_GRF
)
199 else if( eType
& nsSelectionType::SEL_TBL
)
201 else if( eType
& nsSelectionType::SEL_FRM
)
203 else if( eType
== nsSelectionType::SEL_TXT
)
205 else if( eType
& nsSelectionType::SEL_DRW
)
211 *ppStr
= new String( rName
);
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */