tdf#131542 EMF+ Implement BeginContainer record

Change-Id: If388ef4544001fb9064aed3ce979c2790ab0645f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90997
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index c8e0d07..7ec2b16 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -98,6 +98,7 @@ namespace emfplushelper
            case EmfPlusRecordTypeSetCompositingQuality: return "EmfPlusRecordTypeSetCompositingQuality";
            case EmfPlusRecordTypeSave: return "EmfPlusRecordTypeSave";
            case EmfPlusRecordTypeRestore: return "EmfPlusRecordTypeRestore";
            case EmfPlusRecordTypeBeginContainer: return "EmfPlusRecordTypeBeginContainer";
            case EmfPlusRecordTypeBeginContainerNoParams: return "EmfPlusRecordTypeBeginContainerNoParams";
            case EmfPlusRecordTypeEndContainer: return "EmfPlusRecordTypeEndContainer";
            case EmfPlusRecordTypeSetWorldTransform: return "EmfPlusRecordTypeSetWorldTransform";
@@ -234,7 +235,7 @@ namespace emfplushelper
                return 1.0f;

            case UnitTypePoint:
                return Application::GetDefaultDevice()->GetDPIX() / 72;
                return Application::GetDefaultDevice()->GetDPIX() / 72.0;

            case UnitTypeInch:
                return Application::GetDefaultDevice()->GetDPIX();
@@ -243,7 +244,7 @@ namespace emfplushelper
                return Application::GetDefaultDevice()->GetDPIX() / 25.4;

            case UnitTypeDocument:
                return Application::GetDefaultDevice()->GetDPIX() / 300;
                return Application::GetDefaultDevice()->GetDPIX() / 300.0;

            case UnitTypeWorld:
            case UnitTypeDisplay:
@@ -1773,6 +1774,34 @@ namespace emfplushelper
                        GraphicStatePop(mGSStack, stackIndex, mrPropertyHolders.Current());
                        break;
                    }
                    case EmfPlusRecordTypeBeginContainer:
                    {
                        float dx, dy, dw, dh;
                        ReadRectangle(rMS, dx, dy, dw, dh);
                        SAL_INFO("drawinglayer", "EMF+\t Dest RectData: " << dx << "," << dy << " " << dw << "x" << dh);

                        float sx, sy, sw, sh;
                        ReadRectangle(rMS, sx, sy, sw, sh);
                        SAL_INFO("drawinglayer", "EMF+\t Source RectData: " << sx << "," << sy << " " << sw << "x" << sh);

                        sal_uInt32 stackIndex;
                        rMS.ReadUInt32(stackIndex);
                        SAL_INFO("drawinglayer", "EMF+\t Begin Container stack index: " << stackIndex << ", PageUnit: " << flags);

                        if ((flags == UnitTypeDisplay) || (flags == UnitTypeWorld))
                        {
                            SAL_WARN("drawinglayer", "EMF+\t file error. UnitTypeDisplay and UnitTypeWorld are not supported by BeginContainer in EMF+ specification.");
                            break;
                        }
                        const float aPageScale = getUnitToPixelMultiplier(static_cast<UnitType>(flags));
                        GraphicStatePush(mGSContainerStack, stackIndex);
                        const basegfx::B2DHomMatrix transform = basegfx::utils::createScaleTranslateB2DHomMatrix(
                            aPageScale * ( dw / sw ), aPageScale * ( dh / sh ),
                            aPageScale * ( dx - sx ), aPageScale * ( dy - sy) );
                        maWorldTransform *= transform;
                        mappingChanged();
                        break;
                    }
                    case EmfPlusRecordTypeBeginContainerNoParams:
                    {
                        sal_uInt32 stackIndex;
diff --git a/drawinglayer/source/tools/emfphelperdata.hxx b/drawinglayer/source/tools/emfphelperdata.hxx
index 76e4b65..de85f2f 100644
--- a/drawinglayer/source/tools/emfphelperdata.hxx
+++ b/drawinglayer/source/tools/emfphelperdata.hxx
@@ -71,7 +71,7 @@ namespace emfplushelper
    #define EmfPlusRecordTypeSetCompositingQuality 0x4024
    #define EmfPlusRecordTypeSave 0x4025
    #define EmfPlusRecordTypeRestore 0x4026
    //TODO EmfPlusRecordTypeBeginContainer 0x4027
    #define EmfPlusRecordTypeBeginContainer 0x4027
    #define EmfPlusRecordTypeBeginContainerNoParams 0x4028
    #define EmfPlusRecordTypeEndContainer 0x4029
    #define EmfPlusRecordTypeSetWorldTransform 0x402A