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 #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_SDTHELPER_HXX
11 #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_SDTHELPER_HXX
15 #include <com/sun/star/beans/PropertyValue.hpp>
16 #include <com/sun/star/text/XTextRange.hpp>
18 #include <rtl/ustrbuf.hxx>
19 #include <tools/ref.hxx>
36 namespace writerfilter
40 class DomainMapper_Impl
;
43 * Helper to create form controls from w:sdt tokens.
45 * w:sdt tokens can't be imported as form fields, as w:sdt supports
46 * e.g. date picking as well.
48 class SdtHelper final
: public virtual SvRefBase
50 DomainMapper_Impl
& m_rDM_Impl
;
52 /// Items of the drop-down control.
53 std::vector
<OUString
> m_aDropDownItems
;
54 /// Indicator of a drop-down control
55 bool m_bInsideDropDownControl
;
56 /// Pieces of the default text -- currently used only by the dropdown control.
57 OUStringBuffer m_aSdtTexts
;
58 /// Date ISO string contained in the w:date element, used by the date control.
59 OUStringBuffer m_sDate
;
60 /// Date format string as it comes from the ooxml document.
61 OUStringBuffer m_sDateFormat
;
62 /// Start range of the date field
63 css::uno::Reference
<css::text::XTextRange
> m_xDateFieldStartRange
;
64 /// Locale string as it comes from the ooxml document.
65 OUStringBuffer m_sLocale
;
66 /// Grab bag to store unsupported SDTs, aiming to save them back on export.
67 std::vector
<css::beans::PropertyValue
> m_aGrabBag
;
70 /// The last stored SDT element is outside paragraphs.
71 bool m_bOutsideAParagraph
;
73 /// Create and append the drawing::XControlShape, containing the various models.
74 void createControlShape(css::awt::Size aSize
, css::uno::Reference
<css::awt::XControlModel
> const& xControlModel
, const css::uno::Sequence
<css::beans::PropertyValue
>& rGrabBag
);
76 explicit SdtHelper(DomainMapper_Impl
& rDM_Impl
);
77 ~SdtHelper() override
;
79 std::vector
<OUString
>& getDropDownItems()
81 return m_aDropDownItems
;
83 OUStringBuffer
& getSdtTexts()
88 OUStringBuffer
& getDate()
93 OUStringBuffer
& getDateFormat()
98 void setDateFieldStartRange(const css::uno::Reference
<css::text::XTextRange
>& xStartRange
)
100 m_xDateFieldStartRange
= xStartRange
;
103 /// Decides if we have enough information to create a date control.
104 bool validateDateFormat();
106 OUStringBuffer
& getLocale()
110 /// If createControlShape() was ever called.
113 return m_bHasElements
;
116 void setOutsideAParagraph(bool bOutsideAParagraph
)
118 m_bOutsideAParagraph
= bOutsideAParagraph
;
121 bool isOutsideAParagraph()
123 return m_bOutsideAParagraph
;
126 bool isInsideDropDownControl() const { return m_bInsideDropDownControl
; }
127 void setInsideDropDownControl(bool bInside
) { m_bInsideDropDownControl
= bInside
; }
129 /// Create drop-down control from w:sdt's w:dropDownList.
130 void createDropDownControl();
131 /// Create date control from w:sdt's w:date.
132 void createDateContentControl();
134 void appendToInteropGrabBag(const css::beans::PropertyValue
& rValue
);
135 css::uno::Sequence
<css::beans::PropertyValue
> getInteropGrabBagAndClear();
136 bool isInteropGrabBagEmpty();
137 bool containedInInteropGrabBag(const OUString
& rValueName
);
138 sal_Int32
getInteropGrabBagSize();
141 } // namespace dmapper
142 } // namespace writerfilter
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */