File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 <config_features.h> | |||
21 | ||||
22 | #include <avmedia/mediaplayer.hxx> | |||
23 | ||||
24 | #include <basic/sberrors.hxx> | |||
25 | #include <basic/sbstar.hxx> | |||
26 | ||||
27 | #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> | |||
28 | #include <com/sun/star/drawing/XDrawPages.hpp> | |||
29 | #include <com/sun/star/lang/XInitialization.hpp> | |||
30 | #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> | |||
31 | #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp> | |||
32 | #include <com/sun/star/frame/XDispatchProvider.hpp> | |||
33 | #include <com/sun/star/util/URLTransformer.hpp> | |||
34 | #include <com/sun/star/util/XURLTransformer.hpp> | |||
35 | #include <com/sun/star/scanner/XScannerManager2.hpp> | |||
36 | #include <com/sun/star/document/XDocumentProperties.hpp> | |||
37 | ||||
38 | #include <comphelper/processfactory.hxx> | |||
39 | #include <comphelper/propertysequence.hxx> | |||
40 | #include <comphelper/scopeguard.hxx> | |||
41 | #include <comphelper/lok.hxx> | |||
42 | ||||
43 | #include <editeng/contouritem.hxx> | |||
44 | #include <editeng/editdata.hxx> | |||
45 | #include <editeng/eeitem.hxx> | |||
46 | #include <editeng/flditem.hxx> | |||
47 | #include <editeng/section.hxx> | |||
48 | #include <editeng/editobj.hxx> | |||
49 | #include <editeng/CustomPropertyField.hxx> | |||
50 | #include <editeng/urlfieldhelper.hxx> | |||
51 | ||||
52 | #include <sal/log.hxx> | |||
53 | ||||
54 | #include <sfx2/bindings.hxx> | |||
55 | #include <sfx2/dispatch.hxx> | |||
56 | #include <sfx2/docfile.hxx> | |||
57 | #include <sfx2/msgpool.hxx> | |||
58 | #include <sfx2/msg.hxx> | |||
59 | #include <sfx2/request.hxx> | |||
60 | #include <sfx2/viewfrm.hxx> | |||
61 | #include <sfx2/zoomitem.hxx> | |||
62 | ||||
63 | #include <svx/compressgraphicdialog.hxx> | |||
64 | #include <svx/ClassificationDialog.hxx> | |||
65 | #include <svx/ClassificationCommon.hxx> | |||
66 | #include <svx/bmpmask.hxx> | |||
67 | #include <svx/extedit.hxx> | |||
68 | #include <svx/extrusionbar.hxx> | |||
69 | #include <svx/f3dchild.hxx> | |||
70 | #include <svx/fontwork.hxx> | |||
71 | #include <svx/fontworkbar.hxx> | |||
72 | #include <svx/graphichelper.hxx> | |||
73 | #include <svx/hlnkitem.hxx> | |||
74 | #include <svx/imapdlg.hxx> | |||
75 | #include <svx/sdtagitm.hxx> | |||
76 | #include <svx/svdograf.hxx> | |||
77 | #include <svx/svdoole2.hxx> | |||
78 | #include <svx/svdoutl.hxx> | |||
79 | #include <svx/svdpagv.hxx> | |||
80 | #include <svx/svdundo.hxx> | |||
81 | #include <svx/svxdlg.hxx> | |||
82 | #include <svx/svxids.hrc> | |||
83 | #include <svx/sdtfsitm.hxx> | |||
84 | #include <svx/sdmetitm.hxx> | |||
85 | #include <svx/xfillit0.hxx> | |||
86 | #include <svx/xflclit.hxx> | |||
87 | #include <svx/xlineit0.hxx> | |||
88 | #include <svx/xlnedwit.hxx> | |||
89 | #include <svx/xlnstwit.hxx> | |||
90 | #include <svx/xlnwtit.hxx> | |||
91 | #include <svx/chrtitem.hxx> | |||
92 | #include <svx/xlnclit.hxx> | |||
93 | #include <svx/xflgrit.hxx> | |||
94 | ||||
95 | #include <tools/diagnose_ex.h> | |||
96 | ||||
97 | #include <unotools/useroptions.hxx> | |||
98 | ||||
99 | #include <vcl/abstdlg.hxx> | |||
100 | #include <vcl/graph.hxx> | |||
101 | #include <vcl/svapp.hxx> | |||
102 | #include <vcl/unohelp2.hxx> | |||
103 | #include <vcl/weld.hxx> | |||
104 | ||||
105 | #include <editeng/cmapitem.hxx> | |||
106 | #include <editeng/escapementitem.hxx> | |||
107 | #include <editeng/kernitem.hxx> | |||
108 | #include <editeng/wghtitem.hxx> | |||
109 | #include <editeng/postitem.hxx> | |||
110 | #include <editeng/udlnitem.hxx> | |||
111 | #include <editeng/crossedoutitem.hxx> | |||
112 | #include <editeng/shdditem.hxx> | |||
113 | #include <editeng/numitem.hxx> | |||
114 | #include <svx/svdobj.hxx> | |||
115 | #include <svx/SvxColorChildWindow.hxx> | |||
116 | #include <editeng/outlobj.hxx> | |||
117 | #include <editeng/flstitem.hxx> | |||
118 | #include <editeng/fontitem.hxx> | |||
119 | #include <editeng/fhgtitem.hxx> | |||
120 | #include <editeng/colritem.hxx> | |||
121 | ||||
122 | #include <svl/poolitem.hxx> | |||
123 | #include <svl/style.hxx> | |||
124 | #include <svl/whiter.hxx> | |||
125 | ||||
126 | #include <app.hrc> | |||
127 | #include <strings.hrc> | |||
128 | ||||
129 | #include <AnimationChildWindow.hxx> | |||
130 | #include <DrawDocShell.hxx> | |||
131 | #include <DrawViewShell.hxx> | |||
132 | #include <LayerTabBar.hxx> | |||
133 | #include <Outliner.hxx> | |||
134 | #include <ViewShellHint.hxx> | |||
135 | #include <ViewShellImplementation.hxx> | |||
136 | #include <Window.hxx> | |||
137 | #include <drawdoc.hxx> | |||
138 | #include <drawview.hxx> | |||
139 | #include <fuarea.hxx> | |||
140 | #include <fubullet.hxx> | |||
141 | #include <fuchar.hxx> | |||
142 | #include <fucushow.hxx> | |||
143 | #include <fuconnct.hxx> | |||
144 | #include <fucopy.hxx> | |||
145 | #include <fudspord.hxx> | |||
146 | #include <fuexecuteinteraction.hxx> | |||
147 | #include <fuexpand.hxx> | |||
148 | #include <fuinsert.hxx> | |||
149 | #include <fuinsfil.hxx> | |||
150 | #include <fuline.hxx> | |||
151 | #include <fulinend.hxx> | |||
152 | #include <fulink.hxx> | |||
153 | #include <fumeasur.hxx> | |||
154 | #include <fumorph.hxx> | |||
155 | #include <fuoaprms.hxx> | |||
156 | #include <fuolbull.hxx> | |||
157 | #include <fupage.hxx> | |||
158 | #include <fuparagr.hxx> | |||
159 | #include <fuprlout.hxx> | |||
160 | #include <fuscale.hxx> | |||
161 | #include <fusel.hxx> | |||
162 | #include <fusldlg.hxx> | |||
163 | #include <fusnapln.hxx> | |||
164 | #include <fusumry.hxx> | |||
165 | #include <futempl.hxx> | |||
166 | #include <futhes.hxx> | |||
167 | #include <futransf.hxx> | |||
168 | #include <futxtatt.hxx> | |||
169 | #include <fuvect.hxx> | |||
170 | #include <futext.hxx> | |||
171 | #include <helpids.h> | |||
172 | #include <sdabstdlg.hxx> | |||
173 | #include <sdattr.hxx> | |||
174 | #include <sdpage.hxx> | |||
175 | #include <sdresid.hxx> | |||
176 | #include <unokywds.hxx> | |||
177 | #include <slideshow.hxx> | |||
178 | #include <stlsheet.hxx> | |||
179 | #include <undolayer.hxx> | |||
180 | #include <sfx2/sidebar/Sidebar.hxx> | |||
181 | #include <sfx2/classificationhelper.hxx> | |||
182 | #include <sdmod.hxx> | |||
183 | #include <model/SlsPageEnumerationProvider.hxx> | |||
184 | #include <SlideSorter.hxx> | |||
185 | #include <SlideSorterViewShell.hxx> | |||
186 | #include <controller/SlideSorterController.hxx> | |||
187 | #include <model/SlideSorterModel.hxx> | |||
188 | #include <controller/SlsSelectionManager.hxx> | |||
189 | #include <controller/SlsInsertionIndicatorHandler.hxx> | |||
190 | #include <controller/SlsPageSelector.hxx> | |||
191 | ||||
192 | #include <ViewShellBase.hxx> | |||
193 | #include <memory> | |||
194 | ||||
195 | using namespace ::com::sun::star; | |||
196 | using namespace ::com::sun::star::uno; | |||
197 | ||||
198 | #define MIN_ACTIONS_FOR_DIALOG5000 5000 ///< if there are more meta objects, we show a dialog during the break up | |||
199 | ||||
200 | namespace sd { | |||
201 | ||||
202 | namespace { | |||
203 | ||||
204 | const SvxFieldItem* findField(editeng::Section const & rSection) | |||
205 | { | |||
206 | for (SfxPoolItem const * pPool: rSection.maAttributes) | |||
207 | { | |||
208 | if (pPool->Which() == EE_FEATURE_FIELD) | |||
209 | return static_cast<const SvxFieldItem*>(pPool); | |||
210 | } | |||
211 | return nullptr; | |||
212 | } | |||
213 | ||||
214 | bool hasCustomPropertyField(std::vector<editeng::Section> const & aSections, OUString const & rName) | |||
215 | { | |||
216 | for (editeng::Section const & rSection : aSections) | |||
217 | { | |||
218 | const SvxFieldItem* pFieldItem = findField(rSection); | |||
219 | if (pFieldItem) | |||
220 | { | |||
221 | const editeng::CustomPropertyField* pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField()); | |||
222 | if (pCustomPropertyField && pCustomPropertyField->GetName() == rName) | |||
223 | return true; | |||
224 | } | |||
225 | } | |||
226 | return false; | |||
227 | } | |||
228 | ||||
229 | OUString getWeightString(SfxItemSet const & rItemSet) | |||
230 | { | |||
231 | OUString sWeightString = "NORMAL"; | |||
232 | ||||
233 | if (const SfxPoolItem* pItem = rItemSet.GetItem(EE_CHAR_WEIGHT, false)) | |||
234 | { | |||
235 | const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem); | |||
236 | if (pWeightItem && pWeightItem->GetWeight() == WEIGHT_BOLD) | |||
237 | sWeightString = "BOLD"; | |||
238 | } | |||
239 | return sWeightString; | |||
240 | } | |||
241 | ||||
242 | class ClassificationCommon | |||
243 | { | |||
244 | protected: | |||
245 | sd::DrawViewShell& m_rDrawViewShell; | |||
246 | uno::Reference<document::XDocumentProperties> m_xDocumentProperties; | |||
247 | uno::Reference<beans::XPropertyContainer> m_xPropertyContainer; | |||
248 | sfx::ClassificationKeyCreator m_aKeyCreator; | |||
249 | public: | |||
250 | ClassificationCommon(sd::DrawViewShell & rDrawViewShell) | |||
251 | : m_rDrawViewShell(rDrawViewShell) | |||
252 | , m_xDocumentProperties(SfxObjectShell::Current()->getDocProperties()) | |||
253 | , m_xPropertyContainer(m_xDocumentProperties->getUserDefinedProperties()) | |||
254 | , m_aKeyCreator(SfxClassificationHelper::getPolicyType()) | |||
255 | {} | |||
256 | }; | |||
257 | ||||
258 | class ClassificationCollector : public ClassificationCommon | |||
259 | { | |||
260 | private: | |||
261 | std::vector<svx::ClassificationResult> m_aResults; | |||
262 | ||||
263 | void iterateSectionsAndCollect(std::vector<editeng::Section> const & rSections, EditTextObject const & rEditText) | |||
264 | { | |||
265 | sal_Int32 nCurrentParagraph = -1; | |||
266 | OUString sBlank; | |||
267 | ||||
268 | for (editeng::Section const & rSection : rSections) | |||
269 | { | |||
270 | // Insert new paragraph if needed | |||
271 | while (nCurrentParagraph < rSection.mnParagraph) | |||
272 | { | |||
273 | nCurrentParagraph++; | |||
274 | // Get Weight of current paragraph | |||
275 | OUString sWeightProperty = getWeightString(rEditText.GetParaAttribs(nCurrentParagraph)); | |||
276 | // Insert new paragraph into collection | |||
277 | m_aResults.push_back({ svx::ClassificationType::PARAGRAPH, sWeightProperty, sBlank, sBlank }); | |||
278 | } | |||
279 | ||||
280 | const SvxFieldItem* pFieldItem = findField(rSection); | |||
281 | const editeng::CustomPropertyField* pCustomPropertyField = pFieldItem ? | |||
282 | dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField()) : | |||
283 | nullptr; | |||
284 | if (pCustomPropertyField) | |||
285 | { | |||
286 | const OUString& aKey = pCustomPropertyField->GetName(); | |||
287 | if (m_aKeyCreator.isMarkingTextKey(aKey)) | |||
288 | { | |||
289 | OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); | |||
290 | m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank }); | |||
291 | } | |||
292 | else if (m_aKeyCreator.isCategoryNameKey(aKey) || m_aKeyCreator.isCategoryIdentifierKey(aKey)) | |||
293 | { | |||
294 | OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); | |||
295 | m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank }); | |||
296 | } | |||
297 | else if (m_aKeyCreator.isMarkingKey(aKey)) | |||
298 | { | |||
299 | OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); | |||
300 | m_aResults.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank }); | |||
301 | } | |||
302 | else if (m_aKeyCreator.isIntellectualPropertyPartKey(aKey)) | |||
303 | { | |||
304 | OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); | |||
305 | m_aResults.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank, sBlank }); | |||
306 | } | |||
307 | } | |||
308 | } | |||
309 | } | |||
310 | ||||
311 | public: | |||
312 | ClassificationCollector(sd::DrawViewShell & rDrawViewShell) | |||
313 | : ClassificationCommon(rDrawViewShell) | |||
314 | {} | |||
315 | ||||
316 | std::vector<svx::ClassificationResult> const & getResults() const | |||
317 | { | |||
318 | return m_aResults; | |||
319 | } | |||
320 | ||||
321 | void collect() | |||
322 | { | |||
323 | // Set to MASTER mode | |||
324 | EditMode eOldMode = m_rDrawViewShell.GetEditMode(); | |||
325 | if (eOldMode != EditMode::MasterPage) | |||
326 | m_rDrawViewShell.ChangeEditMode(EditMode::MasterPage, false); | |||
327 | ||||
328 | // Scoped guard to revert to the previous mode | |||
329 | comphelper::ScopeGuard const aGuard([this, eOldMode] () { | |||
330 | m_rDrawViewShell.ChangeEditMode(eOldMode, false); | |||
331 | }); | |||
332 | ||||
333 | const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); | |||
334 | ||||
335 | for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) | |||
336 | { | |||
337 | SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); | |||
338 | for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject) | |||
339 | { | |||
340 | SdrObject* pObject = pMasterPage->GetObj(nObject); | |||
341 | SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject); | |||
342 | if (pRectObject && pRectObject->GetTextKind() == OBJ_TEXT) | |||
343 | { | |||
344 | OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject(); | |||
345 | if (pOutlinerParagraphObject) | |||
346 | { | |||
347 | const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject(); | |||
348 | std::vector<editeng::Section> aSections; | |||
349 | rEditText.GetAllSections(aSections); | |||
350 | ||||
351 | // Search for a custom property field that has the classification category identifier key | |||
352 | if (hasCustomPropertyField(aSections, m_aKeyCreator.makeCategoryNameKey())) | |||
353 | { | |||
354 | iterateSectionsAndCollect(aSections, rEditText); | |||
355 | return; | |||
356 | } | |||
357 | } | |||
358 | } | |||
359 | } | |||
360 | } | |||
361 | } | |||
362 | }; | |||
363 | ||||
364 | class ClassificationInserter : public ClassificationCommon | |||
365 | { | |||
366 | private: | |||
367 | /// Delete the previous existing classification object(s) - if they exist | |||
368 | void deleteExistingObjects() | |||
369 | { | |||
370 | OUString sKey = m_aKeyCreator.makeCategoryNameKey(); | |||
371 | ||||
372 | const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); | |||
373 | ||||
374 | for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) | |||
375 | { | |||
376 | SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); | |||
377 | for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject) | |||
378 | { | |||
379 | SdrObject* pObject = pMasterPage->GetObj(nObject); | |||
380 | SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject); | |||
381 | if (pRectObject && pRectObject->GetTextKind() == OBJ_TEXT) | |||
382 | { | |||
383 | OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject(); | |||
384 | if (pOutlinerParagraphObject) | |||
385 | { | |||
386 | const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject(); | |||
387 | std::vector<editeng::Section> aSections; | |||
388 | rEditText.GetAllSections(aSections); | |||
389 | ||||
390 | if (hasCustomPropertyField(aSections, sKey)) | |||
391 | { | |||
392 | pMasterPage->RemoveObject(pRectObject->GetOrdNum()); | |||
393 | } | |||
394 | } | |||
395 | } | |||
396 | } | |||
397 | } | |||
398 | } | |||
399 | ||||
400 | void fillTheOutliner(Outliner* pOutliner, std::vector<svx::ClassificationResult> const & rResults) | |||
401 | { | |||
402 | sal_Int32 nParagraph = -1; | |||
403 | for (svx::ClassificationResult const & rResult : rResults) | |||
404 | { | |||
405 | ||||
406 | ESelection aPosition(nParagraph, EE_TEXTPOS_MAX_COUNT((sal_Int32) 0x7FFFFFFF), nParagraph, EE_TEXTPOS_MAX_COUNT((sal_Int32) 0x7FFFFFFF)); | |||
407 | ||||
408 | switch (rResult.meType) | |||
409 | { | |||
410 | case svx::ClassificationType::TEXT: | |||
411 | { | |||
412 | OUString sKey = m_aKeyCreator.makeNumberedTextKey(); | |||
413 | svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName); | |||
414 | pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); | |||
415 | } | |||
416 | break; | |||
417 | ||||
418 | case svx::ClassificationType::CATEGORY: | |||
419 | { | |||
420 | OUString sKey = m_aKeyCreator.makeCategoryNameKey(); | |||
421 | pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); | |||
422 | } | |||
423 | break; | |||
424 | ||||
425 | case svx::ClassificationType::MARKING: | |||
426 | { | |||
427 | OUString sKey = m_aKeyCreator.makeNumberedMarkingKey(); | |||
428 | svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName); | |||
429 | pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); | |||
430 | } | |||
431 | break; | |||
432 | ||||
433 | case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART: | |||
434 | { | |||
435 | OUString sKey = m_aKeyCreator.makeNumberedIntellectualPropertyPartKey(); | |||
436 | svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName); | |||
437 | pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); | |||
438 | } | |||
439 | break; | |||
440 | ||||
441 | case svx::ClassificationType::PARAGRAPH: | |||
442 | { | |||
443 | nParagraph++; | |||
444 | pOutliner->Insert(""); | |||
445 | ||||
446 | SfxItemSet aItemSet(m_rDrawViewShell.GetDoc()->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{}); | |||
447 | ||||
448 | if (rResult.msName == "BOLD") | |||
449 | aItemSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT)); | |||
450 | else | |||
451 | aItemSet.Put(SvxWeightItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT)); | |||
452 | ||||
453 | SvxNumRule aDefaultNumRule(SvxNumRuleFlags::NONE, 0, false); | |||
454 | aItemSet.Put(SvxNumBulletItem(aDefaultNumRule, EE_PARA_NUMBULLET)); | |||
455 | ||||
456 | pOutliner->SetParaAttribs(nParagraph, aItemSet); | |||
457 | } | |||
458 | break; | |||
459 | ||||
460 | default: | |||
461 | break; | |||
462 | } | |||
463 | } | |||
464 | } | |||
465 | ||||
466 | public: | |||
467 | ClassificationInserter(sd::DrawViewShell & rDrawViewShell) | |||
468 | : ClassificationCommon(rDrawViewShell) | |||
469 | { | |||
470 | } | |||
471 | ||||
472 | void insert(std::vector<svx::ClassificationResult> const & rResults) | |||
473 | { | |||
474 | // Set to MASTER mode | |||
475 | EditMode eOldMode = m_rDrawViewShell.GetEditMode(); | |||
476 | if (eOldMode != EditMode::MasterPage) | |||
477 | m_rDrawViewShell.ChangeEditMode(EditMode::MasterPage, false); | |||
478 | ||||
479 | // Scoped guard to revert the mode | |||
480 | comphelper::ScopeGuard const aGuard([this, eOldMode] () { | |||
481 | m_rDrawViewShell.ChangeEditMode(eOldMode, false); | |||
482 | }); | |||
483 | ||||
484 | // Delete the previous existing object - if exists | |||
485 | deleteExistingObjects(); | |||
486 | ||||
487 | // Clear properties | |||
488 | svx::classification::removeAllProperties(m_xPropertyContainer); | |||
489 | ||||
490 | SfxClassificationHelper aHelper(m_xDocumentProperties); | |||
491 | ||||
492 | // Apply properties from the BA policy | |||
493 | for (svx::ClassificationResult const & rResult : rResults) | |||
494 | { | |||
495 | if (rResult.meType == svx::ClassificationType::CATEGORY) | |||
496 | aHelper.SetBACName(rResult.msName, SfxClassificationHelper::getPolicyType()); | |||
497 | } | |||
498 | ||||
499 | // Insert full text as document property | |||
500 | svx::classification::insertFullTextualRepresentationAsDocumentProperty(m_xPropertyContainer, m_aKeyCreator, rResults); | |||
501 | ||||
502 | // Create the outliner from the | |||
503 | Outliner* pOutliner = m_rDrawViewShell.GetDoc()->GetInternalOutliner(); | |||
504 | OutlinerMode eOutlinerMode = pOutliner->GetMode(); | |||
505 | ||||
506 | comphelper::ScopeGuard const aOutlinerGuard([pOutliner, eOutlinerMode] () { | |||
507 | pOutliner->Init(eOutlinerMode); | |||
508 | }); | |||
509 | ||||
510 | pOutliner->Init(OutlinerMode::TextObject); | |||
511 | ||||
512 | // Fill the outliner with the text from classification result | |||
513 | fillTheOutliner(pOutliner, rResults); | |||
514 | ||||
515 | // Calculate to outliner text size | |||
516 | pOutliner->UpdateFields(); | |||
517 | pOutliner->SetUpdateMode(true); | |||
518 | Size aTextSize(pOutliner->CalcTextSize()); | |||
519 | pOutliner->SetUpdateMode(false); | |||
520 | ||||
521 | // Create objects, apply the outliner and add them (objects) to all master pages | |||
522 | const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); | |||
523 | ||||
524 | for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) | |||
525 | { | |||
526 | SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); | |||
527 | if (!pMasterPage) | |||
528 | continue; | |||
529 | ||||
530 | SdrRectObj* pObject = new SdrRectObj( | |||
531 | *m_rDrawViewShell.GetDoc(), // TTTT should be reference | |||
532 | OBJ_TEXT); | |||
533 | pObject->SetMergedItem(makeSdrTextAutoGrowWidthItem(true)); | |||
534 | pObject->SetOutlinerParaObject(pOutliner->CreateParaObject()); | |||
535 | pMasterPage->InsertObject(pObject); | |||
536 | ||||
537 | // Calculate position | |||
538 | ::tools::Rectangle aRectangle(Point(), pMasterPage->GetSize()); | |||
539 | Point aPosition(aRectangle.Center().X(), aRectangle.Bottom()); | |||
540 | ||||
541 | aPosition.AdjustX( -(aTextSize.Width() / 2) ); | |||
542 | aPosition.AdjustY( -(aTextSize.Height()) ); | |||
543 | ||||
544 | pObject->SetLogicRect(::tools::Rectangle(aPosition, aTextSize)); | |||
545 | } | |||
546 | } | |||
547 | }; | |||
548 | ||||
549 | void lcl_convertStringArguments(sal_uInt16 nSlot, const std::unique_ptr<SfxItemSet>& pArgs) | |||
550 | { | |||
551 | Color aColor; | |||
552 | const SfxPoolItem* pItem = nullptr; | |||
553 | ||||
554 | if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LINE_WIDTH_ARG( 10000 + 203 ), false, &pItem)) | |||
555 | { | |||
556 | double fValue = static_cast<const SvxDoubleItem*>(pItem)->GetValue(); | |||
557 | // FIXME: different units... | |||
558 | int nPow = 100; | |||
559 | int nValue = fValue * nPow; | |||
560 | ||||
561 | XLineWidthItem aItem(nValue); | |||
562 | pArgs->Put(aItem); | |||
563 | } | |||
564 | if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR(10000 + 540), false, &pItem)) | |||
565 | { | |||
566 | OUString sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
567 | ||||
568 | if (sColor == "transparent") | |||
569 | aColor = COL_TRANSPARENT; | |||
570 | else | |||
571 | aColor = Color(sColor.toInt32(16)); | |||
572 | ||||
573 | switch (nSlot) | |||
574 | { | |||
575 | case SID_ATTR_LINE_COLOR( 10000 + 172 ): | |||
576 | { | |||
577 | XLineColorItem aLineColorItem(OUString(), aColor); | |||
578 | pArgs->Put(aLineColorItem); | |||
579 | break; | |||
580 | } | |||
581 | ||||
582 | case SID_ATTR_FILL_COLOR( 10000 + 165 ): | |||
583 | { | |||
584 | XFillColorItem aFillColorItem(OUString(), aColor); | |||
585 | pArgs->Put(aFillColorItem); | |||
586 | break; | |||
587 | } | |||
588 | } | |||
589 | } | |||
590 | if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON( 10000 + 204 ), false, &pItem)) | |||
591 | { | |||
592 | const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem); | |||
593 | if (pJSON) | |||
594 | { | |||
595 | XGradient aGradient = XGradient::fromJSON(pJSON->GetValue()); | |||
596 | XFillGradientItem aItem(aGradient); | |||
597 | pArgs->Put(aItem); | |||
598 | } | |||
599 | } | |||
600 | } | |||
601 | } | |||
602 | ||||
603 | /** | |||
604 | * SfxRequests for temporary actions | |||
605 | */ | |||
606 | ||||
607 | void DrawViewShell::FuTemporary(SfxRequest& rReq) | |||
608 | { | |||
609 | // during a native slide show nothing gets executed! | |||
610 | if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR(10000 + 366))) | |||
| ||||
611 | return; | |||
612 | ||||
613 | DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" )do { if (true && (!(mpDrawView))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "613" ": "), "%s", "sd::DrawViewShell::FuTemporary(), no draw view!" ); } } while (false); | |||
614 | if( !mpDrawView ) | |||
615 | return; | |||
616 | ||||
617 | CheckLineTo (rReq); | |||
618 | ||||
619 | DeactivateCurrentFunction(); | |||
620 | ||||
621 | sal_uInt16 nSId = rReq.GetSlot(); | |||
622 | ||||
623 | switch ( nSId ) | |||
624 | { | |||
625 | case SID_OUTLINE_TEXT_AUTOFIT(27000 +440): | |||
626 | { | |||
627 | SfxUndoManager* pUndoManager = GetDocSh()->GetUndoManager(); | |||
628 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
629 | if( rMarkList.GetMarkCount() == 1 ) | |||
630 | { | |||
631 | pUndoManager->EnterListAction("", "", 0, GetViewShellBase().GetViewShellId()); | |||
632 | mpDrawView->BegUndo(); | |||
633 | ||||
634 | SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); | |||
635 | bool bSet = pObj->GetMergedItemSet().GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue() != drawing::TextFitToSizeType_NONE; | |||
636 | ||||
637 | mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); | |||
638 | ||||
639 | if (!bSet) | |||
640 | { | |||
641 | //If we are turning on AutoFit we have to turn these off if already on | |||
642 | if (pObj->GetMergedItemSet().GetItem<SdrOnOffItem>(SDRATTR_TEXT_AUTOGROWHEIGHT)->GetValue()) | |||
643 | pObj->SetMergedItem(makeSdrTextAutoGrowHeightItem(false)); | |||
644 | if (pObj->GetMergedItemSet().GetItem<SdrOnOffItem>(SDRATTR_TEXT_AUTOGROWWIDTH)->GetValue()) | |||
645 | pObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(false)); | |||
646 | } | |||
647 | ||||
648 | pObj->SetMergedItem(SdrTextFitToSizeTypeItem(bSet ? drawing::TextFitToSizeType_NONE : drawing::TextFitToSizeType_AUTOFIT)); | |||
649 | ||||
650 | mpDrawView->EndUndo(); | |||
651 | pUndoManager->LeaveListAction(); | |||
652 | } | |||
653 | Cancel(); | |||
654 | rReq.Done(); | |||
655 | } | |||
656 | break; | |||
657 | ||||
658 | // area and line attributes: shall have | |||
659 | // an own Execute method (like StateMethode) | |||
660 | case SID_ATTR_FILL_STYLE( 10000 + 164 ): | |||
661 | case SID_ATTR_FILL_COLOR( 10000 + 165 ): | |||
662 | case SID_ATTR_FILL_GRADIENT( 10000 + 166 ): | |||
663 | case SID_ATTR_FILL_HATCH( 10000 + 167 ): | |||
664 | case SID_ATTR_FILL_BITMAP( 10000 + 168 ): | |||
665 | case SID_ATTR_FILL_SHADOW( 10000 + 299 ): | |||
666 | case SID_ATTR_SHADOW_COLOR( 10000 + 1149 ): | |||
667 | case SID_ATTR_SHADOW_TRANSPARENCE( 10000 + 1148 ): | |||
668 | case SID_ATTR_SHADOW_BLUR( 10000 + 755 ): | |||
669 | case SID_ATTR_SHADOW_XDISTANCE( 10000 + 1150 ): | |||
670 | case SID_ATTR_SHADOW_YDISTANCE( 10000 + 1151 ): | |||
671 | case SID_ATTR_FILL_TRANSPARENCE( 10000 + 1124 ): | |||
672 | case SID_ATTR_FILL_FLOATTRANSPARENCE( 10000 + 1125 ): | |||
673 | ||||
674 | case SID_ATTR_LINE_STYLE( 10000 + 169 ): | |||
675 | case SID_ATTR_LINE_DASH( 10000 + 170 ): | |||
676 | case SID_ATTR_LINE_WIDTH( 10000 + 171 ): | |||
677 | case SID_ATTR_LINE_COLOR( 10000 + 172 ): | |||
678 | case SID_ATTR_LINEEND_STYLE( 10000 + 301 ): | |||
679 | case SID_ATTR_LINE_START( 10000 + 173 ): | |||
680 | case SID_ATTR_LINE_END( 10000 + 174 ): | |||
681 | case SID_ATTR_LINE_TRANSPARENCE( 10000 + 1126 ): | |||
682 | case SID_ATTR_LINE_JOINT( 10000 + 1129 ): | |||
683 | case SID_ATTR_LINE_CAP( 10000 + 1130 ): | |||
684 | ||||
685 | case SID_ATTR_TEXT_FITTOSIZE( 10000 + 367 ): | |||
686 | { | |||
687 | if( rReq.GetArgs() ) | |||
688 | { | |||
689 | std::unique_ptr<SfxItemSet> pNewArgs = rReq.GetArgs()->Clone(); | |||
690 | lcl_convertStringArguments(rReq.GetSlot(), pNewArgs); | |||
691 | mpDrawView->SetAttributes(*pNewArgs); | |||
692 | rReq.Done(); | |||
693 | } | |||
694 | else | |||
695 | { | |||
696 | switch( rReq.GetSlot() ) | |||
697 | { | |||
698 | case SID_ATTR_FILL_SHADOW( 10000 + 299 ): | |||
699 | case SID_ATTR_SHADOW_COLOR( 10000 + 1149 ): | |||
700 | case SID_ATTR_SHADOW_TRANSPARENCE( 10000 + 1148 ): | |||
701 | case SID_ATTR_SHADOW_BLUR( 10000 + 755 ): | |||
702 | case SID_ATTR_SHADOW_XDISTANCE( 10000 + 1150 ): | |||
703 | case SID_ATTR_SHADOW_YDISTANCE( 10000 + 1151 ): | |||
704 | case SID_ATTR_FILL_STYLE( 10000 + 164 ): | |||
705 | case SID_ATTR_FILL_COLOR( 10000 + 165 ): | |||
706 | case SID_ATTR_FILL_GRADIENT( 10000 + 166 ): | |||
707 | case SID_ATTR_FILL_HATCH( 10000 + 167 ): | |||
708 | case SID_ATTR_FILL_BITMAP( 10000 + 168 ): | |||
709 | case SID_ATTR_FILL_TRANSPARENCE( 10000 + 1124 ): | |||
710 | case SID_ATTR_FILL_FLOATTRANSPARENCE( 10000 + 1125 ): | |||
711 | GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA( 10000 + 142 ), SfxCallMode::ASYNCHRON ); | |||
712 | break; | |||
713 | case SID_ATTR_LINE_STYLE( 10000 + 169 ): | |||
714 | case SID_ATTR_LINE_DASH( 10000 + 170 ): | |||
715 | case SID_ATTR_LINE_WIDTH( 10000 + 171 ): | |||
716 | case SID_ATTR_LINE_COLOR( 10000 + 172 ): | |||
717 | case SID_ATTR_LINE_TRANSPARENCE( 10000 + 1126 ): | |||
718 | case SID_ATTR_LINE_JOINT( 10000 + 1129 ): | |||
719 | case SID_ATTR_LINE_CAP( 10000 + 1130 ): | |||
720 | GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE( 10000 + 143 ), SfxCallMode::ASYNCHRON ); | |||
721 | break; | |||
722 | case SID_ATTR_TEXT_FITTOSIZE( 10000 + 367 ): | |||
723 | GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG(27000 +281), SfxCallMode::ASYNCHRON ); | |||
724 | break; | |||
725 | } | |||
726 | } | |||
727 | Cancel(); | |||
728 | } | |||
729 | break; | |||
730 | ||||
731 | case SID_HYPHENATION(27000 +340): | |||
732 | { | |||
733 | const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_HYPHENATION(27000 +340)); | |||
734 | ||||
735 | if( pItem ) | |||
736 | { | |||
737 | SfxItemSet aSet( GetPool(), svl::Items<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE>{} ); | |||
738 | bool bValue = pItem->GetValue(); | |||
739 | aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); | |||
740 | mpDrawView->SetAttributes( aSet ); | |||
741 | } | |||
742 | else // only for testing purpose | |||
743 | { | |||
744 | OSL_FAIL(" no value for hyphenation!")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "744" ": "), "%s", " no value for hyphenation!"); } } while (false); | |||
745 | SfxItemSet aSet( GetPool(), svl::Items<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE>{} ); | |||
746 | aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, true ) ); | |||
747 | mpDrawView->SetAttributes( aSet ); | |||
748 | } | |||
749 | rReq.Done(); | |||
750 | Cancel(); | |||
751 | } | |||
752 | break; | |||
753 | ||||
754 | case SID_INSERTPAGE(27000 +14): | |||
755 | case SID_INSERTPAGE_QUICK(27000 +352): | |||
756 | { | |||
757 | SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage()); | |||
758 | Cancel(); | |||
759 | if(HasCurrentFunction(SID_BEZIER_EDIT( 10000 + 126 )) ) | |||
760 | GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT( 10000 + 128 ), SfxCallMode::ASYNCHRON); | |||
761 | if (pNewPage != nullptr) | |||
762 | SwitchPage((pNewPage->GetPageNum()-1)/2); | |||
763 | rReq.Done (); | |||
764 | } | |||
765 | break; | |||
766 | ||||
767 | case SID_DUPLICATE_PAGE(27000 +342): | |||
768 | { | |||
769 | DuplicateSelectedSlides(rReq); | |||
770 | Cancel(); | |||
771 | if(HasCurrentFunction(SID_BEZIER_EDIT( 10000 + 126 )) ) | |||
772 | GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT( 10000 + 128 ), SfxCallMode::ASYNCHRON); | |||
773 | rReq.Done(); | |||
774 | } | |||
775 | break; | |||
776 | ||||
777 | case SID_INSERT_MASTER_PAGE(27000 +431): | |||
778 | { | |||
779 | // Use the API to create a new page. | |||
780 | Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier ( | |||
781 | GetDoc()->getUnoModel(), UNO_QUERY); | |||
782 | if (xMasterPagesSupplier.is()) | |||
783 | { | |||
784 | Reference<drawing::XDrawPages> xMasterPages ( | |||
785 | xMasterPagesSupplier->getMasterPages()); | |||
786 | if (xMasterPages.is()) | |||
787 | { | |||
788 | sal_uInt16 nIndex = GetCurPagePos() + 1; | |||
789 | xMasterPages->insertNewByIndex (nIndex); | |||
790 | ||||
791 | // Create shapes for the default layout. | |||
792 | SdPage* pMasterPage = GetDoc()->GetMasterSdPage( | |||
793 | nIndex, PageKind::Standard); | |||
794 | pMasterPage->CreateTitleAndLayout (true,true); | |||
795 | } | |||
796 | } | |||
797 | ||||
798 | Cancel(); | |||
799 | if(HasCurrentFunction(SID_BEZIER_EDIT( 10000 + 126 ))) | |||
800 | GetViewFrame()->GetDispatcher()->Execute( | |||
801 | SID_OBJECT_SELECT( 10000 + 128 ), SfxCallMode::ASYNCHRON); | |||
802 | rReq.Done (); | |||
803 | } | |||
804 | break; | |||
805 | ||||
806 | case SID_MODIFYPAGE(27000 +43): | |||
807 | { | |||
808 | if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes || | |||
809 | (mePageKind==PageKind::Handout && meEditMode==EditMode::MasterPage) ) | |||
810 | { | |||
811 | if ( mpDrawView->IsTextEdit() ) | |||
812 | { | |||
813 | mpDrawView->SdrEndTextEdit(); | |||
814 | } | |||
815 | sal_uInt16 nPage = maTabControl->GetCurPagePos(); | |||
816 | mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind); | |||
817 | ::sd::ViewShell::mpImpl->ProcessModifyPageSlot ( | |||
818 | rReq, | |||
819 | mpActualPage, | |||
820 | mePageKind); | |||
821 | } | |||
822 | ||||
823 | Cancel(); | |||
824 | rReq.Done (); | |||
825 | } | |||
826 | break; | |||
827 | ||||
828 | case SID_ASSIGN_LAYOUT(27000 +435): | |||
829 | { | |||
830 | if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes || (mePageKind==PageKind::Handout && meEditMode==EditMode::MasterPage)) | |||
831 | { | |||
832 | if ( mpDrawView->IsTextEdit() ) | |||
833 | mpDrawView->SdrEndTextEdit(); | |||
834 | ||||
835 | ::sd::ViewShell::mpImpl->AssignLayout(rReq, mePageKind); | |||
836 | } | |||
837 | Cancel(); | |||
838 | rReq.Done (); | |||
839 | } | |||
840 | break; | |||
841 | ||||
842 | case SID_RENAMEPAGE(27000 +268): | |||
843 | case SID_RENAME_MASTER_PAGE(27000 +433): | |||
844 | { | |||
845 | if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes ) | |||
846 | { | |||
847 | if ( mpDrawView->IsTextEdit() ) | |||
848 | { | |||
849 | mpDrawView->SdrEndTextEdit(); | |||
850 | } | |||
851 | ||||
852 | sal_uInt16 nPage = maTabControl->GetCurPagePos(); | |||
853 | SdPage* pCurrentPage = ( GetEditMode() == EditMode::Page ) | |||
854 | ? GetDoc()->GetSdPage( nPage, GetPageKind() ) | |||
855 | : GetDoc()->GetMasterSdPage( nPage, GetPageKind() ); | |||
856 | ||||
857 | OUString aTitle = SdResId(STR_TITLE_RENAMESLIDEreinterpret_cast<char const *>("STR_TITLE_RENAMESLIDE" "\004" u8"Rename Slide")); | |||
858 | OUString aDescr = SdResId(STR_DESC_RENAMESLIDEreinterpret_cast<char const *>("STR_DESC_RENAMESLIDE" "\004" u8"Name")); | |||
859 | const OUString& aPageName = pCurrentPage->GetName(); | |||
860 | ||||
861 | if(rReq.GetArgs()) | |||
862 | { | |||
863 | OUString aName = rReq.GetArgs()->GetItem<const SfxStringItem>(SID_RENAMEPAGE(27000 +268))->GetValue(); | |||
864 | ||||
865 | bool bResult = RenameSlide( maTabControl->GetPageId(nPage), aName ); | |||
866 | DBG_ASSERT( bResult, "Couldn't rename slide" )do { if (true && (!(bResult))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "866" ": "), "%s", "Couldn't rename slide"); } } while ( false); | |||
867 | } | |||
868 | else | |||
869 | { | |||
870 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
871 | ScopedVclPtr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aPageName, aDescr)); | |||
872 | aNameDlg->SetText( aTitle ); | |||
873 | aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl )::tools::detail::makeLink( ::tools::detail::castTo<DrawViewShell *>(this), &DrawViewShell::LinkStubRenameSlideHdl), true ); | |||
874 | aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE"SD_HID_SD_NAMEDIALOG_PAGE" ); | |||
875 | ||||
876 | if( aNameDlg->Execute() == RET_OK ) | |||
877 | { | |||
878 | OUString aNewName; | |||
879 | aNameDlg->GetName( aNewName ); | |||
880 | if (aNewName != aPageName) | |||
881 | { | |||
882 | bool bResult = RenameSlide( maTabControl->GetPageId(nPage), aNewName ); | |||
883 | DBG_ASSERT( bResult, "Couldn't rename slide" )do { if (true && (!(bResult))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "883" ": "), "%s", "Couldn't rename slide"); } } while ( false); | |||
884 | } | |||
885 | } | |||
886 | } | |||
887 | } | |||
888 | Cancel(); | |||
889 | rReq.Ignore(); | |||
890 | } | |||
891 | break; | |||
892 | ||||
893 | case SID_RENAMEPAGE_QUICK(27000 +405): | |||
894 | { | |||
895 | if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes ) | |||
896 | { | |||
897 | if ( mpDrawView->IsTextEdit() ) | |||
898 | { | |||
899 | mpDrawView->SdrEndTextEdit(); | |||
900 | } | |||
901 | ||||
902 | maTabControl->StartEditMode( maTabControl->GetCurPageId() ); | |||
903 | } | |||
904 | ||||
905 | Cancel(); | |||
906 | rReq.Ignore (); | |||
907 | } | |||
908 | break; | |||
909 | ||||
910 | case SID_PAGESIZE(27000 +253) : // either this (no menu entries or something else!) | |||
911 | { | |||
912 | const SfxItemSet *pArgs = rReq.GetArgs (); | |||
913 | ||||
914 | if (pArgs && pArgs->Count () == 3) | |||
915 | { | |||
916 | const SfxUInt32Item* pWidth = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEWIDTH(27000 +218)); | |||
917 | const SfxUInt32Item* pHeight = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEHEIGHT(27000 +233)); | |||
918 | const SfxBoolItem* pScaleAll = rReq.GetArg<SfxBoolItem>(ID_VAL_SCALEOBJECTS(27000 +224)); | |||
919 | ||||
920 | Size aSize (pWidth->GetValue (), pHeight->GetValue ()); | |||
921 | ||||
922 | SetupPage (aSize, 0, 0, 0, 0, true, false, pScaleAll->GetValue ()); | |||
923 | rReq.Ignore (); | |||
924 | break; | |||
925 | } | |||
926 | #if HAVE_FEATURE_SCRIPTING1 | |||
927 | StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGSErrCode( ErrCodeArea::Sbx, ErrCodeClass::Sbx, 28)); | |||
928 | #endif | |||
929 | rReq.Ignore (); | |||
930 | break; | |||
931 | } | |||
932 | ||||
933 | case SID_PAGEMARGIN(27000 +254) : // or this (no menu entries or something else!) | |||
934 | { | |||
935 | const SfxItemSet *pArgs = rReq.GetArgs (); | |||
936 | ||||
937 | if (pArgs && pArgs->Count () == 5) | |||
938 | { | |||
939 | const SfxUInt32Item* pLeft = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGELEFT(27000 +222)); | |||
940 | const SfxUInt32Item* pRight = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGERIGHT(27000 +223)); | |||
941 | const SfxUInt32Item* pUpper = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGETOP(27000 +220)); | |||
942 | const SfxUInt32Item* pLower = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEBOTTOM(27000 +221)); | |||
943 | const SfxBoolItem* pScaleAll = rReq.GetArg<SfxBoolItem>(ID_VAL_SCALEOBJECTS(27000 +224)); | |||
944 | ||||
945 | Size aEmptySize (0, 0); | |||
946 | ||||
947 | SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (), | |||
948 | pUpper->GetValue (), pLower->GetValue (), | |||
949 | false, true, pScaleAll->GetValue ()); | |||
950 | rReq.Ignore (); | |||
951 | break; | |||
952 | } | |||
953 | #if HAVE_FEATURE_SCRIPTING1 | |||
954 | StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGSErrCode( ErrCodeArea::Sbx, ErrCodeClass::Sbx, 28)); | |||
955 | #endif | |||
956 | rReq.Ignore (); | |||
957 | break; | |||
958 | } | |||
959 | ||||
960 | case SID_ATTR_ZOOMSLIDER( 10000 + 1065 ): | |||
961 | { | |||
962 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
963 | ||||
964 | const SfxUInt16Item* pScale = (pArgs && pArgs->Count () == 1) ? | |||
965 | rReq.GetArg<SfxUInt16Item>(SID_ATTR_ZOOMSLIDER( 10000 + 1065 )) : nullptr; | |||
966 | if (pScale && CHECK_RANGE (5, pScale->GetValue (), 3000)((pScale->GetValue () >= 5) && (pScale->GetValue () <= 3000))) | |||
967 | { | |||
968 | SetZoom (pScale->GetValue ()); | |||
969 | ||||
970 | SfxBindings& rBindings = GetViewFrame()->GetBindings(); | |||
971 | rBindings.Invalidate( SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0) ); | |||
972 | rBindings.Invalidate( SID_ZOOM_IN(10000 + 98) ); | |||
973 | rBindings.Invalidate( SID_ZOOM_OUT(10000 + 97) ); | |||
974 | rBindings.Invalidate( SID_ATTR_ZOOMSLIDER( 10000 + 1065 ) ); | |||
975 | ||||
976 | } | |||
977 | ||||
978 | Cancel(); | |||
979 | rReq.Done (); | |||
980 | break; | |||
981 | } | |||
982 | ||||
983 | case SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0): | |||
984 | { | |||
985 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
986 | mbZoomOnPage = false; | |||
987 | ||||
988 | if ( pArgs ) | |||
989 | { | |||
990 | SvxZoomType eZT = pArgs->Get( SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0) ).GetType(); | |||
991 | switch( eZT ) | |||
992 | { | |||
993 | case SvxZoomType::PERCENT: | |||
994 | SetZoom( static_cast<long>( pArgs->Get( SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0) ).GetValue()) ); | |||
995 | break; | |||
996 | ||||
997 | case SvxZoomType::OPTIMAL: | |||
998 | GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL( 10000 + 101 ), | |||
999 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD ); | |||
1000 | break; | |||
1001 | ||||
1002 | case SvxZoomType::PAGEWIDTH: | |||
1003 | GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH(27000 +98), | |||
1004 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD ); | |||
1005 | break; | |||
1006 | ||||
1007 | case SvxZoomType::WHOLEPAGE: | |||
1008 | GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE(10000 + 100), | |||
1009 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD ); | |||
1010 | break; | |||
1011 | case SvxZoomType::PAGEWIDTH_NOBORDER: | |||
1012 | OSL_FAIL("sd::DrawViewShell::FuTemporary(), SvxZoomType::PAGEWIDTH_NOBORDER not handled!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1012" ": "), "%s", "sd::DrawViewShell::FuTemporary(), SvxZoomType::PAGEWIDTH_NOBORDER not handled!" ); } } while (false); | |||
1013 | break; | |||
1014 | } | |||
1015 | rReq.Ignore (); | |||
1016 | } | |||
1017 | else | |||
1018 | { | |||
1019 | // open zoom dialog | |||
1020 | SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1021 | } | |||
1022 | Cancel(); | |||
1023 | } | |||
1024 | break; | |||
1025 | ||||
1026 | case SID_CHANGEBEZIER(27000 +36): | |||
1027 | case SID_CHANGEPOLYGON(27000 +37): | |||
1028 | if ( mpDrawView->IsTextEdit() ) | |||
1029 | { | |||
1030 | mpDrawView->SdrEndTextEdit(); | |||
1031 | GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT( 10000 + 128 ), SfxCallMode::ASYNCHRON); | |||
1032 | } | |||
1033 | ||||
1034 | if ( mpDrawView->IsPresObjSelected() ) | |||
1035 | { | |||
1036 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1037 | VclMessageType::Info, VclButtonsType::Ok, | |||
1038 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
1039 | xInfoBox->run(); | |||
1040 | } | |||
1041 | else | |||
1042 | { | |||
1043 | if( rReq.GetSlot() == SID_CHANGEBEZIER(27000 +36) ) | |||
1044 | { | |||
1045 | weld::WaitObject aWait(GetFrameWeld()); | |||
1046 | mpDrawView->ConvertMarkedToPathObj(false); | |||
1047 | } | |||
1048 | else | |||
1049 | { | |||
1050 | if( mpDrawView->IsVectorizeAllowed() ) | |||
1051 | { | |||
1052 | SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1053 | } | |||
1054 | else | |||
1055 | { | |||
1056 | weld::WaitObject aWait(GetFrameWeld()); | |||
1057 | mpDrawView->ConvertMarkedToPolyObj(); | |||
1058 | } | |||
1059 | } | |||
1060 | ||||
1061 | Invalidate(SID_CHANGEBEZIER(27000 +36)); | |||
1062 | Invalidate(SID_CHANGEPOLYGON(27000 +37)); | |||
1063 | } | |||
1064 | Cancel(); | |||
1065 | ||||
1066 | if( HasCurrentFunction(SID_BEZIER_EDIT( 10000 + 126 )) ) | |||
1067 | { // where applicable, activate right edit action | |||
1068 | GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT(27000 +74), | |||
1069 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); | |||
1070 | } | |||
1071 | rReq.Ignore (); | |||
1072 | break; | |||
1073 | ||||
1074 | case SID_CONVERT_TO_CONTOUR(27000 +381): | |||
1075 | if ( mpDrawView->IsTextEdit() ) | |||
1076 | { | |||
1077 | mpDrawView->SdrEndTextEdit(); | |||
1078 | GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT( 10000 + 128 ), SfxCallMode::ASYNCHRON); | |||
1079 | } | |||
1080 | ||||
1081 | if ( mpDrawView->IsPresObjSelected() ) | |||
1082 | { | |||
1083 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1084 | VclMessageType::Info, VclButtonsType::Ok, | |||
1085 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
1086 | xInfoBox->run(); | |||
1087 | } | |||
1088 | else | |||
1089 | { | |||
1090 | weld::WaitObject aWait(GetFrameWeld()); | |||
1091 | mpDrawView->ConvertMarkedToPathObj(true); | |||
1092 | ||||
1093 | Invalidate(SID_CONVERT_TO_CONTOUR(27000 +381)); | |||
1094 | } | |||
1095 | Cancel(); | |||
1096 | ||||
1097 | rReq.Ignore (); | |||
1098 | break; | |||
1099 | ||||
1100 | case SID_CONVERT_TO_METAFILE(27000 +379): | |||
1101 | case SID_CONVERT_TO_BITMAP(27000 +378): | |||
1102 | { | |||
1103 | // End text edit mode when it is active because the metafile or | |||
1104 | // bitmap that will be created does not support it. | |||
1105 | if ( mpDrawView->IsTextEdit() ) | |||
1106 | { | |||
1107 | mpDrawView->SdrEndTextEdit(); | |||
1108 | GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT( 10000 + 128 ), SfxCallMode::ASYNCHRON); | |||
1109 | } | |||
1110 | ||||
1111 | if ( mpDrawView->IsPresObjSelected(true,true,true) ) | |||
1112 | { | |||
1113 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1114 | VclMessageType::Info, VclButtonsType::Ok, | |||
1115 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
1116 | xInfoBox->run(); | |||
1117 | } | |||
1118 | else | |||
1119 | { | |||
1120 | weld::WaitObject aWait(GetFrameWeld()); | |||
1121 | ||||
1122 | // create SdrGrafObj from metafile/bitmap | |||
1123 | Graphic aGraphic; | |||
1124 | switch (nSId) | |||
1125 | { | |||
1126 | case SID_CONVERT_TO_METAFILE(27000 +379): | |||
1127 | { | |||
1128 | // switch on undo for the next operations | |||
1129 | mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_METAFILEreinterpret_cast<char const *>("STR_UNDO_CONVERT_TO_METAFILE" "\004" u8"Convert to metafile"))); | |||
1130 | GDIMetaFile aMetaFile(mpDrawView->GetMarkedObjMetaFile()); | |||
1131 | aGraphic = Graphic(aMetaFile); | |||
1132 | } | |||
1133 | break; | |||
1134 | case SID_CONVERT_TO_BITMAP(27000 +378): | |||
1135 | { | |||
1136 | // Disable spelling during conversion | |||
1137 | bool bOnlineSpell = GetDoc()->GetOnlineSpell(); | |||
1138 | GetDoc()->SetOnlineSpell(false); | |||
1139 | ||||
1140 | // switch on undo for the next operations | |||
1141 | mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_BITMAPreinterpret_cast<char const *>("STR_UNDO_CONVERT_TO_BITMAP" "\004" u8"Convert to bitmap"))); | |||
1142 | bool bDone(false); | |||
1143 | ||||
1144 | // I have to get the image here directly since GetMarkedObjBitmapEx works | |||
1145 | // based on Bitmaps, but not on BitmapEx, thus throwing away the alpha | |||
1146 | // channel. Argh! GetMarkedObjBitmapEx itself is too widely used to safely | |||
1147 | // change that, e.g. in the exchange formats. For now I can only add this | |||
1148 | // exception to get good results for Svgs. This is how the code gets more | |||
1149 | // and more crowded, at last I made a remark for myself to change this | |||
1150 | // as one of the next tasks. | |||
1151 | if(1 == mpDrawView->GetMarkedObjectCount()) | |||
1152 | { | |||
1153 | const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(mpDrawView->GetMarkedObjectByIndex(0)); | |||
1154 | ||||
1155 | if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData()) | |||
1156 | { | |||
1157 | aGraphic = Graphic(pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement()); | |||
1158 | bDone = true; | |||
1159 | } | |||
1160 | } | |||
1161 | ||||
1162 | if(!bDone) | |||
1163 | { | |||
1164 | aGraphic = Graphic(mpDrawView->GetMarkedObjBitmapEx()); | |||
1165 | } | |||
1166 | // Restore online spelling | |||
1167 | GetDoc()->SetOnlineSpell(bOnlineSpell); | |||
1168 | } | |||
1169 | break; | |||
1170 | } | |||
1171 | ||||
1172 | // create new object | |||
1173 | SdrGrafObj* pGraphicObj = new SdrGrafObj( | |||
1174 | *GetDoc(), | |||
1175 | aGraphic); | |||
1176 | ||||
1177 | // get some necessary info and ensure it | |||
1178 | const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList()); | |||
1179 | const size_t nMarkCount(rMarkList.GetMarkCount()); | |||
1180 | SdrPageView* pPageView = mpDrawView->GetSdrPageView(); | |||
1181 | OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)")do { if (true && (!(nMarkCount))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1181" ": "), "%s", "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)" ); } } while (false); | |||
1182 | OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)")do { if (true && (!(pPageView))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1182" ": "), "%s", "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)" ); } } while (false); | |||
1183 | ||||
1184 | // fit rectangle of new graphic object to selection's mark rect | |||
1185 | ::tools::Rectangle aAllMarkedRect; | |||
1186 | rMarkList.TakeBoundRect(pPageView, aAllMarkedRect); | |||
1187 | pGraphicObj->SetLogicRect(aAllMarkedRect); | |||
1188 | ||||
1189 | // #i71540# to keep the order, it is necessary to replace the lowest object | |||
1190 | // of the selection with the new object. This also means that with multi | |||
1191 | // selection, all other objects need to be deleted first | |||
1192 | SdrMark* pFirstMark = rMarkList.GetMark(0); | |||
1193 | SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj(); | |||
1194 | ||||
1195 | if(nMarkCount > 1) | |||
1196 | { | |||
1197 | // take first object out of selection | |||
1198 | mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true); | |||
1199 | ||||
1200 | // clear remaining selection | |||
1201 | mpDrawView->DeleteMarkedObj(); | |||
1202 | } | |||
1203 | ||||
1204 | // #i124816# copy layer from lowest object which gets replaced | |||
1205 | pGraphicObj->SetLayer(pReplacementCandidate->GetLayer()); | |||
1206 | ||||
1207 | // now replace lowest object with new one | |||
1208 | mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj); | |||
1209 | ||||
1210 | // switch off undo | |||
1211 | mpDrawView->EndUndo(); | |||
1212 | } | |||
1213 | } | |||
1214 | ||||
1215 | Cancel(); | |||
1216 | ||||
1217 | rReq.Done (); | |||
1218 | break; | |||
1219 | ||||
1220 | case SID_REMOVE_HYPERLINK( 10000 + 459 ): | |||
1221 | { | |||
1222 | if (mpDrawView->IsTextEdit()) | |||
1223 | { | |||
1224 | // First make sure the field is selected | |||
1225 | OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); | |||
1226 | if (pOutView) | |||
1227 | { | |||
1228 | pOutView->SelectFieldAtCursor(); | |||
1229 | URLFieldHelper::RemoveURLField(pOutView->GetEditView()); | |||
1230 | } | |||
1231 | } | |||
1232 | } | |||
1233 | Cancel(); | |||
1234 | rReq.Done (); | |||
1235 | break; | |||
1236 | ||||
1237 | case SID_SET_DEFAULT( 10000 + 456 ): | |||
1238 | { | |||
1239 | std::unique_ptr<SfxItemSet> pSet; | |||
1240 | ||||
1241 | if (mpDrawView->IsTextEdit()) | |||
1242 | { | |||
1243 | pSet.reset(new SfxItemSet( GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{} )); | |||
1244 | mpDrawView->SetAttributes( *pSet, true ); | |||
1245 | } | |||
1246 | else | |||
1247 | { | |||
1248 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
1249 | const size_t nCount = rMarkList.GetMarkCount(); | |||
1250 | ||||
1251 | // For every presentation object a SfxItemSet of hard attributes | |||
1252 | // and the UserCall is stored in this list. This is because | |||
1253 | // at the following mpDrawView->SetAttributes( *pSet, sal_True ) | |||
1254 | // they get lost and have to be restored. | |||
1255 | std::vector<std::pair<std::unique_ptr<SfxItemSet>,SdrObjUserCall*> > aAttrList; | |||
1256 | SdPage* pPresPage = static_cast<SdPage*>( mpDrawView->GetSdrPageView()->GetPage() ); | |||
1257 | ||||
1258 | for ( size_t i = 0; i < nCount; ++i ) | |||
1259 | { | |||
1260 | SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); | |||
1261 | ||||
1262 | if( pPresPage->IsPresObj( pObj ) ) | |||
1263 | { | |||
1264 | auto pNewSet = std::make_unique<SfxItemSet>( GetDoc()->GetPool(), svl::Items<SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT>{} ); | |||
1265 | pNewSet->Put(pObj->GetMergedItemSet()); | |||
1266 | aAttrList.emplace_back(std::move(pNewSet), pObj->GetUserCall()); | |||
1267 | } | |||
1268 | } | |||
1269 | ||||
1270 | pSet.reset(new SfxItemSet( GetPool() )); | |||
1271 | mpDrawView->SetAttributes( *pSet, true ); | |||
1272 | ||||
1273 | sal_uLong j = 0; | |||
1274 | ||||
1275 | for ( size_t i = 0; i < nCount; ++i ) | |||
1276 | { | |||
1277 | SfxStyleSheet* pSheet = nullptr; | |||
1278 | SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); | |||
1279 | ||||
1280 | if (pObj->GetObjIdentifier() == OBJ_TITLETEXT) | |||
1281 | { | |||
1282 | pSheet = mpActualPage->GetStyleSheetForPresObj(PresObjKind::Title); | |||
1283 | if (pSheet) | |||
1284 | pObj->SetStyleSheet(pSheet, false); | |||
1285 | } | |||
1286 | else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT) | |||
1287 | { | |||
1288 | for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++) | |||
1289 | { | |||
1290 | pSheet = mpActualPage->GetStyleSheetForPresObj( PresObjKind::Outline ); | |||
1291 | DBG_ASSERT(pSheet, "Template for outline object not found")do { if (true && (!(pSheet))) { sal_detail_logFormat( (SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1291" ": "), "%s", "Template for outline object not found" ); } } while (false); | |||
1292 | if (pSheet) | |||
1293 | { | |||
1294 | pObj->StartListening(*pSheet); | |||
1295 | ||||
1296 | if( nLevel == 1 ) | |||
1297 | // text frame listens on StyleSheet of level1 | |||
1298 | pObj->NbcSetStyleSheet(pSheet, false); | |||
1299 | } | |||
1300 | } | |||
1301 | } | |||
1302 | ||||
1303 | if( pPresPage->IsPresObj( pObj ) ) | |||
1304 | { | |||
1305 | std::pair<std::unique_ptr<SfxItemSet>,SdrObjUserCall*> &rAttr = aAttrList[j++]; | |||
1306 | ||||
1307 | std::unique_ptr<SfxItemSet> & pNewSet(rAttr.first); | |||
1308 | SdrObjUserCall* pUserCall = rAttr.second; | |||
1309 | ||||
1310 | if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SfxItemState::SET ) | |||
1311 | { | |||
1312 | pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT)); | |||
1313 | } | |||
1314 | ||||
1315 | if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SfxItemState::SET ) | |||
1316 | { | |||
1317 | pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT)); | |||
1318 | } | |||
1319 | ||||
1320 | if( pUserCall ) | |||
1321 | pObj->SetUserCall( pUserCall ); | |||
1322 | } | |||
1323 | } | |||
1324 | } | |||
1325 | ||||
1326 | pSet.reset(); | |||
1327 | Cancel(); | |||
1328 | } | |||
1329 | break; | |||
1330 | ||||
1331 | case SID_DELETE_SNAPITEM(27000 +108): | |||
1332 | { | |||
1333 | SdrPageView* pPV; | |||
1334 | Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos ); | |||
1335 | sal_uInt16 nHitLog = static_cast<sal_uInt16>(GetActiveWindow()->PixelToLogic( Size( | |||
1336 | FuPoor::HITPIX, 0 ) ).Width()); | |||
1337 | sal_uInt16 nHelpLine; | |||
1338 | ||||
1339 | mbMousePosFreezed = false; | |||
1340 | ||||
1341 | if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) ) | |||
1342 | { | |||
1343 | pPV->DeleteHelpLine( nHelpLine ); | |||
1344 | } | |||
1345 | Cancel(); | |||
1346 | rReq.Ignore (); | |||
1347 | } | |||
1348 | break; | |||
1349 | ||||
1350 | case SID_DELETE_PAGE(27000 +80): | |||
1351 | case SID_DELETE_MASTER_PAGE(27000 +432): | |||
1352 | DeleteActualPage(); | |||
1353 | Cancel(); | |||
1354 | rReq.Ignore (); | |||
1355 | break; | |||
1356 | ||||
1357 | case SID_DELETE_LAYER(27000 +81): | |||
1358 | DeleteActualLayer(); | |||
1359 | Cancel(); | |||
1360 | rReq.Ignore (); | |||
1361 | break; | |||
1362 | ||||
1363 | case SID_ORIGINAL_SIZE(27000 +282): | |||
1364 | mpDrawView->SetMarkedOriginalSize(); | |||
1365 | Cancel(); | |||
1366 | rReq.Done(); | |||
1367 | break; | |||
1368 | ||||
1369 | case SID_DRAW_FONTWORK( 10000 + 987 ): | |||
1370 | case SID_DRAW_FONTWORK_VERTICAL( 10000 + 988 ): | |||
1371 | { | |||
1372 | svx::FontworkBar::execute(*mpView, rReq, GetViewFrame()->GetBindings()); // SJ: can be removed (I think) | |||
1373 | Cancel(); | |||
1374 | rReq.Done(); | |||
1375 | } | |||
1376 | break; | |||
1377 | ||||
1378 | case SID_SAVE_GRAPHIC( 10000 + 1116 ): | |||
1379 | { | |||
1380 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
1381 | if( rMarkList.GetMarkCount() == 1 ) | |||
1382 | { | |||
1383 | const SdrGrafObj* pObj = dynamic_cast<const SdrGrafObj*>(rMarkList.GetMark(0)->GetMarkedSdrObj()); | |||
1384 | if (pObj && pObj->GetGraphicType() == GraphicType::Bitmap) | |||
1385 | { | |||
1386 | weld::Window* pFrame = GetFrameWeld(); | |||
1387 | GraphicAttr aGraphicAttr = pObj->GetGraphicAttr(); | |||
1388 | short nState = RET_CANCEL; | |||
1389 | if (aGraphicAttr != GraphicAttr()) // the image has been modified | |||
1390 | { | |||
1391 | if (pFrame) | |||
1392 | { | |||
1393 | nState = GraphicHelper::HasToSaveTransformedImage(pFrame); | |||
1394 | } | |||
1395 | } | |||
1396 | else | |||
1397 | { | |||
1398 | nState = RET_NO; | |||
1399 | } | |||
1400 | ||||
1401 | if (nState == RET_YES) | |||
1402 | { | |||
1403 | GraphicHelper::ExportGraphic(pFrame, pObj->GetTransformedGraphic(), ""); | |||
1404 | } | |||
1405 | else if (nState == RET_NO) | |||
1406 | { | |||
1407 | const GraphicObject& aGraphicObject(pObj->GetGraphicObject()); | |||
1408 | GraphicHelper::ExportGraphic(pFrame, aGraphicObject.GetGraphic(), ""); | |||
1409 | } | |||
1410 | } | |||
1411 | } | |||
1412 | Cancel(); | |||
1413 | rReq.Ignore(); | |||
1414 | } | |||
1415 | break; | |||
1416 | ||||
1417 | case SID_EXTERNAL_EDIT( 10000 + 1113 ): | |||
1418 | { | |||
1419 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
1420 | if( rMarkList.GetMarkCount() == 1 ) | |||
1421 | { | |||
1422 | SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); | |||
1423 | if( dynamic_cast< const SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) | |||
1424 | { | |||
1425 | GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() ); | |||
1426 | m_ExternalEdits.push_back( | |||
1427 | std::make_unique<SdrExternalToolEdit>( | |||
1428 | mpDrawView.get(), pObj)); | |||
1429 | m_ExternalEdits.back()->Edit( &aGraphicObject ); | |||
1430 | } | |||
1431 | } | |||
1432 | Cancel(); | |||
1433 | rReq.Ignore(); | |||
1434 | } | |||
1435 | break; | |||
1436 | ||||
1437 | case SID_COMPRESS_GRAPHIC( 10000 + 1117 ): | |||
1438 | { | |||
1439 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
1440 | if( rMarkList.GetMarkCount() == 1 ) | |||
1441 | { | |||
1442 | SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); | |||
1443 | ||||
1444 | if( dynamic_cast< const SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) | |||
1445 | { | |||
1446 | SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj); | |||
1447 | CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() ); | |||
1448 | if (dialog.run() == RET_OK) | |||
1449 | { | |||
1450 | SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj(); | |||
1451 | SdrPageView* pPageView = mpDrawView->GetSdrPageView(); | |||
1452 | OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects() + " Compress"; | |||
1453 | mpDrawView->BegUndo( aUndoString ); | |||
1454 | mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject ); | |||
1455 | mpDrawView->EndUndo(); | |||
1456 | } | |||
1457 | } | |||
1458 | } | |||
1459 | Cancel(); | |||
1460 | rReq.Ignore(); | |||
1461 | } | |||
1462 | break; | |||
1463 | ||||
1464 | case SID_ATTRIBUTES_LINE( 10000 + 143 ): // BASIC | |||
1465 | { | |||
1466 | SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1467 | if (rReq.GetArgs()) | |||
1468 | Cancel(); | |||
1469 | } | |||
1470 | break; | |||
1471 | ||||
1472 | case SID_ATTRIBUTES_AREA( 10000 + 142 ): // BASIC | |||
1473 | { | |||
1474 | SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1475 | if (rReq.GetArgs()) | |||
1476 | Cancel(); | |||
1477 | } | |||
1478 | break; | |||
1479 | ||||
1480 | case SID_ATTR_TRANSFORMTypedWhichId<SfxInt32Item>( 10000 + 87 ): | |||
1481 | { | |||
1482 | SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1483 | if (rReq.GetArgs()) | |||
1484 | { | |||
1485 | Invalidate(SID_RULER_OBJECTTypedWhichId<SvxRulerItem>( 10000 + 81 )); | |||
1486 | Cancel(); | |||
1487 | } | |||
1488 | } | |||
1489 | break; | |||
1490 | ||||
1491 | case SID_CHAR_DLG_EFFECT( 10000 + 1133 ): | |||
1492 | case SID_CHAR_DLG( 10000 + 296 ): // BASIC | |||
1493 | { | |||
1494 | SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1495 | Cancel(); | |||
1496 | } | |||
1497 | break; | |||
1498 | ||||
1499 | case SID_PARA_DLG( 10000 + 297 ): | |||
1500 | { | |||
1501 | SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1502 | Cancel(); | |||
1503 | } | |||
1504 | break; | |||
1505 | ||||
1506 | case FN_NUM_BULLET_ON((20000 + 100) + 38): | |||
1507 | { | |||
1508 | // The value (sal_uInt16)0xFFFF means set bullet on/off. | |||
1509 | SfxUInt16Item aItem(FN_SVX_SET_BULLET( 10000 + 1137 ), sal_uInt16(0xFFFF)); | |||
1510 | GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_BULLET( 10000 + 1137 ), | |||
1511 | SfxCallMode::RECORD, { &aItem }); | |||
1512 | } | |||
1513 | break; | |||
1514 | ||||
1515 | case FN_NUM_NUMBERING_ON((20000 + 100) + 44): | |||
1516 | { | |||
1517 | // The value (sal_uInt16)0xFFFF means set bullet on/off. | |||
1518 | SfxUInt16Item aItem(FN_SVX_SET_NUMBER( 10000 + 1136 ), sal_uInt16(0xFFFF)); | |||
1519 | GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_NUMBER( 10000 + 1136 ), | |||
1520 | SfxCallMode::RECORD, { &aItem }); | |||
1521 | } | |||
1522 | break; | |||
1523 | ||||
1524 | case SID_OUTLINE_BULLET( 10000 + 156 ): | |||
1525 | case FN_SVX_SET_BULLET( 10000 + 1137 ): | |||
1526 | case FN_SVX_SET_NUMBER( 10000 + 1136 ): | |||
1527 | { | |||
1528 | SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1529 | Cancel(); | |||
1530 | } | |||
1531 | break; | |||
1532 | ||||
1533 | case FN_INSERT_SOFT_HYPHEN((20000 + 300) + 43): | |||
1534 | case FN_INSERT_HARDHYPHEN((20000 + 300) + 85): | |||
1535 | case FN_INSERT_HARD_SPACE((20000 + 300) + 44): | |||
1536 | case FN_INSERT_NNBSP((20000 + 300) + 45): | |||
1537 | case SID_INSERT_RLM( 10000 + 1056 ) : | |||
1538 | case SID_INSERT_LRM( 10000 + 1057 ) : | |||
1539 | case SID_INSERT_ZWNBSP( 10000 + 1059 ) : | |||
1540 | case SID_INSERT_ZWSP( 10000 + 1058 ): | |||
1541 | case SID_CHARMAP((10000 + 500) + 3): | |||
1542 | { | |||
1543 | SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1544 | Cancel(); | |||
1545 | } | |||
1546 | break; | |||
1547 | ||||
1548 | case SID_PRESENTATION_LAYOUT(27000 +64): | |||
1549 | { | |||
1550 | SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); | |||
1551 | Cancel(); | |||
1552 | } | |||
1553 | break; | |||
1554 | ||||
1555 | case SID_PASTE_SPECIAL(5000 + 311): | |||
1556 | { | |||
1557 | SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1558 | Cancel(); | |||
1559 | rReq.Ignore (); | |||
1560 | } | |||
1561 | break; | |||
1562 | ||||
1563 | case SID_CHANGE_PICTURE( 10000 + 1115 ): | |||
1564 | case SID_INSERT_GRAPHICTypedWhichId<SfxStringItem>( 10000 + 241 ): | |||
1565 | { | |||
1566 | SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, | |||
1567 | nSId == SID_CHANGE_PICTURE( 10000 + 1115 ) ) ); | |||
1568 | Cancel(); | |||
1569 | rReq.Ignore (); | |||
1570 | } | |||
1571 | break; | |||
1572 | ||||
1573 | case SID_INSERT_AVMEDIA(5000 + 1696): | |||
1574 | { | |||
1575 | SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1576 | ||||
1577 | Cancel(); | |||
1578 | rReq.Ignore (); | |||
1579 | } | |||
1580 | break; | |||
1581 | ||||
1582 | case SID_INSERT_OBJECT(5000 + 561): | |||
1583 | case SID_INSERT_FLOATINGFRAME(5000 + 563): | |||
1584 | case SID_INSERT_MATH(27000 +106): | |||
1585 | case SID_INSERT_DIAGRAM( 10000 + 140 ): | |||
1586 | case SID_ATTR_TABLE( 10000 + 217 ): | |||
1587 | { | |||
1588 | SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1589 | // Set the selection tool as the old one. This in particular important for the | |||
1590 | // zoom function, in which clicking without dragging zooms as well, and that | |||
1591 | // makes exiting the object editing mode impossible. | |||
1592 | if (dynamic_cast<FuSelection*>( GetOldFunction().get() ) == nullptr) | |||
1593 | SetOldFunction( FuSelection::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1594 | Cancel(); | |||
1595 | rReq.Ignore (); | |||
1596 | } | |||
1597 | break; | |||
1598 | case SID_CLASSIFICATION_APPLY(5000 + 672): | |||
1599 | { | |||
1600 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1601 | const SfxPoolItem* pItem = nullptr; | |||
1602 | if (pArgs && pArgs->GetItemState(nSId, false, &pItem) == SfxItemState::SET) | |||
1603 | { | |||
1604 | const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1605 | auto eType = SfxClassificationPolicyType::IntellectualProperty; | |||
1606 | if (pArgs->GetItemState(SID_TYPE_NAME(5000 + 533), false, &pItem) == SfxItemState::SET) | |||
1607 | { | |||
1608 | const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1609 | eType = SfxClassificationHelper::stringToPolicyType(rType); | |||
1610 | } | |||
1611 | if (SfxViewFrame* pViewFrame = GetViewFrame()) | |||
1612 | { | |||
1613 | if (SfxObjectShell* pObjectShell = pViewFrame->GetObjectShell()) | |||
1614 | { | |||
1615 | SfxClassificationHelper aHelper(pObjectShell->getDocProperties()); | |||
1616 | aHelper.SetBACName(rName, eType); | |||
1617 | } | |||
1618 | } | |||
1619 | } | |||
1620 | else | |||
1621 | SAL_WARN("sd.ui", "missing parameter for SID_CLASSIFICATION_APPLY")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sd.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing parameter for SID_CLASSIFICATION_APPLY") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.ui" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1621" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "missing parameter for SID_CLASSIFICATION_APPLY" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing parameter for SID_CLASSIFICATION_APPLY"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.ui"), ( "/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1621" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing parameter for SID_CLASSIFICATION_APPLY") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.ui" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1621" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "missing parameter for SID_CLASSIFICATION_APPLY" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing parameter for SID_CLASSIFICATION_APPLY"; :: sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.ui"), ( "/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "1621" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1622 | ||||
1623 | Cancel(); | |||
1624 | rReq.Ignore(); | |||
1625 | } | |||
1626 | break; | |||
1627 | ||||
1628 | case SID_CLASSIFICATION_DIALOG( 10000 + 1171 ): | |||
1629 | { | |||
1630 | auto xDialog = std::make_shared<svx::ClassificationDialog>(GetFrameWeld(), false, [](){} ); | |||
1631 | ClassificationCollector aCollector(*this); | |||
1632 | aCollector.collect(); | |||
1633 | ||||
1634 | xDialog->setupValues(aCollector.getResults()); | |||
1635 | ||||
1636 | if (RET_OK == xDialog->run()) | |||
1637 | { | |||
1638 | ClassificationInserter aInserter(*this); | |||
1639 | aInserter.insert(xDialog->getResult()); | |||
1640 | } | |||
1641 | xDialog.reset(); | |||
1642 | ||||
1643 | Cancel(); | |||
1644 | rReq.Ignore(); | |||
1645 | } | |||
1646 | break; | |||
1647 | ||||
1648 | case SID_COPYOBJECTS(27000 +4): | |||
1649 | { | |||
1650 | if ( mpDrawView->IsPresObjSelected(false) ) | |||
1651 | { | |||
1652 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1653 | VclMessageType::Info, VclButtonsType::Ok, | |||
1654 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
1655 | xInfoBox->run(); | |||
1656 | } | |||
1657 | else | |||
1658 | { | |||
1659 | if ( mpDrawView->IsTextEdit() ) | |||
1660 | { | |||
1661 | mpDrawView->SdrEndTextEdit(); | |||
1662 | } | |||
1663 | ||||
1664 | SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1665 | } | |||
1666 | Cancel(); | |||
1667 | rReq.Ignore (); | |||
1668 | } | |||
1669 | break; | |||
1670 | ||||
1671 | case SID_INSERTFILE(27000 +15): // BASIC | |||
1672 | { | |||
1673 | Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); | |||
1674 | SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1675 | Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); | |||
1676 | Cancel(); | |||
1677 | rReq.Done (); | |||
1678 | } | |||
1679 | break; | |||
1680 | ||||
1681 | case SID_SELECT_BACKGROUND(27000 +422): | |||
1682 | case SID_SAVE_BACKGROUND(27000 +423): | |||
1683 | case SID_ATTR_PAGE_SIZETypedWhichId<SvxSizeItem>( 10000 + 51 ): | |||
1684 | case SID_ATTR_PAGETypedWhichId<SvxPageItem>( 10000 + 50 ): | |||
1685 | case SID_PAGESETUP(27000 +2): // BASIC ?? | |||
1686 | { | |||
1687 | SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1688 | Cancel(); | |||
1689 | rReq.Ignore (); // we generate independent macros !! | |||
1690 | } | |||
1691 | break; | |||
1692 | ||||
1693 | case SID_BEFORE_OBJ(27000 +181): | |||
1694 | case SID_BEHIND_OBJ(27000 +146): | |||
1695 | { | |||
1696 | SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); | |||
1697 | rReq.Done(); | |||
1698 | // finishes itself, no Cancel() needed! | |||
1699 | } | |||
1700 | break; | |||
1701 | ||||
1702 | case SID_REVERSE_ORDER(27000 +117): // BASIC | |||
1703 | { | |||
1704 | mpDrawView->ReverseOrderOfMarked(); | |||
1705 | Cancel(); | |||
1706 | rReq.Done (); | |||
1707 | } | |||
1708 | break; | |||
1709 | ||||
1710 | case SID_ANIMATION_EFFECTS(27000 +63): | |||
1711 | { | |||
1712 | SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); | |||
1713 | Cancel(); | |||
1714 | } | |||
1715 | break; | |||
1716 | ||||
1717 | case SID_EXECUTE_ANIMATION_EFFECT(27000 +72): | |||
1718 | { | |||
1719 | SetCurrentFunction(FuExecuteInteraction::Create(this, GetActiveWindow(), | |||
1720 | mpDrawView.get(), GetDoc(), rReq)); | |||
1721 | Cancel(); | |||
1722 | } | |||
1723 | break; | |||
1724 | ||||
1725 | case SID_LINEEND_POLYGON(27000 +71): | |||
1726 | { | |||
1727 | SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1728 | Cancel(); | |||
1729 | } | |||
1730 | break; | |||
1731 | ||||
1732 | case SID_CAPTUREPOINT(27000 +38): | |||
1733 | // negative value to signal call from menu | |||
1734 | maMousePos = Point(-1,-1); | |||
1735 | [[fallthrough]]; | |||
1736 | case SID_SET_SNAPITEM(27000 +77): | |||
1737 | { | |||
1738 | SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); | |||
1739 | Cancel(); | |||
1740 | } | |||
1741 | break; | |||
1742 | ||||
1743 | case SID_MANAGE_LINKS(27000 +5): | |||
1744 | { | |||
1745 | SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1746 | Cancel(); | |||
1747 | rReq.Ignore (); | |||
1748 | } | |||
1749 | break; | |||
1750 | ||||
1751 | case SID_THESAURUS( 10000 + 245 ): | |||
1752 | { | |||
1753 | SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1754 | Cancel(); | |||
1755 | rReq.Ignore (); | |||
1756 | } | |||
1757 | break; | |||
1758 | ||||
1759 | case SID_TEXTATTR_DLG(27000 +281): | |||
1760 | { | |||
1761 | if (mpDrawView->IsTextEdit()) | |||
1762 | mpDrawView->SdrEndTextEdit(); | |||
1763 | SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1764 | Cancel(); | |||
1765 | rReq.Ignore (); | |||
1766 | } | |||
1767 | break; | |||
1768 | ||||
1769 | case SID_MEASURE_DLG( 10000 + 1176 ): | |||
1770 | { | |||
1771 | SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1772 | Cancel(); | |||
1773 | rReq.Ignore (); | |||
1774 | } | |||
1775 | break; | |||
1776 | ||||
1777 | case SID_CONNECTION_DLG(27000 +338): | |||
1778 | { | |||
1779 | SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1780 | Cancel(); | |||
1781 | rReq.Done(); | |||
1782 | } | |||
1783 | break; | |||
1784 | ||||
1785 | case SID_CONNECTION_NEW_ROUTING(27000 +341): | |||
1786 | { | |||
1787 | SfxItemSet aDefAttr( GetPool(), svl::Items<SDRATTR_EDGELINE1DELTA, SDRATTR_EDGELINE3DELTA>{} ); | |||
1788 | GetView()->SetAttributes( aDefAttr, true ); // (ReplaceAll) | |||
1789 | ||||
1790 | Cancel(); | |||
1791 | rReq.Done(); | |||
1792 | } | |||
1793 | break; | |||
1794 | ||||
1795 | case SID_TWAIN_SELECT( 10000 + 331 ): | |||
1796 | { | |||
1797 | if( mxScannerManager.is() ) | |||
1798 | { | |||
1799 | try | |||
1800 | { | |||
1801 | const css::uno::Sequence< css::scanner::ScannerContext > | |||
1802 | aContexts( mxScannerManager->getAvailableScanners() ); | |||
1803 | ||||
1804 | if( aContexts.hasElements() ) | |||
1805 | { | |||
1806 | css::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] ); | |||
1807 | ||||
1808 | Reference<lang::XInitialization> xInit(mxScannerManager, UNO_QUERY); | |||
1809 | if (xInit.is()) | |||
1810 | { | |||
1811 | // initialize dialog | |||
1812 | weld::Window* pWindow = rReq.GetFrameWeld(); | |||
1813 | uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( | |||
1814 | { | |||
1815 | {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference<awt::XWindow>())} | |||
1816 | })); | |||
1817 | xInit->initialize( aSeq ); | |||
1818 | } | |||
1819 | ||||
1820 | mxScannerManager->configureScannerAndScan( aContext, mxScannerListener ); | |||
1821 | } | |||
1822 | } | |||
1823 | catch(...) | |||
1824 | { | |||
1825 | } | |||
1826 | } | |||
1827 | ||||
1828 | Cancel(); | |||
1829 | rReq.Done(); | |||
1830 | } | |||
1831 | break; | |||
1832 | ||||
1833 | case SID_TWAIN_TRANSFER( 10000 + 332 ): | |||
1834 | { | |||
1835 | bool bDone = false; | |||
1836 | ||||
1837 | if( mxScannerManager.is() ) | |||
1838 | { | |||
1839 | try | |||
1840 | { | |||
1841 | const css::uno::Sequence< css::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() ); | |||
1842 | ||||
1843 | if( aContexts.hasElements() ) | |||
1844 | { | |||
1845 | mxScannerManager->startScan( aContexts.getConstArray()[ 0 ], mxScannerListener ); | |||
1846 | bDone = true; | |||
1847 | } | |||
1848 | } | |||
1849 | catch( ... ) | |||
1850 | { | |||
1851 | } | |||
1852 | } | |||
1853 | ||||
1854 | if( !bDone ) | |||
1855 | { | |||
1856 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
1857 | VclMessageType::Info, VclButtonsType::Ok, | |||
1858 | #ifndef UNX1 | |||
1859 | SdResId(STR_TWAIN_NO_SOURCEreinterpret_cast<char const *>("STR_TWAIN_NO_SOURCE" "\004" u8"At present, no TWAIN source is available.")) | |||
1860 | #else | |||
1861 | SdResId(STR_TWAIN_NO_SOURCE_UNXreinterpret_cast<char const *>("STR_TWAIN_NO_SOURCE_UNX" "\004" u8"No SANE source is available at the moment.")) | |||
1862 | #endif | |||
1863 | )); | |||
1864 | xInfoBox->run(); | |||
1865 | ||||
1866 | } | |||
1867 | else | |||
1868 | { | |||
1869 | SfxBindings& rBindings = GetViewFrame()->GetBindings(); | |||
1870 | rBindings.Invalidate( SID_TWAIN_SELECT( 10000 + 331 ) ); | |||
1871 | rBindings.Invalidate( SID_TWAIN_TRANSFER( 10000 + 332 ) ); | |||
1872 | } | |||
1873 | ||||
1874 | Cancel(); | |||
1875 | rReq.Done(); | |||
1876 | } | |||
1877 | break; | |||
1878 | ||||
1879 | case SID_POLYGON_MORPHING(27000 +319): | |||
1880 | { | |||
1881 | SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
1882 | Cancel(); | |||
1883 | } | |||
1884 | break; | |||
1885 | ||||
1886 | case SID_INSERTLAYER(27000 +39): | |||
1887 | { | |||
1888 | if ( mpDrawView->IsTextEdit() ) | |||
1889 | { | |||
1890 | mpDrawView->SdrEndTextEdit(); | |||
1891 | } | |||
1892 | ||||
1893 | SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); | |||
1894 | sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); | |||
1895 | sal_uInt16 nLayer = nLayerCnt - 2 + 1; | |||
1896 | OUString aLayerName = SdResId(STR_LAYERreinterpret_cast<char const *>("STR_LAYER" "\004" u8"Layer" )) + OUString::number(nLayer); | |||
1897 | OUString aLayerTitle, aLayerDesc; | |||
1898 | bool bIsVisible = false; | |||
1899 | bool bIsLocked = false; | |||
1900 | bool bIsPrintable = false; | |||
1901 | ||||
1902 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1903 | ||||
1904 | if (! pArgs) | |||
1905 | { | |||
1906 | SfxItemSet aNewAttr( GetDoc()->GetPool(), svl::Items<ATTR_LAYER_START27000 + 1234, ATTR_LAYER_END27000 + 1234 + 6>{} ); | |||
1907 | ||||
1908 | aNewAttr.Put( makeSdAttrLayerName( aLayerName ) ); | |||
1909 | aNewAttr.Put( makeSdAttrLayerTitle() ); | |||
1910 | aNewAttr.Put( makeSdAttrLayerDesc() ); | |||
1911 | aNewAttr.Put( makeSdAttrLayerVisible() ); | |||
1912 | aNewAttr.Put( makeSdAttrLayerPrintable() ); | |||
1913 | aNewAttr.Put( makeSdAttrLayerLocked() ); | |||
1914 | aNewAttr.Put( makeSdAttrLayerThisPage() ); | |||
1915 | ||||
1916 | SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); | |||
1917 | vcl::Window* pWin = GetActiveWindow(); | |||
1918 | ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, true, SdResId(STR_INSERTLAYERreinterpret_cast<char const *>("STR_INSERTLAYER" "\004" u8"Insert Layer"))) ); | |||
1919 | pDlg->SetHelpId( SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule ::Draw)) )->GetSlotPool()->GetSlot( SID_INSERTLAYER(27000 +39) )->GetCommand() ); | |||
1920 | ||||
1921 | // test for already existing names | |||
1922 | bool bLoop = true; | |||
1923 | while( bLoop && pDlg->Execute() == RET_OK ) | |||
1924 | { | |||
1925 | pDlg->GetAttr( aNewAttr ); | |||
1926 | aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME27000 + 1234)).GetValue (); | |||
1927 | ||||
1928 | if( rLayerAdmin.GetLayer( aLayerName ) | |||
1929 | || aLayerName.isEmpty() | |||
1930 | || LayerTabBar::IsLocalizedNameOfStandardLayer( aLayerName) ) | |||
1931 | { | |||
1932 | // name already exists | |||
1933 | std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), | |||
1934 | VclMessageType::Warning, VclButtonsType::Ok, | |||
1935 | SdResId(STR_WARN_NAME_DUPLICATEreinterpret_cast<char const *>("STR_WARN_NAME_DUPLICATE" "\004" u8"The name chosen already exists. \nPlease enter another name." )))); | |||
1936 | xWarn->run(); | |||
1937 | } | |||
1938 | else | |||
1939 | bLoop = false; | |||
1940 | } | |||
1941 | if( bLoop ) // was canceled | |||
1942 | { | |||
1943 | pDlg.disposeAndClear(); | |||
1944 | Cancel(); | |||
1945 | rReq.Ignore (); | |||
1946 | break; | |||
1947 | } | |||
1948 | else | |||
1949 | { | |||
1950 | aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE27000 + 1234 + 5)).GetValue (); | |||
1951 | aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC27000 + 1234 + 6)).GetValue (); | |||
1952 | bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE27000 + 1234 + 1)).GetValue (); | |||
1953 | bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED27000 + 1234 + 3)).GetValue () ; | |||
1954 | bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE27000 + 1234 + 2)).GetValue () ; | |||
1955 | } | |||
1956 | } | |||
1957 | else if (pArgs->Count () != 4) | |||
1958 | { | |||
1959 | #if HAVE_FEATURE_SCRIPTING1 | |||
1960 | StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGSErrCode( ErrCodeArea::Sbx, ErrCodeClass::Sbx, 28)); | |||
1961 | #endif | |||
1962 | Cancel(); | |||
1963 | rReq.Ignore (); | |||
1964 | break; | |||
1965 | } | |||
1966 | else | |||
1967 | { | |||
1968 | const SfxStringItem* pLayerName = rReq.GetArg<SfxStringItem>(ID_VAL_LAYERNAME(27000 +229)); | |||
1969 | const SfxBoolItem* pIsVisible = rReq.GetArg<SfxBoolItem>(ID_VAL_ISVISIBLE(27000 +249)); | |||
1970 | const SfxBoolItem* pIsLocked = rReq.GetArg<SfxBoolItem>(ID_VAL_ISLOCKED(27000 +231)); | |||
1971 | const SfxBoolItem* pIsPrintable = rReq.GetArg<SfxBoolItem>(ID_VAL_ISPRINTABLE(27000 +232)); | |||
1972 | ||||
1973 | aLayerName = pLayerName->GetValue (); | |||
1974 | bIsVisible = pIsVisible->GetValue (); | |||
1975 | bIsLocked = pIsLocked->GetValue (); | |||
1976 | bIsPrintable = pIsPrintable->GetValue (); | |||
1977 | } | |||
1978 | ||||
1979 | OUString aPrevLayer = mpDrawView->GetActiveLayer(); | |||
1980 | SdrLayer* pLayer; | |||
1981 | sal_uInt16 nPrevLayer = 0; | |||
1982 | nLayerCnt = rLayerAdmin.GetLayerCount(); | |||
1983 | ||||
1984 | for ( nLayer = 0; nLayer < nLayerCnt; nLayer++ ) | |||
1985 | { | |||
1986 | pLayer = rLayerAdmin.GetLayer(nLayer); | |||
1987 | OUString aName = pLayer->GetName(); | |||
1988 | ||||
1989 | if ( aPrevLayer == aName ) | |||
1990 | { | |||
1991 | nPrevLayer = std::max(nLayer, sal_uInt16(4)); | |||
1992 | } | |||
1993 | } | |||
1994 | ||||
1995 | mpDrawView->InsertNewLayer(aLayerName, nPrevLayer + 1); | |||
1996 | pLayer = rLayerAdmin.GetLayer(aLayerName); | |||
1997 | if( pLayer ) | |||
1998 | { | |||
1999 | pLayer->SetTitle( aLayerTitle ); | |||
2000 | pLayer->SetDescription( aLayerDesc ); | |||
2001 | } | |||
2002 | ||||
2003 | mpDrawView->SetLayerVisible( aLayerName, bIsVisible ); | |||
2004 | mpDrawView->SetLayerLocked( aLayerName, bIsLocked); | |||
2005 | mpDrawView->SetLayerPrintable(aLayerName, bIsPrintable); | |||
2006 | ||||
2007 | mpDrawView->SetActiveLayer(aLayerName); | |||
2008 | ||||
2009 | ResetActualLayer(); | |||
2010 | ||||
2011 | GetDoc()->SetChanged(); | |||
2012 | ||||
2013 | GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHLAYER(27000 +44), | |||
2014 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); | |||
2015 | ||||
2016 | Cancel(); | |||
2017 | rReq.Done (); | |||
2018 | } | |||
2019 | break; | |||
2020 | ||||
2021 | case SID_MODIFYLAYER(27000 +45): | |||
2022 | { | |||
2023 | if(!GetLayerTabControl()) // #i87182# | |||
2024 | { | |||
2025 | OSL_ENSURE(false, "No LayerTabBar (!)")do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "2025" ": "), "%s", "No LayerTabBar (!)"); } } while (false ); | |||
2026 | Cancel(); | |||
2027 | rReq.Ignore(); | |||
2028 | break; | |||
2029 | } | |||
2030 | ||||
2031 | if ( mpDrawView->IsTextEdit() ) | |||
2032 | { | |||
2033 | mpDrawView->SdrEndTextEdit(); | |||
2034 | } | |||
2035 | ||||
2036 | SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); | |||
2037 | sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId(); | |||
2038 | OUString aLayerName = GetLayerTabControl()->GetLayerName(nCurPage); | |||
2039 | SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName); | |||
2040 | ||||
2041 | OUString aLayerTitle = pLayer->GetTitle(); | |||
2042 | OUString aLayerDesc = pLayer->GetDescription(); | |||
2043 | ||||
2044 | OUString aOldLayerName(aLayerName); | |||
2045 | OUString aOldLayerTitle(aLayerTitle); | |||
2046 | OUString aOldLayerDesc(aLayerDesc); | |||
2047 | ||||
2048 | bool bIsVisible, bIsLocked, bIsPrintable; | |||
2049 | bool bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName); | |||
2050 | bool bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName); | |||
2051 | bool bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName); | |||
2052 | ||||
2053 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
2054 | // is it allowed to delete the layer? | |||
2055 | bool bDelete = !( LayerTabBar::IsRealNameOfStandardLayer(aLayerName) ); | |||
2056 | ||||
2057 | if (! pArgs) | |||
2058 | { | |||
2059 | SfxItemSet aNewAttr( GetDoc()->GetPool(), svl::Items<ATTR_LAYER_START27000 + 1234, ATTR_LAYER_END27000 + 1234 + 6>{} ); | |||
2060 | ||||
2061 | aNewAttr.Put( makeSdAttrLayerName( aLayerName ) ); | |||
2062 | aNewAttr.Put( makeSdAttrLayerTitle( aLayerTitle ) ); | |||
2063 | aNewAttr.Put( makeSdAttrLayerDesc( aLayerDesc ) ); | |||
2064 | aNewAttr.Put( makeSdAttrLayerVisible( bIsVisible ) ); | |||
2065 | aNewAttr.Put( makeSdAttrLayerLocked( bIsLocked ) ); | |||
2066 | aNewAttr.Put( makeSdAttrLayerPrintable( bIsPrintable ) ); | |||
2067 | aNewAttr.Put( makeSdAttrLayerThisPage() ); | |||
2068 | ||||
2069 | SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); | |||
2070 | vcl::Window* pWin = GetActiveWindow(); | |||
2071 | ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, bDelete, SdResId(STR_MODIFYLAYERreinterpret_cast<char const *>("STR_MODIFYLAYER" "\004" u8"Modify Layer"))) ); | |||
2072 | pDlg->SetHelpId( SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule ::Draw)) )->GetSlotPool()->GetSlot( SID_MODIFYLAYER(27000 +45) )->GetCommand() ); | |||
2073 | ||||
2074 | // test for already existing names | |||
2075 | bool bLoop = true; | |||
2076 | sal_uInt16 nRet = 0; | |||
2077 | while( bLoop ) | |||
2078 | { | |||
2079 | nRet = pDlg->Execute(); | |||
2080 | if (nRet != RET_OK) | |||
2081 | break; | |||
2082 | pDlg->GetAttr( aNewAttr ); | |||
2083 | aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME27000 + 1234)).GetValue (); | |||
2084 | if (bDelete) | |||
2085 | { | |||
2086 | if( (rLayerAdmin.GetLayer( aLayerName ) && aLayerName != aOldLayerName) | |||
2087 | || LayerTabBar::IsRealNameOfStandardLayer(aLayerName) | |||
2088 | || LayerTabBar::IsLocalizedNameOfStandardLayer(aLayerName) | |||
2089 | || aLayerName.isEmpty() ) | |||
2090 | { | |||
2091 | // name already exists | |||
2092 | std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), | |||
2093 | VclMessageType::Warning, VclButtonsType::Ok, | |||
2094 | SdResId(STR_WARN_NAME_DUPLICATEreinterpret_cast<char const *>("STR_WARN_NAME_DUPLICATE" "\004" u8"The name chosen already exists. \nPlease enter another name." )))); | |||
2095 | xWarn->run(); | |||
2096 | } | |||
2097 | else | |||
2098 | bLoop = false; | |||
2099 | } | |||
2100 | else | |||
2101 | bLoop = false; // altering name is already disabled in the dialog itself | |||
2102 | } | |||
2103 | switch (nRet) | |||
2104 | { | |||
2105 | case RET_OK : | |||
2106 | aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE27000 + 1234 + 5)).GetValue (); | |||
2107 | aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC27000 + 1234 + 6)).GetValue (); | |||
2108 | bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE27000 + 1234 + 1)).GetValue (); | |||
2109 | bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED27000 + 1234 + 3)).GetValue (); | |||
2110 | bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE27000 + 1234 + 2)).GetValue (); | |||
2111 | break; | |||
2112 | ||||
2113 | default : | |||
2114 | pDlg.disposeAndClear(); | |||
2115 | rReq.Ignore (); | |||
2116 | Cancel (); | |||
2117 | return; | |||
2118 | } | |||
2119 | } | |||
2120 | else if (pArgs->Count () == 4) | |||
2121 | { | |||
2122 | const SfxStringItem* pLayerName = rReq.GetArg<SfxStringItem>(ID_VAL_LAYERNAME(27000 +229)); | |||
2123 | const SfxBoolItem* pIsVisible = rReq.GetArg<SfxBoolItem>(ID_VAL_ISVISIBLE(27000 +249)); | |||
2124 | const SfxBoolItem* pIsLocked = rReq.GetArg<SfxBoolItem>(ID_VAL_ISLOCKED(27000 +231)); | |||
2125 | const SfxBoolItem* pIsPrintable = rReq.GetArg<SfxBoolItem>(ID_VAL_ISPRINTABLE(27000 +232)); | |||
2126 | ||||
2127 | aLayerName = pLayerName->GetValue (); | |||
2128 | bIsVisible = pIsVisible->GetValue (); | |||
2129 | bIsLocked = pIsLocked->GetValue (); | |||
2130 | bIsPrintable = pIsPrintable->GetValue (); | |||
2131 | } | |||
2132 | else | |||
2133 | { | |||
2134 | #if HAVE_FEATURE_SCRIPTING1 | |||
2135 | StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGSErrCode( ErrCodeArea::Sbx, ErrCodeClass::Sbx, 28)); | |||
2136 | #endif | |||
2137 | Cancel (); | |||
2138 | rReq.Ignore (); | |||
2139 | break; | |||
2140 | } | |||
2141 | ||||
2142 | SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager(); | |||
2143 | std::unique_ptr<SdLayerModifyUndoAction> pAction( new SdLayerModifyUndoAction( | |||
2144 | GetDoc(), | |||
2145 | pLayer, | |||
2146 | // old values | |||
2147 | aOldLayerName, | |||
2148 | aOldLayerTitle, | |||
2149 | aOldLayerDesc, | |||
2150 | bOldIsVisible, | |||
2151 | bOldIsLocked, | |||
2152 | bOldIsPrintable, | |||
2153 | // new values | |||
2154 | aLayerName, | |||
2155 | aLayerTitle, | |||
2156 | aLayerDesc, | |||
2157 | bIsVisible, | |||
2158 | bIsLocked, | |||
2159 | bIsPrintable | |||
2160 | ) ); | |||
2161 | pManager->AddUndoAction( std::move(pAction) ); | |||
2162 | ||||
2163 | ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable ); | |||
2164 | ||||
2165 | Cancel(); | |||
2166 | rReq.Done (); | |||
2167 | } | |||
2168 | break; | |||
2169 | ||||
2170 | case SID_RENAMELAYER(27000 +269): | |||
2171 | { | |||
2172 | if ( mpDrawView->IsTextEdit() ) | |||
2173 | { | |||
2174 | mpDrawView->SdrEndTextEdit(); | |||
2175 | } | |||
2176 | ||||
2177 | if(GetLayerTabControl()) // #i87182# | |||
2178 | { | |||
2179 | GetLayerTabControl()->StartEditMode(GetLayerTabControl()->GetCurPageId()); | |||
2180 | } | |||
2181 | else | |||
2182 | { | |||
2183 | OSL_ENSURE(false, "No LayerTabBar (!)")do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "2183" ": "), "%s", "No LayerTabBar (!)"); } } while (false ); | |||
2184 | } | |||
2185 | ||||
2186 | Cancel(); | |||
2187 | rReq.Ignore (); | |||
2188 | } | |||
2189 | break; | |||
2190 | ||||
2191 | case SID_EDIT_HYPERLINK( 10000 + 978 ) : | |||
2192 | { | |||
2193 | // Ensure the field is selected first | |||
2194 | OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); | |||
2195 | if (pOutView) | |||
2196 | pOutView->SelectFieldAtCursor(); | |||
2197 | ||||
2198 | GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG(5000 + 678) ); | |||
2199 | ||||
2200 | Cancel(); | |||
2201 | rReq.Done (); | |||
2202 | } | |||
2203 | break; | |||
2204 | ||||
2205 | case SID_OPEN_HYPERLINK( 10000 + 955 ): | |||
2206 | { | |||
2207 | OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); | |||
2208 | if ( pOutView ) | |||
2209 | { | |||
2210 | const SvxFieldData* pField = pOutView->GetFieldAtCursor(); | |||
2211 | if( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) ) | |||
2212 | { | |||
2213 | SfxStringItem aUrl( SID_FILE_NAME(5000 + 507), pURLField->GetURL() ); | |||
2214 | SfxStringItem aTarget( SID_TARGETNAME(5000 + 560), pURLField->GetTargetFrame() ); | |||
2215 | ||||
2216 | OUString aReferName; | |||
2217 | SfxViewFrame* pFrame = GetViewFrame(); | |||
2218 | SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium(); | |||
2219 | if (pMed) | |||
2220 | aReferName = pMed->GetName(); | |||
2221 | ||||
2222 | SfxFrameItem aFrm( SID_DOCFRAME(5000 + 598), pFrame ); | |||
2223 | SfxStringItem aReferer( SID_REFERER(5000 + 654), aReferName ); | |||
2224 | ||||
2225 | SfxBoolItem aNewView( SID_OPEN_NEW_VIEW(5000 + 520), false ); | |||
2226 | SfxBoolItem aBrowsing( SID_BROWSE(5000 + 1658), true ); | |||
2227 | ||||
2228 | SfxViewFrame* pViewFrm = SfxViewFrame::Current(); | |||
2229 | if (pViewFrm) | |||
2230 | { | |||
2231 | pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC(5000 + 501), | |||
2232 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, | |||
2233 | { &aUrl, &aTarget, &aFrm, &aReferer, | |||
2234 | &aNewView, &aBrowsing }); | |||
2235 | } | |||
2236 | } | |||
2237 | } | |||
2238 | Cancel(); | |||
2239 | rReq.Done (); | |||
2240 | } | |||
2241 | break; | |||
2242 | ||||
2243 | case SID_COPY_HYPERLINK_LOCATION( 10000 + 1193 ): | |||
2244 | { | |||
2245 | OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); | |||
2246 | if ( pOutView ) | |||
2247 | { | |||
2248 | const SvxFieldData* pField = pOutView->GetFieldAtCursor(); | |||
2249 | if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) | |||
2250 | { | |||
2251 | uno::Reference<datatransfer::clipboard::XClipboard> xClipboard | |||
2252 | = pOutView->GetWindow()->GetClipboard(); | |||
2253 | ||||
2254 | if (comphelper::LibreOfficeKit::isActive()) | |||
2255 | { | |||
2256 | std::function<void (int, const char*)> callback = [&] (int callbackType, const char* text) | |||
2257 | { | |||
2258 | SfxViewFrame* pFrame = GetViewFrame(); | |||
2259 | pFrame->GetViewShell()->libreOfficeKitViewCallback(callbackType, text); | |||
2260 | }; | |||
2261 | vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, &callback); | |||
2262 | } | |||
2263 | else | |||
2264 | vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard); | |||
2265 | } | |||
2266 | } | |||
2267 | ||||
2268 | Cancel(); | |||
2269 | rReq.Done (); | |||
2270 | } | |||
2271 | break; | |||
2272 | ||||
2273 | case SID_HYPERLINK_SETLINKTypedWhichId<SvxHyperlinkItem>(10000 + 362): | |||
2274 | { | |||
2275 | const SfxItemSet* pReqArgs = rReq.GetArgs(); | |||
2276 | ||||
2277 | if (pReqArgs) | |||
2278 | { | |||
2279 | const SvxHyperlinkItem* pHLItem = | |||
2280 | &pReqArgs->Get(SID_HYPERLINK_SETLINKTypedWhichId<SvxHyperlinkItem>(10000 + 362)); | |||
2281 | ||||
2282 | if (pHLItem->GetInsertMode() == HLINK_FIELD) | |||
2283 | { | |||
2284 | InsertURLField(pHLItem->GetURL(), pHLItem->GetName(), | |||
2285 | pHLItem->GetTargetFrame()); | |||
2286 | } | |||
2287 | else if (pHLItem->GetInsertMode() == HLINK_BUTTON) | |||
2288 | { | |||
2289 | InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(), | |||
2290 | pHLItem->GetTargetFrame(), nullptr); | |||
2291 | } | |||
2292 | else if (pHLItem->GetInsertMode() == HLINK_DEFAULT) | |||
2293 | { | |||
2294 | OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView(); | |||
2295 | ||||
2296 | if (pOlView || comphelper::LibreOfficeKit::isActive()) | |||
2297 | { | |||
2298 | InsertURLField(pHLItem->GetURL(), pHLItem->GetName(), | |||
2299 | pHLItem->GetTargetFrame()); | |||
2300 | } | |||
2301 | else | |||
2302 | { | |||
2303 | InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(), | |||
2304 | pHLItem->GetTargetFrame(), nullptr); | |||
2305 | } | |||
2306 | } | |||
2307 | } | |||
2308 | ||||
2309 | Cancel(); | |||
2310 | rReq.Ignore (); | |||
2311 | } | |||
2312 | break; | |||
2313 | ||||
2314 | case SID_HIDE_LAST_LEVEL(27000 +448): | |||
2315 | { | |||
2316 | ESelection aSel; | |||
2317 | // fdo#78151 editing a PresObjKind::Outline in a master page ? | |||
2318 | ::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel); | |||
2319 | if (pOL) | |||
2320 | { | |||
2321 | //we are on the last paragraph | |||
2322 | aSel.Adjust(); | |||
2323 | if (aSel.nEndPara == pOL->GetParagraphCount() - 1) | |||
2324 | { | |||
2325 | sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara); | |||
2326 | //there exists a previous numbering level | |||
2327 | if (nDepth != sal_uInt16(-1) && nDepth > 0) | |||
2328 | { | |||
2329 | Paragraph* pPara = pOL->GetParagraph(aSel.nEndPara); | |||
2330 | pOL->Remove(pPara, 1); | |||
2331 | } | |||
2332 | } | |||
2333 | } | |||
2334 | Cancel(); | |||
2335 | rReq.Done (); | |||
2336 | } | |||
2337 | break; | |||
2338 | ||||
2339 | case SID_SHOW_NEXT_LEVEL(27000 +449): | |||
2340 | { | |||
2341 | const char* const STR_PRESOBJ_MPOUTLINE_ARY[] | |||
2342 | { | |||
2343 | STR_PRESOBJ_MPOUTLINEreinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLINE" "\004" u8"Click to edit the outline text format"), | |||
2344 | STR_PRESOBJ_MPOUTLLAYER2reinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLLAYER2" "\004" u8"Second Outline Level"), | |||
2345 | STR_PRESOBJ_MPOUTLLAYER3reinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLLAYER3" "\004" u8"Third Outline Level"), | |||
2346 | STR_PRESOBJ_MPOUTLLAYER4reinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLLAYER4" "\004" u8"Fourth Outline Level"), | |||
2347 | STR_PRESOBJ_MPOUTLLAYER5reinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLLAYER5" "\004" u8"Fifth Outline Level"), | |||
2348 | STR_PRESOBJ_MPOUTLLAYER6reinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLLAYER6" "\004" u8"Sixth Outline Level"), | |||
2349 | STR_PRESOBJ_MPOUTLLAYER7reinterpret_cast<char const *>("STR_PRESOBJ_MPOUTLLAYER7" "\004" u8"Seventh Outline Level"), | |||
2350 | STR_PRESOBJ_MPNOTESTITLEreinterpret_cast<char const *>("STR_PRESOBJ_MPNOTESTITLE" "\004" u8"Click to move the slide"), | |||
2351 | STR_PRESOBJ_MPNOTESTEXTreinterpret_cast<char const *>("STR_PRESOBJ_MPNOTESTEXT" "\004" u8"Click to edit the notes format"), | |||
2352 | STR_PRESOBJ_NOTESTEXTreinterpret_cast<char const *>("STR_PRESOBJ_NOTESTEXT" "\004" u8"Click to add Notes") | |||
2353 | }; | |||
2354 | ||||
2355 | ESelection aSel; | |||
2356 | // fdo#78151 editing a PresObjKind::Outline in a master page ? | |||
2357 | ::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel); | |||
2358 | if (pOL) | |||
2359 | { | |||
2360 | //we are on the last paragraph | |||
2361 | aSel.Adjust(); | |||
2362 | if (aSel.nEndPara == pOL->GetParagraphCount() - 1) | |||
2363 | { | |||
2364 | sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara); | |||
2365 | //there exists a previous numbering level | |||
2366 | if (nDepth < 8) | |||
2367 | { | |||
2368 | sal_uInt16 nNewDepth = nDepth+1; | |||
2369 | pOL->Insert(SdResId(STR_PRESOBJ_MPOUTLINE_ARY[nNewDepth]), EE_PARA_APPEND((sal_Int32) 0x7FFFFFFF), nNewDepth); | |||
2370 | } | |||
2371 | } | |||
2372 | } | |||
2373 | Cancel(); | |||
2374 | rReq.Done (); | |||
2375 | } | |||
2376 | break; | |||
2377 | ||||
2378 | case SID_INSERT_FLD_DATE_FIX(27000 +358): | |||
2379 | case SID_INSERT_FLD_DATE_VAR(27000 +357): | |||
2380 | case SID_INSERT_FLD_TIME_FIX(27000 +360): | |||
2381 | case SID_INSERT_FLD_TIME_VAR(27000 +359): | |||
2382 | case SID_INSERT_FLD_AUTHOR(27000 +364): | |||
2383 | case SID_INSERT_FLD_PAGE(27000 +361): | |||
2384 | case SID_INSERT_FLD_PAGE_TITLE(27000 +356): | |||
2385 | case SID_INSERT_FLD_PAGES(27000 +373): | |||
2386 | case SID_INSERT_FLD_FILE(27000 +363): | |||
2387 | { | |||
2388 | sal_uInt16 nMul = 1; | |||
2389 | std::unique_ptr<SvxFieldItem> pFieldItem; | |||
2390 | ||||
2391 | switch( nSId ) | |||
2392 | { | |||
2393 | case SID_INSERT_FLD_DATE_FIX(27000 +358): | |||
2394 | pFieldItem.reset(new SvxFieldItem( | |||
2395 | SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD )); | |||
2396 | break; | |||
2397 | ||||
2398 | case SID_INSERT_FLD_DATE_VAR(27000 +357): | |||
2399 | pFieldItem.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD )); | |||
2400 | break; | |||
2401 | ||||
2402 | case SID_INSERT_FLD_TIME_FIX(27000 +360): | |||
2403 | pFieldItem.reset(new SvxFieldItem( | |||
2404 | SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM ), SvxTimeType::Fix ), EE_FEATURE_FIELD )); | |||
2405 | break; | |||
2406 | ||||
2407 | case SID_INSERT_FLD_TIME_VAR(27000 +359): | |||
2408 | pFieldItem.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD )); | |||
2409 | break; | |||
2410 | ||||
2411 | case SID_INSERT_FLD_AUTHOR(27000 +364): | |||
2412 | { | |||
2413 | SvtUserOptions aUserOptions; | |||
2414 | pFieldItem.reset(new SvxFieldItem( | |||
2415 | SvxAuthorField( | |||
2416 | aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD )); | |||
2417 | } | |||
2418 | break; | |||
2419 | ||||
2420 | case SID_INSERT_FLD_PAGE(27000 +361): | |||
2421 | { | |||
2422 | pFieldItem.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD )); | |||
2423 | nMul = 3; | |||
2424 | } | |||
2425 | break; | |||
2426 | ||||
2427 | case SID_INSERT_FLD_PAGE_TITLE(27000 +356): | |||
2428 | { | |||
2429 | pFieldItem.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD)); | |||
2430 | nMul = 3; | |||
2431 | } | |||
2432 | break; | |||
2433 | ||||
2434 | case SID_INSERT_FLD_PAGES(27000 +373): | |||
2435 | { | |||
2436 | pFieldItem.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD )); | |||
2437 | nMul = 3; | |||
2438 | } | |||
2439 | break; | |||
2440 | ||||
2441 | case SID_INSERT_FLD_FILE(27000 +363): | |||
2442 | { | |||
2443 | OUString aName; | |||
2444 | if( GetDocSh()->HasName() ) | |||
2445 | aName = GetDocSh()->GetMedium()->GetName(); | |||
2446 | pFieldItem.reset(new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD )); | |||
2447 | } | |||
2448 | break; | |||
2449 | } | |||
2450 | ||||
2451 | OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView(); | |||
2452 | ||||
2453 | if( pOLV ) | |||
2454 | { | |||
2455 | const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection(); | |||
2456 | ||||
2457 | if( pOldFldItem && ( nullptr != dynamic_cast< const SvxURLField *>( pOldFldItem->GetField() ) || | |||
2458 | nullptr != dynamic_cast< const SvxDateField *>( pOldFldItem->GetField() ) || | |||
2459 | nullptr != dynamic_cast< const SvxTimeField *>( pOldFldItem->GetField() ) || | |||
2460 | nullptr != dynamic_cast< const SvxExtTimeField *>( pOldFldItem->GetField() ) || | |||
2461 | nullptr != dynamic_cast< const SvxExtFileField *>( pOldFldItem->GetField() ) || | |||
2462 | nullptr != dynamic_cast< const SvxAuthorField *>( pOldFldItem->GetField() ) || | |||
2463 | nullptr != dynamic_cast< const SvxPageField *>( pOldFldItem->GetField() ) ) ) | |||
2464 | { | |||
2465 | // select field, then it will be deleted when inserting | |||
2466 | ESelection aSel = pOLV->GetSelection(); | |||
2467 | if( aSel.nStartPos == aSel.nEndPos ) | |||
2468 | aSel.nEndPos++; | |||
2469 | pOLV->SetSelection( aSel ); | |||
2470 | } | |||
2471 | ||||
2472 | if( pFieldItem ) | |||
2473 | pOLV->InsertField( *pFieldItem ); | |||
2474 | } | |||
2475 | else | |||
2476 | { | |||
2477 | Outliner* pOutl = GetDoc()->GetInternalOutliner(); | |||
2478 | pOutl->Init( OutlinerMode::TextObject ); | |||
2479 | OutlinerMode nOutlMode = pOutl->GetMode(); | |||
2480 | pOutl->SetStyleSheet( 0, nullptr ); | |||
2481 | pOutl->QuickInsertField( *pFieldItem, ESelection() ); | |||
2482 | std::unique_ptr<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); | |||
2483 | ||||
2484 | SdrRectObj* pRectObj = new SdrRectObj( | |||
2485 | *GetDoc(), | |||
2486 | OBJ_TEXT); | |||
2487 | pRectObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(true)); | |||
2488 | ||||
2489 | pOutl->UpdateFields(); | |||
2490 | pOutl->SetUpdateMode( true ); | |||
2491 | Size aSize( pOutl->CalcTextSize() ); | |||
2492 | aSize.setWidth( aSize.Width() * nMul ); | |||
2493 | pOutl->SetUpdateMode( false ); | |||
2494 | ||||
2495 | Point aPos; | |||
2496 | ::tools::Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() ); | |||
2497 | aPos = aRect.Center(); | |||
2498 | aPos = GetActiveWindow()->PixelToLogic(aPos); | |||
2499 | aPos.AdjustX( -(aSize.Width() / 2) ); | |||
2500 | aPos.AdjustY( -(aSize.Height() / 2) ); | |||
2501 | ||||
2502 | ::tools::Rectangle aLogicRect(aPos, aSize); | |||
2503 | pRectObj->SetLogicRect(aLogicRect); | |||
2504 | pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) ); | |||
2505 | mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView()); | |||
2506 | pOutl->Init( nOutlMode ); | |||
2507 | } | |||
2508 | ||||
2509 | pFieldItem.reset(); | |||
2510 | ||||
2511 | Cancel(); | |||
2512 | rReq.Ignore (); | |||
2513 | } | |||
2514 | break; | |||
2515 | ||||
2516 | case SID_MODIFY_FIELD(27000 +362): | |||
2517 | { | |||
2518 | OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView(); | |||
2519 | ||||
2520 | if( pOLV ) | |||
2521 | { | |||
2522 | const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection(); | |||
2523 | ||||
2524 | if( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) || | |||
2525 | nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) || | |||
2526 | nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) || | |||
2527 | nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) ) | |||
2528 | { | |||
2529 | // Dialog... | |||
2530 | SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); | |||
2531 | vcl::Window* pWin = GetActiveWindow(); | |||
2532 | ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg( pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOLV->GetAttribs() ) ); | |||
2533 | if( pDlg->Execute() == RET_OK ) | |||
2534 | { | |||
2535 | // To make a correct SetAttribs() call at the utlinerView | |||
2536 | // it is necessary to split the actions here | |||
2537 | std::unique_ptr<SvxFieldData> pField(pDlg->GetField()); | |||
2538 | ESelection aSel = pOLV->GetSelection(); | |||
2539 | bool bSelectionWasModified(false); | |||
2540 | ||||
2541 | if( pField ) | |||
2542 | { | |||
2543 | SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); | |||
2544 | ||||
2545 | if( aSel.nStartPos == aSel.nEndPos ) | |||
2546 | { | |||
2547 | bSelectionWasModified = true; | |||
2548 | aSel.nEndPos++; | |||
2549 | pOLV->SetSelection( aSel ); | |||
2550 | } | |||
2551 | ||||
2552 | pOLV->InsertField( aFieldItem ); | |||
2553 | ||||
2554 | // select again for eventual SetAttribs call | |||
2555 | pOLV->SetSelection( aSel ); | |||
2556 | } | |||
2557 | ||||
2558 | SfxItemSet aSet( pDlg->GetItemSet() ); | |||
2559 | ||||
2560 | if( aSet.Count() ) | |||
2561 | { | |||
2562 | pOLV->SetAttribs( aSet ); | |||
2563 | ||||
2564 | ::Outliner* pOutliner = pOLV->GetOutliner(); | |||
2565 | if( pOutliner ) | |||
2566 | pOutliner->UpdateFields(); | |||
2567 | } | |||
2568 | ||||
2569 | if(pField) | |||
2570 | { | |||
2571 | // restore selection to original | |||
2572 | if(bSelectionWasModified) | |||
2573 | { | |||
2574 | aSel.nEndPos--; | |||
2575 | pOLV->SetSelection( aSel ); | |||
2576 | } | |||
2577 | } | |||
2578 | } | |||
2579 | } | |||
2580 | } | |||
2581 | ||||
2582 | Cancel(); | |||
2583 | rReq.Ignore (); | |||
2584 | } | |||
2585 | break; | |||
2586 | ||||
2587 | case SID_OPEN_XML_FILTERSETTINGS( 10000 + 958 ): | |||
2588 | { | |||
2589 | try | |||
2590 | { | |||
2591 | css::uno::Reference < css::ui::dialogs::XExecutableDialog > xDialog = css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() ); | |||
2592 | xDialog->execute(); | |||
2593 | } | |||
2594 | catch( css::uno::RuntimeException& ) | |||
2595 | { | |||
2596 | DBG_UNHANDLED_EXCEPTION("sd.view")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "2596" ": ", "sd.view" );; | |||
2597 | } | |||
2598 | ||||
2599 | Cancel(); | |||
2600 | rReq.Ignore (); | |||
2601 | } | |||
2602 | break; | |||
2603 | ||||
2604 | case SID_GROUP( 10000 + 454 ): // BASIC | |||
2605 | { | |||
2606 | if ( mpDrawView->IsPresObjSelected( true, true, true ) ) | |||
2607 | { | |||
2608 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2609 | VclMessageType::Info, VclButtonsType::Ok, | |||
2610 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2611 | xInfoBox->run(); | |||
2612 | } | |||
2613 | else | |||
2614 | { | |||
2615 | mpDrawView->GroupMarked(); | |||
2616 | } | |||
2617 | Cancel(); | |||
2618 | rReq.Done (); | |||
2619 | } | |||
2620 | break; | |||
2621 | ||||
2622 | case SID_UNGROUP( 10000 + 455 ): // BASIC | |||
2623 | { | |||
2624 | mpDrawView->UnGroupMarked(); | |||
2625 | Cancel(); | |||
2626 | rReq.Done (); | |||
2627 | } | |||
2628 | break; | |||
2629 | ||||
2630 | case SID_NAME_GROUP(27000 +27): | |||
2631 | { | |||
2632 | // only allow for single object selection since the name of an object needs | |||
2633 | // to be unique | |||
2634 | if(1 == mpDrawView->GetMarkedObjectCount()) | |||
2635 | { | |||
2636 | // #i68101# | |||
2637 | SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0); | |||
2638 | OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)")do { if (true && (!(pSelected))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "2638" ": "), "%s", "DrawViewShell::FuTemp03: nMarkCount, but no object (!)" ); } } while (false); | |||
2639 | OUString aName(pSelected->GetName()); | |||
2640 | ||||
2641 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
2642 | ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetFrameWeld(), aName)); | |||
2643 | ||||
2644 | pDlg->SetCheckNameHdl(LINK(this, DrawViewShell, NameObjectHdl)::tools::detail::makeLink( ::tools::detail::castTo<DrawViewShell *>(this), &DrawViewShell::LinkStubNameObjectHdl)); | |||
2645 | ||||
2646 | if(RET_OK == pDlg->Execute()) | |||
2647 | { | |||
2648 | pDlg->GetName(aName); | |||
2649 | pSelected->SetName(aName); | |||
2650 | ||||
2651 | SdPage* pPage = GetActualPage(); | |||
2652 | if (pPage) | |||
2653 | pPage->notifyObjectRenamed(pSelected); | |||
2654 | } | |||
2655 | } | |||
2656 | ||||
2657 | SfxBindings& rBindings = GetViewFrame()->GetBindings(); | |||
2658 | rBindings.Invalidate( SID_NAVIGATOR_STATE(27000 +288), true ); | |||
2659 | rBindings.Invalidate( SID_CONTEXT(5000 + 310) ); | |||
2660 | ||||
2661 | Cancel(); | |||
2662 | rReq.Ignore(); | |||
2663 | break; | |||
2664 | } | |||
2665 | ||||
2666 | // #i68101# | |||
2667 | case SID_OBJECT_TITLE_DESCRIPTION(27000 +33): | |||
2668 | { | |||
2669 | if(1 == mpDrawView->GetMarkedObjectCount()) | |||
2670 | { | |||
2671 | SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0); | |||
2672 | OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)")do { if (true && (!(pSelected))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "2672" ": "), "%s", "DrawViewShell::FuTemp03: nMarkCount, but no object (!)" ); } } while (false); | |||
2673 | OUString aTitle(pSelected->GetTitle()); | |||
2674 | OUString aDescription(pSelected->GetDescription()); | |||
2675 | ||||
2676 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
2677 | ScopedVclPtr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog( | |||
2678 | GetFrameWeld(), aTitle, aDescription)); | |||
2679 | ||||
2680 | if(RET_OK == pDlg->Execute()) | |||
2681 | { | |||
2682 | pDlg->GetTitle(aTitle); | |||
2683 | pDlg->GetDescription(aDescription); | |||
2684 | pSelected->SetTitle(aTitle); | |||
2685 | pSelected->SetDescription(aDescription); | |||
2686 | } | |||
2687 | } | |||
2688 | ||||
2689 | SfxBindings& rBindings = GetViewFrame()->GetBindings(); | |||
2690 | rBindings.Invalidate( SID_NAVIGATOR_STATE(27000 +288), true ); | |||
2691 | rBindings.Invalidate( SID_CONTEXT(5000 + 310) ); | |||
2692 | ||||
2693 | Cancel(); | |||
2694 | rReq.Ignore(); | |||
2695 | break; | |||
2696 | } | |||
2697 | ||||
2698 | case SID_ENTER_GROUP(27000 +96): // BASIC | |||
2699 | { | |||
2700 | mpDrawView->EnterMarkedGroup(); | |||
2701 | Cancel(); | |||
2702 | rReq.Done (); | |||
2703 | } | |||
2704 | break; | |||
2705 | ||||
2706 | case SID_LEAVE_GROUP(27000 +97): // BASIC | |||
2707 | { | |||
2708 | mpDrawView->LeaveOneGroup(); | |||
2709 | Cancel(); | |||
2710 | rReq.Done (); | |||
2711 | } | |||
2712 | break; | |||
2713 | ||||
2714 | case SID_LEAVE_ALL_GROUPS(27000 +345): // BASIC | |||
2715 | { | |||
2716 | mpDrawView->LeaveAllGroup(); | |||
2717 | Cancel(); | |||
2718 | rReq.Done (); | |||
2719 | } | |||
2720 | break; | |||
2721 | ||||
2722 | case SID_TEXT_COMBINE(27000 +25): // BASIC | |||
2723 | { | |||
2724 | // End text edit to avoid conflicts | |||
2725 | if(mpDrawView->IsTextEdit()) | |||
2726 | mpDrawView->SdrEndTextEdit(); | |||
2727 | ||||
2728 | if ( mpDrawView->IsPresObjSelected() ) | |||
2729 | { | |||
2730 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2731 | VclMessageType::Info, VclButtonsType::Ok, | |||
2732 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2733 | xInfoBox->run(); | |||
2734 | } | |||
2735 | else | |||
2736 | { | |||
2737 | weld::WaitObject aWait(GetFrameWeld()); | |||
2738 | mpDrawView->CombineMarkedTextObjects(); | |||
2739 | } | |||
2740 | Cancel(); | |||
2741 | rReq.Done (); | |||
2742 | } | |||
2743 | break; | |||
2744 | ||||
2745 | case SID_COMBINE(27000 +26): // BASIC | |||
2746 | { | |||
2747 | // End text edit to avoid conflicts | |||
2748 | if(mpDrawView->IsTextEdit()) | |||
2749 | mpDrawView->SdrEndTextEdit(); | |||
2750 | ||||
2751 | if ( mpDrawView->IsPresObjSelected() ) | |||
2752 | { | |||
2753 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2754 | VclMessageType::Info, VclButtonsType::Ok, | |||
2755 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2756 | xInfoBox->run(); | |||
2757 | } | |||
2758 | else | |||
2759 | { | |||
2760 | weld::WaitObject aWait(GetFrameWeld()); | |||
2761 | mpDrawView->CombineMarkedObjects(false); | |||
2762 | } | |||
2763 | Cancel(); | |||
2764 | rReq.Done (); | |||
2765 | } | |||
2766 | break; | |||
2767 | ||||
2768 | case SID_DISTRIBUTE_HLEFT(5000 + 686): | |||
2769 | case SID_DISTRIBUTE_HCENTER(5000 + 687): | |||
2770 | case SID_DISTRIBUTE_HDISTANCE(5000 + 688): | |||
2771 | case SID_DISTRIBUTE_HRIGHT(5000 + 689): | |||
2772 | case SID_DISTRIBUTE_VTOP(5000 + 690): | |||
2773 | case SID_DISTRIBUTE_VCENTER(5000 + 691): | |||
2774 | case SID_DISTRIBUTE_VDISTANCE(5000 + 692): | |||
2775 | case SID_DISTRIBUTE_VBOTTOM(5000 + 693): | |||
2776 | { | |||
2777 | if ( mpDrawView->IsPresObjSelected() ) | |||
2778 | { | |||
2779 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2780 | VclMessageType::Info, VclButtonsType::Ok, | |||
2781 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2782 | xInfoBox->run(); | |||
2783 | } | |||
2784 | else | |||
2785 | { | |||
2786 | mpDrawView->DistributeMarkedObjects(nSId); | |||
2787 | } | |||
2788 | Cancel(); | |||
2789 | rReq.Done (); | |||
2790 | } | |||
2791 | break; | |||
2792 | case SID_POLY_MERGE(5000 + 679): | |||
2793 | { | |||
2794 | // End text edit to avoid conflicts | |||
2795 | if(mpDrawView->IsTextEdit()) | |||
2796 | mpDrawView->SdrEndTextEdit(); | |||
2797 | ||||
2798 | if ( mpDrawView->IsPresObjSelected() ) | |||
2799 | { | |||
2800 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2801 | VclMessageType::Info, VclButtonsType::Ok, | |||
2802 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2803 | xInfoBox->run(); | |||
2804 | } | |||
2805 | else | |||
2806 | { | |||
2807 | weld::WaitObject aWait(GetFrameWeld()); | |||
2808 | mpDrawView->MergeMarkedObjects(SdrMergeMode::Merge); | |||
2809 | } | |||
2810 | Cancel(); | |||
2811 | rReq.Done (); | |||
2812 | } | |||
2813 | break; | |||
2814 | ||||
2815 | case SID_POLY_SUBSTRACT(5000 + 680): | |||
2816 | { | |||
2817 | // End text edit to avoid conflicts | |||
2818 | if(mpDrawView->IsTextEdit()) | |||
2819 | mpDrawView->SdrEndTextEdit(); | |||
2820 | ||||
2821 | if ( mpDrawView->IsPresObjSelected() ) | |||
2822 | { | |||
2823 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2824 | VclMessageType::Info, VclButtonsType::Ok, | |||
2825 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2826 | xInfoBox->run(); | |||
2827 | } | |||
2828 | else | |||
2829 | { | |||
2830 | weld::WaitObject aWait(GetFrameWeld()); | |||
2831 | mpDrawView->MergeMarkedObjects(SdrMergeMode::Subtract); | |||
2832 | } | |||
2833 | Cancel(); | |||
2834 | rReq.Done (); | |||
2835 | } | |||
2836 | break; | |||
2837 | ||||
2838 | case SID_POLY_INTERSECT(5000 + 681): | |||
2839 | { | |||
2840 | // End text edit to avoid conflicts | |||
2841 | if(mpDrawView->IsTextEdit()) | |||
2842 | mpDrawView->SdrEndTextEdit(); | |||
2843 | ||||
2844 | if ( mpDrawView->IsPresObjSelected() ) | |||
2845 | { | |||
2846 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2847 | VclMessageType::Info, VclButtonsType::Ok, | |||
2848 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2849 | xInfoBox->run(); | |||
2850 | } | |||
2851 | else | |||
2852 | { | |||
2853 | weld::WaitObject aWait(GetFrameWeld()); | |||
2854 | mpDrawView->MergeMarkedObjects(SdrMergeMode::Intersect); | |||
2855 | } | |||
2856 | Cancel(); | |||
2857 | rReq.Done (); | |||
2858 | } | |||
2859 | break; | |||
2860 | ||||
2861 | case SID_EQUALIZEWIDTH(5000 + 684): | |||
2862 | case SID_EQUALIZEHEIGHT(5000 + 685): | |||
2863 | { | |||
2864 | // End text edit to avoid conflicts | |||
2865 | if(mpDrawView->IsTextEdit()) | |||
2866 | mpDrawView->SdrEndTextEdit(); | |||
2867 | ||||
2868 | mpDrawView->EqualizeMarkedObjects(nSId == SID_EQUALIZEWIDTH(5000 + 684)); | |||
2869 | Cancel(); | |||
2870 | rReq.Done (); | |||
2871 | } | |||
2872 | break; | |||
2873 | ||||
2874 | case SID_DISMANTLE(27000 +82): // BASIC | |||
2875 | { | |||
2876 | if ( mpDrawView->IsDismantlePossible() ) | |||
2877 | { | |||
2878 | weld::WaitObject aWait(GetFrameWeld()); | |||
2879 | mpDrawView->DismantleMarkedObjects(); | |||
2880 | } | |||
2881 | Cancel(); | |||
2882 | rReq.Done (); | |||
2883 | } | |||
2884 | break; | |||
2885 | ||||
2886 | case SID_CONNECT(27000 +93): // BASIC | |||
2887 | { | |||
2888 | if ( mpDrawView->IsPresObjSelected() ) | |||
2889 | { | |||
2890 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2891 | VclMessageType::Info, VclButtonsType::Ok, | |||
2892 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2893 | xInfoBox->run(); | |||
2894 | } | |||
2895 | else | |||
2896 | { | |||
2897 | weld::WaitObject aWait(GetFrameWeld()); | |||
2898 | mpDrawView->CombineMarkedObjects(); | |||
2899 | } | |||
2900 | Cancel(); | |||
2901 | rReq.Done (); | |||
2902 | } | |||
2903 | break; | |||
2904 | ||||
2905 | case SID_BREAK(27000 +94): // BASIC | |||
2906 | { | |||
2907 | if ( mpDrawView->IsTextEdit() ) | |||
2908 | { | |||
2909 | mpDrawView->SdrEndTextEdit(); | |||
2910 | } | |||
2911 | ||||
2912 | if ( mpDrawView->IsBreak3DObjPossible() ) | |||
2913 | { | |||
2914 | weld::WaitObject aWait(GetFrameWeld()); | |||
2915 | mpDrawView->Break3DObj(); | |||
2916 | } | |||
2917 | else if ( mpDrawView->IsDismantlePossible(true) ) | |||
2918 | { | |||
2919 | weld::WaitObject aWait(GetFrameWeld()); | |||
2920 | mpDrawView->DismantleMarkedObjects(true); | |||
2921 | } | |||
2922 | else if ( mpDrawView->IsImportMtfPossible() ) | |||
2923 | { | |||
2924 | weld::WaitObject aWait(GetFrameWeld()); | |||
2925 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
2926 | const size_t nCnt=rMarkList.GetMarkCount(); | |||
2927 | ||||
2928 | // determine the sum of meta objects of all selected meta files | |||
2929 | sal_uLong nCount = 0; | |||
2930 | for(size_t nm=0; nm<nCnt; ++nm) | |||
2931 | { | |||
2932 | SdrMark* pM=rMarkList.GetMark(nm); | |||
2933 | SdrObject* pObj=pM->GetMarkedSdrObj(); | |||
2934 | SdrGrafObj* pGraf= dynamic_cast< SdrGrafObj *>( pObj ); | |||
2935 | SdrOle2Obj* pOle2= dynamic_cast< SdrOle2Obj *>( pObj ); | |||
2936 | ||||
2937 | if (pGraf != nullptr) | |||
2938 | { | |||
2939 | if (pGraf->HasGDIMetaFile()) | |||
2940 | { | |||
2941 | nCount += pGraf->GetGraphic().GetGDIMetaFile().GetActionSize(); | |||
2942 | } | |||
2943 | else if (pGraf->isEmbeddedVectorGraphicData()) | |||
2944 | { | |||
2945 | nCount += pGraf->getMetafileFromEmbeddedVectorGraphicData().GetActionSize(); | |||
2946 | } | |||
2947 | } | |||
2948 | ||||
2949 | if(pOle2 && pOle2->GetGraphic()) | |||
2950 | { | |||
2951 | nCount += pOle2->GetGraphic()->GetGDIMetaFile().GetActionSize(); | |||
2952 | } | |||
2953 | } | |||
2954 | ||||
2955 | // decide with the sum of all meta objects if we should show a dialog | |||
2956 | if(nCount < MIN_ACTIONS_FOR_DIALOG5000) | |||
2957 | { | |||
2958 | // nope, no dialog | |||
2959 | mpDrawView->DoImportMarkedMtf(); | |||
2960 | } | |||
2961 | else | |||
2962 | { | |||
2963 | SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); | |||
2964 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetFrameWeld(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) )); | |||
2965 | pDlg->Execute(); | |||
2966 | } | |||
2967 | } | |||
2968 | ||||
2969 | Cancel(); | |||
2970 | rReq.Done (); | |||
2971 | } | |||
2972 | break; | |||
2973 | ||||
2974 | case SID_CONVERT_TO_3D( 10000 + 648 ): | |||
2975 | { | |||
2976 | if ( mpDrawView->IsPresObjSelected() ) | |||
2977 | { | |||
2978 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), | |||
2979 | VclMessageType::Info, VclButtonsType::Ok, | |||
2980 | SdResId(STR_ACTION_NOTPOSSIBLEreinterpret_cast<char const *>("STR_ACTION_NOTPOSSIBLE" "\004" u8"This function cannot be run \nwith the selected objects." )))); | |||
2981 | xInfoBox->run(); | |||
2982 | } | |||
2983 | else | |||
2984 | { | |||
2985 | if (mpDrawView->IsConvertTo3DObjPossible()) | |||
2986 | { | |||
2987 | if (mpDrawView->IsTextEdit()) | |||
2988 | { | |||
2989 | mpDrawView->SdrEndTextEdit(); | |||
2990 | } | |||
2991 | ||||
2992 | weld::WaitObject aWait(GetFrameWeld()); | |||
2993 | mpDrawView->ConvertMarkedObjTo3D(); | |||
2994 | } | |||
2995 | } | |||
2996 | ||||
2997 | Cancel(); | |||
2998 | rReq.Done(); | |||
2999 | } | |||
3000 | break; | |||
3001 | ||||
3002 | case SID_FRAME_TO_TOP( 10000 + 286 ): // BASIC | |||
3003 | { | |||
3004 | mpDrawView->PutMarkedToTop(); | |||
3005 | Cancel(); | |||
3006 | rReq.Done (); | |||
3007 | } | |||
3008 | break; | |||
3009 | ||||
3010 | case SID_MOREFRONT(27000 +31): // BASIC | |||
3011 | case SID_FRAME_UP( 10000 + 1118 ): // BASIC | |||
3012 | { | |||
3013 | mpDrawView->MovMarkedToTop(); | |||
3014 | Cancel(); | |||
3015 | rReq.Done (); | |||
3016 | } | |||
3017 | break; | |||
3018 | ||||
3019 | case SID_MOREBACK(27000 +32): // BASIC | |||
3020 | case SID_FRAME_DOWN( 10000 + 1119 ): // BASIC | |||
3021 | { | |||
3022 | mpDrawView->MovMarkedToBtm(); | |||
3023 | Cancel(); | |||
3024 | rReq.Done (); | |||
3025 | } | |||
3026 | break; | |||
3027 | ||||
3028 | case SID_FRAME_TO_BOTTOM( 10000 + 287 ): // BASIC | |||
3029 | { | |||
3030 | mpDrawView->PutMarkedToBtm(); | |||
3031 | Cancel(); | |||
3032 | rReq.Done (); | |||
3033 | } | |||
3034 | break; | |||
3035 | ||||
3036 | case SID_HORIZONTAL(27000 +35): // BASIC | |||
3037 | case SID_FLIP_HORIZONTAL( 10000 + 1127 ): | |||
3038 | { | |||
3039 | mpDrawView->MirrorAllMarkedHorizontal(); | |||
3040 | Cancel(); | |||
3041 | rReq.Done (); | |||
3042 | } | |||
3043 | break; | |||
3044 | ||||
3045 | case SID_VERTICAL(27000 +34): // BASIC | |||
3046 | case SID_FLIP_VERTICAL( 10000 + 1128 ): | |||
3047 | { | |||
3048 | mpDrawView->MirrorAllMarkedVertical(); | |||
3049 | Cancel(); | |||
3050 | rReq.Done (); | |||
3051 | } | |||
3052 | break; | |||
3053 | ||||
3054 | case SID_OBJECT_ALIGN_LEFT( 10000 + 131 ): // BASIC | |||
3055 | { | |||
3056 | mpDrawView->AlignMarkedObjects(SdrHorAlign::Left, SdrVertAlign::NONE); | |||
3057 | Cancel(); | |||
3058 | rReq.Done (); | |||
3059 | } | |||
3060 | break; | |||
3061 | ||||
3062 | case SID_OBJECT_ALIGN_CENTER( 10000 + 132 ): // BASIC | |||
3063 | { | |||
3064 | mpDrawView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::NONE); | |||
3065 | Cancel(); | |||
3066 | rReq.Done (); | |||
3067 | } | |||
3068 | break; | |||
3069 | ||||
3070 | case SID_OBJECT_ALIGN_RIGHT( 10000 + 133 ): // BASIC | |||
3071 | { | |||
3072 | mpDrawView->AlignMarkedObjects(SdrHorAlign::Right, SdrVertAlign::NONE); | |||
3073 | Cancel(); | |||
3074 | rReq.Done (); | |||
3075 | } | |||
3076 | break; | |||
3077 | ||||
3078 | case SID_OBJECT_ALIGN_UP( 10000 + 134 ): // BASIC | |||
3079 | { | |||
3080 | mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Top); | |||
3081 | Cancel(); | |||
3082 | rReq.Done (); | |||
3083 | } | |||
3084 | break; | |||
3085 | ||||
3086 | case SID_OBJECT_ALIGN_MIDDLE( 10000 + 135 ): // BASIC | |||
3087 | { | |||
3088 | mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Center); | |||
3089 | Cancel(); | |||
3090 | rReq.Done (); | |||
3091 | } | |||
3092 | break; | |||
3093 | ||||
3094 | case SID_OBJECT_ALIGN_DOWN( 10000 + 136 ): // BASIC | |||
3095 | { | |||
3096 | mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Bottom); | |||
3097 | Cancel(); | |||
3098 | rReq.Done (); | |||
3099 | } | |||
3100 | break; | |||
3101 | ||||
3102 | case SID_SELECTALL(5000 + 723): // BASIC | |||
3103 | { | |||
3104 | if( (dynamic_cast<FuSelection*>( GetOldFunction().get() ) != nullptr) && | |||
3105 | !GetView()->IsFrameDragSingles() && GetView()->HasMarkablePoints()) | |||
3106 | { | |||
3107 | if ( !mpDrawView->IsAction() ) | |||
3108 | mpDrawView->MarkAllPoints(); | |||
3109 | } | |||
3110 | else | |||
3111 | mpDrawView->SelectAll(); | |||
3112 | ||||
3113 | Cancel(); | |||
3114 | rReq.Done (); | |||
3115 | } | |||
3116 | break; | |||
3117 | ||||
3118 | case SID_STYLE_NEW(5000 + 549): // BASIC ??? | |||
3119 | case SID_STYLE_APPLY(5000 + 552): | |||
3120 | case SID_STYLE_EDIT(5000 + 550): | |||
3121 | case SID_STYLE_DELETE(5000 + 551): | |||
3122 | case SID_STYLE_HIDE(5000 + 1603): | |||
3123 | case SID_STYLE_SHOW(5000 + 1604): | |||
3124 | case SID_STYLE_FAMILYTypedWhichId<SfxUInt16Item>(5000 + 553): | |||
3125 | case SID_STYLE_WATERCAN(5000 + 554): | |||
3126 | case SID_STYLE_UPDATE_BY_EXAMPLE(5000 + 556): | |||
3127 | case SID_STYLE_NEW_BY_EXAMPLE(5000 + 555): | |||
3128 | { | |||
3129 | if( rReq.GetSlot() == SID_STYLE_EDIT(5000 + 550) && !rReq.GetArgs() ) | |||
3130 | { | |||
3131 | SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet(); | |||
3132 | if( pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page) | |||
3133 | pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet(); | |||
3134 | ||||
3135 | if( (pStyleSheet == nullptr) && GetView()->IsTextEdit() ) | |||
3136 | { | |||
3137 | GetView()->SdrEndTextEdit(); | |||
3138 | ||||
3139 | pStyleSheet = mpDrawView->GetStyleSheet(); | |||
3140 | if(pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page) | |||
3141 | pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet(); | |||
3142 | } | |||
3143 | ||||
3144 | if( pStyleSheet == nullptr ) | |||
3145 | { | |||
3146 | rReq.Ignore(); | |||
3147 | break; | |||
3148 | } | |||
3149 | ||||
3150 | SfxAllItemSet aSet(GetDoc()->GetPool()); | |||
3151 | ||||
3152 | SfxStringItem aStyleNameItem( SID_STYLE_EDIT(5000 + 550), pStyleSheet->GetName() ); | |||
3153 | aSet.Put(aStyleNameItem); | |||
3154 | ||||
3155 | SfxUInt16Item aStyleFamilyItem( SID_STYLE_FAMILYTypedWhichId<SfxUInt16Item>(5000 + 553), static_cast<sal_uInt16>(pStyleSheet->GetFamily()) ); | |||
3156 | aSet.Put(aStyleFamilyItem); | |||
3157 | ||||
3158 | rReq.SetArgs(aSet); | |||
3159 | } | |||
3160 | ||||
3161 | if( rReq.GetArgs() ) | |||
3162 | { | |||
3163 | SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
3164 | if( rReq.GetSlot() == SID_STYLE_APPLY(5000 + 552) ) | |||
3165 | GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY(5000 + 552) ); | |||
3166 | Cancel(); | |||
3167 | } | |||
3168 | else if( rReq.GetSlot() == SID_STYLE_APPLY(5000 + 552) ) | |||
3169 | GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER(5000 + 539), SfxCallMode::ASYNCHRON ); | |||
3170 | rReq.Ignore (); | |||
3171 | } | |||
3172 | break; | |||
3173 | ||||
3174 | case SID_IMAP( 10000 + 371 ): | |||
3175 | { | |||
3176 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); | |||
3177 | ||||
3178 | GetViewFrame()->ToggleChildWindow( nId ); | |||
3179 | GetViewFrame()->GetBindings().Invalidate( SID_IMAP( 10000 + 371 ) ); | |||
3180 | ||||
3181 | if ( GetViewFrame()->HasChildWindow( nId ) | |||
3182 | && ( ( ViewShell::Implementation::GetImageMapDialog() ) != nullptr ) ) | |||
3183 | { | |||
3184 | const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); | |||
3185 | ||||
3186 | if ( rMarkList.GetMarkCount() == 1 ) | |||
3187 | UpdateIMapDlg( rMarkList.GetMark( 0 )->GetMarkedSdrObj() ); | |||
3188 | } | |||
3189 | ||||
3190 | Cancel(); | |||
3191 | rReq.Ignore (); | |||
3192 | } | |||
3193 | break; | |||
3194 | ||||
3195 | case SID_GRID_FRONT(27000 +248): | |||
3196 | { | |||
3197 | mpDrawView->SetGridFront( !mpDrawView->IsGridFront() ); | |||
3198 | Cancel(); | |||
3199 | rReq.Done (); | |||
3200 | } | |||
3201 | break; | |||
3202 | ||||
3203 | case SID_HELPLINES_FRONT(27000 +180): | |||
3204 | { | |||
3205 | mpDrawView->SetHlplFront( !mpDrawView->IsHlplFront() ); | |||
3206 | Cancel(); | |||
3207 | rReq.Done (); | |||
3208 | } | |||
3209 | break; | |||
3210 | ||||
3211 | case SID_FONTWORK( 10000 + 256 ): | |||
3212 | { | |||
3213 | if ( rReq.GetArgs() ) | |||
3214 | { | |||
3215 | GetViewFrame()->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), | |||
3216 | static_cast<const SfxBoolItem&>(rReq.GetArgs()-> | |||
3217 | Get(SID_FONTWORK( 10000 + 256 ))).GetValue()); | |||
3218 | } | |||
3219 | else | |||
3220 | { | |||
3221 | GetViewFrame()->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); | |||
3222 | } | |||
3223 | ||||
3224 | GetViewFrame()->GetBindings().Invalidate(SID_FONTWORK( 10000 + 256 )); | |||
3225 | Cancel(); | |||
3226 | rReq.Ignore (); | |||
3227 | } | |||
3228 | break; | |||
3229 | ||||
3230 | case SID_COLOR_CONTROL( 10000 + 417 ): | |||
3231 | { | |||
3232 | if ( rReq.GetArgs() ) | |||
3233 | GetViewFrame()->SetChildWindow(SvxColorChildWindow::GetChildWindowId(), | |||
3234 | static_cast<const SfxBoolItem&>(rReq.GetArgs()-> | |||
3235 | Get(SID_COLOR_CONTROL( 10000 + 417 ))).GetValue()); | |||
3236 | else | |||
3237 | GetViewFrame()->ToggleChildWindow(SvxColorChildWindow::GetChildWindowId() ); | |||
3238 | ||||
3239 | GetViewFrame()->GetBindings().Invalidate(SID_COLOR_CONTROL( 10000 + 417 )); | |||
3240 | Cancel(); | |||
3241 | rReq.Ignore (); | |||
3242 | } | |||
3243 | break; | |||
3244 | ||||
3245 | case SID_EXTRUSION_TOGGLE( 10000 + 960 ): | |||
3246 | case SID_EXTRUSION_TILT_DOWN( 10000 + 961 ): | |||
3247 | case SID_EXTRUSION_TILT_UP( 10000 + 962 ): | |||
3248 | case SID_EXTRUSION_TILT_LEFT( 10000 + 963 ): | |||
3249 | case SID_EXTRUSION_TILT_RIGHT( 10000 + 964 ): | |||
3250 | case SID_EXTRUSION_3D_COLOR( 10000 + 969 ): | |||
3251 | case SID_EXTRUSION_DEPTH( 10000 + 970 ): | |||
3252 | case SID_EXTRUSION_DIRECTION( 10000 + 971 ): | |||
3253 | case SID_EXTRUSION_PROJECTION( 10000 + 972 ): | |||
3254 | case SID_EXTRUSION_LIGHTING_DIRECTION( 10000 + 973 ): | |||
3255 | case SID_EXTRUSION_LIGHTING_INTENSITY( 10000 + 974 ): | |||
3256 | case SID_EXTRUSION_SURFACE( 10000 + 975 ): | |||
3257 | case SID_EXTRUSION_DEPTH_FLOATER( 10000 + 965 ): | |||
3258 | case SID_EXTRUSION_DIRECTION_FLOATER( 10000 + 966 ): | |||
3259 | case SID_EXTRUSION_LIGHTING_FLOATER( 10000 + 967 ): | |||
3260 | case SID_EXTRUSION_SURFACE_FLOATER( 10000 + 968 ): | |||
3261 | case SID_EXTRUSION_DEPTH_DIALOG( 10000 + 976 ): | |||
3262 | svx::ExtrusionBar::execute( mpDrawView.get(), rReq, GetViewFrame()->GetBindings() ); | |||
3263 | Cancel(); | |||
3264 | rReq.Ignore (); | |||
3265 | break; | |||
3266 | ||||
3267 | case SID_FONTWORK_SHAPE( 10000 + 983 ): | |||
3268 | case SID_FONTWORK_SHAPE_TYPE( 10000 + 979 ): | |||
3269 | case SID_FONTWORK_ALIGNMENT( 10000 + 984 ): | |||
3270 | case SID_FONTWORK_SAME_LETTER_HEIGHTS( 10000 + 980 ): | |||
3271 | case SID_FONTWORK_CHARACTER_SPACING( 10000 + 985 ): | |||
3272 | case SID_FONTWORK_KERN_CHARACTER_PAIRS( 10000 + 986 ): | |||
3273 | case SID_FONTWORK_GALLERY_FLOATER( 10000 + 977 ): | |||
3274 | case SID_FONTWORK_CHARACTER_SPACING_FLOATER( 10000 + 982 ): | |||
3275 | case SID_FONTWORK_ALIGNMENT_FLOATER( 10000 + 981 ): | |||
3276 | case SID_FONTWORK_CHARACTER_SPACING_DIALOG( 10000 + 1054 ): | |||
3277 | svx::FontworkBar::execute(*mpDrawView, rReq, GetViewFrame()->GetBindings()); | |||
3278 | Cancel(); | |||
3279 | rReq.Ignore (); | |||
3280 | break; | |||
3281 | ||||
3282 | case SID_BMPMASK( 10000 + 350 ): | |||
3283 | { | |||
3284 | GetViewFrame()->ToggleChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ); | |||
3285 | GetViewFrame()->GetBindings().Invalidate( SID_BMPMASK( 10000 + 350 ) ); | |||
3286 | ||||
3287 | Cancel(); | |||
3288 | rReq.Ignore (); | |||
3289 | } | |||
3290 | break; | |||
3291 | ||||
3292 | case SID_NAVIGATOR(10000 + 366): | |||
3293 | { | |||
3294 | if ( rReq.GetArgs() ) | |||
3295 | GetViewFrame()->SetChildWindow(SID_NAVIGATOR(10000 + 366), | |||
3296 | static_cast<const SfxBoolItem&>(rReq.GetArgs()-> | |||
3297 | Get(SID_NAVIGATOR(10000 + 366))).GetValue()); | |||
3298 | else | |||
3299 | GetViewFrame()->ToggleChildWindow( SID_NAVIGATOR(10000 + 366) ); | |||
3300 | ||||
3301 | GetViewFrame()->GetBindings().Invalidate(SID_NAVIGATOR(10000 + 366)); | |||
3302 | Cancel(); | |||
3303 | rReq.Ignore (); | |||
3304 | } | |||
3305 | break; | |||
3306 | ||||
3307 | case SID_SLIDE_TRANSITIONS_PANEL(27000 +334): | |||
3308 | case SID_MASTER_SLIDES_PANEL(27000 +184): | |||
3309 | case SID_CUSTOM_ANIMATION_PANEL(27000 +183): | |||
3310 | case SID_GALLERY(5000 + 960): | |||
3311 | { | |||
3312 | // First make sure that the sidebar is visible | |||
3313 | GetViewFrame()->ShowChildWindow(SID_SIDEBAR(10000 + 336)); | |||
3314 | ||||
3315 | OUString panelId; | |||
3316 | if (nSId == SID_CUSTOM_ANIMATION_PANEL(27000 +183)) | |||
3317 | panelId = "SdCustomAnimationPanel"; | |||
3318 | else if (nSId == SID_GALLERY(5000 + 960)) | |||
3319 | panelId = "GalleryPanel"; | |||
3320 | else if (nSId == SID_SLIDE_TRANSITIONS_PANEL(27000 +334)) | |||
3321 | panelId = "SdSlideTransitionPanel"; | |||
3322 | else if (nSId == SID_MASTER_SLIDES_PANEL(27000 +184)) | |||
3323 | panelId = "SdAllMasterPagesPanel"; | |||
3324 | ||||
3325 | ::sfx2::sidebar::Sidebar::TogglePanel( | |||
3326 | panelId, | |||
3327 | GetViewFrame()->GetFrame().GetFrameInterface()); | |||
3328 | ||||
3329 | Cancel(); | |||
3330 | rReq.Done(); | |||
3331 | } | |||
3332 | break; | |||
3333 | ||||
3334 | case SID_ANIMATION_OBJECTS(27000 +62): | |||
3335 | { | |||
3336 | if ( rReq.GetArgs() ) | |||
3337 | GetViewFrame()->SetChildWindow( | |||
3338 | AnimationChildWindow::GetChildWindowId(), | |||
3339 | static_cast<const SfxBoolItem&>(rReq.GetArgs()-> | |||
3340 | Get(SID_ANIMATION_OBJECTS(27000 +62))).GetValue()); | |||
3341 | else | |||
3342 | GetViewFrame()->ToggleChildWindow( | |||
3343 | AnimationChildWindow::GetChildWindowId() ); | |||
3344 | ||||
3345 | GetViewFrame()->GetBindings().Invalidate(SID_ANIMATION_OBJECTS(27000 +62)); | |||
3346 | Cancel(); | |||
3347 | rReq.Ignore (); | |||
3348 | } | |||
3349 | break; | |||
3350 | ||||
3351 | case SID_3D_WIN( 10000 + 644 ): | |||
3352 | { | |||
3353 | if ( rReq.GetArgs() ) | |||
3354 | GetViewFrame()->SetChildWindow( Svx3DChildWindow::GetChildWindowId(), | |||
3355 | static_cast<const SfxBoolItem&>(rReq.GetArgs()-> | |||
3356 | Get( SID_3D_WIN( 10000 + 644 ) )).GetValue()); | |||
3357 | else | |||
3358 | GetViewFrame()->ToggleChildWindow( Svx3DChildWindow::GetChildWindowId() ); | |||
3359 | ||||
3360 | GetViewFrame()->GetBindings().Invalidate( SID_3D_WIN( 10000 + 644 ) ); | |||
3361 | Cancel(); | |||
3362 | rReq.Ignore (); | |||
3363 | } | |||
3364 | break; | |||
3365 | ||||
3366 | case SID_CONVERT_TO_3D_LATHE_FAST( 10000 + 649 ): | |||
3367 | { | |||
3368 | /* The call is enough. The initialization via Start3DCreation and | |||
3369 | CreateMirrorPolygons is no longer needed if the parameter | |||
3370 | sal_True is provided. Then a tilted rotary body with an axis left | |||
3371 | besides the bounding rectangle of the selected objects is drawn | |||
3372 | immediately and without user interaction. */ | |||
3373 | mpDrawView->SdrEndTextEdit(); | |||
3374 | if(GetActiveWindow()) | |||
3375 | GetActiveWindow()->EnterWait(); | |||
3376 | mpDrawView->End3DCreation(true); | |||
3377 | Cancel(); | |||
3378 | rReq.Ignore(); | |||
3379 | if(GetActiveWindow()) | |||
3380 | GetActiveWindow()->LeaveWait(); | |||
3381 | } | |||
3382 | break; | |||
3383 | ||||
3384 | case SID_PRESENTATION_DLG(27000 +339): | |||
3385 | { | |||
3386 | SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
3387 | Cancel(); | |||
3388 | } | |||
3389 | break; | |||
3390 | ||||
3391 | case SID_REMOTE_DLG(27000 +337): | |||
3392 | { | |||
3393 | #ifdef ENABLE_SDREMOTE1 | |||
3394 | SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); | |||
3395 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetFrameWeld())); | |||
3396 | pDlg->Execute(); | |||
3397 | #endif | |||
3398 | } | |||
3399 | break; | |||
3400 | ||||
3401 | case SID_CUSTOMSHOW_DLG(27000 +365): | |||
3402 | { | |||
3403 | SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
3404 | Cancel(); | |||
3405 | } | |||
3406 | break; | |||
3407 | ||||
3408 | case SID_EXPAND_PAGE(27000 +343): | |||
3409 | { | |||
3410 | SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
3411 | Cancel(); | |||
3412 | } | |||
3413 | break; | |||
3414 | ||||
3415 | case SID_SUMMARY_PAGE(27000 +344): | |||
3416 | { | |||
3417 | mpDrawView->SdrEndTextEdit(); | |||
3418 | SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); | |||
3419 | Cancel(); | |||
3420 | } | |||
3421 | break; | |||
3422 | ||||
3423 | #if HAVE_FEATURE_AVMEDIA1 | |||
3424 | case SID_AVMEDIA_PLAYER(5000 + 1694): | |||
3425 | { | |||
3426 | GetViewFrame()->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() ); | |||
3427 | GetViewFrame()->GetBindings().Invalidate( SID_AVMEDIA_PLAYER(5000 + 1694) ); | |||
3428 | Cancel(); | |||
3429 | rReq.Ignore (); | |||
3430 | } | |||
3431 | break; | |||
3432 | #endif | |||
3433 | ||||
3434 | case SID_PRESENTATION_MINIMIZER(27000 +450): | |||
3435 | { | |||
3436 | Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext()); | |||
3437 | Reference<util::XURLTransformer> xParser(util::URLTransformer::create(xContext)); | |||
3438 | Reference<frame::XDispatchProvider> xProvider(GetViewShellBase().GetController()->getFrame(), UNO_QUERY); | |||
3439 | if (xProvider.is()) | |||
3440 | { | |||
3441 | util::URL aURL; | |||
3442 | aURL.Complete = "vnd.com.sun.star.comp.PresentationMinimizer:execute"; | |||
3443 | xParser->parseStrict(aURL); | |||
3444 | uno::Reference<frame::XDispatch> xDispatch(xProvider->queryDispatch(aURL, OUString(), 0)); | |||
3445 | if (xDispatch.is()) | |||
3446 | { | |||
3447 | xDispatch->dispatch(aURL, uno::Sequence< beans::PropertyValue >()); | |||
3448 | } | |||
3449 | } | |||
3450 | Cancel(); | |||
3451 | rReq.Ignore(); | |||
3452 | } | |||
3453 | break; | |||
3454 | ||||
3455 | case SID_DISPLAY_MASTER_BACKGROUND(27000 +436): | |||
3456 | case SID_DISPLAY_MASTER_OBJECTS(27000 +437): | |||
3457 | { | |||
3458 | // Determine current page and toggle visibility of layers | |||
3459 | // associated with master page background or master page shapes. | |||
3460 | // FIXME: This solution is wrong, because shapes of master pages need | |||
3461 | // not be on layer "background" or "backgroundobjects". | |||
3462 | // See tdf#118613 | |||
3463 | SdPage* pPage = GetActualPage(); | |||
3464 | if (pPage != nullptr | |||
3465 | && GetDoc() != nullptr) | |||
3466 | { | |||
3467 | SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); | |||
3468 | SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); | |||
3469 | SdrLayerID aLayerId; | |||
3470 | if (nSId == SID_DISPLAY_MASTER_BACKGROUND(27000 +436)) | |||
3471 | aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background); | |||
3472 | else | |||
3473 | aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); | |||
3474 | aVisibleLayers.Set(aLayerId, !aVisibleLayers.IsSet(aLayerId)); | |||
3475 | pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); | |||
3476 | } | |||
3477 | Cancel(); | |||
3478 | rReq.Done(); // Mark task as done to auto-update the state of each buttons tdf#132816 | |||
3479 | } | |||
3480 | break; | |||
3481 | ||||
3482 | case SID_PHOTOALBUM(27000 +336): | |||
3483 | { | |||
3484 | SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); | |||
3485 | vcl::Window* pWin = GetActiveWindow(); | |||
3486 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog( | |||
3487 | pWin ? pWin->GetFrameWeld() : nullptr, | |||
3488 | GetDoc())); | |||
3489 | ||||
3490 | pDlg->Execute(); | |||
3491 | Cancel(); | |||
3492 | rReq.Ignore (); | |||
3493 | } | |||
3494 | break; | |||
3495 | ||||
3496 | case SID_INSERT_QRCODE( 10000 + 1191 ): | |||
3497 | case SID_EDIT_QRCODE( 10000 + 1192 ): | |||
3498 | { | |||
3499 | VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); | |||
3500 | const uno::Reference<frame::XModel> xModel = GetViewShellBase().GetController()->getModel(); | |||
3501 | ScopedVclPtr<AbstractQrCodeGenDialog> pDlg(pFact->CreateQrCodeGenDialog( | |||
3502 | GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_QRCODE( 10000 + 1192 ))); | |||
3503 | pDlg->Execute(); | |||
3504 | Cancel(); | |||
3505 | rReq.Ignore (); | |||
3506 | } | |||
3507 | break; | |||
3508 | ||||
3509 | case SID_ADDITIONS_DIALOG(5000 + 1740): | |||
3510 | { | |||
3511 | OUString sAdditionsTag = ""; | |||
3512 | ||||
3513 | const SfxStringItem* pStringArg = rReq.GetArg<SfxStringItem>(SID_ADDITIONS_TAG(5000 + 1741)); | |||
3514 | if (pStringArg) | |||
3515 | sAdditionsTag = pStringArg->GetValue(); | |||
3516 | ||||
3517 | VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); | |||
3518 | ScopedVclPtr<AbstractAdditionsDialog> pDlg( | |||
3519 | pFact->CreateAdditionsDialog(GetFrameWeld(), sAdditionsTag)); | |||
3520 | pDlg->Execute(); | |||
3521 | Cancel(); | |||
3522 | rReq.Ignore (); | |||
3523 | } | |||
3524 | break; | |||
3525 | ||||
3526 | case SID_ATTR_GLOW_COLOR( 10000 + 321 ): | |||
3527 | case SID_ATTR_GLOW_RADIUS( 10000 + 320 ): | |||
3528 | case SID_ATTR_GLOW_TRANSPARENCY( 10000 + 322 ): | |||
3529 | case SID_ATTR_SOFTEDGE_RADIUS( 10000 + 323 ): | |||
3530 | if (const SfxItemSet* pNewArgs = rReq.GetArgs()) | |||
3531 | mpDrawView->SetAttributes(*pNewArgs); | |||
3532 | rReq.Done(); | |||
3533 | Cancel(); | |||
3534 | break; | |||
3535 | ||||
3536 | default: | |||
3537 | { | |||
3538 | SAL_WARN( "sd.ui", "Slot without function" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sd.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Slot without function") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.ui"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "3538" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Slot without function"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Slot without function"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sd.ui"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "3538" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Slot without function") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.ui"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "3538" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Slot without function"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Slot without function"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sd.ui"), ("/home/maarten/src/libreoffice/core/sd/source/ui/view/drviews2.cxx" ":" "3538" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
3539 | Cancel(); | |||
3540 | rReq.Ignore (); | |||
3541 | } | |||
3542 | break; | |||
3543 | } | |||
3544 | ||||
3545 | if(HasCurrentFunction()) | |||
3546 | { | |||
3547 | GetCurrentFunction()->Activate(); | |||
3548 | } | |||
3549 | } | |||
3550 | ||||
3551 | void DrawViewShell::ExecChar( SfxRequest &rReq ) | |||
3552 | { | |||
3553 | SdDrawDocument* pDoc = GetDoc(); | |||
3554 | if (!pDoc || !mpDrawView) | |||
3555 | return; | |||
3556 | ||||
3557 | SfxItemSet aEditAttr( pDoc->GetPool() ); | |||
3558 | mpDrawView->GetAttributes( aEditAttr ); | |||
3559 | ||||
3560 | //modified by wj for sym2_1580, if put old itemset into new set, | |||
3561 | //when mpDrawView->SetAttributes(aNewAttr) it will invalidate all the item | |||
3562 | // and use old attr to update all the attributes | |||
3563 | // SfxItemSet aNewAttr( GetPool(), | |||
3564 | // EE_ITEMS_START, EE_ITEMS_END ); | |||
3565 | // aNewAttr.Put( aEditAttr, sal_False ); | |||
3566 | SfxItemSet aNewAttr( pDoc->GetPool() ); | |||
3567 | //modified end | |||
3568 | ||||
3569 | sal_uInt16 nSId = rReq.GetSlot(); | |||
3570 | ||||
3571 | switch ( nSId ) | |||
3572 | { | |||
3573 | case SID_ATTR_CHAR_FONT( 10000 + 7 ): | |||
3574 | if( rReq.GetArgs() ) | |||
3575 | { | |||
3576 | const SvxFontItem* pItem = rReq.GetArg<SvxFontItem>(SID_ATTR_CHAR_FONT( 10000 + 7 )); | |||
3577 | if (pItem) | |||
3578 | { | |||
3579 | aNewAttr.Put(*pItem); | |||
3580 | } | |||
3581 | } | |||
3582 | break; | |||
3583 | case SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 ): | |||
3584 | if( rReq.GetArgs() ) | |||
3585 | { | |||
3586 | const SvxFontHeightItem* pItem = rReq.GetArg<SvxFontHeightItem>(SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 )); | |||
3587 | if (pItem) | |||
3588 | { | |||
3589 | aNewAttr.Put(*pItem); | |||
3590 | } | |||
3591 | } | |||
3592 | break; | |||
3593 | case SID_ATTR_CHAR_WEIGHT( 10000 + 9 ): | |||
3594 | if( rReq.GetArgs() ) | |||
3595 | { | |||
3596 | const SvxWeightItem* pItem = rReq.GetArg<SvxWeightItem>(SID_ATTR_CHAR_WEIGHT( 10000 + 9 )); | |||
3597 | if (pItem) | |||
3598 | { | |||
3599 | aNewAttr.Put(*pItem); | |||
3600 | } | |||
3601 | } | |||
3602 | break; | |||
3603 | case SID_ATTR_CHAR_POSTURE( 10000 + 8 ): | |||
3604 | if( rReq.GetArgs() ) | |||
3605 | { | |||
3606 | const SvxPostureItem* pItem = rReq.GetArg<SvxPostureItem>(SID_ATTR_CHAR_POSTURE( 10000 + 8 )); | |||
3607 | if (pItem) | |||
3608 | { | |||
3609 | aNewAttr.Put(*pItem); | |||
3610 | } | |||
3611 | } | |||
3612 | break; | |||
3613 | case SID_ATTR_CHAR_UNDERLINE( 10000 + 14 ): | |||
3614 | if( rReq.GetArgs() ) | |||
3615 | { | |||
3616 | const SvxUnderlineItem* pItem = rReq.GetArg<SvxUnderlineItem>(SID_ATTR_CHAR_UNDERLINE( 10000 + 14 )); | |||
3617 | if (pItem) | |||
3618 | { | |||
3619 | aNewAttr.Put(*pItem); | |||
3620 | } | |||
3621 | else | |||
3622 | { | |||
3623 | FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle(); | |||
3624 | aNewAttr.Put( SvxUnderlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_UNDERLINE ) ); | |||
3625 | } | |||
3626 | } | |||
3627 | break; | |||
3628 | case SID_ATTR_CHAR_OVERLINE( ((10000 + 1499) + 1) + 68 ): | |||
3629 | if( rReq.GetArgs() ) | |||
3630 | { | |||
3631 | const SvxOverlineItem* pItem = rReq.GetArg<SvxOverlineItem>(SID_ATTR_CHAR_OVERLINE( ((10000 + 1499) + 1) + 68 )); | |||
3632 | if (pItem) | |||
3633 | { | |||
3634 | aNewAttr.Put(*pItem); | |||
3635 | } | |||
3636 | else | |||
3637 | { | |||
3638 | FontLineStyle eFU = aEditAttr.Get( EE_CHAR_OVERLINE ).GetLineStyle(); | |||
3639 | aNewAttr.Put( SvxOverlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_OVERLINE ) ); | |||
3640 | } | |||
3641 | } | |||
3642 | break; | |||
3643 | ||||
3644 | case SID_ULINE_VAL_NONE(10000 + 1195): | |||
3645 | { | |||
3646 | aNewAttr.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE)); | |||
3647 | break; | |||
3648 | } | |||
3649 | ||||
3650 | case SID_ULINE_VAL_SINGLE(10000 + 1196): | |||
3651 | case SID_ULINE_VAL_DOUBLE(10000 + 1197): | |||
3652 | case SID_ULINE_VAL_DOTTED(10000 + 1198): | |||
3653 | { | |||
3654 | FontLineStyle eOld = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle(); | |||
3655 | FontLineStyle eNew = eOld; | |||
3656 | ||||
3657 | switch (nSId) | |||
3658 | { | |||
3659 | case SID_ULINE_VAL_SINGLE(10000 + 1196): | |||
3660 | eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE; | |||
3661 | break; | |||
3662 | case SID_ULINE_VAL_DOUBLE(10000 + 1197): | |||
3663 | eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE; | |||
3664 | break; | |||
3665 | case SID_ULINE_VAL_DOTTED(10000 + 1198): | |||
3666 | eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED; | |||
3667 | break; | |||
3668 | } | |||
3669 | ||||
3670 | SvxUnderlineItem aUnderline(eNew, EE_CHAR_UNDERLINE); | |||
3671 | aNewAttr.Put(aUnderline); | |||
3672 | } | |||
3673 | break; | |||
3674 | ||||
3675 | case SID_ATTR_CHAR_SHADOWED( 10000 + 10 ): | |||
3676 | if( rReq.GetArgs() ) | |||
3677 | { | |||
3678 | const SvxShadowedItem* pItem = rReq.GetArg<SvxShadowedItem>(SID_ATTR_CHAR_SHADOWED( 10000 + 10 )); | |||
3679 | if (pItem) | |||
3680 | { | |||
3681 | aNewAttr.Put(*pItem); | |||
3682 | } | |||
3683 | } | |||
3684 | break; | |||
3685 | case SID_ATTR_CHAR_CONTOUR( 10000 + 12 ): | |||
3686 | if( rReq.GetArgs() ) | |||
3687 | { | |||
3688 | const SvxContourItem* pItem = rReq.GetArg<SvxContourItem>(SID_ATTR_CHAR_CONTOUR( 10000 + 12 )); | |||
3689 | if (pItem) | |||
3690 | { | |||
3691 | aNewAttr.Put(*pItem); | |||
3692 | } | |||
3693 | } | |||
3694 | break; | |||
3695 | ||||
3696 | case SID_ATTR_CHAR_STRIKEOUT( 10000 + 13 ): | |||
3697 | if( rReq.GetArgs() ) | |||
3698 | { | |||
3699 | const SvxCrossedOutItem* pItem = rReq.GetArg<SvxCrossedOutItem>(SID_ATTR_CHAR_STRIKEOUT( 10000 + 13 )); | |||
3700 | if (pItem) | |||
3701 | { | |||
3702 | aNewAttr.Put(*pItem); | |||
3703 | } | |||
3704 | } | |||
3705 | break; | |||
3706 | case SID_ATTR_CHAR_COLOR( 10000 + 17 ): | |||
3707 | if( rReq.GetArgs() ) | |||
3708 | { | |||
3709 | const SvxColorItem* pItem = rReq.GetArg<SvxColorItem>(SID_ATTR_CHAR_COLOR( 10000 + 17 )); | |||
3710 | if (pItem) | |||
3711 | { | |||
3712 | aNewAttr.Put(*pItem); | |||
3713 | } | |||
3714 | } | |||
3715 | break; | |||
3716 | case SID_ATTR_CHAR_KERNING( 10000 + 18 ): | |||
3717 | if( rReq.GetArgs() ) | |||
3718 | { | |||
3719 | const SvxKerningItem* pItem = rReq.GetArg<SvxKerningItem>(SID_ATTR_CHAR_KERNING( 10000 + 18 )); | |||
3720 | if (pItem) | |||
3721 | { | |||
3722 | aNewAttr.Put(*pItem); | |||
3723 | } | |||
3724 | } | |||
3725 | break; | |||
3726 | case SID_ATTR_CHAR_CASEMAP( 10000 + 19 ): | |||
3727 | if( rReq.GetArgs() ) | |||
3728 | { | |||
3729 | const SvxCaseMapItem* pItem = rReq.GetArg<SvxCaseMapItem>(SID_ATTR_CHAR_CASEMAP( 10000 + 19 )); | |||
3730 | if (pItem) | |||
3731 | { | |||
3732 | aNewAttr.Put(*pItem); | |||
3733 | } | |||
3734 | } | |||
3735 | break; | |||
3736 | case SID_SET_SUB_SCRIPT( 10000 + 295 ): | |||
3737 | { | |||
3738 | SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); | |||
3739 | SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); | |||
3740 | if( eEsc == SvxEscapement::Subscript ) | |||
3741 | aItem.SetEscapement( SvxEscapement::Off ); | |||
3742 | else | |||
3743 | aItem.SetEscapement( SvxEscapement::Subscript ); | |||
3744 | aNewAttr.Put( aItem ); | |||
3745 | } | |||
3746 | break; | |||
3747 | case SID_SET_SUPER_SCRIPT( 10000 + 294 ): | |||
3748 | { | |||
3749 | SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); | |||
3750 | SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); | |||
3751 | if( eEsc == SvxEscapement::Superscript ) | |||
3752 | aItem.SetEscapement( SvxEscapement::Off ); | |||
3753 | else | |||
3754 | aItem.SetEscapement( SvxEscapement::Superscript ); | |||
3755 | aNewAttr.Put( aItem ); | |||
3756 | } | |||
3757 | break; | |||
3758 | case SID_SHRINK_FONT_SIZE( 10000 + 1043 ): | |||
3759 | case SID_GROW_FONT_SIZE( 10000 + 1042 ): | |||
3760 | { | |||
3761 | const SvxFontListItem* pFonts = dynamic_cast<const SvxFontListItem*>(GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST( 10000 + 22 ) ) ); | |||
3762 | const FontList* pFontList = pFonts ? pFonts->GetFontList() : nullptr; | |||
3763 | if( pFontList ) | |||
3764 | { | |||
3765 | FuText::ChangeFontSize( nSId == SID_GROW_FONT_SIZE( 10000 + 1042 ), nullptr, pFontList, mpView ); | |||
3766 | GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 ) ); | |||
3767 | } | |||
3768 | break; | |||
3769 | } | |||
3770 | case SID_ATTR_CHAR_BACK_COLOR( 10000 + 1153 ): | |||
3771 | if( rReq.GetArgs() ) | |||
3772 | { | |||
3773 | const SvxBackgroundColorItem* pItem = rReq.GetArg<SvxBackgroundColorItem>(SID_ATTR_CHAR_BACK_COLOR( 10000 + 1153 )); | |||
3774 | if (pItem) | |||
3775 | { | |||
3776 | aNewAttr.Put(*pItem); | |||
3777 | } | |||
3778 | } | |||
3779 | break; | |||
3780 | default: | |||
3781 | break; | |||
3782 | } | |||
3783 | ||||
3784 | mpDrawView->SetAttributes(aNewAttr); | |||
3785 | rReq.Done(); | |||
3786 | Cancel(); | |||
3787 | } | |||
3788 | ||||
3789 | /** This method consists basically of three parts: | |||
3790 | 1. Process the arguments of the SFX request. | |||
3791 | 2. Use the model to create a new page or duplicate an existing one. | |||
3792 | 3. Update the tab control and switch to the new page. | |||
3793 | */ | |||
3794 | SdPage* DrawViewShell::CreateOrDuplicatePage ( | |||
3795 | SfxRequest& rRequest, | |||
3796 | PageKind ePageKind, | |||
3797 | SdPage* pPage, | |||
3798 | const sal_Int32 nInsertPosition) | |||
3799 | { | |||
3800 | SdPage* pNewPage = nullptr; | |||
3801 | if (ePageKind == PageKind::Standard && meEditMode != EditMode::MasterPage) | |||
3802 | { | |||
3803 | if ( mpDrawView->IsTextEdit() ) | |||
3804 | { | |||
3805 | mpDrawView->SdrEndTextEdit(); | |||
3806 | } | |||
3807 | pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition); | |||
3808 | } | |||
3809 | return pNewPage; | |||
3810 | } | |||
3811 | ||||
3812 | void DrawViewShell::DuplicateSelectedSlides (SfxRequest& rRequest) | |||
3813 | { | |||
3814 | // Create a list of the pages that are to be duplicated. The process of | |||
3815 | // duplication alters the selection. | |||
3816 | sal_Int32 nInsertPosition (0); | |||
3817 | ::std::vector<SdPage*> aPagesToDuplicate; | |||
3818 | sd::slidesorter::SlideSorter &mrSlideSorter = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase())->GetSlideSorter(); | |||
3819 | sd::slidesorter::model::PageEnumeration aSelectedPages ( | |||
3820 | sd::slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); | |||
3821 | while (aSelectedPages.HasMoreElements()) | |||
3822 | { | |||
3823 | sd::slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); | |||
3824 | if (pDescriptor && pDescriptor->GetPage()) | |||
3825 | { | |||
3826 | aPagesToDuplicate.push_back(pDescriptor->GetPage()); | |||
3827 | nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2; | |||
3828 | } | |||
3829 | } | |||
3830 | ||||
3831 | // Duplicate the pages in aPagesToDuplicate and collect the newly | |||
3832 | // created pages in aPagesToSelect. | |||
3833 | const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled()); | |||
3834 | if (bUndo) | |||
3835 | mrSlideSorter.GetView().BegUndo(SdResId(STR_INSERTPAGEreinterpret_cast<char const *>("STR_INSERTPAGE" "\004" u8"Insert Slide" ))); | |||
3836 | ||||
3837 | ::std::vector<SdPage*> aPagesToSelect; | |||
3838 | for(::std::vector<SdPage*>::const_iterator | |||
3839 | iPage(aPagesToDuplicate.begin()), | |||
3840 | iEnd(aPagesToDuplicate.end()); | |||
3841 | iPage!=iEnd; | |||
3842 | ++iPage, nInsertPosition+=2) | |||
3843 | { | |||
3844 | aPagesToSelect.push_back( | |||
3845 | mrSlideSorter.GetViewShell()->CreateOrDuplicatePage( | |||
3846 | rRequest, PageKind::Standard, *iPage, nInsertPosition)); | |||
3847 | } | |||
3848 | aPagesToDuplicate.clear(); | |||
3849 | ||||
3850 | if (bUndo) | |||
3851 | mrSlideSorter.GetView().EndUndo(); | |||
3852 | ||||
3853 | // Set the selection to the pages in aPagesToSelect. | |||
3854 | sd::slidesorter::controller::PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); | |||
3855 | rSelector.DeselectAllPages(); | |||
3856 | for (auto const& it: aPagesToSelect) | |||
3857 | { | |||
3858 | rSelector.SelectPage(it); | |||
3859 | } | |||
3860 | } | |||
3861 | ||||
3862 | void DrawViewShell::ExecutePropPanelAttr (SfxRequest const & rReq) | |||
3863 | { | |||
3864 | if(SlideShow::IsRunning( GetViewShellBase() )) | |||
3865 | return; | |||
3866 | ||||
3867 | SdDrawDocument* pDoc = GetDoc(); | |||
3868 | if (!pDoc || !mpDrawView) | |||
3869 | return; | |||
3870 | ||||
3871 | sal_uInt16 nSId = rReq.GetSlot(); | |||
3872 | SfxItemSet aAttrs( pDoc->GetPool() ); | |||
3873 | ||||
3874 | switch ( nSId ) | |||
3875 | { | |||
3876 | case SID_TABLE_VERT_NONE( 10000 + 1075 ): | |||
3877 | case SID_TABLE_VERT_CENTER( 10000 + 1074 ): | |||
3878 | case SID_TABLE_VERT_BOTTOM( 10000 + 1073 ): | |||
3879 | SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP; | |||
3880 | if (nSId == SID_TABLE_VERT_CENTER( 10000 + 1074 )) | |||
3881 | eTVA = SDRTEXTVERTADJUST_CENTER; | |||
3882 | else if (nSId == SID_TABLE_VERT_BOTTOM( 10000 + 1073 )) | |||
3883 | eTVA = SDRTEXTVERTADJUST_BOTTOM; | |||
3884 | ||||
3885 | aAttrs.Put( SdrTextVertAdjustItem(eTVA) ); | |||
3886 | mpDrawView->SetAttributes(aAttrs); | |||
3887 | ||||
3888 | break; | |||
3889 | } | |||
3890 | } | |||
3891 | ||||
3892 | void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet) | |||
3893 | { | |||
3894 | SfxWhichIter aIter( rSet ); | |||
3895 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
3896 | ||||
3897 | SdDrawDocument* pDoc = GetDoc(); | |||
3898 | if (!pDoc || !mpDrawView) | |||
3899 | return; | |||
3900 | ||||
3901 | SfxItemSet aAttrs( pDoc->GetPool() ); | |||
3902 | mpDrawView->GetAttributes( aAttrs ); | |||
3903 | ||||
3904 | while ( nWhich ) | |||
3905 | { | |||
3906 | sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich) | |||
3907 | ? GetPool().GetSlotId(nWhich) | |||
3908 | : nWhich; | |||
3909 | switch ( nSlotId ) | |||
3910 | { | |||
3911 | case SID_TABLE_VERT_NONE( 10000 + 1075 ): | |||
3912 | case SID_TABLE_VERT_CENTER( 10000 + 1074 ): | |||
3913 | case SID_TABLE_VERT_BOTTOM( 10000 + 1073 ): | |||
3914 | bool bContour = false; | |||
3915 | SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ); | |||
3916 | if( eConState != SfxItemState::DONTCARE ) | |||
3917 | { | |||
3918 | bContour = aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue(); | |||
3919 | } | |||
3920 | if (bContour) break; | |||
3921 | ||||
3922 | SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); | |||
3923 | //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); | |||
3924 | ||||
3925 | //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) | |||
3926 | if(SfxItemState::DONTCARE != eVState) | |||
3927 | { | |||
3928 | SdrTextVertAdjust eTVA = aAttrs.Get(SDRATTR_TEXT_VERTADJUST).GetValue(); | |||
3929 | bool bSet = (nSlotId == SID_TABLE_VERT_NONE( 10000 + 1075 ) && eTVA == SDRTEXTVERTADJUST_TOP) || | |||
3930 | (nSlotId == SID_TABLE_VERT_CENTER( 10000 + 1074 ) && eTVA == SDRTEXTVERTADJUST_CENTER) || | |||
3931 | (nSlotId == SID_TABLE_VERT_BOTTOM( 10000 + 1073 ) && eTVA == SDRTEXTVERTADJUST_BOTTOM); | |||
3932 | rSet.Put(SfxBoolItem(nSlotId, bSet)); | |||
3933 | } | |||
3934 | else | |||
3935 | { | |||
3936 | rSet.Put(SfxBoolItem(nSlotId, false)); | |||
3937 | } | |||
3938 | break; | |||
3939 | } | |||
3940 | nWhich = aIter.NextWhich(); | |||
3941 | } | |||
3942 | } | |||
3943 | ||||
3944 | } // end of namespace sd | |||
3945 | ||||
3946 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||
22 | |||||||||
23 | #include "sal/config.h" | ||||||||
24 | |||||||||
25 | #include <cassert> | ||||||||
26 | #include <cstddef> | ||||||||
27 | #include <functional> | ||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
29 | #include <type_traits> | ||||||||
30 | #endif | ||||||||
31 | |||||||||
32 | #include "sal/types.h" | ||||||||
33 | |||||||||
34 | namespace rtl | ||||||||
35 | { | ||||||||
36 | |||||||||
37 | /** Template reference class for reference type. | ||||||||
38 | */ | ||||||||
39 | template <class reference_type> | ||||||||
40 | class Reference | ||||||||
41 | { | ||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||
43 | */ | ||||||||
44 | reference_type * m_pBody; | ||||||||
45 | |||||||||
46 | |||||||||
47 | public: | ||||||||
48 | /** Constructor... | ||||||||
49 | */ | ||||||||
50 | Reference() | ||||||||
51 | : m_pBody (NULL__null) | ||||||||
52 | {} | ||||||||
53 | |||||||||
54 | |||||||||
55 | /** Constructor... | ||||||||
56 | */ | ||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||
58 | : m_pBody (pBody) | ||||||||
59 | { | ||||||||
60 | } | ||||||||
61 | |||||||||
62 | /** Constructor... | ||||||||
63 | */ | ||||||||
64 | Reference (reference_type * pBody) | ||||||||
65 | : m_pBody (pBody) | ||||||||
66 | { | ||||||||
67 | if (m_pBody) | ||||||||
68 | m_pBody->acquire(); | ||||||||
69 | } | ||||||||
70 | |||||||||
71 | /** Copy constructor... | ||||||||
72 | */ | ||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||
75 | { | ||||||||
76 | if (m_pBody) | ||||||||
77 | m_pBody->acquire(); | ||||||||
78 | } | ||||||||
79 | |||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
81 | /** Move constructor... | ||||||||
82 | */ | ||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||
85 | { | ||||||||
86 | handle.m_pBody = nullptr; | ||||||||
87 | } | ||||||||
88 | #endif | ||||||||
89 | |||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||
92 | |||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||
94 | |||||||||
95 | @param rRef another reference | ||||||||
96 | */ | ||||||||
97 | template< class derived_type > | ||||||||
98 | inline Reference( | ||||||||
99 | const Reference< derived_type > & rRef, | ||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||
101 | : m_pBody (rRef.get()) | ||||||||
102 | { | ||||||||
103 | if (m_pBody) | ||||||||
104 | m_pBody->acquire(); | ||||||||
105 | } | ||||||||
106 | #endif | ||||||||
107 | |||||||||
108 | /** Destructor... | ||||||||
109 | */ | ||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||
111 | { | ||||||||
112 | if (m_pBody
| ||||||||
113 | m_pBody->release(); | ||||||||
114 | } | ||||||||
115 | |||||||||
116 | /** Set... | ||||||||
117 | Similar to assignment. | ||||||||
118 | */ | ||||||||
119 | Reference<reference_type> & | ||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||
121 | { | ||||||||
122 | if (pBody) | ||||||||
123 | pBody->acquire(); | ||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||
125 | m_pBody = pBody; | ||||||||
126 | if (pOld) | ||||||||
127 | pOld->release(); | ||||||||
128 | return *this; | ||||||||
129 | } | ||||||||
130 | |||||||||
131 | /** Assignment. | ||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||
133 | bind it to the body represented by the handle. | ||||||||
134 | */ | ||||||||
135 | Reference<reference_type> & | ||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||
137 | { | ||||||||
138 | return set( handle.m_pBody ); | ||||||||
139 | } | ||||||||
140 | |||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
142 | /** Assignment. | ||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||
144 | * bind it to the body represented by the handle, and | ||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||
146 | */ | ||||||||
147 | Reference<reference_type> & | ||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||
149 | { | ||||||||
150 | // self-movement guts ourself | ||||||||
151 | if (m_pBody) | ||||||||
152 | m_pBody->release(); | ||||||||
153 | m_pBody = handle.m_pBody; | ||||||||
154 | handle.m_pBody = nullptr; | ||||||||
155 | return *this; | ||||||||
156 | } | ||||||||
157 | #endif | ||||||||
158 | |||||||||
159 | /** Assignment... | ||||||||
160 | */ | ||||||||
161 | Reference<reference_type> & | ||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||
163 | { | ||||||||
164 | return set( pBody ); | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | /** Unbind the body from this handle. | ||||||||
168 | Note that for a handle representing a large body, | ||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||
171 | since in the second case two large objects exist in memory | ||||||||
172 | (the old body and the new body). | ||||||||
173 | */ | ||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||
175 | { | ||||||||
176 | if (m_pBody) | ||||||||
177 | { | ||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||
179 | m_pBody = NULL__null; | ||||||||
180 | pOld->release(); | ||||||||
181 | } | ||||||||
182 | return *this; | ||||||||
183 | } | ||||||||
184 | |||||||||
185 | |||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||
188 | are the same. | ||||||||
189 | */ | ||||||||
190 | reference_type * SAL_CALL get() const | ||||||||
191 | { | ||||||||
192 | return m_pBody; | ||||||||
| |||||||||
193 | } | ||||||||
194 | |||||||||
195 | |||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||
197 | */ | ||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||
199 | { | ||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||
201 | return m_pBody; | ||||||||
202 | } | ||||||||
203 | |||||||||
204 | |||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||
206 | */ | ||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||
208 | { | ||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||
210 | return *m_pBody; | ||||||||
211 | } | ||||||||
212 | |||||||||
213 | |||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||
215 | */ | ||||||||
216 | bool SAL_CALL is() const | ||||||||
217 | { | ||||||||
218 | return (m_pBody != NULL__null); | ||||||||
219 | } | ||||||||
220 | |||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||
223 | */ | ||||||||
224 | explicit operator bool() const | ||||||||
225 | { | ||||||||
226 | return is(); | ||||||||
227 | } | ||||||||
228 | #endif | ||||||||
229 | |||||||||
230 | /** Returns True if this points to pBody. | ||||||||
231 | */ | ||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||
233 | { | ||||||||
234 | return (m_pBody == pBody); | ||||||||
235 | } | ||||||||
236 | |||||||||
237 | |||||||||
238 | /** Returns True if handle points to the same body. | ||||||||
239 | */ | ||||||||
240 | bool | ||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||
242 | { | ||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | |||||||||
247 | /** Needed to place References into STL collection. | ||||||||
248 | */ | ||||||||
249 | bool | ||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||
251 | { | ||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||
253 | } | ||||||||
254 | |||||||||
255 | |||||||||
256 | /** Needed to place References into STL collection. | ||||||||
257 | */ | ||||||||
258 | bool | ||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||
260 | { | ||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||
262 | } | ||||||||
263 | |||||||||
264 | |||||||||
265 | /** Needed to place References into STL collection. | ||||||||
266 | */ | ||||||||
267 | bool | ||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||
269 | { | ||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||
271 | } | ||||||||
272 | }; | ||||||||
273 | |||||||||
274 | } // namespace rtl | ||||||||
275 | |||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
277 | namespace std | ||||||||
278 | { | ||||||||
279 | |||||||||
280 | /// @cond INTERNAL | ||||||||
281 | /** | ||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||
283 | |||||||||
284 | @since LibreOffice 6.3 | ||||||||
285 | */ | ||||||||
286 | template<typename T> | ||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||
288 | { | ||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||
290 | { return std::size_t(s.get()); } | ||||||||
291 | }; | ||||||||
292 | /// @endcond | ||||||||
293 | |||||||||
294 | } | ||||||||
295 | |||||||||
296 | #endif | ||||||||
297 | |||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||
299 | |||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |