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 .
20 #include <sfx2/request.hxx>
21 #include <sfx2/viewfrm.hxx>
22 #include <sfx2/objface.hxx>
23 #include <svx/svdograf.hxx>
28 #include <swmodule.hxx>
33 #include <caption.hxx>
34 #include <poolfmt.hxx>
36 #include <SwStyleNameMapper.hxx>
39 #include <swabstdlg.hxx>
41 #include <strings.hrc>
47 void SwView::ExecDlgExt(SfxRequest
const &rReq
)
49 vcl::Window
& rMDI
= GetViewFrame()->GetWindow();
51 switch ( rReq
.GetSlot() )
53 case FN_INSERT_CAPTION
:
55 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
56 assert(pFact
&& "SwAbstractDialogFactory fail!");
58 ScopedVclPtr
<VclAbstractDialog
> pDialog(pFact
->CreateSwCaptionDialog( &rMDI
, *this ));
59 assert(pDialog
&& "Dialog creation failed!");
66 case SID_INSERT_SIGNATURELINE
:
67 case SID_EDIT_SIGNATURELINE
:
69 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
70 assert(pFact
&& "VclAbstractDialogFactory fail!");
72 const uno::Reference
<frame::XModel
> xModel(GetCurrentDocument());
73 ScopedVclPtr
<AbstractSignatureLineDialog
> pDialog(pFact
->CreateSignatureLineDialog(
74 GetFrameWeld(), xModel
, rReq
.GetSlot() == SID_EDIT_SIGNATURELINE
));
75 assert(pDialog
&& "Dialog creation failed!");
81 case SID_SIGN_SIGNATURELINE
:
83 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
84 assert(pFact
&& "VclAbstractDialogFactory fail!");
86 const uno::Reference
<frame::XModel
> xModel(GetCurrentDocument());
87 VclPtr
<AbstractSignSignatureLineDialog
> pDialog
88 = pFact
->CreateSignSignatureLineDialog(GetFrameWeld(), xModel
);
89 assert(pDialog
&& "Dialog creation failed!");
95 case FN_EDIT_FOOTNOTE
:
97 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
98 assert(pFact
&& "Dialog creation failed!");
99 ScopedVclPtr
<AbstractInsFootNoteDlg
> pDlg(pFact
->CreateInsFootNoteDlg(
100 GetFrameWeld(), *m_pWrtShell
, true));
101 assert(pDlg
&& "Dialog creation failed!");
103 pDlg
->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE
)->GetCommand());
104 pDlg
->SetText( SwResId(STR_EDIT_FOOTNOTE
) );
111 bool SwView::isSignatureLineSelected()
113 SwWrtShell
& rSh
= GetWrtShell();
114 SdrView
* pSdrView
= rSh
.GetDrawView();
118 if (pSdrView
->GetMarkedObjectCount() != 1)
121 SdrObject
* pPickObj
= pSdrView
->GetMarkedObjectByIndex(0);
125 SdrGrafObj
* pGraphic
= dynamic_cast<SdrGrafObj
*>(pPickObj
);
129 return pGraphic
->isSignatureLine();
132 void SwView::AutoCaption(const sal_uInt16 nType
, const SvGlobalName
*pOleId
)
134 SwModuleOptions
* pModOpt
= SW_MOD()->GetModuleConfig();
136 bool bWeb
= dynamic_cast<SwWebView
*>( this ) != nullptr;
137 if (pModOpt
->IsInsWithCaption(bWeb
))
139 const InsCaptionOpt
*pOpt
= pModOpt
->GetCapOption(bWeb
, static_cast<SwCapObjType
>(nType
), pOleId
);
140 if (pOpt
&& pOpt
->UseCaption())
145 void SwView::InsertCaption(const InsCaptionOpt
*pOpt
)
150 const OUString
&rName
= pOpt
->GetCategory();
152 // Is there a pool template with the same name?
153 SwWrtShell
&rSh
= GetWrtShell();
156 sal_uInt16 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, SwGetPoolIdFromName::TxtColl
);
157 if( USHRT_MAX
!= nPoolId
)
158 rSh
.GetTextCollFromPool(nPoolId
);
159 // Pool template does not exist: Does it exist on the document?
160 else if( !rSh
.GetParaStyle(rName
) )
162 // It also does not exist in the document: generate
163 SwTextFormatColl
* pDerivedFrom
= rSh
.GetTextCollFromPool(RES_POOLCOLL_LABEL
);
164 rSh
.MakeTextFormatColl(rName
, pDerivedFrom
);
168 SelectionType eType
= rSh
.GetSelectionType();
169 if (eType
& SelectionType::Ole
)
170 eType
= SelectionType::Graphic
;
172 const SwLabelType eT
= (eType
& SelectionType::Table
) ? LTYPE_TABLE
:
173 (eType
& SelectionType::Frame
) ? LTYPE_FLY
:
174 (eType
== SelectionType::Text
) ? LTYPE_FLY
:
175 (eType
& SelectionType::DrawObject
) ? LTYPE_DRAW
:
178 SwFieldMgr
aMgr(&rSh
);
179 SwSetExpFieldType
* pFieldType
=
180 static_cast<SwSetExpFieldType
*>(aMgr
.GetFieldType(SwFieldIds::SetExp
, rName
));
181 if (!pFieldType
&& !rName
.isEmpty() )
183 // Create new field types
184 SwSetExpFieldType
aSwSetExpFieldType(rSh
.GetDoc(), rName
, nsSwGetSetExpType::GSE_SEQ
);
185 aMgr
.InsertFieldType(aSwSetExpFieldType
);
186 pFieldType
= static_cast<SwSetExpFieldType
*>(aMgr
.GetFieldType(SwFieldIds::SetExp
, rName
));
189 if (!pOpt
->IgnoreSeqOpts())
193 pFieldType
->SetDelimiter(pOpt
->GetSeparator());
194 pFieldType
->SetOutlineLvl( static_cast< sal_uInt8
>(pOpt
->GetLevel()) );
198 sal_uInt16 nID
= USHRT_MAX
;
199 SwFieldType
* pType
= nullptr;
200 const size_t nCount
= aMgr
.GetFieldTypeCount();
201 if( !rName
.isEmpty() )
203 for (size_t i
= 0; i
< nCount
; ++i
)
205 pType
= aMgr
.GetFieldType(SwFieldIds::Unknown
, i
);
206 OUString
aTmpName( pType
->GetName() );
207 if (aTmpName
== rName
&& pType
->Which() == SwFieldIds::SetExp
)
210 OSL_ENSURE(nID
==i
, "Downcasting to sal_uInt16 lost information!");
215 rSh
.StartAllAction();
217 GetWrtShell().InsertLabel( eT
,
219 !pOpt
->IgnoreSeqOpts() ? OUString() : pOpt
->GetSeparator(),
220 pOpt
->GetNumSeparator(),
223 pOpt
->GetCharacterStyle(),
224 pOpt
->CopyAttributes() );
227 static_cast<SwSetExpFieldType
*>(pType
)->SetSeqFormat(pOpt
->GetNumType());
229 rSh
.UpdateExpFields( true );
233 if ( rSh
.IsFrameSelected() )
235 GetEditWin().StopInsFrame();
236 rSh
.EnterSelFrameMode();
240 if (eType
& SelectionType::Graphic
)
242 else if( eType
& SelectionType::Table
)
244 else if( eType
& SelectionType::Frame
)
245 SetOldFrameCat(rName
);
246 else if( eType
== SelectionType::Text
)
247 SetOldFrameCat(rName
);
248 else if( eType
& SelectionType::DrawObject
)
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */