tdf#119201 Don't show/print hidden shapes in DOCX
Similar fix to b38065ea94
Only rely visibility setting for now, but properly:
visible means also printed, hidden means not printed.
Ie. import visible property also as printable, and only
output visible property in DOCX format (DOC shapes have no
such property).
Change-Id: Ifc3c36f90aa16ded1a9f31197612a5c85fde5d87
Reviewed-on: https://gerrit.libreoffice.org/68239
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
BIN
sw/qa/extras/ooxmlexport/data/tdf119201.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/tdf119201.docx
Normal file
Binary file not shown.
@@ -147,6 +147,20 @@ DECLARE_OOXMLEXPORT_TEST(testFrameSizeExport, "floating-tables-anchor.docx")
|
|||||||
assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tblPr/w:tblW", "w", "4000");
|
assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tblPr/w:tblW", "w", "4000");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLARE_OOXMLEXPORT_TEST(testTdf119201, "tdf119201.docx")
|
||||||
|
{
|
||||||
|
// Visibility of shapes wasn't imported/exported, for now base printable property on that, too
|
||||||
|
auto xShape(getShape(1));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("First shape should be visible.", getProperty<bool>(xShape, "Visible"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("First shape should be printable.", getProperty<bool>(xShape, "Printable"));
|
||||||
|
xShape = getShape(2);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Second shape should not be visible.", !getProperty<bool>(xShape, "Visible"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Second shape should not be printable.", !getProperty<bool>(xShape, "Printable"));
|
||||||
|
xShape = getShape(3);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Third shape should be visible.", getProperty<bool>(xShape, "Visible"));
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Third shape should be printable.", getProperty<bool>(xShape, "Printable"));
|
||||||
|
}
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -892,6 +892,10 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFo
|
|||||||
if (!pSdrObject->GetDescription().isEmpty())
|
if (!pSdrObject->GetDescription().isEmpty())
|
||||||
pDocPrAttrList->add(XML_descr,
|
pDocPrAttrList->add(XML_descr,
|
||||||
OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
|
OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
|
||||||
|
if (!pSdrObject->IsVisible()
|
||||||
|
&& pFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
|
||||||
|
|
||||||
|
pDocPrAttrList->add(XML_hidden, OString::number(1).getStr());
|
||||||
sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
|
sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
|
||||||
pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
|
pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
|
||||||
|
|
||||||
|
@@ -225,6 +225,7 @@ public:
|
|||||||
|
|
||||||
bool bSizeProtected;
|
bool bSizeProtected;
|
||||||
bool bPositionProtected;
|
bool bPositionProtected;
|
||||||
|
bool bHidden;
|
||||||
|
|
||||||
sal_Int32 nShapeOptionType;
|
sal_Int32 nShapeOptionType;
|
||||||
|
|
||||||
@@ -277,6 +278,7 @@ public:
|
|||||||
,bIsGraphic(false)
|
,bIsGraphic(false)
|
||||||
,bSizeProtected(false)
|
,bSizeProtected(false)
|
||||||
,bPositionProtected(false)
|
,bPositionProtected(false)
|
||||||
|
,bHidden(false)
|
||||||
,nShapeOptionType(0)
|
,nShapeOptionType(0)
|
||||||
,m_rPositionOffsets(rPositionOffsets)
|
,m_rPositionOffsets(rPositionOffsets)
|
||||||
,m_rAligns(rAligns)
|
,m_rAligns(rAligns)
|
||||||
@@ -559,6 +561,9 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
|
|||||||
//alternative text
|
//alternative text
|
||||||
m_pImpl->title = rValue.getString();
|
m_pImpl->title = rValue.getString();
|
||||||
break;
|
break;
|
||||||
|
case NS_ooxml::LN_CT_NonVisualDrawingProps_hidden:
|
||||||
|
m_pImpl->bHidden = (nIntValue == 1);
|
||||||
|
break;
|
||||||
case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noChangeAspect://90644;
|
case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noChangeAspect://90644;
|
||||||
//disallow aspect ratio change - ignored
|
//disallow aspect ratio change - ignored
|
||||||
break;
|
break;
|
||||||
@@ -717,7 +722,6 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
|
|||||||
if ( bUseShape )
|
if ( bUseShape )
|
||||||
m_xShape = xShape;
|
m_xShape = xShape;
|
||||||
|
|
||||||
|
|
||||||
if ( m_xShape.is( ) )
|
if ( m_xShape.is( ) )
|
||||||
{
|
{
|
||||||
uno::Reference< beans::XPropertySet > xShapeProps
|
uno::Reference< beans::XPropertySet > xShapeProps
|
||||||
@@ -785,6 +789,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
|
|||||||
// This needs to be AT_PARAGRAPH by default and not AT_CHARACTER, otherwise shape will move when the user inserts a new paragraph.
|
// This needs to be AT_PARAGRAPH by default and not AT_CHARACTER, otherwise shape will move when the user inserts a new paragraph.
|
||||||
text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
|
text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
|
||||||
|
|
||||||
|
if (m_pImpl->bHidden)
|
||||||
|
{
|
||||||
|
xShapeProps->setPropertyValue("Visible", uno::makeAny(false));
|
||||||
|
xShapeProps->setPropertyValue("Printable", uno::makeAny(false));
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid setting AnchorType for TextBoxes till SwTextBoxHelper::syncProperty() doesn't handle transition.
|
// Avoid setting AnchorType for TextBoxes till SwTextBoxHelper::syncProperty() doesn't handle transition.
|
||||||
bool bTextBox = false;
|
bool bTextBox = false;
|
||||||
xShapeProps->getPropertyValue("TextBox") >>= bTextBox;
|
xShapeProps->getPropertyValue("TextBox") >>= bTextBox;
|
||||||
|
Reference in New Issue
Block a user