22#include <com/sun/star/awt/XControlModel.hpp>
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/container/XIndexContainer.hpp>
25#include <com/sun/star/container/XNamed.hpp>
26#include <com/sun/star/drawing/XControlShape.hpp>
27#include <com/sun/star/drawing/XDrawPage.hpp>
28#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
29#include <com/sun/star/form/XForm.hpp>
30#include <com/sun/star/form/XFormComponent.hpp>
31#include <com/sun/star/form/XFormsSupplier.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <com/sun/star/text/TextContentAnchorType.hpp>
34#include <com/sun/star/text/VertOrientation.hpp>
35#include <com/sun/star/uno/Any.hxx>
71 if (xDrawPageSupplier.is())
72 rDrawPage = xDrawPageSupplier->getDrawPage();
80 if (! rServiceFactory.is())
81 rServiceFactory.set(rTextDocument, uno::UNO_QUERY);
83 return rServiceFactory;
92 if (xFormsSupplier.is())
95 static constexpr OUStringLiteral sDOCXForm =
u"DOCX-Standard";
97 OUString sFormName(sDOCXForm);
98 sal_uInt16 nUnique = 0;
100 while (xFormsNamedContainer->hasByName(sFormName))
103 sFormName = sDOCXForm + OUString::number(nUnique);
110 xFormProperties(xForm, uno::UNO_QUERY);
112 xFormProperties->setPropertyValue(
"Name", aAny);
115 rForm.set(xForm, uno::UNO_QUERY);
119 xForms->insertByIndex(xForms->getCount(), aAny);
130 return xIndexContainer;
139 m_pImpl->rTextDocument = xTextDocument;
147 const OUString & rControlName)
152 xServiceFactory(
m_pImpl->getServiceFactory());
154 if (! xServiceFactory.is())
159 if (!xInterface.is())
162 m_pImpl->rFormComponent.set(xInterface, uno::UNO_QUERY);
163 if (!
m_pImpl->rFormComponent.is())
168 sal_uInt32 nCheckBoxHeight = 16 *
m_pFFData->getCheckboxHeight();
176 float fCheckBoxHeight = 0.0;
177 xTextRangeProps->getPropertyValue(
"CharHeight") >>= fCheckBoxHeight;
178 nCheckBoxHeight =
static_cast<sal_uInt32
>(floor(fCheckBoxHeight * 35.3));
180 catch (beans::UnknownPropertyException &)
185 m_pImpl->aSize.Width = nCheckBoxHeight;
188 if (!
m_pFFData->getStatusText().isEmpty())
193 xPropSet->setPropertyValue(
"DefaultState",
uno::Any(
m_pFFData->getCheckboxChecked()));
200 xPropSet->setPropertyValue(
"Name",
uno::Any(rControlName));
223 if ( !(
m_pFFData && xNamed.is() && xNameCont.is()) )
226 OUString sTmp =
m_pFFData->getEntryMacro();
227 if ( !sTmp.isEmpty() )
228 xNameCont->insertByName(
"EntryMacro",
uno::Any(sTmp) );
230 if ( !sTmp.isEmpty() )
231 xNameCont->insertByName(
"ExitMacro",
uno::Any(sTmp) );
234 if ( !sTmp.isEmpty() )
235 xNameCont->insertByName(
"Help",
uno::Any(sTmp) );
238 if ( !sTmp.isEmpty() )
239 xNameCont->insertByName(
"Hint",
uno::Any(sTmp) );
246 if ( !sTmp.isEmpty() )
247 xNamed->setName( sTmp );
249 catch ( uno::Exception& )
255 if ( !sTmp.isEmpty() )
256 xNameCont->insertByName(
"Type",
uno::Any(sTmp) );
258 const sal_uInt16 nMaxLength =
m_pFFData->getTextMaxLength();
261 xNameCont->insertByName(
"MaxLength",
uno::Any(nMaxLength) );
265 if ( !sTmp.isEmpty() )
266 xNameCont->insertByName(
"Content",
uno::Any(sTmp) );
269 if ( !sTmp.isEmpty() )
270 xNameCont->insertByName(
"Format",
uno::Any(sTmp) );
276 aAny <<=
m_pFFData->getCheckboxChecked();
278 xPropSet->setPropertyValue(
"Checked", aAny);
283 if (!rEntries.empty())
290 sal_Int32 nResult =
m_pFFData->getDropDownResult().toInt32();
305 bool bCreated =
false;
310 if (! xFormComps.is())
313 sal_Int32 nControl = 0;
315 OUString sControlName;
319 OUString sTmp =
"Control" + OUString::number(nControl);
322 if (! xFormCompsByName->hasByName(sTmp))
343 xFormComps->insertByIndex(xFormComps->getCount(), aAny);
345 if (!
m_pImpl->getServiceFactory().is())
350 if (! xInterface.is())
358 xShape->setSize(
m_pImpl->aSize);
362 sal_uInt16 nTmp = sal_uInt16(text::TextContentAnchorType_AS_CHARACTER);
363 xShapeProps->setPropertyValue(
"AnchorType",
uno::Any(sal_uInt16(nTmp)));
365 nTmp = text::VertOrientation::CENTER;
366 xShapeProps->setPropertyValue(
"VertOrient",
uno::Any(sal_uInt16(nTmp)));
368 xShapeProps->setPropertyValue(
"TextRange",
uno::Any(xTextRange));
372 xControlShape->setControl(xControlModel);
374 m_pImpl->getDrawPage()->add(xShape);
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
::std::vector< OUString > DropDownEntries_t
#define TOOLS_INFO_EXCEPTION(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr OUStringLiteral ODF_FORMTEXT
constexpr OUStringLiteral ODF_FORMDROPDOWN_RESULT
constexpr OUStringLiteral ODF_FORMDROPDOWN_LISTENTRY
constexpr OUStringLiteral ODF_FORMCHECKBOX
constexpr OUStringLiteral ODF_FORMDROPDOWN