1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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>
15 #include <sal/log.hxx>
18 #include <unotextrange.hxx>
20 #include "vbacontentcontrol.hxx"
21 #include "vbacontentcontrollistentries.hxx"
22 #include "vbarange.hxx"
24 using namespace ::ooo::vba
;
25 using namespace ::com::sun::star
;
28 * Content controls are the modern version of FormFields, providing inline functionality similar
29 * to that of ActiveX form controls. Individual content controls may contain contents
30 * such as dates, lists, or paragraphs of formatted text.
32 * Not all functions are applicable to each type of control, so use getType verification liberally.
34 SwVbaContentControl::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
)
42 assert(m_pCC
&& "SwVbaContentControl created without a shared_ptr. Why would you do that?");
45 SwVbaContentControl::~SwVbaContentControl() {}
47 sal_Bool
SwVbaContentControl::getAllowInsertDeleteSection()
49 SAL_INFO("sw.vba", "SwVbaContentControl::getAllowInsertDeleteSection stub");
53 void SwVbaContentControl::setAllowInsertDeleteSection(sal_Bool
/*bSet*/)
55 SAL_INFO("sw.vba", "SwVbaContentControl::setAllowInsertDeleteSection stub");
58 sal_Int32
SwVbaContentControl::getAppearance()
60 SAL_INFO("sw.vba", "SwVbaContentControl::getAppearance stub");
61 // wdContentControlBoundingBox / wdContentControlHidden / wdContentControlTags
65 void SwVbaContentControl::setAppearance(sal_Int32 nSet
)
67 SAL_INFO("sw.vba", "SwVbaContentControl::setAppearance[" << nSet
<< "] stub");
70 OUString
SwVbaContentControl::getBuildingBlockCategory()
72 SAL_INFO("sw.vba", "SwVbaContentControl::getBuildingBlockCategory stub");
76 void SwVbaContentControl::setBuildingBlockCategory(const OUString
& sSet
)
78 SAL_INFO("sw.vba", "SwVbaContentControl::setBuildingBlockCategory[" << sSet
<< "] stub");
81 sal_Int32
SwVbaContentControl::getBuildingBlockType()
83 SAL_INFO("sw.vba", "SwVbaContentControl::getBuildingBlockType stub");
84 // returns a WdBuildingBlockTypes that represents the type of building block
88 void SwVbaContentControl::setBuildingBlockType(sal_Int32 nSet
)
90 SAL_INFO("sw.vba", "SwVbaContentControl::setBuildingBlockType[" << nSet
<< "] stub");
93 sal_Bool
SwVbaContentControl::getChecked() { return m_pCC
->GetCheckbox() && m_pCC
->GetChecked(); }
95 void SwVbaContentControl::setChecked(sal_Bool bSet
)
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())
104 if (m_pCC
->GetCheckbox() && m_pCC
->GetChecked() != static_cast<bool>(bSet
))
106 m_pCC
->SetChecked(bSet
);
107 m_pCC
->SetShowingPlaceHolder(false);
108 if (m_pCC
->GetTextAttr())
109 m_pCC
->GetTextAttr()->Invalidate();
113 sal_Int32
SwVbaContentControl::getColor()
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
;
236 return word::WdColor::wdColorBlack
;
239 void SwVbaContentControl::setColor(sal_Int32 nWdColor
)
243 case word::WdColor::wdColorAqua
:
244 m_pCC
->SetColor("wdColorAqua");
246 case word::WdColor::wdColorAutomatic
:
247 m_pCC
->SetColor("wdColorAutomatic");
249 case word::WdColor::wdColorBlack
:
250 m_pCC
->SetColor("wdColorBlack");
252 case word::WdColor::wdColorBlue
:
253 m_pCC
->SetColor("wdColorBlue");
255 case word::WdColor::wdColorBlueGray
:
256 m_pCC
->SetColor("wdColorBlueGray");
258 case word::WdColor::wdColorBrightGreen
:
259 m_pCC
->SetColor("wdColorBrightGreen");
261 case word::WdColor::wdColorBrown
:
262 m_pCC
->SetColor("wdColorBrown");
264 case word::WdColor::wdColorDarkBlue
:
265 m_pCC
->SetColor("wdColorDarkBlue");
267 case word::WdColor::wdColorDarkGreen
:
268 m_pCC
->SetColor("wdColorDarkGreen");
270 case word::WdColor::wdColorDarkRed
:
271 m_pCC
->SetColor("wdColorDarkRed");
273 case word::WdColor::wdColorDarkTeal
:
274 m_pCC
->SetColor("wdColorDarkTeal");
276 case word::WdColor::wdColorDarkYellow
:
277 m_pCC
->SetColor("wdColorDarkYellow");
279 case word::WdColor::wdColorGold
:
280 m_pCC
->SetColor("wdColorGold");
282 case word::WdColor::wdColorGray05
:
283 m_pCC
->SetColor("wdColorGray05");
285 case word::WdColor::wdColorGray10
:
286 m_pCC
->SetColor("wdColorGray10");
288 case word::WdColor::wdColorGray125
:
289 m_pCC
->SetColor("wdColorGray125");
291 case word::WdColor::wdColorGray15
:
292 m_pCC
->SetColor("wdColorGray15");
294 case word::WdColor::wdColorGray20
:
295 m_pCC
->SetColor("wdColorGray20");
297 case word::WdColor::wdColorGray25
:
298 m_pCC
->SetColor("wdColorGray25");
300 case word::WdColor::wdColorGray30
:
301 m_pCC
->SetColor("wdColorGray30");
303 case word::WdColor::wdColorGray35
:
304 m_pCC
->SetColor("wdColorGray35");
306 case word::WdColor::wdColorGray375
:
307 m_pCC
->SetColor("wdColorGray375");
309 case word::WdColor::wdColorGray40
:
310 m_pCC
->SetColor("wdColorGray40");
312 case word::WdColor::wdColorGray45
:
313 m_pCC
->SetColor("wdColorGray45");
315 case word::WdColor::wdColorGray50
:
316 m_pCC
->SetColor("wdColorGray50");
318 case word::WdColor::wdColorGray55
:
319 m_pCC
->SetColor("wdColorGray55");
321 case word::WdColor::wdColorGray60
:
322 m_pCC
->SetColor("wdColorGray60");
324 case word::WdColor::wdColorGray625
:
325 m_pCC
->SetColor("wdColorGray625");
327 case word::WdColor::wdColorGray65
:
328 m_pCC
->SetColor("wdColorGray65");
330 case word::WdColor::wdColorGray70
:
331 m_pCC
->SetColor("wdColorGray70");
333 case word::WdColor::wdColorGray75
:
334 m_pCC
->SetColor("wdColorGray75");
336 case word::WdColor::wdColorGray80
:
337 m_pCC
->SetColor("wdColorGray80");
339 case word::WdColor::wdColorGray85
:
340 m_pCC
->SetColor("wdColorGray85");
342 case word::WdColor::wdColorGray875
:
343 m_pCC
->SetColor("wdColorGray875");
345 case word::WdColor::wdColorGray90
:
346 m_pCC
->SetColor("wdColorGray90");
348 case word::WdColor::wdColorGray95
:
349 m_pCC
->SetColor("wdColorGray95");
351 case word::WdColor::wdColorGreen
:
352 m_pCC
->SetColor("wdColorGreen");
354 case word::WdColor::wdColorIndigo
:
355 m_pCC
->SetColor("wdColorIndigo");
357 case word::WdColor::wdColorLavender
:
358 m_pCC
->SetColor("wdColorLavender");
360 case word::WdColor::wdColorLightBlue
:
361 m_pCC
->SetColor("wdColorLightBlue");
363 case word::WdColor::wdColorLightGreen
:
364 m_pCC
->SetColor("wdColorLightGreen");
366 case word::WdColor::wdColorLightOrange
:
367 m_pCC
->SetColor("wdColorLightOrange");
369 case word::WdColor::wdColorLightTurquoise
:
370 m_pCC
->SetColor("wdColorLightTurquoise");
372 case word::WdColor::wdColorLightYellow
:
373 m_pCC
->SetColor("wdColorLightYellow");
375 case word::WdColor::wdColorLime
:
376 m_pCC
->SetColor("wdColorLime");
378 case word::WdColor::wdColorOliveGreen
:
379 m_pCC
->SetColor("wdColorOliveGreen");
381 case word::WdColor::wdColorOrange
:
382 m_pCC
->SetColor("wdColorOrange");
384 case word::WdColor::wdColorPaleBlue
:
385 m_pCC
->SetColor("wdColorPaleBlue");
387 case word::WdColor::wdColorPink
:
388 m_pCC
->SetColor("wdColorPink");
390 case word::WdColor::wdColorPlum
:
391 m_pCC
->SetColor("wdColorPlum");
393 case word::WdColor::wdColorRed
:
394 m_pCC
->SetColor("wdColorRed");
396 case word::WdColor::wdColorRose
:
397 m_pCC
->SetColor("wdColorRose");
399 case word::WdColor::wdColorSeaGreen
:
400 m_pCC
->SetColor("wdColorSeaGreen");
402 case word::WdColor::wdColorSkyBlue
:
403 m_pCC
->SetColor("wdColorSkyBlue");
405 case word::WdColor::wdColorTan
:
406 m_pCC
->SetColor("wdColorTan");
408 case word::WdColor::wdColorTeal
:
409 m_pCC
->SetColor("wdColorTeal");
411 case word::WdColor::wdColorTurquoise
:
412 m_pCC
->SetColor("wdColorTurquoise");
414 case word::WdColor::wdColorViolet
:
415 m_pCC
->SetColor("wdColorViolet");
417 case word::WdColor::wdColorWhite
:
418 m_pCC
->SetColor("wdColorWhite");
424 sal_Int32
SwVbaContentControl::getDateCalendarType()
426 SAL_INFO("sw.vba", "SwVbaContentControl::getDateCalendarType stub");
427 // returns a WdCalendarTypes that represents the type of building block
428 return word::WdCalendarType::wdCalendarWestern
;
431 void SwVbaContentControl::setDateCalendarType(sal_Int32 nSet
)
433 SAL_INFO("sw.vba", "SwVbaContentControl::setDateCalendarType[" << nSet
<< "] stub");
436 OUString
SwVbaContentControl::getDateDisplayFormat() { return m_pCC
->GetDateFormat(); }
438 void SwVbaContentControl::setDateDisplayFormat(const OUString
& sSet
) { m_pCC
->SetDateFormat(sSet
); }
440 sal_Int32
SwVbaContentControl::getDateStorageFormat()
442 SAL_INFO("sw.vba", "SwVbaContentControl::getDateStorageFormat stub");
443 // returns a WdContentControlDateStorageFormat when bound to the XML data store.
447 void SwVbaContentControl::setDateStorageFormat(sal_Int32 nSet
)
449 SAL_INFO("sw.vba", "SwVbaContentControl::setDateStorageFormat[" << nSet
<< "] stub");
452 sal_Int32
SwVbaContentControl::getDateDisplayLocale()
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
;
459 uno::Any
SwVbaContentControl::getDropdownListEntries()
461 if (!m_pCC
->GetDropDown() && !m_pCC
->GetComboBox())
465 uno::Reference
<XCollection
>(new SwVbaContentControlListEntries(this, mxContext
, m_pCC
)));
468 OUString
SwVbaContentControl::getID()
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()));
474 sal_Int32
SwVbaContentControl::getLevel()
476 SAL_INFO("sw.vba", "SwVbaContentControl::getLevel stub");
477 // returns a WdContentControlLevel
481 sal_Bool
SwVbaContentControl::getLockContentControl()
483 std::optional
<bool> oLock
= m_pCC
->GetLock(/*bControl=*/true);
484 return oLock
&& *oLock
;
487 void SwVbaContentControl::setLockContentControl(sal_Bool bSet
)
489 std::optional
<bool> oLock
= m_pCC
->GetLock(/*bControl=*/false);
490 m_pCC
->SetLock(/*bContents=*/oLock
&& *oLock
, /*bControl=*/bSet
);
493 sal_Bool
SwVbaContentControl::getLockContents()
495 // If the theoretical design model says it is locked, then report as locked.
496 std::optional
<bool> oLock
= m_pCC
->GetLock(/*bControl=*/false);
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
503 || m_pCC
->GetType() == SwContentControlType::DROP_DOWN_LIST
504 || m_pCC
->GetType() == SwContentControlType::PICTURE
)
509 return m_pCC
->GetReadWrite();
512 void SwVbaContentControl::setLockContents(sal_Bool bSet
)
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
);
518 // Checkbox/DropDown/Picture are normally locked in LO implementation - don't unlock them.
519 if (m_pCC
->GetType() == SwContentControlType::CHECKBOX
520 || m_pCC
->GetType() == SwContentControlType::DROP_DOWN_LIST
521 || m_pCC
->GetType() == SwContentControlType::PICTURE
)
525 m_pCC
->SetReadWrite(bSet
);
528 sal_Bool
SwVbaContentControl::getMultiLine()
530 SAL_INFO("sw.vba", "SwVbaContentControl::getMultiLine stub");
534 void SwVbaContentControl::setMultiLine(sal_Bool
/*bSet*/)
536 SAL_INFO("sw.vba", "SwVbaContentControl::setMultiLine stub");
539 OUString
SwVbaContentControl::getPlaceholderText()
541 // return m_pCC->GetPlaceholderDocPart(); // This is not correct. Much more complex than this...
542 SAL_INFO("sw.vba", "SwVbaContentControl::getPlaceholderText stub");
546 sal_Bool
SwVbaContentControl::getShowingPlaceholderText() { return m_pCC
->GetShowingPlaceHolder(); }
548 uno::Reference
<word::XRange
> SwVbaContentControl::getRange()
550 uno::Reference
<word::XRange
> xRet
;
551 SwTextNode
* pTextNode
= m_pCC
->GetTextNode();
552 if (pTextNode
&& m_pCC
->GetTextAttr())
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
));
561 xRet
= new SwVbaRange(mxParent
, mxContext
, mxTextDocument
, xText
->getStart(),
567 OUString
SwVbaContentControl::getRepeatingSectionItemTitle()
569 SAL_INFO("sw.vba", "SwVbaContentControl::getRepeatingSectionItemTitle stub");
573 void SwVbaContentControl::setRepeatingSectionItemTitle(const OUString
& rSet
)
575 SAL_INFO("sw.vba", "SwVbaContentControl::setRepeatingSectionItemTitle[" << rSet
<< "] stub");
578 OUString
SwVbaContentControl::getTag() { return m_pCC
->GetTag(); }
580 void SwVbaContentControl::setTag(const OUString
& rSet
) { return m_pCC
->SetTag(rSet
); }
582 sal_Bool
SwVbaContentControl::getTemporary()
584 SAL_INFO("sw.vba", "SwVbaContentControl::getTemporary stub");
585 // Is content control removed when user edits (one time use)? Not implemented in LO.
589 void SwVbaContentControl::setTemporary(sal_Bool
/*bSet*/)
591 SAL_INFO("sw.vba", "SwVbaContentControl::setTemporary stub");
594 OUString
SwVbaContentControl::getTitle() { return m_pCC
->GetAlias(); }
596 void SwVbaContentControl::setTitle(const OUString
& rSet
) { return m_pCC
->SetAlias(rSet
); }
598 sal_Int32
SwVbaContentControl::getType()
600 SwContentControlType eType
= m_pCC
->GetType();
601 sal_Int32 eVbaType
= word::WdContentControlType::wdContentControlRichText
;
605 case SwContentControlType::CHECKBOX
:
606 eVbaType
= word::WdContentControlType::wdContentControlCheckbox
;
608 case SwContentControlType::DROP_DOWN_LIST
:
609 eVbaType
= word::WdContentControlType::wdContentControlDropdownList
;
611 case SwContentControlType::PICTURE
:
612 eVbaType
= word::WdContentControlType::wdContentControlPicture
;
614 case SwContentControlType::DATE
:
615 eVbaType
= word::WdContentControlType::wdContentControlDate
;
617 case SwContentControlType::PLAIN_TEXT
:
618 eVbaType
= word::WdContentControlType::wdContentControlText
;
620 case SwContentControlType::COMBO_BOX
:
621 eVbaType
= word::WdContentControlType::wdContentControlComboBox
;
623 case SwContentControlType::RICH_TEXT
:
629 void SwVbaContentControl::setType(sal_Int32 nSet
)
631 SAL_INFO("sw.vba", "SwVbaContentControl::setType[" << nSet
<< "] stub");
632 // SwContentControlType eType = SwContentControlType::RICH_TEXT;
635 // case word::WdContentControlType::wdContentControlCheckbox:
636 // eType = SwContentControlType::CHECKBOX;
638 // case word::WdContentControlType::wdContentControlDropdownList:
639 // eType = SwContentControlType::DROP_DOWN_LIST;
641 // case word::WdContentControlType::wdContentControlPicture:
642 // eType = SwContentControlType::PICTURE;
644 // case word::WdContentControlType::wdContentControlDate:
645 // eType = SwContentControlType::DATE;
647 // case word::WdContentControlType::wdContentControlText:
648 // eType = SwContentControlType::PLAIN_TEXT;
650 // case word::WdContentControlType::wdContentControlComboBox:
651 // eType = SwContentControlType::COMBO_BOX;
653 // case word::WdContentControlType::wdContentControlRichText:
656 // m_pCC->SetType(eType);
659 void SwVbaContentControl::Copy()
661 SAL_INFO("sw.vba", "SwVbaContentControl::Copy[" << getID() << "] stub");
664 void SwVbaContentControl::Cut()
666 if (getLockContentControl() || !m_pCC
->GetTextAttr())
670 "SwVbaContentControl::Cut[" << getID() << "], but missing sending to clipboard");
672 m_pCC
->GetTextAttr()->Delete(/*bSaveContents=*/getLockContents());
675 void SwVbaContentControl::Delete(const uno::Any
& DeleteContents
)
677 if (getLockContentControl() || !m_pCC
->GetTextAttr())
680 bool bDeleteContents
= false;
681 DeleteContents
>>= bDeleteContents
;
683 m_pCC
->GetTextAttr()->Delete(/*bSaveContents=*/!bDeleteContents
|| getLockContents());
686 void SwVbaContentControl::SetCheckedSymbol(sal_Int32 Character
, const uno::Any
& Font
)
688 if (!m_pCC
->GetTextAttr())
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?
695 m_pCC
->SetCheckedState(OUString(static_cast<sal_Unicode
>(Character
)));
697 if (m_pCC
->GetCheckbox() && m_pCC
->GetChecked() && !m_pCC
->GetShowingPlaceHolder())
698 m_pCC
->GetTextAttr()->Invalidate();
701 void SwVbaContentControl::SetUnCheckedSymbol(sal_Int32 Character
, const uno::Any
& Font
)
703 if (!m_pCC
->GetTextAttr())
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?
710 m_pCC
->SetUncheckedState(OUString(static_cast<sal_Unicode
>(Character
)));
712 if (m_pCC
->GetCheckbox() && !m_pCC
->GetChecked() && !m_pCC
->GetShowingPlaceHolder())
713 m_pCC
->GetTextAttr()->Invalidate();
716 void SwVbaContentControl::SetPlaceholderText(const uno::Any
& BuildingBlock
, const uno::Any
& Range
,
717 const uno::Any
& Text
)
719 SAL_INFO("sw.vba", "SwVbaContentControl::SetPlaceholderText stub");
720 if (BuildingBlock
.hasValue())
722 // Set placeholder text to the building block - whatever that is.
724 else if (Range
.hasValue())
726 // Set placeholder text to the contents of the Range, however you do that.
728 else if (Text
.hasValue())
730 // Set placeholder text to the provided string
734 // Remove placeholder text.
735 m_pCC
->SetPlaceholderDocPart("");
737 if (m_pCC
->GetShowingPlaceHolder() && !getLockContents() && m_pCC
->GetTextAttr())
739 //replace the text and ensure showing placeholder is still set
743 void SwVbaContentControl::Ungroup() { SAL_INFO("sw.vba", "SwVbaContentControl::UnGroup stub"); }
745 OUString
SwVbaContentControl::getServiceImplName() { return "SwVbaContentControl"; }
747 uno::Sequence
<OUString
> SwVbaContentControl::getServiceNames()
749 static uno::Sequence
<OUString
> const aServiceNames
{ "ooo.vba.word.ContentControl" };
750 return aServiceNames
;
753 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */