72#include <rtl/string.hxx>
85#include <osl/thread.h>
93 , m_nCachedBaseLine(0)
107 sal_uInt16 strsize =
m_pObjStrm->QuickReaduInt16();
113 sal_uInt32 nServerContextSize =
m_pObjStrm->QuickReaduInt32();
114 if (nServerContextSize > 0)
116 sal_uInt16 nMaxPossibleSize =
m_pObjStrm->remainingSize();
118 if (nServerContextSize > nMaxPossibleSize)
120 SAL_WARN(
"lwp",
"stream too short for claimed no of records");
121 nServerContextSize = nMaxPossibleSize;
124 std::vector<unsigned char> aServerContext(nServerContextSize);
125 m_pObjStrm->QuickRead(aServerContext.data(),
static_cast<sal_uInt16
>(nServerContextSize));
126 if (nServerContextSize > 44)
143 if (nServerContextSize == 0)
146 strcmp(
reinterpret_cast<char *
>(
m_sDataFormat),
".sdw") == 0)
159 sal_uInt32 nFilterContextSize =
m_pObjStrm->QuickReaduInt32();
160 if (nFilterContextSize > 0)
162 sal_uInt16 nMaxPossibleSize =
m_pObjStrm->remainingSize();
164 if (nFilterContextSize > nMaxPossibleSize)
166 SAL_WARN(
"lwp",
"stream too short for claimed no of records");
167 nFilterContextSize = nMaxPossibleSize;
170 std::vector<unsigned char> aFilterContext(nFilterContextSize);
171 m_pObjStrm->QuickRead(aFilterContext.data(),
static_cast<sal_uInt16
>(nFilterContextSize));
208 pCont->
Add(vXFDrawObject.get());
223 pImage->
SetImageData(aGrafData.data(), aGrafData.size());
268 if (xMyLayout.is() && xMyLayout->IsFrame())
270 std::unique_ptr<XFFrameStyle> pXFFrameStyle(
new XFFrameStyle());
288 std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
295 std::string aGrfObjName;
299 std::vector<sal_uInt8>
aData = pBentoContainer->GetGraphicData(aGrfObjName.c_str());
314 sal_uInt16 nHigh = rMyID.
GetHigh();
315 sal_uInt32 nLow = rMyID.
GetLow();
317 rName = std::string(
"Gr");
319 rName.append(pTempStr);
328 std::vector<sal_uInt8> aGrafData;
334 std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
343 std::string aGrfObjName;
347 return pBentoContainer->GetGraphicData(aGrfObjName.c_str());
361 std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
370 std::string aGrfObjName;
373 OString sDName=OString::Concat(std::string_view(aGrfObjName)) +
"-D";
376 pGrafStream = pBentoContainer->FindValueStreamWithPropertyName(sDName.getStr());
378 std::unique_ptr<SvMemoryStream> pMemGrafStream(
static_cast<SvMemoryStream*
>(pGrafStream));
383 sal_uInt32 nDataLen = pGrafStream->
TellEnd();
385 pGrafData.reset(
new sal_uInt8 [nDataLen]);
386 pMemGrafStream->ReadBytes(pGrafData.get(), nDataLen);
402 std::unique_ptr<XFImageStyle> xImageStyle(
new XFImageStyle);
408 xImageStyle->SetBrightness(nSODCBrightness);
412 sal_Int32 nSODCContrast =
static_cast<sal_Int32
>(80 -
static_cast<double>(
m_aIPData.
nContrast)*1.6);
413 xImageStyle->SetContrast(nSODCContrast);
436 if (pMyScale && pFrameGeo)
438 if (fOrgGrafHeight == 0.0 || fOrgGrafWidth == 0.0)
446 double fDisFrameWidth = fFrameWidth - (fLeftMargin+fRightMargin);
447 double fDisFrameHeight = fFrameHeight - (fTopMargin+fBottomMargin);
450 double fSclGrafWidth = fOrgGrafWidth;
451 double fSclGrafHeight = fOrgGrafHeight;
463 fSclGrafWidth = fScalePercentage * fOrgGrafWidth;
464 fSclGrafHeight = fScalePercentage * fOrgGrafHeight;
470 fSclGrafWidth = fOrgGrafWidth;
471 fSclGrafHeight = fOrgGrafHeight;
475 if (fDisFrameHeight == 0.0)
477 if (fOrgGrafWidth/fOrgGrafHeight >= fDisFrameWidth/fDisFrameHeight)
479 fSclGrafWidth = fDisFrameWidth;
480 fSclGrafHeight = (fDisFrameWidth/fOrgGrafWidth) * fOrgGrafHeight;
484 fSclGrafHeight = fDisFrameHeight;
485 fSclGrafWidth = (fDisFrameHeight/fOrgGrafHeight) * fOrgGrafWidth;
490 fSclGrafWidth = fDisFrameWidth;
491 fSclGrafHeight = fDisFrameHeight;
496 double fXRatio = fSclGrafWidth / fOrgGrafWidth;
497 double fYRatio = fSclGrafHeight / fOrgGrafHeight;
500 pImage->SetWidth(fSclGrafWidth);
501 pImage->SetHeight(fSclGrafHeight);
511 double fClipWidth = 0;
512 double fClipHeight = 0;
513 bool sal_bCropped =
false;
514 if (fSclGrafWidth > fDisFrameWidth)
518 fClipWidth = (fSclGrafWidth-fDisFrameWidth ) / 2 / fXRatio;
523 if (fSclGrafHeight > fDisFrameHeight)
527 fClipHeight = (fSclGrafHeight-fDisFrameHeight ) / 2 / fYRatio;
533 xImageStyle->SetClip(fClipWidth, fClipWidth, fClipHeight, fClipHeight);
534 pImage->SetWidth(fDisFrameWidth);
535 pImage->SetHeight(fDisFrameHeight);
564 LwpRect(
double fL,
double fR,
double fT,
double fB)
572 LwpRect aFrameRect(-fOffsetX, (fDisFrameWidth-fOffsetX), (-fOffsetY), (fDisFrameHeight-fOffsetY));
573 LwpRect aImageRect(0, fSclGrafWidth, 0, fSclGrafHeight);
575 if (aFrameRect.fRight <= aImageRect.fLeft || aFrameRect.fLeft >= aImageRect.fRight
576 ||aFrameRect.fBottom <= aImageRect.fTop|| aFrameRect.fTop >= aImageRect.fBottom)
584 if (aFrameRect.fLeft > aImageRect.fLeft)
586 aCropRect.fLeft = (aFrameRect.fLeft - aImageRect.fLeft) / fXRatio;
589 if (aFrameRect.fRight < aImageRect.fRight)
591 aCropRect.fRight = (aImageRect.fRight - aFrameRect.fRight) / fXRatio;
595 if (aFrameRect.fTop > aImageRect.fTop)
597 aCropRect.fTop = (aFrameRect.fTop - aImageRect.fTop) / fYRatio;
599 if (aFrameRect.fBottom < aImageRect.fBottom)
601 aCropRect.fBottom = (aImageRect.fBottom - aFrameRect.fBottom) / fYRatio;
604 xImageStyle->SetClip(aCropRect.fLeft, aCropRect.fRight, aCropRect.fTop, aCropRect.fBottom);
605 double fPicWidth = fSclGrafWidth - (aCropRect.fLeft+aCropRect.fRight)*fXRatio;
606 double fPicHeight = fSclGrafHeight- (aCropRect.fTop+aCropRect.fBottom)*fYRatio;
607 double fX = fOffsetX > 0 ? fOffsetX : 0.00;
608 double fY = fOffsetY > 0 ? fOffsetY : 0.00;
609 pImage->SetPosition((fX+fLeftMargin), (fY+fTopMargin), fPicWidth, fPicHeight);
624 if ( !rHolder.
str().isEmpty() )
626 pImage->SetName(rHolder.
str());
639 std::unique_ptr<sal_uInt8[]> pGrafData;
646 pXFPara->
Add(
"Formula:");
656 sal_uInt32 nBegin = 45;
663 if (bOk && pGrafData[nEnd] ==
'$' && nEnd > 0 && pGrafData[nEnd-1] !=
'\\')
670 bOk &= nEnd >= nBegin;
673 std::unique_ptr<sal_uInt8[]> pEquData(
new sal_uInt8[nEnd - nBegin + 1] );
678 pXFNotePara->
Add(OUString(
reinterpret_cast<char*
>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
680 pXFNote->
Add(pXFNotePara);
682 pXFPara->
Add(pXFNote);
virtual OUString GetStyleName()=0
@descr: return the style name.
LwpObjectID & GetOnlyLayout()
AtomHolder class of Word Pro to hold a string.
const OUString & str() const
LwpAssociatedLayouts & GetLayoutsWithMe()
rtl::Reference< LwpVirtualLayout > GetLayout(LwpVirtualLayout const *pStartLayout)
LwpAtomHolder & GetName()
XFStyleManager * GetXFStyleManager()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
void CreateGrafObject()
@descr create xf-image object and save it in the container: m_vXFDrawObjects.
ImageProcessingData m_aIPData
void XFConvertEquation(XFContentContainer *pCont)
@descr Reserve the equation text in a note in the context.
OUString m_LinkedFilePath
virtual void XFConvert(XFContentContainer *pCont) override
@descr default XFConvert function pCont is the XFContentContainer for the object conversion
unsigned char m_sServerContextFormat[AFID_MAX_CONTEXT_FORMAT_SIZE]
std::vector< rtl::Reference< XFFrame > > m_vXFDrawObjects
LwpGraphicObject(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void RegisterStyle() override
@descr create drawing object and image object.
sal_Int32 m_nCachedBaseLine
static void GetBentoNamebyID(LwpObjectID const &rMyID, std::string &rName)
@descr create drawing object.
void Read() override
@descr: Read GraphicOleObject part
void GetGrafOrgSize(tools::Long &rWidth, tools::Long &rHeight)
virtual ~LwpGraphicObject() override
void CreateDrawObjects()
@descr create drawing object.
std::vector< sal_uInt8 > GetRawGrafData()
@descr get the image data read from bento stream according to the VO_GRAPHIC ID.
bool IsGrafFormatValid() const
@descr judge if the graphic format is what we can support: bmp, jpg, wmf, gif, tgf(tif).
sal_uInt32 GetGrafData(std::unique_ptr< sal_uInt8[]> &pGrafData)
@descr get the image data (only -D data) read from bento stream according to the VO_GRAPHIC ID.
unsigned char m_sDataFormat[AFID_MAX_FILE_FORMAT_SIZE]
@descr super class of LwpOleObject and LwpGraphicObject
virtual void Read() override
@descr: Read GraphicOleObject part
sal_Int32 GetHeight() const
sal_Int32 GetWidth() const
sal_uInt32 GetScalePercentage() const
sal_uInt16 GetScaleMode() const
sal_Int32 GetScaleWidth() const
sal_Int32 GetScaleHeight() const
sal_uInt16 GetScaleCenter()
LwpLayoutScale * GetLayoutScale()
sal_uInt16 GetScaleTile()
LwpLayoutGeometry * GetGeometry()
@descr: Get the geometry of current layout
sal_uInt16 GetHigh() const
rtl::Reference< LwpObject > obj(VO_TYPE tag=VO_INVALID) const
@descr get object from object factory per the object id
sal_uInt32 GetLow() const
std::unique_ptr< LwpObjectStream > m_pObjStrm
LwpObjectID & GetObjectID()
void CreateDrawObjects(std::vector< rtl::Reference< XFFrame > > *pDrawObjVector)
@descr entry of lwp-drawing objects.
encapsulate XInputStream to provide SvStream like interfaces
LwpSvStream * GetCompressedStream()
bool IsFitGraphic()
@descr: Whether the size of layout is fit the graphic
double GetMarginsValue(sal_uInt8 nWhichSide)
virtual sal_uInt64 TellEnd()
virtual void Add(XFContent *pContent)
@descr Add content.
Style for all frame objects.
void SetFileURL(const OUString &url)
@descr Use file link source.a
void SetImageData(sal_uInt8 const *buf, int len)
@descr Use base64 stream.
Paragraph object for SODC.
Style manager for the filter.
IXFStyleRet AddStyle(std::unique_ptr< IXFStyle > pStyle)
#define SAL_WARN(area, stream)
const sal_uInt8 MARGIN_BOTTOM
const sal_uInt8 MARGIN_RIGHT
const sal_uInt8 MARGIN_TOP
const sal_uInt8 MARGIN_LEFT
#define AFID_MAX_FILE_FORMAT_SIZE
sal_uLong BenOpenContainer(LwpSvStream *pStream, std::unique_ptr< LtcBenContainer > *ppContainer)
New bento container from file stream.
constexpr OUStringLiteral aData
int sprintf(char(&s)[N], char const *format, T &&... arguments)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
sal_uInt8 nEdgeEnhancement
unsigned long LinkedFileSize
unsigned long LinkedFileTime
@ enumXFFrameXPosFromLeft