forked from amazingfate/loongoffice
for Writer objects, now added support for Paragraph and PageStyle (including Header and Footer) for direct attributes and style attributes (cherry picked from commit cc25c58f7052827bfebdc9fbeec668c8fa29ed1b) Conflicts: cui/source/factory/dlgfact.cxx cui/source/factory/dlgfact.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cuires.hrc cui/source/tabpages/bbdlg.cxx cui/source/tabpages/bbdlg.src cui/source/tabpages/page.cxx cui/source/tabpages/tparea.cxx include/svx/pagectrl.hxx include/svx/svxdlg.hxx include/svx/svxids.hrc include/xmloff/PageMasterStyleMap.hxx include/xmloff/prstylei.hxx include/xmloff/txtprmap.hxx svx/Package_inc.mk svx/inc/svx/hdft.hxx svx/source/dialog/hdft.cxx svx/source/dialog/pagectrl.cxx svx/source/tbxctrls/tbxcolorupdate.cxx svx/source/unodraw/unobrushitemhelper.cxx sw/Library_sw.mk sw/inc/fillattributes.hxx sw/inc/format.hxx sw/inc/frmatr.hxx sw/inc/frmfmt.hxx sw/inc/hintids.hxx sw/inc/hints.hxx sw/inc/ndtxt.hxx sw/inc/node.hxx sw/inc/swunohelper.hxx sw/inc/unobrushitemhelper.hxx sw/inc/unoprnms.hxx sw/source/core/attr/format.cxx sw/source/core/attr/hints.cxx sw/source/core/doc/docdesc.cxx sw/source/core/doc/docdraw.cxx sw/source/core/doc/docfmt.cxx sw/source/core/doc/docnew.cxx sw/source/core/doc/docredln.cxx sw/source/core/doc/poolfmt.cxx sw/source/core/doc/visiturl.cxx sw/source/core/docnode/node.cxx sw/source/core/inc/frame.hxx sw/source/core/inc/frmtool.hxx sw/source/core/inc/rolbck.hxx sw/source/core/layout/atrfrm.cxx sw/source/core/layout/fillattributes.cxx sw/source/core/layout/findfrm.cxx sw/source/core/layout/paintfrm.cxx sw/source/core/txtnode/ndtxt.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txtedt.cxx sw/source/core/undo/rolbck.cxx sw/source/core/unocore/swunohelper.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unomap.cxx sw/source/core/unocore/unoparagraph.cxx sw/source/core/unocore/unoprnms.cxx sw/source/core/unocore/unostyle.cxx sw/source/ui/chrdlg/paradlg.src sw/source/ui/chrdlg/pardlg.cxx sw/source/ui/fmtui/tmpdlg.cxx sw/source/ui/fmtui/tmpdlg.src sw/source/uibase/app/docst.cxx sw/source/uibase/app/docstyle.cxx sw/source/uibase/frmdlg/colex.cxx sw/source/uibase/shells/basesh.cxx sw/source/uibase/shells/textsh1.cxx sw/source/uibase/uiview/viewstat.cxx sw/source/uibase/utlui/uitool.cxx xmloff/inc/PageMasterImportContext.hxx xmloff/inc/xmloff/XMLShapeStyleContext.hxx xmloff/source/draw/XMLShapeStyleContext.cxx xmloff/source/draw/sdpropls.hxx xmloff/source/style/PageMasterExportPropMapper.cxx xmloff/source/style/PageMasterImportContext.cxx xmloff/source/style/PageMasterPropHdlFactory.cxx xmloff/source/style/PageMasterStyleMap.cxx xmloff/source/style/prstylei.cxx xmloff/source/text/txtexppr.cxx xmloff/source/text/txtprhdl.cxx xmloff/source/text/txtprmap.cxx xmloff/source/text/txtstyli.cxx Conflicts: svx/source/dialog/hdft.cxx sw/source/core/doc/visiturl.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txtatr2.cxx sw/source/core/unocore/unostyle.cxx Change-Id: I7e8779db6c0cbd1e242b63eab888f468f2de509a
402 lines
14 KiB
C++
402 lines
14 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#ifndef INCLUDED_VCL_BMPACC_HXX
|
|
#define INCLUDED_VCL_BMPACC_HXX
|
|
|
|
#include <tools/solar.h>
|
|
#include <vcl/dllapi.h>
|
|
#include <vcl/salbtype.hxx>
|
|
#include <vcl/bitmap.hxx>
|
|
|
|
|
|
// - Access defines -
|
|
#define DECL_FORMAT_GETPIXEL( Format ) \
|
|
static BitmapColor GetPixelFor##Format( ConstScanline pScanline, long nX, const ColorMask& rMask );
|
|
|
|
#define DECL_FORMAT_SETPIXEL( Format ) \
|
|
static void SetPixelFor##Format( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask );
|
|
|
|
#define DECL_FORMAT( Format ) \
|
|
DECL_FORMAT_GETPIXEL( Format ) \
|
|
DECL_FORMAT_SETPIXEL( Format )
|
|
|
|
#define IMPL_FORMAT_GETPIXEL( Format ) \
|
|
BitmapColor BitmapReadAccess::GetPixelFor##Format( ConstScanline pScanline, long nX, const ColorMask& rMask )
|
|
|
|
#define IMPL_FORMAT_GETPIXEL_NOMASK( Format ) \
|
|
BitmapColor BitmapReadAccess::GetPixelFor##Format( ConstScanline pScanline, long nX, const ColorMask& )
|
|
|
|
#define IMPL_FORMAT_SETPIXEL( Format ) \
|
|
void BitmapReadAccess::SetPixelFor##Format( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask )
|
|
|
|
#define IMPL_FORMAT_SETPIXEL_NOMASK( Format ) \
|
|
void BitmapReadAccess::SetPixelFor##Format( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& )
|
|
|
|
#define CASE_FORMAT( Format ) \
|
|
case( BMP_FORMAT##Format ): \
|
|
{ \
|
|
mFncGetPixel = GetPixelFor##Format;\
|
|
mFncSetPixel = SetPixelFor##Format;\
|
|
} \
|
|
break;
|
|
|
|
// - Access functions -
|
|
typedef BitmapColor (*FncGetPixel)( ConstScanline pScanline, long nX, const ColorMask& rMask );
|
|
typedef void (*FncSetPixel)( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask );
|
|
|
|
|
|
// - BitmapReadAccess -
|
|
class VCL_DLLPUBLIC BitmapReadAccess
|
|
{
|
|
friend class BitmapWriteAccess;
|
|
|
|
private:
|
|
|
|
BitmapReadAccess() {}
|
|
BitmapReadAccess( const BitmapReadAccess& ) {}
|
|
BitmapReadAccess& operator=( const BitmapReadAccess& ) { return *this; }
|
|
|
|
protected:
|
|
Bitmap maBitmap;
|
|
BitmapBuffer* mpBuffer;
|
|
Scanline* mpScanBuf;
|
|
ColorMask maColorMask;
|
|
FncGetPixel mFncGetPixel;
|
|
FncSetPixel mFncSetPixel;
|
|
bool mbModify;
|
|
|
|
|
|
SAL_DLLPRIVATE void ImplCreate( Bitmap& rBitmap );
|
|
SAL_DLLPRIVATE void ImplDestroy();
|
|
SAL_DLLPRIVATE bool ImplSetAccessPointers( sal_uLong nFormat );
|
|
|
|
public:
|
|
|
|
SAL_DLLPRIVATE void ImplZeroInitUnusedBits();
|
|
SAL_DLLPRIVATE BitmapBuffer* ImplGetBitmapBuffer() const { return mpBuffer; }
|
|
|
|
DECL_FORMAT( _1BIT_MSB_PAL )
|
|
DECL_FORMAT( _1BIT_LSB_PAL )
|
|
DECL_FORMAT( _4BIT_MSN_PAL )
|
|
DECL_FORMAT( _4BIT_LSN_PAL )
|
|
DECL_FORMAT( _8BIT_PAL )
|
|
DECL_FORMAT( _8BIT_TC_MASK )
|
|
DECL_FORMAT( _16BIT_TC_MSB_MASK )
|
|
DECL_FORMAT( _16BIT_TC_LSB_MASK )
|
|
DECL_FORMAT( _24BIT_TC_BGR )
|
|
DECL_FORMAT( _24BIT_TC_RGB )
|
|
DECL_FORMAT( _24BIT_TC_MASK )
|
|
DECL_FORMAT( _32BIT_TC_ABGR )
|
|
DECL_FORMAT( _32BIT_TC_ARGB )
|
|
DECL_FORMAT( _32BIT_TC_BGRA )
|
|
DECL_FORMAT( _32BIT_TC_RGBA )
|
|
DECL_FORMAT( _32BIT_TC_MASK )
|
|
protected:
|
|
BitmapReadAccess( Bitmap& rBitmap, bool bModify );
|
|
|
|
public:
|
|
BitmapReadAccess( Bitmap& rBitmap );
|
|
virtual ~BitmapReadAccess();
|
|
|
|
inline bool operator!() const;
|
|
|
|
inline long Width() const;
|
|
inline long Height() const;
|
|
inline Point TopLeft() const;
|
|
inline Point BottomRight() const;
|
|
|
|
inline bool IsTopDown() const;
|
|
inline bool IsBottomUp() const;
|
|
|
|
inline sal_uLong GetScanlineFormat() const;
|
|
inline sal_uLong GetScanlineSize() const;
|
|
|
|
inline sal_uInt16 GetBitCount() const;
|
|
inline BitmapColor GetBestMatchingColor( const BitmapColor& rBitmapColor );
|
|
|
|
inline Scanline GetBuffer() const;
|
|
inline Scanline GetScanline( long nY ) const;
|
|
|
|
inline bool HasPalette() const;
|
|
inline const BitmapPalette& GetPalette() const;
|
|
inline sal_uInt16 GetPaletteEntryCount() const;
|
|
inline const BitmapColor& GetPaletteColor( sal_uInt16 nColor ) const;
|
|
inline const BitmapColor& GetBestPaletteColor( const BitmapColor& rBitmapColor ) const;
|
|
sal_uInt16 GetBestPaletteIndex( const BitmapColor& rBitmapColor ) const;
|
|
|
|
inline bool HasColorMask() const;
|
|
inline ColorMask& GetColorMask() const;
|
|
|
|
inline BitmapColor GetPixelFromData( const sal_uInt8* pData, long nX ) const;
|
|
inline void SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor );
|
|
inline BitmapColor GetPixel( long nY, long nX ) const;
|
|
inline BitmapColor GetColor( long nY, long nX ) const;
|
|
inline sal_uInt8 GetPixelIndex( long nY, long nX ) const;
|
|
inline sal_uInt8 GetLuminance( long nY, long nX ) const;
|
|
|
|
/** Get the interpolated color at coordinates fY, fX; if outside, return rFallback */
|
|
BitmapColor GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const;
|
|
|
|
/** Get the color at coordinates fY, fX; if outside, return rFallback. Automatically does the correct
|
|
inside/outside checks, e.g. static_cast< sal_uInt32 >(-0.25) *is* 0, not -1 and has to be outside */
|
|
BitmapColor GetColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const;
|
|
};
|
|
|
|
// - BitmapWriteAccess -
|
|
class VCL_DLLPUBLIC BitmapWriteAccess : public BitmapReadAccess
|
|
{
|
|
public:
|
|
|
|
BitmapWriteAccess( Bitmap& rBitmap );
|
|
virtual ~BitmapWriteAccess();
|
|
|
|
void CopyScanline( long nY, const BitmapReadAccess& rReadAcc );
|
|
void CopyScanline( long nY, ConstScanline aSrcScanline,
|
|
sal_uLong nSrcScanlineFormat, sal_uLong nSrcScanlineSize );
|
|
|
|
void CopyBuffer( const BitmapReadAccess& rReadAcc );
|
|
|
|
inline void SetPalette( const BitmapPalette& rPalette );
|
|
inline void SetPaletteEntryCount( sal_uInt16 nCount );
|
|
inline void SetPaletteColor( sal_uInt16 nColor, const BitmapColor& rBitmapColor );
|
|
|
|
inline void SetPixel( long nY, long nX, const BitmapColor& rBitmapColor );
|
|
inline void SetPixelIndex( long nY, long nX, sal_uInt8 cIndex );
|
|
|
|
void SetLineColor( const Color& rColor );
|
|
|
|
void SetFillColor();
|
|
void SetFillColor( const Color& rColor );
|
|
|
|
void Erase( const Color& rColor );
|
|
|
|
void DrawLine( const Point& rStart, const Point& rEnd );
|
|
|
|
void FillRect( const Rectangle& rRect );
|
|
void DrawRect( const Rectangle& rRect );
|
|
|
|
private:
|
|
|
|
BitmapColor* mpLineColor;
|
|
BitmapColor* mpFillColor;
|
|
|
|
BitmapWriteAccess() {}
|
|
BitmapWriteAccess( const BitmapWriteAccess& ) : BitmapReadAccess() {}
|
|
BitmapWriteAccess& operator=( const BitmapWriteAccess& ) { return *this; }
|
|
};
|
|
|
|
// - Inlines -
|
|
inline bool BitmapReadAccess::operator!() const
|
|
{
|
|
return( mpBuffer == NULL );
|
|
}
|
|
|
|
inline long BitmapReadAccess::Width() const
|
|
{
|
|
return( mpBuffer ? mpBuffer->mnWidth : 0L );
|
|
}
|
|
|
|
inline long BitmapReadAccess::Height() const
|
|
{
|
|
return( mpBuffer ? mpBuffer->mnHeight : 0L );
|
|
}
|
|
|
|
inline Point BitmapReadAccess::TopLeft() const
|
|
{
|
|
return Point();
|
|
}
|
|
|
|
inline Point BitmapReadAccess::BottomRight() const
|
|
{
|
|
return Point( Width() - 1L, Height() - 1L );
|
|
}
|
|
|
|
inline bool BitmapReadAccess::IsTopDown() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return mpBuffer && ( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN );
|
|
}
|
|
|
|
inline bool BitmapReadAccess::IsBottomUp() const
|
|
{
|
|
return !IsTopDown();
|
|
}
|
|
|
|
inline sal_uLong BitmapReadAccess::GetScanlineFormat() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return( mpBuffer ? BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) : 0UL );
|
|
}
|
|
|
|
inline sal_uLong BitmapReadAccess::GetScanlineSize() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return( mpBuffer ? mpBuffer->mnScanlineSize : 0UL );
|
|
}
|
|
|
|
inline sal_uInt16 BitmapReadAccess::GetBitCount() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return( mpBuffer ? mpBuffer->mnBitCount : 0 );
|
|
}
|
|
|
|
inline BitmapColor BitmapReadAccess::GetBestMatchingColor( const BitmapColor& rBitmapColor )
|
|
{
|
|
if( HasPalette() )
|
|
return BitmapColor( (sal_uInt8) GetBestPaletteIndex( rBitmapColor ) );
|
|
else
|
|
return rBitmapColor;
|
|
}
|
|
|
|
inline Scanline BitmapReadAccess::GetBuffer() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return( mpBuffer ? mpBuffer->mpBits : NULL );
|
|
}
|
|
|
|
inline Scanline BitmapReadAccess::GetScanline( long nY ) const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
|
|
return( mpBuffer ? mpScanBuf[ nY ] : NULL );
|
|
}
|
|
|
|
inline bool BitmapReadAccess::HasPalette() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return( mpBuffer && !!mpBuffer->maPalette );
|
|
}
|
|
|
|
inline const BitmapPalette& BitmapReadAccess::GetPalette() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return mpBuffer->maPalette;
|
|
}
|
|
|
|
inline sal_uInt16 BitmapReadAccess::GetPaletteEntryCount() const
|
|
{
|
|
assert(HasPalette() && "Bitmap has no palette!");
|
|
return( HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0 );
|
|
}
|
|
|
|
inline const BitmapColor& BitmapReadAccess::GetPaletteColor( sal_uInt16 nColor ) const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
assert(HasPalette() && "Bitmap has no palette!");
|
|
return mpBuffer->maPalette[ nColor ];
|
|
}
|
|
|
|
inline const BitmapColor& BitmapReadAccess::GetBestPaletteColor( const BitmapColor& rBitmapColor ) const
|
|
{
|
|
return GetPaletteColor( GetBestPaletteIndex( rBitmapColor ) );
|
|
}
|
|
|
|
inline bool BitmapReadAccess::HasColorMask() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
const sal_uLong nFormat = BMP_SCANLINE_FORMAT( mpBuffer->mnFormat );
|
|
|
|
return( nFormat == BMP_FORMAT_8BIT_TC_MASK ||
|
|
nFormat == BMP_FORMAT_16BIT_TC_MSB_MASK ||
|
|
nFormat == BMP_FORMAT_16BIT_TC_LSB_MASK ||
|
|
nFormat == BMP_FORMAT_24BIT_TC_MASK ||
|
|
nFormat == BMP_FORMAT_32BIT_TC_MASK );
|
|
}
|
|
|
|
inline ColorMask& BitmapReadAccess::GetColorMask() const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
return mpBuffer->maColorMask;
|
|
}
|
|
|
|
inline BitmapColor BitmapReadAccess::GetPixel( long nY, long nX ) const
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
|
|
assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
|
|
return mFncGetPixel( mpScanBuf[ nY ], nX, maColorMask );
|
|
}
|
|
|
|
inline sal_uInt8 BitmapReadAccess::GetPixelIndex( long nY, long nX ) const
|
|
{
|
|
return GetPixel( nY, nX ).GetBlueOrIndex();
|
|
}
|
|
|
|
inline BitmapColor BitmapReadAccess::GetPixelFromData( const sal_uInt8* pData, long nX ) const
|
|
{
|
|
assert(pData && "Access is not valid!");
|
|
return mFncGetPixel( pData, nX, maColorMask );
|
|
}
|
|
|
|
inline void BitmapReadAccess::SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor )
|
|
{
|
|
assert(pData && "Access is not valid!");
|
|
mFncSetPixel( pData, nX, rBitmapColor, maColorMask );
|
|
}
|
|
|
|
inline BitmapColor BitmapReadAccess::GetColor( long nY, long nX ) const
|
|
{
|
|
if( HasPalette() )
|
|
return mpBuffer->maPalette[ GetPixelIndex( nY, nX ) ];
|
|
else
|
|
return GetPixel( nY, nX );
|
|
}
|
|
|
|
inline sal_uInt8 BitmapReadAccess::GetLuminance( long nY, long nX ) const
|
|
{
|
|
return GetColor( nY, nX ).GetLuminance();
|
|
}
|
|
|
|
inline void BitmapWriteAccess::SetPalette( const BitmapPalette& rPalette )
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
mpBuffer->maPalette = rPalette;
|
|
}
|
|
|
|
inline void BitmapWriteAccess::SetPaletteEntryCount( sal_uInt16 nCount )
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
mpBuffer->maPalette.SetEntryCount( nCount );
|
|
}
|
|
|
|
inline void BitmapWriteAccess::SetPaletteColor( sal_uInt16 nColor, const BitmapColor& rBitmapColor )
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
assert(HasPalette() && "Bitmap has no palette!");
|
|
mpBuffer->maPalette[ nColor ] = rBitmapColor;
|
|
}
|
|
|
|
inline void BitmapWriteAccess::SetPixel( long nY, long nX, const BitmapColor& rBitmapColor )
|
|
{
|
|
assert(mpBuffer && "Access is not valid!");
|
|
assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
|
|
assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
|
|
mFncSetPixel( mpScanBuf[ nY ], nX, rBitmapColor, maColorMask );
|
|
}
|
|
|
|
inline void BitmapWriteAccess::SetPixelIndex( long nY, long nX, sal_uInt8 cIndex )
|
|
{
|
|
SetPixel( nY, nX, BitmapColor( cIndex ));
|
|
}
|
|
|
|
#endif // INCLUDED_VCL_BMPACC_HXX
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|