summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/textfld.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/shells/textfld.cxx')
-rw-r--r--sw/source/uibase/shells/textfld.cxx30
1 files changed, 19 insertions, 11 deletions
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index be599349a86f..8af1da077698 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -733,17 +733,25 @@ FIELD_INSERT:
SwPaM* pCursorPos = rSh.GetCursor();
if(pCursorPos)
{
- IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
- sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDATE);
-
- // Use a default date format and language
- sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldBM->GetParameters();
- SvNumberFormatter* pFormatter = rSh.GetDoc()->GetNumberFormatter();
- sal_uInt32 nStandardFormat = pFormatter->GetStandardFormat(css::util::NumberFormat::DATE);
- const SvNumberformat* pFormat = pFormatter->GetEntry(nStandardFormat);
-
- (*pParameters)[ODF_FORMDATE_DATEFORMAT] <<= pFormat->GetFormatstring();
- (*pParameters)[ODF_FORMDATE_DATEFORMAT_LANGUAGE] <<= LanguageTag(pFormat->GetLanguage()).getBcp47();
+ // Insert five enspaces into the text field so the field has extent
+ sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
+ bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH));
+ if(bSuccess)
+ {
+ IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+ SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()-5,
+ pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex());
+ sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMDATE);
+
+ // Use a default date format and language
+ sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldBM->GetParameters();
+ SvNumberFormatter* pFormatter = rSh.GetDoc()->GetNumberFormatter();
+ sal_uInt32 nStandardFormat = pFormatter->GetStandardFormat(css::util::NumberFormat::DATE);
+ const SvNumberformat* pFormat = pFormatter->GetEntry(nStandardFormat);
+
+ (*pParameters)[ODF_FORMDATE_DATEFORMAT] <<= pFormat->GetFormatstring();
+ (*pParameters)[ODF_FORMDATE_DATEFORMAT_LANGUAGE] <<= LanguageTag(pFormat->GetLanguage()).getBcp47();
+ }
}
rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr);