LibreOffice Module sw (master) 1
vbacontentcontrol.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include <ooo/vba/word/WdColor.hpp>
11#include <ooo/vba/word/WdCalendarType.hpp>
12#include <ooo/vba/word/WdContentControlType.hpp>
13#include <ooo/vba/word/WdLanguageID.hpp>
14
15#include <sal/log.hxx>
16
17#include <ndtxt.hxx>
18#include <unotextrange.hxx>
19
20#include "vbacontentcontrol.hxx"
22#include "vbarange.hxx"
23
24using namespace ::ooo::vba;
25using namespace ::com::sun::star;
26
34SwVbaContentControl::SwVbaContentControl(const uno::Reference<XHelperInterface>& rParent,
35 const uno::Reference<uno::XComponentContext>& rContext,
36 const uno::Reference<text::XTextDocument>& xTextDocument,
37 std::shared_ptr<SwContentControl> pContentControl)
38 : SwVbaContentControl_BASE(rParent, rContext)
39 , mxTextDocument(xTextDocument)
40 , m_pCC(pContentControl)
41{
42 assert(m_pCC && "SwVbaContentControl created without a shared_ptr. Why would you do that?");
43}
44
46
48{
49 SAL_INFO("sw.vba", "SwVbaContentControl::getAllowInsertDeleteSection stub");
50 return false;
51}
52
54{
55 SAL_INFO("sw.vba", "SwVbaContentControl::setAllowInsertDeleteSection stub");
56}
57
59{
60 SAL_INFO("sw.vba", "SwVbaContentControl::getAppearance stub");
61 // wdContentControlBoundingBox / wdContentControlHidden / wdContentControlTags
62 return 0;
63}
64
66{
67 SAL_INFO("sw.vba", "SwVbaContentControl::setAppearance[" << nSet << "] stub");
68}
69
71{
72 SAL_INFO("sw.vba", "SwVbaContentControl::getBuildingBlockCategory stub");
73 return OUString();
74}
75
77{
78 SAL_INFO("sw.vba", "SwVbaContentControl::setBuildingBlockCategory[" << sSet << "] stub");
79}
80
82{
83 SAL_INFO("sw.vba", "SwVbaContentControl::getBuildingBlockType stub");
84 // returns a WdBuildingBlockTypes that represents the type of building block
85 return 0;
86}
87
89{
90 SAL_INFO("sw.vba", "SwVbaContentControl::setBuildingBlockType[" << nSet << "] stub");
91}
92
93sal_Bool SwVbaContentControl::getChecked() { return m_pCC->GetCheckbox() && m_pCC->GetChecked(); }
94
96{
97 // Word 2010: if locked, then the checked status is changed, but not the underlying text.
98 // Do we really want to do that? That is pretty bizarre behaviour...
99 // For now, just implement what seems to be a more logical response.
100 // TODO: test with modern versions.
101 if (getLockContents())
102 return;
103
104 if (m_pCC->GetCheckbox() && m_pCC->GetChecked() != static_cast<bool>(bSet))
105 {
106 m_pCC->SetChecked(bSet);
107 m_pCC->SetShowingPlaceHolder(false);
108 if (m_pCC->GetTextAttr())
109 m_pCC->GetTextAttr()->Invalidate();
110 }
111}
112
114{
115 //This is just an assumed implementation - I have no testing environment to confirm.
116 OUString sColor = m_pCC->GetColor();
117 if (sColor == "wdColorAutomatic")
118 return word::WdColor::wdColorAutomatic;
119 if (sColor == "wdColorBlack")
120 return word::WdColor::wdColorBlack;
121 if (sColor == "wdColorBlue")
122 return word::WdColor::wdColorBlue;
123 if (sColor == "wdColorBlueGray")
124 return word::WdColor::wdColorBlueGray;
125 if (sColor == "wdColorBrightGreen")
126 return word::WdColor::wdColorBrightGreen;
127 if (sColor == "wdColorBrown")
128 return word::WdColor::wdColorBrown;
129 if (sColor == "wdColorDarkBlue")
130 return word::WdColor::wdColorDarkBlue;
131 if (sColor == "wdColorDarkGreen")
132 return word::WdColor::wdColorDarkGreen;
133 if (sColor == "wdColorDarkRed")
134 return word::WdColor::wdColorDarkRed;
135 if (sColor == "wdColorDarkTeal")
136 return word::WdColor::wdColorDarkTeal;
137 if (sColor == "wdColorDarkYellow")
138 return word::WdColor::wdColorDarkYellow;
139 if (sColor == "wdColorGold")
140 return word::WdColor::wdColorGold;
141 if (sColor == "wdColorGray05")
142 return word::WdColor::wdColorGray05;
143 if (sColor == "wdColorGray10")
144 return word::WdColor::wdColorGray10;
145 if (sColor == "wdColorGray125")
146 return word::WdColor::wdColorGray125;
147 if (sColor == "wdColorGray15")
148 return word::WdColor::wdColorGray15;
149 if (sColor == "wdColorGray20")
150 return word::WdColor::wdColorGray20;
151 if (sColor == "wdColorGray25")
152 return word::WdColor::wdColorGray25;
153 if (sColor == "wdColorGray30")
154 return word::WdColor::wdColorGray30;
155 if (sColor == "wdColorGray35")
156 return word::WdColor::wdColorGray35;
157 if (sColor == "wdColorGray375")
158 return word::WdColor::wdColorGray375;
159 if (sColor == "wdColorGray40")
160 return word::WdColor::wdColorGray40;
161 if (sColor == "wdColorGray45")
162 return word::WdColor::wdColorGray45;
163 if (sColor == "wdColorGray50")
164 return word::WdColor::wdColorGray50;
165 if (sColor == "wdColorGray55")
166 return word::WdColor::wdColorGray55;
167 if (sColor == "wdColorGray60")
168 return word::WdColor::wdColorGray60;
169 if (sColor == "wdColorGray625")
170 return word::WdColor::wdColorGray625;
171 if (sColor == "wdColorGray65")
172 return word::WdColor::wdColorGray65;
173 if (sColor == "wdColorGray70")
174 return word::WdColor::wdColorGray70;
175 if (sColor == "wdColorGray75")
176 return word::WdColor::wdColorGray75;
177 if (sColor == "wdColorGray80")
178 return word::WdColor::wdColorGray80;
179 if (sColor == "wdColorGray85")
180 return word::WdColor::wdColorGray85;
181 if (sColor == "wdColorGray875")
182 return word::WdColor::wdColorGray875;
183 if (sColor == "wdColorGray90")
184 return word::WdColor::wdColorGray90;
185 if (sColor == "wdColorGray95")
186 return word::WdColor::wdColorGray95;
187 if (sColor == "wdColorGreen")
188 return word::WdColor::wdColorGreen;
189 if (sColor == "wdColorIndigo")
190 return word::WdColor::wdColorIndigo;
191 if (sColor == "wdColorLavender")
192 return word::WdColor::wdColorLavender;
193 if (sColor == "wdColorLightBlue")
194 return word::WdColor::wdColorLightBlue;
195 if (sColor == "wdColorLightGreen")
196 return word::WdColor::wdColorLightGreen;
197 if (sColor == "wdColorLightOrange")
198 return word::WdColor::wdColorLightOrange;
199 if (sColor == "wdColorLightTurquoise")
200 return word::WdColor::wdColorLightTurquoise;
201 if (sColor == "wdColorLightYellow")
202 return word::WdColor::wdColorLightYellow;
203 if (sColor == "wdColorLime")
204 return word::WdColor::wdColorLime;
205 if (sColor == "wdColorOliveGreen")
206 return word::WdColor::wdColorOliveGreen;
207 if (sColor == "wdColorOrange")
208 return word::WdColor::wdColorOrange;
209 if (sColor == "wdColorPaleBlue")
210 return word::WdColor::wdColorPaleBlue;
211 if (sColor == "wdColorPink")
212 return word::WdColor::wdColorPink;
213 if (sColor == "wdColorPlum")
214 return word::WdColor::wdColorPlum;
215 if (sColor == "wdColorRed")
216 return word::WdColor::wdColorRed;
217 if (sColor == "wdColorRose")
218 return word::WdColor::wdColorRose;
219 if (sColor == "wdColorSeaGreen")
220 return word::WdColor::wdColorSeaGreen;
221 if (sColor == "wdColorSkyBlue")
222 return word::WdColor::wdColorSkyBlue;
223 if (sColor == "wdColorTan")
224 return word::WdColor::wdColorTan;
225 if (sColor == "wdColorTeal")
226 return word::WdColor::wdColorTeal;
227 if (sColor == "wdColorTurquoise")
228 return word::WdColor::wdColorTurquoise;
229 if (sColor == "wdColorViolet")
230 return word::WdColor::wdColorViolet;
231 if (sColor == "wdColorWhite")
232 return word::WdColor::wdColorWhite;
233 if (sColor == "wdColorYellow")
234 return word::WdColor::wdColorYellow;
235
236 return word::WdColor::wdColorBlack;
237}
238
239void SwVbaContentControl::setColor(sal_Int32 nWdColor)
240{
241 switch (nWdColor)
242 {
243 case word::WdColor::wdColorAqua:
244 m_pCC->SetColor("wdColorAqua");
245 break;
246 case word::WdColor::wdColorAutomatic:
247 m_pCC->SetColor("wdColorAutomatic");
248 break;
249 case word::WdColor::wdColorBlack:
250 m_pCC->SetColor("wdColorBlack");
251 break;
252 case word::WdColor::wdColorBlue:
253 m_pCC->SetColor("wdColorBlue");
254 break;
255 case word::WdColor::wdColorBlueGray:
256 m_pCC->SetColor("wdColorBlueGray");
257 break;
258 case word::WdColor::wdColorBrightGreen:
259 m_pCC->SetColor("wdColorBrightGreen");
260 break;
261 case word::WdColor::wdColorBrown:
262 m_pCC->SetColor("wdColorBrown");
263 break;
264 case word::WdColor::wdColorDarkBlue:
265 m_pCC->SetColor("wdColorDarkBlue");
266 break;
267 case word::WdColor::wdColorDarkGreen:
268 m_pCC->SetColor("wdColorDarkGreen");
269 break;
270 case word::WdColor::wdColorDarkRed:
271 m_pCC->SetColor("wdColorDarkRed");
272 break;
273 case word::WdColor::wdColorDarkTeal:
274 m_pCC->SetColor("wdColorDarkTeal");
275 break;
276 case word::WdColor::wdColorDarkYellow:
277 m_pCC->SetColor("wdColorDarkYellow");
278 break;
279 case word::WdColor::wdColorGold:
280 m_pCC->SetColor("wdColorGold");
281 break;
282 case word::WdColor::wdColorGray05:
283 m_pCC->SetColor("wdColorGray05");
284 break;
285 case word::WdColor::wdColorGray10:
286 m_pCC->SetColor("wdColorGray10");
287 break;
288 case word::WdColor::wdColorGray125:
289 m_pCC->SetColor("wdColorGray125");
290 break;
291 case word::WdColor::wdColorGray15:
292 m_pCC->SetColor("wdColorGray15");
293 break;
294 case word::WdColor::wdColorGray20:
295 m_pCC->SetColor("wdColorGray20");
296 break;
297 case word::WdColor::wdColorGray25:
298 m_pCC->SetColor("wdColorGray25");
299 break;
300 case word::WdColor::wdColorGray30:
301 m_pCC->SetColor("wdColorGray30");
302 break;
303 case word::WdColor::wdColorGray35:
304 m_pCC->SetColor("wdColorGray35");
305 break;
306 case word::WdColor::wdColorGray375:
307 m_pCC->SetColor("wdColorGray375");
308 break;
309 case word::WdColor::wdColorGray40:
310 m_pCC->SetColor("wdColorGray40");
311 break;
312 case word::WdColor::wdColorGray45:
313 m_pCC->SetColor("wdColorGray45");
314 break;
315 case word::WdColor::wdColorGray50:
316 m_pCC->SetColor("wdColorGray50");
317 break;
318 case word::WdColor::wdColorGray55:
319 m_pCC->SetColor("wdColorGray55");
320 break;
321 case word::WdColor::wdColorGray60:
322 m_pCC->SetColor("wdColorGray60");
323 break;
324 case word::WdColor::wdColorGray625:
325 m_pCC->SetColor("wdColorGray625");
326 break;
327 case word::WdColor::wdColorGray65:
328 m_pCC->SetColor("wdColorGray65");
329 break;
330 case word::WdColor::wdColorGray70:
331 m_pCC->SetColor("wdColorGray70");
332 break;
333 case word::WdColor::wdColorGray75:
334 m_pCC->SetColor("wdColorGray75");
335 break;
336 case word::WdColor::wdColorGray80:
337 m_pCC->SetColor("wdColorGray80");
338 break;
339 case word::WdColor::wdColorGray85:
340 m_pCC->SetColor("wdColorGray85");
341 break;
342 case word::WdColor::wdColorGray875:
343 m_pCC->SetColor("wdColorGray875");
344 break;
345 case word::WdColor::wdColorGray90:
346 m_pCC->SetColor("wdColorGray90");
347 break;
348 case word::WdColor::wdColorGray95:
349 m_pCC->SetColor("wdColorGray95");
350 break;
351 case word::WdColor::wdColorGreen:
352 m_pCC->SetColor("wdColorGreen");
353 break;
354 case word::WdColor::wdColorIndigo:
355 m_pCC->SetColor("wdColorIndigo");
356 break;
357 case word::WdColor::wdColorLavender:
358 m_pCC->SetColor("wdColorLavender");
359 break;
360 case word::WdColor::wdColorLightBlue:
361 m_pCC->SetColor("wdColorLightBlue");
362 break;
363 case word::WdColor::wdColorLightGreen:
364 m_pCC->SetColor("wdColorLightGreen");
365 break;
366 case word::WdColor::wdColorLightOrange:
367 m_pCC->SetColor("wdColorLightOrange");
368 break;
369 case word::WdColor::wdColorLightTurquoise:
370 m_pCC->SetColor("wdColorLightTurquoise");
371 break;
372 case word::WdColor::wdColorLightYellow:
373 m_pCC->SetColor("wdColorLightYellow");
374 break;
375 case word::WdColor::wdColorLime:
376 m_pCC->SetColor("wdColorLime");
377 break;
378 case word::WdColor::wdColorOliveGreen:
379 m_pCC->SetColor("wdColorOliveGreen");
380 break;
381 case word::WdColor::wdColorOrange:
382 m_pCC->SetColor("wdColorOrange");
383 break;
384 case word::WdColor::wdColorPaleBlue:
385 m_pCC->SetColor("wdColorPaleBlue");
386 break;
387 case word::WdColor::wdColorPink:
388 m_pCC->SetColor("wdColorPink");
389 break;
390 case word::WdColor::wdColorPlum:
391 m_pCC->SetColor("wdColorPlum");
392 break;
393 case word::WdColor::wdColorRed:
394 m_pCC->SetColor("wdColorRed");
395 break;
396 case word::WdColor::wdColorRose:
397 m_pCC->SetColor("wdColorRose");
398 break;
399 case word::WdColor::wdColorSeaGreen:
400 m_pCC->SetColor("wdColorSeaGreen");
401 break;
402 case word::WdColor::wdColorSkyBlue:
403 m_pCC->SetColor("wdColorSkyBlue");
404 break;
405 case word::WdColor::wdColorTan:
406 m_pCC->SetColor("wdColorTan");
407 break;
408 case word::WdColor::wdColorTeal:
409 m_pCC->SetColor("wdColorTeal");
410 break;
411 case word::WdColor::wdColorTurquoise:
412 m_pCC->SetColor("wdColorTurquoise");
413 break;
414 case word::WdColor::wdColorViolet:
415 m_pCC->SetColor("wdColorViolet");
416 break;
417 case word::WdColor::wdColorWhite:
418 m_pCC->SetColor("wdColorWhite");
419 break;
420 default:;
421 }
422}
423
425{
426 SAL_INFO("sw.vba", "SwVbaContentControl::getDateCalendarType stub");
427 // returns a WdCalendarTypes that represents the type of building block
428 return word::WdCalendarType::wdCalendarWestern;
429}
430
432{
433 SAL_INFO("sw.vba", "SwVbaContentControl::setDateCalendarType[" << nSet << "] stub");
434}
435
436OUString SwVbaContentControl::getDateDisplayFormat() { return m_pCC->GetDateFormat(); }
437
438void SwVbaContentControl::setDateDisplayFormat(const OUString& sSet) { m_pCC->SetDateFormat(sSet); }
439
441{
442 SAL_INFO("sw.vba", "SwVbaContentControl::getDateStorageFormat stub");
443 // returns a WdContentControlDateStorageFormat when bound to the XML data store.
444 return 0;
445}
446
448{
449 SAL_INFO("sw.vba", "SwVbaContentControl::setDateStorageFormat[" << nSet << "] stub");
450}
451
453{
454 SAL_INFO("sw.vba", "SwVbaContentControl::getDateDisplayLocale stub");
455 // returns a WdLanguageID that represents the language format for a date content control.
456 return word::WdLanguageID::wdEnglishUS;
457}
458
460{
461 if (!m_pCC->GetDropDown() && !m_pCC->GetComboBox())
462 return uno::Any();
463
464 return uno::Any(
465 uno::Reference<XCollection>(new SwVbaContentControlListEntries(this, mxContext, m_pCC)));
466}
467
469{
470 // This signed integer is treated in VBA as if it was an unsigned int.
471 return OUString::number(static_cast<sal_uInt32>(m_pCC->GetId()));
472}
473
475{
476 SAL_INFO("sw.vba", "SwVbaContentControl::getLevel stub");
477 // returns a WdContentControlLevel
478 return 0;
479}
480
482{
483 std::optional<bool> oLock = m_pCC->GetLock(/*bControl=*/true);
484 return oLock && *oLock;
485}
486
488{
489 std::optional<bool> oLock = m_pCC->GetLock(/*bControl=*/false);
490 m_pCC->SetLock(/*bContents=*/oLock && *oLock, /*bControl=*/bSet);
491}
492
494{
495 // If the theoretical design model says it is locked, then report as locked.
496 std::optional<bool> oLock = m_pCC->GetLock(/*bControl=*/false);
497 if (oLock && *oLock)
498 return true;
499
500 // Now check the real implementation.
501 // Checkbox/DropDown/Picture are normally locked - but not in this sense. Report as unlocked.
502 if (m_pCC->GetType() == SwContentControlType::CHECKBOX
504 || m_pCC->GetType() == SwContentControlType::PICTURE)
505 {
506 return false;
507 }
508
509 return m_pCC->GetReadWrite();
510}
511
513{
514 // Set the lock both theoretically and actually.
515 std::optional<bool> oLock = m_pCC->GetLock(/*bControl=*/true);
516 m_pCC->SetLock(/*bContents=*/bSet, /*bControl=*/oLock && *oLock);
517
518 // Checkbox/DropDown/Picture are normally locked in LO implementation - don't unlock them.
519 if (m_pCC->GetType() == SwContentControlType::CHECKBOX
521 || m_pCC->GetType() == SwContentControlType::PICTURE)
522 {
523 return;
524 }
525 m_pCC->SetReadWrite(bSet);
526}
527
529{
530 SAL_INFO("sw.vba", "SwVbaContentControl::getMultiLine stub");
531 return false;
532}
533
535{
536 SAL_INFO("sw.vba", "SwVbaContentControl::setMultiLine stub");
537}
538
540{
541 // return m_pCC->GetPlaceholderDocPart(); // This is not correct. Much more complex than this...
542 SAL_INFO("sw.vba", "SwVbaContentControl::getPlaceholderText stub");
543 return OUString();
544}
545
547
548uno::Reference<word::XRange> SwVbaContentControl::getRange()
549{
550 uno::Reference<word::XRange> xRet;
551 SwTextNode* pTextNode = m_pCC->GetTextNode();
552 if (pTextNode && m_pCC->GetTextAttr())
553 {
554 // Don't select the text attribute itself at the start.
555 SwPosition aStart(*pTextNode, m_pCC->GetTextAttr()->GetStart() + 1);
556 // Don't select the CH_TXTATR_BREAKWORD itself at the end.
557 SwPosition aEnd(*pTextNode, *m_pCC->GetTextAttr()->End() - 1);
558 uno::Reference<text::XTextRange> xText(
559 SwXTextRange::CreateXTextRange(pTextNode->GetDoc(), aStart, &aEnd));
560 if (xText.is())
561 xRet = new SwVbaRange(mxParent, mxContext, mxTextDocument, xText->getStart(),
562 xText->getEnd());
563 }
564 return xRet;
565}
566
568{
569 SAL_INFO("sw.vba", "SwVbaContentControl::getRepeatingSectionItemTitle stub");
570 return OUString();
571}
572
574{
575 SAL_INFO("sw.vba", "SwVbaContentControl::setRepeatingSectionItemTitle[" << rSet << "] stub");
576}
577
578OUString SwVbaContentControl::getTag() { return m_pCC->GetTag(); }
579
580void SwVbaContentControl::setTag(const OUString& rSet) { return m_pCC->SetTag(rSet); }
581
583{
584 SAL_INFO("sw.vba", "SwVbaContentControl::getTemporary stub");
585 // Is content control removed when user edits (one time use)? Not implemented in LO.
586 return false;
587}
588
590{
591 SAL_INFO("sw.vba", "SwVbaContentControl::setTemporary stub");
592}
593
594OUString SwVbaContentControl::getTitle() { return m_pCC->GetAlias(); }
595
596void SwVbaContentControl::setTitle(const OUString& rSet) { return m_pCC->SetAlias(rSet); }
597
599{
600 SwContentControlType eType = m_pCC->GetType();
601 sal_Int32 eVbaType = word::WdContentControlType::wdContentControlRichText;
602
603 switch (eType)
604 {
606 eVbaType = word::WdContentControlType::wdContentControlCheckbox;
607 break;
609 eVbaType = word::WdContentControlType::wdContentControlDropdownList;
610 break;
612 eVbaType = word::WdContentControlType::wdContentControlPicture;
613 break;
615 eVbaType = word::WdContentControlType::wdContentControlDate;
616 break;
618 eVbaType = word::WdContentControlType::wdContentControlText;
619 break;
621 eVbaType = word::WdContentControlType::wdContentControlComboBox;
622 break;
624 default:;
625 }
626 return eVbaType;
627}
628
630{
631 SAL_INFO("sw.vba", "SwVbaContentControl::setType[" << nSet << "] stub");
632 // SwContentControlType eType = SwContentControlType::RICH_TEXT;
633 // switch(nSet)
634 // {
635 // case word::WdContentControlType::wdContentControlCheckbox:
636 // eType = SwContentControlType::CHECKBOX;
637 // break;
638 // case word::WdContentControlType::wdContentControlDropdownList:
639 // eType = SwContentControlType::DROP_DOWN_LIST;
640 // break;
641 // case word::WdContentControlType::wdContentControlPicture:
642 // eType = SwContentControlType::PICTURE;
643 // break;
644 // case word::WdContentControlType::wdContentControlDate:
645 // eType = SwContentControlType::DATE;
646 // break;
647 // case word::WdContentControlType::wdContentControlText:
648 // eType = SwContentControlType::PLAIN_TEXT;
649 // break;
650 // case word::WdContentControlType::wdContentControlComboBox:
651 // eType = SwContentControlType::COMBO_BOX;
652 // break;
653 // case word::WdContentControlType::wdContentControlRichText:
654 // default:;
655 // }
656 // m_pCC->SetType(eType);
657}
658
660{
661 SAL_INFO("sw.vba", "SwVbaContentControl::Copy[" << getID() << "] stub");
662}
663
665{
666 if (getLockContentControl() || !m_pCC->GetTextAttr())
667 return;
668
669 SAL_INFO("sw.vba",
670 "SwVbaContentControl::Cut[" << getID() << "], but missing sending to clipboard");
671
672 m_pCC->GetTextAttr()->Delete(/*bSaveContents=*/getLockContents());
673}
674
675void SwVbaContentControl::Delete(const uno::Any& DeleteContents)
676{
677 if (getLockContentControl() || !m_pCC->GetTextAttr())
678 return;
679
680 bool bDeleteContents = false;
681 DeleteContents >>= bDeleteContents;
682
683 m_pCC->GetTextAttr()->Delete(/*bSaveContents=*/!bDeleteContents || getLockContents());
684}
685
686void SwVbaContentControl::SetCheckedSymbol(sal_Int32 Character, const uno::Any& Font)
687{
688 if (!m_pCC->GetTextAttr())
689 return;
690
691 SAL_INFO_IF(Font.hasValue(), "sw.vba", "SetCheckedSymbol Font[" << Font << "] stub");
692 if (Character < 31 || Character > SAL_MAX_UINT16)
693 return; // unsupported character. Would such a thing exist in VBA?
694
695 m_pCC->SetCheckedState(OUString(static_cast<sal_Unicode>(Character)));
696
697 if (m_pCC->GetCheckbox() && m_pCC->GetChecked() && !m_pCC->GetShowingPlaceHolder())
698 m_pCC->GetTextAttr()->Invalidate();
699}
700
701void SwVbaContentControl::SetUnCheckedSymbol(sal_Int32 Character, const uno::Any& Font)
702{
703 if (!m_pCC->GetTextAttr())
704 return;
705
706 SAL_INFO_IF(Font.hasValue(), "sw.vba", "SetUnCheckedSymbol Font[" << Font << "] stub");
707 if (Character < 31 || Character > SAL_MAX_UINT16)
708 return; // unsupported character. Would such a thing exist in VBA?
709
710 m_pCC->SetUncheckedState(OUString(static_cast<sal_Unicode>(Character)));
711
712 if (m_pCC->GetCheckbox() && !m_pCC->GetChecked() && !m_pCC->GetShowingPlaceHolder())
713 m_pCC->GetTextAttr()->Invalidate();
714}
715
717 const uno::Any& Text)
718{
719 SAL_INFO("sw.vba", "SwVbaContentControl::SetPlaceholderText stub");
720 if (BuildingBlock.hasValue())
721 {
722 // Set placeholder text to the building block - whatever that is.
723 }
724 else if (Range.hasValue())
725 {
726 // Set placeholder text to the contents of the Range, however you do that.
727 }
728 else if (Text.hasValue())
729 {
730 // Set placeholder text to the provided string
731 }
732 else
733 {
734 // Remove placeholder text.
735 m_pCC->SetPlaceholderDocPart("");
736 }
737 if (m_pCC->GetShowingPlaceHolder() && !getLockContents() && m_pCC->GetTextAttr())
738 {
739 //replace the text and ensure showing placeholder is still set
740 }
741}
742
743void SwVbaContentControl::Ungroup() { SAL_INFO("sw.vba", "SwVbaContentControl::UnGroup stub"); }
744
745OUString SwVbaContentControl::getServiceImplName() { return "SwVbaContentControl"; }
746
748{
749 static uno::Sequence<OUString> const aServiceNames{ "ooo.vba.word.ContentControl" };
750 return aServiceNames;
751}
752
753/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::WeakReference< ov::XHelperInterface > mxParent
SwDoc & GetDoc()
Definition: node.hxx:233
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
void SAL_CALL setBuildingBlockType(sal_Int32 nSet) override
OUString SAL_CALL getDateDisplayFormat() override
sal_Int32 SAL_CALL getLevel() override
OUString SAL_CALL getRepeatingSectionItemTitle() override
void SAL_CALL SetUnCheckedSymbol(sal_Int32 Character, const css::uno::Any &sFont) override
std::shared_ptr< SwContentControl > m_pCC
OUString SAL_CALL getTitle() override
void SAL_CALL setColor(sal_Int32 nSet) override
void SAL_CALL setMultiLine(sal_Bool bSet) override
void SAL_CALL setDateDisplayFormat(const OUString &sSet) override
sal_Int32 SAL_CALL getColor() override
void SAL_CALL Delete(const css::uno::Any &bDeleteContents) override
OUString getServiceImplName() override
css::uno::Sequence< OUString > getServiceNames() override
void SAL_CALL setAppearance(sal_Int32 nSet) override
sal_Int32 SAL_CALL getDateStorageFormat() override
void SAL_CALL setDateCalendarType(sal_Int32 nSet) override
OUString SAL_CALL getID() override
SwVbaContentControl(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::text::XTextDocument > &xTextDocument, std::shared_ptr< SwContentControl > pContentControl)
Content controls are the modern version of FormFields, providing inline functionality similar to that...
sal_Bool SAL_CALL getShowingPlaceholderText() override
void SAL_CALL SetPlaceholderText(const css::uno::Any &BuildingBlock, const css::uno::Any &Range, const css::uno::Any &sText) override
css::uno::Any SAL_CALL getDropdownListEntries() override
sal_Bool SAL_CALL getTemporary() override
OUString SAL_CALL getPlaceholderText() override
void SAL_CALL setDateStorageFormat(sal_Int32 nSet) override
sal_Int32 SAL_CALL getType() override
void SAL_CALL setLockContents(sal_Bool bSet) override
void SAL_CALL Ungroup() override
sal_Int32 SAL_CALL getDateCalendarType() override
OUString SAL_CALL getTag() override
void SAL_CALL setChecked(sal_Bool bSet) override
sal_Int32 SAL_CALL getBuildingBlockType() override
sal_Bool SAL_CALL getMultiLine() override
void SAL_CALL setBuildingBlockCategory(const OUString &sSet) override
void SAL_CALL setType(sal_Int32 nSet) override
void SAL_CALL setTitle(const OUString &rSet) override
void SAL_CALL Cut() override
sal_Bool SAL_CALL getLockContentControl() override
void SAL_CALL setTag(const OUString &rSet) override
void SAL_CALL Copy() override
void SAL_CALL SetCheckedSymbol(sal_Int32 Character, const css::uno::Any &sFont) override
sal_Int32 SAL_CALL getAppearance() override
sal_Bool SAL_CALL getAllowInsertDeleteSection() override
void SAL_CALL setRepeatingSectionItemTitle(const OUString &rSet) override
sal_Int32 SAL_CALL getDateDisplayLocale() override
css::uno::Reference< ooo::vba::word::XRange > SAL_CALL getRange() override
void SAL_CALL setLockContentControl(sal_Bool bSet) override
OUString SAL_CALL getBuildingBlockCategory() override
sal_Bool SAL_CALL getChecked() override
css::uno::Reference< css::text::XTextDocument > mxTextDocument
void SAL_CALL setTemporary(sal_Bool bSet) override
sal_Bool SAL_CALL getLockContents() override
void SAL_CALL setAllowInsertDeleteSection(sal_Bool bSet) override
static rtl::Reference< SwXTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1221
constexpr OUStringLiteral sColor
Sequence< OUString > aServiceNames
DocumentType eType
SwContentControlType
#define SAL_INFO_IF(condition, area, stream)
#define SAL_INFO(area, stream)
static SfxItemSet & rSet
Marks a position in the document model.
Definition: pam.hxx:38
bool hasValue()
#define SAL_MAX_UINT16
unsigned char sal_Bool
sal_uInt16 sal_Unicode