summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx16
-rw-r--r--include/vcl/vectorgraphicdata.hxx3
-rw-r--r--svx/source/svdraw/svdxcgv.cxx11
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx9
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx22
-rw-r--r--vcl/source/gdi/vectorgraphicdata.cxx7
6 files changed, 58 insertions, 10 deletions
diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
index 2f750e73af65..63b4ffd6986d 100644
--- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
+++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
@@ -34,6 +34,7 @@
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/converters.hxx>
+#include <comphelper/sequenceashashmap.hxx>
using namespace ::com::sun::star;
@@ -81,6 +82,16 @@ namespace drawinglayer::unorenderer
const css::geometry::RealRectangle2D& Range,
::sal_uInt32 MaximumQuadraticPixels)
{
+ o3tl::Length eRangeUnit = o3tl::Length::mm100;
+ comphelper::SequenceAsHashMap aViewInformationMap(aViewInformationSequence);
+ auto it = aViewInformationMap.find("RangeUnit");
+ if (it != aViewInformationMap.end())
+ {
+ sal_Int32 nVal{};
+ it->second >>= nVal;
+ eRangeUnit = static_cast<o3tl::Length>(nVal);
+ }
+
uno::Reference< rendering::XBitmap > XBitmap;
if(aPrimitive2DSequence.hasElements())
@@ -107,9 +118,8 @@ namespace drawinglayer::unorenderer
}
const geometry::ViewInformation2D aViewInformation2D(aViewInformationSequence);
- const double fFactor100th_mmToInch(1.0 / (2.54 * 1000.0));
- const sal_uInt32 nDiscreteWidth(basegfx::fround((fWidth * fFactor100th_mmToInch) * DPI_X));
- const sal_uInt32 nDiscreteHeight(basegfx::fround((fHeight * fFactor100th_mmToInch) * DPI_Y));
+ const sal_uInt32 nDiscreteWidth(basegfx::fround(o3tl::convert(fWidth, eRangeUnit, o3tl::Length::in) * DPI_X));
+ const sal_uInt32 nDiscreteHeight(basegfx::fround(o3tl::convert(fHeight, eRangeUnit, o3tl::Length::in) * DPI_Y));
basegfx::B2DHomMatrix aEmbedding(
basegfx::utils::createTranslateB2DHomMatrix(
diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index 90b92411dfab..3057ea82b8b8 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -41,7 +41,8 @@ typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray;
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
const basegfx::B2DRange& rTargetRange,
- const sal_uInt32 nMaximumQuadraticPixels = 500000);
+ const sal_uInt32 nMaximumQuadraticPixels = 500000,
+ const o3tl::Length eTargetUnit = o3tl::Length::mm100);
enum class VectorGraphicDataType
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 1cf15c720a31..7d52431cd2b7 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -490,11 +490,20 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
if(!aRange.isEmpty())
{
+ o3tl::Length eRangeUnit = o3tl::Length::mm100;
+
+ if (GetModel()->IsWriter())
+ {
+ eRangeUnit = o3tl::Length::twip;
+ }
+
// if we have geometry and it has a range, convert to BitmapEx using
// common tooling
aBmp = convertPrimitive2DSequenceToBitmapEx(
xPrimitives,
- aRange);
+ aRange,
+ /*nMaximumQuadraticPixels=*/ 500000,
+ eRangeUnit);
}
}
}
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index b97cf7968640..1f5182ac6e4c 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1723,6 +1723,15 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNG)
// - Actual : image/x-vclgraphic
// i.e. the result was invalid ReqIF.
assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "type", "image/png");
+
+ // Then check the pixel size of the shape:
+ Size aPixelSize(Application::GetDefaultDevice()->LogicToPixel(Size(10000, 10000),
+ MapMode(MapUnit::Map100thMM)));
+ // Without the accompanying fix in place, this test would have failed with:
+ // - no attribute 'width' exist
+ // i.e. shapes had no width.
+ assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "width",
+ OUString::number(aPixelSize.getWidth()));
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index ed6d646594ee..8f6608097f07 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -933,12 +933,28 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
// "width" and/or "height"
// Only output SwFrameSize::Variable/SwFrameSize::Minimum if ANYSIZE is set
+ const SwFormatFrameSize* pFSItem = nullptr;
+ std::optional<SwFormatFrameSize> aFrameSize;
+ if (SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ))
+ {
+ pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
+ }
+ else if (const SdrObject* pObject = rFrameFormat.FindSdrObject())
+ {
+ // Write size for Draw shapes as well.
+ const tools::Rectangle& rSnapRect = pObject->GetSnapRect();
+ aFrameSize.emplace();
+ aFrameSize->SetWidthSizeType(SwFrameSize::Fixed);
+ aFrameSize->SetWidth(rSnapRect.getWidth());
+ aFrameSize->SetHeightSizeType(SwFrameSize::Fixed);
+ aFrameSize->SetHeight(rSnapRect.getHeight());
+ pFSItem = &*aFrameSize;
+ }
if( (nFrameOptions & HtmlFrmOpts::Size) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ) &&
+ pFSItem &&
( (nFrameOptions & HtmlFrmOpts::AnySize) ||
- SwFrameSize::Fixed == static_cast<const SwFormatFrameSize *>(pItem)->GetHeightSizeType()) )
+ SwFrameSize::Fixed == pFSItem->GetHeightSizeType()) )
{
- const SwFormatFrameSize *pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index 8430ebe2b289..b424d4dcd503 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -48,7 +48,8 @@ using namespace ::com::sun::star;
BitmapEx convertPrimitive2DSequenceToBitmapEx(
const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
const basegfx::B2DRange& rTargetRange,
- const sal_uInt32 nMaximumQuadraticPixels)
+ const sal_uInt32 nMaximumQuadraticPixels,
+ const o3tl::Length eTargetUnit)
{
BitmapEx aRetval;
@@ -61,7 +62,9 @@ BitmapEx convertPrimitive2DSequenceToBitmapEx(
uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer = graphic::Primitive2DTools::create(xContext);
- uno::Sequence< beans::PropertyValue > aViewParameters;
+ uno::Sequence< beans::PropertyValue > aViewParameters = {
+ comphelper::makePropertyValue("RangeUnit", static_cast<sal_Int32>(eTargetUnit)),
+ };
geometry::RealRectangle2D aRealRect;
aRealRect.X1 = rTargetRange.getMinX();