21#include <com/sun/star/embed/XEmbedPersist.hpp>
22#include <com/sun/star/embed/Aspects.hpp>
23#include <com/sun/star/embed/ElementModes.hpp>
77 SAL_INFO(
"sw",
"WW8Export::OutputGrfNode( const SwGrfNode& )" );
88 OUString
const& rStorageName,
SwOLENode* pOLENd)
90 bool bGraphicNeeded =
false;
92 for (
auto pItem = aIter.
GetCurItem(); !bGraphicNeeded && pItem; pItem = aIter.
NextItem())
94 switch (pItem->Which())
111 bGraphicNeeded =
true;
125 bGraphicNeeded =
true;
130 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
152 std::unique_ptr<SvStream> pGraphicStream;
156 uno::Reference< embed::XEmbedPersist > xPersist(
158 uno::UNO_QUERY_THROW );
165 catch(
const uno::Exception& )
168 OSL_ENSURE( pGraphicStream && !pGraphicStream->GetError(),
"No graphic stream available!" );
169 if ( pGraphicStream && !pGraphicStream->GetError() )
181 bGraphicNeeded =
false;
189 bGraphicNeeded =
true;
190 return bGraphicNeeded;
195 SAL_INFO(
"sw",
"WW8Export::OutputOLENode( const SwOLENode& rOLENode )" );
200 0x03, 0x6a, 0, 0, 0, 0,
205 pSpecOLE = aSpecOLE_WW8;
206 nSize =
sizeof( aSpecOLE_WW8 );
207 pDataAdr = pSpecOLE + 2;
214 uno::Reference < embed::XEmbeddedObject > xObj(
const_cast<SwOLENode&
>(rOLENode).GetOLEObj().GetOleRef());
218 const embed::XEmbeddedObject *pObj = xObj.get();
224 WW8OleMap::value_type entry = std::make_pair(pObj, nPictureId);
225 std::pair<WW8OleMap::iterator, bool> aRes =
m_aOleMap.insert(entry);
226 bool bIsNotDuplicate = aRes.second;
227 nPictureId = aRes.first->second;
229 OUString sStorageName =
"_" + OUString::number( nPictureId );
240 sal_Int64 nAspect = rOLENode.
GetAspect();
242 m_oOLEExp->ExportOLEObject( aObjRef, *xOleStg );
243 if ( nAspect == embed::Aspects::MSOLE_ICON )
245 OUString aObjInfo(
"\3ObjInfo" );
246 if ( !xOleStg->IsStream( aObjInfo ) )
248 const sal_uInt8 pObjInfoData[] = { 0x40, 0x00, 0x03, 0x00 };
250 if ( rObjInfoStream.
is() && !rObjInfoStream->GetError() )
252 rObjInfoStream->WriteBytes(pObjInfoData,
sizeof(pObjInfoData));
279 bool bGraphicNeeded =
false;
283 bGraphicNeeded =
true;
291 xOleStg, xObjStg, sStorageName,
const_cast<SwOLENode*
>(&rOLENode));
319 uno::Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement(
"OLELinks", embed::ElementModes::READ );
324 if( !(xObjStg.
is() && xObjSrc.
is()) )
329 xObjSrc->CopyTo( xOleDst.
get() );
331 if ( xOleDst->GetError( ) )
337 std::unique_ptr<ww::bytes> pBuf(
new ww::bytes );
342 pBuf->push_back( 1 );
345 pBuf->push_back( 1 );
348 pBuf->push_back( 1 );
350 m_pChpPlc->AppendFkpEntry(
Strm().Tell(), pBuf->size(), pBuf->data() );
358 bool bURLStarted =
false;
392 if (eAn == RndStdIds::FLY_AS_CHAR)
395 if ((eVert == text::VertOrientation::CHAR_CENTER) || (eVert == text::VertOrientation::LINE_CENTER))
411 nHeight-=nFontHeight/20;
414 Set_UInt16( pArr, -
static_cast<sal_Int16
>(nHeight));
438 ( (eAn == RndStdIds::FLY_AT_PARA) ||
439 (eAn == RndStdIds::FLY_AT_PAGE) ) )
444 m_pO->insert(
m_pO->end(), nSty, nSty+2 );
469 const sal_uInt16 nWidth =
static_cast< sal_uInt16
>(aSize.
Width());
470 const sal_uInt16 nHeight =
static_cast< sal_uInt16
>(aSize.
Height());
471 maDetails.emplace_back(rFly, nWidth, nHeight);
475 sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight,
const SwAttrSet* pAttrSet)
477 sal_Int16 nXSizeAdd = 0, nYSizeAdd = 0;
478 sal_Int16 nCropL = 0, nCropR = 0, nCropT = 0, nCropB = 0;
482 if (pAttrSet && (pCropItem
485 nCropL =
static_cast<sal_Int16
>(pCropItem->
GetLeft());
486 nCropR =
static_cast<sal_Int16
>(pCropItem->
GetRight());
487 nCropT =
static_cast<sal_Int16
>(pCropItem->
GetTop());
488 nCropB =
static_cast<sal_Int16
>(pCropItem->
GetBottom());
489 nXSizeAdd = nXSizeAdd -
static_cast<sal_Int16
>( pCropItem->
GetLeft() + pCropItem->
GetRight() );
490 nYSizeAdd = nYSizeAdd -
static_cast<sal_Int16
>( pCropItem->
GetTop() + pCropItem->
GetBottom() );
494 sal_uInt16 nHdrLen = 0x44;
503 bool bShadow =
false;
506 bShadow = (pSI->GetLocation() != SvxShadowLocation::NONE) &&
507 (pSI->GetWidth() != 0);
510 static const SvxBoxItemLine aLnArr[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
511 SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
514 const ::editeng::SvxBorderLine* pLn = pBox->GetLine(
i );
519 pBox->GetDistance(
i ), bShadow );
532 case SvxBoxItemLine::TOP:
533 case SvxBoxItemLine::BOTTOM:
534 nHeight -= bShadow ? nThick*2 : nThick;
535 nHeight = nHeight - nSpacing;
537 case SvxBoxItemLine::LEFT:
538 case SvxBoxItemLine::RIGHT:
540 nWidth -= bShadow ? nThick*2 : nThick;
541 nWidth = nWidth - nSpacing;
544 memcpy( pArr, &aBrc.
aBits1, 2);
547 memcpy( pArr, &aBrc.
aBits2, 2);
562 const bool bIsSubstitutedSize = (aGrTwipSz.
Width() > SHRT_MAX) || (aGrTwipSz.
Height() > SHRT_MAX) ||
564 if ( bIsSubstitutedSize )
579 if ( aGrTwipSz.
Width() + nXSizeAdd )
581 if ( !bIsSubstitutedSize )
583 const double fVal = nWidth * 1000.0 / (aGrTwipSz.
Width() + nXSizeAdd );
584 Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
596 if ( aGrTwipSz.
Height() + nYSizeAdd )
598 if ( !bIsSubstitutedSize )
600 const double fVal = nHeight * 1000.0 / (aGrTwipSz.
Height() + nYSizeAdd);
601 Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
613 if ( !bIsSubstitutedSize )
625 const ww8::Frame &rFly, sal_uInt16 nWidth, sal_uInt16 nHeight)
632 sal_uInt16
const mm = 94;
638 RTL_TEXTENCODING_MS_1252);
651 sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight)
653 sal_Int16 nXSizeAdd = 0, nYSizeAdd = 0;
656 sal_uInt16 nHdrLen = 0x44;
662 static const SvxBoxItemLine aLnArr[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
663 SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
672 case SvxBoxItemLine::TOP:
673 case SvxBoxItemLine::BOTTOM:
675 nHeight = nHeight - nSpacing;
677 case SvxBoxItemLine::LEFT:
678 case SvxBoxItemLine::RIGHT:
681 nWidth = nWidth - nSpacing;
684 memcpy( pArr, &aBrc.
aBits1, 2);
687 memcpy(pArr, &aBrc.
aBits2, 2);
712 if( aGrTwipSz.
Width() + nXSizeAdd )
714 double fVal = nWidth * 1000.0 / (aGrTwipSz.
Width() + nXSizeAdd);
715 Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
720 if( aGrTwipSz.
Height() + nYSizeAdd )
722 double fVal = nHeight * 1000.0 / (aGrTwipSz.
Height() + nYSizeAdd);
723 Set_UInt16( pArr, o3tl::narrowing<sal_uInt16>(::rtl::math::round(fVal)) );
746 sal_uInt16 nWidth = rItem.
mnWid;
747 sal_uInt16 nHeight = rItem.
mnHei;
757 OSL_ENSURE(pNd,
"Impossible");
777 OSL_ENSURE(pNd,
"Impossible");
780#ifdef OLE_PREVIEW_AS_EMF
833 OSL_ENSURE(
false,
"Some inline export not implemented");
853 for (
auto aIter =
maDetails.begin(); aIter != aEnd; ++aIter)
859 auto aIter2 = std::find(
maDetails.begin(), aIter, *aIter);
862 aIter->mnPos = aIter2->mnPos;
constexpr auto convertTwipToMm100(N n)
static OutputDevice * GetDefaultDevice()
static GraphicFilter & GetGraphicFilter()
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
const GDIMetaFile & GetGDIMetaFile() const
virtual SwDrawModel * GetOrCreateDrawModel()=0
const sw::BroadcastingModify * m_pOutFormatNode
std::unique_ptr< SwWW8WrGrf > m_pGrf
const SfxPoolItem & GetItem(sal_uInt16 nWhich) const
std::optional< SvxMSExportOLEObjects > m_oOLEExp
const ww8::Frame * m_pParentFrame
void OutputFormat(const SwFormat &rFormat, bool bPapFormat, bool bChpFormat, bool bFlyFormat=false)
Output attributes.
std::unique_ptr< WW8_WrPlcPn > m_pPapPlc
std::unique_ptr< WW8_WrPlcPn > m_pChpPlc
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static SotStorage * OpenOLEStorage(css::uno::Reference< css::embed::XStorage > const &xStorage, OUString const &rEleName, StreamMode=StreamMode::STD_READWRITE)
SotStorage * OpenSotStorage(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE, bool transacted=true)
SotStorage & GetStorage() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
sal_Int32 GetRight() const
sal_Int32 GetLeft() const
sal_Int32 GetBottom() const
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)
tools::Long GetHeight() const
const SwFormatURL & GetURL(bool=true) const
const SwFormatAnchor & GetAnchor(bool=true) const
virtual void WritePictures()
sal_Int32 WriteOLEFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
void WriteEmptyFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
sal_Int32 WriteGrfFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
void WriteGrfBullet(const Graphic &)
const SwAttrSet * GetpSwAttrSet() const
css::uno::Reference< css::embed::XStorage > GetDocStorage()
bool IsInVerticalText(const SwPosition &rPos) const
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
bool IsLinkedFile() const
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Base class of the Writer document model elements.
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
sal_Int64 GetAspect() const
const SwOLEObj & GetOLEObj() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
static bool ImportOleWMF(const tools::SvRef< SotStorage > &xSrc1, GDIMetaFile &rWMF, tools::Long &rX, tools::Long &rY)
void WriteGraphicNode(SvStream &rStrm, const GraphicDetails &rItem)
void WriteGrfForBullet(SvStream &rStrm, const Graphic &rGrf, sal_uInt16 nWidth, sal_uInt16 nHeight)
void WriteGrfFromGrfNode(SvStream &rStrm, const SwGrfNode &rNd, const ww8::Frame &rFly, sal_uInt16 nWidth, sal_uInt16 nHeight)
WW8Export & m_rWrt
for access to the variables
static void WritePICBulletFHeader(SvStream &rStrm, const Graphic &rGrf, sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight)
static void WritePICFHeader(SvStream &rStrm, const ww8::Frame &rFly, sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight, const SwAttrSet *pAttrSet=nullptr)
std::vector< GraphicDetails > maDetails
void Insert(const ww8::Frame &rFly)
static void InsUInt32(ww::bytes &rO, sal_uInt32 n)
static void WriteString8(SvStream &rStrm, std::u16string_view rStr, bool bAddZero, rtl_TextEncoding eCodeSet)
static void FillCount(SvStream &rStrm, sal_uLong nCount)
static void InsUInt16(ww::bytes &rO, sal_uInt16 n)
virtual void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
std::unique_ptr< WW8AttributeOutput > m_pAttrOutput
Converting attributes to stream data.
virtual void OutputGrfNode(const SwGrfNode &) override
Output SwGrfNode.
void OutGrf(const ww8::Frame &rFrame)
SwWW8Writer * m_pWriter
Pointer to the writer.
virtual void OutputOLENode(const SwOLENode &) override
Output SwOLENode.
void WriteChar(sal_Unicode c) override
bool TestOleNeedsGraphic(const SwAttrSet &rSet, tools::SvRef< SotStorage > const &xOleStg, const tools::SvRef< SotStorage > &xObjStg, OUString const &rStorageName, SwOLENode *pOLENd)
SvStream * m_pDataStrm
Streams for WW97 Export.
static WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine &pLine, sal_uInt16 nDist, bool bShadow)
std::unique_ptr< WW8Fib > m_pFib
File Information Block.
virtual void OutputLinkedOLE(const OUString &) override
SwWW8Writer & GetWriter() const
std::unique_ptr< ww::bytes > m_pO
Buffer.
virtual void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner=ww8::WW8TableNodeInfoInner::Pointer_t()) override
const OUString & GetBaseURL() const
css::uno::Reference< css::io::XInputStream > GetGraphicStream(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString *pMediaType=nullptr)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
Make exporting a Writer Frame easy.
const Size & GetSize() const
The Size of the contained element.
const Size & GetLayoutSize() const
The layout size of the contained element.
const Graphic & GetGraphic() const
WriterSource GetWriterType() const
Get the type of frame that this wraps.
const SwFrameFormat & GetFrameFormat() const
Get the writer SwFrameFormat that this object describes.
const SwNode * GetContent() const
Get the first node of content in the frame.
bool IsInline() const
Is this frame inline (as character)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(113)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SwCropGrf > RES_GRFATR_CROPGRF(142)
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(101)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aObjectPool
::Color BGRToRGB(sal_uInt32 nColour)
sal_uInt8 TransColToIco(const Color &rCol)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::vector< sal_uInt8 > bytes
static constexpr sal_uInt16 val
Marks a position in the document model.
sal_uInt8 brcType() const
sal_uInt8 dptLineWidth() const
sal_uInt8 dptSpace() const
short DetermineBorderProperties(short *pSpace) const
VCL_DLLPUBLIC bool WriteWindowMetafileBits(SvStream &rStream, const GDIMetaFile &rMTF)
static sal_uInt8 nAttrMagicIdx
OUString FieldString(ww::eField eIndex)
void Set_UInt32(sal_uInt8 *&p, sal_uInt32 n)
void Set_UInt8(sal_uInt8 *&p, sal_uInt8 n)
void Set_UInt16(sal_uInt8 *&p, sal_uInt16 n)