23#include <com/sun/star/embed/XClassifiedObject.hpp>
24#include <com/sun/star/embed/Aspects.hpp>
27#include <osl/endian.h>
29#include <com/sun/star/drawing/XShape.hpp>
35#include <osl/diagnose.h>
83 StreamMode::STD_READ );
85 pS->SetEndian( SvStreamEndian::LITTLE );
87 OSL_ENSURE(
pS->TellEnd() >= 76,
"+OLE-PIC-Stream is shorter than 76 Byte" );
98 pS->ReadInt32( nOrgWidth )
99 .ReadInt32( nOrgHeight );
101 pS->ReadInt32( nScaleX )
102 .ReadInt32( nScaleY )
103 .ReadInt32( nCropLeft )
104 .ReadInt32( nCropTop )
105 .ReadInt32( nCropRight )
106 .ReadInt32( nCropBottom );
108 rX = nOrgWidth - nCropLeft - nCropRight;
109 rY = nOrgHeight - nCropTop - nCropBottom;
110 if (10 > nScaleX || 65536 < nScaleX || 10 > nScaleY || 65536 < nScaleY)
112 OSL_ENSURE( !
pS,
"+OLE-scaling information in PIC-stream wrong" );
117 rX = (rX * nScaleX) / 1000;
118 rY = (rY * nScaleY) / 1000;
127 StreamMode::STD_READ );
129 pSt->SetEndian( SvStreamEndian::LITTLE );
130 size_t const nRead = pSt->ReadBytes(pMfp,
sizeof(*pMfp));
132 if (nRead !=
sizeof(*pMfp))
135#if defined OSL_BIGENDIAN
136 pMfp->mm = OSL_SWAPWORD( pMfp->mm );
137 pMfp->xExt = OSL_SWAPWORD( pMfp->xExt );
138 pMfp->yExt = OSL_SWAPWORD( pMfp->yExt );
141 if( pMfp->mm == 94 || pMfp->mm == 99 )
143 SAL_WARN(
"sw.ww8",
"+OLE: wrong metafile type");
148 SAL_WARN(
"sw.ww8",
"OLE: wrong mMetafile type (not anisotropic)");
150 if( !pMfp->xExt || !pMfp->yExt )
152 SAL_WARN(
"sw.ww8",
"+OLE: size of 0?");
159 SAL_WARN(
"sw.ww8",
"+OLE: could not read the metafile");
167 Size aNewSiz( pMfp->xExt, pMfp->yExt );
171 rWMF.
Scale( aFracX, aFracY );
182 pStp->SetEndian( SvStreamEndian::LITTLE );
184 size_t const nReadTst = pStp->ReadBytes(aTestA,
sizeof(aTestA));
185 if (nReadTst !=
sizeof(aTestA))
199 OSL_ENSURE(pPersist,
"No persist, cannot insert objects correctly");
205 std::optional<SfxItemSet> pMathFlySet;
206 uno::Reference < embed::XClassifiedObject > xClass = rObject.
GetObjRef();
214 pMathFlySet.emplace(rFlySet);
230 OSL_ENSURE(bSuccess,
"Insert OLE failed");
233 const SfxItemSet *pFlySet = pMathFlySet ? &*pMathFlySet : &rFlySet;
251 std::optional<SfxItemSet> pTempSet;
257 pFlySet = &*pTempSet;
264 pTempSet->Put( aAnchor );
271 pTempSet->Put(
SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
285 pFormat =
InsertOle(*pOleObj, *pFlySet, pGrfSet);
292 GraphicType::GdiMetafile == aGraph.
GetType() ||
293 GraphicType::Bitmap == aGraph.
GetType()
297 *
m_pPaM, OUString(), OUString(), &aGraph, pFlySet,
312 Size aFinalSize, aOrigSize;
320 rWMF.
Scale( aScaleX, aScaleY );
331 SAL_WARN(
"sw.ww8",
"no storage for ole objects");
341 OUString aSrcStgName =
"_" + OUString::number(
m_nObjLocFc );
351 nX = aSizeTwip.
Width();
365 nX = aSizeTwip.
Width();
378 aRect.
SetSize(pSize->GetSize());
387 uno::Reference< drawing::XShape > xRef;
392 OSL_ENSURE(pRet,
"Impossible");
394 pRet->SetLogicRect(aRect);
399 if (GraphicType::GdiMetafile == rGraph.
GetType() ||
400 GraphicType::Bitmap == rGraph.
GetType())
408 if (m_nObjLocFc < m_pDataStream->TellEnd())
414 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
418 StreamMode::STD_READ );
419 if ( xObjInfoSrc.
is() && !xObjInfoSrc->GetError() )
422 xObjInfoSrc->ReadUChar( nByte );
423 if ( ( nByte >> 4 ) & embed::Aspects::MSOLE_ICON )
424 nAspect = embed::Aspects::MSOLE_ICON;
453 std::vector<OUString> aAuthorNames;
457 sal_uInt16
nCount =
static_cast< sal_uInt16
>(aAuthorNames.size());
458 for( sal_uInt16 nAuthor = 0; nAuthor <
nCount; ++nAuthor )
480 if( RedlineType::Format ==
eType )
482 pSprmCIbstRMark = nLen >= 3 ?
pData+1 :
nullptr;
483 pSprmCDttmRMark = nLen >= 7 ?
pData+3 :
nullptr;
491 std::vector<SprmResult> aResult;
492 bool bIns = (RedlineType::Insert ==
eType);
496 pSprmCIbstRMark = (aResult.empty() || aResult.back().nRemainingData < 2) ?
nullptr : aResult.back().pSprm;
499 pSprmCDttmRMark = (aResult.empty() || aResult.back().nRemainingData < 4) ?
nullptr : aResult.back().pSprm;
503 m_xPlcxMan->HasCharSprm( bIns ? 0x4804 : 0x4863, aResult);
504 pSprmCIbstRMark = (aResult.empty() || aResult.back().nRemainingData < 2) ?
nullptr : aResult.back().pSprm;
507 pSprmCDttmRMark = (aResult.empty() || aResult.back().nRemainingData < 4) ?
nullptr : aResult.back().pSprm;
516 sal_uInt16 nWWAutNo = pSprmCIbstRMark ? SVBT16ToUInt16(pSprmCIbstRMark) : 0;
517 sal_uInt32 nWWDate = pSprmCDttmRMark ? SVBT32ToUInt32(pSprmCDttmRMark): 0;
static sal_uInt8 nTablePos
GraphicType GetType() const
MapMode GetPrefMapMode() const
virtual SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet)=0
Insert a DrawObject.
virtual SwFlyFrameFormat * InsertOLE(const SwPaM &rRg, const OUString &rObjName, sal_Int64 nAspect, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet)=0
virtual SwFlyFrameFormat * InsertGraphic(const SwPaM &rRg, const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet, SwFrameFormat *)=0
Insert graphic or formula.
virtual std::size_t InsertRedlineAuthor(const OUString &rAuthor)=0
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
css::uno::Reference< css::embed::XStorage > const & GetStorage()
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static sal_uInt16 IsMath(const SvGlobalName &rName)
SotStorage * OpenSotStorage(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE, bool transacted=true)
sal_uInt64 Seek(sal_uInt64 nPos)
static rtl::Reference< SdrOle2Obj > CreateSdrOLEFromStorage(SdrModel &rSdrModel, const OUString &rStorageName, tools::SvRef< SotStorage > const &rSrcStorage, const css::uno::Reference< css::embed::XStorage > &xDestStg, const Graphic &rGraf, const tools::Rectangle &rBoundRect, const tools::Rectangle &rVisArea, SvStream *pDataStrrm, ErrCode &rError, sal_uInt32 nConvertFlags, sal_Int64 nAspect, OUString const &rBaseURL)
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
SfxObjectShell * GetPersist() const
const SwAttrPool & GetAttrPool() const
SwDocShell * GetDocShell()
static sal_uInt32 GetFilterFlags()
const SwPosition * GetPoint() const
static bool ImportOleWMF(const tools::SvRef< SotStorage > &xSrc1, GDIMetaFile &rWMF, tools::Long &rX, tools::Long &rY)
std::unique_ptr< SwMSConvertControls > m_xFormImpl
SwFrameFormat * ImportOle(const Graphic *=nullptr, const SfxItemSet *pFlySet=nullptr, const SfxItemSet *pGrfSet=nullptr, const tools::Rectangle &aVisArea=tools::Rectangle())
std::unique_ptr< WW8SwFlyPara > m_xSFlyPara
SwFlyFrameFormat * InsertOle(SdrOle2Obj &rObject, const SfxItemSet &rFlySet, const SfxItemSet *rGrfSet)
const OUString & GetBaseURL() const
void ReadRevMarkAuthorStrTabl(SvStream &rStrm, sal_Int32 nTablePos, sal_Int32 nTableSiz, SwDoc &rDoc)
rtl::Reference< SdrObject > ImportOleBase(Graphic &rGraph, const Graphic *pGrf=nullptr, const SfxItemSet *pFlySet=nullptr, const tools::Rectangle &aVisArea=tools::Rectangle())
std::shared_ptr< WW8PLCFMan > m_xPlcxMan
void Read_CPropRMark(sal_uInt16, const sal_uInt8 *pData, short nLen)
std::map< sal_uInt16, std::size_t > m_aAuthorInfos
Redlining Authors, map word author key to writer author value.
void Read_CFRMarkDel(sal_uInt16, const sal_uInt8 *pData, short nLen)
std::unique_ptr< WW8TabDesc > m_xTableDesc
void Read_CFRMark(sal_uInt16, const sal_uInt8 *pData, short nLen)
rtl_TextEncoding m_eStructCharSet
void NewAttr(const SfxPoolItem &rAttr, const bool bFirstLineOfStSet=false, const bool bLeftIndentSet=false)
std::unique_ptr< sw::util::RedlineStack > m_xRedlineStack
static bool GetPictGrafFromStream(Graphic &rGraphic, SvStream &rSrc)
void Read_CRevisionMark(RedlineType eType, const sal_uInt8 *pData, short nLen)
Make inserting an OLE object into a Writer document easy.
bool TransferToDoc(OUString &rName)
Transfer ownership of the OLE object to a document's SvPersist.
@ Fixed
Frame cannot be moved in Var-direction.
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr sal_uInt16 RES_FRMATR_END(141)
#define SAL_WARN(area, stream)
void SetProgressState(tools::Long nPosition, SwDocShell const *pDocShell)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aObjectPool
DateTime DTTM2DateTime(tools::Long lDTTM)
static constexpr auto Items
#define STREAM_SEEK_TO_BEGIN
static constexpr sal_uInt16 val
VCL_DLLPUBLIC bool ReadWindowMetafile(SvStream &rStream, GDIMetaFile &rMTF)
static bool SwWw6ReadMetaStream(GDIMetaFile &rWMF, OLE_MFP *pMfp, tools::SvRef< SotStorage > const &rSrc1)
static bool SwWw8ReadScaling(tools::Long &rX, tools::Long &rY, tools::SvRef< SotStorage > const &rSrc1)
static bool SwWw6ReadMacPICTStream(Graphic &rGraph, tools::SvRef< SotStorage > const &rSrc1)
void WW8ReadSTTBF(bool bVer8, SvStream &rStrm, sal_uInt32 nStart, sal_Int32 nLen, sal_uInt16 nExtraLen, rtl_TextEncoding eCS, std::vector< OUString > &rArray, std::vector< ww::bytes > *pExtraArray, std::vector< OUString > *pValueArray)
reads array of strings (see MS documentation: String Table stored in File) returns NOT the original p...