tdf#125884 Import DOCX Fontwork; only for discussion

Change-Id: I48933ae356f1d70e8041fb53a2681fb70c635d59
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index cd9afdc..a3ae47d 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -10,22 +10,35 @@
#include "WpsContext.hxx"
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/tuple/b2dtuple.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <drawingml/customshapeproperties.hxx>
#include <drawingml/presetgeometrynames.hxx>
#include <drawingml/textbody.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/beans/XPropertyContainer.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
#include <com/sun/star/drawing/HomogenMatrix3.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
#include <svx/svdoashp.hxx>
#include <svx/svdtrans.hxx>
#include <svx/unoshape.hxx>
#include <svx/unoapi.hxx>
#include <oox/helper/attributelist.hxx>
#include <oox/helper/propertymap.hxx>
#include <oox/token/namespaces.hxx>
#include <oox/token/tokens.hxx>
#include <oox/drawingml/shape.hxx>

#include <boost/optional.hpp>

using ::com::sun::star::container::XEnumeration;
using namespace com::sun::star;

namespace oox
@@ -180,10 +193,74 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
                    comphelper::SequenceAsHashMap aCustomShapeGeometry(
                        xPropertySet->getPropertyValue("CustomShapeGeometry"));
                    aCustomShapeGeometry["PresetTextWarp"] <<= preset;
                    // ODF cannot express Warp text in abitrary shapes and LibreOffice cannot
                    // render such shapes. Ignore Warp in those cases and transform only in
                    // case outer shape is a rectangle.
                    OUString sType;
                    aCustomShapeGeometry["Type"] >>= sType;
                    if (preset.isEmpty() || preset == "textNoShape" || sType != "ooxml-rect")
                        break;

                    // Need to backup the text content. Setting property TextBox to false, calls
                    // SwTextBoxHelper::destroy(...) and that destroys box _and_ text.
                    uno::Reference<text::XTextRange> xTextRange(mxShape, uno::UNO_QUERY);
                    OUString sShapeText;
                    if (xTextRange.is())
                        sShapeText = xTextRange->getString(); // all paragraphs, with eol encoded

                    xPropertySet->setPropertyValue("TextBox", uno::Any(false));

                    // Write the text without special content like tables or fields back to the shape.
                    // ToDO: Remove empty paragraph, which is generate by getString();
                    uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY);
                    if (xText.is())
                    {
                        uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
                        if (xTextCursor.is())
                        {
                            xTextCursor->gotoStart(false);
                            xText->insertString(xTextCursor, sShapeText, true);
                        }
                    }
                    // ToDo: Alter size and position to previous inner Text area. Might need to backup
                    // the padding values before destroying the textbox.

                    const OUString sFontworkType(PresetGeometryTypeNames::GetFontworkType(preset));
                    aCustomShapeGeometry["Type"] <<= sFontworkType;
                    uno::Sequence<beans::PropertyValue> aTextpathPropSeq(
                        comphelper::InitPropertySequence(
                            { { "TextPath", uno::Any(true) },
                              { "TextPathMode",
                                uno::Any(drawing::EnhancedCustomShapeTextPathMode_PATH) },
                              { "ScaleX", uno::Any(false) },
                              { "SameLetterHeights", uno::Any(false) } }));
                    aCustomShapeGeometry["TextPath"] <<= aTextpathPropSeq;

                    // will be set by defaults from preset definitions
                    aCustomShapeGeometry.erase("ViewBox");
                    aCustomShapeGeometry.erase("CoordinateSize");
                    aCustomShapeGeometry.erase("Equations");
                    aCustomShapeGeometry.erase("Path");
                    aCustomShapeGeometry.erase("Handles");
                    // might be set by child avLst
                    aCustomShapeGeometry.erase("AdjustmentValues");

                    xPropertySet->setPropertyValue(
                        "CustomShapeGeometry",
                        uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));

                    // ToDo: Remove in final patch
                    uno::Reference<lang::XServiceInfo> xServiceInfo(mxShape, uno::UNO_QUERY);
                    bool bInfo = xServiceInfo->supportsService("com.sun.star.drawing.Text");
                    OUString sInfo;
                    if (bInfo)
                        sInfo = "true";
                    else
                        sInfo = "false";
                    SAL_INFO("oox", "debug " << sInfo);
                }
                // return this; // needed to get avLst read.
                // ToDo: add cases for avLst and its guides.
            }
            break;
        case XML_txbx: