BitmapEx->Bitmap in SdrExchangeView
now that Bitmap can handle transparency Change-Id: Id54be05c5d026bfc35d131ce62e496268ee0c8ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188660 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -1484,7 +1484,7 @@ void SvxLineTabPage::PopulateMenus()
|
||||
pObj->SetMergedItemSet(m_rOutAttrs);
|
||||
}
|
||||
aView.MarkAll();
|
||||
BitmapEx aBitmapEx(aView.GetMarkedObjBitmapEx());
|
||||
Bitmap aBitmap(aView.GetMarkedObjBitmap());
|
||||
GDIMetaFile aMeta(aView.GetMarkedObjMetaFile());
|
||||
aView.UnmarkAll();
|
||||
pPage->RemoveObject(1);
|
||||
@@ -1495,17 +1495,17 @@ void SvxLineTabPage::PopulateMenus()
|
||||
pInfo->sItemId = "symbol" + OUString::number(i);
|
||||
m_aSymbolBrushItems.emplace_back(pInfo);
|
||||
|
||||
Size aSize(aBitmapEx.GetSizePixel());
|
||||
Size aSize(aBitmap.GetSizePixel());
|
||||
if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
|
||||
{
|
||||
bool bWidth = aSize.Width() > aSize.Height();
|
||||
double nScale = bWidth ?
|
||||
double(MAX_BMP_WIDTH) / static_cast<double>(aSize.Width()):
|
||||
double(MAX_BMP_HEIGHT) / static_cast<double>(aSize.Height());
|
||||
aBitmapEx.Scale(nScale, nScale);
|
||||
aBitmap.Scale(nScale, nScale);
|
||||
}
|
||||
pVD->SetOutputSizePixel(aBitmapEx.GetSizePixel());
|
||||
pVD->DrawBitmapEx(Point(), aBitmapEx);
|
||||
pVD->SetOutputSizePixel(aBitmap.GetSizePixel());
|
||||
pVD->DrawBitmapEx(Point(), aBitmap);
|
||||
m_xSymbolsMenu->append(pInfo->sItemId, u""_ustr, *pVD);
|
||||
}
|
||||
pPage->RemoveObject(0);
|
||||
|
||||
@@ -395,6 +395,16 @@ BitmapEx convertPrimitive2DContainerToBitmapEx(primitive2d::Primitive2DContainer
|
||||
|
||||
return BitmapEx();
|
||||
}
|
||||
|
||||
Bitmap convertPrimitive2DContainerToBitmap(primitive2d::Primitive2DContainer&& rSequence,
|
||||
const basegfx::B2DRange& rTargetRange,
|
||||
sal_uInt32 nMaximumQuadraticPixels,
|
||||
const o3tl::Length eTargetUnit,
|
||||
const std::optional<Size>& rTargetDPI)
|
||||
{
|
||||
return Bitmap(convertPrimitive2DContainerToBitmapEx(std::move(rSequence), rTargetRange, nMaximumQuadraticPixels, eTargetUnit, rTargetDPI));
|
||||
}
|
||||
|
||||
} // end of namespace drawinglayer
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -50,6 +50,11 @@ BitmapEx DRAWINGLAYER_DLLPUBLIC convertPrimitive2DContainerToBitmapEx(
|
||||
const sal_uInt32 nMaximumQuadraticPixels = 500000,
|
||||
const o3tl::Length eTargetUnit = o3tl::Length::mm100,
|
||||
const std::optional<Size>& rTargetDPI = std::nullopt);
|
||||
Bitmap DRAWINGLAYER_DLLPUBLIC convertPrimitive2DContainerToBitmap(
|
||||
drawinglayer::primitive2d::Primitive2DContainer&& rSeq, const basegfx::B2DRange& rTargetRange,
|
||||
const sal_uInt32 nMaximumQuadraticPixels = 500000,
|
||||
const o3tl::Length eTargetUnit = o3tl::Length::mm100,
|
||||
const std::optional<Size>& rTargetDPI = std::nullopt);
|
||||
|
||||
} // end of namespace drawinglayer
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
// Draw all marked objects onto a bitmap, with the display's color depth
|
||||
// and resolution
|
||||
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked = false, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt) const;
|
||||
Bitmap GetMarkedObjBitmap(bool bNoVDevIfOneBmpMarked = false, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt) const;
|
||||
|
||||
// Copy all marked objects to a new model, consisting of exactly one page,
|
||||
// with the flag PageNotValid set. This means, that only the page's objects
|
||||
|
||||
@@ -84,6 +84,10 @@ bool VCL_DLLPUBLIC WriteDIBBitmapEx(
|
||||
const BitmapEx& rSource,
|
||||
SvStream& rOStm);
|
||||
|
||||
bool VCL_DLLPUBLIC WriteDIBBitmapEx(
|
||||
const Bitmap& rSource,
|
||||
SvStream& rOStm);
|
||||
|
||||
// needed in emfio for emf/wmf migration
|
||||
sal_uInt32 VCL_DLLPUBLIC getDIBV5HeaderSize();
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ bool ScDrawTransferObj::GetData( const css::datatransfer::DataFlavor& rFlavor, c
|
||||
if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
|
||||
bOK = SetGDIMetaFile( aView.GetMarkedObjMetaFile(true) );
|
||||
else
|
||||
bOK = SetBitmapEx( aView.GetMarkedObjBitmapEx(true), rFlavor );
|
||||
bOK = SetBitmapEx( BitmapEx(aView.GetMarkedObjBitmap(true)), rFlavor );
|
||||
}
|
||||
else if ( nFormat == SotClipboardFormatId::SVXB )
|
||||
{
|
||||
|
||||
@@ -508,7 +508,7 @@ bool SdTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
|
||||
const bool bToggleOnlineSpell = mpSdDrawDocumentIntern && mpSdDrawDocumentIntern->GetOnlineSpell();
|
||||
if (bToggleOnlineSpell)
|
||||
mpSdDrawDocumentIntern->SetOnlineSpell(false);
|
||||
bOK = SetBitmapEx( mpSdViewIntern->GetMarkedObjBitmapEx(true), rFlavor );
|
||||
bOK = SetBitmapEx( BitmapEx(mpSdViewIntern->GetMarkedObjBitmap(true)), rFlavor );
|
||||
if (bToggleOnlineSpell)
|
||||
mpSdDrawDocumentIntern->SetOnlineSpell(true);
|
||||
}
|
||||
|
||||
@@ -1772,7 +1772,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
|
||||
// switch on undo for the next operations
|
||||
mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_BITMAP));
|
||||
aGraphic = Graphic(mpDrawView->GetMarkedObjBitmapEx());
|
||||
aGraphic = Graphic(mpDrawView->GetMarkedObjBitmap());
|
||||
// Restore online spelling
|
||||
GetDoc()->SetOnlineSpell(bOnlineSpell);
|
||||
}
|
||||
|
||||
+3
-3
@@ -52,7 +52,7 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
BitmapEx aThumbBmp; // Allow transparence to survive
|
||||
Bitmap aThumbBmp; // Allow transparence to survive
|
||||
GDIMetaFile aThumbMtf;
|
||||
INetURLObject aURL;
|
||||
OUString aTitle;
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
virtual SgaObjKind GetObjKind() const = 0;
|
||||
virtual sal_uInt16 GetVersion() const = 0;
|
||||
|
||||
virtual BitmapEx GetThumbBmp() const { return aThumbBmp; }
|
||||
virtual Bitmap GetThumbBmp() const { return aThumbBmp; }
|
||||
const GDIMetaFile& GetThumbMtf() const { return aThumbMtf; }
|
||||
const INetURLObject& GetURL() const { return aURL; }
|
||||
bool IsValid() const { return bIsValid; }
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
virtual ~SgaObjectSound() override;
|
||||
|
||||
virtual SgaObjKind GetObjKind() const override { return SgaObjKind::Sound; }
|
||||
virtual BitmapEx GetThumbBmp() const override;
|
||||
virtual Bitmap GetThumbBmp() const override;
|
||||
};
|
||||
|
||||
class FmFormModel;
|
||||
|
||||
@@ -101,16 +101,16 @@ bool SgaObject::CreateThumb( const Graphic& rGraphic )
|
||||
|
||||
if( rGraphic.GetType() == GraphicType::Bitmap )
|
||||
{
|
||||
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
||||
Size aBmpSize( aBmpEx.GetSizePixel() );
|
||||
Bitmap aBmp( rGraphic.GetBitmapEx() );
|
||||
Size aBmpSize( aBmp.GetSizePixel() );
|
||||
|
||||
if( aBmpSize.Width() && aBmpSize.Height() )
|
||||
{
|
||||
if( aBmpEx.GetPrefMapMode().GetMapUnit() != MapUnit::MapPixel &&
|
||||
aBmpEx.GetPrefSize().Width() > 0 &&
|
||||
aBmpEx.GetPrefSize().Height() > 0 )
|
||||
if( aBmp.GetPrefMapMode().GetMapUnit() != MapUnit::MapPixel &&
|
||||
aBmp.GetPrefSize().Width() > 0 &&
|
||||
aBmp.GetPrefSize().Height() > 0 )
|
||||
{
|
||||
Size aLogSize( OutputDevice::LogicToLogic(aBmpEx.GetPrefSize(), aBmpEx.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) );
|
||||
Size aLogSize( OutputDevice::LogicToLogic(aBmp.GetPrefSize(), aBmp.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) );
|
||||
|
||||
if( !aLogSize.IsEmpty() )
|
||||
{
|
||||
@@ -122,12 +122,12 @@ bool SgaObject::CreateThumb( const Graphic& rGraphic )
|
||||
else
|
||||
aBmpSize.setHeight( basegfx::fround<tools::Long>( aBmpSize.Width() / fFactorLog ) );
|
||||
|
||||
aBmpEx.Scale(aBmpSize, BmpScaleFlag::BestQuality);
|
||||
aBmp.Scale(aBmpSize, BmpScaleFlag::BestQuality);
|
||||
}
|
||||
}
|
||||
|
||||
// take over BitmapEx
|
||||
aThumbBmp = aBmpEx;
|
||||
// take over Bitmap
|
||||
aThumbBmp = aBmp;
|
||||
|
||||
if( ( aBmpSize.Width() <= S_THUMB ) && ( aBmpSize.Height() <= S_THUMB ) )
|
||||
{
|
||||
@@ -161,7 +161,7 @@ bool SgaObject::CreateThumb( const Graphic& rGraphic )
|
||||
aSize.setHeight( static_cast<sal_Int32>( S_THUMB / fFactor ) );
|
||||
|
||||
const GraphicConversionParameters aParameters(aSize, false, true, true /*TODO: extra ", true" post-#i121194#*/);
|
||||
aThumbBmp = rGraphic.GetBitmapEx(aParameters);
|
||||
aThumbBmp = Bitmap(rGraphic.GetBitmapEx(aParameters));
|
||||
|
||||
if( !aThumbBmp.IsEmpty() )
|
||||
{
|
||||
@@ -324,7 +324,7 @@ SgaObjectSound::~SgaObjectSound()
|
||||
{
|
||||
}
|
||||
|
||||
BitmapEx SgaObjectSound::GetThumbBmp() const
|
||||
Bitmap SgaObjectSound::GetThumbBmp() const
|
||||
{
|
||||
OUString sId;
|
||||
|
||||
@@ -346,7 +346,7 @@ BitmapEx SgaObjectSound::GetThumbBmp() const
|
||||
|
||||
const BitmapEx aBmpEx(sId);
|
||||
|
||||
return aBmpEx;
|
||||
return Bitmap(aBmpEx);
|
||||
}
|
||||
|
||||
void SgaObjectSound::WriteData( SvStream& rOut, const OUString& rDestDir ) const
|
||||
@@ -466,7 +466,7 @@ bool SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel )
|
||||
|
||||
aView.ShowSdrPage(const_cast< FmFormPage* >(pPage));
|
||||
aView.MarkAllObj();
|
||||
aThumbBmp = aView.GetMarkedObjBitmapEx(true);
|
||||
aThumbBmp = aView.GetMarkedObjBitmap(true);
|
||||
aGraphic = Graphic(aThumbBmp);
|
||||
bRet = SgaObject::CreateThumb(aGraphic);
|
||||
}
|
||||
|
||||
@@ -422,9 +422,9 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
|
||||
}
|
||||
}
|
||||
|
||||
BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const sal_uInt32 nMaximumQuadraticPixels, const std::optional<Size>& rTargetDPI) const
|
||||
Bitmap SdrExchangeView::GetMarkedObjBitmap(bool bNoVDevIfOneBmpMarked, const sal_uInt32 nMaximumQuadraticPixels, const std::optional<Size>& rTargetDPI) const
|
||||
{
|
||||
BitmapEx aBmp;
|
||||
Bitmap aBmp;
|
||||
|
||||
const SdrMarkList& rMarkList = GetMarkedObjectList();
|
||||
if(1 == rMarkList.GetMarkCount())
|
||||
@@ -435,12 +435,12 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const
|
||||
if(bNoVDevIfOneBmpMarked)
|
||||
{
|
||||
if (pGrafObj->GetGraphicType() == GraphicType::Bitmap)
|
||||
aBmp = pGrafObj->GetTransformedGraphic().GetBitmapEx();
|
||||
aBmp = Bitmap(pGrafObj->GetTransformedGraphic().GetBitmapEx());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGrafObj->isEmbeddedVectorGraphicData())
|
||||
aBmp = pGrafObj->GetGraphic().getVectorGraphicData()->getReplacement();
|
||||
aBmp = Bitmap(pGrafObj->GetGraphic().getVectorGraphicData()->getReplacement());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const
|
||||
|
||||
// if we have geometry and it has a range, convert to BitmapEx using
|
||||
// common tooling
|
||||
aBmp = drawinglayer::convertPrimitive2DContainerToBitmapEx(
|
||||
aBmp = drawinglayer::convertPrimitive2DContainerToBitmap(
|
||||
std::move(xPrimitives),
|
||||
aRange,
|
||||
nMaximumQuadraticPixels,
|
||||
|
||||
@@ -1324,7 +1324,7 @@ bool SwFEShell::GetDrawObjGraphic( SotClipboardFormatId nFormat, Graphic& rGrf )
|
||||
else if( SotClipboardFormatId::GDIMETAFILE == nFormat )
|
||||
rGrf = Imp()->GetDrawView()->GetMarkedObjMetaFile();
|
||||
else if( SotClipboardFormatId::BITMAP == nFormat || SotClipboardFormatId::PNG == nFormat )
|
||||
rGrf = Imp()->GetDrawView()->GetMarkedObjBitmapEx();
|
||||
rGrf = Imp()->GetDrawView()->GetMarkedObjBitmap();
|
||||
}
|
||||
return bConvert;
|
||||
}
|
||||
|
||||
@@ -8203,7 +8203,7 @@ Graphic SwDrawFrameFormat::MakeGraphic( ImageMap*, const sal_uInt32 nMaximumQuad
|
||||
SdrView aView( *pMod );
|
||||
SdrPageView *pPgView = aView.ShowSdrPage(aView.GetModel().GetPage(0));
|
||||
aView.MarkObj( pObj, pPgView );
|
||||
aRet = aView.GetMarkedObjBitmapEx(/*bNoVDevIfOneBmpMarked=*/false, nMaximumQuadraticPixels, rTargetDPI);
|
||||
aRet = aView.GetMarkedObjBitmap(/*bNoVDevIfOneBmpMarked=*/false, nMaximumQuadraticPixels, rTargetDPI);
|
||||
aView.HideSdrPage();
|
||||
}
|
||||
return aRet;
|
||||
|
||||
@@ -1820,6 +1820,13 @@ bool WriteDIBBitmapEx(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WriteDIBBitmapEx(
|
||||
const Bitmap& rSource,
|
||||
SvStream& rOStm)
|
||||
{
|
||||
return WriteDIBBitmapEx(BitmapEx(rSource), rOStm);
|
||||
}
|
||||
|
||||
sal_uInt32 getDIBV5HeaderSize()
|
||||
{
|
||||
return DIBV5HEADERSIZE;
|
||||
|
||||
Reference in New Issue
Block a user