21#include <osl/endian.h>
37CGM::CGM(uno::Reference< frame::XModel >
const & rModel)
51 , mbPictureBody(false)
53 , mbFirstOutPut(false)
54 , mbInDefaultReplacement(false)
59 , mpEndValidSource(nullptr)
86 throw css::uno::Exception(
"attempt to read past end of input",
nullptr);
88 return ( pSource[ 0 ] << 8 ) + pSource[ 1 ];
93 return static_cast<sal_uInt8>( nSource >> ( ( nPrecision - 1 ) << 3 ) );
100 throw css::uno::Exception(
"attempt to read past end of input",
nullptr);
106 return static_cast<char>(*pSource);
111 return static_cast<sal_Int16
>( ( pSource[ 0 ] << 8 ) | pSource[ 1 ] );
116 return ( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | pSource[ 2 ] << 8 ) >> 8;
120 return static_cast<sal_Int32
>( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | ( pSource[ 2 ] << 8 ) | ( pSource[ 3 ] ) );
132 throw css::uno::Exception(
"attempt to read past end of input",
nullptr);
137 return static_cast<sal_Int8>(*pSource);
140 return static_cast<sal_uInt16
>( ( pSource[ 0 ] << 8 ) | pSource[ 1 ] );
144 return ( pSource[ 0 ] << 16 ) | ( pSource[ 1 ] << 8 ) | pSource[ 2 ];
148 return static_cast<sal_uInt32
>( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | ( pSource[ 2 ] << 8 ) | ( pSource[ 3 ] ) );
158 for (
int i = 0;
i < 4;
i++ )
160 pDest[
i ] = pSource[
i ^ 3 ];
166 for (
int i = 0;
i < 8;
i++ )
168 pDest[
i ] = pSource[
i ^ 7 ];
181 const bool bCompatible =
true;
183 const bool bCompatible =
false;
187 throw css::uno::Exception(
"attempt to read past end of input",
nullptr);
195 if ( nRealSize == 4 )
203 if ( nRealSize == 4 )
205 memcpy(
static_cast<void*
>(&fFloatBuf), pPtr, 4 );
206 nRetValue =
static_cast<double>(fFloatBuf);
210 memcpy(
static_cast<void*
>(&fDoubleBuf), pPtr, 8 );
211 nRetValue = fDoubleBuf;
217 const int nSwitch = bCompatible ? 0 : 1 ;
218 if ( nRealSize == 4 )
220 sal_uInt16* pShort =
static_cast<sal_uInt16*
>(pPtr);
221 nVal = pShort[ nSwitch ];
223 nVal |= pShort[ nSwitch ^ 1 ];
224 nRetValue =
static_cast<double>(nVal);
229 sal_Int32* pLong =
static_cast<sal_Int32*
>(pPtr);
230 nRetValue =
static_cast<double>(
abs( pLong[ nSwitch ] ));
232 nVal =
static_cast<sal_uInt32
>( pLong[ nSwitch ^ 1 ] );
234 nRetValue +=
static_cast<double>(nVal);
235 if ( pLong[ nSwitch ] < 0 )
237 nRetValue = -nRetValue;
249 return pElement->nVDCIntegerPrecision << 1;
342 sal_uInt32 nDiff =
pElement->nColorValueExtent[ 3 ] -
pElement->nColorValueExtent[ 0 ] + 1;
346 nColor = ( ( nColor -
pElement->nColorValueExtent[ 0 ] ) << 8 ) / nDiff;
347 nTmp = nColor << 16 & 0xff0000;
350 nDiff =
pElement->nColorValueExtent[ 4 ] -
pElement->nColorValueExtent[ 1 ] + 1;
353 nColor = ( ( nColor -
pElement->nColorValueExtent[ 1 ] ) << 8 ) / nDiff;
354 nTmp |= nColor << 8 & 0xff00;
357 nDiff =
pElement->nColorValueExtent[ 5 ] -
pElement->nColorValueExtent[ 2 ] + 1;
360 nColor = ( ( nColor -
pElement->nColorValueExtent[ 2 ] ) << 8 ) / nDiff;
426 switch (
pElement->eDeviceViewPortMode )
438 if (
pElement->nDeviceViewPortScale < 0 )
461 switch (
pElement->eDeviceViewPortMode )
473 if (
pElement->nDeviceViewPortScale < 0 )
496 switch (
pElement->eDeviceViewPortMode )
508 if (
pElement->nDeviceViewPortScale < 0 )
532 switch (
pElement->eDeviceViewPortMode )
545 if (
pElement->nDeviceViewPortScale < 0 )
547 rFloatPoint.
X = -rFloatPoint.
X;
548 rFloatPoint.
Y = -rFloatPoint.
Y;
597 SAL_WARN(
"filter.icgm",
"recursion in ImplDefaultReplacement");
687ImportCGM(
SvStream& rIn, uno::Reference< frame::XModel >
const & rXModel, css::uno::Reference<css::task::XStatusIndicator>
const & aXStatInd)
690 sal_uInt32 nStatus = 0;
704 sal_uInt32 nNext = 0;
705 sal_uInt32 nAdd = nInSize / 20;
706 bool bProgressBar = aXStatInd.is();
708 aXStatInd->start(
"CGM Import" , nInSize );
714 sal_uInt32 nCurrentPos = rIn.
Tell();
715 if ( nCurrentPos >= nNext )
717 aXStatInd->setValue( nCurrentPos );
718 nNext = nCurrentPos + nAdd;
722 if (!aCGM.
Write(rIn))
733 catch (
const css::uno::Exception&)
FILTER_DLLPUBLIC sal_uInt32 ImportCGM(SvStream &rIn, uno::Reference< frame::XModel > const &rXModel, css::uno::Reference< css::task::XStatusIndicator > const &aXStatInd)
void ImplGetRectangleNS(FloatRect &)
sal_uInt32 mnElementClass
void ImplMapPoint(FloatPoint &)
double ImplGetFloat(RealPrecision, sal_uInt32 nRealSize)
static void ImplGetSwitch4(const sal_uInt8 *pSource, sal_uInt8 *pDest)
static sal_uInt8 ImplGetByte(sal_uInt32 nSource, sal_uInt32 nPrecision)
sal_Int32 ImplGetI(sal_uInt32 nPrecision)
void ImplMapDouble(double &)
CGM(css::uno::Reference< css::frame::XModel > const &rModel)
sal_uInt32 ImplGetBitmapColor(bool bDirectColor=false)
void ImplGetPoint(FloatPoint &rFloatPoint, bool bMap=false)
void ImplGetRectangle(FloatRect &, bool bMap=false)
bool mbInDefaultReplacement
sal_uInt8 * mpEndValidSource
void ImplDefaultReplacement()
static void ImplGetSwitch8(const sal_uInt8 *pSource, sal_uInt8 *pDest)
::std::vector< std::unique_ptr< sal_uInt8[]> > maDefRepList
::std::vector< sal_uInt32 > maDefRepSizeList
std::unique_ptr< sal_uInt8[]> mpBuf
bool Write(SvStream &rIStm)
sal_uInt32 ImplGetUI(sal_uInt32 nPrecision)
std::unique_ptr< CGMElements > pCopyOfE
std::unique_ptr< CGMElements > pElement
sal_uInt32 ImplGetPointSize()
sal_uInt32 mnAct4PostReset
sal_uInt32 GetBackGroundColor() const
void SetEndian(SvStreamEndian SvStreamEndian)
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
sal_uInt64 remainingSize()
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN(area, stream)
Shape IDs per cluster in DGG atom.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
SwNodeOffset abs(const SwNodeOffset &a)