[Libreoffice-commits] core.git: sw/qa sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 14 14:52:25 UTC 2019
sw/qa/extras/ooxmlexport/data/ooo39250-1-min.rtf | 42 +++++++++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 16 ++++++++
sw/source/filter/ww8/docxsdrexport.cxx | 36 +++++++++----------
3 files changed, 75 insertions(+), 19 deletions(-)
New commits:
commit eceace1f688ef2a50dc298cb4149c5a84fcaa34e
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Aug 14 12:35:51 2019 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 14 16:51:19 2019 +0200
sw: fix assert on export of ooo39250-1.rtf to DOCX
The problem is that a fly anchored at-char inside a text frame is being
exported; in DocxSdrExport::startDMLAnchorInline() the
m_bFlyFrameGraphic is true so an "inline" element is written but then
DocxSdrExport::writeDMLTextFrame() sets the flag to true then false,
so in endDMLAnchorInline() it's false and "anchor" results.
Remove the pointless information hiding between DocxSdrExport and its
own pImpl class so that the previous flag can be restored.
(regression from commit 28b77c89dfcafae82cf2a6d85731b643ff9290e5
which changed things somehow so that the anchor is inside the text
frame instead of the body as it was before; Word has it also in the
text frame so we can consider it an improvement)
Change-Id: I2df20b5cc336251f1c20cf81b6d68153c0c6ff46
Reviewed-on: https://gerrit.libreoffice.org/77454
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
diff --git a/sw/qa/extras/ooxmlexport/data/ooo39250-1-min.rtf b/sw/qa/extras/ooxmlexport/data/ooo39250-1-min.rtf
new file mode 100644
index 000000000000..df1467e4fe47
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/ooo39250-1-min.rtf
@@ -0,0 +1,42 @@
+{\rtf1\ansi\ansicpg1250\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1060\deflangfe1060{\fonttbl{\f0\froman\fcharset238\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\f1\fswiss\fcharset238\fprq2{\*\panose 020b0604020202020204}Arial;}{\f40\froman\fcharset0\fprq2 Times New Roman;}{\f39\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f41\froman\fcharset161\fprq2 Times New Roman Greek;}
+{\f42\froman\fcharset162\fprq2 Times New Roman Tur;}{\f43\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f44\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f45\froman\fcharset186\fprq2 Times New Roman Baltic;}
+{\f46\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f50\fswiss\fcharset0\fprq2 Arial;}{\f49\fswiss\fcharset204\fprq2 Arial Cyr;}{\f51\fswiss\fcharset161\fprq2 Arial Greek;}{\f52\fswiss\fcharset162\fprq2 Arial Tur;}
+{\f53\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f54\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f55\fswiss\fcharset186\fprq2 Arial Baltic;}{\f56\fswiss\fcharset163\fprq2 Arial (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;
+\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;
+\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1060\langfe1060\cgrid\langnp1060\langfenp1060 \snext0 Normal;}{\*\cs10 \additive
+\ssemihidden Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
+\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}}{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid3551688\rsid4459474}
+{\*\generator Microsoft Word 11.0.6359;}{\info{\author robi01}{\doccomm Produced by: PsQRFilters V2.11 for QuickReport (www.pragnaan.com)}{\operator robi01}{\creatim\yr2004\mo12\dy16\hr12\min51}{\revtim\yr2004\mo12\dy16\hr12\min51}{\version2}{\edmins1}
+{\nofpages1}{\nofwords256}{\nofchars1465}{\nofcharsws1718}{\vern24703}}\paperw11906\paperh16838\margl567\margr567\margt283\margb283 \widowctrl\ftnbj\aenddoc\hyphhotz425\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120
+\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\nolnhtadjtbl\rsidroot3551688 \fet0\sectd \linex0\headery0\footery0\colsx708\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}
+{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}
+{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9
+\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs24\lang1060\langfe1060\cgrid\langnp1060\langfenp1060 {\lang1024\langfe1024\noproof\insrsid3551688
+}
+{\f1\insrsid3551688 \par }
+
+\pard \ql \li0\ri0\nowidctlpar\pvpg\phpg\posx702\posy11927\absw1095\faauto\rin0\lin0\itap0 {\f1\fs16\cf1\insrsid3551688
+\par }
+\pard \ql \li0\ri0\nowidctlpar\pvpg\phpg\posx1782\posy11927\absw1695\faauto\rin0\lin0\itap0 {\lang1024\langfe1024\noproof\insrsid3551688
+}
+
+\pard \qr \li0\ri0\nowidctlpar\pvpg\phpg\posx7347\posy11492\absw1785\faauto\rin0\lin0\itap0 {\b\f1\fs16\cf1\insrsid3551688 Za pla\'e8ilo: }
+
+{\lang1024\langfe1024\noproof\insrsid3551688
+{\shp{\*\shpinst\shpleft687\shptop12452\shpright11248\shpbottom13593\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz7\shplid1033{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}
+{\sp{\sn lTxid}{\sv 65536}}{\sp{\sn dxTextLeft}{\sv 0}}{\sp{\sn dyTextTop}{\sv 0}}{\sp{\sn dxTextRight}{\sv 0}}{\sp{\sn dyTextBottom}{\sv 0}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn lineWidth}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn fShadow}{\sv 0}}
+{\sp{\sn posrelh}{\sv 1}}{\sp{\sn posrelv}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 0}}{\sp{\sn fBehindDocument}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 0}}{\shptxt \pard\plain \qc \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0
+\fs24\lang1060\langfe1060\cgrid\langnp1060\langfenp1060 {\b\f1\fs16\expnd-1\expndtw-6\insrsid3551688
+\par
+\par Pla\'e8ilo izvr\'9aite na transakcijski ra\'e8un NLB in se sklicujte na \'9atevilko predra\'e8una
+\par Do popolnega pla\'e8ila ostaja predmet pogodbe last podjetja TI, d.o.o. }{\f1\fs16\expnd-1\expndtw-6\insrsid3551688
+\par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\f1\fs16\expnd-1\expndtw-6\insrsid3551688
+\par }{\f1\insrsid3551688 _}}}{\shprslt{\*\do\dobxpage\dobypage\dodhgt7\dptxbx\dptxlrtb{\dptxbxtext\pard\plain \qc \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs24\lang1060\langfe1060\cgrid\langnp1060\langfenp1060 {\b\f1\fs16\expnd-1\expndtw-6\insrsid3551688
+\par
+\par Pla\'e8ilo izvr\'9aite na transakcijski ra\'e8un NLB in se sklicujte na \'9atevilko predra\'e8una
+\par Do popolnega pla\'e8ila ostaja predmet pogodbe last podjetja TI, d.o.o. }{\f1\fs16\expnd-1\expndtw-6\insrsid3551688
+\par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\f1\fs16\expnd-1\expndtw-6\insrsid3551688
+\par }{\f1\insrsid3551688 _}}\dpx687\dpy12452\dpxsize10561\dpysize1141\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255\dpfillbgcr255\dpfillbgcg255\dpfillbgcb255\dpfillpat0\dplinehollow}}}}
+
+}
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 837595bb65f8..5ed31b49c97f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -11,6 +11,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <editeng/frmdiritem.hxx>
@@ -31,10 +32,23 @@ protected:
*/
bool mustTestImportOf(const char* filename) const override {
// If the testcase is stored in some other format, it's pointless to test.
- return OString(filename).endsWith(".docx");
+ return OString(filename).endsWith(".docx") || OString(filename) == "ooo39250-1-min.rtf";
}
};
+// TODO: the re-import doesn't work just yet, but that isn't a regression...
+DECLARE_SW_EXPORT_TEST(testFlyInFly, "ooo39250-1-min.rtf", nullptr, Test)
+{
+ // check that anchor of text frame is in other text frame
+ uno::Reference<text::XTextContent> const xAnchored(getShape(3), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xAnchored.is());
+ CPPUNIT_ASSERT_EQUAL(OUString(""), uno::Reference<container::XNamed>(xAnchored, uno::UNO_QUERY_THROW)->getName());
+ uno::Reference<text::XText> const xAnchorText(xAnchored->getAnchor()->getText());
+ uno::Reference<text::XTextFrame> const xAnchorFrame(xAnchorText, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xAnchorFrame.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("Frame2"), uno::Reference<container::XNamed>(xAnchorFrame, uno::UNO_QUERY_THROW)->getName());
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf121374_sectionHF, "tdf121374_sectionHF.odt")
{
uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index b65ca4a383f7..8fa71a663bc9 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -26,6 +26,7 @@
#include <frmatr.hxx>
#include "docxattributeoutput.hxx"
#include "docxexportfilter.hxx"
+#include <comphelper/flagguard.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <sal/log.hxx>
@@ -138,7 +139,6 @@ private:
bool m_bDrawingOpen;
bool m_bParagraphSdtOpen;
bool m_bParagraphHasDrawing; ///Flag for checking drawing in a paragraph.
- bool m_bFlyFrameGraphic;
rtl::Reference<sax_fastparser::FastAttributeList> m_pFlyFillAttrList;
sax_fastparser::FastAttributeList* m_pFlyWrapAttrList;
sax_fastparser::FastAttributeList* m_pBodyPrAttrList;
@@ -149,6 +149,8 @@ private:
sal_Int32 m_nDMLandVMLTextFrameRotation;
public:
+ bool m_bFlyFrameGraphic = false;
+
Impl(DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer,
oox::drawingml::DrawingML* pDrawingML)
: m_rExport(rExport)
@@ -160,7 +162,6 @@ public:
, m_bDrawingOpen(false)
, m_bParagraphSdtOpen(false)
, m_bParagraphHasDrawing(false)
- , m_bFlyFrameGraphic(false)
, m_pFlyWrapAttrList(nullptr)
, m_pBodyPrAttrList(nullptr)
, m_bDMLAndVMLDrawingOpen(false)
@@ -261,8 +262,6 @@ public:
return m_pDashLineStyleAttr;
}
- void setFlyFrameGraphic(bool bFlyFrameGraphic) { m_bFlyFrameGraphic = bFlyFrameGraphic; }
-
bool getFlyFrameGraphic() const { return m_bFlyFrameGraphic; }
oox::drawingml::DrawingML* getDrawingML() const { return m_pDrawingML; }
@@ -1112,9 +1111,8 @@ void DocxSdrExport::writeOnlyTextOfFrame(ww8::Frame const* pParentFrame)
ExportDataSaveRestore aDataGuard(m_pImpl->getExport(), nStt, nEnd, pParentFrame);
m_pImpl->setBodyPrAttrList(sax_fastparser::FastSerializerHelper::createAttrList());
- m_pImpl->setFlyFrameGraphic(true);
+ ::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true);
m_pImpl->getExport().WriteText();
- m_pImpl->setFlyFrameGraphic(false);
}
void DocxSdrExport::writeBoxItemLine(const SvxBoxItem& rBox)
@@ -1367,14 +1365,15 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
else if (rDirection.GetValue() == SvxFrameDirection::Vertical_LR_BT)
m_pImpl->getBodyPrAttrList()->add(XML_vert, "vert270");
- m_pImpl->setFlyFrameGraphic(true);
- m_pImpl->getExport().WriteText();
- if (m_pImpl->getParagraphSdtOpen())
{
- m_pImpl->getExport().DocxAttrOutput().EndParaSdtBlock();
- m_pImpl->setParagraphSdtOpen(false);
+ ::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true);
+ m_pImpl->getExport().WriteText();
+ if (m_pImpl->getParagraphSdtOpen())
+ {
+ m_pImpl->getExport().DocxAttrOutput().EndParaSdtBlock();
+ m_pImpl->setParagraphSdtOpen(false);
+ }
}
- m_pImpl->setFlyFrameGraphic(false);
pFS->endElementNS(XML_w, XML_txbxContent);
pFS->endElementNS(XML_wps, XML_txbx);
@@ -1515,14 +1514,15 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText
pFS->startElementNS(XML_v, XML_textbox, xTextboxAttrList);
}
pFS->startElementNS(XML_w, XML_txbxContent);
- m_pImpl->setFlyFrameGraphic(true);
- m_pImpl->getExport().WriteText();
- if (m_pImpl->getParagraphSdtOpen())
{
- m_pImpl->getExport().DocxAttrOutput().EndParaSdtBlock();
- m_pImpl->setParagraphSdtOpen(false);
+ ::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true);
+ m_pImpl->getExport().WriteText();
+ if (m_pImpl->getParagraphSdtOpen())
+ {
+ m_pImpl->getExport().DocxAttrOutput().EndParaSdtBlock();
+ m_pImpl->setParagraphSdtOpen(false);
+ }
}
- m_pImpl->setFlyFrameGraphic(false);
pFS->endElementNS(XML_w, XML_txbxContent);
if (!bTextBoxOnly)
{
More information about the Libreoffice-commits
mailing list