hwpfilter/source/hwpreader.cxx                       |   64 ++++---------------
 sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx |binary
 sw/source/core/unocore/unodraw.cxx                   |    2 
 3 files changed, 17 insertions(+), 49 deletions(-)

New commits:
commit 03b30fada578923e9c34b1824d293e719a2caa5e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Feb 17 09:57:34 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 17 21:43:46 2022 +0100

    Refetch in case SwTextNode::InsertItem causes it to be deleted
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130087
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 3dab7bc9dd8763d68fc2e6496e8069c7823685c2)
    
    Change-Id: Ie189ae4d37ffc33e58bb405f2521d1ae02a9997b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130112
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx 
b/sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx
new file mode 100755
index 000000000000..add554ae9596
Binary files /dev/null and 
b/sw/qa/core/data/ooxml/fail/LIBREOFFICE-DBDAZAEC.docx differ
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index fed0e4a55d6a..1d7cc5fea594 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1147,6 +1147,8 @@ void SwXShape::setPropertyValue(const OUString& 
rPropertyName, const uno::Any& a
                         SwFormatFlyCnt aFormat( pFormat );
                         pNd->InsertItem(aFormat, pInternalPam->GetPoint()
                                 ->nContent.GetIndex(), 0 );
+                        //Refetch in case SwTextNode::InsertItem causes it to 
be deleted
+                        pFormat = GetFrameFormat();
                     }
                     else
                     {
commit 205003bb76d6ceb49a07bbbecb0080b4a139c97b
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Jan 28 15:02:54 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 17 21:43:33 2022 +0100

    avoid dangling tmp files in hwp import
    
    if there is embedded data use office-binary-data to transport it
    instead of a temp file
    
    https: //issues.oasis-open.org/browse/OFFICE-3933
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129076
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit e95d5d5666505cb05e9660f24f6c7ae039451ef8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129759
    (cherry picked from commit bfff5c7dadf9628926fbb5cd0394fcfc4464eb0b)
    
    Change-Id: Ia1cebf0770c99210df09f03dbb507451d9cf7764
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130082
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 4144d20e0bde..5dccd3b7b7b2 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -515,62 +515,28 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
             if( prop->flag >> 18  & 0x01 )
             {
                 padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, 
"fillimage%d", buf)));
-                if( !prop->pictype )
+
+                EmPicture *emp = nullptr;
+                if (prop->pictype && strlen(prop->szPatternFile) > 3)
+                    emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
+                if (!emp)
                 {
                     padd( "xlink:href", sXML_CDATA,
                         reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr( 
reinterpret_cast<uchar const 
*>(urltounix(prop->szPatternFile).c_str())).c_str())));
+                    padd( "xlink:type", sXML_CDATA, "simple");
+                    padd( "xlink:show", sXML_CDATA, "embed");
+                    padd( "xlink:actuate", sXML_CDATA, "onLoad");
                 }
-                else
-                {
-                    EmPicture *emp = nullptr;
-                    if ( strlen( prop->szPatternFile ) > 3)
-                        emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
-                    if( emp )
-                    {
-                        char filename[128+17+9];
-                        char dirname[128];
-                        int fd;
-#ifdef _WIN32
-                        GetTempPathA(sizeof(dirname), dirname);
-                        sprintf(filename, "%s%s",dirname, emp->name);
-                        if( (fd = open( filename , _O_CREAT | _O_WRONLY | 
_O_BINARY , 0666)) >= 0 )
-#else
-                        strcpy(dirname, "/tmp/");
-                        sprintf(filename, "%s%s", dirname, emp->name);
-                        if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) 
>= 0 )
-#endif
-                        {
-                            size_t nWritten = write(fd, emp->data.get(), 
emp->size);
-                            OSL_VERIFY(nWritten == emp->size);
-                            close(fd);
-                        }
-#ifdef _WIN32
-                        int j;
-                        for(j = 0 ; j < static_cast<int>(strlen( dirname )) ; 
j++)
-                        {
-                            if( dirname[j] == '\\' ) buf[j] = '/';
-                            else buf[j] = dirname[j];
-                        }
-                        buf[j] = '\0';
-                        sprintf(filename, "file:///%s%s",buf, emp->name );
-#else
-                        sprintf(filename, "file://%s%s",dirname, emp->name );
-#endif
-                        padd( "xlink:href", sXML_CDATA, ascii(filename));
-                    }
-                    else
-                    {
-                        padd( "xlink:href", sXML_CDATA,
-                            reinterpret_cast<sal_Unicode const 
*>(hconv(kstr2hstr( reinterpret_cast<uchar const 
*>(urltounix(prop->szPatternFile).c_str())).c_str())));
-                    }
-
-                }
-                padd( "xlink:type", sXML_CDATA, "simple");
-                padd( "xlink:show", sXML_CDATA, "embed");
-                padd( "xlink:actuate", sXML_CDATA, "onLoad");
 
                 rstartEl( "draw:fill-image", mxList.get());
                 mxList->clear();
+                if (emp)
+                {
+                    rstartEl("office:binary-data", mxList.get());
+                    std::shared_ptr<char> 
pStr(base64_encode_string(emp->data.get(), emp->size), Free<char>());
+                    rchars(ascii(pStr.get()));
+                    rendEl("office:binary-data");
+                }
                 rendEl( "draw:fill-image");
             }
 /*  If there is a gradient, when a bitmap file is present, this is the first. 
*/

Reply via email to