[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sw/inc sw/qa sw/source writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Jan 21 09:35:51 UTC 2019
sw/inc/cmdid.h | 2 +
sw/inc/unoframe.hxx | 2 +
sw/inc/unoprnms.hxx | 2 +
sw/qa/extras/odfexport/data/tdf99631.docx |binary
sw/qa/extras/odfexport/odfexport.cxx | 15 +++++++++
sw/qa/extras/ooxmlexport/data/tdf99631.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 15 +++++++++
sw/source/core/unocore/unoframe.cxx | 35 +++++++++++++++++++++-
sw/source/core/unocore/unomap1.cxx | 2 +
sw/source/filter/ww8/docxattributeoutput.cxx | 28 ++++++++++++++++-
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 +++++
writerfilter/source/dmapper/OLEHandler.cxx | 12 +++++++
writerfilter/source/dmapper/OLEHandler.hxx | 4 ++
13 files changed, 123 insertions(+), 2 deletions(-)
New commits:
commit 5db1b9e519e1af16d3faf98465b5a901c6bdbb36
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Wed Dec 12 12:58:07 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jan 21 10:35:30 2019 +0100
tdf#99631 DOCX: keep zoom of embedded XLSX
and other OLE objects by handling their VisibleArea settings.
(Cherry-picked from the following commits:
5c1a6c9adb5ccfbb869a0a7ac730d8860a1bf405
"DOCX import: set 1:1 scale in embedded XLSX"
69ce3374f90847f357249a41118314508da6bb98
"DOCX import: keep zoom of embedded XLSX"
fc50869a818f5411bf2bbd34db398078308f2ba3
"DOCX export: keep zoom of embedded XLSX")
Change-Id: I3f246b779afd145fe260af83173c1944df21fb1a
Reviewed-on: https://gerrit.libreoffice.org/65271
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index d829c3d45fe2..28a13ea71abd 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -599,6 +599,8 @@
#define FN_UNO_HIDDEN (FN_EXTRA2 + 122)
#define FN_UNO_STYLE_INTEROP_GRAB_BAG (FN_EXTRA2 + 123)
#define FN_UNO_TABLE_TEMPLATE_NAME (FN_EXTRA2 + 124)
+#define FN_UNO_VISIBLE_AREA_WIDTH (FN_EXTRA2 + 125)
+#define FN_UNO_VISIBLE_AREA_HEIGHT (FN_EXTRA2 + 126)
// Area: Help
// Region: Traveling & Selection
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx
index 41dc3292c53c..43876e94a580 100644
--- a/sw/inc/unoframe.hxx
+++ b/sw/inc/unoframe.hxx
@@ -72,6 +72,8 @@ private:
std::unique_ptr<SwPaM> m_pCopySource;
sal_Int64 m_nDrawAspect;
+ sal_Int64 m_nVisibleAreaWidth;
+ sal_Int64 m_nVisibleAreaHeight;
protected:
css::uno::Reference< css::beans::XPropertySet > mxStyleData;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index a168bbc38498..30731e1033e6 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -821,6 +821,8 @@
#define UNO_NAME_RSID "Rsid"
#define UNO_NAME_PARRSID "ParRsid"
#define UNO_NAME_DRAW_ASPECT "DrawAspect"
+#define UNO_NAME_VISIBLE_AREA_WIDTH "VisibleAreaWidth"
+#define UNO_NAME_VISIBLE_AREA_HEIGHT "VisibleAreaHeight"
#define UNO_NAME_LINE_STYLE "LineStyle"
#define UNO_NAME_LINE_WIDTH "LineWidth"
diff --git a/sw/qa/extras/odfexport/data/tdf99631.docx b/sw/qa/extras/odfexport/data/tdf99631.docx
new file mode 100644
index 000000000000..c72950b7240a
Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf99631.docx differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 930a3ce1f73d..4f13fc4dfae6 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2123,6 +2123,21 @@ DECLARE_ODFEXPORT_TEST(tdf118502, "tdf118502.odt")
CPPUNIT_ASSERT(xReplacementGraphic.is());
}
+DECLARE_ODFEXPORT_TEST(tdf99631, "tdf99631.docx")
+{
+ // check import of VisualArea settings of the embedded XLSX OLE objects
+ xmlDocPtr pXmlDoc = parseExport("Object 1/settings.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPathContent(pXmlDoc, "//config:config-item[@config:name='VisibleAreaWidth']", "4515");
+ assertXPathContent(pXmlDoc, "//config:config-item[@config:name='VisibleAreaHeight']", "903");
+
+ xmlDocPtr pXmlDoc2 = parseExport("Object 2/settings.xml");
+ if (!pXmlDoc2)
+ return;
+ assertXPathContent(pXmlDoc2, "//config:config-item[@config:name='VisibleAreaWidth']", "4515");
+ assertXPathContent(pXmlDoc2, "//config:config-item[@config:name='VisibleAreaHeight']", "1354");
+}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99631.docx b/sw/qa/extras/ooxmlexport/data/tdf99631.docx
new file mode 100644
index 000000000000..c72950b7240a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf99631.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 547afcd1a399..3e90ed1b4d9d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -921,6 +921,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf117137, "tdf117137.docx")
CPPUNIT_ASSERT(xPara3->getPropertyValue("NumberingRules").hasValue());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf99631, "tdf99631.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "//w:object", 2);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object", 2);
+ // first XSLX OLE object (1:1 scale)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dxaOrig", "2560");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dyaOrig", "513");
+ // second XLSX OLE object (same content + 1 row, but zoomed)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dxaOrig", "2560");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dyaOrig", "768");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 93cf268e765a..c4d0e482e8bf 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1127,7 +1127,9 @@ bool SwOLEProperties_Impl::AnyToItemSet(
{
const ::uno::Any* pTemp;
if(!GetProperty(FN_UNO_CLSID, 0, pTemp) && !GetProperty(FN_UNO_STREAM_NAME, 0, pTemp)
- && !GetProperty(FN_EMBEDDED_OBJECT, 0, pTemp) )
+ && !GetProperty(FN_EMBEDDED_OBJECT, 0, pTemp)
+ && !GetProperty(FN_UNO_VISIBLE_AREA_WIDTH, 0, pTemp)
+ && !GetProperty(FN_UNO_VISIBLE_AREA_HEIGHT, 0, pTemp) )
return false;
SwFrameProperties_Impl::AnyToItemSet( pDoc, rFrameSet, rSet, rSizeFound);
@@ -1194,6 +1196,8 @@ SwXFrame::SwXFrame(FlyCntType eSet, const ::SfxItemPropertySet* pSet, SwDoc *pDo
, eType(eSet)
, bIsDescriptor(true)
, m_nDrawAspect(embed::Aspects::MSOLE_CONTENT)
+ , m_nVisibleAreaWidth(0)
+ , m_nVisibleAreaHeight(0)
{
// Register ourselves as a listener to the document (via the page descriptor)
pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
@@ -1247,6 +1251,8 @@ SwXFrame::SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet, const ::SfxItem
, eType(eSet)
, bIsDescriptor(false)
, m_nDrawAspect(embed::Aspects::MSOLE_CONTENT)
+ , m_nVisibleAreaWidth(0)
+ , m_nVisibleAreaHeight(0)
{
}
@@ -1949,6 +1955,18 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
else if (sAspect == "Content")
m_nDrawAspect = embed::Aspects::MSOLE_CONTENT;
}
+ else if (FN_UNO_VISIBLE_AREA_WIDTH == pEntry->nWID)
+ {
+ OUString sAspect = "";
+ aValue >>= sAspect;
+ m_nVisibleAreaWidth = sAspect.toInt64();
+ }
+ else if (FN_UNO_VISIBLE_AREA_HEIGHT == pEntry->nWID)
+ {
+ OUString sAspect = "";
+ aValue >>= sAspect;
+ m_nVisibleAreaHeight = sAspect.toInt64();
+ }
}
else
throw uno::RuntimeException();
@@ -2845,6 +2863,21 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
{
UnoActionContext aAction(pDoc);
pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
+
+ // tdf#99631 set imported VisibleArea settings of embedded XLSX OLE objects
+ if ( m_nDrawAspect == embed::Aspects::MSOLE_CONTENT
+ && m_nVisibleAreaWidth && m_nVisibleAreaHeight )
+ {
+ sal_Int64 nAspect = m_nDrawAspect;
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) );
+ Size aSize( OutputDevice::LogicToLogic(Size( m_nVisibleAreaWidth, m_nVisibleAreaHeight),
+ MapMode(MapUnit::MapTwip), MapMode(aUnit)));
+ awt::Size aSz;
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xIPObj->setVisualAreaSize(m_nDrawAspect, aSz);
+ }
+
if(!bSizeFound)
{
//TODO/LATER: how do I transport it to the OLENode?
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index de331a18cbf8..2c96d9ffeded 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -899,6 +899,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetEmbeddedPropertyMap
{ OUString(UNO_NAME_COMPONENT),FN_UNO_COMPONENT, cppu::UnoType<css::lang::XComponent>::get(), PropertyAttribute::READONLY, 0},
{ OUString(UNO_NAME_EMBEDDED_OBJECT),FN_EMBEDDED_OBJECT, cppu::UnoType<css::embed::XEmbeddedObject>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_DRAW_ASPECT),FN_UNO_DRAW_ASPECT, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
+ { OUString(UNO_NAME_VISIBLE_AREA_WIDTH),FN_UNO_VISIBLE_AREA_WIDTH, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
+ { OUString(UNO_NAME_VISIBLE_AREA_HEIGHT),FN_UNO_VISIBLE_AREA_HEIGHT, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
// added FillProperties for SW, same as FILL_PROPERTIES in svx
// but need own defines in Writer due to later association of strings
// and uno types (see loop at end of this method and definition of SW_PROP_NMID)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c576fec3ec09..85e8167bd171 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -147,6 +147,8 @@
#include <algorithm>
#include <stdarg.h>
+#include <toolkit/helper/vclunohelper.hxx>
+
using ::editeng::SvxBorderLine;
using namespace oox;
@@ -5314,7 +5316,31 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
m_rDrawingML.SetFS(m_pSerializer);
OUString sImageId = m_rDrawingML.WriteImage( *pGraphic );
- m_pSerializer->startElementNS( XML_w, XML_object, FSEND );
+ if ( sDrawAspect == "Content" )
+ {
+ awt::Size aSize;
+ try
+ {
+ aSize = xObj->getVisualAreaSize( rNode.GetAspect() );
+
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( rNode.GetAspect() ) );
+ Size aOriginalSize( OutputDevice::LogicToLogic(Size( aSize.Width, aSize.Height),
+ MapMode(aUnit), MapMode(MapUnit::MapTwip)));
+
+ m_pSerializer->startElementNS( XML_w, XML_object,
+ FSNS(XML_w, XML_dxaOrig), OString::number(aOriginalSize.Width()),
+ FSNS(XML_w, XML_dyaOrig), OString::number(aOriginalSize.Height()),
+ FSEND );
+ }
+ catch ( uno::Exception& )
+ {
+ m_pSerializer->startElementNS( XML_w, XML_object, FSEND );
+ }
+ }
+ else
+ {
+ m_pSerializer->startElementNS( XML_w, XML_object, FSEND );
+ }
OStringBuffer sShapeStyle, sShapeId;
sShapeStyle.append( "width:" ).append( double( rSize.Width() ) / 20 )
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f2a14ceb8f7a..46ff7984ad35 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1762,6 +1762,14 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const std::share
xOLEProperties->setPropertyValue(getPropertyName( PROP_HEIGHT ),
uno::makeAny(aSize.Height));
+ OUString aVisAreaWidth = pOLEHandler->GetVisAreaWidth();
+ if(!aVisAreaWidth.isEmpty())
+ xOLEProperties->setPropertyValue("VisibleAreaWidth", uno::makeAny(aVisAreaWidth));
+
+ OUString aVisAreaHeight = pOLEHandler->GetVisAreaHeight();
+ if(!aVisAreaHeight.isEmpty())
+ xOLEProperties->setPropertyValue("VisibleAreaHeight", uno::makeAny(aVisAreaHeight));
+
uno::Reference< graphic::XGraphic > xGraphic = pOLEHandler->getReplacement();
xOLEProperties->setPropertyValue(getPropertyName( PROP_GRAPHIC ),
uno::makeAny(xGraphic));
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index dee9ceb22ae1..fad449489e3c 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -95,8 +95,10 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
rVal.getAny() >>= m_xInputStream;
break;
case NS_ooxml::LN_CT_Object_dxaOrig:
+ m_sVisAreaWidth = sStringValue;
break;
case NS_ooxml::LN_CT_Object_dyaOrig:
+ m_sVisAreaHeight = sStringValue;
break;
case NS_ooxml::LN_shape:
{
@@ -262,6 +264,16 @@ OUString const & OLEHandler::GetDrawAspect() const
return m_sDrawAspect;
}
+OUString const & OLEHandler::GetVisAreaWidth() const
+{
+ return m_sVisAreaWidth;
+}
+
+OUString const & OLEHandler::GetVisAreaHeight() const
+{
+ return m_sVisAreaHeight;
+}
+
OUString OLEHandler::copyOLEOStream(
uno::Reference<text::XTextDocument> const& xTextDocument)
{
diff --git a/writerfilter/source/dmapper/OLEHandler.hxx b/writerfilter/source/dmapper/OLEHandler.hxx
index 6ba2fb34ae1a..b0aae530f37a 100644
--- a/writerfilter/source/dmapper/OLEHandler.hxx
+++ b/writerfilter/source/dmapper/OLEHandler.hxx
@@ -52,6 +52,8 @@ class OLEHandler : public LoggedProperties
OUString m_sProgId;
OUString m_sShapeId;
OUString m_sDrawAspect;
+ OUString m_sVisAreaWidth;
+ OUString m_sVisAreaHeight;
OUString m_sObjectId;
OUString m_sr_id;
/// The stream URL right after the import of the raw data.
@@ -90,6 +92,8 @@ public:
OUString getCLSID(const css::uno::Reference<css::uno::XComponentContext>& xComponentContext) const;
OUString const & GetDrawAspect() const;
+ OUString const & GetVisAreaWidth() const;
+ OUString const & GetVisAreaHeight() const;
OUString copyOLEOStream(css::uno::Reference<css::text::XTextDocument> const& xTextDocument);
More information about the Libreoffice-commits
mailing list