tdf#152246 Fix RTL content control field position

With this patch, the horizonal position of the content control fields
are corrected. Previously, they were calculated just like the fields in
the LTR paragraphs. To implement this, I've used the
GetTextFrame()->SwitchLTRtoRTL method.

The remaining issue is that The exported fileds in the PDF are still LTR
themselves. For example, the combo box will still be LTR.

It should be pointed that handling vertical text is still an issue that
should be addressed later. If you rotate the paragraph with content
control field, the output does not obey, which is incorrect.

Change-Id: I927d14f9ca90434b4397dcf175dbb9531dda0c7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150515
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 1466e2a58f40c869d8c2590a4479e85c093b3468)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151270
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index ea420b0..ab31c52 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -1064,11 +1064,19 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co
    auto pTextFrame = const_cast<SwTextFrame*>(rInf.GetTextFrame());
    SwTextSizeInfo aInf(pTextFrame);
    SwTextCursor aLine(pTextFrame, &aInf);
    SwRect aStartRect;
    SwRect aStartRect, aEndRect;
    aLine.GetCharRect(&aStartRect, nViewStart);
    aLocation = aStartRect;
    SwRect aEndRect;
    aLine.GetCharRect(&aEndRect, nViewEnd);

    // Handling RTL text direction
    if(rInf.GetTextFrame()->IsRightToLeft())
    {
        rInf.GetTextFrame()->SwitchLTRtoRTL( aStartRect );
        rInf.GetTextFrame()->SwitchLTRtoRTL( aEndRect );
    }
    // TODO: handle rInf.GetTextFrame()->IsVertical()

    aLocation = aStartRect;
    aLocation.Union(aEndRect);
    pDescriptor->Location = aLocation.SVRect();