diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-03-01 08:39:11 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-03-07 02:37:36 +0100 |
commit | d72145f9307c732ced4a546ac1e5093ec7c1a982 (patch) | |
tree | 648cf88d30ba3da260edb22829d8cd8be0c9345e /sw | |
parent | 6b39ed0eaffabb6ffe11496d833053c094c72f7b (diff) |
Move BackGraphicURL property & friends to BackGraphic + fixes
This moves BackGraphicURL, HeaderGraphicURL, FooterGraphicURL and
ParaBackGraphicURL properties to BackGraphic, HeaderBackGraphic,
FooterBackGraphic and ParaBackGraphic. With this the property type
changes from String to XGraphic.
This change also fixes a bunch of test failures, changes the tests
to use the new properties and the correct type, changes the import
and export filters like xmloff and oox, to make the tests happy.
Change-Id: Ie66097514203c6dc36ab27420faf265322e9279e
Reviewed-on: https://gerrit.libreoffice.org/50760
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 13 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 48 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlbrsh.cxx | 75 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlbrshi.hxx | 7 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlexpit.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimpit.cxx | 11 |
9 files changed, 83 insertions, 99 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index d796e58e88ee..a4b4bfec4b9a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -603,17 +603,20 @@ DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - bool bIsGraphic = false; + uno::Reference<graphic::XGraphic> xGraphic; + sal_Int16 nNumberingType = -1; + for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "NumberingType") - CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>()); - else if (rProp.Name == "GraphicURL") - bIsGraphic = true; + nNumberingType = rProp.Value.get<sal_Int16>(); + else if (rProp.Name == "Graphic") + xGraphic = rProp.Value.get<uno::Reference<graphic::XGraphic>>(); } - CPPUNIT_ASSERT_EQUAL(true, bIsGraphic); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType); + CPPUNIT_ASSERT(xGraphic.is()); } DECLARE_OOXMLEXPORT_TEST(testFdo64826, "fdo64826.docx") diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index cd0b7d962f45..5f1b96b01ebb 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -552,17 +552,20 @@ DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - bool bIsGraphic = false; + uno::Reference<graphic::XGraphic> xGraphic; + sal_Int16 nNumberingType = -1; + for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "NumberingType") - CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>()); - else if (rProp.Name == "GraphicURL") - bIsGraphic = true; + nNumberingType = rProp.Value.get<sal_Int16>(); + else if (rProp.Name == "Graphic") + xGraphic = rProp.Value.get<uno::Reference<graphic::XGraphic>>(); } - CPPUNIT_ASSERT_EQUAL(true, bIsGraphic); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType); + CPPUNIT_ASSERT(xGraphic.is()); } DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf") diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 4c4c206a5747..cafbbcd56950 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -1432,30 +1432,27 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_BULLET_FONT, aDesc)); } } - if(SVX_NUM_BITMAP == rFormat.GetNumberingType()) + if (SVX_NUM_BITMAP == rFormat.GetNumberingType()) { //GraphicURL const SvxBrushItem* pBrush = rFormat.GetBrush(); - if(pBrush) + uno::Reference<graphic::XGraphic> xGraphic; + if (pBrush) { - Any aAny; - pBrush->QueryValue( aAny, MID_GRAPHIC_URL ); - aAny >>= aUString; + xGraphic = pBrush->GetGraphic()->GetXGraphic(); + aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC, xGraphic)); } - else - aUString.clear(); - aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_URL, aUString)); - //graphicbitmap + //GraphicBitmap const Graphic* pGraphic = nullptr; - if(pBrush ) + if (pBrush) pGraphic = pBrush->GetGraphic(); - if(pGraphic) + if (pGraphic) { uno::Reference<awt::XBitmap> xBitmap(pGraphic->GetXGraphic(), uno::UNO_QUERY); aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_BITMAP, xBitmap)); } - Size aSize = rFormat.GetGraphicSize(); + Size aSize = rFormat.GetGraphicSize(); // #i101131# // adjust conversion due to type mismatch between <Size> and <awt::Size> awt::Size aAwtSize(convertTwipToMm100(aSize.Width()), convertTwipToMm100(aSize.Height())); @@ -1580,7 +1577,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( UNO_NAME_BULLET_FONT, // 17 UNO_NAME_BULLET_FONT_NAME, // 18 UNO_NAME_BULLET_CHAR, // 19 - UNO_NAME_GRAPHIC_URL, // 20 + UNO_NAME_GRAPHIC, // 20 UNO_NAME_GRAPHIC_BITMAP, // 21 UNO_NAME_GRAPHIC_SIZE, // 22 UNO_NAME_VERT_ORIENT, // 23 @@ -1925,22 +1922,27 @@ void SwXNumberingRules::SetPropertiesToNumFormat( } } break; - case 20: //UNO_NAME_GRAPHIC_URL, + case 20: //UNO_NAME_GRAPHIC, { assert( !pDocShell ); - OUString sBrushURL; - pProp->Value >>= sBrushURL; - if(!pSetBrush) + uno::Reference<graphic::XGraphic> xGraphic; + if (pProp->Value >>= xGraphic) { - const SvxBrushItem* pOrigBrush = aFormat.GetBrush(); - if(pOrigBrush) + if (!pSetBrush) { - pSetBrush = new SvxBrushItem(*pOrigBrush); + const SvxBrushItem* pOrigBrush = aFormat.GetBrush(); + if(pOrigBrush) + { + pSetBrush = new SvxBrushItem(*pOrigBrush); + } + else + pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND); } - else - pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND); + Graphic aGraphic(xGraphic); + pSetBrush->SetGraphic(aGraphic); } - pSetBrush->PutValue( pProp->Value, MID_GRAPHIC_URL ); + else + bWrongArg = true; } break; case 21: //UNO_NAME_GRAPHIC_BITMAP, diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index ea14bc88228c..1f5b1811b282 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1838,7 +1838,6 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc) MID_BACK_COLOR, MID_GRAPHIC_TRANSPARENT, MID_GRAPHIC_POSITION, - MID_GRAPHIC_URL, MID_GRAPHIC, MID_GRAPHIC_FILTER }); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 0e81dae183ae..29d5cf1dbb78 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8454,7 +8454,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) uno::Reference< drawing::XShape > xShape( const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY ); m_rDrawingML.SetFS(m_pSerializer); - m_rDrawingML.WriteBlipFill( xPropertySet, "BackGraphicURL" ); + m_rDrawingML.WriteBlipFill(xPropertySet, "BackGraphic"); } } } diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx index 6bb997059b65..85d6bd963143 100644 --- a/sw/source/filter/xml/xmlbrsh.cxx +++ b/sw/source/filter/xml/xmlbrsh.cxx @@ -83,9 +83,7 @@ void SwXMLBrushItemImportContext::ProcessAttrs( switch( aTokenMap.Get( nPrefix, aLocalName ) ) { case XML_TOK_BGIMG_HREF: - SvXMLImportItemMapper::PutXMLValue( - *pItem, GetImport().ResolveGraphicObjectURL( rValue, false), - MID_GRAPHIC_LINK, rUnitConv ); + m_xGraphic = GetImport().loadGraphicByURL(rValue); break; case XML_TOK_BGIMG_TYPE: case XML_TOK_BGIMG_ACTUATE: @@ -113,24 +111,16 @@ SvXMLImportContextRef SwXMLBrushItemImportContext::CreateChildContext( const uno::Reference< xml::sax::XAttributeList > & xAttrList ) { SvXMLImportContext *pContext = nullptr; - if( xmloff::token::IsXMLToken( rLocalName, - xmloff::token::XML_BINARY_DATA ) ) + if (xmloff::token::IsXMLToken(rLocalName, xmloff::token::XML_BINARY_DATA)) { - if( !xBase64Stream.is() && pItem->GetGraphicLink().isEmpty() ) + if (!m_xBase64Stream.is()) { - const GraphicObject *pGrObj = pItem->GetGraphicObject(); - if( !pGrObj || GraphicType::NONE == pGrObj->GetType() ) - { - xBase64Stream = - GetImport().GetStreamForGraphicObjectURLFromBase64(); - if( xBase64Stream.is() ) - pContext = new XMLBase64ImportContext( GetImport(), nPrefix, - rLocalName, xAttrList, - xBase64Stream ); - } + m_xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); + if (m_xBase64Stream.is()) + pContext = new XMLBase64ImportContext(GetImport(), nPrefix, rLocalName, xAttrList, m_xBase64Stream); } } - if( !pContext ) + if (!pContext) { pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } @@ -140,17 +130,21 @@ SvXMLImportContextRef SwXMLBrushItemImportContext::CreateChildContext( void SwXMLBrushItemImportContext::EndElement() { - if( xBase64Stream.is() ) + if (m_xBase64Stream.is()) + { + m_xGraphic = GetImport().loadGraphicFromBase64(m_xBase64Stream); + m_xBase64Stream = nullptr; + } + if (m_xGraphic.is()) { - const OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ) ); - xBase64Stream = nullptr; - SvXMLImportItemMapper::PutXMLValue( *pItem, sURL, MID_GRAPHIC_LINK, GetImport().GetMM100UnitConverter() ); + Graphic aGraphic(m_xGraphic); + pItem->SetGraphic(aGraphic); } - if( pItem->GetGraphicLink().isEmpty() && !(pItem->GetGraphic()) ) - pItem->SetGraphicPos( GPOS_NONE ); - else if( GPOS_NONE == pItem->GetGraphicPos() ) - pItem->SetGraphicPos( GPOS_TILED ); + if (!(pItem->GetGraphic())) + pItem->SetGraphicPos(GPOS_NONE); + else if (GPOS_NONE == pItem->GetGraphicPos()) + pItem->SetGraphicPos(GPOS_TILED); } SwXMLBrushItemImportContext::SwXMLBrushItemImportContext( @@ -197,39 +191,42 @@ void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem ) { GetExport().CheckAttrList(); - OUString sURL; - const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter(); - if( SvXMLExportItemMapper::QueryXMLValue( - rItem, sURL, MID_GRAPHIC_LINK, rUnitConv ) ) + uno::Reference<graphic::XGraphic> xGraphic; + + const Graphic* pGraphic = rItem.GetGraphic(); + + if (pGraphic) + xGraphic = pGraphic->GetXGraphic(); + + if (xGraphic.is()) { - OUString sValue = GetExport().AddEmbeddedGraphicObject( sURL ); - if( !sValue.isEmpty() ) + OUString sMimeType; + OUString sValue = GetExport().AddEmbeddedXGraphic(xGraphic, sMimeType); + if (!sValue.isEmpty()) { GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sValue ); GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); } - if( SvXMLExportItemMapper::QueryXMLValue( - rItem, sValue, MID_GRAPHIC_POSITION, rUnitConv ) ) + const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter(); + if (SvXMLExportItemMapper::QueryXMLValue(rItem, sValue, MID_GRAPHIC_POSITION, rUnitConv)) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION, sValue ); - if( SvXMLExportItemMapper::QueryXMLValue( - rItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv ) ) + if (SvXMLExportItemMapper::QueryXMLValue(rItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv)) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REPEAT, sValue ); - if( SvXMLExportItemMapper::QueryXMLValue( - rItem, sValue, MID_GRAPHIC_FILTER, rUnitConv ) ) + if (SvXMLExportItemMapper::QueryXMLValue(rItem, sValue, MID_GRAPHIC_FILTER, rUnitConv)) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FILTER_NAME, sValue ); } { SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, XML_BACKGROUND_IMAGE, true, true ); - if( !sURL.isEmpty() ) + if (xGraphic.is()) { // optional office:binary-data - GetExport().AddEmbeddedGraphicObjectAsBase64( sURL ); + GetExport().AddEmbeddedXGraphicAsBase64(xGraphic); } } } diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx index 75d5da234cca..3e07e42de3aa 100644 --- a/sw/source/filter/xml/xmlbrshi.hxx +++ b/sw/source/filter/xml/xmlbrshi.hxx @@ -22,6 +22,7 @@ #include <memory> #include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <xmloff/xmlictxt.hxx> @@ -36,8 +37,10 @@ namespace com { namespace sun { namespace star { class SwXMLBrushItemImportContext : public SvXMLImportContext { private: - css::uno::Reference < css::io::XOutputStream > xBase64Stream; - std::unique_ptr<SvxBrushItem> pItem; + css::uno::Reference<css::io::XOutputStream> m_xBase64Stream; + css::uno::Reference<css::graphic::XGraphic> m_xGraphic; + + std::unique_ptr<SvxBrushItem> pItem; void ProcessAttrs( const css::uno::Reference<css::xml::sax::XAttributeList > & xAttrList, diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx index c4234435ada5..69f982f1e8f7 100644 --- a/sw/source/filter/xml/xmlexpit.cxx +++ b/sw/source/filter/xml/xmlexpit.cxx @@ -902,18 +902,6 @@ bool SvXMLExportItemMapper::QueryXMLValue( bOk = true; break; - case MID_GRAPHIC_LINK: - if (rBrush.GetGraphicPos() != GPOS_NONE) - { - uno::Any aAny; - rBrush.QueryValue( aAny, MID_GRAPHIC_URL ); - OUString sTmp; - aAny >>= sTmp; - aOut.append( sTmp ); - bOk = true; - } - break; - case MID_GRAPHIC_POSITION: switch (rBrush.GetGraphicPos()) { diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index 6806ae9b62b3..13f8591292cb 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -661,17 +661,6 @@ bool SvXMLImportItemMapper::PutXMLValue( } break; - case MID_GRAPHIC_LINK: - { - SvxGraphicPosition eOldGraphicPos = rBrush.GetGraphicPos(); - rBrush.PutValue( Any(rValue), MID_GRAPHIC_URL ); - if( GPOS_NONE == eOldGraphicPos && - GPOS_NONE != rBrush.GetGraphicPos() ) - rBrush.SetGraphicPos( GPOS_TILED ); - bOk = true; - } - break; - case MID_GRAPHIC_REPEAT: { SvxGraphicPosition eGraphicPos = rBrush.GetGraphicPos(); |