LibreOffice Module sw (master) 1
viewdlg2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sfx2/request.hxx>
21#include <sfx2/objface.hxx>
22#include <svx/svdograf.hxx>
23#include <svx/svdview.hxx>
24#include <osl/diagnose.h>
25#include <fldmgr.hxx>
26#include <expfld.hxx>
27#include <modcfg.hxx>
28
29#include <swmodule.hxx>
30#include <view.hxx>
31#include <wview.hxx>
32#include <wrtsh.hxx>
33#include <cmdid.h>
34#include <caption.hxx>
35#include <poolfmt.hxx>
36#include <edtwin.hxx>
37#include <SwStyleNameMapper.hxx>
38
39#include <swabstdlg.hxx>
40
41#include <strings.hrc>
42
43#include <memory>
44
45#include <svl/stritem.hxx>
46
47using namespace css;
48
50{
51 switch (rReq.GetSlot())
52 {
54 {
57 pFact->CreateSwCaptionDialog(GetFrameWeld(), *this));
58 pDialog->StartExecuteAsync([pDialog](sal_Int32) {
59 pDialog->disposeOnce();
60 });
61 break;
62 }
63 case SID_INSERT_SIGNATURELINE:
64 case SID_EDIT_SIGNATURELINE:
65 {
67 const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
69 GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_SIGNATURELINE));
70 pDialog->Execute();
71 break;
72 }
73 case SID_INSERT_QRCODE:
74 case SID_EDIT_QRCODE:
75 {
77 const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
79 GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_QRCODE));
80 pDialog->Execute();
81 break;
82 }
83 case SID_ADDITIONS_DIALOG:
84 {
85 OUString sAdditionsTag = "";
86
87 const SfxStringItem* pStringArg = rReq.GetArg<SfxStringItem>(FN_PARAM_ADDITIONS_TAG);
88 if (pStringArg)
89 sAdditionsTag = pStringArg->GetValue();
90
93 pFact->CreateAdditionsDialog(GetFrameWeld(), sAdditionsTag));
94 pDialog->Execute();
95 break;
96 }
97 case SID_SIGN_SIGNATURELINE:
98 {
100 const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
103 pDialog->Execute();
104 break;
105 }
106 case FN_EDIT_FOOTNOTE:
107 {
110 GetFrameWeld(), *m_pWrtShell, true));
111
112 pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
113 pDlg->SetText( SwResId(STR_EDIT_FOOTNOTE) );
114 pDlg->Execute();
115 break;
116 }
117 }
118}
119
121{
122 SwWrtShell& rSh = GetWrtShell();
123 SdrView* pSdrView = rSh.GetDrawView();
124 if (!pSdrView)
125 return false;
126
127 if (pSdrView->GetMarkedObjectCount() != 1)
128 return false;
129
130 SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
131 if (!pPickObj)
132 return false;
133
134 SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
135 if (!pGraphic)
136 return false;
137
138 return pGraphic->isSignatureLine();
139}
140
142{
143 SwWrtShell& rSh = GetWrtShell();
144 SdrView* pSdrView = rSh.GetDrawView();
145 if (!pSdrView)
146 return false;
147
148 if (pSdrView->GetMarkedObjectCount() != 1)
149 return false;
150
151 SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
152 if (!pPickObj)
153 return false;
154
155 SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
156 if (!pGraphic)
157 return false;
158
159 return pGraphic->isSignatureLineSigned();
160}
161
163{
164 SwWrtShell& rSh = GetWrtShell();
165 SdrView* pSdrView = rSh.GetDrawView();
166 if (!pSdrView)
167 return false;
168
169 if (pSdrView->GetMarkedObjectCount() != 1)
170 return false;
171
172 SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
173 if (!pPickObj)
174 return false;
175
176 SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
177 if (!pGraphic)
178 return false;
179
180 return pGraphic->getQrCode() != nullptr;
181}
182
183void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
184{
185 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
186
187 bool bWeb = dynamic_cast<SwWebView*>( this ) != nullptr;
188 if (pModOpt->IsInsWithCaption(bWeb))
189 {
190 const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, static_cast<SwCapObjType>(nType), pOleId);
191 if (pOpt && pOpt->UseCaption())
192 InsertCaption(pOpt);
193 }
194}
195
197{
198 if (!pOpt)
199 return;
200
201 const OUString &rName = pOpt->GetCategory();
202
203 // Is there a pool template with the same name?
204 SwWrtShell &rSh = GetWrtShell();
205 if(!rName.isEmpty())
206 {
208 if( USHRT_MAX != nPoolId )
209 rSh.GetTextCollFromPool(nPoolId);
210 // Pool template does not exist: Does it exist on the document?
211 else if( !rSh.GetParaStyle(rName) )
212 {
213 // It also does not exist in the document: generate
215 rSh.MakeTextFormatColl(rName, pDerivedFrom);
216 }
217 }
218
222
228
229 SwFieldMgr aMgr(&rSh);
230 SwSetExpFieldType* pFieldType =
231 static_cast<SwSetExpFieldType*>(aMgr.GetFieldType(SwFieldIds::SetExp, rName));
232 if (!pFieldType && !rName.isEmpty() )
233 {
234 // Create new field types
235 SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
236 aMgr.InsertFieldType(aSwSetExpFieldType);
237 pFieldType = static_cast<SwSetExpFieldType*>(aMgr.GetFieldType(SwFieldIds::SetExp, rName));
238 }
239
240 if (!pOpt->IgnoreSeqOpts())
241 {
242 if (pFieldType)
243 {
244 pFieldType->SetDelimiter(pOpt->GetSeparator());
245 pFieldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) );
246 }
247 }
248
249 sal_uInt16 nID = USHRT_MAX;
250 SwFieldType* pType = nullptr;
251 const size_t nCount = aMgr.GetFieldTypeCount();
252 if( !rName.isEmpty() )
253 {
254 for (size_t i = 0; i < nCount; ++i)
255 {
256 pType = aMgr.GetFieldType(SwFieldIds::Unknown, i);
257 OUString aTmpName( pType->GetName() );
258 if (aTmpName == rName && pType->Which() == SwFieldIds::SetExp)
259 {
260 nID = i;
261 OSL_ENSURE(nID==i, "Downcasting to sal_uInt16 lost information!");
262 break;
263 }
264 }
265 }
266 rSh.StartAllAction();
267
269 pOpt->GetCaption(),
270 !pOpt->IgnoreSeqOpts() ? OUString() : pOpt->GetSeparator(),
271 pOpt->GetNumSeparator(),
272 !pOpt->GetPos(),
273 nID,
274 pOpt->GetCharacterStyle(),
275 pOpt->CopyAttributes() );
276 // Set Number Format
277 if(pType)
278 static_cast<SwSetExpFieldType*>(pType)->SetSeqFormat(pOpt->GetNumType());
279
280 rSh.UpdateExpFields( true );
281
282 rSh.EndAllAction();
283
284 if ( rSh.IsFrameSelected() )
285 {
287 rSh.EnterSelFrameMode();
288 }
289
290 // remember category
292 SetOldGrfCat(rName);
293 else if( eType & SelectionType::Table)
294 SetOldTabCat(rName);
295 else if( eType & SelectionType::Frame)
296 SetOldFrameCat(rName);
297 else if( eType == SelectionType::Text)
298 SetOldFrameCat(rName);
300 SetOldDrwCat(rName);
301}
302
303/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwCapObjType
const OUString & GetValue() const
const OUString & GetCategory() const
Definition: caption.hxx:55
const OUString & GetNumSeparator() const
Definition: caption.hxx:61
sal_uInt16 GetPos() const
Definition: caption.hxx:67
bool & UseCaption()
Definition: caption.hxx:48
const OUString & GetCharacterStyle() const
Definition: caption.hxx:76
sal_uInt16 GetNumType() const
Definition: caption.hxx:58
bool & CopyAttributes()
Definition: caption.hxx:83
const OUString & GetCaption() const
Definition: caption.hxx:64
const OUString & GetSeparator() const
Definition: caption.hxx:73
bool & IgnoreSeqOpts()
Definition: caption.hxx:80
sal_uInt16 GetLevel() const
Definition: caption.hxx:70
bool isSignatureLineSigned() const
bool isSignatureLine() const
css::drawing::BarCode * getQrCode() const
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
size_t GetMarkedObjectCount() const
sal_uInt16 GetSlot() const
const T * GetArg(sal_uInt16 nSlotId) const
static SfxInterface * GetStaticInterface()
weld::Window * GetFrameWeld() const
virtual css::uno::Reference< css::frame::XModel > GetCurrentDocument() const
virtual VclPtr< AbstractInsFootNoteDlg > CreateInsFootNoteDlg(weld::Window *pParent, SwWrtShell &rSh, bool bEd=false)=0
virtual VclPtr< VclAbstractDialog > CreateSwCaptionDialog(weld::Window *pParent, SwView &rV)=0
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:121
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
Definition: edfld.cxx:315
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatCollName, SwTextFormatColl *pDerivedFrom=nullptr)
Definition: edfcol.cxx:2271
void EndAllAction()
Definition: edws.cxx:97
void StopInsFrame()
Definition: edtwin.cxx:761
bool IsFrameSelected() const
Definition: feshview.cxx:1133
void InsertLabel(const SwLabelType eType, const OUString &rText, const OUString &rSeparator, const OUString &rNumberSeparator, const bool bBefore, const sal_uInt16 nId, const OUString &rCharacterStyle, const bool bCpyBrd)
Definition: fews.cxx:421
void InsertFieldType(SwFieldType const &rType)
Definition: fldmgr.cxx:880
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
Definition: fldmgr.cxx:415
size_t GetFieldTypeCount() const
Definition: fldmgr.cxx:408
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:139
SwFieldIds Which() const
Definition: fldbas.hxx:276
const InsCaptionOpt * GetCapOption(bool bHTML, const SwCapObjType eType, const SvGlobalName *pOleId)
Definition: modcfg.cxx:61
bool IsInsWithCaption(bool bHTML) const
Definition: modcfg.hxx:265
void SetOutlineLvl(sal_uInt8 n)
Definition: expfld.hxx:184
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:182
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
SdrView * GetDrawView()
Definition: vnew.cxx:386
void AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId=nullptr)
Definition: viewdlg2.cxx:183
SwWrtShell & GetWrtShell() const
Definition: view.hxx:423
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:194
void SetOldDrwCat(const OUString &sStr)
Definition: view2.cxx:3168
void SetOldFrameCat(const OUString &sStr)
Definition: view2.cxx:3158
bool isSignatureLineSigned() const
Definition: viewdlg2.cxx:141
bool isSignatureLineSelected() const
Definition: viewdlg2.cxx:120
void ExecDlgExt(SfxRequest const &)
Definition: viewdlg2.cxx:49
bool isQRCodeSelected() const
Definition: viewdlg2.cxx:162
SwEditWin & GetEditWin()
Definition: view.hxx:426
void SetOldTabCat(const OUString &sStr)
Definition: view2.cxx:3148
void SetOldGrfCat(const OUString &sStr)
Definition: view2.cxx:3138
void InsertCaption(const InsCaptionOpt *pOpt)
Definition: viewdlg2.cxx:196
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void EnterSelFrameMode(const Point *pStartDrag=nullptr)
Definition: select.cxx:711
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1723
SwTextFormatColl * GetParaStyle(const OUString &rCollName, GetStyle eCreate=GETSTYLE_NOCREATE)
Definition: wrtsh1.cxx:1823
virtual VclPtr< AbstractSignSignatureLineDialog > CreateSignSignatureLineDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XModel > xModel)=0
virtual VclPtr< AbstractSignatureLineDialog > CreateSignatureLineDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XModel > xModel, bool bEditExisting)=0
static VclAbstractDialogFactory * Create()
virtual VclPtr< AbstractAdditionsDialog > CreateAdditionsDialog(weld::Window *pParent, const OUString &sAdditionsTag)=0
virtual VclPtr< AbstractQrCodeGenDialog > CreateQrCodeGenDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XModel > xModel, bool bEditExisting)=0
#define FN_INSERT_CAPTION
Definition: cmdid.h:214
#define FN_EDIT_FOOTNOTE
Definition: cmdid.h:115
int nCount
DocumentType eType
SelectionType
int i
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:209
@ RES_POOLCOLL_LABEL
Subgroup labels.
Definition: poolfmt.hxx:345
QPRO_FUNC_TYPE nType
Reference< XModel > xModel
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
#define SW_MOD()
Definition: swmodule.hxx:254
SwLabelType
Definition: swtypes.hxx:85
unsigned char sal_uInt8