1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sfx2/request.hxx>
#include <sfx2/objface.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdview.hxx>
#include <osl/diagnose.h>
#include <fldmgr.hxx>
#include <expfld.hxx>
#include <modcfg.hxx>
#include <swmodule.hxx>
#include <view.hxx>
#include <wview.hxx>
#include <wrtsh.hxx>
#include <cmdid.h>
#include <caption.hxx>
#include <poolfmt.hxx>
#include <edtwin.hxx>
#include <SwStyleNameMapper.hxx>
#include <swabstdlg.hxx>
#include <strings.hrc>
#include <memory>
#include <svl/stritem.hxx>
using namespace css;
void SwView::ExecDlgExt(SfxRequest const& rReq)
{
switch (rReq.GetSlot())
{
case FN_INSERT_CAPTION:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
VclPtr<VclAbstractDialog> pDialog(
pFact->CreateSwCaptionDialog(GetFrameWeld(), *this));
pDialog->StartExecuteAsync([pDialog](sal_Int32) {
pDialog->disposeOnce();
});
break;
}
case SID_INSERT_SIGNATURELINE:
case SID_EDIT_SIGNATURELINE:
{
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
ScopedVclPtr<AbstractSignatureLineDialog> pDialog(pFact->CreateSignatureLineDialog(
GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_SIGNATURELINE));
pDialog->Execute();
break;
}
case SID_INSERT_QRCODE:
case SID_EDIT_QRCODE:
{
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
VclPtr<AbstractQrCodeGenDialog> pDialog(pFact->CreateQrCodeGenDialog(
GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_QRCODE));
pDialog->StartExecuteAsync([pDialog](sal_Int32) {
pDialog->disposeOnce();
});
break;
}
case SID_ADDITIONS_DIALOG:
{
OUString sAdditionsTag = "";
const SfxStringItem* pStringArg = rReq.GetArg<SfxStringItem>(FN_PARAM_ADDITIONS_TAG);
if (pStringArg)
sAdditionsTag = pStringArg->GetValue();
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
ScopedVclPtr<AbstractAdditionsDialog> pDialog(
pFact->CreateAdditionsDialog(GetFrameWeld(), sAdditionsTag));
pDialog->Execute();
break;
}
case SID_SIGN_SIGNATURELINE:
{
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
ScopedVclPtr<AbstractSignSignatureLineDialog> pDialog(
pFact->CreateSignSignatureLineDialog(GetFrameWeld(), xModel));
pDialog->Execute();
break;
}
case FN_EDIT_FOOTNOTE:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
ScopedVclPtr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg(
GetFrameWeld(), *m_pWrtShell, true));
pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
pDlg->SetText( SwResId(STR_EDIT_FOOTNOTE) );
pDlg->Execute();
break;
}
}
}
bool SwView::isSignatureLineSelected() const
{
SwWrtShell& rSh = GetWrtShell();
SdrView* pSdrView = rSh.GetDrawView();
if (!pSdrView)
return false;
if (pSdrView->GetMarkedObjectCount() != 1)
return false;
SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
if (!pPickObj)
return false;
SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
if (!pGraphic)
return false;
return pGraphic->isSignatureLine();
}
bool SwView::isSignatureLineSigned() const
{
SwWrtShell& rSh = GetWrtShell();
SdrView* pSdrView = rSh.GetDrawView();
if (!pSdrView)
return false;
if (pSdrView->GetMarkedObjectCount() != 1)
return false;
SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
if (!pPickObj)
return false;
SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
if (!pGraphic)
return false;
return pGraphic->isSignatureLineSigned();
}
bool SwView::isQRCodeSelected() const
{
SwWrtShell& rSh = GetWrtShell();
SdrView* pSdrView = rSh.GetDrawView();
if (!pSdrView)
return false;
if (pSdrView->GetMarkedObjectCount() != 1)
return false;
SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
if (!pPickObj)
return false;
SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
if (!pGraphic)
return false;
return pGraphic->getQrCode() != nullptr;
}
void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
{
SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
bool bWeb = dynamic_cast<SwWebView*>( this ) != nullptr;
if (pModOpt->IsInsWithCaption(bWeb))
{
const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, static_cast<SwCapObjType>(nType), pOleId);
if (pOpt && pOpt->UseCaption())
InsertCaption(pOpt);
}
}
void SwView::InsertCaption(const InsCaptionOpt *pOpt)
{
if (!pOpt)
return;
const OUString &rName = pOpt->GetCategory();
// Is there a pool template with the same name?
SwWrtShell &rSh = GetWrtShell();
if(!rName.isEmpty())
{
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::TxtColl);
if( USHRT_MAX != nPoolId )
rSh.GetTextCollFromPool(nPoolId);
// Pool template does not exist: Does it exist on the document?
else if( !rSh.GetParaStyle(rName) )
{
// It also does not exist in the document: generate
SwTextFormatColl* pDerivedFrom = rSh.GetTextCollFromPool(RES_POOLCOLL_LABEL);
rSh.MakeTextFormatColl(rName, pDerivedFrom);
}
}
SelectionType eType = rSh.GetSelectionType();
if (eType & SelectionType::Ole)
eType = SelectionType::Graphic;
const SwLabelType eT = (eType & SelectionType::Table) ? SwLabelType::Table :
(eType & SelectionType::Frame) ? SwLabelType::Fly :
(eType == SelectionType::Text) ? SwLabelType::Fly :
(eType & SelectionType::DrawObject) ? SwLabelType::Draw :
SwLabelType::Object;
SwFieldMgr aMgr(&rSh);
SwSetExpFieldType* pFieldType =
static_cast<SwSetExpFieldType*>(aMgr.GetFieldType(SwFieldIds::SetExp, rName));
if (!pFieldType && !rName.isEmpty() )
{
// Create new field types
SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
aMgr.InsertFieldType(aSwSetExpFieldType);
pFieldType = static_cast<SwSetExpFieldType*>(aMgr.GetFieldType(SwFieldIds::SetExp, rName));
}
if (!pOpt->IgnoreSeqOpts())
{
if (pFieldType)
{
pFieldType->SetDelimiter(pOpt->GetSeparator());
pFieldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) );
}
}
sal_uInt16 nID = USHRT_MAX;
SwFieldType* pType = nullptr;
const size_t nCount = aMgr.GetFieldTypeCount();
if( !rName.isEmpty() )
{
for (size_t i = 0; i < nCount; ++i)
{
pType = aMgr.GetFieldType(SwFieldIds::Unknown, i);
OUString aTmpName( pType->GetName() );
if (aTmpName == rName && pType->Which() == SwFieldIds::SetExp)
{
nID = i;
OSL_ENSURE(nID==i, "Downcasting to sal_uInt16 lost information!");
break;
}
}
}
rSh.StartAllAction();
GetWrtShell().InsertLabel( eT,
pOpt->GetCaption(),
!pOpt->IgnoreSeqOpts() ? OUString() : pOpt->GetSeparator(),
pOpt->GetNumSeparator(),
!pOpt->GetPos(),
nID,
pOpt->GetCharacterStyle(),
pOpt->CopyAttributes() );
// Set Number Format
if(pType)
static_cast<SwSetExpFieldType*>(pType)->SetSeqFormat(pOpt->GetNumType());
rSh.UpdateExpFields( true );
rSh.EndAllAction();
if ( rSh.IsFrameSelected() )
{
GetEditWin().StopInsFrame();
rSh.EnterSelFrameMode();
}
// remember category
if (eType & SelectionType::Graphic)
SetOldGrfCat(rName);
else if( eType & SelectionType::Table)
SetOldTabCat(rName);
else if( eType & SelectionType::Frame)
SetOldFrameCat(rName);
else if( eType == SelectionType::Text)
SetOldFrameCat(rName);
else if( eType & SelectionType::DrawObject)
SetOldDrwCat(rName);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|