diff options
Diffstat (limited to 'svx/source/xoutdev')
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 768 | ||||
-rw-r--r-- | svx/source/xoutdev/_xpoly.cxx | 2135 | ||||
-rw-r--r-- | svx/source/xoutdev/makefile.mk | 59 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 5778 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr2.cxx | 1712 | ||||
-rw-r--r-- | svx/source/xoutdev/xattrbmp.cxx | 894 | ||||
-rw-r--r-- | svx/source/xoutdev/xexch.cxx | 204 | ||||
-rw-r--r-- | svx/source/xoutdev/xpool.cxx | 235 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabbtmp.cxx | 294 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabcolr.cxx | 548 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabdash.cxx | 378 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabgrdt.cxx | 372 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabhtch.cxx | 374 | ||||
-rw-r--r-- | svx/source/xoutdev/xtable.cxx | 511 | ||||
-rw-r--r-- | svx/source/xoutdev/xtablend.cxx | 395 |
15 files changed, 14657 insertions, 0 deletions
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx new file mode 100644 index 000000000000..1f9bec471c8f --- /dev/null +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -0,0 +1,768 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <sot/factory.hxx> +#include <tools/urlobj.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/bmpacc.hxx> +#include <tools/poly.hxx> +#include <vcl/virdev.hxx> +#include <vcl/wrkwin.hxx> +#include <svl/solar.hrc> +#include <sfx2/docfile.hxx> +#include <sfx2/app.hxx> +#include "xoutbmp.hxx" +#include <svtools/FilterConfigItem.hxx> +#include <svtools/filter.hxx> + +// ----------- +// - Defines - +// ----------- + +#define FORMAT_BMP String(RTL_CONSTASCII_USTRINGPARAM("bmp")) +#define FORMAT_GIF String(RTL_CONSTASCII_USTRINGPARAM("gif")) +#define FORMAT_JPG String(RTL_CONSTASCII_USTRINGPARAM("jpg")) +#define FORMAT_PNG String(RTL_CONSTASCII_USTRINGPARAM("png")) + +// -------------- +// - XOutBitmap - +// -------------- + +GraphicFilter* XOutBitmap::pGrfFilter = NULL; + +// ----------------------------------------------------------------------------- + +BitmapEx XOutBitmap::CreateQuickDrawBitmapEx( const Graphic& rGraphic, const OutputDevice& rCompDev, + const MapMode& rMapMode, const Size& rLogSize, + const Point& rPoint, const Size& rSize ) +{ + BitmapEx aRetBmp; + + if( rGraphic.IsAlpha() ) + aRetBmp = rGraphic.GetBitmapEx(); + else + { + VirtualDevice aVDev( rCompDev ); + MapMode aMap( rMapMode ); + + aMap.SetOrigin( Point() ); + aVDev.SetMapMode( aMap ); + + Point aPoint( aVDev.LogicToPixel( rPoint ) ); + Size aOldSize( aVDev.LogicToPixel( rSize ) ); + Size aAbsSize( aOldSize ); + Size aQSizePix( aVDev.LogicToPixel( rLogSize ) ); + + aVDev.SetMapMode( MapMode() ); + + if( aOldSize.Width() < 0 ) + aAbsSize.Width() = -aAbsSize.Width(); + + if( aOldSize.Height() < 0 ) + aAbsSize.Height() = -aAbsSize.Height(); + + if( aVDev.SetOutputSizePixel( aAbsSize ) ) + { + Point aNewOrg( -aPoint.X(), -aPoint.Y() ); + const Point aNullPoint; + + // horizontale Spiegelung ggf. beruecksichtigen + if( aOldSize.Width() < 0 ) + { + aNewOrg.X() -= aOldSize.Width(); + + // und jetzt noch einen abziehen + aNewOrg.X()--; + } + + // vertikale Spiegelung ggf. beruecksichtigen + if( rSize.Height() < 0 ) + { + aNewOrg.Y() -= aOldSize.Height(); + + // und jetzt noch einen abziehen + aNewOrg.Y()--; + } + + if( rGraphic.GetType() != GRAPHIC_BITMAP ) + { + rGraphic.Draw( &aVDev, aNewOrg, aQSizePix ); + + const Bitmap aBmp( aVDev.GetBitmap( aNullPoint, aAbsSize ) ); + Bitmap aMask; + + Graphic( rGraphic.GetGDIMetaFile().GetMonochromeMtf( COL_BLACK ) ).Draw( &aVDev, aNewOrg, aQSizePix ); + aMask = aVDev.GetBitmap( aNullPoint, aAbsSize ); + aRetBmp = BitmapEx( aBmp, aMask ); + } + else + { + Bitmap aBmp( rGraphic.GetBitmap() ); + +// UNX has got problems with 1x1 bitmaps which are transparent (KA 02.11.1998) +#ifdef UNX + const Size aBmpSize( aBmp.GetSizePixel() ); + BOOL bFullTrans = FALSE; + + if( aBmpSize.Width() == 1 && aBmpSize.Height() == 1 && rGraphic.IsTransparent() ) + { + Bitmap aTrans( rGraphic.GetBitmapEx().GetMask() ); + BitmapReadAccess* pMAcc = aBmp.AcquireReadAccess(); + + if( pMAcc ) + { + if( pMAcc->GetColor( 0, 0 ) == BitmapColor( Color( COL_WHITE ) ) ) + bFullTrans = TRUE; + + aTrans.ReleaseAccess( pMAcc ); + } + } + + if( !bFullTrans ) +#endif // UNX + + { + DitherBitmap( aBmp ); + aVDev.DrawBitmap( aNewOrg, aQSizePix, aBmp ); + aBmp = aVDev.GetBitmap( aNullPoint, aAbsSize ); + + if( !rGraphic.IsTransparent() ) + aRetBmp = BitmapEx( aBmp ); + else + { + Bitmap aTrans( rGraphic.GetBitmapEx().GetMask() ); + + if( !aTrans ) + aRetBmp = BitmapEx( aBmp, rGraphic.GetBitmapEx().GetTransparentColor() ); + else + { + aVDev.DrawBitmap( aNewOrg, aQSizePix, aTrans ); + aRetBmp = BitmapEx( aBmp, aVDev.GetBitmap( Point(), aAbsSize ) ); + } + } + } + } + } + } + + return aRetBmp; +} + +// ------------------------------------------------------------------------ + +void XOutBitmap::DrawQuickDrawBitmapEx( OutputDevice* pOutDev, const Point& rPt, + const Size& rSize, const BitmapEx& rBmpEx ) +{ + const Size aBmpSizePix( rBmpEx.GetSizePixel() ); + const Size aSizePix( pOutDev->LogicToPixel( rSize ) ); + + if ( ( aSizePix.Width() - aBmpSizePix.Width() ) || ( aSizePix.Height() - aBmpSizePix.Height() ) ) + rBmpEx.Draw( pOutDev, rPt, rSize ); + else + rBmpEx.Draw( pOutDev, rPt ); +} + +// ------------------------------------------------------------------------ + +void XOutBitmap::DrawTiledBitmapEx( OutputDevice* pOutDev, + const Point& rStartPt, const Size& rGrfSize, + const Rectangle& rTileRect, const BitmapEx& rBmpEx ) +{ + Rectangle aClipRect( pOutDev->LogicToPixel( pOutDev->GetClipRegion().GetBoundRect() ) ); + Rectangle aPixRect( pOutDev->LogicToPixel( rTileRect ) ); + const Size aPixSize( pOutDev->LogicToPixel( rGrfSize ) ); + const Point aPixPoint( pOutDev->LogicToPixel( rStartPt ) ); + Point aOrg; + const long nWidth = aPixSize.Width(); + const long nHeight = aPixSize.Height(); + long nXPos = aPixPoint.X() + ( ( aPixRect.Left() - aPixPoint.X() ) / nWidth ) * nWidth; + long nYPos = aPixPoint.Y() + ( ( aPixRect.Top() - aPixPoint.Y() ) / nHeight ) * nHeight; + const long nBottom = aPixRect.Bottom(); + const long nRight = aPixRect.Right(); + const long nLeft = nXPos; + const BOOL bNoSize = ( aPixSize == rBmpEx.GetSizePixel() ); + + pOutDev->Push(); + pOutDev->SetMapMode( MapMode() ); + + // ggf. neue ClipRegion berechnen und setzen + if ( pOutDev->IsClipRegion() ) + aPixRect.Intersection( aClipRect ); + + pOutDev->SetClipRegion( aPixRect ); + + while( nYPos <= nBottom ) + { + while( nXPos <= nRight ) + { + if ( bNoSize ) + rBmpEx.Draw( pOutDev, Point( nXPos, nYPos ) ); + else + rBmpEx.Draw( pOutDev, Point( nXPos, nYPos ), aPixSize ); + + nXPos += nWidth; + } + + nXPos = nLeft; + nYPos += nHeight; + } + + pOutDev->Pop(); +} + +// ------------------------------------------------------------------------ + +Animation XOutBitmap::MirrorAnimation( const Animation& rAnimation, BOOL bHMirr, BOOL bVMirr ) +{ + Animation aNewAnim( rAnimation ); + + if( bHMirr || bVMirr ) + { + const Size& rGlobalSize = aNewAnim.GetDisplaySizePixel(); + ULONG nMirrorFlags = 0L; + + if( bHMirr ) + nMirrorFlags |= BMP_MIRROR_HORZ; + + if( bVMirr ) + nMirrorFlags |= BMP_MIRROR_VERT; + + for( USHORT i = 0, nCount = aNewAnim.Count(); i < nCount; i++ ) + { + AnimationBitmap aAnimBmp( aNewAnim.Get( i ) ); + + // BitmapEx spiegeln + aAnimBmp.aBmpEx.Mirror( nMirrorFlags ); + + // Die Positionen innerhalb der Gesamtbitmap + // muessen natuerlich auch angepasst werden + if( bHMirr ) + aAnimBmp.aPosPix.X() = rGlobalSize.Width() - aAnimBmp.aPosPix.X() - + aAnimBmp.aSizePix.Width(); + + if( bVMirr ) + aAnimBmp.aPosPix.Y() = rGlobalSize.Height() - aAnimBmp.aPosPix.Y() - + aAnimBmp.aSizePix.Height(); + + aNewAnim.Replace( aAnimBmp, i ); + } + } + + return aNewAnim; +} + +// ------------------------------------------------------------------------ + +Graphic XOutBitmap::MirrorGraphic( const Graphic& rGraphic, const ULONG nMirrorFlags ) +{ + Graphic aRetGraphic; + + if( nMirrorFlags ) + { + if( rGraphic.IsAnimated() ) + { + aRetGraphic = MirrorAnimation( rGraphic.GetAnimation(), + ( nMirrorFlags & BMP_MIRROR_HORZ ) == BMP_MIRROR_HORZ, + ( nMirrorFlags & BMP_MIRROR_VERT ) == BMP_MIRROR_VERT ); + } + else + { + if( rGraphic.IsTransparent() ) + { + BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); + + aBmpEx.Mirror( nMirrorFlags ); + aRetGraphic = aBmpEx; + } + else + { + Bitmap aBmp( rGraphic.GetBitmap() ); + + aBmp.Mirror( nMirrorFlags ); + aRetGraphic = aBmp; + } + } + } + else + aRetGraphic = rGraphic; + + return aRetGraphic; +} + +// ------------------------------------------------------------------------ + +USHORT XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, + const String& rFilterName, const ULONG nFlags, + const Size* pMtfSize_100TH_MM ) +{ + if( rGraphic.GetType() != GRAPHIC_NONE ) + { + INetURLObject aURL( rFileName ); + Graphic aGraphic; + String aExt; + GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter(); + USHORT nErr = GRFILTER_FILTERERROR, nFilter = GRFILTER_FORMAT_NOTFOUND; + BOOL bTransparent = rGraphic.IsTransparent(), bAnimated = rGraphic.IsAnimated(); + + DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "XOutBitmap::WriteGraphic(...): invalid URL" ); + + // calculate correct file name + if( !( nFlags & XOUTBMP_DONT_EXPAND_FILENAME ) ) + { + String aName( aURL.getBase() ); + aName += '_'; + aName += String(aURL.getExtension()); + aName += '_'; + String aStr( String::CreateFromInt32( rGraphic.GetChecksum(), 16 ) ); + if ( aStr.GetChar(0) == '-' ) + aStr.SetChar(0,'m'); + aName += aStr; + aURL.setBase( aName ); + } + + if( ( nFlags & XOUTBMP_USE_NATIVE_IF_POSSIBLE ) && + !( nFlags & XOUTBMP_MIRROR_HORZ ) && + !( nFlags & XOUTBMP_MIRROR_VERT ) && + ( rGraphic.GetType() != GRAPHIC_GDIMETAFILE ) && rGraphic.IsLink() ) + { + // try to write native link + const GfxLink aGfxLink( ( (Graphic&) rGraphic ).GetLink() ); + + switch( aGfxLink.GetType() ) + { + case( GFX_LINK_TYPE_NATIVE_GIF ): aExt = FORMAT_GIF; break; + case( GFX_LINK_TYPE_NATIVE_JPG ): aExt = FORMAT_JPG; break; + case( GFX_LINK_TYPE_NATIVE_PNG ): aExt = FORMAT_PNG; break; + + default: + break; + } + + if( aExt.Len() ) + { + aURL.setExtension( aExt ); + rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); + + SfxMedium aMedium( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC, TRUE ); + SvStream* pOStm = aMedium.GetOutStream(); + + if( pOStm && aGfxLink.GetDataSize() && aGfxLink.GetData() ) + { + pOStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() ); + aMedium.Commit(); + + if( !aMedium.GetError() ) + nErr = GRFILTER_OK; + } + } + } + + if( GRFILTER_OK != nErr ) + { + String aFilter( rFilterName ); + BOOL bWriteTransGrf = ( aFilter.EqualsIgnoreCaseAscii( "transgrf" ) ) || + ( aFilter.EqualsIgnoreCaseAscii( "gif" ) ) || + ( nFlags & XOUTBMP_USE_GIF_IF_POSSIBLE ) || + ( ( nFlags & XOUTBMP_USE_GIF_IF_SENSIBLE ) && ( bAnimated || bTransparent ) ); + + // get filter and extension + if( bWriteTransGrf ) + aFilter = FORMAT_GIF; + + nFilter = pFilter->GetExportFormatNumberForShortName( aFilter ); + + if( GRFILTER_FORMAT_NOTFOUND == nFilter ) + { + nFilter = pFilter->GetExportFormatNumberForShortName( FORMAT_JPG ); + + if( GRFILTER_FORMAT_NOTFOUND == nFilter ) + nFilter = pFilter->GetExportFormatNumberForShortName( FORMAT_BMP ); + } + + if( GRFILTER_FORMAT_NOTFOUND != nFilter ) + { + aExt = pFilter->GetExportFormatShortName( nFilter ).ToLowerAscii(); + + if( bWriteTransGrf ) + { + if( bAnimated ) + aGraphic = rGraphic; + else + { + if( pMtfSize_100TH_MM && ( rGraphic.GetType() != GRAPHIC_BITMAP ) ) + { + VirtualDevice aVDev; + const Size aSize( aVDev.LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) ); + + if( aVDev.SetOutputSizePixel( aSize ) ) + { + const Wallpaper aWallpaper( aVDev.GetBackground() ); + const Point aPt; + + aVDev.SetBackground( Wallpaper( Color( COL_BLACK ) ) ); + aVDev.Erase(); + rGraphic.Draw( &aVDev, aPt, aSize ); + + const Bitmap aBitmap( aVDev.GetBitmap( aPt, aSize ) ); + + aVDev.SetBackground( aWallpaper ); + aVDev.Erase(); + rGraphic.Draw( &aVDev, aPt, aSize ); + + aVDev.SetRasterOp( ROP_XOR ); + aVDev.DrawBitmap( aPt, aSize, aBitmap ); + aGraphic = BitmapEx( aBitmap, aVDev.GetBitmap( aPt, aSize ) ); + } + else + aGraphic = rGraphic.GetBitmapEx(); + } + else + aGraphic = rGraphic.GetBitmapEx(); + } + } + else + { + if( pMtfSize_100TH_MM && ( rGraphic.GetType() != GRAPHIC_BITMAP ) ) + { + VirtualDevice aVDev; + const Size aSize( aVDev.LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) ); + + if( aVDev.SetOutputSizePixel( aSize ) ) + { + rGraphic.Draw( &aVDev, Point(), aSize ); + aGraphic = aVDev.GetBitmap( Point(), aSize ); + } + else + aGraphic = rGraphic.GetBitmap(); + } + else + aGraphic = rGraphic.GetBitmap(); + } + + // mirror? + if( ( nFlags & XOUTBMP_MIRROR_HORZ ) || ( nFlags & XOUTBMP_MIRROR_VERT ) ) + aGraphic = MirrorGraphic( aGraphic, nFlags ); + + if( ( GRFILTER_FORMAT_NOTFOUND != nFilter ) && ( aGraphic.GetType() != GRAPHIC_NONE ) ) + { + aURL.setExtension( aExt ); + rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); + nErr = ExportGraphic( aGraphic, aURL, *pFilter, nFilter, NULL ); + } + } + } + + return nErr; + } + else + { + return GRFILTER_OK; + } +} + +// ------------------------------------------------------------------------ + +#ifdef _MSC_VER +#pragma optimize ( "", off ) +#endif + +USHORT XOutBitmap::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rURL, + GraphicFilter& rFilter, const USHORT nFormat, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData ) +{ + DBG_ASSERT( rURL.GetProtocol() != INET_PROT_NOT_VALID, "XOutBitmap::ExportGraphic(...): invalid URL" ); + + SfxMedium aMedium( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC, TRUE ); + SvStream* pOStm = aMedium.GetOutStream(); + USHORT nRet = GRFILTER_IOERROR; + + if( pOStm ) + { + pGrfFilter = &rFilter; + + nRet = rFilter.ExportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pOStm, nFormat, pFilterData ); + + pGrfFilter = NULL; + aMedium.Commit(); + + if( aMedium.GetError() && ( GRFILTER_OK == nRet ) ) + nRet = GRFILTER_IOERROR; + } + + return nRet; +} + +#ifdef _MSC_VER +#pragma optimize ( "", on ) +#endif + +// ------------------------------------------------------------------------ + +Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const BYTE cThreshold ) +{ + const Size aSize( rBmp.GetSizePixel() ); + Bitmap aRetBmp; + BOOL bRet = FALSE; + + if( ( aSize.Width() > 2L ) && ( aSize.Height() > 2L ) ) + { + Bitmap aWorkBmp( rBmp ); + + if( aWorkBmp.Convert( BMP_CONVERSION_8BIT_GREYS ) ) + { + Bitmap aDstBmp( aSize, 1 ); + BitmapReadAccess* pReadAcc = aWorkBmp.AcquireReadAccess(); + BitmapWriteAccess* pWriteAcc = aDstBmp.AcquireWriteAccess(); + + if( pReadAcc && pWriteAcc ) + { + const long nWidth = aSize.Width(); + const long nWidth2 = nWidth - 2L; + const long nHeight = aSize.Height(); + const long nHeight2 = nHeight - 2L; + const long lThres2 = (long) cThreshold * cThreshold; + const BitmapColor aWhite = (BYTE) pWriteAcc->GetBestMatchingColor( Color( COL_WHITE ) ); + const BitmapColor aBlack = (BYTE) pWriteAcc->GetBestMatchingColor( Color( COL_BLACK ) ); + long nSum1; + long nSum2; + long lGray; + + // Rand mit Weiss init. + pWriteAcc->SetLineColor( Color( COL_WHITE) ); + pWriteAcc->DrawLine( Point(), Point( nWidth - 1L, 0L ) ); + pWriteAcc->DrawLine( Point( nWidth - 1L, 0L ), Point( nWidth - 1L, nHeight - 1L ) ); + pWriteAcc->DrawLine( Point( nWidth - 1L, nHeight - 1L ), Point( 0L, nHeight - 1L ) ); + pWriteAcc->DrawLine( Point( 0, nHeight - 1L ), Point() ); + + for( long nY = 0L, nY1 = 1L, nY2 = 2; nY < nHeight2; nY++, nY1++, nY2++ ) + { + for( long nX = 0L, nXDst = 1L, nXTmp; nX < nWidth2; nX++, nXDst++ ) + { + nXTmp = nX; + + nSum1 = -( nSum2 = lGray = (BYTE) pReadAcc->GetPixel( nY, nXTmp++ ) ); + nSum2 += ( (long) (BYTE) pReadAcc->GetPixel( nY, nXTmp++ ) ) << 1; + nSum1 += ( lGray = pReadAcc->GetPixel( nY, nXTmp ) ); + nSum2 += lGray; + + nSum1 += ( (long) (BYTE) pReadAcc->GetPixel( nY1, nXTmp ) ) << 1; + nSum1 -= ( (long) (BYTE) pReadAcc->GetPixel( nY1, nXTmp -= 2 ) ) << 1; + + nSum1 += ( lGray = -(long) (BYTE) pReadAcc->GetPixel( nY2, nXTmp++ ) ); + nSum2 += lGray; + nSum2 -= ( (long) (BYTE) pReadAcc->GetPixel( nY2, nXTmp++ ) ) << 1; + nSum1 += ( lGray = (long) (BYTE) pReadAcc->GetPixel( nY2, nXTmp ) ); + nSum2 -= lGray; + + if( ( nSum1 * nSum1 + nSum2 * nSum2 ) < lThres2 ) + pWriteAcc->SetPixel( nY1, nXDst, aWhite ); + else + pWriteAcc->SetPixel( nY1, nXDst, aBlack ); + } + } + + bRet = TRUE; + } + + aWorkBmp.ReleaseAccess( pReadAcc ); + aDstBmp.ReleaseAccess( pWriteAcc ); + + if( bRet ) + aRetBmp = aDstBmp; + } + } + + if( !aRetBmp ) + aRetBmp = rBmp; + else + { + aRetBmp.SetPrefMapMode( rBmp.GetPrefMapMode() ); + aRetBmp.SetPrefSize( rBmp.GetPrefSize() ); + } + + return aRetBmp; +}; + +// ------------------------------------------------------------------------ + +Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const ULONG nFlags, + const BYTE cEdgeDetectThreshold, const Rectangle* pWorkRectPixel ) +{ + Bitmap aWorkBmp; + Polygon aRetPoly; + Point aTmpPoint; + Rectangle aWorkRect( aTmpPoint, rBmp.GetSizePixel() ); + + if( pWorkRectPixel ) + aWorkRect.Intersection( *pWorkRectPixel ); + + aWorkRect.Justify(); + + if( ( aWorkRect.GetWidth() > 4 ) && ( aWorkRect.GetHeight() > 4 ) ) + { + // falls Flag gesetzt, muessen wir Kanten detektieren + if( nFlags & XOUTBMP_CONTOUR_EDGEDETECT ) + aWorkBmp = DetectEdges( rBmp, cEdgeDetectThreshold ); + else + aWorkBmp = rBmp; + + BitmapReadAccess* pAcc = aWorkBmp.AcquireReadAccess(); + + if( pAcc ) + { + const Size& rPrefSize = aWorkBmp.GetPrefSize(); + const long nWidth = pAcc->Width(); + const long nHeight = pAcc->Height(); + const double fFactorX = (double) rPrefSize.Width() / nWidth; + const double fFactorY = (double) rPrefSize.Height() / nHeight; + const long nStartX1 = aWorkRect.Left() + 1L; + const long nEndX1 = aWorkRect.Right(); + const long nStartX2 = nEndX1 - 1L; +// const long nEndX2 = nStartX1 - 1L; + const long nStartY1 = aWorkRect.Top() + 1L; + const long nEndY1 = aWorkRect.Bottom(); + const long nStartY2 = nEndY1 - 1L; +// const long nEndY2 = nStartY1 - 1L; + Point* pPoints1 = NULL; + Point* pPoints2 = NULL; + long nX, nY; + USHORT nPolyPos = 0; + const BitmapColor aBlack = pAcc->GetBestMatchingColor( Color( COL_BLACK ) ); + + if( nFlags & XOUTBMP_CONTOUR_VERT ) + { + pPoints1 = new Point[ nWidth ]; + pPoints2 = new Point[ nWidth ]; + + for( nX = nStartX1; nX < nEndX1; nX++ ) + { + nY = nStartY1; + + // zunaechst Zeile von Links nach Rechts durchlaufen + while( nY < nEndY1 ) + { + if( aBlack == pAcc->GetPixel( nY, nX ) ) + { + pPoints1[ nPolyPos ] = Point( nX, nY ); + nY = nStartY2; + + // diese Schleife wird immer gebreaked da hier ja min. ein Pixel ist + while( TRUE ) + { + if( aBlack == pAcc->GetPixel( nY, nX ) ) + { + pPoints2[ nPolyPos ] = Point( nX, nY ); + break; + } + + nY--; + } + + nPolyPos++; + break; + } + + nY++; + } + } + } + else + { + pPoints1 = new Point[ nHeight ]; + pPoints2 = new Point[ nHeight ]; + + for ( nY = nStartY1; nY < nEndY1; nY++ ) + { + nX = nStartX1; + + // zunaechst Zeile von Links nach Rechts durchlaufen + while( nX < nEndX1 ) + { + if( aBlack == pAcc->GetPixel( nY, nX ) ) + { + pPoints1[ nPolyPos ] = Point( nX, nY ); + nX = nStartX2; + + // diese Schleife wird immer gebreaked da hier ja min. ein Pixel ist + while( TRUE ) + { + if( aBlack == pAcc->GetPixel( nY, nX ) ) + { + pPoints2[ nPolyPos ] = Point( nX, nY ); + break; + } + + nX--; + } + + nPolyPos++; + break; + } + + nX++; + } + } + } + + const USHORT nNewSize1 = nPolyPos << 1; + + aRetPoly = Polygon( nPolyPos, pPoints1 ); + aRetPoly.SetSize( nNewSize1 + 1 ); + aRetPoly[ nNewSize1 ] = aRetPoly[ 0 ]; + + for( USHORT j = nPolyPos; nPolyPos < nNewSize1; ) + aRetPoly[ nPolyPos++ ] = pPoints2[ --j ]; + + if( ( fFactorX != 0. ) && ( fFactorY != 0. ) ) + aRetPoly.Scale( fFactorX, fFactorY ); + + delete[] pPoints1; + delete[] pPoints2; + } + } + + return aRetPoly; +}; + +// ---------------- +// - DitherBitmap - +// ---------------- + +BOOL DitherBitmap( Bitmap& rBitmap ) +{ + BOOL bRet = FALSE; + + if( ( rBitmap.GetBitCount() >= 8 ) && ( Application::GetDefaultDevice()->GetColorCount() < 257 ) ) + bRet = rBitmap.Dither( BMP_DITHER_FLOYD ); + else + bRet = FALSE; + + return bRet; +} diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx new file mode 100644 index 000000000000..0e6252ddcb92 --- /dev/null +++ b/svx/source/xoutdev/_xpoly.cxx @@ -0,0 +1,2135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <osl/endian.h> +#include <tools/stream.hxx> +#include <tools/debug.hxx> +#include <tools/poly.hxx> + +#include <svx/xpoly.hxx> +#include "xpolyimp.hxx" +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <vcl/salbtype.hxx> // FRound +#include <basegfx/range/b2drange.hxx> +#include <basegfx/numeric/ftools.hxx> + +#define GLOBALOVERFLOW + +DBG_NAME(XPolygon); +DBG_NAME(XPolyPolygon); + +/************************************************************************* +|* +|* ImpXPolygon::ImpXPolygon() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +ImpXPolygon::ImpXPolygon( USHORT nInitSize, USHORT _nResize ) +{ + pPointAry = NULL; + pFlagAry = NULL; + bDeleteOldPoints = FALSE; + nSize = 0; + nResize = _nResize; + nPoints = 0; + nRefCount = 1; + + Resize( nInitSize ); +} + +/************************************************************************* +|* +|* ImpXPolygon::ImpXPolygon() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +ImpXPolygon::ImpXPolygon( const ImpXPolygon& rImpXPoly ) +{ + ( (ImpXPolygon&) rImpXPoly ).CheckPointDelete(); + + pPointAry = NULL; + pFlagAry = NULL; + bDeleteOldPoints = FALSE; + nSize = 0; + ImpXPolygon::nResize = rImpXPoly.nResize; + nPoints = 0; + nRefCount = 1; + + Resize( rImpXPoly.nSize ); + + // Kopieren + nPoints = rImpXPoly.nPoints; + memcpy( pPointAry, rImpXPoly.pPointAry, nSize*sizeof( Point ) ); + memcpy( pFlagAry, rImpXPoly.pFlagAry, nSize ); +} + +/************************************************************************* +|* +|* ImpXPolygon::~ImpXPolygon() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +ImpXPolygon::~ImpXPolygon() +{ + delete[] (char*) pPointAry; + delete[] pFlagAry; + if ( bDeleteOldPoints ) + delete[] (char*) pOldPointAry; +} + +/************************************************************************* +|* +|* ImpXPolygon::operator==() +|* +|* Ersterstellung Joe 26-09-95 +|* Letzte Aenderung +|* +*************************************************************************/ + + +bool ImpXPolygon::operator==(const ImpXPolygon& rImpXPoly) const +{ + return nPoints==rImpXPoly.nPoints && + (nPoints==0 || + (memcmp(pPointAry,rImpXPoly.pPointAry,nPoints*sizeof(Point))==0 && + memcmp(pFlagAry,rImpXPoly.pFlagAry,nPoints)==0)); +} + +/************************************************************************* +|* +|* ImpXPolygon::Resize() +|* +|* !!! Polygongroesse aendern - wenn bDeletePoints FALSE, dann den +|* Point-Array nicht loeschen, sondern in pOldPointAry sichern und +|* das Flag bDeleteOldPoints setzen. Beim naechsten Zugriff wird +|* das Array dann geloescht. +|* Damit wird verhindert, dass bei XPoly[n] = XPoly[0] durch ein +|* Resize der fuer den rechten Ausdruck verwendete Point-Array +|* vorzeitig geloescht wird. +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +void ImpXPolygon::Resize( USHORT nNewSize, BOOL bDeletePoints ) +{ + if( nNewSize == nSize ) + return; + + BYTE* pOldFlagAry = pFlagAry; + USHORT nOldSize = nSize; + + CheckPointDelete(); + pOldPointAry = pPointAry; + + // Neue Groesse auf vielfaches von nResize runden, sofern Objekt + // nicht neu angelegt wurde (nSize != 0) + if ( nSize != 0 && nNewSize > nSize ) + { + DBG_ASSERT(nResize, "Resize-Versuch trotz nResize = 0 !"); + nNewSize = nSize + ((nNewSize-nSize-1) / nResize + 1) * nResize; + } + // Punkt Array erzeugen + nSize = nNewSize; + pPointAry = (Point*)new char[ nSize*sizeof( Point ) ]; + memset( pPointAry, 0, nSize*sizeof( Point ) ); + + // Flag Array erzeugen + pFlagAry = new BYTE[ nSize ]; + memset( pFlagAry, 0, nSize ); + + // Eventuell umkopieren + if( nOldSize ) + { + if( nOldSize < nSize ) + { + memcpy( pPointAry, pOldPointAry, nOldSize*sizeof( Point ) ); + memcpy( pFlagAry, pOldFlagAry, nOldSize ); + } + else + { + memcpy( pPointAry, pOldPointAry, nSize*sizeof( Point ) ); + memcpy( pFlagAry, pOldFlagAry, nSize ); + + // Anzahl der gueltigen Punkte anpassen + if( nPoints > nSize ) + nPoints = nSize; + } + if ( bDeletePoints ) delete[] (char*) pOldPointAry; + else bDeleteOldPoints = TRUE; + delete[] pOldFlagAry; + } +} + + +/************************************************************************* +|* +|* ImpXPolygon::InsertSpace() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 29.03.95 ESO +|* +*************************************************************************/ + +void ImpXPolygon::InsertSpace( USHORT nPos, USHORT nCount ) +{ + CheckPointDelete(); + + if ( nPos > nPoints ) + nPos = nPoints; + + // Wenn Polygon zu klein dann groesser machen + if( (nPoints + nCount) > nSize ) + Resize( nPoints + nCount ); + + // Wenn nicht hinter dem letzten Punkt eingefuegt wurde, + // den Rest nach hinten schieben + if( nPos < nPoints ) + { + USHORT nMove = nPoints - nPos; + memmove( &pPointAry[nPos+nCount], &pPointAry[nPos], + nMove * sizeof(Point) ); + memmove( &pFlagAry[nPos+nCount], &pFlagAry[nPos], nMove ); + } + memset( &pPointAry[nPos], 0, nCount * sizeof( Point ) ); + memset( &pFlagAry [nPos], 0, nCount ); + + nPoints = nPoints + nCount; +} + + +/************************************************************************* +|* +|* ImpXPolygon::Remove() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.94 ESO +|* +*************************************************************************/ + +void ImpXPolygon::Remove( USHORT nPos, USHORT nCount ) +{ + CheckPointDelete(); + + if( (nPos + nCount) <= nPoints ) + { + USHORT nMove = nPoints - nPos - nCount; + + if( nMove ) + { + memmove( &pPointAry[nPos], &pPointAry[nPos+nCount], + nMove * sizeof(Point) ); + memmove( &pFlagAry[nPos], &pFlagAry[nPos+nCount], nMove ); + } + memset( &pPointAry[nPoints - nCount], 0, nCount * sizeof( Point ) ); + memset( &pFlagAry [nPoints - nCount], 0, nCount ); + nPoints = nPoints - nCount; + } +} + + +/************************************************************************* +|* +|* XPolygon::XPolygon() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +XPolygon::XPolygon( USHORT nSize, USHORT nResize ) +{ + DBG_CTOR(XPolygon,NULL); + pImpXPolygon = new ImpXPolygon( nSize, nResize ); +} + +/************************************************************************* +|* +|* XPolygon::XPolygon() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +XPolygon::XPolygon( const XPolygon& rXPoly ) +{ + DBG_CTOR(XPolygon,NULL); + pImpXPolygon = rXPoly.pImpXPolygon; + pImpXPolygon->nRefCount++; +} + +/************************************************************************* +|* +|* XPolygon::XPolygon() +|* +|* XPolygon aus einem Standardpolygon erstellen +|* Ersterstellung 18.01.95 ESO +|* Letzte Aenderung 18.01.95 ESO +|* +*************************************************************************/ + +XPolygon::XPolygon( const Polygon& rPoly ) +{ + DBG_CTOR(XPolygon,NULL); + + USHORT nSize = rPoly.GetSize(); + pImpXPolygon = new ImpXPolygon( nSize ); + pImpXPolygon->nPoints = nSize; + + for( USHORT i = 0; i < nSize; i++ ) + { + pImpXPolygon->pPointAry[i] = rPoly[i]; + pImpXPolygon->pFlagAry[i] = (BYTE) rPoly.GetFlags( i ); + } +} + +/************************************************************************* +|* +|* XPolygon::XPolygon() +|* +|* Rechteck (auch mit abgerundeten Ecken) als Bezierpolygon erzeugen +|* Ersterstellung 09.01.95 ESO +|* Letzte Aenderung 09.01.95 ESO +|* +*************************************************************************/ + +XPolygon::XPolygon(const Rectangle& rRect, long nRx, long nRy) +{ + DBG_CTOR(XPolygon,NULL); + pImpXPolygon = new ImpXPolygon(17); + long nWh = (rRect.GetWidth() - 1) / 2; + long nHh = (rRect.GetHeight() - 1) / 2; + + if ( nRx > nWh ) nRx = nWh; + if ( nRy > nHh ) nRy = nHh; + + // Rx negativ, damit Umlauf im Uhrzeigersinn erfolgt + nRx = -nRx; + + // Faktor fuer Kontrollpunkte der Bezierkurven: 8/3 * (sin(45g) - 0.5) + long nXHdl = (long)(0.552284749 * nRx); + long nYHdl = (long)(0.552284749 * nRy); + USHORT nPos = 0; + + if ( nRx && nRy ) + { + Point aCenter; + + for (USHORT nQuad = 0; nQuad < 4; nQuad++) + { + switch ( nQuad ) + { + case 0: aCenter = rRect.TopLeft(); + aCenter.X() -= nRx; + aCenter.Y() += nRy; + break; + case 1: aCenter = rRect.TopRight(); + aCenter.X() += nRx; + aCenter.Y() += nRy; + break; + case 2: aCenter = rRect.BottomRight(); + aCenter.X() += nRx; + aCenter.Y() -= nRy; + break; + case 3: aCenter = rRect.BottomLeft(); + aCenter.X() -= nRx; + aCenter.Y() -= nRy; + break; + } + GenBezArc(aCenter, nRx, nRy, nXHdl, nYHdl, 0, 900, nQuad, nPos); + pImpXPolygon->pFlagAry[nPos ] = (BYTE) XPOLY_SMOOTH; + pImpXPolygon->pFlagAry[nPos+3] = (BYTE) XPOLY_SMOOTH; + nPos += 4; + } + } + else + { + pImpXPolygon->pPointAry[nPos++] = rRect.TopLeft(); + pImpXPolygon->pPointAry[nPos++] = rRect.TopRight(); + pImpXPolygon->pPointAry[nPos++] = rRect.BottomRight(); + pImpXPolygon->pPointAry[nPos++] = rRect.BottomLeft(); + } + pImpXPolygon->pPointAry[nPos] = pImpXPolygon->pPointAry[0]; + pImpXPolygon->nPoints = nPos + 1; +} + +/************************************************************************* +|* +|* XPolygon::XPolygon() +|* +|* Ellipsen(bogen) als Bezierpolygon erzeugen +|* Ersterstellung 09.01.95 +|* Letzte Aenderung 09.01.95 +|* +*************************************************************************/ + +XPolygon::XPolygon(const Point& rCenter, long nRx, long nRy, + USHORT nStartAngle, USHORT nEndAngle, BOOL bClose) +{ + DBG_CTOR(XPolygon,NULL); + pImpXPolygon = new ImpXPolygon(17); + + nStartAngle %= 3600; + if ( nEndAngle > 3600 ) nEndAngle %= 3600; + BOOL bFull = (nStartAngle == 0 && nEndAngle == 3600); + + // Faktor fuer Kontrollpunkte der Bezierkurven: 8/3 * (sin(45g) - 0.5) + long nXHdl = (long)(0.552284749 * nRx); + long nYHdl = (long)(0.552284749 * nRy); + USHORT nPos = 0; + BOOL bLoopEnd = FALSE; + + do + { + USHORT nA1, nA2; + USHORT nQuad = nStartAngle / 900; + if ( nQuad == 4 ) nQuad = 0; + bLoopEnd = CheckAngles(nStartAngle, nEndAngle, nA1, nA2); + GenBezArc(rCenter, nRx, nRy, nXHdl, nYHdl, nA1, nA2, nQuad, nPos); + nPos += 3; + if ( !bLoopEnd ) + pImpXPolygon->pFlagAry[nPos] = (BYTE) XPOLY_SMOOTH; + + } while ( !bLoopEnd ); + + // Wenn kein Vollkreis, dann ggf. Enden mit Mittelpunkt verbinden + if ( !bFull && bClose ) + pImpXPolygon->pPointAry[++nPos] = rCenter; + + if ( bFull ) + { + pImpXPolygon->pFlagAry[0 ] = (BYTE) XPOLY_SMOOTH; + pImpXPolygon->pFlagAry[nPos] = (BYTE) XPOLY_SMOOTH; + } + pImpXPolygon->nPoints = nPos + 1; +} + +/************************************************************************* +|* +|* XPolygon::~XPolygon() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +XPolygon::~XPolygon() +{ + DBG_DTOR(XPolygon,NULL); + if( pImpXPolygon->nRefCount > 1 ) + pImpXPolygon->nRefCount--; + else + delete pImpXPolygon; +} + +/************************************************************************* +|* +|* XPolygon::CheckReference() +|* +|* Referenzzaehler desImpXPoly pruefen und ggf. von diesem abkoppeln +|* Ersterstellung 17.01.95 ESO +|* Letzte Aenderung 17.01.95 ESO +|* +*************************************************************************/ + +void XPolygon::CheckReference() +{ + if( pImpXPolygon->nRefCount > 1 ) + { + pImpXPolygon->nRefCount--; + pImpXPolygon = new ImpXPolygon( *pImpXPolygon ); + } +} + +/************************************************************************* +|* +|* XPolygon::SetSize() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +void XPolygon::SetSize( USHORT nNewSize ) +{ + CheckReference(); + pImpXPolygon->Resize( nNewSize ); +} + +/************************************************************************* +|* +|* XPolygon::GetSize() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +USHORT XPolygon::GetSize() const +{ + pImpXPolygon->CheckPointDelete(); + return pImpXPolygon->nSize; +} + +/************************************************************************* +|* +|* XPolygon::SetPointCount() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +void XPolygon::SetPointCount( USHORT nPoints ) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + if( pImpXPolygon->nSize < nPoints ) + pImpXPolygon->Resize( nPoints ); + + if ( nPoints < pImpXPolygon->nPoints ) + { + USHORT nSize = pImpXPolygon->nPoints - nPoints; + memset( &pImpXPolygon->pPointAry[nPoints], 0, nSize * sizeof( Point ) ); + memset( &pImpXPolygon->pFlagAry [nPoints], 0, nSize ); + } + pImpXPolygon->nPoints = nPoints; +} + +/************************************************************************* +|* +|* XPolygon::GetPointCount() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +USHORT XPolygon::GetPointCount() const +{ + pImpXPolygon->CheckPointDelete(); + return pImpXPolygon->nPoints; +} + +/************************************************************************* +|* +|* XPolygon::Insert() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +void XPolygon::Insert( USHORT nPos, const Point& rPt, XPolyFlags eFlags ) +{ + CheckReference(); + if (nPos>pImpXPolygon->nPoints) nPos=pImpXPolygon->nPoints; + pImpXPolygon->InsertSpace( nPos, 1 ); + pImpXPolygon->pPointAry[nPos] = rPt; + pImpXPolygon->pFlagAry[nPos] = (BYTE)eFlags; +} + +/************************************************************************* +|* +|* XPolygon::Insert() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +void XPolygon::Insert( USHORT nPos, const XPolygon& rXPoly ) +{ + CheckReference(); + if (nPos>pImpXPolygon->nPoints) nPos=pImpXPolygon->nPoints; + + USHORT nPoints = rXPoly.GetPointCount(); + + pImpXPolygon->InsertSpace( nPos, nPoints ); + + memcpy( &(pImpXPolygon->pPointAry[nPos]), + rXPoly.pImpXPolygon->pPointAry, + nPoints*sizeof( Point ) ); + memcpy( &(pImpXPolygon->pFlagAry[nPos]), + rXPoly.pImpXPolygon->pFlagAry, + nPoints ); +} + +/************************************************************************* +|* +|* XPolygon::Insert() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +void XPolygon::Insert( USHORT nPos, const Polygon& rPoly ) +{ + CheckReference(); + if (nPos>pImpXPolygon->nPoints) nPos=pImpXPolygon->nPoints; + + USHORT nPoints = rPoly.GetSize(); + + pImpXPolygon->InsertSpace( nPos, nPoints ); + + USHORT i; + for( i=0; i < nPoints; i++ ) + pImpXPolygon->pPointAry[i] = rPoly[i]; + + // Die Flags sind durch das InsertSpace bereits auf 0 gesetzt +} + +/************************************************************************* +|* +|* XPolygon::Remove() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 08.11.94 +|* +*************************************************************************/ + +void XPolygon::Remove( USHORT nPos, USHORT nCount ) +{ + CheckReference(); + pImpXPolygon->Remove( nPos, nCount ); +} + +/************************************************************************* +|* +|* XPolygon::Move() +|* +|* Beschreibung +|* Ersterstellung 09.11.94 +|* Letzte Aenderung 09.11.94 +|* +*************************************************************************/ + +void XPolygon::Move( long nHorzMove, long nVertMove ) +{ + if ( !nHorzMove && !nVertMove ) + return; + + CheckReference(); + + // Punkte verschieben + USHORT nCount = pImpXPolygon->nPoints; + for ( USHORT i = 0; i < nCount; i++ ) + { + Point* pPt = &(pImpXPolygon->pPointAry[i]); + pPt->X() += nHorzMove; + pPt->Y() += nVertMove; + } +} + +/************************************************************************* +|* +|* XPolygon::GetBoundRect() +|* +|* Beschreibung +|* Ersterstellung 09.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +Rectangle XPolygon::GetBoundRect() const +{ + pImpXPolygon->CheckPointDelete(); + Rectangle aRetval; + + if(pImpXPolygon->nPoints) + { + // #i37709# + // For historical reasons the control points are not part of the + // BoundRect. This makes it necessary to subdivide the polygon to + // get a relatively correct BoundRect. Numerically, this is not + // correct and never was. + + const basegfx::B2DRange aPolygonRange(basegfx::tools::getRange(getB2DPolygon())); + aRetval = Rectangle( + FRound(aPolygonRange.getMinX()), FRound(aPolygonRange.getMinY()), + FRound(aPolygonRange.getMaxX()), FRound(aPolygonRange.getMaxY())); + } + + return aRetval; +} + +/************************************************************************* +|* +|* XPolygon::operator[]() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 +|* +*************************************************************************/ + +const Point& XPolygon::operator[]( USHORT nPos ) const +{ + DBG_ASSERT(nPos < pImpXPolygon->nPoints, "Ungueltiger Index bei const-Arrayzugriff auf XPolygon"); + + pImpXPolygon->CheckPointDelete(); + return pImpXPolygon->pPointAry[nPos]; +} + +/************************************************************************* +|* +|* XPolygon::operator[]() +|* +|* Beschreibung +|* Ersterstellung 08.11.94 +|* Letzte Aenderung 12.01.95 ESO +|* +*************************************************************************/ + +Point& XPolygon::operator[]( USHORT nPos ) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + if( nPos >= pImpXPolygon->nSize ) + { + DBG_ASSERT(pImpXPolygon->nResize, "Ungueltiger Index bei Arrayzugriff auf XPolygon"); + pImpXPolygon->Resize(nPos + 1, FALSE); + } + if( nPos >= pImpXPolygon->nPoints ) + pImpXPolygon->nPoints = nPos + 1; + + return pImpXPolygon->pPointAry[nPos]; +} + +/************************************************************************* +|* +|* XPolygon::operator=() +|* +|* Beschreibung Zuweisungsoperator +|* Ersterstellung ESO 22.11.94 +|* Letzte Aenderung ESO 12.01.95 +|* +*************************************************************************/ + +XPolygon& XPolygon::operator=( const XPolygon& rXPoly ) +{ + pImpXPolygon->CheckPointDelete(); + + rXPoly.pImpXPolygon->nRefCount++; + + if( pImpXPolygon->nRefCount > 1 ) + pImpXPolygon->nRefCount--; + else + delete pImpXPolygon; + + pImpXPolygon = rXPoly.pImpXPolygon; + return *this; +} + +/************************************************************************* +|* +|* XPolygon::operator==() +|* +|* Beschreibung Gleichheitsoperator +|* Ersterstellung ESO 22.11.94 +|* Letzte Aenderung Joe 26.09.95 +|* +*************************************************************************/ + +BOOL XPolygon::operator==( const XPolygon& rXPoly ) const +{ + pImpXPolygon->CheckPointDelete(); + if (rXPoly.pImpXPolygon==pImpXPolygon) return TRUE; + return *rXPoly.pImpXPolygon == *pImpXPolygon; +} + +/************************************************************************* +|* +|* XPolygon::operator!=() +|* +|* Beschreibung Ungleichheitsoperator +|* Ersterstellung ESO 22.11.94 +|* Letzte Aenderung Joe 26.09.95 +|* +*************************************************************************/ + +BOOL XPolygon::operator!=( const XPolygon& rXPoly ) const +{ + pImpXPolygon->CheckPointDelete(); + if (rXPoly.pImpXPolygon==pImpXPolygon) return FALSE; + return *rXPoly.pImpXPolygon != *pImpXPolygon; +} + +/************************************************************************* +|* +|* XPolygon::GetFlags() +|* +|* Flags fuer den Punkt an der Position nPos zurueckgeben +|* Ersterstellung ESO 11.11.94 +|* Letzte Aenderung ESO 12.01.95 +|* +*************************************************************************/ + +XPolyFlags XPolygon::GetFlags( USHORT nPos ) const +{ + pImpXPolygon->CheckPointDelete(); + return (XPolyFlags) pImpXPolygon->pFlagAry[nPos]; +} + +/************************************************************************* +|* +|* XPolygon::SetFlags() +|* +|* Flags fuer den Punkt an der Position nPos setzen +|* Ersterstellung ESO 11.11.94 +|* Letzte Aenderung ESO 12.01.95 +|* +*************************************************************************/ + +void XPolygon::SetFlags( USHORT nPos, XPolyFlags eFlags ) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + pImpXPolygon->pFlagAry[nPos] = (BYTE) eFlags; +} + +/************************************************************************* +|* +|* XPolygon::IsControl() +|* +|* Kurzform zur Abfrage des CONTROL-Flags +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 12.01.95 +|* +*************************************************************************/ + +BOOL XPolygon::IsControl(USHORT nPos) const +{ + return ( (XPolyFlags) pImpXPolygon->pFlagAry[nPos] == XPOLY_CONTROL ); +} + +/************************************************************************* +|* +|* XPolygon::IsSmooth() +|* +|* Kurzform zur Abfrage von SMOOTH- und SYMMTR-Flag +|* Ersterstellung ESO 18.04.95 +|* Letzte Aenderung ESO 18.04.95 +|* +*************************************************************************/ + +BOOL XPolygon::IsSmooth(USHORT nPos) const +{ + XPolyFlags eFlag = (XPolyFlags) pImpXPolygon->pFlagAry[nPos]; + return ( eFlag == XPOLY_SMOOTH || eFlag == XPOLY_SYMMTR ); +} + +/************************************************************************* +|* +|* XPolygon::CalcDistance() +|* +|* Abstand zwischen zwei Punkten berechnen +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 09.01.95 +|* +*************************************************************************/ + +double XPolygon::CalcDistance(USHORT nP1, USHORT nP2) +{ + const Point& rP1 = pImpXPolygon->pPointAry[nP1]; + const Point& rP2 = pImpXPolygon->pPointAry[nP2]; + double fDx = rP2.X() - rP1.X(); + double fDy = rP2.Y() - rP1.Y(); + return sqrt(fDx * fDx + fDy * fDy); +} + +/************************************************************************* +|* +|* XPolygon::SubdivideBezier() +|* +|* Bezierkurve unterteilen +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 09.01.95 +|* +*************************************************************************/ + +void XPolygon::SubdivideBezier(USHORT nPos, BOOL bCalcFirst, double fT) +{ + Point* pPoints = pImpXPolygon->pPointAry; + double fT2 = fT * fT; + double fT3 = fT * fT2; + double fU = 1.0 - fT; + double fU2 = fU * fU; + double fU3 = fU * fU2; + USHORT nIdx = nPos; + short nPosInc, nIdxInc; + + if ( bCalcFirst ) + { + nPos += 3; + nPosInc = -1; + nIdxInc = 0; + } + else + { + nPosInc = 1; + nIdxInc = 1; + } + pPoints[nPos].X() = (long) (fU3 * pPoints[nIdx ].X() + + fT * fU2 * pPoints[nIdx+1].X() * 3 + + fT2 * fU * pPoints[nIdx+2].X() * 3 + + fT3 * pPoints[nIdx+3].X()); + pPoints[nPos].Y() = (long) (fU3 * pPoints[nIdx ].Y() + + fT * fU2 * pPoints[nIdx+1].Y() * 3 + + fT2 * fU * pPoints[nIdx+2].Y() * 3 + + fT3 * pPoints[nIdx+3].Y()); + nPos = nPos + nPosInc; + nIdx = nIdx + nIdxInc; + pPoints[nPos].X() = (long) (fU2 * pPoints[nIdx ].X() + + fT * fU * pPoints[nIdx+1].X() * 2 + + fT2 * pPoints[nIdx+2].X()); + pPoints[nPos].Y() = (long) (fU2 * pPoints[nIdx ].Y() + + fT * fU * pPoints[nIdx+1].Y() * 2 + + fT2 * pPoints[nIdx+2].Y()); + nPos = nPos + nPosInc; + nIdx = nIdx + nIdxInc; + pPoints[nPos].X() = (long) (fU * pPoints[nIdx ].X() + + fT * pPoints[nIdx+1].X()); + pPoints[nPos].Y() = (long) (fU * pPoints[nIdx ].Y() + + fT * pPoints[nIdx+1].Y()); +} + +/************************************************************************/ + +void XPolygon::GenBezArc(const Point& rCenter, long nRx, long nRy, + long nXHdl, long nYHdl, USHORT nStart, USHORT nEnd, + USHORT nQuad, USHORT nFirst) +{ + Point* pPoints = pImpXPolygon->pPointAry; + pPoints[nFirst ] = rCenter; + pPoints[nFirst+3] = rCenter; + + if ( nQuad == 1 || nQuad == 2 ) + { + nRx = -nRx; nXHdl = -nXHdl; + } + if ( nQuad == 0 || nQuad == 1 ) + { + nRy = -nRy; nYHdl = -nYHdl; + } + + if ( nQuad == 0 || nQuad == 2 ) + { + pPoints[nFirst].X() += nRx; pPoints[nFirst+3].Y() += nRy; + } + else + { + pPoints[nFirst].Y() += nRy; pPoints[nFirst+3].X() += nRx; + } + pPoints[nFirst+1] = pPoints[nFirst]; + pPoints[nFirst+2] = pPoints[nFirst+3]; + + if ( nQuad == 0 || nQuad == 2 ) + { + pPoints[nFirst+1].Y() += nYHdl; pPoints[nFirst+2].X() += nXHdl; + } + else + { + pPoints[nFirst+1].X() += nXHdl; pPoints[nFirst+2].Y() += nYHdl; + } + if ( nStart > 0 ) + SubdivideBezier(nFirst, FALSE, (double)nStart / 900); + if ( nEnd < 900 ) + SubdivideBezier(nFirst, TRUE, (double)(nEnd-nStart) / (900-nStart)); + SetFlags(nFirst+1, XPOLY_CONTROL); + SetFlags(nFirst+2, XPOLY_CONTROL); +} + +/************************************************************************/ + +BOOL XPolygon::CheckAngles(USHORT& nStart, USHORT nEnd, USHORT& nA1, USHORT& nA2) +{ + if ( nStart == 3600 ) nStart = 0; + if ( nEnd == 0 ) nEnd = 3600; + USHORT nStPrev = nStart; + USHORT nMax = (nStart / 900 + 1) * 900; + USHORT nMin = nMax - 900; + + if ( nEnd >= nMax || nEnd <= nStart ) nA2 = 900; + else nA2 = nEnd - nMin; + nA1 = nStart - nMin; + nStart = nMax; + + // TRUE zurueck, falls letztes Segment berechnet wurde + return (nStPrev < nEnd && nStart >= nEnd); +} + +/************************************************************************* +|* +|* XPolygon::CalcSmoothJoin() +|* +|* glatten Uebergang zu einer Bezierkurve berechnen, indem der +|* entsprechende Punkt auf die Verbindungslinie von zwei anderen +|* Punkten projiziert wird +|* Center = End- bzw. Anfangspunkt der Bezierkurve +|* Drag = der bewegte Punkt, der die Verschiebung von Pnt vorgibt +|* Pnt = der zu modifizierende Punkt +|* Wenn Center am Anfang bzw. Ende des Polygons liegt, wird Pnt +|* auf die entgegengesetzte Seite verlegt +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 18.04.95 +|* +\************************************************************************/ + +void XPolygon::CalcSmoothJoin(USHORT nCenter, USHORT nDrag, USHORT nPnt) +{ + CheckReference(); + +// USHORT nMaxPnt = pImpXPolygon->nPoints - 1; + +// if ( nCenter == nMaxPnt ) nPnt = 1; +// else if ( nCenter == 0 ) nPnt = nMaxPnt - 1; + + // Wenn nPnt kein Control-Punkt, d.h. nicht verschiebbar, dann + // statt dessen nDrag auf der Achse nCenter-nPnt verschieben + if ( !IsControl(nPnt) ) + { + USHORT nTmp = nDrag; + nDrag = nPnt; + nPnt = nTmp; + } + Point* pPoints = pImpXPolygon->pPointAry; + Point aDiff = pPoints[nDrag] - pPoints[nCenter]; + double fDiv = CalcDistance(nCenter, nDrag); + + if ( fDiv ) + { + double fRatio = CalcDistance(nCenter, nPnt) / fDiv; + // bei SMOOTH bisherige Laenge beibehalten + if ( GetFlags(nCenter) == XPOLY_SMOOTH || !IsControl(nDrag) ) + { + aDiff.X() = (long) (fRatio * aDiff.X()); + aDiff.Y() = (long) (fRatio * aDiff.Y()); + } + pPoints[nPnt] = pPoints[nCenter] - aDiff; + } +} + +/************************************************************************* +|* +|* XPolygon::CalcTangent() +|* +|* Tangente fuer den Uebergang zwischen zwei Bezierkurven berechnen +|* Center = End- bzw. Anfangspunkt der Bezierkurven +|* Prev = vorheriger Zugpunkt +|* Next = naechster Zugpunkt +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 18.04.95 +|* +\************************************************************************/ + +void XPolygon::CalcTangent(USHORT nCenter, USHORT nPrev, USHORT nNext) +{ + CheckReference(); + + double fAbsLen = CalcDistance(nNext, nPrev); + + if ( fAbsLen ) + { + const Point& rCenter = pImpXPolygon->pPointAry[nCenter]; + Point& rNext = pImpXPolygon->pPointAry[nNext]; + Point& rPrev = pImpXPolygon->pPointAry[nPrev]; + Point aDiff = rNext - rPrev; + double fNextLen = CalcDistance(nCenter, nNext) / fAbsLen; + double fPrevLen = CalcDistance(nCenter, nPrev) / fAbsLen; + + // bei SYMMTR gleiche Laenge fuer beide Seiten + if ( GetFlags(nCenter) == XPOLY_SYMMTR ) + { + fPrevLen = (fNextLen + fPrevLen) / 2; + fNextLen = fPrevLen; + } + rNext.X() = rCenter.X() + (long) (fNextLen * aDiff.X()); + rNext.Y() = rCenter.Y() + (long) (fNextLen * aDiff.Y()); + rPrev.X() = rCenter.X() - (long) (fPrevLen * aDiff.X()); + rPrev.Y() = rCenter.Y() - (long) (fPrevLen * aDiff.Y()); + } +} + +/************************************************************************* +|* +|* XPolygon::PointsToBezier() +|* +|* wandelt vier Polygonpunkte in eine Bezierkurve durch diese Punkte um +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 09.01.95 +|* +\************************************************************************/ + +void XPolygon::PointsToBezier(USHORT nFirst) +{ + double nFullLength, nPart1Length, nPart2Length; + double fX0, fY0, fX1, fY1, fX2, fY2, fX3, fY3; + double fTx1, fTx2, fTy1, fTy2; + double fT1, fU1, fT2, fU2, fV; + Point* pPoints = pImpXPolygon->pPointAry; + + if ( nFirst > pImpXPolygon->nPoints - 4 || IsControl(nFirst) || + IsControl(nFirst+1) || IsControl(nFirst+2) || IsControl(nFirst+3) ) + return; + + CheckReference(); + + fTx1 = pPoints[nFirst+1].X(); + fTy1 = pPoints[nFirst+1].Y(); + fTx2 = pPoints[nFirst+2].X(); + fTy2 = pPoints[nFirst+2].Y(); + fX0 = pPoints[nFirst ].X(); + fY0 = pPoints[nFirst ].Y(); + fX3 = pPoints[nFirst+3].X(); + fY3 = pPoints[nFirst+3].Y(); + + nPart1Length = CalcDistance(nFirst, nFirst+1); + nPart2Length = nPart1Length + CalcDistance(nFirst+1, nFirst+2); + nFullLength = nPart2Length + CalcDistance(nFirst+2, nFirst+3); + if ( nFullLength < 20 ) + return; + + if ( nPart2Length == nFullLength ) + nPart2Length -= 1; + if ( nPart1Length == nFullLength ) + nPart1Length = nPart2Length - 1; + if ( nPart1Length <= 0 ) + nPart1Length = 1; + if ( nPart2Length <= 0 || nPart2Length == nPart1Length ) + nPart2Length = nPart1Length + 1; + + fT1 = nPart1Length / nFullLength; + fU1 = 1.0 - fT1; + fT2 = nPart2Length / nFullLength; + fU2 = 1.0 - fT2; + fV = 3 * (1.0 - (fT1 * fU2) / (fT2 * fU1)); + + fX1 = fTx1 / (fT1 * fU1 * fU1) - fTx2 * fT1 / (fT2 * fT2 * fU1 * fU2); + fX1 /= fV; + fX1 -= fX0 * ( fU1 / fT1 + fU2 / fT2) / 3; + fX1 += fX3 * ( fT1 * fT2 / (fU1 * fU2)) / 3; + + fY1 = fTy1 / (fT1 * fU1 * fU1) - fTy2 * fT1 / (fT2 * fT2 * fU1 * fU2); + fY1 /= fV; + fY1 -= fY0 * ( fU1 / fT1 + fU2 / fT2) / 3; + fY1 += fY3 * ( fT1 * fT2 / (fU1 * fU2)) / 3; + + fX2 = fTx2 / (fT2 * fT2 * fU2 * 3) - fX0 * fU2 * fU2 / ( fT2 * fT2 * 3); + fX2 -= fX1 * fU2 / fT2; + fX2 -= fX3 * fT2 / (fU2 * 3); + + fY2 = fTy2 / (fT2 * fT2 * fU2 * 3) - fY0 * fU2 * fU2 / ( fT2 * fT2 * 3); + fY2 -= fY1 * fU2 / fT2; + fY2 -= fY3 * fT2 / (fU2 * 3); + + pPoints[nFirst+1] = Point((long) fX1, (long) fY1); + pPoints[nFirst+2] = Point((long) fX2, (long) fY2); + SetFlags(nFirst+1, XPOLY_CONTROL); + SetFlags(nFirst+2, XPOLY_CONTROL); +} + +/************************************************************************* +|* +|* XPolygon::Translate() +|* +|* Polygon auf den uebergebenen Punkt verschieben +|* Ersterstellung ESO 17.01.95 +|* Letzte Aenderung ESO 17.01.95 +|* +*************************************************************************/ + +void XPolygon::Translate(const Point& rTrans) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + pImpXPolygon->pPointAry[i] += rTrans; +} + +/************************************************************************* +|* +|* XPolygon::Rotate() +|* +|* Alle Punkte um den Punkt rCenter drehen, Sinus und Cosinus +|* muessen uebergeben werden +|* Ersterstellung ESO 09.01.95 +|* Letzte Aenderung ESO 17.01.95 +|* +*************************************************************************/ + +void XPolygon::Rotate(const Point& rCenter, double fSin, double fCos) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + long nX; + long nY; + long nNewX; + long nNewY; + long nCenterX = rCenter.X(); + long nCenterY = rCenter.Y(); + + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + { + Point *pPt = &(pImpXPolygon->pPointAry[i]); + nX = pPt->X()-nCenterX; + nY = pPt->Y()-nCenterY; + nNewX = (long)floor(fCos * nX + fSin * nY + 0.5); + nNewY = -(long)floor(fSin * nX - fCos * nY + 0.5); + pPt->X() = nNewX + nCenterX; + pPt->Y() = nNewY + nCenterY; + + /* und so stand das in einem anderen File auf T: + dass ich am 29-11-1995 gegettet habe. Joe M. + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + { + Point P = pImpXPolygon->pPointAry[i] - rCenter; + long X = P.X(); + long Y = P.Y(); + P.X() = (long)floor(fCos * X + fSin * Y + 0.5); + P.Y() = -(long)floor(fSin * X - fCos * Y + 0.5); + pImpXPolygon->pPointAry[i] = P + rCenter; + */ + } +} + +/************************************************************************* +|* +|* XPolygon::Rotate() +|* +|* Alle Punkte um den Punkt rCenter mit dem Winkel nAngle drehen +|* Winkel in 10tel Grad, Wertebereich 0 - 3600 +|* Ersterstellung ESO 17.01.95 +|* Letzte Aenderung ESO 17.01.95 +|* +*************************************************************************/ + +void XPolygon::Rotate(const Point& rCenter, USHORT nAngle) +{ + nAngle %= 3600; + + if ( nAngle != 0 ) + { + double fAngle = F_PI * nAngle / 1800; + double fSin = sin(fAngle); + double fCos = cos(fAngle); + Rotate(rCenter, fSin, fCos); + } +} + +/************************************************************************* +|* +|* XPolygon::Scale() +|* +|* XPolygon in X- und/oder Y-Richtung skalieren +|* Ersterstellung ESO 01.02.95 +|* Letzte Aenderung ESO 01.02.95 +|* +*************************************************************************/ + +void XPolygon::Scale(double fSx, double fSy) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + { + Point& rPnt = pImpXPolygon->pPointAry[i]; + rPnt.X() = (long)(fSx * rPnt.X()); + rPnt.Y() = (long)(fSy * rPnt.Y()); + } +} + +/************************************************************************* +|* +|* XPolygon::SlantX() +|* +|* XPolygon in X-Richtung um einen beliebigen Winkel kippen, +|* bezogen auf eine Referenz-Y-Koordinate +|* Ersterstellung ESO 01.02.95 +|* Letzte Aenderung ESO 01.02.95 +|* +*************************************************************************/ + +void XPolygon::SlantX(long nYRef, double fSin, double fCos) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + { + Point& rPnt = pImpXPolygon->pPointAry[i]; + long nDy = rPnt.Y() - nYRef; + rPnt.X() += (long)(fSin * nDy); + rPnt.Y() = nYRef + (long)(fCos * nDy); + } +} + +/************************************************************************* +|* +|* XPolygon::SlantY() +|* +|* XPolygon in Y-Richtung um einen beliebigen Winkel kippen, +|* bezogen auf eine Referenz-X-Koordinate +|* Ersterstellung ESO 01.02.95 +|* Letzte Aenderung ESO 01.02.95 +|* +*************************************************************************/ + +void XPolygon::SlantY(long nXRef, double fSin, double fCos) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + { + Point& rPnt = pImpXPolygon->pPointAry[i]; + long nDx = rPnt.X() - nXRef; + rPnt.X() = nXRef + (long)(fCos * nDx); + rPnt.Y() -= (long)(fSin * nDx); + } +} + +/************************************************************************* +|* +|* XPolygon::Distort() +|* +|* XPolygon verzerren, indem die Koordinaten relativ zu einem +|* Referenzrechteck in ein beliebiges Viereck skaliert werden +|* Zuordnung der Viereck-Punkte im Polygon zum Referenzrechteck: +|* 0: links oben 0----1 +|* 1: rechts oben | | +|* 2: rechts unten 3----2 +|* 3: links unten +|* Ersterstellung ESO 07.07.95 +|* Letzte Aenderung ESO 07.07.95 +|* +*************************************************************************/ + +void XPolygon::Distort(const Rectangle& rRefRect, + const XPolygon& rDistortedRect) +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + long Xr, Wr, X1, X2, X3, X4; + long Yr, Hr, Y1, Y2, Y3, Y4; + double fTx, fTy, fUx, fUy; + + Xr = rRefRect.Left(); + Yr = rRefRect.Top(); + Wr = rRefRect.GetWidth(); + Hr = rRefRect.GetHeight(); + + if ( Wr && Hr ) + { + DBG_ASSERT(rDistortedRect.pImpXPolygon->nPoints >= 4, + "Distort-Rechteck zu klein"); + + X1 = rDistortedRect[0].X(); + Y1 = rDistortedRect[0].Y(); + X2 = rDistortedRect[1].X(); + Y2 = rDistortedRect[1].Y(); + X3 = rDistortedRect[3].X(); + Y3 = rDistortedRect[3].Y(); + X4 = rDistortedRect[2].X(); + Y4 = rDistortedRect[2].Y(); + + USHORT nPntCnt = pImpXPolygon->nPoints; + + for (USHORT i = 0; i < nPntCnt; i++) + { + Point& rPnt = pImpXPolygon->pPointAry[i]; + + fTx = (double)(rPnt.X() - Xr) / Wr; + fTy = (double)(rPnt.Y() - Yr) / Hr; + fUx = 1.0 - fTx; + fUy = 1.0 - fTy; + + rPnt.X() = (long) ( fUy * (fUx * X1 + fTx * X2) + + fTy * (fUx * X3 + fTx * X4) ); + rPnt.Y() = (long) ( fUx * (fUy * Y1 + fTy * Y3) + + fTx * (fUy * Y2 + fTy * Y4) ); + } + } +} + +/************************************************************************* +|* +|* Bestimme den linken, unteren Punkt des Polygons und richte das +|* Polygon so aus, dass dieser Punkt auf dem Index 0 liegt +|* +\************************************************************************/ + +void XPolygon::Rotate20() +{ + pImpXPolygon->CheckPointDelete(); + CheckReference(); + + double fMinY = pImpXPolygon->pPointAry->Y(); + double fMinX = pImpXPolygon->pPointAry->X(); + long nPntCnt = pImpXPolygon->nPoints; + long nIndex0 = 0; + + for (long nPoints = 1; + nPoints < nPntCnt; + nPoints ++) + { + Point &rPnt = pImpXPolygon->pPointAry[nPoints]; + + if ((rPnt.X () < fMinX) || (fMinX == rPnt.X ()) && + (fMinY >= rPnt.Y ())) + { + fMinX = rPnt.X (); + fMinY = rPnt.Y (); + nIndex0 = nPoints; + } + } + + if (nIndex0 < nPntCnt) + { + Point *pTemp = new Point [nIndex0]; + memcpy (pTemp, pImpXPolygon->pPointAry, nIndex0 * sizeof (Point)); + memcpy (pImpXPolygon->pPointAry, &pImpXPolygon->pPointAry [nIndex0], (nPntCnt - nIndex0) * sizeof (Point)); + memcpy (&pImpXPolygon->pPointAry [nIndex0], pTemp, nIndex0 * sizeof (Point)); + delete[] pTemp; + } +} + +basegfx::B2DPolygon XPolygon::getB2DPolygon() const +{ + // #i74631# use tools Polygon class for conversion to not have the code doubled + // here. This needs one more conversion but avoids different convertors in + // the long run + DBG_ASSERT(pImpXPolygon != 0, "XPolygon::getB2DPolygon(): XPolygon has no implementation incarnated (!)"); + const Polygon aSource(GetPointCount(), pImpXPolygon->pPointAry, pImpXPolygon->pFlagAry); + + return aSource.getB2DPolygon(); +} + +XPolygon::XPolygon(const basegfx::B2DPolygon& rPolygon) +{ + // #i74631# use tools Polygon class for conversion to not have the code doubled + // here. This needs one more conversion but avoids different convertors in + // the long run + DBG_CTOR(XPolygon,NULL); + + const Polygon aSource(rPolygon); + USHORT nSize = aSource.GetSize(); + pImpXPolygon = new ImpXPolygon( nSize ); + pImpXPolygon->nPoints = nSize; + + for( USHORT i = 0; i < nSize; i++ ) + { + pImpXPolygon->pPointAry[i] = aSource[i]; + pImpXPolygon->pFlagAry[i] = (BYTE) aSource.GetFlags( i ); + } +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +//+--------------- XPolyPolygon -----------------------------------------+ +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +/************************************************************************* +|* +|* ImpXPolyPolygon::ImpXPolyPolygon() +|* +|* Beschreibung Erzeugt das XPolygon-Array +|* Ersterstellung CL 09.11.94 +|* Letzte Aenderung MM 09.11.94 +|* +*************************************************************************/ + +ImpXPolyPolygon::ImpXPolyPolygon( const ImpXPolyPolygon& rImpXPolyPoly ) : + aXPolyList( rImpXPolyPoly.aXPolyList ) +{ + nRefCount = 1; + + // Einzelne Elemente duplizieren + XPolygon* pXPoly = aXPolyList.First(); + while ( pXPoly ) + { + aXPolyList.Replace( new XPolygon( *(aXPolyList.GetCurObject()) ) ); + pXPoly = aXPolyList.Next(); + } +} + + +/************************************************************************* +|* +|* ImpXPolyPolygon::~ImpXPolyPolygon() +|* +|* Beschreibung Loescht das Polygon-Array +|* Ersterstellung CL 09.06.93 +|* Letzte Aenderung CL 09.06.93 +|* +*************************************************************************/ + +ImpXPolyPolygon::~ImpXPolyPolygon() +{ + XPolygon* pXPoly = aXPolyList.First(); + while( pXPoly ) + { + delete pXPoly; + pXPoly = aXPolyList.Next(); + } +} + +/************************************************************************* +|* +|* ImpXPolyPolygon::operator==() +|* +|* Ersterstellung Joe 26-09-95 +|* Letzte Aenderung +|* +*************************************************************************/ + + +bool ImpXPolyPolygon::operator==(const ImpXPolyPolygon& rImpXPolyPoly) const +{ + USHORT nAnz=(USHORT)aXPolyList.Count(); + const XPolygonList& rCmpList=rImpXPolyPoly.aXPolyList; + if (nAnz!=(USHORT)rCmpList.Count()) return FALSE; + bool bEq=true; + for (USHORT i=nAnz; i>0 && bEq;) { + i--; + bEq= *aXPolyList.GetObject(i) == *rCmpList.GetObject(i); + } + return bEq; +} + +/************************************************************************* +|* +|* XPolyPolygon::XPolyPolygon() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolyPolygon::XPolyPolygon( USHORT nInitSize, USHORT nResize ) +{ + DBG_CTOR(XPolyPolygon,NULL); + pImpXPolyPolygon = new ImpXPolyPolygon( nInitSize, nResize ); +} + + +/************************************************************************* +|* +|* XPolyPolygon::XPolyPolygon() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolyPolygon::XPolyPolygon( const XPolygon& rXPoly ) +{ + DBG_CTOR(XPolyPolygon,NULL); + pImpXPolyPolygon = new ImpXPolyPolygon; + pImpXPolyPolygon->aXPolyList.Insert( new XPolygon( rXPoly ) ); +} + +/************************************************************************* +|* +|* XPolyPolygon::XPolyPolygon() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolyPolygon::XPolyPolygon( const XPolyPolygon& rXPolyPoly ) +{ + DBG_CTOR(XPolyPolygon,NULL); + pImpXPolyPolygon = rXPolyPoly.pImpXPolyPolygon; + pImpXPolyPolygon->nRefCount++; +} + +/************************************************************************* +|* +|* XPolyPolygon::XPolyPolygon() +|* +|* XPolyPolygon aus einen Standard-PolyPolygon erzeugen +|* Ersterstellung 18.01.95 ESO +|* Letzte Aenderung 18.01.95 ESO +|* +*************************************************************************/ + +XPolyPolygon::XPolyPolygon( const PolyPolygon& rPolyPoly ) +{ + DBG_CTOR(XPolyPolygon,NULL); + pImpXPolyPolygon = new ImpXPolyPolygon; + + for (USHORT i = 0; i < rPolyPoly.Count(); i++) + pImpXPolyPolygon->aXPolyList.Insert( + new XPolygon(rPolyPoly.GetObject(i)) ); +} + +/************************************************************************* +|* +|* XPolyPolygon::~XPolyPolygon() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolyPolygon::~XPolyPolygon() +{ + DBG_DTOR(XPolyPolygon,NULL); + if( pImpXPolyPolygon->nRefCount > 1 ) + pImpXPolyPolygon->nRefCount--; + else + delete pImpXPolyPolygon; +} + +/************************************************************************* +|* +|* XPolygon::CheckReference() +|* +|* Referenzzaehler desImpXPolyPoly pruefen und ggf. von diesem abkoppeln +|* Ersterstellung 18.01.95 ESO +|* Letzte Aenderung 18.01.95 ESO +|* +*************************************************************************/ + +void XPolyPolygon::CheckReference() +{ + if( pImpXPolyPolygon->nRefCount > 1 ) + { + pImpXPolyPolygon->nRefCount--; + pImpXPolyPolygon = new ImpXPolyPolygon( *pImpXPolyPolygon ); + } +} + +/************************************************************************* +|* +|* XPolyPolygon::Insert() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +void XPolyPolygon::Insert( const XPolygon& rXPoly, USHORT nPos ) +{ + CheckReference(); + XPolygon* pXPoly = new XPolygon( rXPoly ); + pImpXPolyPolygon->aXPolyList.Insert( pXPoly, nPos ); +} + +/************************************************************************* +|* +|* XPolyPolygon::Insert() +|* +|* saemtliche XPolygone aus einem XPolyPolygon einfuegen +|* Ersterstellung 18.01.95 ESO +|* Letzte Aenderung 18.01.95 ESO +|* +*************************************************************************/ + +void XPolyPolygon::Insert( const XPolyPolygon& rXPolyPoly, USHORT nPos ) +{ + CheckReference(); + + for (USHORT i = 0; i < rXPolyPoly.Count(); i++) + { + XPolygon* pXPoly = new XPolygon(rXPolyPoly[i]); + pImpXPolyPolygon->aXPolyList.Insert(pXPoly, nPos); + if ( nPos != XPOLYPOLY_APPEND ) + nPos++; + } +} + +/************************************************************************* +|* +|* XPolyPolygon::Remove() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolygon XPolyPolygon::Remove( USHORT nPos ) +{ + CheckReference(); + XPolygon* pTmpXPoly = pImpXPolyPolygon->aXPolyList.Remove( nPos ); + XPolygon aXPoly( *pTmpXPoly ); + delete pTmpXPoly; + return aXPoly; +} + + +/************************************************************************* +|* +|* XPolyPolygon::Replace() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolygon XPolyPolygon::Replace( const XPolygon& rXPoly, USHORT nPos ) +{ + CheckReference(); + XPolygon* pXPoly = new XPolygon( rXPoly ); + XPolygon* pTmpXPoly = pImpXPolyPolygon->aXPolyList.Replace( pXPoly, nPos ); + XPolygon aXPoly( *pTmpXPoly ); + delete pTmpXPoly; + return aXPoly; +} + + +/************************************************************************* +|* +|* XPolyPolygon::GetObject() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +const XPolygon& XPolyPolygon::GetObject( USHORT nPos ) const +{ + return *(pImpXPolyPolygon->aXPolyList.GetObject( nPos )); +} + + +/************************************************************************* +|* +|* XPolyPolygon::Clear() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung TH 17.10.94 +|* +*************************************************************************/ + +void XPolyPolygon::Clear() +{ + if ( pImpXPolyPolygon->nRefCount > 1 ) + { + pImpXPolyPolygon->nRefCount--; + pImpXPolyPolygon = new ImpXPolyPolygon(); + } + else + { + XPolygon* pXPoly = pImpXPolyPolygon->aXPolyList.First(); + while( pXPoly ) + { + delete pXPoly; + pXPoly = pImpXPolyPolygon->aXPolyList.Next(); + } + pImpXPolyPolygon->aXPolyList.Clear(); + } +} + + +/************************************************************************* +|* +|* XPolyPolygon::Count() +|* +|* Beschreibung +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +USHORT XPolyPolygon::Count() const +{ + return (USHORT)(pImpXPolyPolygon->aXPolyList.Count()); +} + + +/************************************************************************* +|* +|* XPolyPolygon::Move() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung TH 04.10.94 +|* Letzte Aenderung TH 04.10.94 +|* +*************************************************************************/ + +void XPolyPolygon::Move( long nHorzMove, long nVertMove ) +{ + // Diese Abfrage sollte man fuer die DrawEngine durchfuehren + if ( !nHorzMove && !nVertMove ) + return; + + // Referenzcounter beruecksichtigen + CheckReference(); + + // Punkte verschieben + XPolygon* pXPoly = pImpXPolyPolygon->aXPolyList.First(); + while( pXPoly ) + { + pXPoly->Move( nHorzMove, nVertMove ); + pXPoly = pImpXPolyPolygon->aXPolyList.Next(); + } +} + +/************************************************************************* +|* +|* XPolyPolygon::GetBoundRect() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung TH 04.10.94 +|* Letzte Aenderung TH 04.10.94 +|* +*************************************************************************/ + +Rectangle XPolyPolygon::GetBoundRect() const +{ + USHORT nXPoly = (USHORT)pImpXPolyPolygon->aXPolyList.Count(); + Rectangle aRect; + + for ( USHORT n = 0; n < nXPoly; n++ ) + { + const XPolygon* pXPoly = pImpXPolyPolygon->aXPolyList.GetObject( n ); + aRect.Union( pXPoly->GetBoundRect() ); + } + + return aRect; +} + + +/************************************************************************* +|* +|* XPolyPolygon::operator[]() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung TH 28.10.94 +|* Letzte Aenderung TH 28.10.94 +|* +*************************************************************************/ + +XPolygon& XPolyPolygon::operator[]( USHORT nPos ) +{ + CheckReference(); + return *(pImpXPolyPolygon->aXPolyList.GetObject( nPos )); +} + +/************************************************************************* +|* +|* XPolyPolygon::operator=() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung CL 27.01.93 +|* +*************************************************************************/ + +XPolyPolygon& XPolyPolygon::operator=( const XPolyPolygon& rXPolyPoly ) +{ + rXPolyPoly.pImpXPolyPolygon->nRefCount++; + + if( pImpXPolyPolygon->nRefCount > 1 ) + pImpXPolyPolygon->nRefCount--; + else + delete pImpXPolyPolygon; + + pImpXPolyPolygon = rXPolyPoly.pImpXPolyPolygon; + return *this; +} + + +/************************************************************************* +|* +|* XPolyPolygon::operator==() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung Joe 27.01.93 +|* +*************************************************************************/ + +BOOL XPolyPolygon::operator==( const XPolyPolygon& rXPolyPoly ) const +{ + if (pImpXPolyPolygon==rXPolyPoly.pImpXPolyPolygon) return TRUE; + return *pImpXPolyPolygon == *rXPolyPoly.pImpXPolyPolygon; +} + + +/************************************************************************* +|* +|* XPolyPolygon::operator!=() +|* +|* Beschreibung POLY.SDW +|* Ersterstellung CL 27.01.93 +|* Letzte Aenderung Joe 27.01.93 +|* +*************************************************************************/ + +BOOL XPolyPolygon::operator!=( const XPolyPolygon& rXPolyPoly ) const +{ + if (pImpXPolyPolygon==rXPolyPoly.pImpXPolyPolygon) return FALSE; + return *pImpXPolyPolygon != *rXPolyPoly.pImpXPolyPolygon; +} + +/************************************************************************* +|* +|* XPolyPolygon::Translate() +|* +|* Alle Polygone auf den uebergebenen Punkt verschieben +|* Ersterstellung ESO 25.01.95 +|* Letzte Aenderung ESO 25.01.95 +|* +*************************************************************************/ + +void XPolyPolygon::Translate(const Point& rTrans) +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->Translate(rTrans); +} + +/************************************************************************* +|* +|* XPolyPolygon::Rotate() +|* +|* Alle Polygone um den Punkt rCenter drehen, Sinus und Cosinus +|* muessen uebergeben werden +|* Ersterstellung ESO 25.01.95 +|* Letzte Aenderung ESO 25.01.95 +|* +*************************************************************************/ + +void XPolyPolygon::Rotate(const Point& rCenter, double fSin, double fCos) +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->Rotate(rCenter, fSin, fCos); +} + +/************************************************************************* +|* +|* Bestimme den linken, unteren Punkt des Polygons und richte das +|* Polygon so aus, dass dieser Punkt auf dem Index 0 liegt +|* +\************************************************************************/ + +void XPolyPolygon::Rotate20() +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->Rotate20(); +} + +/************************************************************************* +|* +|* XPolyPolygon::Rotate() +|* +|* Alle Poylgone um den Punkt rCenter mit dem Winkel nAngle drehen +|* Winkel in 10tel Grad, Wertebereich 0 - 3600 +|* Ersterstellung ESO 25.01.95 +|* Letzte Aenderung ESO 25.01.95 +|* +*************************************************************************/ + +void XPolyPolygon::Rotate(const Point& rCenter, USHORT nAngle) +{ + nAngle %= 3600; + + if ( nAngle != 0 ) + { + double fAngle = F_PI * nAngle / 1800; + double fSin = sin(fAngle); + double fCos = cos(fAngle); + Rotate(rCenter, fSin, fCos); + } +} + +/************************************************************************* +|* +|* XPolyPolygon::Scale() +|* +|* Alle Polygone in X- und/oder Y-Richtung skalieren +|* Ersterstellung ESO 01.02.95 +|* Letzte Aenderung ESO 01.02.95 +|* +*************************************************************************/ + +void XPolyPolygon::Scale(double fSx, double fSy) +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->Scale(fSx, fSy); +} + +/************************************************************************* +|* +|* XPolyPolygon::SlantX() +|* +|* Alle Polygone in X-Richtung um einen beliebigen Winkel kippen, +|* bezogen auf eine Referenz-Y-Koordinate +|* Ersterstellung ESO 01.02.95 +|* Letzte Aenderung ESO 01.02.95 +|* +*************************************************************************/ + +void XPolyPolygon::SlantX(long nYRef, double fSin, double fCos) +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->SlantX(nYRef, fSin, fCos); +} + +/************************************************************************* +|* +|* XPolyPolygon::SlantY() +|* +|* Alle Polygone in Y-Richtung um einen beliebigen Winkel kippen, +|* bezogen auf eine Referenz-X-Koordinate +|* Ersterstellung ESO 01.02.95 +|* Letzte Aenderung ESO 01.02.95 +|* +*************************************************************************/ + +void XPolyPolygon::SlantY(long nXRef, double fSin, double fCos) +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->SlantY(nXRef, fSin, fCos); +} + +/************************************************************************* +|* +|* XPolygon::Distort() +|* +|* XPolygon verzerren, indem die Koordinaten relativ zu einem +|* Referenzrechteck in ein beliebiges Viereck skaliert werden +|* Zuordnung der Viereck-Punkte im Polygon zum Referenzrechteck: +|* 0: links oben 0----1 +|* 1: rechts oben | | +|* 2: rechts unten 3----2 +|* 3: links unten +|* Ersterstellung ESO 07.07.95 +|* Letzte Aenderung ESO 07.07.95 +|* +*************************************************************************/ + +void XPolyPolygon::Distort(const Rectangle& rRefRect, + const XPolygon& rDistortedRect) +{ + CheckReference(); + + for (USHORT i = 0; i < Count(); i++) + pImpXPolyPolygon->aXPolyList.GetObject(i)->Distort(rRefRect, + rDistortedRect); +} + +basegfx::B2DPolyPolygon XPolyPolygon::getB2DPolyPolygon() const +{ + basegfx::B2DPolyPolygon aRetval; + + for(sal_uInt16 a(0L); a < Count(); a++) + { + const XPolygon& rPoly = (*this)[a]; + aRetval.append(rPoly.getB2DPolygon()); + } + + return aRetval; +} + +XPolyPolygon::XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon) +{ + DBG_CTOR(XPolyPolygon,NULL); + pImpXPolyPolygon = new ImpXPolyPolygon( 16, 16 ); + + for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++) + { + basegfx::B2DPolygon aCandidate = rPolyPolygon.getB2DPolygon(a); + XPolygon aNewPoly(aCandidate); + Insert(aNewPoly); + } +} + +// eof diff --git a/svx/source/xoutdev/makefile.mk b/svx/source/xoutdev/makefile.mk new file mode 100644 index 000000000000..1ed48bc71f08 --- /dev/null +++ b/svx/source/xoutdev/makefile.mk @@ -0,0 +1,59 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=svx +PROJECTPCH=xout +PROJECTPCHSOURCE=xoutpch +TARGET=xout +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/xattr.obj \ + $(SLO)$/xattr2.obj \ + $(SLO)$/xattrbmp.obj \ + $(SLO)$/xpool.obj \ + $(SLO)$/xtable.obj \ + $(SLO)$/xtabcolr.obj \ + $(SLO)$/xtablend.obj \ + $(SLO)$/xtabdash.obj \ + $(SLO)$/xtabhtch.obj \ + $(SLO)$/xtabgrdt.obj \ + $(SLO)$/xtabbtmp.obj \ + $(SLO)$/xexch.obj \ + $(SLO)$/_xpoly.obj \ + $(SLO)$/_xoutbmp.obj + +.INCLUDE : target.mk diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx new file mode 100644 index 000000000000..a301e47e5c25 --- /dev/null +++ b/svx/source/xoutdev/xattr.cxx @@ -0,0 +1,5778 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include <com/sun/star/drawing/Hatch.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/LineDash.hpp> +#include <com/sun/star/drawing/DashStyle.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/drawing/PointSequence.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <svl/itempool.hxx> +#include <editeng/memberids.hrc> +#include <tools/stream.hxx> + +#include "unoapi.hxx" +#include <svl/style.hxx> +#include "unopolyhelper.hxx" + +#include <tools/bigint.hxx> +#include <svl/itemset.hxx> +#include <svx/dialogs.hrc> +#include "svdstr.hrc" +#include "xattr.hxx" +#include <svx/xtable.hxx> +#include <svx/dialmgr.hxx> +#include <editeng/itemtype.hxx> +#include <svx/xdef.hxx> +#include <svx/unomid.hxx> +#include <svx/svdmodel.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/vector/b2dvector.hxx> + +#include <stdio.h> + +using namespace ::rtl; +using namespace ::com::sun::star; + +#define GLOBALOVERFLOW + +#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) +#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L)) + +/************************************************************************/ + +#define VCLTOSVCOL( rCol ) (USHORT)((((USHORT)(rCol))<<8)|(rCol)) + +/************************************************************************/ + +XubString aNameOrIndexEmptyString; + +TYPEINIT1_AUTOFACTORY(NameOrIndex, SfxStringItem); + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +long ScaleMetricValue( long nVal, long nMul, long nDiv ) +{ + BigInt aVal( nVal ); + + aVal *= nMul; + + if ( aVal.IsNeg() != ( nDiv < 0 ) ) + aVal-=nDiv/2; // fuer korrektes Runden + else + aVal+=nDiv/2; // fuer korrektes Runden + + aVal/=nDiv; + + return long( aVal ); +} + +/************************************************************************* +|* +|* NameOrIndex::NameOrIndex(USHORT nWhich, INT32 nIndex) +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +NameOrIndex::NameOrIndex(USHORT _nWhich, INT32 nIndex) : + SfxStringItem(_nWhich, aNameOrIndexEmptyString), + nPalIndex(nIndex) +{ +} + +/************************************************************************* +|* +|* NameOrIndex::NameOrIndex(USHORT nWhich, const String& rName) +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +NameOrIndex::NameOrIndex(USHORT _nWhich, const XubString& rName) : + SfxStringItem(_nWhich, rName), + nPalIndex(-1) +{ +} + +/************************************************************************* +|* +|* NameOrIndex::NameOrIndex(USHORT nWhich, SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +NameOrIndex::NameOrIndex(USHORT _nWhich, SvStream& rIn) : + SfxStringItem(_nWhich, rIn) +{ + rIn >> nPalIndex; +} + +/************************************************************************* +|* +|* NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) : + SfxStringItem(rNameOrIndex), + nPalIndex(rNameOrIndex.nPalIndex) +{ +} + +/************************************************************************* +|* +|* int NameOrIndex::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +int NameOrIndex::operator==(const SfxPoolItem& rItem) const +{ + return ( SfxStringItem::operator==(rItem) && + ((const NameOrIndex&) rItem).nPalIndex == nPalIndex ); +} + +/************************************************************************* +|* +|* SfxPoolItem* NameOrIndex::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +SfxPoolItem* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const +{ + + return new NameOrIndex(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* NameOrIndex::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +SfxPoolItem* NameOrIndex::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new NameOrIndex(Which(), rIn); +} + +/************************************************************************* +|* +|* SvStream* NameOrIndex::Store(SvStream& rIn) const +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +SvStream& NameOrIndex::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + SfxStringItem::Store( rOut, nItemVersion ); + rOut << nPalIndex; + return rOut; +} + +/** this static checks if the given NameOrIndex item has a unique name for its value. + The returned String is a unique name for an item with this value in both given pools. + Argument pPool2 can be null. + If returned string equals NameOrIndex->GetName(), the name was already unique. +*/ +String NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, const SfxItemPool* /*pPool2*/, SvxCompareValueFunc pCompareValueFunc, USHORT nPrefixResId, XPropertyList* pDefaults ) +{ + sal_Bool bForceNew = sal_False; + + String aUniqueName; + SvxUnogetInternalNameForItem( nWhich, pCheckItem->GetName(), aUniqueName ); + + // 2. if we have a name check if there is already an item with the + // same name in the documents pool with a different line end or start + + if( aUniqueName.Len() && pPool1 ) + { + const sal_uInt16 nCount = pPool1->GetItemCount( nWhich ); + + const NameOrIndex *pItem; + for( sal_uInt16 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)pPool1->GetItem( nWhich, nSurrogate ); + + if( pItem && ( pItem->GetName() == pCheckItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( !pCompareValueFunc( pItem, pCheckItem ) ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + } + + // if we have no name yet, find existing item with same conent or + // create a unique name + if( aUniqueName.Len() == 0 ) + { + sal_Int32 nUserIndex = 1; + const ResId aRes(SVX_RES(nPrefixResId)); + String aUser( aRes ); + aUser += sal_Unicode( ' ' ); + + if( pDefaults ) + { + const int nCount = pDefaults->Count(); + int nIndex; + for( nIndex = 0; nIndex < nCount; nIndex++ ) + { + XPropertyEntry* pEntry = pDefaults->Get( nIndex, 0 ); + if( pEntry ) + { + bool bFound = false; + + switch( nWhich ) + { + case XATTR_FILLBITMAP: + bFound = (((XFillBitmapItem*)pCheckItem)->GetBitmapValue().GetGraphicObject().GetUniqueID() == + ((XBitmapEntry*)pEntry)->GetXBitmap().GetGraphicObject().GetUniqueID()); + break; + case XATTR_LINEDASH: + bFound = (((XLineDashItem*)pCheckItem)->GetDashValue() == ((XDashEntry*)pEntry) ->GetDash()); + break; + case XATTR_LINESTART: + bFound = (((XLineStartItem*)pCheckItem)->GetLineStartValue() == ((XLineEndEntry*)pEntry)->GetLineEnd()); + break; + case XATTR_LINEEND: + bFound = (((XLineEndItem*)pCheckItem)->GetLineEndValue() == ((XLineEndEntry*)pEntry)->GetLineEnd()); + break; + case XATTR_FILLGRADIENT: + bFound = (((XFillGradientItem*)pCheckItem)->GetGradientValue() == ((XGradientEntry*)pEntry)->GetGradient()); + break; + case XATTR_FILLHATCH: + bFound = (((XFillHatchItem*)pCheckItem)->GetHatchValue() == ((XHatchEntry*)pEntry)->GetHatch()); + break; + } + + if( bFound ) + { + aUniqueName = pEntry->GetName(); + break; + } + else + { + sal_Int32 nThisIndex = pEntry->GetName().Copy( aUser.Len() ).ToInt32(); + if( nThisIndex >= nUserIndex ) + nUserIndex = nThisIndex + 1; + } + } + } + } + + if( (aUniqueName.Len() == 0) && pPool1 ) + { + const sal_uInt16 nCount = pPool1->GetItemCount( nWhich ); + const NameOrIndex *pItem; + for( sal_uInt16 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)pPool1->GetItem( nWhich, nSurrogate ); + + if( pItem && pItem->GetName().Len() ) + { + if( !bForceNew && pCompareValueFunc( pItem, pCheckItem ) ) + return pItem->GetName(); + + if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 ) + { + sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32(); + if( nThisIndex >= nUserIndex ) + nUserIndex = nThisIndex + 1; + } + } + } + aUniqueName = aUser; + aUniqueName += String::CreateFromInt32( nUserIndex ); + } + } + + return aUniqueName; +} + +//************************************************************************* + +// ------------------- +// class XColorItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XColorItem, NameOrIndex); + +/************************************************************************* +|* +|* XColorItem::XColorItem(USHORT nWhich, INT32 nIndex, const Color& rTheColor) +|* +\************************************************************************/ + +XColorItem::XColorItem(USHORT _nWhich, INT32 nIndex, const Color& rTheColor) : + NameOrIndex(_nWhich, nIndex), + aColor(rTheColor) +{ +} + +/************************************************************************* +|* +|* XColorItem::XColorItem(USHORT nWhich, const String& rName, const Color& rTheColor) +|* +\************************************************************************/ + +XColorItem::XColorItem(USHORT _nWhich, const XubString& rName, const Color& rTheColor) : + NameOrIndex(_nWhich, rName), + aColor(rTheColor) +{ +} + +/************************************************************************* +|* +|* XColorItem::XColorItem(const XColorItem& rItem) +|* +\************************************************************************/ + +XColorItem::XColorItem(const XColorItem& rItem) : + NameOrIndex(rItem), + aColor(rItem.aColor) +{ +} + +/************************************************************************* +|* +|* XColorItem::XColorItem(USHORT nWhich, SvStream& rIn) +|* +\************************************************************************/ + +XColorItem::XColorItem(USHORT _nWhich, SvStream& rIn) : + NameOrIndex(_nWhich, rIn) +{ + if (!IsIndex()) + { + rIn >> aColor; + } +} + +/************************************************************************* +|* +|* XColorItem::Clone(SfxItemPool* pPool) const +|* +\************************************************************************/ + +SfxPoolItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XColorItem(*this); +} + +/************************************************************************* +|* +|* int XColorItem::operator==(const SfxPoolItem& rItem) const +|* +\************************************************************************/ + +int XColorItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && + ((const XColorItem&) rItem).aColor == aColor ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XColorItem::Create(SvStream& rIn, USHORT nVer) const +|* +\************************************************************************/ + +SfxPoolItem* XColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XColorItem(Which(), rIn); +} + +/************************************************************************* +|* +|* SfxPoolItem* XColorItem::Store(SvStream& rOut) const +|* +\************************************************************************/ + +SvStream& XColorItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if ( !IsIndex() ) + { + rOut << aColor; + } + + return rOut; +} + +/************************************************************************* +|* +|* const XColor& XColorItem::GetColorValue(const XColorTable* pTable) const +|* +\************************************************************************/ + +const Color& XColorItem::GetColorValue(const XColorTable* pTable) const +{ + if (!IsIndex()) + return aColor; + else + return pTable->GetColor(GetIndex())->GetColor(); + +} + +sal_Bool XColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetColorValue().GetRGBColor(); + return sal_True; +} + +sal_Bool XColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetColorValue( nValue ); + + return sal_True; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Linienattribute +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +//--------------------- +// class XLineStyleItem +//--------------------- +TYPEINIT1_AUTOFACTORY(XLineStyleItem, SfxEnumItem); + +/************************************************************************* +|* +|* XLineStyleItem::XLineStyleItem(XLineStyle eTheLineStyle) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineStyleItem::XLineStyleItem(XLineStyle eTheLineStyle) : + SfxEnumItem(XATTR_LINESTYLE, sal::static_int_cast< USHORT >(eTheLineStyle)) +{ +} + +/************************************************************************* +|* +|* XLineStyleItem::XLineStyleItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineStyleItem::XLineStyleItem(SvStream& rIn) : + SfxEnumItem(XATTR_LINESTYLE, rIn) +{ +} + +/************************************************************************* +|* +|* XLineStyleItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 09.11.94 +|* Letzte Aenderung 09.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineStyleItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineStyleItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineStyleItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineStyleItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + { + USHORT nId = 0; + + switch( (USHORT)GetValue() ) + { + case XLINE_NONE: + nId = RID_SVXSTR_INVISIBLE; + break; + case XLINE_SOLID: + nId = RID_SVXSTR_SOLID; + break; + } + + if ( nId ) + rText = SVX_RESSTR( nId ); + return ePres; + } + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineStyleItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + ::com::sun::star::drawing::LineStyle eLS = (::com::sun::star::drawing::LineStyle)GetValue(); + rVal <<= eLS; + return sal_True; +} + +sal_Bool XLineStyleItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + ::com::sun::star::drawing::LineStyle eLS; + if(!(rVal >>= eLS )) + { + // also try an int (for Basic) + sal_Int32 nLS = 0; + if(!(rVal >>= nLS)) + return sal_False; + eLS = (::com::sun::star::drawing::LineStyle)nLS; + } + + SetValue( sal::static_int_cast< USHORT >( eLS ) ); + return sal_True; +} + +//------------------------------------------------------------------------ + +USHORT XLineStyleItem::GetValueCount() const +{ + return 3; +} + + +// ------------ +// class XDash +// ------------ +/************************************************************************* +|* +|* XDash::XDash(XDashStyle, USHORT, ULONG, USHORT, ULONG, ULONG) +|* +|* Beschreibung +|* Ersterstellung 21.11.94 +|* Letzte Aenderung 21.11.94 +|* +*************************************************************************/ + +XDash::XDash(XDashStyle eTheDash, USHORT nTheDots, ULONG nTheDotLen, + USHORT nTheDashes, ULONG nTheDashLen, ULONG nTheDistance) : + eDash(eTheDash), + nDots(nTheDots), + nDotLen(nTheDotLen), + nDashes(nTheDashes), + nDashLen(nTheDashLen), + nDistance(nTheDistance) +{ +} + +/************************************************************************* +|* +|* int XDash::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 29.11.94 +|* Letzte Aenderung 29.11.94 +|* +*************************************************************************/ + +bool XDash::operator==(const XDash& rDash) const +{ + return ( eDash == rDash.eDash && + nDots == rDash.nDots && + nDotLen == rDash.nDotLen && + nDashes == rDash.nDashes && + nDashLen == rDash.nDashLen && + nDistance == rDash.nDistance ); +} + +// XDash is translated into an array of doubles which describe the lengths of the +// dashes, dots and empty passages. It returns the complete length of the full DashDot +// sequence and fills the given vetor of doubles accordingly (also resizing, so deleting it). +static double SMALLEST_DASH_WIDTH(26.95); +double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const +{ + double fFullDotDashLen(0.0); + const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2; + rDotDashArray.resize( nNumDotDashArray, 0.0 ); + sal_uInt16 a; + sal_uInt16 nIns(0); + double fDashDotDistance = (double)GetDistance(); + double fSingleDashLen = (double)GetDashLen(); + double fSingleDotLen = (double)GetDotLen(); + + if(GetDashStyle() == XDASH_RECTRELATIVE || GetDashStyle() == XDASH_ROUNDRELATIVE) + { + if(fLineWidth != 0.0) + { + double fFactor = fLineWidth / 100.0; + + if(GetDashes()) + { + if(GetDashLen()) + { + // is a dash + fSingleDashLen *= fFactor; + } + else + { + // is a dot + fSingleDashLen = fLineWidth; + } + } + + if(GetDots()) + { + if(GetDotLen()) + { + // is a dash + fSingleDotLen *= fFactor; + } + else + { + // is a dot + fSingleDotLen = fLineWidth; + } + } + + if(GetDashes() || GetDots()) + { + if(GetDistance()) + { + fDashDotDistance *= fFactor; + } + else + { + fDashDotDistance = fLineWidth; + } + } + } + else + { + if(GetDashes()) + { + if(GetDashLen()) + { + // is a dash + fSingleDashLen = (SMALLEST_DASH_WIDTH * fSingleDashLen) / 100.0; + } + else + { + // is a dot + fSingleDashLen = SMALLEST_DASH_WIDTH; + } + } + + if(GetDots()) + { + if(GetDotLen()) + { + // is a dash + fSingleDotLen = (SMALLEST_DASH_WIDTH * fSingleDotLen) / 100.0; + } + else + { + // is a dot + fSingleDotLen = SMALLEST_DASH_WIDTH; + } + } + + if(GetDashes() || GetDots()) + { + if(GetDistance()) + { + // dash as distance + fDashDotDistance = (SMALLEST_DASH_WIDTH * fDashDotDistance) / 100.0; + } + else + { + // dot as distance + fDashDotDistance = SMALLEST_DASH_WIDTH; + } + } + } + } + else + { + // smallest dot size compare value + double fDotCompVal(fLineWidth != 0.0 ? fLineWidth : SMALLEST_DASH_WIDTH); + + // absolute values + if(GetDashes()) + { + if(GetDashLen()) + { + // is a dash + if(fSingleDashLen < SMALLEST_DASH_WIDTH) + { + fSingleDashLen = SMALLEST_DASH_WIDTH; + } + } + else + { + // is a dot + if(fSingleDashLen < fDotCompVal) + { + fSingleDashLen = fDotCompVal; + } + } + } + + if(GetDots()) + { + if(GetDotLen()) + { + // is a dash + if(fSingleDotLen < SMALLEST_DASH_WIDTH) + { + fSingleDotLen = SMALLEST_DASH_WIDTH; + } + } + else + { + // is a dot + if(fSingleDotLen < fDotCompVal) + { + fSingleDotLen = fDotCompVal; + } + } + } + + if(GetDashes() || GetDots()) + { + if(GetDistance()) + { + // dash as distance + if(fDashDotDistance < SMALLEST_DASH_WIDTH) + { + fDashDotDistance = SMALLEST_DASH_WIDTH; + } + } + else + { + // dot as distance + if(fDashDotDistance < fDotCompVal) + { + fDashDotDistance = fDotCompVal; + } + } + } + } + + for(a=0;a<GetDots();a++) + { + rDotDashArray[nIns++] = fSingleDotLen; + fFullDotDashLen += fSingleDotLen; + rDotDashArray[nIns++] = fDashDotDistance; + fFullDotDashLen += fDashDotDistance; + } + + for(a=0;a<GetDashes();a++) + { + rDotDashArray[nIns++] = fSingleDashLen; + fFullDotDashLen += fSingleDashLen; + rDotDashArray[nIns++] = fDashDotDistance; + fFullDotDashLen += fDashDotDistance; + } + + return fFullDotDashLen; +} + +// ------------------- +// class XLineDashItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XLineDashItem, NameOrIndex); + +/************************************************************************* +|* +|* XLineDashItem::XLineDashItem(INT32 nIndex, const XDash& rTheDash) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineDashItem::XLineDashItem(INT32 nIndex, const XDash& rTheDash) : + NameOrIndex(XATTR_LINEDASH, nIndex), + aDash(rTheDash) +{ +} + +/************************************************************************* +|* +|* XLineDashItem::XLineDashItem(const String& rName, const XDash& rTheDash) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineDashItem::XLineDashItem(const XubString& rName, const XDash& rTheDash) : + NameOrIndex(XATTR_LINEDASH, rName), + aDash(rTheDash) +{ +} + +/************************************************************************* +|* +|* XLineDashItem::XLineDashItem(const XLineDashItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineDashItem::XLineDashItem(const XLineDashItem& rItem) : + NameOrIndex(rItem), + aDash(rItem.aDash) +{ +} + +/************************************************************************* +|* +|* XLineDashItem::XLineDashItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineDashItem::XLineDashItem(SvStream& rIn) : + NameOrIndex(XATTR_LINEDASH, rIn) +{ + if (!IsIndex()) + { + USHORT nSTemp; + UINT32 nLTemp; + INT32 nITemp; + + rIn >> nITemp; aDash.SetDashStyle((XDashStyle)nITemp); + rIn >> nSTemp; aDash.SetDots(nSTemp); + rIn >> nLTemp; aDash.SetDotLen(nLTemp); + rIn >> nSTemp; aDash.SetDashes(nSTemp); + rIn >> nLTemp; aDash.SetDashLen(nLTemp); + rIn >> nLTemp; aDash.SetDistance(nLTemp); + } +} + +//************************************************************************* + +XLineDashItem::XLineDashItem(SfxItemPool* /*pPool*/, const XDash& rTheDash) +: NameOrIndex( XATTR_LINEDASH, -1 ), + aDash(rTheDash) +{ +} + +//************************************************************************* + +XLineDashItem::XLineDashItem(SfxItemPool* /*pPool*/) +: NameOrIndex(XATTR_LINEDASH, -1 ) +{ +} + +/************************************************************************* +|* +|* XLineDashItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineDashItem(*this); +} + +/************************************************************************* +|* +|* int XLineDashItem::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +int XLineDashItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && + aDash == ((const XLineDashItem&) rItem).aDash ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineDashItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineDashItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineDashItem(rIn); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineDashItem::Store(SvStream& rOut) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SvStream& XLineDashItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if (!IsIndex()) + { + rOut << (INT32) aDash.GetDashStyle(); + rOut << aDash.GetDots(); + rOut << (UINT32) aDash.GetDotLen(); + rOut << aDash.GetDashes(); + rOut << (UINT32) aDash.GetDashLen(); + rOut << (UINT32) aDash.GetDistance(); + } + + return rOut; +} + +/************************************************************************* +|* +|* const XDash& XLineDashItem::GetValue(const XDashTable* pTable) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +const XDash& XLineDashItem::GetDashValue(const XDashTable* pTable) const // GetValue -> GetDashValue +{ + if (!IsIndex()) + return aDash; + else + return pTable->GetDash(GetIndex())->GetDash(); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineDashItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//------------------------------------------------------------------------ + +FASTBOOL XLineDashItem::HasMetrics() const +{ + return TRUE; +} + +//------------------------------------------------------------------------ + +FASTBOOL XLineDashItem::ScaleMetrics(long nMul, long nDiv) +{ + aDash.SetDotLen( ScaleMetricValue( aDash.GetDotLen(), nMul, nDiv ) ); + aDash.SetDashLen( ScaleMetricValue( aDash.GetDashLen(), nMul, nDiv ) ); + aDash.SetDistance( ScaleMetricValue( aDash.GetDistance(), nMul, nDiv ) ); + return TRUE; +} + +sal_Bool XLineDashItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch ( nMemberId ) + { + case 0: + { + uno::Sequence< beans::PropertyValue > aPropSeq( 2 ); + + ::com::sun::star::drawing::LineDash aLineDash; + + const XDash& rXD = GetDashValue(); + aLineDash.Style = (::com::sun::star::drawing::DashStyle)((UINT16)rXD.GetDashStyle()); + aLineDash.Dots = rXD.GetDots(); + aLineDash.DotLen = rXD.GetDotLen(); + aLineDash.Dashes = rXD.GetDashes(); + aLineDash.DashLen = rXD.GetDashLen(); + aLineDash.Distance = rXD.GetDistance(); + + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )); + aPropSeq[0].Value = uno::makeAny( aApiName ); + aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" )); + aPropSeq[1].Value = uno::makeAny( aLineDash ); + rVal = uno::makeAny( aPropSeq ); + break; + } + + case MID_NAME: + { + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + rVal <<= aApiName; + break; + } + + case MID_LINEDASH: + { + const XDash& rXD = GetDashValue(); + + ::com::sun::star::drawing::LineDash aLineDash; + + aLineDash.Style = (::com::sun::star::drawing::DashStyle)((UINT16)rXD.GetDashStyle()); + aLineDash.Dots = rXD.GetDots(); + aLineDash.DotLen = rXD.GetDotLen(); + aLineDash.Dashes = rXD.GetDashes(); + aLineDash.DashLen = rXD.GetDashLen(); + aLineDash.Distance = rXD.GetDistance(); + + rVal <<= aLineDash; + break; + } + + case MID_LINEDASH_STYLE: + { + const XDash& rXD = GetDashValue(); + rVal <<= (::com::sun::star::drawing::DashStyle)((sal_Int16)rXD.GetDashStyle()); + break; + } + + case MID_LINEDASH_DOTS: + { + const XDash& rXD = GetDashValue(); + rVal <<= rXD.GetDots(); + break; + } + + case MID_LINEDASH_DOTLEN: + { + const XDash& rXD = GetDashValue(); + rVal <<= rXD.GetDotLen(); + break; + } + + case MID_LINEDASH_DASHES: + { + const XDash& rXD = GetDashValue(); + rVal <<= rXD.GetDashes(); + break; + } + + case MID_LINEDASH_DASHLEN: + { + const XDash& rXD = GetDashValue(); + rVal <<= rXD.GetDashLen(); + break; + } + + case MID_LINEDASH_DISTANCE: + { + const XDash& rXD = GetDashValue(); + rVal <<= rXD.GetDistance(); + break; + } + + default: DBG_ERROR("Wrong MemberId!"); return sal_False; + } + + return sal_True; +} + +sal_Bool XLineDashItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch ( nMemberId ) + { + case 0: + { + uno::Sequence< beans::PropertyValue > aPropSeq; + ::com::sun::star::drawing::LineDash aLineDash; + rtl::OUString aName; + sal_Bool bLineDash( sal_False ); + + if ( rVal >>= aPropSeq ) + { + for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) + { + if ( aPropSeq[n].Name.equalsAsciiL( "Name", 4 )) + aPropSeq[n].Value >>= aName; + else if ( aPropSeq[n].Name.equalsAsciiL( "LineDash", 8 )) + { + if ( aPropSeq[n].Value >>= aLineDash ) + bLineDash = sal_True; + } + } + + SetName( aName ); + if ( bLineDash ) + { + XDash aXDash; + + aXDash.SetDashStyle((XDashStyle)((UINT16)(aLineDash.Style))); + aXDash.SetDots(aLineDash.Dots); + aXDash.SetDotLen(aLineDash.DotLen); + aXDash.SetDashes(aLineDash.Dashes); + aXDash.SetDashLen(aLineDash.DashLen); + aXDash.SetDistance(aLineDash.Distance); + + if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes())) + aXDash.SetDots(1); + + SetDashValue( aXDash ); + } + + return sal_True; + } + + return sal_False; + } + + case MID_NAME: + { + rtl::OUString aName; + if (!(rVal >>= aName)) + return sal_False; + SetName( aName ); + break; + } + + case MID_LINEDASH: + { + ::com::sun::star::drawing::LineDash aLineDash; + if(!(rVal >>= aLineDash)) + return sal_False; + + XDash aXDash; + + aXDash.SetDashStyle((XDashStyle)((UINT16)(aLineDash.Style))); + aXDash.SetDots(aLineDash.Dots); + aXDash.SetDotLen(aLineDash.DotLen); + aXDash.SetDashes(aLineDash.Dashes); + aXDash.SetDashLen(aLineDash.DashLen); + aXDash.SetDistance(aLineDash.Distance); + + if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes())) + aXDash.SetDots(1); + + SetDashValue( aXDash ); + break; + } + + case MID_LINEDASH_STYLE: + { + sal_Int16 nVal = sal_Int16(); + if(!(rVal >>= nVal)) + return sal_False; + + XDash aXDash = GetDashValue(); + aXDash.SetDashStyle((XDashStyle)((UINT16)(nVal))); + + if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes())) + aXDash.SetDots(1); + + SetDashValue( aXDash ); + + break; + } + + case MID_LINEDASH_DOTS: + case MID_LINEDASH_DASHES: + { + sal_Int16 nVal = sal_Int16(); + if(!(rVal >>= nVal)) + return sal_False; + + XDash aXDash = GetDashValue(); + if ( nMemberId == MID_LINEDASH_DOTS ) + aXDash.SetDots( nVal ); + else + aXDash.SetDashes( nVal ); + + if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes())) + aXDash.SetDots(1); + + SetDashValue( aXDash ); + break; + } + + case MID_LINEDASH_DOTLEN: + case MID_LINEDASH_DASHLEN: + case MID_LINEDASH_DISTANCE: + { + sal_Int32 nVal = 0; + if(!(rVal >>= nVal)) + return sal_False; + + XDash aXDash = GetDashValue(); + if ( nMemberId == MID_LINEDASH_DOTLEN ) + aXDash.SetDotLen( nVal ); + else if ( nMemberId == MID_LINEDASH_DASHLEN ) + aXDash.SetDashLen( nVal ); + else + aXDash.SetDistance( nVal ); + + if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes())) + aXDash.SetDots(1); + + SetDashValue( aXDash ); + break; + } + } + + return sal_True; +} + +BOOL XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) +{ + return ((XLineDashItem*)p1)->GetDashValue() == ((XLineDashItem*)p2)->GetDashValue(); +} + +XLineDashItem* XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const +{ + if( pModel ) + { + const String aUniqueName = NameOrIndex::CheckNamedItem( this, + XATTR_LINEDASH, + &pModel->GetItemPool(), + pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, + XLineDashItem::CompareValueFunc, + RID_SVXSTR_DASH11, + pModel->GetDashList() ); + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() ) + { + return new XLineDashItem( aUniqueName, aDash ); + } + } + + return (XLineDashItem*)this; +} + +// ------------------- +// class XLineWidthItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XLineWidthItem, SfxMetricItem); + +/************************************************************************* +|* +|* XLineWidthItem::XLineWidthItem(long nWidth) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineWidthItem::XLineWidthItem(long nWidth) : + SfxMetricItem(XATTR_LINEWIDTH, nWidth) +{ +} + +/************************************************************************* +|* +|* XLineWidthItem::XLineWidthItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineWidthItem::XLineWidthItem(SvStream& rIn) : + SfxMetricItem(XATTR_LINEWIDTH, rIn) +{ +} + +/************************************************************************* +|* +|* XLineWidthItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineWidthItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineWidthItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineWidthItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineWidthItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineWidthItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineWidthItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const IntlWrapper * pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetMetricText( (long) GetValue(), + eCoreUnit, ePresUnit, pIntl); + rText += SVX_RESSTR( GetMetricId( ePresUnit) ); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + sal_Int32 nValue = GetValue(); + if( 0 != (nMemberId&CONVERT_TWIPS) ) + nValue = TWIP_TO_MM100(nValue); + + rVal <<= nValue; + return sal_True; +} + +sal_Bool XLineWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + if( 0 != (nMemberId&CONVERT_TWIPS) ) + nValue = MM100_TO_TWIP(nValue); + + SetValue( nValue ); + return sal_True; +} + +// ------------------- +// class XLineColorItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XLineColorItem, XColorItem); + +/************************************************************************* +|* +|* XLineColorItem::XLineColorItem(INT32 nIndex, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineColorItem::XLineColorItem(INT32 nIndex, const Color& rTheColor) : + XColorItem(XATTR_LINECOLOR, nIndex, rTheColor) +{ +} + +/************************************************************************* +|* +|* XLineColorItem::XLineColorItem(const XubString& rName, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineColorItem::XLineColorItem(const XubString& rName, const Color& rTheColor) : + XColorItem(XATTR_LINECOLOR, rName, rTheColor) +{ +} + +/************************************************************************* +|* +|* XLineColorItem::XLineColorItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineColorItem::XLineColorItem(SvStream& rIn) : + XColorItem(XATTR_LINECOLOR, rIn) +{ +} + +/************************************************************************* +|* +|* XLineColorItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineColorItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineColorItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineColorItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineColorItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineColorItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetColorValue().GetRGBColor(); + return sal_True; +} + +sal_Bool XLineColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + if(!(rVal >>= nValue)) + return sal_False; + + SetColorValue( nValue ); + return sal_True; +} + +////////////////////////////////////////////////////////////////////////////// +// tooling for simple spooling B2DPolygon to file and back + +namespace +{ + void streamOutB2DPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, SvStream& rOut) + { + const sal_uInt32 nPolygonCount(rPolyPolygon.count()); + rOut << nPolygonCount; + + for(sal_uInt32 a(0L); a < nPolygonCount; a++) + { + const basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(a)); + const sal_uInt32 nPointCount(aCandidate.count()); + const sal_uInt8 bClosed(aCandidate.isClosed() ? 1 : 0); + const sal_uInt8 bControlPoints(aCandidate.areControlPointsUsed() ? 1 : 0); + rOut << nPointCount; + rOut << bClosed; + rOut << bControlPoints; + + for(sal_uInt32 b(0L); b < nPointCount; b++) + { + const basegfx::B2DPoint aPoint(aCandidate.getB2DPoint(b)); + rOut << aPoint.getX(); + rOut << aPoint.getY(); + + if(bControlPoints) + { + const sal_uInt8 bEdgeIsCurve(aCandidate.isPrevControlPointUsed(b) || aCandidate.isNextControlPointUsed(b) ? 1 : 0); + rOut << bEdgeIsCurve; + + if(bEdgeIsCurve) + { + const basegfx::B2DVector aControlVectorA(aCandidate.getPrevControlPoint(b)); + rOut << aControlVectorA.getX(); + rOut << aControlVectorA.getY(); + + const basegfx::B2DVector aControlVectorB(aCandidate.getNextControlPoint(b)); + rOut << aControlVectorB.getX(); + rOut << aControlVectorB.getY(); + } + } + } + } + } + + basegfx::B2DPolyPolygon streamInB2DPolyPolygon(SvStream& rIn) + { + basegfx::B2DPolyPolygon aRetval; + sal_uInt32 nPolygonCount; + rIn >> nPolygonCount; + + for(sal_uInt32 a(0L); a < nPolygonCount; a++) + { + sal_uInt32 nPointCount; + sal_uInt8 bClosed; + sal_uInt8 bControlPoints; + + rIn >> nPointCount; + rIn >> bClosed; + rIn >> bControlPoints; + + basegfx::B2DPolygon aCandidate; + aCandidate.setClosed(0 != bClosed); + + for(sal_uInt32 b(0L); b < nPointCount; b++) + { + double fX, fY; + rIn >> fX; + rIn >> fY; + aCandidate.append(basegfx::B2DPoint(fX, fY)); + + if(0 != bControlPoints) + { + sal_uInt8 bEdgeIsCurve; + rIn >> bEdgeIsCurve; + + if(0 != bEdgeIsCurve) + { + rIn >> fX; + rIn >> fY; + aCandidate.setPrevControlPoint(b, basegfx::B2DVector(fX, fY)); + + rIn >> fX; + rIn >> fY; + aCandidate.setNextControlPoint(b, basegfx::B2DVector(fX, fY)); + } + } + } + + aRetval.append(aCandidate); + } + + return aRetval; + } +} + +////////////////////////////////////////////////////////////////////////////// + +// ----------------------- +// class XLineStartItem +// ----------------------- +TYPEINIT1_AUTOFACTORY(XLineStartItem, NameOrIndex); + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(INT32 nIndex) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(INT32 nIndex) +: NameOrIndex(XATTR_LINESTART, nIndex) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(const XubString& rName, +|* const basegfx::B2DPolyPolygon& rXPolygon) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(const XubString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon) +: NameOrIndex(XATTR_LINESTART, rName), + maPolyPolygon(rPolyPolygon) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(const XLineStartItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(const XLineStartItem& rItem) +: NameOrIndex(rItem), + maPolyPolygon(rItem.maPolyPolygon) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(SvStream& rIn) : + NameOrIndex(XATTR_LINESTART, rIn) +{ + if (!IsIndex()) + { + maPolyPolygon = streamInB2DPolyPolygon(rIn); + } +} + +//************************************************************************* + +XLineStartItem::XLineStartItem(SfxItemPool* /*pPool*/, const basegfx::B2DPolyPolygon& rPolyPolygon) +: NameOrIndex( XATTR_LINESTART, -1 ), + maPolyPolygon(rPolyPolygon) +{ +} + +//************************************************************************* + +XLineStartItem::XLineStartItem(SfxItemPool* /*pPool*/) +: NameOrIndex(XATTR_LINESTART, -1 ) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStartItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineStartItem(*this); +} + +/************************************************************************* +|* +|* int XLineStartItem::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +int XLineStartItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && ((const XLineStartItem&) rItem).maPolyPolygon == maPolyPolygon ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineStartItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStartItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineStartItem(rIn); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineStartItem::Store(SvStream& rOut) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +SvStream& XLineStartItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if (!IsIndex()) + { + streamOutB2DPolyPolygon(maPolyPolygon, rOut); + } + + return rOut; +} + +/************************************************************************* +|* +|* const basegfx::B2DPolyPolygon& XLineStartItem::GetValue(const XLineEndTable* pTable) +|* const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +basegfx::B2DPolyPolygon XLineStartItem::GetLineStartValue(const XLineEndTable* pTable) const +{ + if (!IsIndex()) + { + return maPolyPolygon; + } + else + { + return pTable->GetLineEnd(GetIndex())->GetLineEnd(); + } +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineStartItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineStartItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + if( nMemberId == MID_NAME ) + { + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + rVal <<= aApiName; + } + else + { + com::sun::star::drawing::PolyPolygonBezierCoords aBezier; + SvxConvertB2DPolyPolygonToPolyPolygonBezier( maPolyPolygon, aBezier ); + rVal <<= aBezier; + } + + return sal_True; +} + +sal_Bool XLineStartItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + if( nMemberId == MID_NAME ) + { + return sal_False; + } + else + { + maPolyPolygon.clear(); + + if( rVal.hasValue() && rVal.getValue() ) + { + if( rVal.getValueType() != ::getCppuType((const com::sun::star::drawing::PolyPolygonBezierCoords*)0) ) + return sal_False; + + com::sun::star::drawing::PolyPolygonBezierCoords* pCoords = (com::sun::star::drawing::PolyPolygonBezierCoords*)rVal.getValue(); + if( pCoords->Coordinates.getLength() > 0 ) + { + maPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords ); + // #i72807# close line start/end polygons hard + // maPolyPolygon.setClosed(true); + } + } + } + + return sal_True; +} + +/** this function searches in both the models pool and the styles pool for XLineStartItem + and XLineEndItem with the same value or name and returns an item with the value of + this item and a unique name for an item with this value. */ +XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const +{ + if( pModel ) + { + XLineStartItem* pTempItem = NULL; + const XLineStartItem* pLineStartItem = this; + + String aUniqueName( GetName() ); + + if( !maPolyPolygon.count() ) + { + // if the polygon is empty, check if the name is empty + if( aUniqueName.Len() == 0 ) + return (XLineStartItem*)this; + + // force empty name for empty polygons + return new XLineStartItem( String(), maPolyPolygon ); + } + + if( maPolyPolygon.count() > 1L ) + { + // check if the polygon is closed + if(!maPolyPolygon.isClosed()) + { + // force a closed polygon + basegfx::B2DPolyPolygon aNew(maPolyPolygon); + aNew.setClosed(true); + pTempItem = new XLineStartItem( aUniqueName, aNew ); + pLineStartItem = pTempItem; + } + } + + sal_Bool bForceNew = sal_False; + + // 2. if we have a name check if there is already an item with the + // same name in the documents pool with a different line end or start + + sal_uInt16 nCount, nSurrogate; + + const SfxItemPool* pPool1 = &pModel->GetItemPool(); + if( aUniqueName.Len() && pPool1 ) + { + nCount = pPool1->GetItemCount( XATTR_LINESTART ); + + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + + if( !bForceNew ) + { + nCount = pPool1->GetItemCount( XATTR_LINEEND ); + + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + } + } + + const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL; + if( aUniqueName.Len() && pPool2) + { + nCount = pPool2->GetItemCount( XATTR_LINESTART ); + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineStartItem* pItem = (const XLineStartItem*)pPool2->GetItem( XATTR_LINESTART, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + + if( !bForceNew ) + { + nCount = pPool2->GetItemCount( XATTR_LINEEND ); + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineEndItem* pItem = (const XLineEndItem*)pPool2->GetItem( XATTR_LINEEND, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + } + } + + // if we have no name yet, find existing item with same conent or + // create a unique name + if( aUniqueName.Len() == 0 ) + { + sal_Bool bFoundExisting = sal_False; + + sal_Int32 nUserIndex = 1; + const ResId aRes(SVX_RES(RID_SVXSTR_LINEEND)); + const String aUser( aRes ); + + if( pPool1 ) + { + nCount = pPool1->GetItemCount( XATTR_LINESTART ); + sal_uInt16 nSurrogate2; + + for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + { + const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate2 ); + + if( pItem && pItem->GetName().Len() ) + { + if( !bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue() ) + { + aUniqueName = pItem->GetName(); + bFoundExisting = sal_True; + break; + } + + if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 ) + { + sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32(); + if( nThisIndex >= nUserIndex ) + nUserIndex = nThisIndex + 1; + } + } + } + + nCount = pPool1->GetItemCount( XATTR_LINEEND ); + for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + { + const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate2 ); + + if( pItem && pItem->GetName().Len() ) + { + if( !bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue() ) + { + aUniqueName = pItem->GetName(); + bFoundExisting = sal_True; + break; + } + + if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 ) + { + sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32(); + if( nThisIndex >= nUserIndex ) + nUserIndex = nThisIndex + 1; + } + } + } + } + + if( !bFoundExisting ) + { + aUniqueName = aUser; + aUniqueName += sal_Unicode(' '); + aUniqueName += String::CreateFromInt32( nUserIndex ); + } + } + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() || pTempItem ) + { + if( pTempItem ) + { + pTempItem->SetName( aUniqueName ); + return pTempItem; + } + else + { + return new XLineStartItem( aUniqueName, maPolyPolygon ); + } + } + } + + return (XLineStartItem*)this; +} + +// --------------------- +// class XLineEndItem +// --------------------- +TYPEINIT1_AUTOFACTORY(XLineEndItem, NameOrIndex); + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(INT32 nIndex) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(INT32 nIndex) +: NameOrIndex(XATTR_LINEEND, nIndex) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(const XubString& rName, +|* const basegfx::B2DPolyPolygon& rXPolygon) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(const XubString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon) +: NameOrIndex(XATTR_LINEEND, rName), + maPolyPolygon(rPolyPolygon) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(const XLineEndItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(const XLineEndItem& rItem) +: NameOrIndex(rItem), + maPolyPolygon(rItem.maPolyPolygon) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(SvStream& rIn) : + NameOrIndex(XATTR_LINEEND, rIn) +{ + if (!IsIndex()) + { + maPolyPolygon = streamInB2DPolyPolygon(rIn); + } +} + +//************************************************************************* + +XLineEndItem::XLineEndItem(SfxItemPool* /*pPool*/, const basegfx::B2DPolyPolygon& rPolyPolygon) +: NameOrIndex( XATTR_LINEEND, -1 ), + maPolyPolygon(rPolyPolygon) +{ +} + +//************************************************************************* + +XLineEndItem::XLineEndItem(SfxItemPool* /*pPool*/) +: NameOrIndex(XATTR_LINEEND, -1 ) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineEndItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineEndItem(*this); +} + +/************************************************************************* +|* +|* int XLineEndItem::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +int XLineEndItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && ((const XLineEndItem&) rItem).maPolyPolygon == maPolyPolygon ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineEndItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineEndItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineEndItem(rIn); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineEndItem::Store(SvStream& rOut) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +SvStream& XLineEndItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if (!IsIndex()) + { + streamOutB2DPolyPolygon(maPolyPolygon, rOut); + } + + return rOut; +} + +/************************************************************************* +|* +|* const basegfx::B2DPolyPolygon& XLineEndItem::GetValue(const XLineEndTable* pTable) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +basegfx::B2DPolyPolygon XLineEndItem::GetLineEndValue(const XLineEndTable* pTable) const +{ + if (!IsIndex()) + { + return maPolyPolygon; + } + else + { + return pTable->GetLineEnd(GetIndex())->GetLineEnd(); + } +} + + +/** this function searches in both the models pool and the styles pool for XLineStartItem + and XLineEndItem with the same value or name and returns an item with the value of + this item and a unique name for an item with this value. */ +XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const +{ + if( pModel ) + { + XLineEndItem* pTempItem = NULL; + const XLineEndItem* pLineEndItem = this; + + String aUniqueName( GetName() ); + + if( !maPolyPolygon.count() ) + { + // if the polygon is empty, check if the name is empty + if( aUniqueName.Len() == 0 ) + return (XLineEndItem*)this; + + // force empty name for empty polygons + return new XLineEndItem( String(), maPolyPolygon ); + } + + if( maPolyPolygon.count() > 1L ) + { + // check if the polygon is closed + if(!maPolyPolygon.isClosed()) + { + // force a closed polygon + basegfx::B2DPolyPolygon aNew(maPolyPolygon); + aNew.setClosed(true); + pTempItem = new XLineEndItem( aUniqueName, aNew ); + pLineEndItem = pTempItem; + } + } + + sal_Bool bForceNew = sal_False; + + // 2. if we have a name check if there is already an item with the + // same name in the documents pool with a different line end or start + + sal_uInt16 nCount, nSurrogate; + + const SfxItemPool* pPool1 = &pModel->GetItemPool(); + if( aUniqueName.Len() && pPool1 ) + { + nCount = pPool1->GetItemCount( XATTR_LINESTART ); + + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + + if( !bForceNew ) + { + nCount = pPool1->GetItemCount( XATTR_LINEEND ); + + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + } + } + + const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL; + if( aUniqueName.Len() && pPool2) + { + nCount = pPool2->GetItemCount( XATTR_LINESTART ); + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineStartItem* pItem = (const XLineStartItem*)pPool2->GetItem( XATTR_LINESTART, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + + if( !bForceNew ) + { + nCount = pPool2->GetItemCount( XATTR_LINEEND ); + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + const XLineEndItem* pItem = (const XLineEndItem*)pPool2->GetItem( XATTR_LINEEND, nSurrogate ); + + if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) + { + // if there is already an item with the same name and the same + // value its ok to set it + if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() ) + { + // same name but different value, we need a new name for this item + aUniqueName = String(); + bForceNew = sal_True; + } + break; + } + } + } + } + + // if we have no name yet, find existing item with same conent or + // create a unique name + if( aUniqueName.Len() == 0 ) + { + sal_Bool bFoundExisting = sal_False; + + sal_Int32 nUserIndex = 1; + const ResId aRes(SVX_RES(RID_SVXSTR_LINEEND)); + const String aUser( aRes ); + + if( pPool1 ) + { + nCount = pPool1->GetItemCount( XATTR_LINESTART ); + sal_uInt16 nSurrogate2; + + for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + { + const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate2 ); + + if( pItem && pItem->GetName().Len() ) + { + if( !bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue() ) + { + aUniqueName = pItem->GetName(); + bFoundExisting = sal_True; + break; + } + + if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 ) + { + sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32(); + if( nThisIndex >= nUserIndex ) + nUserIndex = nThisIndex + 1; + } + } + } + + nCount = pPool1->GetItemCount( XATTR_LINEEND ); + for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + { + const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate2 ); + + if( pItem && pItem->GetName().Len() ) + { + if( !bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue() ) + { + aUniqueName = pItem->GetName(); + bFoundExisting = sal_True; + break; + } + + if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 ) + { + sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32(); + if( nThisIndex >= nUserIndex ) + nUserIndex = nThisIndex + 1; + } + } + } + } + + if( !bFoundExisting ) + { + aUniqueName = aUser; + aUniqueName += sal_Unicode(' '); + aUniqueName += String::CreateFromInt32( nUserIndex ); + } + } + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() || pTempItem ) + { + if( pTempItem ) + { + pTempItem->SetName( aUniqueName ); + return pTempItem; + } + else + { + return new XLineEndItem( aUniqueName, maPolyPolygon ); + } + } + } + + return (XLineEndItem*)this; +} + + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineEndItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineEndItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + if( nMemberId == MID_NAME ) + { + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + rVal <<= aApiName; + } + else + { + com::sun::star::drawing::PolyPolygonBezierCoords aBezier; + SvxConvertB2DPolyPolygonToPolyPolygonBezier( maPolyPolygon, aBezier ); + rVal <<= aBezier; + } + return sal_True; +} + +sal_Bool XLineEndItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + if( nMemberId == MID_NAME ) + { + return sal_False; + } + else + { + maPolyPolygon.clear(); + + if( rVal.hasValue() && rVal.getValue() ) + { + if( rVal.getValueType() != ::getCppuType((const com::sun::star::drawing::PolyPolygonBezierCoords*)0) ) + return sal_False; + + com::sun::star::drawing::PolyPolygonBezierCoords* pCoords = (com::sun::star::drawing::PolyPolygonBezierCoords*)rVal.getValue(); + if( pCoords->Coordinates.getLength() > 0 ) + { + maPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords ); + // #i72807# close line start/end polygons hard + // maPolyPolygon.setClosed(true); + } + } + } + + return sal_True; +} + +// ---------------------------- +// class XLineStartWidthItem +// ---------------------------- +TYPEINIT1_AUTOFACTORY(XLineStartWidthItem, SfxMetricItem); + +/************************************************************************* +|* +|* XLineStartWidthItem::XLineStartWidthItem(INT32 nWidth) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineStartWidthItem::XLineStartWidthItem(long nWidth) : + SfxMetricItem(XATTR_LINESTARTWIDTH, nWidth) +{ +} + +/************************************************************************* +|* +|* XLineStartWidthItem::XLineStartWidthItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineStartWidthItem::XLineStartWidthItem(SvStream& rIn) : + SfxMetricItem(XATTR_LINESTARTWIDTH, rIn) +{ +} + +/************************************************************************* +|* +|* XLineStartWidthItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStartWidthItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineStartWidthItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineStartWidthItem::Create(SvStream& rIn, USHORT nVer) +|* const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStartWidthItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineStartWidthItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineStartWidthItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const IntlWrapper * pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetMetricText( (long) GetValue(), + eCoreUnit, ePresUnit, pIntl); + rText += SVX_RESSTR( GetMetricId( ePresUnit) ); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineStartWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +sal_Bool XLineStartWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetValue( nValue ); + return sal_True; +} + + + +// -------------------------- +// class XLineEndWidthItem +// -------------------------- +TYPEINIT1_AUTOFACTORY(XLineEndWidthItem, SfxMetricItem); + +/************************************************************************* +|* +|* XLineEndWidthItem::XLineEndWidthItem(long nWidth) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineEndWidthItem::XLineEndWidthItem(long nWidth) : + SfxMetricItem(XATTR_LINEENDWIDTH, nWidth) +{ +} + +/************************************************************************* +|* +|* XLineEndWidthItem::XLineEndWidthItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineEndWidthItem::XLineEndWidthItem(SvStream& rIn) : + SfxMetricItem(XATTR_LINEENDWIDTH, rIn) +{ +} + +/************************************************************************* +|* +|* XLineEndWidthItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineEndWidthItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineEndWidthItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineEndWidthItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineEndWidthItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineEndWidthItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineEndWidthItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const IntlWrapper *pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetMetricText( (long) GetValue(), + eCoreUnit, ePresUnit, pIntl); + rText += SVX_RESSTR( GetMetricId( ePresUnit) ); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineEndWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +sal_Bool XLineEndWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetValue( nValue ); + return sal_True; +} + + +// ----------------------------- +// class XLineStartCenterItem +// ----------------------------- +TYPEINIT1_AUTOFACTORY(XLineStartCenterItem, SfxBoolItem); + +/************************************************************************* +|* +|* XLineStartCenterItem::XLineStartCenterItem(BOOL bStartCenter) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineStartCenterItem::XLineStartCenterItem(BOOL bStartCenter) : + SfxBoolItem(XATTR_LINESTARTCENTER, bStartCenter) +{ +} + +/************************************************************************* +|* +|* XLineStartCenterItem::XLineStartCenterItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineStartCenterItem::XLineStartCenterItem(SvStream& rIn) : + SfxBoolItem(XATTR_LINESTARTCENTER, rIn) +{ +} + +/************************************************************************* +|* +|* XLineStartCenterItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStartCenterItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineStartCenterItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineStartCenterItem::Create(SvStream& rIn, USHORT nVer) +|* const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineStartCenterItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineStartCenterItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineStartCenterItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = XubString( ResId( GetValue() ? RID_SVXSTR_CENTERED : + RID_SVXSTR_NOTCENTERED, DIALOG_MGR() ) ); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineStartCenterItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + sal_Bool bValue = GetValue(); + rVal.setValue( &bValue, ::getCppuBooleanType() ); + return sal_True; +} + +sal_Bool XLineStartCenterItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + if( !rVal.hasValue() || rVal.getValueType() != ::getCppuBooleanType() ) + return sal_False; + + SetValue( *(sal_Bool*)rVal.getValue() ); + return sal_True; +} + + +// --------------------------- +// class XLineEndCenterItem +// --------------------------- +TYPEINIT1_AUTOFACTORY(XLineEndCenterItem, SfxBoolItem); + +/************************************************************************* +|* +|* XLineEndCenterItem::XLineEndCenterItem(BOOL bEndCenter) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineEndCenterItem::XLineEndCenterItem(BOOL bEndCenter) : + SfxBoolItem(XATTR_LINEENDCENTER, bEndCenter) +{ +} + +/************************************************************************* +|* +|* XLineEndCenterItem::XLineEndCenterItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineEndCenterItem::XLineEndCenterItem(SvStream& rIn) : + SfxBoolItem(XATTR_LINEENDCENTER, rIn) +{ +} + +/************************************************************************* +|* +|* XLineEndCenterItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineEndCenterItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineEndCenterItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineEndCenterItem::Create(SvStream& rIn, USHORT nVer) +|* const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XLineEndCenterItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineEndCenterItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineEndCenterItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = XubString( ResId( GetValue() ? RID_SVXSTR_CENTERED : + RID_SVXSTR_NOTCENTERED, DIALOG_MGR() ) ); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +sal_Bool XLineEndCenterItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + sal_Bool bValue = GetValue(); + rVal.setValue( &bValue, ::getCppuBooleanType() ); + return sal_True; +} + +BOOL XLineEndCenterItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + if( !rVal.hasValue() || rVal.getValueType() != ::getCppuBooleanType() ) + return sal_False; + + SetValue( *(sal_Bool*)rVal.getValue() ); + return sal_True; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Fuellattribute +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +// -------------------- +// class XFillStyleItem +// -------------------- +TYPEINIT1_AUTOFACTORY(XFillStyleItem, SfxEnumItem); + +/************************************************************************* +|* +|* XFillStyleItem::XFillStyleItem(XFillStyle eFillStyle) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillStyleItem::XFillStyleItem(XFillStyle eFillStyle) : + SfxEnumItem(XATTR_FILLSTYLE, sal::static_int_cast< USHORT >(eFillStyle)) +{ +} + +/************************************************************************* +|* +|* XFillStyleItem::XFillStyleItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillStyleItem::XFillStyleItem(SvStream& rIn) : + SfxEnumItem(XATTR_FILLSTYLE, rIn) +{ +} + +/************************************************************************* +|* +|* XFillStyleItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 09.11.94 +|* Letzte Aenderung 09.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillStyleItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFillStyleItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillStyleItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillStyleItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillStyleItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + USHORT nId = 0; + + switch( (USHORT)GetValue() ) + { + case XFILL_NONE: + nId = RID_SVXSTR_INVISIBLE; + break; + case XFILL_SOLID: + nId = RID_SVXSTR_SOLID; + break; + case XFILL_GRADIENT: + nId = RID_SVXSTR_GRADIENT; + break; + case XFILL_HATCH: + nId = RID_SVXSTR_HATCH; + break; + case XFILL_BITMAP: + nId = RID_SVXSTR_BITMAP; + break; + } + + if ( nId ) + rText = SVX_RESSTR( nId ); + return ePres; + } + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//------------------------------------------------------------------------ + +USHORT XFillStyleItem::GetValueCount() const +{ + return 5; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillStyleItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + ::com::sun::star::drawing::FillStyle eFS = (::com::sun::star::drawing::FillStyle)GetValue(); + + rVal <<= eFS; + + return sal_True; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillStyleItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + ::com::sun::star::drawing::FillStyle eFS; + if(!(rVal >>= eFS)) + { + // also try an int (for Basic) + sal_Int32 nFS = 0; + if(!(rVal >>= nFS)) + return sal_False; + eFS = (::com::sun::star::drawing::FillStyle)nFS; + } + + SetValue( sal::static_int_cast< USHORT >( eFS ) ); + + return sal_True; +} + + +// ------------------- +// class XFillColorItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XFillColorItem, XColorItem); + +/************************************************************************* +|* +|* XFillColorItem::XFillColorItem(INT32 nIndex, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillColorItem::XFillColorItem(INT32 nIndex, const Color& rTheColor) : + XColorItem(XATTR_FILLCOLOR, nIndex, rTheColor) +{ +} + +/************************************************************************* +|* +|* XFillColorItem::XFillColorItem(const XubString& rName, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillColorItem::XFillColorItem(const XubString& rName, const Color& rTheColor) : + XColorItem(XATTR_FILLCOLOR, rName, rTheColor) +{ +} + +/************************************************************************* +|* +|* XFillColorItem::XFillColorItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillColorItem::XFillColorItem(SvStream& rIn) : + XColorItem(XATTR_FILLCOLOR, rIn) +{ +} + +/************************************************************************* +|* +|* XFillColorItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillColorItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFillColorItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillColorItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillColorItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillColorItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +// ----------------------------------------------------------------------- + +sal_Bool XFillColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetColorValue().GetRGBColor(); + + return sal_True; +} + +// ----------------------------------------------------------------------- + +sal_Bool XFillColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + if(!(rVal >>= nValue )) + return sal_False; + + SetColorValue( nValue ); + return sal_True; +} + +// ----------------------------- +// class XSecondaryFillColorItem +// ----------------------------- +TYPEINIT1_AUTOFACTORY(XSecondaryFillColorItem, XColorItem); + +XSecondaryFillColorItem::XSecondaryFillColorItem(INT32 nIndex, const Color& rTheColor) : + XColorItem(XATTR_SECONDARYFILLCOLOR, nIndex, rTheColor) +{ +} + +XSecondaryFillColorItem::XSecondaryFillColorItem(const XubString& rName, const Color& rTheColor) : + XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor) +{ +} + +XSecondaryFillColorItem::XSecondaryFillColorItem( SvStream& rIn ) : + XColorItem(XATTR_SECONDARYFILLCOLOR, rIn) +{ +} + +SfxPoolItem* XSecondaryFillColorItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XSecondaryFillColorItem(*this); +} + +SfxPoolItem* XSecondaryFillColorItem::Create( SvStream& rIn, USHORT nVer ) const +{ + if ( nVer >= 2 ) + return new XSecondaryFillColorItem( rIn ); + else + return new XSecondaryFillColorItem( String(), Color(0,184,255) ); +} +USHORT XSecondaryFillColorItem::GetVersion( USHORT /*nFileFormatVersion*/ ) const +{ + return 2; +} +SfxItemPresentation XSecondaryFillColorItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +// ---------------- +// class XGradient +// ---------------- + +/************************************************************************* +|* +|* XGradient::XGradient() +|* +*************************************************************************/ + +XGradient::XGradient() : + eStyle( XGRAD_LINEAR ), + aStartColor( Color( COL_BLACK ) ), + aEndColor( Color( COL_WHITE ) ), + nAngle( 0 ), + nBorder( 0 ), + nOfsX( 50 ), + nOfsY( 50 ), + nIntensStart( 100 ), + nIntensEnd( 100 ), + nStepCount( 0 ) +{ +} + +/************************************************************************* +|* +|* XGradient::XGradient(XGradientStyle, const Color&, const Color&, +|* long, USHORT, USHORT, USHORT) +|* +|* Beschreibung +|* Ersterstellung 21.11.94 +|* Letzte Aenderung 21.11.94 +|* +*************************************************************************/ + +XGradient::XGradient(const Color& rStart, const Color& rEnd, + XGradientStyle eTheStyle, long nTheAngle, USHORT nXOfs, + USHORT nYOfs, USHORT nTheBorder, + USHORT nStartIntens, USHORT nEndIntens, + USHORT nSteps) : + eStyle(eTheStyle), + aStartColor(rStart), + aEndColor(rEnd), + nAngle(nTheAngle), + nBorder(nTheBorder), + nOfsX(nXOfs), + nOfsY(nYOfs), + nIntensStart(nStartIntens), + nIntensEnd(nEndIntens), + nStepCount(nSteps) +{ +} + +/************************************************************************* +|* +|* int XGradient::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 29.11.94 +|* Letzte Aenderung 29.11.94 +|* +*************************************************************************/ + +bool XGradient::operator==(const XGradient& rGradient) const +{ + return ( eStyle == rGradient.eStyle && + aStartColor == rGradient.aStartColor && + aEndColor == rGradient.aEndColor && + nAngle == rGradient.nAngle && + nBorder == rGradient.nBorder && + nOfsX == rGradient.nOfsX && + nOfsY == rGradient.nOfsY && + nIntensStart == rGradient.nIntensStart && + nIntensEnd == rGradient.nIntensEnd && + nStepCount == rGradient.nStepCount ); +} + + +// ----------------------- +// class XFillGradientItem +// ----------------------- +TYPEINIT1_AUTOFACTORY(XFillGradientItem, NameOrIndex); + +/************************************************************************* +|* +|* XFillGradientItem::XFillGradientItem(INT32 nIndex, +|* const XGradient& rTheGradient) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillGradientItem::XFillGradientItem(INT32 nIndex, + const XGradient& rTheGradient) : + NameOrIndex(XATTR_FILLGRADIENT, nIndex), + aGradient(rTheGradient) +{ +} + +/************************************************************************* +|* +|* XFillGradientItem::XFillGradientItem(const XubString& rName, +|* const XGradient& rTheGradient) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillGradientItem::XFillGradientItem(const XubString& rName, + const XGradient& rTheGradient) : + NameOrIndex(XATTR_FILLGRADIENT, rName), + aGradient(rTheGradient) +{ +} + +/************************************************************************* +|* +|* XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) : + NameOrIndex(rItem), + aGradient(rItem.aGradient) +{ +} + +/************************************************************************* +|* +|* XFillGradientItem::XFillGradientItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillGradientItem::XFillGradientItem(SvStream& rIn, USHORT nVer) : + NameOrIndex(XATTR_FILLGRADIENT, rIn), + aGradient(COL_BLACK, COL_WHITE) +{ + if (!IsIndex()) + { + USHORT nUSTemp; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + INT16 nITemp; + INT32 nLTemp; + + rIn >> nITemp; aGradient.SetGradientStyle((XGradientStyle)nITemp); + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + Color aCol; + aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) ); + aGradient.SetStartColor( aCol ); + + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) ); + aGradient.SetEndColor(aCol); + rIn >> nLTemp; aGradient.SetAngle(nLTemp); + rIn >> nUSTemp; aGradient.SetBorder(nUSTemp); + rIn >> nUSTemp; aGradient.SetXOffset(nUSTemp); + rIn >> nUSTemp; aGradient.SetYOffset(nUSTemp); + rIn >> nUSTemp; aGradient.SetStartIntens(nUSTemp); + rIn >> nUSTemp; aGradient.SetEndIntens(nUSTemp); + + // bei neueren Versionen wird zusaetzlich + // die Schrittweite mit eingelesen + if (nVer >= 1) + { + rIn >> nUSTemp; aGradient.SetSteps(nUSTemp); + } + } +} + +//************************************************************************* + +XFillGradientItem::XFillGradientItem(SfxItemPool* /*pPool*/, const XGradient& rTheGradient) +: NameOrIndex( XATTR_FILLGRADIENT, -1 ), + aGradient(rTheGradient) +{ +} + +//************************************************************************* + +XFillGradientItem::XFillGradientItem(SfxItemPool* /*pPool*/) +: NameOrIndex(XATTR_FILLGRADIENT, -1 ) +{ +} + +/************************************************************************* +|* +|* XFillGradientItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillGradientItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFillGradientItem(*this); +} + +/************************************************************************* +|* +|* int XFillGradientItem::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +int XFillGradientItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && + aGradient == ((const XFillGradientItem&) rItem).aGradient ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillGradientItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillGradientItem::Create(SvStream& rIn, USHORT nVer) const +{ + return new XFillGradientItem(rIn, nVer); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillGradientItem::Store(SvStream& rOut) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SvStream& XFillGradientItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if (!IsIndex()) + { + rOut << (INT16)aGradient.GetGradientStyle(); + + USHORT nTmp; + + nTmp = VCLTOSVCOL( aGradient.GetStartColor().GetRed() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aGradient.GetStartColor().GetGreen() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aGradient.GetStartColor().GetBlue() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aGradient.GetEndColor().GetRed() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aGradient.GetEndColor().GetGreen() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aGradient.GetEndColor().GetBlue() ); rOut << nTmp; + + rOut << (INT32) aGradient.GetAngle(); + rOut << aGradient.GetBorder(); + rOut << aGradient.GetXOffset(); + rOut << aGradient.GetYOffset(); + rOut << aGradient.GetStartIntens(); + rOut << aGradient.GetEndIntens(); + rOut << aGradient.GetSteps(); + } + + return rOut; +} + +/************************************************************************* +|* +|* const XGradient& XFillGradientItem::GetValue(const XGradientTable* pTable) +|* const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +const XGradient& XFillGradientItem::GetGradientValue(const XGradientTable* pTable) const // GetValue -> GetGradientValue +{ + if (!IsIndex()) + return aGradient; + else + return pTable->GetGradient(GetIndex())->GetGradient(); +} + + +/************************************************************************* +|* +|* USHORT XFillGradientItem::GetVersion() const +|* +|* Beschreibung +|* Ersterstellung 01.11.95 +|* Letzte Aenderung 01.11.95 +|* +*************************************************************************/ + +USHORT XFillGradientItem::GetVersion( USHORT /*nFileFormatVersion*/) const +{ + // !!! this version number also represents the version number of superclasses + // !!! (e.g. XFillFloatTransparenceItem); if you make any changes here, + // !!! the superclass is also affected + return 1; +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillGradientItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +// ----------------------------------------------------------------------- +sal_Bool XFillGradientItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + //sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + switch ( nMemberId ) + { + case 0: + { + uno::Sequence< beans::PropertyValue > aPropSeq( 2 ); + + ::com::sun::star::awt::Gradient aGradient2; + + const XGradient& aXGradient = GetGradientValue(); + aGradient2.Style = (::com::sun::star::awt::GradientStyle) aXGradient.GetGradientStyle(); + aGradient2.StartColor = (INT32)aXGradient.GetStartColor().GetColor(); + aGradient2.EndColor = (INT32)aXGradient.GetEndColor().GetColor(); + aGradient2.Angle = (short)aXGradient.GetAngle(); + aGradient2.Border = aXGradient.GetBorder(); + aGradient2.XOffset = aXGradient.GetXOffset(); + aGradient2.YOffset = aXGradient.GetYOffset(); + aGradient2.StartIntensity = aXGradient.GetStartIntens(); + aGradient2.EndIntensity = aXGradient.GetEndIntens(); + aGradient2.StepCount = aXGradient.GetSteps(); + + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )); + aPropSeq[0].Value = uno::makeAny( aApiName ); + aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" )); + aPropSeq[1].Value = uno::makeAny( aGradient2 ); + rVal = uno::makeAny( aPropSeq ); + break; + } + + case MID_FILLGRADIENT: + { + const XGradient& aXGradient = GetGradientValue(); + ::com::sun::star::awt::Gradient aGradient2; + + aGradient2.Style = (::com::sun::star::awt::GradientStyle) aXGradient.GetGradientStyle(); + aGradient2.StartColor = (INT32)aXGradient.GetStartColor().GetColor(); + aGradient2.EndColor = (INT32)aXGradient.GetEndColor().GetColor(); + aGradient2.Angle = (short)aXGradient.GetAngle(); + aGradient2.Border = aXGradient.GetBorder(); + aGradient2.XOffset = aXGradient.GetXOffset(); + aGradient2.YOffset = aXGradient.GetYOffset(); + aGradient2.StartIntensity = aXGradient.GetStartIntens(); + aGradient2.EndIntensity = aXGradient.GetEndIntens(); + aGradient2.StepCount = aXGradient.GetSteps(); + + rVal <<= aGradient2; + break; + } + + case MID_NAME: + { + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + rVal <<= aApiName; + break; + } + + case MID_GRADIENT_STYLE: rVal <<= (sal_Int16)GetGradientValue().GetGradientStyle(); break; + case MID_GRADIENT_STARTCOLOR: rVal <<= (sal_Int32)GetGradientValue().GetStartColor().GetColor(); break; + case MID_GRADIENT_ENDCOLOR: rVal <<= (sal_Int32)GetGradientValue().GetEndColor().GetColor(); break; + case MID_GRADIENT_ANGLE: rVal <<= (sal_Int16)GetGradientValue().GetAngle(); break; + case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break; + case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break; + case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break; + case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break; + case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break; + case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break; + + default: DBG_ERROR("Wrong MemberId!"); return sal_False; + } + + return sal_True; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillGradientItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch ( nMemberId ) + { + case 0: + { + uno::Sequence< beans::PropertyValue > aPropSeq; + ::com::sun::star::awt::Gradient aGradient2; + rtl::OUString aName; + bool bGradient( false ); + + if ( rVal >>= aPropSeq ) + { + for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) + { + if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ))) + aPropSeq[n].Value >>= aName; + else if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillGradient" ))) + { + if ( aPropSeq[n].Value >>= aGradient2 ) + bGradient = true; + } + } + + SetName( aName ); + if ( bGradient ) + { + XGradient aXGradient; + + aXGradient.SetGradientStyle( (XGradientStyle) aGradient2.Style ); + aXGradient.SetStartColor( aGradient2.StartColor ); + aXGradient.SetEndColor( aGradient2.EndColor ); + aXGradient.SetAngle( aGradient2.Angle ); + aXGradient.SetBorder( aGradient2.Border ); + aXGradient.SetXOffset( aGradient2.XOffset ); + aXGradient.SetYOffset( aGradient2.YOffset ); + aXGradient.SetStartIntens( aGradient2.StartIntensity ); + aXGradient.SetEndIntens( aGradient2.EndIntensity ); + aXGradient.SetSteps( aGradient2.StepCount ); + + SetGradientValue( aXGradient ); + } + + return sal_True; + } + + return sal_False; + } + + case MID_NAME: + { + rtl::OUString aName; + if (!(rVal >>= aName )) + return sal_False; + SetName( aName ); + break; + } + + case MID_FILLGRADIENT: + { + ::com::sun::star::awt::Gradient aGradient2; + if(!(rVal >>= aGradient2)) + return sal_False; + + XGradient aXGradient; + + aXGradient.SetGradientStyle( (XGradientStyle) aGradient2.Style ); + aXGradient.SetStartColor( aGradient2.StartColor ); + aXGradient.SetEndColor( aGradient2.EndColor ); + aXGradient.SetAngle( aGradient2.Angle ); + aXGradient.SetBorder( aGradient2.Border ); + aXGradient.SetXOffset( aGradient2.XOffset ); + aXGradient.SetYOffset( aGradient2.YOffset ); + aXGradient.SetStartIntens( aGradient2.StartIntensity ); + aXGradient.SetEndIntens( aGradient2.EndIntensity ); + aXGradient.SetSteps( aGradient2.StepCount ); + + SetGradientValue( aXGradient ); + break; + } + + case MID_GRADIENT_STARTCOLOR: + case MID_GRADIENT_ENDCOLOR: + { + sal_Int32 nVal = 0; + if(!(rVal >>= nVal )) + return sal_False; + + XGradient aXGradient = GetGradientValue(); + + if ( nMemberId == MID_GRADIENT_STARTCOLOR ) + aXGradient.SetStartColor( nVal ); + else + aXGradient.SetEndColor( nVal ); + SetGradientValue( aXGradient ); + break; + } + + case MID_GRADIENT_STYLE: + case MID_GRADIENT_ANGLE: + case MID_GRADIENT_BORDER: + case MID_GRADIENT_STARTINTENSITY: + case MID_GRADIENT_ENDINTENSITY: + case MID_GRADIENT_STEPCOUNT: + case MID_GRADIENT_XOFFSET: + case MID_GRADIENT_YOFFSET: + { + sal_Int16 nVal = sal_Int16(); + if(!(rVal >>= nVal )) + return sal_False; + + XGradient aXGradient = GetGradientValue(); + + switch ( nMemberId ) + { + case MID_GRADIENT_STYLE: + aXGradient.SetGradientStyle( (XGradientStyle)nVal ); break; + case MID_GRADIENT_ANGLE: + aXGradient.SetAngle( nVal ); break; + case MID_GRADIENT_BORDER: + aXGradient.SetBorder( nVal ); break; + case MID_GRADIENT_STARTINTENSITY: + aXGradient.SetStartIntens( nVal ); break; + case MID_GRADIENT_ENDINTENSITY: + aXGradient.SetEndIntens( nVal ); break; + case MID_GRADIENT_STEPCOUNT: + aXGradient.SetSteps( nVal ); break; + case MID_GRADIENT_XOFFSET: + aXGradient.SetXOffset( nVal ); break; + case MID_GRADIENT_YOFFSET: + aXGradient.SetYOffset( nVal ); break; + } + + SetGradientValue( aXGradient ); + break; + } + } + + return sal_True; +} + +BOOL XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) +{ + return ((XFillGradientItem*)p1)->GetGradientValue() == ((XFillGradientItem*)p2)->GetGradientValue(); +} + +XFillGradientItem* XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const +{ + if( pModel ) + { + const String aUniqueName = NameOrIndex::CheckNamedItem( this, + XATTR_FILLGRADIENT, + &pModel->GetItemPool(), + pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, + XFillGradientItem::CompareValueFunc, + RID_SVXSTR_GRADIENT, + pModel->GetGradientList() ); + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() ) + { + return new XFillGradientItem( aUniqueName, aGradient ); + } + } + + return (XFillGradientItem*)this; +} + +// ---------------------------------- +// class XFillFloatTransparenceItem - +// ---------------------------------- + +TYPEINIT1_AUTOFACTORY( XFillFloatTransparenceItem, XFillGradientItem ); + +// ----------------------------------------------------------------------------- + +XFillFloatTransparenceItem::XFillFloatTransparenceItem() : + bEnabled( FALSE ) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//------------------------------------------------------------------------ + +XFillFloatTransparenceItem::XFillFloatTransparenceItem( INT32 nIndex, const XGradient& rGradient, BOOL bEnable ) : + XFillGradientItem ( nIndex, rGradient ), + bEnabled ( bEnable ) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//------------------------------------------------------------------------ + +XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XubString& rName, const XGradient& rGradient, BOOL bEnable ) : + XFillGradientItem ( rName, rGradient ), + bEnabled ( bEnable ) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//------------------------------------------------------------------------ + +XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) : + XFillGradientItem ( rItem ), + bEnabled ( rItem.bEnabled ) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//------------------------------------------------------------------------ + +//XFillFloatTransparenceItem::XFillFloatTransparenceItem( SvStream& rIn, USHORT nVer ) : +// XFillGradientItem ( rIn, nVer ) +//{ +// SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +// rIn >> bEnabled; +//} + +//************************************************************************* + +XFillFloatTransparenceItem::XFillFloatTransparenceItem(SfxItemPool* /*pPool*/, const XGradient& rTheGradient, BOOL bEnable ) +: XFillGradientItem ( -1, rTheGradient ), + bEnabled ( bEnable ) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//************************************************************************* + +XFillFloatTransparenceItem::XFillFloatTransparenceItem(SfxItemPool* /*pPool*/) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//------------------------------------------------------------------------ + +int XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const +{ + return ( NameOrIndex::operator==(rItem) ) && + ( GetGradientValue() == ((const XFillGradientItem&)rItem).GetGradientValue() ) && + ( bEnabled == ( (XFillFloatTransparenceItem&) rItem ).bEnabled ); +} + +//------------------------------------------------------------------------ + +SfxPoolItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillFloatTransparenceItem( *this ); +} + +//------------------------------------------------------------------------ + +//SfxPoolItem* XFillFloatTransparenceItem::Create( SvStream& rIn, USHORT nVer ) const +//{ +// return( ( 0 == nVer ) ? Clone( NULL ) : new XFillFloatTransparenceItem( rIn, nVer ) ); +//} + +//------------------------------------------------------------------------ + +//SvStream& XFillFloatTransparenceItem::Store( SvStream& rOut, USHORT nItemVersion ) const +//{ +// XFillGradientItem::Store( rOut, nItemVersion ); +// rOut << bEnabled; +// return rOut; +//} + +//------------------------------------------------------------------------ + +USHORT XFillFloatTransparenceItem::GetVersion( USHORT nFileFormatVersion ) const +{ + // !!! if version number of this object must be increased, please !!! + // !!! increase version number of base class XFillGradientItem !!! + return XFillGradientItem::GetVersion( nFileFormatVersion ); +} + +//------------------------------------------------------------------------ + +sal_Bool XFillFloatTransparenceItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + return XFillGradientItem::QueryValue( rVal, nMemberId ); +} + +//------------------------------------------------------------------------ + +sal_Bool XFillFloatTransparenceItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + return XFillGradientItem::PutValue( rVal, nMemberId ); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, SfxMapUnit ePresUnit, + XubString& rText, + const IntlWrapper * pIntlWrapper ) const +{ + return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, pIntlWrapper ); +} + +BOOL XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) +{ + return ((XFillFloatTransparenceItem*)p1)->IsEnabled() == ((XFillFloatTransparenceItem*)p2)->IsEnabled() && + ((XFillFloatTransparenceItem*)p1)->GetGradientValue() == ((XFillFloatTransparenceItem*)p2)->GetGradientValue(); +} + +XFillFloatTransparenceItem* XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const +{ + // #85953# unique name only necessary when enabled + if(IsEnabled()) + { + if( pModel ) + { + const String aUniqueName = NameOrIndex::CheckNamedItem( this, + XATTR_FILLFLOATTRANSPARENCE, + &pModel->GetItemPool(), + pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, + XFillFloatTransparenceItem::CompareValueFunc, + RID_SVXSTR_TRASNGR0, + NULL ); + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() ) + { + return new XFillFloatTransparenceItem( aUniqueName, GetGradientValue(), TRUE ); + } + } + } + else + { + // #85953# if disabled, force name to empty string + if(GetName().Len()) + { + return new XFillFloatTransparenceItem(String(), GetGradientValue(), FALSE); + } + } + + return (XFillFloatTransparenceItem*)this; +} + +// ------------- +// class XHatch +// ------------- + +/************************************************************************* +|* +|* XHatch::XHatch(XHatchStyle, const Color&, long, long) +|* +|* Beschreibung +|* Ersterstellung 21.11.94 +|* Letzte Aenderung 21.11.94 +|* +*************************************************************************/ + +XHatch::XHatch(const Color& rCol, XHatchStyle eTheStyle, long nTheDistance, + long nTheAngle) : + eStyle(eTheStyle), + aColor(rCol), + nDistance(nTheDistance), + nAngle(nTheAngle) +{ +} + +/************************************************************************* +|* +|* int XHatch::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 29.11.94 +|* Letzte Aenderung 29.11.94 +|* +*************************************************************************/ + +bool XHatch::operator==(const XHatch& rHatch) const +{ + return ( eStyle == rHatch.eStyle && + aColor == rHatch.aColor && + nDistance == rHatch.nDistance && + nAngle == rHatch.nAngle ); +} + + +// ----------------------- +// class XFillHatchItem +// ----------------------- +TYPEINIT1_AUTOFACTORY(XFillHatchItem, NameOrIndex); + +/************************************************************************* +|* +|* XFillHatchItem::XFillHatchItem(INT32 nIndex, +|* const XHatch& rTheHatch) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillHatchItem::XFillHatchItem(INT32 nIndex, + const XHatch& rTheHatch) : + NameOrIndex(XATTR_FILLHATCH, nIndex), + aHatch(rTheHatch) +{ +} + +/************************************************************************* +|* +|* XFillHatchItem::XFillHatchItem(const XubString& rName, +|* const XHatch& rTheHatch) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillHatchItem::XFillHatchItem(const XubString& rName, + const XHatch& rTheHatch) : + NameOrIndex(XATTR_FILLHATCH, rName), + aHatch(rTheHatch) +{ +} + +/************************************************************************* +|* +|* XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) : + NameOrIndex(rItem), + aHatch(rItem.aHatch) +{ +} + +/************************************************************************* +|* +|* XFillHatchItem::XFillHatchItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillHatchItem::XFillHatchItem(SvStream& rIn) : + NameOrIndex(XATTR_FILLHATCH, rIn), + aHatch(COL_BLACK) +{ + if (!IsIndex()) + { + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + INT16 nITemp; + INT32 nLTemp; + + rIn >> nITemp; aHatch.SetHatchStyle((XHatchStyle)nITemp); + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + + Color aCol; + aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) ); + aHatch.SetColor(aCol); + rIn >> nLTemp; aHatch.SetDistance(nLTemp); + rIn >> nLTemp; aHatch.SetAngle(nLTemp); + } +} + +//************************************************************************* + +XFillHatchItem::XFillHatchItem(SfxItemPool* /*pPool*/, const XHatch& rTheHatch) +: NameOrIndex( XATTR_FILLHATCH, -1 ), + aHatch(rTheHatch) +{ +} + +//************************************************************************* + +XFillHatchItem::XFillHatchItem(SfxItemPool* /*pPool*/) +: NameOrIndex(XATTR_FILLHATCH, -1 ) +{ +} + +/************************************************************************* +|* +|* XFillHatchItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFillHatchItem(*this); +} + +/************************************************************************* +|* +|* int XFillHatchItem::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +int XFillHatchItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && + aHatch == ((const XFillHatchItem&) rItem).aHatch ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillHatchItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillHatchItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillHatchItem(rIn); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillHatchItem::Store(SvStream& rOut) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +SvStream& XFillHatchItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if (!IsIndex()) + { + rOut << (INT16)aHatch.GetHatchStyle(); + + USHORT nTmp; + nTmp = VCLTOSVCOL( aHatch.GetColor().GetRed() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aHatch.GetColor().GetGreen() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aHatch.GetColor().GetBlue() ); rOut << nTmp; + + rOut << (INT32) aHatch.GetDistance(); + rOut << (INT32) aHatch.GetAngle(); + } + + return rOut; +} + +/************************************************************************* +|* +|* const XHatch& XFillHatchItem::GetValue(const XHatchTable* pTable) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +const XHatch& XFillHatchItem::GetHatchValue(const XHatchTable* pTable) const // GetValue -> GetHatchValue +{ + if (!IsIndex()) + return aHatch; + else + return pTable->GetHatch(GetIndex())->GetHatch(); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillHatchItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//------------------------------------------------------------------------ + +FASTBOOL XFillHatchItem::HasMetrics() const +{ + return TRUE; +} + +//------------------------------------------------------------------------ + +FASTBOOL XFillHatchItem::ScaleMetrics(long nMul, long nDiv) +{ + aHatch.SetDistance( ScaleMetricValue( aHatch.GetDistance(), nMul, nDiv ) ); + return TRUE; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillHatchItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch ( nMemberId ) + { + case 0: + { + uno::Sequence< beans::PropertyValue > aPropSeq( 2 ); + + ::com::sun::star::drawing::Hatch aUnoHatch; + + aUnoHatch.Style = (::com::sun::star::drawing::HatchStyle)aHatch.GetHatchStyle(); + aUnoHatch.Color = aHatch.GetColor().GetColor(); + aUnoHatch.Distance = aHatch.GetDistance(); + aUnoHatch.Angle = aHatch.GetAngle(); + + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )); + aPropSeq[0].Value = uno::makeAny( aApiName ); + aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" )); + aPropSeq[1].Value = uno::makeAny( aUnoHatch ); + rVal = uno::makeAny( aPropSeq ); + break; + } + + case MID_FILLHATCH: + { + ::com::sun::star::drawing::Hatch aUnoHatch; + + aUnoHatch.Style = (::com::sun::star::drawing::HatchStyle)aHatch.GetHatchStyle(); + aUnoHatch.Color = aHatch.GetColor().GetColor(); + aUnoHatch.Distance = aHatch.GetDistance(); + aUnoHatch.Angle = aHatch.GetAngle(); + rVal <<= aUnoHatch; + break; + } + + case MID_NAME: + { + rtl::OUString aApiName; + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + rVal <<= aApiName; + break; + } + + case MID_HATCH_STYLE: + rVal <<= (::com::sun::star::drawing::HatchStyle)aHatch.GetHatchStyle(); break; + case MID_HATCH_COLOR: + rVal <<= (sal_Int32)aHatch.GetColor().GetColor(); break; + case MID_HATCH_DISTANCE: + rVal <<= aHatch.GetDistance(); break; + case MID_HATCH_ANGLE: + rVal <<= aHatch.GetAngle(); break; + + default: DBG_ERROR("Wrong MemberId!"); return sal_False; + } + + return sal_True; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillHatchItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch ( nMemberId ) + { + case 0: + { + uno::Sequence< beans::PropertyValue > aPropSeq; + ::com::sun::star::drawing::Hatch aUnoHatch; + rtl::OUString aName; + bool bHatch( false ); + + if ( rVal >>= aPropSeq ) + { + for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) + { + if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ))) + aPropSeq[n].Value >>= aName; + else if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillHatch" ))) + { + if ( aPropSeq[n].Value >>= aUnoHatch ) + bHatch = true; + } + } + + SetName( aName ); + if ( bHatch ) + { + aHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style ); + aHatch.SetColor( aUnoHatch.Color ); + aHatch.SetDistance( aUnoHatch.Distance ); + aHatch.SetAngle( aUnoHatch.Angle ); + } + + return sal_True; + } + + return sal_False; + } + + case MID_FILLHATCH: + { + ::com::sun::star::drawing::Hatch aUnoHatch; + if(!(rVal >>= aUnoHatch)) + return sal_False; + + aHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style ); + aHatch.SetColor( aUnoHatch.Color ); + aHatch.SetDistance( aUnoHatch.Distance ); + aHatch.SetAngle( aUnoHatch.Angle ); + break; + } + + case MID_NAME: + { + rtl::OUString aName; + if (!(rVal >>= aName )) + return sal_False; + SetName( aName ); + break; + } + + case MID_HATCH_STYLE: + { + sal_Int16 nVal = sal_Int16(); + if (!(rVal >>= nVal )) + return sal_False; + aHatch.SetHatchStyle( (XHatchStyle)nVal ); + break; + } + + case MID_HATCH_COLOR: + case MID_HATCH_DISTANCE: + case MID_HATCH_ANGLE: + { + sal_Int32 nVal = 0; + if (!(rVal >>= nVal )) + return sal_False; + + if ( nMemberId == MID_HATCH_COLOR ) + aHatch.SetColor( nVal ); + else if ( nMemberId == MID_HATCH_DISTANCE ) + aHatch.SetDistance( nVal ); + else + aHatch.SetAngle( nVal ); + break; + } + + default: DBG_ERROR("Wrong MemberId!"); return sal_False; + } + + return sal_True; +} + +BOOL XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) +{ + return ((XFillHatchItem*)p1)->GetHatchValue() == ((XFillHatchItem*)p2)->GetHatchValue(); +} + +XFillHatchItem* XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const +{ + if( pModel ) + { + const String aUniqueName = NameOrIndex::CheckNamedItem( this, + XATTR_FILLHATCH, + &pModel->GetItemPool(), + pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, + XFillHatchItem::CompareValueFunc, + RID_SVXSTR_HATCH10, + pModel->GetHatchList() ); + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() ) + { + return new XFillHatchItem( aUniqueName, aHatch ); + } + } + + return (XFillHatchItem*)this; +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// FormText-Attribute +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +//------------------------- +// class XFormTextStyleItem +//------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextStyleItem, SfxEnumItem); + +/************************************************************************* +|* +|* XFormTextStyleItem::XFormTextStyleItem() +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) : + SfxEnumItem(XATTR_FORMTXTSTYLE, sal::static_int_cast< USHORT >(eTheStyle)) +{ +} + +/************************************************************************* +|* +|* XFormTextStyleItem::XFormTextStyleItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextStyleItem::XFormTextStyleItem(SvStream& rIn) : + SfxEnumItem(XATTR_FORMTXTSTYLE, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextStyleItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextStyleItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextStyleItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextStyleItem(rIn); +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +USHORT XFormTextStyleItem::GetValueCount() const +{ + return 5; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextStyleItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextStyleItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetValue(sal::static_int_cast< USHORT >(nValue)); + + return sal_True; +} + +//------------------------- +// class XFormTextAdjustItem +//------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextAdjustItem, SfxEnumItem); + +/************************************************************************* +|* +|* XFormTextAdjustItem::XFormTextAdjustItem() +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) : + SfxEnumItem(XATTR_FORMTXTADJUST, sal::static_int_cast< USHORT >(eTheAdjust)) +{ +} + +/************************************************************************* +|* +|* XFormTextAdjustItem::XFormTextAdjustItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextAdjustItem::XFormTextAdjustItem(SvStream& rIn) : + SfxEnumItem(XATTR_FORMTXTADJUST, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextAdjustItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextAdjustItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextAdjustItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextAdjustItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextAdjustItem(rIn); +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +USHORT XFormTextAdjustItem::GetValueCount() const +{ + return 4; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetValue(sal::static_int_cast< USHORT >(nValue)); + + return sal_True; +} + +//---------------------------- +// class XFormTextDistanceItem +//---------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextDistanceItem, SfxMetricItem); + +/************************************************************************* +|* +|* XFormTextDistanceItem::XFormTextDistanceItem() +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextDistanceItem::XFormTextDistanceItem(long nDist) : + SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist) +{ +} + +/************************************************************************* +|* +|* XFormTextDistanceItem::XFormTextDistanceItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextDistanceItem::XFormTextDistanceItem(SvStream& rIn) : + SfxMetricItem(XATTR_FORMTXTDISTANCE, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextDistanceItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextDistanceItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextDistanceItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextDistanceItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextDistanceItem(rIn); +} + +//------------------------- +// class XFormTextStartItem +//------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextStartItem, SfxMetricItem); + +/************************************************************************* +|* +|* XFormTextStartItem::XFormTextStartItem(long nStart) +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextStartItem::XFormTextStartItem(long nStart) : + SfxMetricItem(XATTR_FORMTXTSTART, nStart) +{ +} + +/************************************************************************* +|* +|* XFormTextStartItem::XFormTextStartItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +XFormTextStartItem::XFormTextStartItem(SvStream& rIn) : + SfxMetricItem(XATTR_FORMTXTSTART, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextStartItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextStartItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextStartItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 02.02.95 ESO +|* Letzte Aenderung 02.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextStartItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextStartItem(rIn); +} + +// ------------------------- +// class XFormTextMirrorItem +// ------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextMirrorItem, SfxBoolItem); + +/************************************************************************* +|* +|* XFormTextMirrorItem::XFormTextMirrorItem(BOOL bMirror) +|* +|* Ersterstellung 06.02.95 ESO +|* Letzte Aenderung 06.02.95 ESO +|* +*************************************************************************/ + +XFormTextMirrorItem::XFormTextMirrorItem(BOOL bMirror) : + SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror) +{ +} + +/************************************************************************* +|* +|* XFormTextMirrorItem::XFormTextMirrorItem(SvStream& rIn) +|* +|* Ersterstellung 06.02.95 ESO +|* Letzte Aenderung 06.02.95 ESO +|* +*************************************************************************/ + +XFormTextMirrorItem::XFormTextMirrorItem(SvStream& rIn) : + SfxBoolItem(XATTR_FORMTXTMIRROR, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextMirrorItem::Clone(SfxItemPool* pPool) const +|* +|* Ersterstellung 06.02.95 ESO +|* Letzte Aenderung 06.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextMirrorItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextMirrorItem::Create(SvStream& rIn, USHORT nVer) +|* const +|* +|* Ersterstellung 06.02.95 ESO +|* Letzte Aenderung 06.02.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextMirrorItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextMirrorItem(rIn); +} + + +// -------------------------- +// class XFormTextOutlineItem +// -------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextOutlineItem, SfxBoolItem); + +/************************************************************************* +|* +|* XFormTextOutlineItem::XFormTextOutlineItem() +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +XFormTextOutlineItem::XFormTextOutlineItem(BOOL bOutline) : + SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline) +{ +} + +/************************************************************************* +|* +|* XFormTextOutlineItem::XFormTextOutlineItem(SvStream& rIn) +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +XFormTextOutlineItem::XFormTextOutlineItem(SvStream& rIn) : + SfxBoolItem(XATTR_FORMTXTOUTLINE, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextOutlineItem::Clone(SfxItemPool* pPool) const +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextOutlineItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextOutlineItem::Create(SvStream& rIn, USHORT nVer) +|* const +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextOutlineItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextOutlineItem(rIn); +} + +//-------------------------- +// class XFormTextShadowItem +//-------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextShadowItem, SfxEnumItem); + +/************************************************************************* +|* +|* XFormTextShadowItem::XFormTextShadowItem() +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) : + SfxEnumItem( + XATTR_FORMTXTSHADOW, sal::static_int_cast< USHORT >(eFormTextShadow)) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowItem::XFormTextShadowItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextShadowItem::XFormTextShadowItem(SvStream& rIn) : + SfxEnumItem(XATTR_FORMTXTSHADOW, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextShadowItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextShadowItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextShadowItem(rIn); +} + + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +USHORT XFormTextShadowItem::GetValueCount() const +{ + return 3; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextShadowItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextShadowItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetValue(sal::static_int_cast< USHORT >(nValue)); + + return sal_True; +} + +// ------------------------------- +// class XFormTextShadowColorItem +// ------------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextShadowColorItem, XColorItem); + +/************************************************************************* +|* +|* XFormTextShadowColorItem::XFormTextShadowColorItem() +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextShadowColorItem::XFormTextShadowColorItem(INT32 nIndex, + const Color& rTheColor) : + XColorItem(XATTR_FORMTXTSHDWCOLOR, nIndex, rTheColor) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowColorItem::XFormTextShadowColorItem(const XubString& rName, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextShadowColorItem::XFormTextShadowColorItem(const XubString& rName, + const Color& rTheColor) : + XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowColorItem::XFormTextShadowColorItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextShadowColorItem::XFormTextShadowColorItem(SvStream& rIn) : + XColorItem(XATTR_FORMTXTSHDWCOLOR, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowColorItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextShadowColorItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextShadowColorItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextShadowColorItem(rIn); +} + +//------------------------------ +// class XFormTextShadowXValItem +//------------------------------ +TYPEINIT1_AUTOFACTORY(XFormTextShadowXValItem, SfxMetricItem); + +/************************************************************************* +|* +|* XFormTextShadowXValItem::XFormTextShadowXValItem(long) +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +XFormTextShadowXValItem::XFormTextShadowXValItem(long nVal) : + SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowXValItem::XFormTextShadowXValItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +XFormTextShadowXValItem::XFormTextShadowXValItem(SvStream& rIn) : + SfxMetricItem(XATTR_FORMTXTSHDWXVAL, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowXValItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextShadowXValItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextShadowXValItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowXValItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextShadowXValItem(rIn); +} + +//------------------------------ +// class XFormTextShadowYValItem +//------------------------------ +TYPEINIT1_AUTOFACTORY(XFormTextShadowYValItem, SfxMetricItem); + +/************************************************************************* +|* +|* XFormTextShadowYValItem::XFormTextShadowYValItem(long) +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +XFormTextShadowYValItem::XFormTextShadowYValItem(long nVal) : + SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowYValItem::XFormTextShadowYValItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +XFormTextShadowYValItem::XFormTextShadowYValItem(SvStream& rIn) : + SfxMetricItem(XATTR_FORMTXTSHDWYVAL, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowYValItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextShadowYValItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextShadowYValItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 28.06.95 ESO +|* Letzte Aenderung 28.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowYValItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextShadowYValItem(rIn); +} + +//--------------------------- +// class XFormTextStdFormItem +//--------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextStdFormItem, SfxEnumItem); + +/************************************************************************* +|* +|* XFormTextStdFormItem::XFormTextStdFormItem() +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextStdFormItem::XFormTextStdFormItem(XFormTextStdForm eFormTextStdForm) : + SfxEnumItem( + XATTR_FORMTXTSTDFORM, sal::static_int_cast< USHORT >(eFormTextStdForm)) +{ +} + +/************************************************************************* +|* +|* XFormTextStdFormItem::XFormTextStdFormItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextStdFormItem::XFormTextStdFormItem(SvStream& rIn) : + SfxEnumItem(XATTR_FORMTXTSTDFORM, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextStdFormItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +SfxPoolItem* XFormTextStdFormItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextStdFormItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextStdFormItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +SfxPoolItem* XFormTextStdFormItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextStdFormItem(rIn); +} + + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +USHORT XFormTextStdFormItem::GetValueCount() const +{ + return 3; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextStdFormItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +/************************************************************************* +|* +|* +|* +\*************************************************************************/ + +// #FontWork# +sal_Bool XFormTextStdFormItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/) +{ + sal_Int32 nValue = 0; + rVal >>= nValue; + SetValue(sal::static_int_cast< USHORT >(nValue)); + + return sal_True; +} + +// -------------------------- +// class XFormTextHideFormItem +// -------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextHideFormItem, SfxBoolItem); + +/************************************************************************* +|* +|* XFormTextHideFormItem::XFormTextHideFormItem() +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +XFormTextHideFormItem::XFormTextHideFormItem(BOOL bHide) : + SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide) +{ +} + +/************************************************************************* +|* +|* XFormTextHideFormItem::XFormTextHideFormItem(SvStream& rIn) +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +XFormTextHideFormItem::XFormTextHideFormItem(SvStream& rIn) : + SfxBoolItem(XATTR_FORMTXTHIDEFORM, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextHideFormItem::Clone(SfxItemPool* pPool) const +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextHideFormItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextHideFormItem::Create(SvStream& rIn, USHORT nVer) +|* const +|* +|* Ersterstellung 27.06.95 ESO +|* Letzte Aenderung 27.06.95 ESO +|* +*************************************************************************/ + +SfxPoolItem* XFormTextHideFormItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextHideFormItem(rIn); +} + + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// SetItems +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +TYPEINIT1(XLineAttrSetItem, SfxSetItem); + +/************************************************************************* +|* +|* Konstruktoren fuer Linienattribute-SetItem +|* +\************************************************************************/ + +XLineAttrSetItem::XLineAttrSetItem( SfxItemSet* pItemSet ) : + SfxSetItem( XATTRSET_LINE, pItemSet) +{ +} + +/************************************************************************/ + +XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) : + SfxSetItem( XATTRSET_LINE, + new SfxItemSet( *pItemPool, XATTR_LINE_FIRST, XATTR_LINE_LAST)) +{ +} + +/************************************************************************/ + +XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) : + SfxSetItem( rLineAttr ) +{ +} + +/************************************************************************/ + +XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr, + SfxItemPool* pItemPool) : + SfxSetItem( rLineAttr, pItemPool ) +{ +} + +/************************************************************************* +|* +|* Clone-Funktion +|* +\************************************************************************/ + +SfxPoolItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const +{ + return new XLineAttrSetItem( *this, pPool ); +} + +/************************************************************************* +|* +|* SetItem aus Stream erzeugen +|* +\************************************************************************/ + +SfxPoolItem* XLineAttrSetItem::Create( SvStream& rStream, USHORT /*nVersion*/) const +{ + SfxItemSet *pSet2 = new SfxItemSet( *GetItemSet().GetPool(), + XATTR_LINE_FIRST, XATTR_LINE_LAST); + pSet2->Load( rStream ); + return new XLineAttrSetItem( pSet2 ); +} + +/************************************************************************* +|* +|* SetItem in Stream speichern +|* +\************************************************************************/ + +SvStream& XLineAttrSetItem::Store( SvStream& rStream, USHORT nItemVersion ) const +{ + return SfxSetItem::Store( rStream, nItemVersion ); +} + + +TYPEINIT1(XFillAttrSetItem, SfxSetItem); + +/************************************************************************* +|* +|* Konstruktoren fuer Fuellattribute-SetItem +|* +\************************************************************************/ + +XFillAttrSetItem::XFillAttrSetItem( SfxItemSet* pItemSet ) : + SfxSetItem( XATTRSET_FILL, pItemSet) +{ +} + +/************************************************************************/ + +XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) : + SfxSetItem( XATTRSET_FILL, + new SfxItemSet( *pItemPool, XATTR_FILL_FIRST, XATTR_FILL_LAST)) +{ +} + +/************************************************************************/ + +XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) : + SfxSetItem( rFillAttr ) +{ +} + +/************************************************************************/ + +XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr, + SfxItemPool* pItemPool ) : + SfxSetItem( rFillAttr, pItemPool ) +{ +} + +/************************************************************************* +|* +|* Clone-Funktion +|* +\************************************************************************/ + +SfxPoolItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const +{ + return new XFillAttrSetItem( *this, pPool ); +} + +/************************************************************************* +|* +|* SetItem aus Stream erzeugen +|* +\************************************************************************/ + +SfxPoolItem* XFillAttrSetItem::Create( SvStream& rStream, USHORT /*nVersion*/) const +{ + SfxItemSet *pSet2 = new SfxItemSet( *GetItemSet().GetPool(), + XATTR_FILL_FIRST, XATTR_FILL_LAST); + pSet2->Load( rStream ); + return new XFillAttrSetItem( pSet2 ); +} + +/************************************************************************* +|* +|* SetItem in Stream speichern +|* +\************************************************************************/ + +SvStream& XFillAttrSetItem::Store( SvStream& rStream, USHORT nItemVersion ) const +{ + return SfxSetItem::Store( rStream, nItemVersion ); +} + +// eof + diff --git a/svx/source/xoutdev/xattr2.cxx b/svx/source/xoutdev/xattr2.cxx new file mode 100644 index 000000000000..ea91bc120201 --- /dev/null +++ b/svx/source/xoutdev/xattr2.cxx @@ -0,0 +1,1712 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- + + +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/uno/Any.hxx> + +#include <svx/dialogs.hrc> +#include "xattr.hxx" +#include <svx/xtable.hxx> +#include <svx/dialmgr.hxx> +#include <editeng/itemtype.hxx> +#include <svx/xdef.hxx> + +#define GLOBALOVERFLOW + +/************************************************************************/ + +//------------------------------ +// class XLineTransparenceItem +//------------------------------ +TYPEINIT1_AUTOFACTORY(XLineTransparenceItem, SfxUInt16Item); + +/************************************************************************* +|* +|* XLineTransparenceItem::XLineTransparenceItem(USHORT) +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +XLineTransparenceItem::XLineTransparenceItem(USHORT nLineTransparence) : + SfxUInt16Item(XATTR_LINETRANSPARENCE, nLineTransparence) +{ +} + +/************************************************************************* +|* +|* XLineTransparenceItem::XLineTransparenceItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +XLineTransparenceItem::XLineTransparenceItem(SvStream& rIn) : + SfxUInt16Item(XATTR_LINETRANSPARENCE, rIn) +{ +} + +/************************************************************************* +|* +|* XLineTransparenceItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +SfxPoolItem* XLineTransparenceItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineTransparenceItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XLineTransparenceItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +SfxPoolItem* XLineTransparenceItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XLineTransparenceItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineTransparenceItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = XubString( ResId( RID_SVXSTR_TRANSPARENCE, DIALOG_MGR() ) ); + rText.AppendAscii(": "); + case SFX_ITEM_PRESENTATION_NAMELESS: + rText += XubString( UniString::CreateFromInt32((USHORT) GetValue()) ); + rText += sal_Unicode('%'); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//----------------------- +// class XLineJointItem - +//----------------------- + +TYPEINIT1_AUTOFACTORY(XLineJointItem, SfxEnumItem); + +// ----------------------------------------------------------------------------- + +XLineJointItem::XLineJointItem( XLineJoint eLineJoint ) : + SfxEnumItem(XATTR_LINEJOINT, sal::static_int_cast< USHORT >(eLineJoint)) +{ +} + +// ----------------------------------------------------------------------------- + +XLineJointItem::XLineJointItem( SvStream& rIn ) : + SfxEnumItem( XATTR_LINEJOINT, rIn ) +{ +} + +// ----------------------------------------------------------------------------- + +USHORT XLineJointItem::GetVersion( USHORT /*nFileFormatVersion*/) const +{ + return 1; +} + +// ----------------------------------------------------------------------------- + +SfxPoolItem* XLineJointItem::Create( SvStream& rIn, USHORT nVer ) const +{ + XLineJointItem* pRet = new XLineJointItem( rIn ); + + if(nVer < 1) + pRet->SetValue(XLINEJOINT_ROUND); + + return pRet; +} + +// ----------------------------------------------------------------------------- + +SfxPoolItem* XLineJointItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XLineJointItem( *this ); +} + +// ----------------------------------------------------------------------------- + +SfxItemPresentation XLineJointItem::GetPresentation( SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, XubString& rText, const IntlWrapper*) const +{ + rText.Erase(); + + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: return ePres; + + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + { + USHORT nId = 0; + + switch( GetValue() ) + { + case( XLINEJOINT_NONE ): + nId = RID_SVXSTR_LINEJOINT_NONE; + break; + + case( XLINEJOINT_MIDDLE ): + nId = RID_SVXSTR_LINEJOINT_MIDDLE; + break; + + + case( XLINEJOINT_BEVEL ): + nId = RID_SVXSTR_LINEJOINT_BEVEL; + break; + + + case( XLINEJOINT_MITER ): + nId = RID_SVXSTR_LINEJOINT_MITER; + break; + + + case( XLINEJOINT_ROUND ): + nId = RID_SVXSTR_LINEJOINT_ROUND; + break; + } + + if( nId ) + rText = SVX_RESSTR( nId ); + + return ePres; + } + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +// ----------------------------------------------------------------------------- + +sal_Bool XLineJointItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const +{ + ::com::sun::star::drawing::LineJoint eJoint = ::com::sun::star::drawing::LineJoint_NONE; + + switch( GetValue() ) + { + case XLINEJOINT_NONE: + break; + case XLINEJOINT_MIDDLE: + eJoint = ::com::sun::star::drawing::LineJoint_MIDDLE; + break; + case XLINEJOINT_BEVEL: + eJoint = ::com::sun::star::drawing::LineJoint_BEVEL; + break; + case XLINEJOINT_MITER: + eJoint = ::com::sun::star::drawing::LineJoint_MITER; + break; + case XLINEJOINT_ROUND: + eJoint = ::com::sun::star::drawing::LineJoint_ROUND; + break; + default: + DBG_ERROR( "Unknown LineJoint enum value!" ); + } + + rVal <<= eJoint; + return sal_True; +} + +// ----------------------------------------------------------------------------- + +BOOL XLineJointItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) +{ + XLineJoint eJoint = XLINEJOINT_NONE; + ::com::sun::star::drawing::LineJoint eUnoJoint; + + if(!(rVal >>= eUnoJoint)) + { + // also try an int (for Basic) + sal_Int32 nLJ = 0; + if(!(rVal >>= nLJ)) + return sal_False; + eUnoJoint = (::com::sun::star::drawing::LineJoint)nLJ; + } + + switch( eUnoJoint ) + { + case ::com::sun::star::drawing::LineJoint_MIDDLE: + eJoint = XLINEJOINT_MIDDLE; + break; + case ::com::sun::star::drawing::LineJoint_BEVEL: + eJoint = XLINEJOINT_BEVEL; + break; + case ::com::sun::star::drawing::LineJoint_MITER: + eJoint = XLINEJOINT_MITER; + break; + case ::com::sun::star::drawing::LineJoint_ROUND: + eJoint = XLINEJOINT_ROUND; + break; + default: + break; + } + + SetValue( sal::static_int_cast< USHORT >( eJoint ) ); + + return sal_True; +} + +// ----------------------------------------------------------------------------- + +USHORT XLineJointItem::GetValueCount() const +{ + // don't forget to update the api interface also + return 5; +} + +//------------------------------ +// class XFillTransparenceItem +//------------------------------ +TYPEINIT1_AUTOFACTORY(XFillTransparenceItem, SfxUInt16Item); + +/************************************************************************* +|* +|* XFillTransparenceItem::XFillTransparenceItem(USHORT) +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +XFillTransparenceItem::XFillTransparenceItem(USHORT nFillTransparence) : + SfxUInt16Item(XATTR_FILLTRANSPARENCE, nFillTransparence) +{ +} + +/************************************************************************* +|* +|* XFillTransparenceItem::XFillTransparenceItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +XFillTransparenceItem::XFillTransparenceItem(SvStream& rIn) : + SfxUInt16Item(XATTR_FILLTRANSPARENCE, rIn) +{ +} + +/************************************************************************* +|* +|* XFillTransparenceItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillTransparenceItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFillTransparenceItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillTransparenceItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 07.11.95 KA +|* Letzte Aenderung 07.11.95 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillTransparenceItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillTransparenceItem(rIn); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillTransparenceItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + rText = XubString( ResId( RID_SVXSTR_TRANSPARENCE, DIALOG_MGR() ) ); + rText.AppendAscii(": "); + case SFX_ITEM_PRESENTATION_NAMELESS: + rText += XubString( UniString::CreateFromInt32((USHORT) GetValue() )); + rText += sal_Unicode('%'); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//------------------------------ +// class XFormTextShadowTranspItem +//------------------------------ +TYPEINIT1_AUTOFACTORY(XFormTextShadowTranspItem, SfxUInt16Item); + +/************************************************************************* +|* +|* XFormTextShadowTranspItem::XFormTextShadowTranspItem(USHORT) +|* +|* Beschreibung +|* Ersterstellung 09.11.95 KA +|* Letzte Aenderung 09.11.95 KA +|* +*************************************************************************/ + +XFormTextShadowTranspItem::XFormTextShadowTranspItem(USHORT nShdwTransparence) : + SfxUInt16Item(XATTR_FORMTXTSHDWTRANSP, nShdwTransparence) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowTranspItem::XFormTextShadowTranspItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 09.11.95 KA +|* Letzte Aenderung 09.11.95 KA +|* +*************************************************************************/ + +XFormTextShadowTranspItem::XFormTextShadowTranspItem(SvStream& rIn) : + SfxUInt16Item(XATTR_FORMTXTSHDWTRANSP, rIn) +{ +} + +/************************************************************************* +|* +|* XFormTextShadowTranspItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 09.11.95 KA +|* Letzte Aenderung 09.11.95 KA +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowTranspItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFormTextShadowTranspItem(*this); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFormTextShadowTranspItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 09.11.95 KA +|* Letzte Aenderung 09.11.95 KA +|* +*************************************************************************/ + +SfxPoolItem* XFormTextShadowTranspItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFormTextShadowTranspItem(rIn); +} + + +//------------------------------ +// class XFillGradientStepCountItem +//------------------------------ +TYPEINIT1_AUTOFACTORY(XGradientStepCountItem, SfxUInt16Item); + +/************************************************************************* +|* +|* XGradientStepCountItem::XGradientStepCountItem( USHORT ) +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +XGradientStepCountItem::XGradientStepCountItem( USHORT nStepCount ) : + SfxUInt16Item( XATTR_GRADIENTSTEPCOUNT, nStepCount ) +{ +} + +/************************************************************************* +|* +|* XGradientStepCountItem::XGradientStepCountItem( SvStream& rIn ) +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +XGradientStepCountItem::XGradientStepCountItem( SvStream& rIn ) : + SfxUInt16Item( XATTR_GRADIENTSTEPCOUNT, rIn ) +{ +} + +/************************************************************************* +|* +|* XGradientStepCountItem::Clone( SfxItemPool* pPool ) const +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XGradientStepCountItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XGradientStepCountItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XGradientStepCountItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XGradientStepCountItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XGradientStepCountItem( rIn ); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XGradientStepCountItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: +// rText = XubString( ResId( RID_SVXSTR_GRADIENTSTEPCOUNT, DIALOG_MGR() ) ); +// rText += ": "; + case SFX_ITEM_PRESENTATION_NAMELESS: + rText += XubString( UniString::CreateFromInt32((USHORT) GetValue() )); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpTileItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpTileItem, SfxBoolItem ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpTileItem::XFillBmpTileItem( BOOL bTile ) : + SfxBoolItem( XATTR_FILLBMP_TILE, bTile ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpTileItem::XFillBmpTileItem( SvStream& rIn ) : + SfxBoolItem( XATTR_FILLBMP_TILE, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpTileItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpTileItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpTileItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpTileItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpTileItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpTilePosItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpPosItem, SfxEnumItem ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpPosItem::XFillBmpPosItem( RECT_POINT eRP ) : + SfxEnumItem( XATTR_FILLBMP_POS, sal::static_int_cast< USHORT >( eRP ) ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpPosItem::XFillBmpPosItem( SvStream& rIn ) : + SfxEnumItem( XATTR_FILLBMP_POS, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpPosItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpPosItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpPosItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpPosItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpPosItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +/****************************************************************************** +|* +|* +|* +\******************************************************************************/ + +USHORT XFillBmpPosItem::GetValueCount() const +{ + return 9; +} + + +//------------------------------ +// class XFillBmpTileSizeXItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpSizeXItem, SfxMetricItem ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpSizeXItem::XFillBmpSizeXItem( long nSizeX ) : + SfxMetricItem( XATTR_FILLBMP_SIZEX, nSizeX ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpSizeXItem::XFillBmpSizeXItem( SvStream& rIn ) : + SfxMetricItem( XATTR_FILLBMP_SIZEX, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpSizeXItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpSizeXItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpSizeXItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpSizeXItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpSizeXItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +/************************************************************************* +|* +|* Beschreibung +|* Ersterstellung 05.11.96 KA +|* Letzte Aenderung 05.11.96 KA +|* +\*************************************************************************/ + +FASTBOOL XFillBmpSizeXItem::HasMetrics() const +{ + return GetValue() > 0L; +} + + +//------------------------------ +// class XFillBmpTileSizeYItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpSizeYItem, SfxMetricItem ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpSizeYItem::XFillBmpSizeYItem( long nSizeY ) : + SfxMetricItem( XATTR_FILLBMP_SIZEY, nSizeY ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpSizeYItem::XFillBmpSizeYItem( SvStream& rIn ) : + SfxMetricItem( XATTR_FILLBMP_SIZEY, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpSizeYItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpSizeYItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpSizeYItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpSizeYItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpSizeYItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +/************************************************************************* +|* +|* Beschreibung +|* Ersterstellung 05.11.96 KA +|* Letzte Aenderung 05.11.96 KA +|* +\*************************************************************************/ + +FASTBOOL XFillBmpSizeYItem::HasMetrics() const +{ + return GetValue() > 0L; +} + + +//------------------------------ +// class XFillBmpTileLogItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpSizeLogItem, SfxBoolItem ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpSizeLogItem::XFillBmpSizeLogItem( BOOL bLog ) : + SfxBoolItem( XATTR_FILLBMP_SIZELOG, bLog ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpSizeLogItem::XFillBmpSizeLogItem( SvStream& rIn ) : + SfxBoolItem( XATTR_FILLBMP_SIZELOG, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpSizeLogItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpSizeLogItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpSizeLogItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpSizeLogItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpSizeLogItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpTileOffXItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpTileOffsetXItem, SfxUInt16Item ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpTileOffsetXItem::XFillBmpTileOffsetXItem( USHORT nOffX ) : + SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETX, nOffX ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpTileOffsetXItem::XFillBmpTileOffsetXItem( SvStream& rIn ) : + SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETX, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpTileOffsetXItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpTileOffsetXItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpTileOffsetXItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpTileOffsetXItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpTileOffsetXItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpTileOffYItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpTileOffsetYItem, SfxUInt16Item ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpTileOffsetYItem::XFillBmpTileOffsetYItem( USHORT nOffY ) : + SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETY, nOffY ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpTileOffsetYItem::XFillBmpTileOffsetYItem( SvStream& rIn ) : + SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETY, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpTileOffsetYItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpTileOffsetYItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpTileOffsetYItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpTileOffsetYItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpTileOffsetYItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpStretchItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpStretchItem, SfxBoolItem ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpStretchItem::XFillBmpStretchItem( BOOL bStretch ) : + SfxBoolItem( XATTR_FILLBMP_STRETCH, bStretch ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +XFillBmpStretchItem::XFillBmpStretchItem( SvStream& rIn ) : + SfxBoolItem( XATTR_FILLBMP_STRETCH, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpStretchItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpStretchItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpStretchItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpStretchItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung 28.02.96 KA +|* Letzte Aenderung 28.02.96 KA +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpStretchItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpTileOffPosXItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpPosOffsetXItem, SfxUInt16Item ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +XFillBmpPosOffsetXItem::XFillBmpPosOffsetXItem( USHORT nOffPosX ) : + SfxUInt16Item( XATTR_FILLBMP_POSOFFSETX, nOffPosX ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +XFillBmpPosOffsetXItem::XFillBmpPosOffsetXItem( SvStream& rIn ) : + SfxUInt16Item( XATTR_FILLBMP_POSOFFSETX, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpPosOffsetXItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpPosOffsetXItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpPosOffsetXItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpPosOffsetXItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpPosOffsetXItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + +//------------------------------ +// class XFillBmpTileOffPosYItem +//------------------------------ +TYPEINIT1_AUTOFACTORY( XFillBmpPosOffsetYItem, SfxUInt16Item ); + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +XFillBmpPosOffsetYItem::XFillBmpPosOffsetYItem( USHORT nOffPosY ) : + SfxUInt16Item( XATTR_FILLBMP_POSOFFSETY, nOffPosY ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +XFillBmpPosOffsetYItem::XFillBmpPosOffsetYItem( SvStream& rIn ) : + SfxUInt16Item( XATTR_FILLBMP_POSOFFSETY, rIn ) +{ +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpPosOffsetYItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBmpPosOffsetYItem( *this ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +SfxPoolItem* XFillBmpPosOffsetYItem::Create( SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBmpPosOffsetYItem( rIn ); +} + + +/************************************************************************* +|* +|* +|* +|* Beschreibung +|* Ersterstellung KA 29.04.96 +|* Letzte Aenderung KA 29.04.96 +|* +*************************************************************************/ + +SfxItemPresentation XFillBmpPosOffsetYItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//-------------------------- +// class XFillBackgroundItem +//-------------------------- +TYPEINIT1_AUTOFACTORY(XFillBackgroundItem, SfxBoolItem); + +/************************************************************************* +|* +|* XFillBackgroundItem::XFillBackgroundItem( BOOL ) +|* +|* Beschreibung +|* Ersterstellung 19.11.96 KA +|* Letzte Aenderung +|* +*************************************************************************/ + +XFillBackgroundItem::XFillBackgroundItem( BOOL bFill ) : + SfxBoolItem( XATTR_FILLBACKGROUND, bFill ) +{ +} + +/************************************************************************* +|* +|* XFillBackgroundItem::XFillBackgroundItem( SvStream& rIn ) +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +XFillBackgroundItem::XFillBackgroundItem( SvStream& rIn ) : + SfxBoolItem( XATTR_FILLBACKGROUND, rIn ) +{ +} + +/************************************************************************* +|* +|* XFillBackgroundItem::Clone( SfxItemPool* pPool ) const +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBackgroundItem::Clone( SfxItemPool* /*pPool*/) const +{ + return new XFillBackgroundItem( *this ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillBackgroundItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 23.01.96 KA +|* Letzte Aenderung 23.01.96 KA +|* +*************************************************************************/ + +SfxPoolItem* XFillBackgroundItem::Create(SvStream& rIn, USHORT /*nVer*/) const +{ + return new XFillBackgroundItem( rIn ); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillBackgroundItem::GetPresentation( SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, XubString& rText, const IntlWrapper*) const +{ + rText.Erase(); + + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + + + diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx new file mode 100644 index 000000000000..486602e28256 --- /dev/null +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -0,0 +1,894 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <tools/stream.hxx> +#include <vcl/window.hxx> +#include <vcl/virdev.hxx> +#include <vcl/bitmapex.hxx> +#include <toolkit/unohlp.hxx> +#include <svl/style.hxx> +#include <editeng/memberids.hrc> + +#include <svx/dialogs.hrc> +#include "xattr.hxx" +#include <svx/xtable.hxx> +#include <svx/xdef.hxx> +#include <svx/unomid.hxx> +#include <editeng/unoprnms.hxx> + +#include "unoapi.hxx" +#include <svx/svdmodel.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> + +#define GLOBALOVERFLOW + +using namespace ::com::sun::star; + +// --------------- +// class XOBitmap +// --------------- + +/************************************************************************* +|* +|* XOBitmap::XOBitmap() +|* +|* Beschreibung +|* Ersterstellung 27.07.95 +|* Letzte Aenderung 27.07.95 +|* +*************************************************************************/ + +XOBitmap::XOBitmap() : + eType ( XBITMAP_NONE ), + eStyle ( XBITMAP_STRETCH ), + pPixelArray ( NULL ), + bGraphicDirty ( FALSE ) +{ +} + +/************************************************************************* +|* +|* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE ) +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +XOBitmap::XOBitmap( const Bitmap& rBmp, XBitmapStyle eInStyle ) : + eType ( XBITMAP_IMPORT ), + eStyle ( eInStyle ), + aGraphicObject ( rBmp ), + pPixelArray ( NULL ), + bGraphicDirty ( FALSE ) +{ +} + +/************************************************************************* +|* +|* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE ) +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +XOBitmap::XOBitmap( const GraphicObject& rGraphicObject, XBitmapStyle eInStyle ) : + eType ( XBITMAP_IMPORT ), + eStyle ( eInStyle ), + aGraphicObject ( rGraphicObject ), + pPixelArray ( NULL ), + bGraphicDirty ( FALSE ) +{ +} + +/************************************************************************* +|* +|* XOBitmap::XOBitmap( USHORT* pArray, const Color& aPixelColor, +|* const Color& aBckgrColor, const Size& rSize = Size( 8, 8 ), +|* XBitmapStyle eStyle = XBITMAP_TILE ) +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +XOBitmap::XOBitmap( const USHORT* pArray, const Color& rPixelColor, + const Color& rBckgrColor, const Size& rSize, + XBitmapStyle eInStyle ) : + eStyle ( eInStyle ), + pPixelArray ( NULL ), + aArraySize ( rSize ), + aPixelColor ( rPixelColor ), + aBckgrColor ( rBckgrColor ), + bGraphicDirty ( TRUE ) + +{ + if( aArraySize.Width() == 8 && aArraySize.Height() == 8 ) + { + eType = XBITMAP_8X8; + pPixelArray = new USHORT[ 64 ]; + + for( USHORT i = 0; i < 64; i++ ) + *( pPixelArray + i ) = *( pArray + i ); + } + else + { + DBG_ASSERT( 0, "Nicht unterstuetzte Bitmapgroesse" ); + } +} + +/************************************************************************* +|* +|* XOBitmap::XOBitmap( const XOBitmap& rXBmp ) +|* +|* Beschreibung +|* Ersterstellung 27.07.95 +|* Letzte Aenderung 27.07.95 +|* +*************************************************************************/ + +XOBitmap::XOBitmap( const XOBitmap& rXBmp ) : + pPixelArray ( NULL ) +{ + eType = rXBmp.eType; + eStyle = rXBmp.eStyle; + aGraphicObject = rXBmp.aGraphicObject; + aArraySize = rXBmp.aArraySize; + aPixelColor = rXBmp.aPixelColor; + aBckgrColor = rXBmp.aBckgrColor; + bGraphicDirty = rXBmp.bGraphicDirty; + + if( rXBmp.pPixelArray ) + { + if( eType == XBITMAP_8X8 ) + { + pPixelArray = new USHORT[ 64 ]; + + for( USHORT i = 0; i < 64; i++ ) + *( pPixelArray + i ) = *( rXBmp.pPixelArray + i ); + } + } +} + +/************************************************************************* +|* +|* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE ) +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +XOBitmap::~XOBitmap() +{ + if( pPixelArray ) + delete []pPixelArray; +} + +/************************************************************************* +|* +|* XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp ) +|* +|* Beschreibung +|* Ersterstellung 27.07.95 +|* Letzte Aenderung 27.07.95 +|* +*************************************************************************/ + +XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp ) +{ + eType = rXBmp.eType; + eStyle = rXBmp.eStyle; + aGraphicObject = rXBmp.aGraphicObject; + aArraySize = rXBmp.aArraySize; + aPixelColor = rXBmp.aPixelColor; + aBckgrColor = rXBmp.aBckgrColor; + bGraphicDirty = rXBmp.bGraphicDirty; + + if( rXBmp.pPixelArray ) + { + if( eType == XBITMAP_8X8 ) + { + pPixelArray = new USHORT[ 64 ]; + + for( USHORT i = 0; i < 64; i++ ) + *( pPixelArray + i ) = *( rXBmp.pPixelArray + i ); + } + } + return( *this ); +} + +/************************************************************************* +|* +|* int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const +{ + if( eType != rXOBitmap.eType || + eStyle != rXOBitmap.eStyle || + aGraphicObject != rXOBitmap.aGraphicObject || + aArraySize != rXOBitmap.aArraySize || + aPixelColor != rXOBitmap.aPixelColor || + aBckgrColor != rXOBitmap.aBckgrColor || + bGraphicDirty != rXOBitmap.bGraphicDirty ) + { + return( FALSE ); + } + + if( pPixelArray && rXOBitmap.pPixelArray ) + { + USHORT nCount = (USHORT) ( aArraySize.Width() * aArraySize.Height() ); + for( USHORT i = 0; i < nCount; i++ ) + { + if( *( pPixelArray + i ) != *( rXOBitmap.pPixelArray + i ) ) + return( FALSE ); + } + } + return( TRUE ); +} + +/************************************************************************* +|* +|* void SetPixelArray( const USHORT* pArray ) +|* +|* Beschreibung +|* Ersterstellung 27.07.95 +|* Letzte Aenderung 27.07.95 +|* +*************************************************************************/ + +void XOBitmap::SetPixelArray( const USHORT* pArray ) +{ + if( eType == XBITMAP_8X8 ) + { + if( pPixelArray ) + delete []pPixelArray; + + pPixelArray = new USHORT[ 64 ]; + + for( USHORT i = 0; i < 64; i++ ) + *( pPixelArray + i ) = *( pArray + i ); + + bGraphicDirty = TRUE; + } + else + { + DBG_ASSERT( 0, "Nicht unterstuetzter Bitmaptyp" ); + } +} + +/************************************************************************* +|* +|* Bitmap XOBitmap::GetBitmap() +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +Bitmap XOBitmap::GetBitmap() const +{ + return GetGraphicObject().GetGraphic().GetBitmap(); +} + +/************************************************************************* +|* +|* Bitmap XOBitmap::GetGraphicObject() +|* +|* Beschreibung +|* Ersterstellung +|* Letzte Aenderung +|* +*************************************************************************/ + +const GraphicObject& XOBitmap::GetGraphicObject() const +{ + if( bGraphicDirty ) + ( (XOBitmap*) this )->Array2Bitmap(); + + return aGraphicObject; +} + +/************************************************************************* +|* +|* void XOBitmap::Bitmap2Array() +|* +|* Beschreibung Umwandlung der Bitmap in Array, Hinter- u. +|* Vordergrundfarbe +|* Ersterstellung 27.07.95 +|* Letzte Aenderung 27.07.95 +|* +*************************************************************************/ + +void XOBitmap::Bitmap2Array() +{ + VirtualDevice aVD; + BOOL bPixelColor = FALSE; + const Bitmap aBitmap( GetBitmap() ); + const USHORT nLines = 8; // von Type abhaengig + + if( !pPixelArray ) + pPixelArray = new USHORT[ nLines * nLines ]; + + aVD.SetOutputSizePixel( aBitmap.GetSizePixel() ); + aVD.DrawBitmap( Point(), aBitmap ); + aPixelColor = aBckgrColor = aVD.GetPixel( Point() ); + + // Aufbau des Arrays und Ermittlung der Vorder-, bzw. + // Hintergrundfarbe + for( USHORT i = 0; i < nLines; i++ ) + { + for( USHORT j = 0; j < nLines; j++ ) + { + if ( aVD.GetPixel( Point( j, i ) ) == aBckgrColor ) + *( pPixelArray + j + i * nLines ) = 0; + else + { + *( pPixelArray + j + i * nLines ) = 1; + if( !bPixelColor ) + { + aPixelColor = aVD.GetPixel( Point( j, i ) ); + bPixelColor = TRUE; + } + } + } + } +} + +/************************************************************************* +|* +|* void XOBitmap::Array2Bitmap() +|* +|* Beschreibung Umwandlung des Arrays, Hinter- u. +|* Vordergrundfarbe in eine Bitmap +|* Ersterstellung 27.07.95 +|* Letzte Aenderung 27.07.95 +|* +*************************************************************************/ + +void XOBitmap::Array2Bitmap() +{ + VirtualDevice aVD; + USHORT nLines = 8; // von Type abhaengig + + if( !pPixelArray ) + return; + + aVD.SetOutputSizePixel( Size( nLines, nLines ) ); + + // Aufbau der Bitmap + for( USHORT i = 0; i < nLines; i++ ) + { + for( USHORT j = 0; j < nLines; j++ ) + { + if( *( pPixelArray + j + i * nLines ) == 0 ) + aVD.DrawPixel( Point( j, i ), aBckgrColor ); + else + aVD.DrawPixel( Point( j, i ), aPixelColor ); + } + } + + aGraphicObject = GraphicObject( aVD.GetBitmap( Point(), Size( nLines, nLines ) ) ); + bGraphicDirty = FALSE; +} + +// ----------------------- +// class XFillBitmapItem +// ----------------------- +TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex); + +/************************************************************************* +|* +|* XFillBitmapItem::XFillBitmapItem(long nIndex, +|* const Bitmap& rTheBitmap) +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XFillBitmapItem::XFillBitmapItem(long nIndex, + const XOBitmap& rTheBitmap) : + NameOrIndex( XATTR_FILLBITMAP, nIndex ), + aXOBitmap( rTheBitmap ) +{ +} + +/************************************************************************* +|* +|* XFillBitmapItem::XFillBitmapItem(const XubString& rName, +|* const Bitmap& rTheBitmap) +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XFillBitmapItem::XFillBitmapItem(const XubString& rName, + const XOBitmap& rTheBitmap) : + NameOrIndex( XATTR_FILLBITMAP, rName ), + aXOBitmap( rTheBitmap ) +{ +} + +/************************************************************************* +|* +|* XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) : + NameOrIndex( rItem ), + aXOBitmap( rItem.aXOBitmap ) +{ +} + +/************************************************************************* +|* +|* XFillBitmapItem::XFillBitmapItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 26.07.94 +|* +*************************************************************************/ + +XFillBitmapItem::XFillBitmapItem( SvStream& rIn, USHORT nVer ) : + NameOrIndex( XATTR_FILLBITMAP, rIn ) +{ + if( nVer == 0 ) + { + if (!IsIndex()) + { + // Behandlung der alten Bitmaps + Bitmap aBmp; + + rIn >> aBmp; + + aXOBitmap.SetBitmap( aBmp ); + aXOBitmap.SetBitmapStyle( XBITMAP_TILE ); + + if( aBmp.GetSizePixel().Width() == 8 && + aBmp.GetSizePixel().Height() == 8 ) + { + aXOBitmap.SetBitmapType( XBITMAP_8X8 ); + aXOBitmap.Bitmap2Array(); + } + else + aXOBitmap.SetBitmapType( XBITMAP_IMPORT ); + } + } + else if( nVer == 1 ) + { + if (!IsIndex()) + { + INT16 iTmp; + rIn >> iTmp; + aXOBitmap.SetBitmapStyle( (XBitmapStyle) iTmp ); + rIn >> iTmp; + aXOBitmap.SetBitmapType( (XBitmapType) iTmp ); + + if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT ) + { + Bitmap aBmp; + rIn >> aBmp; + aXOBitmap.SetBitmap( aBmp ); + } + else if( aXOBitmap.GetBitmapType() == XBITMAP_8X8 ) + { + USHORT* pArray = new USHORT[ 64 ]; + Color aColor; + + for( USHORT i = 0; i < 64; i++ ) + rIn >> *( pArray + i ); + aXOBitmap.SetPixelArray( pArray ); + + rIn >> aColor; + aXOBitmap.SetPixelColor( aColor ); + rIn >> aColor; + aXOBitmap.SetBackgroundColor( aColor ); + + delete []pArray; + } + } + } + + // #81908# force bitmap to exist + aXOBitmap.GetBitmap(); +} + +//************************************************************************* + +XFillBitmapItem::XFillBitmapItem( SfxItemPool* /*pPool*/, const XOBitmap& rTheBitmap ) +: NameOrIndex( XATTR_FILLBITMAP, -1 ), + aXOBitmap( rTheBitmap ) +{ +} + +//************************************************************************* + +XFillBitmapItem::XFillBitmapItem( SfxItemPool* /*pPool*/) +: NameOrIndex(XATTR_FILLBITMAP, -1 ) +{ +} + +/************************************************************************* +|* +|* XFillBitmapItem::Clone(SfxItemPool* pPool) const +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const +{ + return new XFillBitmapItem(*this); +} + +/************************************************************************* +|* +|* int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const +{ + return ( NameOrIndex::operator==(rItem) && + aXOBitmap == ((const XFillBitmapItem&) rItem).aXOBitmap ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, USHORT nVer) const +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, USHORT nVer) const +{ + return new XFillBitmapItem( rIn, nVer ); +} + +/************************************************************************* +|* +|* SfxPoolItem* XFillBitmapItem::Store(SvStream& rOut) const +|* +|* Beschreibung +|* Ersterstellung 17.11.94 +|* Letzte Aenderung 26.07.94 +|* +*************************************************************************/ + +SvStream& XFillBitmapItem::Store( SvStream& rOut, USHORT nItemVersion ) const +{ + NameOrIndex::Store( rOut, nItemVersion ); + + if (!IsIndex()) + { + rOut << (INT16) aXOBitmap.GetBitmapStyle(); + if( !aXOBitmap.GetBitmap() ) + rOut << (INT16) XBITMAP_NONE; + else + { + rOut << (INT16) aXOBitmap.GetBitmapType(); + if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT ) + { + const USHORT nOldComprMode = rOut.GetCompressMode(); + USHORT nNewComprMode = nOldComprMode; + + if( rOut.GetVersion() >= SOFFICE_FILEFORMAT_50 ) + nNewComprMode |= COMPRESSMODE_ZBITMAP; + else + nNewComprMode &= ~COMPRESSMODE_ZBITMAP; + + rOut.SetCompressMode( nNewComprMode ); + rOut << aXOBitmap.GetBitmap(); + rOut.SetCompressMode( nOldComprMode ); + } + else if( aXOBitmap.GetBitmapType() == XBITMAP_8X8 ) + { + USHORT* pArray = aXOBitmap.GetPixelArray(); + for( USHORT i = 0; i < 64; i++ ) + rOut << (USHORT) *( pArray + i ); + + rOut << aXOBitmap.GetPixelColor(); + rOut << aXOBitmap.GetBackgroundColor(); + } + } + } + + return rOut; +} + +/************************************************************************* +|* +|* const Bitmap& XFillBitmapItem::GetValue(const XBitmapTable* pTable) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 26.07.94 +|* +*************************************************************************/ + +const XOBitmap& XFillBitmapItem::GetBitmapValue(const XBitmapTable* pTable) const // GetValue -> GetBitmapValue +{ + if (!IsIndex()) + return aXOBitmap; + else + return pTable->GetBitmap(GetIndex())->GetXBitmap(); +} + + +/************************************************************************* +|* +|* USHORT XFillBitmapItem::GetVersion() const +|* +|* Beschreibung +|* Ersterstellung 26.07.95 +|* Letzte Aenderung 26.07.95 +|* +*************************************************************************/ + +USHORT XFillBitmapItem::GetVersion( USHORT /*nFileFormatVersion*/) const +{ + // 2. Version + return( 1 ); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillBitmapItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, const IntlWrapper * +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return ePres; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + rText += GetName(); + return ePres; + default: + return SFX_ITEM_PRESENTATION_NONE; + } +} + +//------------------------------------------------------------------------ + +sal_Bool XFillBitmapItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + // needed for MID_NAME + ::rtl::OUString aApiName; + // needed for complete item (MID 0) + ::rtl::OUString aInternalName; + + ::rtl::OUString aURL; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; + + if( nMemberId == MID_NAME ) + { + SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); + } + else if( nMemberId == 0 ) + { + aInternalName = GetName(); + } + + if( nMemberId == MID_GRAFURL || + nMemberId == 0 ) + { + XOBitmap aLocalXOBitmap( GetBitmapValue() ); + aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); + aURL += ::rtl::OUString::createFromAscii( aLocalXOBitmap.GetGraphicObject().GetUniqueID().GetBuffer() ); + } + if( nMemberId == MID_BITMAP || + nMemberId == 0 ) + { + XOBitmap aLocalXOBitmap( GetBitmapValue() ); + Bitmap aBmp( aLocalXOBitmap.GetBitmap() ); + BitmapEx aBmpEx( aBmp ); + + xBmp.set( VCLUnoHelper::CreateBitmap( aBmpEx ) ); + } + + if( nMemberId == MID_NAME ) + rVal <<= aApiName; + else if( nMemberId == MID_GRAFURL ) + rVal <<= aURL; + else if( nMemberId == MID_BITMAP ) + rVal <<= xBmp; + else + { + // member-id 0 => complete item (e.g. for toolbars) + DBG_ASSERT( nMemberId == 0, "invalid member-id" ); + uno::Sequence< beans::PropertyValue > aPropSeq( 3 ); + + aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )); + aPropSeq[0].Value = uno::makeAny( aInternalName ); + aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" )); + aPropSeq[1].Value = uno::makeAny( aURL ); + aPropSeq[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" )); + aPropSeq[2].Value = uno::makeAny( xBmp ); + + rVal <<= aPropSeq; + } + + return sal_True; +} + +//------------------------------------------------------------------------ + +sal_Bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + ::rtl::OUString aName; + ::rtl::OUString aURL; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic; + + bool bSetName = false; + bool bSetURL = false; + bool bSetBitmap = false; + + if( nMemberId == MID_NAME ) + bSetName = (rVal >>= aName); + else if( nMemberId == MID_GRAFURL ) + bSetURL = (rVal >>= aURL); + else if( nMemberId == MID_BITMAP ) + { + bSetBitmap = (rVal >>= xBmp); + if ( !bSetBitmap ) + bSetBitmap = (rVal >>= xGraphic ); + } + else + { + DBG_ASSERT( nMemberId == 0, "invalid member-id" ); + uno::Sequence< beans::PropertyValue > aPropSeq; + if( rVal >>= aPropSeq ) + { + for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) + { + if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ))) + bSetName = (aPropSeq[n].Value >>= aName); + else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillBitmapURL" ))) + bSetURL = (aPropSeq[n].Value >>= aURL); + else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Bitmap" ))) + bSetBitmap = (aPropSeq[n].Value >>= xBmp); + } + } + } + + if( bSetName ) + { + SetName( aName ); + } + if( bSetURL ) + { + GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); + XOBitmap aBMP( aGrafObj ); + SetBitmapValue( aBMP ); + } + if( bSetBitmap ) + { + Bitmap aInput; + if ( xBmp.is() ) + { + BitmapEx aInputEx( VCLUnoHelper::GetBitmap( xBmp ) ); + aInput = aInputEx.GetBitmap(); + } + else if ( xGraphic.is() ) + { + Graphic aGraphic( xGraphic ); + aInput = aGraphic.GetBitmap(); + } + + // note: aXOBitmap is the member bitmap + aXOBitmap.SetBitmap( aInput ); + aXOBitmap.SetBitmapType(XBITMAP_IMPORT); + + if(aInput.GetSizePixel().Width() == 8 + && aInput.GetSizePixel().Height() == 8 + && aInput.GetColorCount() == 2) + { + aXOBitmap.Bitmap2Array(); + aXOBitmap.SetBitmapType(XBITMAP_8X8); + aXOBitmap.SetPixelSize(aInput.GetSizePixel()); + } + } + + return (bSetName || bSetURL || bSetBitmap); +} + +BOOL XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) +{ + return ((XFillBitmapItem*)p1)->GetBitmapValue().GetGraphicObject().GetUniqueID() == + ((XFillBitmapItem*)p2)->GetBitmapValue().GetGraphicObject().GetUniqueID(); +} + +XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const +{ + if( pModel ) + { + const String aUniqueName = NameOrIndex::CheckNamedItem( this, + XATTR_FILLBITMAP, + &pModel->GetItemPool(), + pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, + XFillBitmapItem::CompareValueFunc, + RID_SVXSTR_BMP21, + pModel->GetBitmapList() ); + + // if the given name is not valid, replace it! + if( aUniqueName != GetName() ) + { + return new XFillBitmapItem( aUniqueName, aXOBitmap ); + } + } + + return (XFillBitmapItem*)this; +} diff --git a/svx/source/xoutdev/xexch.cxx b/svx/source/xoutdev/xexch.cxx new file mode 100644 index 000000000000..eec20c0fe80c --- /dev/null +++ b/svx/source/xoutdev/xexch.cxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- + +#include <sot/formats.hxx> +#include <tools/vcompat.hxx> +#include <svx/xflasit.hxx> +#include <svx/xfillit0.hxx> +#ifndef _SFXIPOOL_HXX +#include <svl/itempool.hxx> +#endif +#include <svl/whiter.hxx> +#ifndef _SFXIPOOL_HXX +#include <svl/itempool.hxx> +#endif +#include <svl/itemset.hxx> +#include <svx/xdef.hxx> +#include "xexch.hxx" + + +TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream ); + + +/************************************************************************* +|* +|* Default-Ctor (Fuer Assign()) +|* +*************************************************************************/ +XFillExchangeData::XFillExchangeData() : + pXFillAttrSetItem( NULL ), + pPool( NULL ) +{ +} + + +/************************************************************************* +|* +|* Ctor +|* +*************************************************************************/ +XFillExchangeData::XFillExchangeData( const XFillAttrSetItem rXFillAttrSetItem ) : + pXFillAttrSetItem( (XFillAttrSetItem*) rXFillAttrSetItem.Clone( rXFillAttrSetItem.GetItemSet().GetPool() ) ), + pPool( rXFillAttrSetItem.GetItemSet().GetPool() ) +{ +} + + +/************************************************************************* +|* +|* Dtor +|* +*************************************************************************/ +XFillExchangeData::~XFillExchangeData() +{ + delete pXFillAttrSetItem; +} + +/************************************************************************* +|* +|* +|* +*************************************************************************/ +ULONG XFillExchangeData::RegisterClipboardFormatName() +{ + return( SOT_FORMATSTR_ID_XFA ); +} + +/****************************************************************************** +|* +|* Binaer-Export (z.Z. ohne Versionsverwaltung, da nicht persistent!) +|* +\******************************************************************************/ + +SvStream& operator<<( SvStream& rOStm, const XFillExchangeData& rData ) +{ + if( rData.pXFillAttrSetItem ) + { + SfxWhichIter aIter( rData.pXFillAttrSetItem->GetItemSet() ); + USHORT nWhich = aIter.FirstWhich(); + const SfxPoolItem* pItem; + sal_uInt32 nItemCount = 0; + sal_Size nFirstPos = rOStm.Tell(); + + rOStm << nItemCount; + + while( nWhich ) + { + if( SFX_ITEM_SET == rData.pXFillAttrSetItem->GetItemSet().GetItemState( nWhich, FALSE, &pItem ) ) + { + VersionCompat aCompat( rOStm, STREAM_WRITE ); + const USHORT nItemVersion2 = pItem->GetVersion( (USHORT) rOStm.GetVersion() ); + + rOStm << nWhich << nItemVersion2; + pItem->Store( rOStm, nItemVersion2 ); + + nItemCount++; + } + + nWhich = aIter.NextWhich(); + } + + const ULONG nLastPos = rOStm.Tell(); + rOStm.Seek( nFirstPos ); + rOStm << nItemCount; + rOStm.Seek( nLastPos ); + } + + return rOStm; +} + + +/****************************************************************************** +|* +|* Binaer-Import (z.Z. ohne Versionsverwaltung, da nicht persistent!) +|* +\******************************************************************************/ + +SvStream& operator>>( SvStream& rIStm, XFillExchangeData& rData ) +{ + DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" ); + + SfxItemSet* pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST ); + SfxPoolItem* pNewItem; + sal_uInt32 nItemCount = 0; + USHORT nWhich, nItemVersion; + + rIStm >> nItemCount; + + if( nItemCount > ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 ) ) + nItemCount = ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 ); + + for( sal_uInt32 i = 0; i < nItemCount; i++ ) + { + VersionCompat aCompat( rIStm, STREAM_READ ); + + rIStm >> nWhich >> nItemVersion; + + if( nWhich ) + { + pNewItem = rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion ); + + if( pNewItem ) + { + pSet->Put( *pNewItem ); + delete pNewItem; + } + } + } + + delete rData.pXFillAttrSetItem; + rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet ); + rData.pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool(); + + return rIStm; +} + +/************************************************************************* +|* +|* XBitmap& XBitmap::operator=( const XBitmap& rXBmp ) +|* +*************************************************************************/ + +XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData ) +{ + delete pXFillAttrSetItem; + + if( rData.pXFillAttrSetItem ) + pXFillAttrSetItem = (XFillAttrSetItem*) rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() ); + else + { + pPool = NULL; + pXFillAttrSetItem = NULL; + } + + return( *this ); +} diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx new file mode 100644 index 000000000000..47dda35245a4 --- /dev/null +++ b/svx/source/xoutdev/xpool.cxx @@ -0,0 +1,235 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <svx/xtable.hxx> +#include "xattr.hxx" +#include <svx/xpool.hxx> +#include <svx/svdattr.hxx> +#include <svx/svxids.hrc> +#include <svl/itemset.hxx> + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +XOutdevItemPool::XOutdevItemPool( + SfxItemPool* _pMaster, + sal_uInt16 nAttrStart, + sal_uInt16 nAttrEnd, + sal_Bool bLoadRefCounts) +: SfxItemPool(String("XOutdevItemPool", gsl_getSystemTextEncoding()), nAttrStart, nAttrEnd, 0L, 0L, bLoadRefCounts) +{ + // prepare some defaults + const XubString aNullStr; + const Bitmap aNullBmp; + const basegfx::B2DPolyPolygon aNullPol; + const Color aNullLineCol(RGB_Color(COL_BLACK)); + const Color aNullFillCol(RGB_Color(COL_DEFAULT_SHAPE_FILLING)); // "Blue 8" + const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY)); + const XDash aNullDash; + const XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE)); + const XHatch aNullHatch(aNullLineCol); + + // get master pointer, evtl. add myself to the end of the pools + if(!_pMaster) + { + _pMaster = this; + } + else + { + SfxItemPool* pParent = _pMaster; + + while(pParent->GetSecondaryPool()) + { + pParent = pParent->GetSecondaryPool(); + } + + pParent->SetSecondaryPool(this); + } + + // prepare PoolDefaults + mppLocalPoolDefaults = new SfxPoolItem*[GetLastWhich() - GetFirstWhich() + 1]; + + mppLocalPoolDefaults[XATTR_LINESTYLE -XATTR_START] = new XLineStyleItem; + mppLocalPoolDefaults[XATTR_LINEDASH -XATTR_START] = new XLineDashItem(this,aNullDash); + mppLocalPoolDefaults[XATTR_LINEWIDTH -XATTR_START] = new XLineWidthItem; + mppLocalPoolDefaults[XATTR_LINECOLOR -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol); + mppLocalPoolDefaults[XATTR_LINESTART -XATTR_START] = new XLineStartItem(this,aNullPol); + mppLocalPoolDefaults[XATTR_LINEEND -XATTR_START] = new XLineEndItem (this,aNullPol); + mppLocalPoolDefaults[XATTR_LINESTARTWIDTH -XATTR_START] = new XLineStartWidthItem; + mppLocalPoolDefaults[XATTR_LINEENDWIDTH -XATTR_START] = new XLineEndWidthItem; + mppLocalPoolDefaults[XATTR_LINESTARTCENTER -XATTR_START] = new XLineStartCenterItem; + mppLocalPoolDefaults[XATTR_LINEENDCENTER -XATTR_START] = new XLineEndCenterItem; + mppLocalPoolDefaults[XATTR_LINETRANSPARENCE -XATTR_START] = new XLineTransparenceItem; + mppLocalPoolDefaults[XATTR_LINEJOINT -XATTR_START] = new XLineJointItem; + mppLocalPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem; + mppLocalPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol); + mppLocalPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(this,aNullGrad); + mppLocalPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (this,aNullHatch); + mppLocalPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (this,aNullBmp); + mppLocalPoolDefaults[XATTR_FILLTRANSPARENCE -XATTR_START] = new XFillTransparenceItem; + mppLocalPoolDefaults[XATTR_GRADIENTSTEPCOUNT -XATTR_START] = new XGradientStepCountItem; + mppLocalPoolDefaults[XATTR_FILLBMP_TILE -XATTR_START] = new XFillBmpTileItem; + mppLocalPoolDefaults[XATTR_FILLBMP_POS -XATTR_START] = new XFillBmpPosItem; + mppLocalPoolDefaults[XATTR_FILLBMP_SIZEX -XATTR_START] = new XFillBmpSizeXItem; + mppLocalPoolDefaults[XATTR_FILLBMP_SIZEY -XATTR_START] = new XFillBmpSizeYItem; + mppLocalPoolDefaults[XATTR_FILLBMP_SIZELOG -XATTR_START] = new XFillBmpSizeLogItem; + mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETX -XATTR_START] = new XFillBmpTileOffsetXItem; + mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETY -XATTR_START] = new XFillBmpTileOffsetYItem; + mppLocalPoolDefaults[XATTR_FILLBMP_STRETCH -XATTR_START] = new XFillBmpStretchItem; + mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETX -XATTR_START] = new XFillBmpPosOffsetXItem; + mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = new XFillBmpPosOffsetYItem; + mppLocalPoolDefaults[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = new XFillFloatTransparenceItem( this, aNullGrad, FALSE ); + mppLocalPoolDefaults[XATTR_SECONDARYFILLCOLOR -XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol); + mppLocalPoolDefaults[XATTR_FILLBACKGROUND -XATTR_START] = new XFillBackgroundItem; + mppLocalPoolDefaults[XATTR_FORMTXTSTYLE -XATTR_START] = new XFormTextStyleItem; + mppLocalPoolDefaults[XATTR_FORMTXTADJUST -XATTR_START] = new XFormTextAdjustItem; + mppLocalPoolDefaults[XATTR_FORMTXTDISTANCE -XATTR_START] = new XFormTextDistanceItem; + mppLocalPoolDefaults[XATTR_FORMTXTSTART -XATTR_START] = new XFormTextStartItem; + mppLocalPoolDefaults[XATTR_FORMTXTMIRROR -XATTR_START] = new XFormTextMirrorItem; + mppLocalPoolDefaults[XATTR_FORMTXTOUTLINE -XATTR_START] = new XFormTextOutlineItem; + mppLocalPoolDefaults[XATTR_FORMTXTSHADOW -XATTR_START] = new XFormTextShadowItem; + mppLocalPoolDefaults[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol); + mppLocalPoolDefaults[XATTR_FORMTXTSHDWXVAL -XATTR_START] = new XFormTextShadowXValItem; + mppLocalPoolDefaults[XATTR_FORMTXTSHDWYVAL -XATTR_START] = new XFormTextShadowYValItem; + mppLocalPoolDefaults[XATTR_FORMTXTSTDFORM -XATTR_START] = new XFormTextStdFormItem; + mppLocalPoolDefaults[XATTR_FORMTXTHIDEFORM -XATTR_START] = new XFormTextHideFormItem; + mppLocalPoolDefaults[XATTR_FORMTXTSHDWTRANSP -XATTR_START] = new XFormTextShadowTranspItem; + + // create SetItems + SfxItemSet* pSet=new SfxItemSet(*_pMaster, XATTR_LINE_FIRST, XATTR_LINE_LAST); + mppLocalPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(pSet); + pSet=new SfxItemSet(*_pMaster, XATTR_FILL_FIRST, XATTR_FILL_LAST); + mppLocalPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(pSet); + + // create ItemInfos + mpLocalItemInfos = new SfxItemInfo[GetLastWhich() - GetFirstWhich() + 1]; + for(sal_uInt16 i(GetFirstWhich()); i <= GetLastWhich(); i++) + { + mpLocalItemInfos[i - XATTR_START]._nSID = 0; + mpLocalItemInfos[i - XATTR_START]._nFlags = SFX_ITEM_POOLABLE; + } + + mpLocalItemInfos[XATTR_LINESTYLE -XATTR_START]._nSID = SID_ATTR_LINE_STYLE; + mpLocalItemInfos[XATTR_LINEDASH -XATTR_START]._nSID = SID_ATTR_LINE_DASH; + mpLocalItemInfos[XATTR_LINEWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH; + mpLocalItemInfos[XATTR_LINECOLOR -XATTR_START]._nSID = SID_ATTR_LINE_COLOR; + mpLocalItemInfos[XATTR_LINESTART -XATTR_START]._nSID = SID_ATTR_LINE_START; + mpLocalItemInfos[XATTR_LINEEND -XATTR_START]._nSID = SID_ATTR_LINE_END; + mpLocalItemInfos[XATTR_LINESTARTWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH; + mpLocalItemInfos[XATTR_LINEENDWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH; + mpLocalItemInfos[XATTR_LINESTARTCENTER -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER; + mpLocalItemInfos[XATTR_LINEENDCENTER -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER; + mpLocalItemInfos[XATTR_FILLSTYLE -XATTR_START]._nSID = SID_ATTR_FILL_STYLE; + mpLocalItemInfos[XATTR_FILLCOLOR -XATTR_START]._nSID = SID_ATTR_FILL_COLOR; + mpLocalItemInfos[XATTR_FILLGRADIENT -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT; + mpLocalItemInfos[XATTR_FILLHATCH -XATTR_START]._nSID = SID_ATTR_FILL_HATCH; + mpLocalItemInfos[XATTR_FILLBITMAP -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP; + mpLocalItemInfos[XATTR_FORMTXTSTYLE -XATTR_START]._nSID = SID_FORMTEXT_STYLE; + mpLocalItemInfos[XATTR_FORMTXTADJUST -XATTR_START]._nSID = SID_FORMTEXT_ADJUST; + mpLocalItemInfos[XATTR_FORMTXTDISTANCE -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE; + mpLocalItemInfos[XATTR_FORMTXTSTART -XATTR_START]._nSID = SID_FORMTEXT_START; + mpLocalItemInfos[XATTR_FORMTXTMIRROR -XATTR_START]._nSID = SID_FORMTEXT_MIRROR; + mpLocalItemInfos[XATTR_FORMTXTOUTLINE -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE; + mpLocalItemInfos[XATTR_FORMTXTSHADOW -XATTR_START]._nSID = SID_FORMTEXT_SHADOW; + mpLocalItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR; + mpLocalItemInfos[XATTR_FORMTXTSHDWXVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL; + mpLocalItemInfos[XATTR_FORMTXTSHDWYVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL; + mpLocalItemInfos[XATTR_FORMTXTSTDFORM -XATTR_START]._nSID = SID_FORMTEXT_STDFORM; + mpLocalItemInfos[XATTR_FORMTXTHIDEFORM -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM; + + // if it's my own creation level, set Defaults and ItemInfos + if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich()) + { + SetDefaults(mppLocalPoolDefaults); + SetItemInfos(mpLocalItemInfos); + } +} + +/************************************************************************* +|* +|* copy ctor, sorgt dafuer, dass die static defaults gecloned werden +|* (Parameter 2 = TRUE) +|* +\************************************************************************/ + +XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool) +: SfxItemPool(rPool, TRUE), + mppLocalPoolDefaults(0L), + mpLocalItemInfos(0L) +{ +} + +/************************************************************************* +|* +|* Clone() +|* +\************************************************************************/ + +SfxItemPool* XOutdevItemPool::Clone() const +{ + return new XOutdevItemPool(*this); +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +XOutdevItemPool::~XOutdevItemPool() +{ + Delete(); + + // remove own static defaults + if(mppLocalPoolDefaults) + { + SfxPoolItem** ppDefaultItem = mppLocalPoolDefaults; + for(sal_uInt16 i(GetLastWhich() - GetFirstWhich() + 1); i; --i, ++ppDefaultItem) + { + if ( *ppDefaultItem ) //Teile schon von abgel. Klasse abgeraeumt! + { + SetRefCount( **ppDefaultItem, 0 ); + delete *ppDefaultItem; + } + } + + delete[] mppLocalPoolDefaults; + } + + if(mpLocalItemInfos) + { + delete[] mpLocalItemInfos; + } +} + +// eof diff --git a/svx/source/xoutdev/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx new file mode 100644 index 000000000000..b4a426b0cf11 --- /dev/null +++ b/svx/source/xoutdev/xtabbtmp.cxx @@ -0,0 +1,294 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#ifndef SVX_LIGHT + +#include <com/sun/star/container/XNameContainer.hpp> +#include "XPropertyTable.hxx" +#include <unotools/ucbstreamhelper.hxx> + +#include "xmlxtexp.hxx" +#include "xmlxtimp.hxx" + +#endif + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <svl/itemset.hxx> +#include <sfx2/docfile.hxx> +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> + +#define GLOBALOVERFLOW + +using namespace com::sun::star; +using namespace rtl; + +sal_Unicode const pszExtBitmap[] = {'s','o','b'}; + +static char const aChckBitmap[] = { 0x04, 0x00, 'S','O','B','L'}; // very old +static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'}; // old +static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'}; // = 5.2 +static char const aChckXML[] = { 'P', 'K', 0x03, 0x04 }; // = 6.0 + +// ------------------- +// class XBitmapTable +// ------------------- + +/************************************************************************* +|* +|* XBitmapTable::XBitmapTable() +|* +*************************************************************************/ + +XBitmapTable::XBitmapTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyTable( rPath, pInPool, nInitSize, nReSize) +{ + pBmpTable = new Table( nInitSize, nReSize ); +} + +/************************************************************************/ + +XBitmapTable::~XBitmapTable() +{ +} + +/************************************************************************/ + +XBitmapEntry* XBitmapTable::Replace(long nIndex, XBitmapEntry* pEntry ) +{ + return (XBitmapEntry*) XPropertyTable::Replace(nIndex, pEntry); +} + +/************************************************************************/ + +XBitmapEntry* XBitmapTable::Remove(long nIndex) +{ + return (XBitmapEntry*) XPropertyTable::Remove(nIndex, 0); +} + +/************************************************************************/ + +XBitmapEntry* XBitmapTable::GetBitmap(long nIndex) const +{ + return (XBitmapEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XBitmapTable::Load() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XBitmapTable::Save() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XBitmapTable::Create() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XBitmapTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XBitmapTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// ------------------ +// class XBitmapList +// ------------------ + +/************************************************************************* +|* +|* XBitmapList::XBitmapList() +|* +*************************************************************************/ + +XBitmapList::XBitmapList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyList( rPath, pInPool, nInitSize, nReSize) +{ + // pBmpList = new List( nInitSize, nReSize ); +} + +/************************************************************************/ + +XBitmapList::~XBitmapList() +{ +} + +/************************************************************************/ + +XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex ) +{ + return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex); +} + +/************************************************************************/ + +XBitmapEntry* XBitmapList::Remove(long nIndex) +{ + return (XBitmapEntry*) XPropertyList::Remove(nIndex, 0); +} + +/************************************************************************/ + +XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const +{ + return (XBitmapEntry*) XPropertyList::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XBitmapList::Load() +{ + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); + } + return( FALSE ); +} + +/************************************************************************/ + +BOOL XBitmapList::Save() +{ + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); +} + +/************************************************************************/ +// Umgestellt am 27.07.95 auf XBitmap + +BOOL XBitmapList::Create() +{ + // Array der Bitmap + //----------------------- + // 00 01 02 03 04 05 06 07 + // 08 09 10 11 12 13 14 15 + // 16 17 18 19 20 21 22 23 + // 24 25 26 27 28 29 30 31 + // 32 33 34 35 36 37 38 39 + // 40 41 42 43 44 45 46 47 + // 48 49 50 51 52 53 54 55 + // 56 57 58 59 60 61 62 63 + + String aStr( SVX_RES( RID_SVXSTR_BITMAP ) ); + Color aColWhite( RGB_Color( COL_WHITE ) ); + xub_StrLen nLen; + USHORT aArray[64]; + + memset( aArray, 0, sizeof( aArray ) ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert( new XBitmapEntry( XOBitmap( aArray, aColWhite, aColWhite ), aStr ) ); + + aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1; + aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1; + aStr.SetChar(nLen, sal_Unicode('2')); + Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_BLACK ), aColWhite ), aStr ) ); + + aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1; + aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1; + aStr.SetChar(nLen, sal_Unicode('3')); + Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTRED ), aColWhite ), aStr ) ); + + aArray[24] = 1; aArray[25] = 1; aArray[26] = 1; + aArray[29] = 1; aArray[30] = 1; aArray[31] = 1; + aStr.SetChar(nLen, sal_Unicode('4')); + Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTBLUE ), aColWhite ), aStr ) ); + + return( TRUE ); +} + +/************************************************************************/ + +BOOL XBitmapList::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XBitmapList::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// eof diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx new file mode 100644 index 000000000000..853d397010b7 --- /dev/null +++ b/svx/source/xoutdev/xtabcolr.cxx @@ -0,0 +1,548 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#ifndef SVX_LIGHT + +#include <com/sun/star/container/XNameContainer.hpp> +#include "XPropertyTable.hxx" +#include <unotools/ucbstreamhelper.hxx> + +#include <unotools/pathoptions.hxx> + +#include "xmlxtexp.hxx" +#include "xmlxtimp.hxx" + +#endif + +#include <sfx2/docfile.hxx> +#include <tools/urlobj.hxx> +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> + +#define GLOBALOVERFLOW + +using namespace com::sun::star; +using namespace rtl; + +sal_Unicode const pszExtColor[] = {'s','o','c'}; + +static char const aChckColor[] = { 0x04, 0x00, 'S','O','C','L'}; // < 5.2 +static char const aChckColor0[] = { 0x04, 0x00, 'S','O','C','0'}; // = 5.2 +static char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0 + +// ------------------ +// class XColorTable +// ------------------ + +static XColorTable* pTable=0; + +/************************************************************************* +|* +|* XColorTable::XColorTable() +|* +*************************************************************************/ + +XColorTable::XColorTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyTable( rPath, pInPool, nInitSize, nReSize) +{ + // ColorTable braucht keine eigene BmpTable + // pBmpTable = new Table( nInitSize, nReSize ); +} + +/************************************************************************/ + +XColorTable::~XColorTable() +{ +} + +XColorTable* XColorTable::GetStdColorTable() +{ + if ( !pTable ) + pTable = new XColorTable( SvtPathOptions().GetPalettePath() ); + return pTable; +} + +/************************************************************************/ + +XColorEntry* XColorTable::Replace(long nIndex, XColorEntry* pEntry ) +{ + return (XColorEntry*) XPropertyTable::Replace(nIndex, pEntry); +} + +/************************************************************************/ + +XColorEntry* XColorTable::Remove(long nIndex) +{ + return (XColorEntry*) XPropertyTable::Remove(nIndex, 0); +} + +/************************************************************************/ + +XColorEntry* XColorTable::GetColor(long nIndex) const +{ + return (XColorEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XColorTable::Load() +{ + if( bTableDirty ) + { + bTableDirty = FALSE; + + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtColor, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXColorTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); + } + return( FALSE ); +} + +/************************************************************************/ + +BOOL XColorTable::Save() +{ + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtColor, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXColorTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); +} + +/************************************************************************/ + +BOOL XColorTable::Create() +{ + XubString aStr; + xub_StrLen nLen; + ResMgr& rRes = DIALOG_MGR(); + + static USHORT __READONLY_DATA aResId[] = + { + RID_SVXSTR_BLACK, + RID_SVXSTR_BLUE, + RID_SVXSTR_GREEN, + RID_SVXSTR_CYAN, + RID_SVXSTR_RED, + RID_SVXSTR_MAGENTA, + RID_SVXSTR_BROWN, + RID_SVXSTR_GREY, + RID_SVXSTR_LIGHTGREY, + RID_SVXSTR_LIGHTBLUE, + RID_SVXSTR_LIGHTGREEN, + RID_SVXSTR_LIGHTCYAN, + RID_SVXSTR_LIGHTRED, + RID_SVXSTR_LIGHTMAGENTA, + RID_SVXSTR_YELLOW, + RID_SVXSTR_WHITE + }; + + // MT: COL_XXX ist in VCL kein enum mehr!!! + // COL_WHITE ist seeeehr gross! ( => Zugriff ueber das obige Array hinweg ) + // Mit der unteren Schleife gibt es keinen Absturtz, aber es ist + // alles schwarz, weil alles kleine Werte. + // Ausserdem ist die ganze Vorgehensweise laut MM sehr unperformant + // => lieber gleich Stringlisten laden. + + // BM: ifndef VCL part removed (deprecated) + + static ColorData __READONLY_DATA aColTab[] = + { + COL_BLACK, + COL_BLUE, + COL_GREEN, + COL_CYAN, + COL_RED, + COL_MAGENTA, + COL_BROWN, + COL_GRAY, + COL_LIGHTGRAY, + COL_LIGHTBLUE, + COL_LIGHTGREEN, + COL_LIGHTCYAN, + COL_LIGHTRED, + COL_LIGHTMAGENTA, + COL_YELLOW, + COL_WHITE + }; + + for( USHORT n = 0; n < 16; ++n ) + { + Insert( n, new XColorEntry( Color( aColTab[n] ), + String( ResId( aResId[ n ], rRes )) ) ); + } + + aStr = SVX_RESSTR( RID_SVXSTR_GREY ); + aStr.AppendAscii(" 80%"); + nLen = aStr.Len() - 3; + Insert(16, new XColorEntry( Color( 51, 51, 51 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(17, new XColorEntry( Color( 76, 76, 76 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(18, new XColorEntry( Color(102,102,102 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(19, new XColorEntry( Color(153,153,153 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(20, new XColorEntry( Color(179,179,179 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(21, new XColorEntry( Color(204,204,204 ), aStr ) ); + // BM: new 15% + aStr.SetChar(nLen, sal_Unicode('1')); + aStr.SetChar(nLen + 1, sal_Unicode('5')); + Insert(22, new XColorEntry( Color(217,217,217 ), aStr ) ); + aStr.SetChar(nLen + 1, sal_Unicode('0')); + Insert(23, new XColorEntry( Color(230,230,230 ), aStr ) ); + Insert(24, new XColorEntry( Color(230,230,255 ), SVX_RESSTR( RID_SVXSTR_BLUEGREY ) ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_RED ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(25, new XColorEntry( Color(255, 51,102 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(26, new XColorEntry( Color(220, 35, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(27, new XColorEntry( Color(184, 71, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(28, new XColorEntry( Color(255, 51, 51 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(29, new XColorEntry( Color(235, 97, 61 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(30, new XColorEntry( Color(184, 71, 71 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(31, new XColorEntry( Color(184, 0, 71 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert(32, new XColorEntry( Color(153, 40, 76 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_MAGENTA ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(33, new XColorEntry( Color(148, 0,107 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(34, new XColorEntry( Color(148, 71,107 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(35, new XColorEntry( Color(148, 71,148 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(36, new XColorEntry( Color(153,102,204 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(37, new XColorEntry( Color(107, 71,148 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(38, new XColorEntry( Color(107, 35,148 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(39, new XColorEntry( Color(107, 0,148 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert(40, new XColorEntry( Color( 94, 17,166 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_BLUE ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(41, new XColorEntry( Color( 40, 0,153 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(42, new XColorEntry( Color( 71, 0,184 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(43, new XColorEntry( Color( 35, 0,220 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(44, new XColorEntry( Color( 35, 35,220 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(45, new XColorEntry( Color( 0, 71,255 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(46, new XColorEntry( Color( 0,153,255 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(47, new XColorEntry( Color( 0,184,255 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert(48, new XColorEntry( Color(153,204,255 ), aStr ) ); + //Insert(48, new XColorEntry( Color( 46,215,255 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_CYAN ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(49, new XColorEntry( Color( 0,220,255 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(50, new XColorEntry( Color( 0,204,204 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(51, new XColorEntry( Color( 35,184,220 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(52, new XColorEntry( Color( 71,184,184 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(53, new XColorEntry( Color( 51,163,163 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(54, new XColorEntry( Color( 25,138,138 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(55, new XColorEntry( Color( 0,107,107 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert(56, new XColorEntry( Color( 0, 74, 74 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_GREEN ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(57, new XColorEntry( Color( 53, 94, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(58, new XColorEntry( Color( 92,133, 38 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(59, new XColorEntry( Color(125,166, 71 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(60, new XColorEntry( Color(148,189, 94 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(61, new XColorEntry( Color( 0,174, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(62, new XColorEntry( Color( 51,204,102 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(63, new XColorEntry( Color( 61,235, 61 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert(64, new XColorEntry( Color( 35,255, 35 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_YELLOW ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(65, new XColorEntry( Color(230,255, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(66, new XColorEntry( Color(255,255,153 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(67, new XColorEntry( Color(255,255,102 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(68, new XColorEntry( Color(230,230, 76 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(69, new XColorEntry( Color(204,204, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(70, new XColorEntry( Color(179,179, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert(71, new XColorEntry( Color(128,128, 25 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert(72, new XColorEntry( Color(102,102, 0 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_BROWN ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(73, new XColorEntry( Color( 76, 25, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(74, new XColorEntry( Color(102, 51, 0 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(75, new XColorEntry( Color(128, 76, 25 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(76, new XColorEntry( Color(153,102, 51 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_ORANGE ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(77, new XColorEntry( Color(204,102, 51 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(78, new XColorEntry( Color(255,102, 51 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(79, new XColorEntry( Color(255,153,102 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(80, new XColorEntry( Color(255,204,153 ), aStr ) ); + + // new chart colors + aStr = SVX_RESSTR( RID_SVXSTR_VIOLET ); + Insert( 81, new XColorEntry( Color( 0x99, 0x99, 0xff ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_BORDEAUX ); + Insert( 82, new XColorEntry( Color( 0x99, 0x33, 0x66 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_PALE_YELLOW ); + Insert( 83, new XColorEntry( Color( 0xff, 0xff, 0xcc ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_PALE_GREEN ); + Insert( 84, new XColorEntry( Color( 0xcc, 0xff, 0xff ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_DKVIOLET ); + Insert( 85, new XColorEntry( Color( 0x66, 0x00, 0x66 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_SALMON ); + Insert( 86, new XColorEntry( Color( 0xff, 0x80, 0x80 ), aStr ) ); + + aStr = SVX_RESSTR( RID_SVXSTR_SEABLUE ); + Insert( 87, new XColorEntry( Color( 0x00, 0x66, 0xcc ), aStr ) ); + + // Sun colors + aStr = SVX_RESSTR( RID_SVXSTR_COLOR_SUN ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert( 88, new XColorEntry( Color( 0x33, 0x33, 0x66 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert( 89, new XColorEntry( Color( 0x66, 0x66, 0x99 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert( 90, new XColorEntry( Color( 0x99, 0x99, 0xcc ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert( 91, new XColorEntry( Color( 0xcc, 0xcc, 0xff ), aStr ) ); + + // Chart default colors + aStr = SVX_RESSTR( RID_SVXSTR_COLOR_CHART ); + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert( 92, new XColorEntry( Color( 0x00, 0x45, 0x86 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert( 93, new XColorEntry( Color( 0xff, 0x42, 0x0e ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert( 94, new XColorEntry( Color( 0xff, 0xd3, 0x20 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert( 95, new XColorEntry( Color( 0x57, 0x9d, 0x1c ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert( 96, new XColorEntry( Color( 0x7e, 0x00, 0x21 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert( 97, new XColorEntry( Color( 0x83, 0xca, 0xff ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('7')); + Insert( 98, new XColorEntry( Color( 0x31, 0x40, 0x04 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('8')); + Insert( 99, new XColorEntry( Color( 0xae, 0xcf, 0x00 ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('9')); + Insert( 100, new XColorEntry( Color( 0x4b, 0x1f, 0x6f ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('1')); + aStr.AppendAscii("0"); + nLen = aStr.Len() - 1; + Insert( 101, new XColorEntry( Color( 0xff, 0x95, 0x0e ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('1')); + Insert( 102, new XColorEntry( Color( 0xc5, 0x00, 0x0b ), aStr ) ); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert( 103, new XColorEntry( Color( 0x00, 0x84, 0xd1 ), aStr ) ); + + return( Count() == 104 ); +} + +/************************************************************************/ + +BOOL XColorTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XColorTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// -------------------- +// class XColorList +// -------------------- + +/************************************************************************* +|* +|* XColorList::XColorList() +|* +*************************************************************************/ + +XColorList::XColorList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyList( rPath, pInPool, nInitSize, nReSize) +{ + // pBmpList = new List( nInitSize, nReSize ); +} + +/************************************************************************/ + +XColorList::~XColorList() +{ +} + +/************************************************************************/ + +XColorEntry* XColorList::Replace(XColorEntry* pEntry, long nIndex ) +{ + return (XColorEntry*) XPropertyList::Replace(pEntry, nIndex); +} + +/************************************************************************/ + +XColorEntry* XColorList::Remove(long nIndex) +{ + return (XColorEntry*) XPropertyList::Remove(nIndex, 0); +} + +/************************************************************************/ + +XColorEntry* XColorList::GetColor(long nIndex) const +{ + return (XColorEntry*) XPropertyList::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XColorList::Load() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XColorList::Save() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XColorList::Create() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XColorList::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XColorList::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// eof diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx new file mode 100644 index 000000000000..88cec422f49a --- /dev/null +++ b/svx/source/xoutdev/xtabdash.cxx @@ -0,0 +1,378 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- + +#ifndef SVX_LIGHT + +#include <com/sun/star/container/XNameContainer.hpp> +#include "XPropertyTable.hxx" +#include <unotools/ucbstreamhelper.hxx> + +#include "xmlxtexp.hxx" +#include "xmlxtimp.hxx" + +#endif +#include <vcl/svapp.hxx> + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <vcl/window.hxx> +#include <svl/itemset.hxx> +#include <sfx2/docfile.hxx> +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xlnwtit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xflclit.hxx> + +#include <svx/svdorect.hxx> +#include <svx/svdopath.hxx> +#include <svx/svdmodel.hxx> +#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> + +using namespace com::sun::star; +using namespace rtl; + +#define GLOBALOVERFLOW + +sal_Unicode const pszExtDash[] = {'s','o','d'}; +char const aChckDash[] = { 0x04, 0x00, 'S','O','D','L'}; // < 5.2 +char const aChckDash0[] = { 0x04, 0x00, 'S','O','D','0'}; // = 5.2 +char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0 + +// ----------------- +// class XDashTable +// ----------------- + +/************************************************************************* +|* +|* XDashTable::XDashTable() +|* +*************************************************************************/ + +XDashTable::XDashTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyTable( rPath, pInPool, nInitSize, nReSize) +{ + pBmpTable = new Table( nInitSize, nReSize ); +} + +/************************************************************************/ + +XDashTable::~XDashTable() +{ +} + +/************************************************************************/ + +XDashEntry* XDashTable::Replace(long nIndex, XDashEntry* pEntry ) +{ + return (XDashEntry*) XPropertyTable::Replace(nIndex, pEntry); +} + +/************************************************************************/ + +XDashEntry* XDashTable::Remove(long nIndex) +{ + return (XDashEntry*) XPropertyTable::Remove(nIndex, 0); +} + +/************************************************************************/ + +XDashEntry* XDashTable::GetDash(long nIndex) const +{ + return (XDashEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XDashTable::Load() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XDashTable::Save() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XDashTable::Create() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XDashTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XDashTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// ---------------- +// class XDashList +// ---------------- + +class impXDashList +{ +private: + VirtualDevice* mpVirtualDevice; + SdrModel* mpSdrModel; + SdrObject* mpBackgroundObject; + SdrObject* mpLineObject; + +public: + impXDashList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pL) + : mpVirtualDevice(pV), + mpSdrModel(pM), + mpBackgroundObject(pB), + mpLineObject(pL) + {} + + ~impXDashList() + { + delete mpVirtualDevice; + SdrObject::Free(mpBackgroundObject); + SdrObject::Free(mpLineObject); + delete mpSdrModel; + } + + VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; } + SdrObject* getBackgroundObject() const { return mpBackgroundObject; } + SdrObject* getLineObject() const { return mpLineObject; } +}; + +void XDashList::impCreate() +{ + if(!mpData) + { + const Point aZero(0, 0); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + VirtualDevice* pVirDev = new VirtualDevice; + OSL_ENSURE(0 != pVirDev, "XDashList: no VirtualDevice created!" ); + pVirDev->SetMapMode(MAP_100TH_MM); + const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH * 2, BITMAP_HEIGHT))); + pVirDev->SetOutputSize(aSize); + pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode() + ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT + : DRAWMODE_DEFAULT); + + SdrModel* pSdrModel = new SdrModel(); + OSL_ENSURE(0 != pSdrModel, "XDashList: no SdrModel created!" ); + pSdrModel->GetItemPool().FreezeIdRanges(); + + const Rectangle aBackgroundSize(aZero, aSize); + SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize); + OSL_ENSURE(0 != pBackgroundObject, "XDashList: no BackgroundObject created!" ); + pBackgroundObject->SetModel(pSdrModel); + pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID)); + pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); + pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor())); + + const basegfx::B2DPoint aStart(0, aSize.Height() / 2); + const basegfx::B2DPoint aEnd(aSize.Width(), aSize.Height() / 2); + basegfx::B2DPolygon aPolygon; + aPolygon.append(aStart); + aPolygon.append(aEnd); + SdrObject* pLineObject = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygon)); + OSL_ENSURE(0 != pLineObject, "XDashList: no LineObject created!" ); + pLineObject->SetModel(pSdrModel); + pLineObject->SetMergedItem(XLineStyleItem(XLINE_DASH)); + pLineObject->SetMergedItem(XLineColorItem(String(), rStyleSettings.GetFieldTextColor())); + pLineObject->SetMergedItem(XLineWidthItem(30)); + + mpData = new impXDashList(pVirDev, pSdrModel, pBackgroundObject, pLineObject); + OSL_ENSURE(0 != mpData, "XDashList: data creation went wrong!" ); + } +} + +void XDashList::impDestroy() +{ + if(mpData) + { + delete mpData; + mpData = 0; + } +} + +XDashList::XDashList(const String& rPath, XOutdevItemPool* pInPool, sal_uInt16 nInitSize, sal_uInt16 nReSize) +: XPropertyList(rPath, pInPool, nInitSize, nReSize), + mpData(0) +{ + pBmpList = new List(nInitSize, nReSize); +} + +XDashList::~XDashList() +{ + impDestroy(); +} + +XDashEntry* XDashList::Replace(XDashEntry* pEntry, long nIndex ) +{ + return (XDashEntry*) XPropertyList::Replace(pEntry, nIndex); +} + +XDashEntry* XDashList::Remove(long nIndex) +{ + return (XDashEntry*) XPropertyList::Remove(nIndex, 0); +} + +XDashEntry* XDashList::GetDash(long nIndex) const +{ + return (XDashEntry*) XPropertyList::Get(nIndex, 0); +} + +BOOL XDashList::Load() +{ + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtDash, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXDashTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); + } + return( FALSE ); +} + +BOOL XDashList::Save() +{ + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtDash, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXDashTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); +} + +BOOL XDashList::Create() +{ + XubString aStr( SVX_RES( RID_SVXSTR_LINESTYLE ) ); + xub_StrLen nLen; + + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(new XDashEntry(XDash(XDASH_RECT,1, 50,1, 50, 50),aStr)); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(new XDashEntry(XDash(XDASH_RECT,1,500,1,500,500),aStr)); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(new XDashEntry(XDash(XDASH_RECT,2, 50,3,250,120),aStr)); + + return( TRUE ); +} + +BOOL XDashList::CreateBitmapsForUI() +{ + impCreate(); + + for( long i = 0; i < Count(); i++) + { + Bitmap* pBmp = CreateBitmapForUI( i, FALSE ); + DBG_ASSERT( pBmp, "XDashList: Bitmap(UI) konnte nicht erzeugt werden!" ); + + if( pBmp ) + pBmpList->Insert( pBmp, i ); + } + + impDestroy(); + + return( TRUE ); +} + +Bitmap* XDashList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + impCreate(); + VirtualDevice* pVD = mpData->getVirtualDevice(); + SdrObject* pLine = mpData->getLineObject(); + + pLine->SetMergedItem(XLineStyleItem(XLINE_DASH)); + pLine->SetMergedItem(XLineDashItem(String(), GetDash(nIndex)->GetDash())); + + sdr::contact::SdrObjectVector aObjectVector; + aObjectVector.push_back(mpData->getBackgroundObject()); + aObjectVector.push_back(pLine); + sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0); + sdr::contact::DisplayInfo aDisplayInfo; + + aPainter.ProcessDisplay(aDisplayInfo); + + const Point aZero(0, 0); + Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize())); + + if(bDelete) + { + impDestroy(); + } + + return pBitmap; +} + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx new file mode 100644 index 000000000000..2a64d4b8855a --- /dev/null +++ b/svx/source/xoutdev/xtabgrdt.cxx @@ -0,0 +1,372 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- + +#ifndef SVX_LIGHT + +#include <com/sun/star/container/XNameContainer.hpp> +#include "XPropertyTable.hxx" +#include <unotools/ucbstreamhelper.hxx> + +#include "xmlxtexp.hxx" +#include "xmlxtimp.hxx" + +#endif + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <svl/itemset.hxx> +#include <sfx2/docfile.hxx> +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xflgrit.hxx> + +#include <svx/svdorect.hxx> +#include <svx/svdmodel.hxx> +#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <vcl/svapp.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xgrscit.hxx> + +#define GLOBALOVERFLOW + +using namespace com::sun::star; +using namespace rtl; + +sal_Unicode const pszExtGradient[] = {'s','o','g'}; + +char const aChckGradient[] = { 0x04, 0x00, 'S','O','G','L'}; // < 5.2 +char const aChckGradient0[] = { 0x04, 0x00, 'S','O','G','0'}; // = 5.2 +char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0 + +// --------------------- +// class XGradientTable +// --------------------- + +/************************************************************************* +|* +|* XGradientTable::XGradientTable() +|* +*************************************************************************/ + +XGradientTable::XGradientTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyTable( rPath, pInPool, nInitSize, nReSize) +{ + pBmpTable = new Table( nInitSize, nReSize ); +} + +/************************************************************************/ + +XGradientTable::~XGradientTable() +{ +} + +/************************************************************************/ + +XGradientEntry* XGradientTable::Replace(long nIndex, XGradientEntry* pEntry ) +{ + return (XGradientEntry*) XPropertyTable::Replace(nIndex, pEntry); +} + +/************************************************************************/ + +XGradientEntry* XGradientTable::Remove(long nIndex) +{ + return (XGradientEntry*) XPropertyTable::Remove(nIndex, 0); +} + +/************************************************************************/ + +XGradientEntry* XGradientTable::GetGradient(long nIndex) const +{ + return (XGradientEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XGradientTable::Load() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XGradientTable::Save() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XGradientTable::Create() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XGradientTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XGradientTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// -------------------- +// class XGradientList +// -------------------- + +class impXGradientList +{ +private: + VirtualDevice* mpVirtualDevice; + SdrModel* mpSdrModel; + SdrObject* mpBackgroundObject; + +public: + impXGradientList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB) + : mpVirtualDevice(pV), + mpSdrModel(pM), + mpBackgroundObject(pB) + {} + + ~impXGradientList() + { + delete mpVirtualDevice; + SdrObject::Free(mpBackgroundObject); + delete mpSdrModel; + } + + VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; } + SdrObject* getBackgroundObject() const { return mpBackgroundObject; } +}; + +void XGradientList::impCreate() +{ + if(!mpData) + { + const Point aZero(0, 0); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + VirtualDevice* pVirDev = new VirtualDevice; + OSL_ENSURE(0 != pVirDev, "XGradientList: no VirtualDevice created!" ); + pVirDev->SetMapMode(MAP_100TH_MM); + const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT))); + pVirDev->SetOutputSize(aSize); + pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode() + ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT + : DRAWMODE_DEFAULT); + + SdrModel* pSdrModel = new SdrModel(); + OSL_ENSURE(0 != pSdrModel, "XGradientList: no SdrModel created!" ); + pSdrModel->GetItemPool().FreezeIdRanges(); + + const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1))); + const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight())); + SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize); + OSL_ENSURE(0 != pBackgroundObject, "XGradientList: no BackgroundObject created!" ); + pBackgroundObject->SetModel(pSdrModel); + pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_GRADIENT)); + pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID)); + pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK))); + pBackgroundObject->SetMergedItem(XGradientStepCountItem(sal_uInt16((BITMAP_WIDTH + BITMAP_HEIGHT) / 3))); + + mpData = new impXGradientList(pVirDev, pSdrModel, pBackgroundObject); + OSL_ENSURE(0 != mpData, "XGradientList: data creation went wrong!" ); + } +} + +void XGradientList::impDestroy() +{ + if(mpData) + { + delete mpData; + mpData = 0; + } +} + +XGradientList::XGradientList( const String& rPath, XOutdevItemPool* pInPool, sal_uInt16 nInitSize, sal_uInt16 nReSize) +: XPropertyList(rPath, pInPool, nInitSize, nReSize), + mpData(0) +{ + pBmpList = new List(nInitSize, nReSize); +} + +XGradientList::~XGradientList() +{ + if(mpData) + { + delete mpData; + mpData = 0; + } +} + +XGradientEntry* XGradientList::Replace(XGradientEntry* pEntry, long nIndex ) +{ + return( (XGradientEntry*) XPropertyList::Replace( pEntry, nIndex ) ); +} + +XGradientEntry* XGradientList::Remove(long nIndex) +{ + return( (XGradientEntry*) XPropertyList::Remove( nIndex, 0 ) ); +} + +XGradientEntry* XGradientList::GetGradient(long nIndex) const +{ + return( (XGradientEntry*) XPropertyList::Get( nIndex, 0 ) ); +} + +BOOL XGradientList::Load() +{ + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtGradient, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXGradientTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); + + } + return( FALSE ); +} + +BOOL XGradientList::Save() +{ + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtGradient, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXGradientTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); +} + +BOOL XGradientList::Create() +{ + XubString aStr( SVX_RES( RID_SVXSTR_GRADIENT ) ); + xub_StrLen nLen; + + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLACK ),RGB_Color(COL_WHITE ),XGRAD_LINEAR , 0,10,10, 0,100,100),aStr)); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLUE ),RGB_Color(COL_RED ),XGRAD_AXIAL , 300,20,20,10,100,100),aStr)); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(new XGradientEntry(XGradient(RGB_Color(COL_RED ),RGB_Color(COL_YELLOW ),XGRAD_RADIAL , 600,30,30,20,100,100),aStr)); + aStr.SetChar(nLen, sal_Unicode('4')); + Insert(new XGradientEntry(XGradient(RGB_Color(COL_YELLOW ),RGB_Color(COL_GREEN ),XGRAD_ELLIPTICAL, 900,40,40,30,100,100),aStr)); + aStr.SetChar(nLen, sal_Unicode('5')); + Insert(new XGradientEntry(XGradient(RGB_Color(COL_GREEN ),RGB_Color(COL_MAGENTA),XGRAD_SQUARE , 1200,50,50,40,100,100),aStr)); + aStr.SetChar(nLen, sal_Unicode('6')); + Insert(new XGradientEntry(XGradient(RGB_Color(COL_MAGENTA),RGB_Color(COL_YELLOW ),XGRAD_RECT , 1900,60,60,50,100,100),aStr)); + + return( TRUE ); +} + +BOOL XGradientList::CreateBitmapsForUI() +{ + impCreate(); + + for( long i = 0; i < Count(); i++) + { + Bitmap* pBmp = CreateBitmapForUI( i, FALSE ); + DBG_ASSERT( pBmp, "XGradientList: Bitmap(UI) konnte nicht erzeugt werden!" ); + + if( pBmp ) + pBmpList->Insert( pBmp, i ); + } + + impDestroy(); + + return( FALSE ); +} + +Bitmap* XGradientList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + impCreate(); + VirtualDevice* pVD = mpData->getVirtualDevice(); + SdrObject* pBackgroundObject = mpData->getBackgroundObject(); + + const SfxItemSet& rItemSet = pBackgroundObject->GetMergedItemSet(); + pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_GRADIENT)); + pBackgroundObject->SetMergedItem(XFillGradientItem(rItemSet.GetPool(), GetGradient(nIndex)->GetGradient())); + + sdr::contact::SdrObjectVector aObjectVector; + aObjectVector.push_back(pBackgroundObject); + sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0); + sdr::contact::DisplayInfo aDisplayInfo; + + aPainter.ProcessDisplay(aDisplayInfo); + + const Point aZero(0, 0); + Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize())); + + if(bDelete) + { + impDestroy(); + } + + return pBitmap; +} + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx new file mode 100644 index 000000000000..703b2db16b1f --- /dev/null +++ b/svx/source/xoutdev/xtabhtch.cxx @@ -0,0 +1,374 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- + +#ifndef SVX_LIGHT + +#include <com/sun/star/container/XNameContainer.hpp> +#include "XPropertyTable.hxx" +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/svapp.hxx> + +#include "xmlxtexp.hxx" +#include "xmlxtimp.hxx" + +#endif + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <svl/itemset.hxx> +#include <sfx2/docfile.hxx> +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> +#include "dlgutil.hxx" +#include <svx/xflhtit.hxx> +#include <svx/xflclit.hxx> +#include <svx/xfillit0.hxx> + +#include <svx/svdorect.hxx> +#include <svx/svdmodel.hxx> +#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <svx/xlnclit.hxx> + +using namespace ::com::sun::star; +using namespace ::rtl; + +sal_Unicode const pszExtHatch[] = {'s','o','h'}; + +char const aChckHatch[] = { 0x04, 0x00, 'S','O','H','L'}; // < 5.2 +char const aChckHatch0[] = { 0x04, 0x00, 'S','O','H','0'}; // = 5.2 +char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0 + +// ------------------ +// class XHatchTable +// ------------------ + +/************************************************************************* +|* +|* XHatchTable::XHatchTable() +|* +*************************************************************************/ + +XHatchTable::XHatchTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyTable( rPath, pInPool, nInitSize, nReSize) +{ + pBmpTable = new Table( nInitSize, nReSize ); +} + +/************************************************************************/ + +XHatchTable::~XHatchTable() +{ +} + +/************************************************************************/ + +XHatchEntry* XHatchTable::Replace(long nIndex, XHatchEntry* pEntry ) +{ + return (XHatchEntry*) XPropertyTable::Replace(nIndex, pEntry); +} + +/************************************************************************/ + +XHatchEntry* XHatchTable::Remove(long nIndex) +{ + return (XHatchEntry*) XPropertyTable::Remove(nIndex, 0); +} + +/************************************************************************/ + +XHatchEntry* XHatchTable::GetHatch(long nIndex) const +{ + return (XHatchEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XHatchTable::Load() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XHatchTable::Save() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XHatchTable::Create() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XHatchTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XHatchTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +// ----------------- +// class XHatchList +// ----------------- + +class impXHatchList +{ +private: + VirtualDevice* mpVirtualDevice; + SdrModel* mpSdrModel; + SdrObject* mpBackgroundObject; + SdrObject* mpHatchObject; + +public: + impXHatchList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pH) + : mpVirtualDevice(pV), + mpSdrModel(pM), + mpBackgroundObject(pB), + mpHatchObject(pH) + {} + + ~impXHatchList() + { + delete mpVirtualDevice; + SdrObject::Free(mpBackgroundObject); + SdrObject::Free(mpHatchObject); + delete mpSdrModel; + } + + VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; } + SdrObject* getBackgroundObject() const { return mpBackgroundObject; } + SdrObject* getHatchObject() const { return mpHatchObject; } +}; + +void XHatchList::impCreate() +{ + if(!mpData) + { + const Point aZero(0, 0); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + VirtualDevice* pVirDev = new VirtualDevice; + OSL_ENSURE(0 != pVirDev, "XDashList: no VirtualDevice created!" ); + pVirDev->SetMapMode(MAP_100TH_MM); + const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT))); + pVirDev->SetOutputSize(aSize); + pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode() + ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT + : DRAWMODE_DEFAULT); + + SdrModel* pSdrModel = new SdrModel(); + OSL_ENSURE(0 != pSdrModel, "XDashList: no SdrModel created!" ); + pSdrModel->GetItemPool().FreezeIdRanges(); + + const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1))); + const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight())); + SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize); + OSL_ENSURE(0 != pBackgroundObject, "XDashList: no BackgroundObject created!" ); + pBackgroundObject->SetModel(pSdrModel); + pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID)); + pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor())); + pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID)); + pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK))); + + SdrObject* pHatchObject = new SdrRectObj(aBackgroundSize); + OSL_ENSURE(0 != pHatchObject, "XDashList: no HatchObject created!" ); + pHatchObject->SetModel(pSdrModel); + pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH)); + pHatchObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); + + mpData = new impXHatchList(pVirDev, pSdrModel, pBackgroundObject, pHatchObject); + OSL_ENSURE(0 != mpData, "XDashList: data creation went wrong!" ); + } +} + +void XHatchList::impDestroy() +{ + if(mpData) + { + delete mpData; + mpData = 0; + } +} + +XHatchList::XHatchList(const String& rPath, XOutdevItemPool* pInPool, sal_uInt16 nInitSize, sal_uInt16 nReSize) +: XPropertyList(rPath, pInPool, nInitSize, nReSize), + mpData(0) +{ + pBmpList = new List(nInitSize, nReSize); +} + +XHatchList::~XHatchList() +{ + if(mpData) + { + delete mpData; + mpData = 0; + } +} + +XHatchEntry* XHatchList::Replace(XHatchEntry* pEntry, long nIndex ) +{ + return (XHatchEntry*) XPropertyList::Replace(pEntry, nIndex); +} + +XHatchEntry* XHatchList::Remove(long nIndex) +{ + return (XHatchEntry*) XPropertyList::Remove(nIndex, 0); +} + +XHatchEntry* XHatchList::GetHatch(long nIndex) const +{ + return (XHatchEntry*) XPropertyList::Get(nIndex, 0); +} + +BOOL XHatchList::Load() +{ + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtHatch, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); + } + return( FALSE ); +} + +BOOL XHatchList::Save() +{ + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtHatch, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); +} + +BOOL XHatchList::Create() +{ + XubString aStr( SVX_RES( RID_SVXSTR_HATCH ) ); + xub_StrLen nLen; + + aStr.AppendAscii(" 1"); + nLen = aStr.Len() - 1; + Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK),XHATCH_SINGLE,100, 0),aStr)); + aStr.SetChar(nLen, sal_Unicode('2')); + Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED ),XHATCH_DOUBLE, 80,450),aStr)); + aStr.SetChar(nLen, sal_Unicode('3')); + Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE ),XHATCH_TRIPLE,120, 0),aStr)); + + return( TRUE ); +} + +BOOL XHatchList::CreateBitmapsForUI() +{ + impCreate(); + + for( long i = 0; i < Count(); i++) + { + Bitmap* pBmp = CreateBitmapForUI( i, FALSE ); + DBG_ASSERT( pBmp, "XHatchList: Bitmap(UI) konnte nicht erzeugt werden!" ); + + if( pBmp ) + pBmpList->Insert( pBmp, i ); + } + + impDestroy(); + + return( TRUE ); +} + +Bitmap* XHatchList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + impCreate(); + VirtualDevice* pVD = mpData->getVirtualDevice(); + SdrObject* pHatchObject = mpData->getHatchObject(); + + pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH)); + pHatchObject->SetMergedItem(XFillHatchItem(String(), GetHatch(nIndex)->GetHatch())); + + sdr::contact::SdrObjectVector aObjectVector; + aObjectVector.push_back(mpData->getBackgroundObject()); + aObjectVector.push_back(pHatchObject); + sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0); + sdr::contact::DisplayInfo aDisplayInfo; + + aPainter.ProcessDisplay(aDisplayInfo); + + const Point aZero(0, 0); + Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize())); + + if(bDelete) + { + impDestroy(); + } + + return pBitmap; +} + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx new file mode 100644 index 000000000000..befbe5696db9 --- /dev/null +++ b/svx/source/xoutdev/xtable.cxx @@ -0,0 +1,511 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> + +#define GLOBALOVERFLOW + +// Vergleichsstrings +sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 }; + +// Konvertiert in echte RGB-Farben, damit in den Listboxen +// endlich mal richtig selektiert werden kann. +Color RGB_Color( ColorData nColorName ) +{ + Color aColor( nColorName ); + Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() ); + return aRGBColor; +} + +// --------------------- +// class XPropertyTable +// --------------------- + +/************************************************************************* +|* +|* XPropertyTable::XPropertyTable() +|* +*************************************************************************/ + +XPropertyTable::XPropertyTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + aName ( pszStandard, 8 ), + aPath ( rPath ), + pXPool ( pInPool ), + aTable ( nInitSize, nReSize ), + pBmpTable ( NULL ), + bTableDirty ( TRUE ), + bBitmapsDirty ( TRUE ), + bOwnPool ( FALSE ) +{ + if( !pXPool ) + { + bOwnPool = TRUE; + pXPool = new XOutdevItemPool; + DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" ); + } +} + +/************************************************************************* +|* +|* XPropertyTable::XPropertyTable( SvStraem& ) +|* +*************************************************************************/ + +XPropertyTable::XPropertyTable( SvStream& /*rIn*/) : + pBmpTable ( NULL ) +{ +} + +/************************************************************************* +|* +|* XPropertyTable::~XPropertyTable() +|* +*************************************************************************/ + +XPropertyTable::~XPropertyTable() +{ + XPropertyEntry* pEntry = (XPropertyEntry*)aTable.First(); + Bitmap* pBitmap = NULL; + for (ULONG nIndex = 0; nIndex < aTable.Count(); nIndex++) + { + delete pEntry; + pEntry = (XPropertyEntry*)aTable.Next(); + } + // Hier wird die Bitmaptabelle geloescht + if( pBmpTable ) + { + pBitmap = (Bitmap*) pBmpTable->First(); + + for( ULONG nIndex = 0; nIndex < pBmpTable->Count(); nIndex++ ) + { + delete pBitmap; + pBitmap = (Bitmap*) pBmpTable->Next(); + } + delete pBmpTable; + pBmpTable = NULL; + } + // Eigener Pool wird geloescht + if( bOwnPool && pXPool ) + { + SfxItemPool::Free(pXPool); + } +} + +/************************************************************************* +|* +|* XPropertyTable::Clear() +|* +*************************************************************************/ + +void XPropertyTable::Clear() +{ + aTable.Clear(); + if( pBmpTable ) + pBmpTable->Clear(); +} + +/************************************************************************/ + +long XPropertyTable::Count() const +{ + if( bTableDirty ) + { + // ( (XPropertyTable*) this )->bTableDirty = FALSE; <- im Load() + if( !( (XPropertyTable*) this )->Load() ) + ( (XPropertyTable*) this )->Create(); + } + return( aTable.Count() ); +} + +/************************************************************************* +|* +|* XPropertyEntry* XPropertyTable::Get() +|* +*************************************************************************/ + +XPropertyEntry* XPropertyTable::Get( long nIndex, USHORT /*nDummy*/) const +{ + if( bTableDirty ) + { + // ( (XPropertyTable*) this )->bTableDirty = FALSE; <- im Load() + if( !( (XPropertyTable*) this )->Load() ) + ( (XPropertyTable*) this )->Create(); + } + return (XPropertyEntry*) aTable.GetObject( (ULONG) nIndex ); +} + +/************************************************************************* +|* +|* long XPropertyTable::Get(const String& rName) +|* +*************************************************************************/ + +long XPropertyTable::Get(const XubString& rName) +{ + if( bTableDirty ) + { + // bTableDirty = FALSE; + if( !Load() ) + Create(); + } + long nPos = 0; + XPropertyEntry* pEntry = (XPropertyEntry*)aTable.First(); + while (pEntry && pEntry->GetName() != rName) + { + nPos++; + pEntry = (XPropertyEntry*)aTable.Next(); + } + if (!pEntry) nPos = -1; + return nPos; +} + +/************************************************************************* +|* +|* Bitmap* XPropertyTable::GetBitmap() +|* +*************************************************************************/ + +Bitmap* XPropertyTable::GetBitmap( long nIndex ) const +{ + if( pBmpTable ) + { + if( bBitmapsDirty ) + { + ( (XPropertyTable*) this )->bBitmapsDirty = FALSE; + ( (XPropertyTable*) this )->CreateBitmapsForUI(); + } + + if( pBmpTable->Count() >= (ULONG) nIndex ) + return (Bitmap*) pBmpTable->GetObject( (ULONG) nIndex ); + } + return( NULL ); +} + +/************************************************************************* +|* +|* void XPropertyTable::Insert() +|* +*************************************************************************/ + +BOOL XPropertyTable::Insert( long nIndex, XPropertyEntry* pEntry ) +{ + BOOL bReturn = aTable.Insert( (ULONG) nIndex, pEntry ); + + if( pBmpTable && !bBitmapsDirty ) + { + Bitmap* pBmp = CreateBitmapForUI( (ULONG) nIndex ); + pBmpTable->Insert( (ULONG) nIndex, pBmp ); + } + return bReturn; +} + +/************************************************************************* +|* +|* void XPropertyTable::Replace() +|* +*************************************************************************/ + +XPropertyEntry* XPropertyTable::Replace( long nIndex, XPropertyEntry* pEntry ) +{ + XPropertyEntry* pOldEntry = (XPropertyEntry*) aTable.Replace( (ULONG) nIndex, pEntry ); + + if( pBmpTable && !bBitmapsDirty ) + { + Bitmap* pBmp = CreateBitmapForUI( (ULONG) nIndex ); + Bitmap* pOldBmp = (Bitmap*) pBmpTable->Replace( (ULONG) nIndex, pBmp ); + if( pOldBmp ) + delete pOldBmp; + } + return pOldEntry; +} + +/************************************************************************* +|* +|* void XPropertyTable::Remove() +|* +*************************************************************************/ + +XPropertyEntry* XPropertyTable::Remove( long nIndex, USHORT /*nDummy*/) +{ + if( pBmpTable && !bBitmapsDirty ) + { + Bitmap* pOldBmp = (Bitmap*) pBmpTable->Remove( (ULONG) nIndex ); + if( pOldBmp ) + delete pOldBmp; + } + return (XPropertyEntry*) aTable.Remove((ULONG)nIndex); +} + +/************************************************************************/ + +void XPropertyTable::SetName( const String& rString ) +{ + if(rString.Len()) + { + aName = rString; + } +} + +// -------------------- +// class XPropertyList +// -------------------- + + +/************************************************************************* +|* +|* XPropertyList::XPropertyList() +|* +*************************************************************************/ + +XPropertyList::XPropertyList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + aName ( pszStandard, 8 ), + aPath ( rPath ), + pXPool ( pInPool ), + aList ( nInitSize, nReSize ), + pBmpList ( NULL ), + bListDirty ( TRUE ), + bBitmapsDirty ( TRUE ), + bOwnPool ( FALSE ) +{ + if( !pXPool ) + { + bOwnPool = TRUE; + pXPool = new XOutdevItemPool; + DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" ); + } +} + +/************************************************************************* +|* +|* XPropertyList::XPropertyList( SvStraem& ) +|* +*************************************************************************/ + +XPropertyList::XPropertyList( SvStream& /*rIn*/) : + pBmpList ( NULL ) +{ +} + +/************************************************************************* +|* +|* XPropertyList::~XPropertyList() +|* +*************************************************************************/ + +XPropertyList::~XPropertyList() +{ + XPropertyEntry* pEntry = (XPropertyEntry*)aList.First(); + Bitmap* pBitmap = NULL; + for( ULONG nIndex = 0; nIndex < aList.Count(); nIndex++ ) + { + delete pEntry; + pEntry = (XPropertyEntry*)aList.Next(); + } + + if( pBmpList ) + { + pBitmap = (Bitmap*) pBmpList->First(); + + for( ULONG nIndex = 0; nIndex < pBmpList->Count(); nIndex++ ) + { + delete pBitmap; + pBitmap = (Bitmap*) pBmpList->Next(); + } + delete pBmpList; + pBmpList = NULL; + } + + if( bOwnPool && pXPool ) + { + SfxItemPool::Free(pXPool); + } +} + +/************************************************************************* +|* +|* XPropertyList::Clear() +|* +*************************************************************************/ + +void XPropertyList::Clear() +{ + aList.Clear(); + if( pBmpList ) + pBmpList->Clear(); +} + +/************************************************************************/ + +long XPropertyList::Count() const +{ + if( bListDirty ) + { + // ( (XPropertyList*) this )->bListDirty = FALSE; <- im Load() + if( !( (XPropertyList*) this )->Load() ) + ( (XPropertyList*) this )->Create(); + } + return( aList.Count() ); +} + +/************************************************************************* +|* +|* XPropertyEntry* XPropertyList::Get() +|* +*************************************************************************/ + +XPropertyEntry* XPropertyList::Get( long nIndex, USHORT /*nDummy*/) const +{ + if( bListDirty ) + { + // ( (XPropertyList*) this )->bListDirty = FALSE; <- im Load() + if( !( (XPropertyList*) this )->Load() ) + ( (XPropertyList*) this )->Create(); + } + return (XPropertyEntry*) aList.GetObject( (ULONG) nIndex ); +} + +/************************************************************************* +|* +|* XPropertyList::Get() +|* +*************************************************************************/ + +long XPropertyList::Get(const XubString& rName) +{ + if( bListDirty ) + { + //bListDirty = FALSE; + if( !Load() ) + Create(); + } + long nPos = 0; + XPropertyEntry* pEntry = (XPropertyEntry*)aList.First(); + while (pEntry && pEntry->GetName() != rName) + { + nPos++; + pEntry = (XPropertyEntry*)aList.Next(); + } + if (!pEntry) nPos = -1; + return nPos; +} + +/************************************************************************* +|* +|* Bitmap* XPropertyList::GetBitmap() +|* +*************************************************************************/ + +Bitmap* XPropertyList::GetBitmap( long nIndex ) const +{ + if( pBmpList ) + { + if( bBitmapsDirty ) + { + ( (XPropertyList*) this )->bBitmapsDirty = FALSE; + ( (XPropertyList*) this )->CreateBitmapsForUI(); + } + if( pBmpList->Count() >= (ULONG) nIndex ) + return (Bitmap*) pBmpList->GetObject( (ULONG) nIndex ); + } + return( NULL ); +} + +/************************************************************************* +|* +|* void XPropertyList::Insert() +|* +*************************************************************************/ + +void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex ) +{ + aList.Insert( pEntry, (ULONG) nIndex ); + + if( pBmpList && !bBitmapsDirty ) + { + Bitmap* pBmp = CreateBitmapForUI( + (ULONG) nIndex < aList.Count() ? nIndex : aList.Count() - 1 ); + pBmpList->Insert( pBmp, (ULONG) nIndex ); + } +} + +/************************************************************************* +|* +|* void XPropertyList::Replace() +|* +*************************************************************************/ + +XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex ) +{ + XPropertyEntry* pOldEntry = (XPropertyEntry*) aList.Replace( pEntry, (ULONG) nIndex ); + + if( pBmpList && !bBitmapsDirty ) + { + Bitmap* pBmp = CreateBitmapForUI( (ULONG) nIndex ); + Bitmap* pOldBmp = (Bitmap*) pBmpList->Replace( pBmp, (ULONG) nIndex ); + if( pOldBmp ) + delete pOldBmp; + } + return pOldEntry; +} + +/************************************************************************* +|* +|* void XPropertyList::Remove() +|* +*************************************************************************/ + +XPropertyEntry* XPropertyList::Remove( long nIndex, USHORT /*nDummy*/) +{ + if( pBmpList && !bBitmapsDirty ) + { + Bitmap* pOldBmp = (Bitmap*) pBmpList->Remove( (ULONG) nIndex ); + if( pOldBmp ) + delete pOldBmp; + } + return (XPropertyEntry*) aList.Remove( (ULONG) nIndex ); +} + +/************************************************************************/ + +void XPropertyList::SetName( const String& rString ) +{ + if(rString.Len()) + { + aName = rString; + } +} + + + diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx new file mode 100644 index 000000000000..54d359506f77 --- /dev/null +++ b/svx/source/xoutdev/xtablend.cxx @@ -0,0 +1,395 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +// include --------------------------------------------------------------- + +#ifndef SVX_LIGHT + +#include <com/sun/star/container/XNameContainer.hpp> +#include "XPropertyTable.hxx" +#include <unotools/ucbstreamhelper.hxx> + +#include "xmlxtexp.hxx" +#include "xmlxtimp.hxx" + +#endif +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> + +#ifndef _SV_APP_HXX +#include <vcl/svapp.hxx> +#endif +#include <svl/itemset.hxx> +#include <sfx2/docfile.hxx> + +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> + +#include <svx/xtable.hxx> +#include <svx/xpool.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xflclit.hxx> +#include <svx/xlnstwit.hxx> +#include <svx/xlnedwit.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnedit.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> + +#include <svx/svdorect.hxx> +#include <svx/svdopath.hxx> +#include <svx/svdmodel.hxx> +#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> +#include <svx/sdr/contact/displayinfo.hxx> + +#define GLOBALOVERFLOW + +using namespace com::sun::star; +using namespace rtl; + +sal_Unicode const pszExtLineEnd[] = {'s','o','e'}; + +static char const aChckLEnd[] = { 0x04, 0x00, 'S','O','E','L'}; // < 5.2 +static char const aChckLEnd0[] = { 0x04, 0x00, 'S','O','E','0'}; // = 5.2 +static char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0 + +// -------------------- +// class XLineEndTable +// -------------------- + +/************************************************************************* +|* +|* XLineEndTable::XLineEndTable() +|* +*************************************************************************/ + +XLineEndTable::XLineEndTable( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyTable( rPath, pInPool, nInitSize, nReSize) +{ + pBmpTable = new Table( nInitSize, nReSize ); +} + +/************************************************************************/ + +XLineEndTable::~XLineEndTable() +{ +} + +/************************************************************************/ + +XLineEndEntry* XLineEndTable::Replace(long nIndex, XLineEndEntry* pEntry ) +{ + return (XLineEndEntry*) XPropertyTable::Replace(nIndex, pEntry); +} + +/************************************************************************/ + +XLineEndEntry* XLineEndTable::Remove(long nIndex) +{ + return (XLineEndEntry*) XPropertyTable::Remove(nIndex, 0); +} + +/************************************************************************/ + +XLineEndEntry* XLineEndTable::GetLineEnd(long nIndex) const +{ + return (XLineEndEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XLineEndTable::Load() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XLineEndTable::Save() +{ + return( FALSE ); +} + +/************************************************************************/ + +BOOL XLineEndTable::Create() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XLineEndTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/) +{ + return( NULL ); +} + +/************************************************************************/ + +BOOL XLineEndTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +// -------------------- +// class XLineEndList +// -------------------- + +class impXLineEndList +{ +private: + VirtualDevice* mpVirtualDevice; + SdrModel* mpSdrModel; + SdrObject* mpBackgroundObject; + SdrObject* mpLineObject; + +public: + impXLineEndList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pL) + : mpVirtualDevice(pV), + mpSdrModel(pM), + mpBackgroundObject(pB), + mpLineObject(pL) + {} + + ~impXLineEndList() + { + delete mpVirtualDevice; + SdrObject::Free(mpBackgroundObject); + SdrObject::Free(mpLineObject); + delete mpSdrModel; + } + + VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; } + SdrObject* getBackgroundObject() const { return mpBackgroundObject; } + SdrObject* getLineObject() const { return mpLineObject; } +}; + +void XLineEndList::impCreate() +{ + if(!mpData) + { + const Point aZero(0, 0); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + VirtualDevice* pVirDev = new VirtualDevice; + OSL_ENSURE(0 != pVirDev, "XLineEndList: no VirtualDevice created!" ); + pVirDev->SetMapMode(MAP_100TH_MM); + const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH * 2, BITMAP_HEIGHT))); + pVirDev->SetOutputSize(aSize); + pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode() + ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT + : DRAWMODE_DEFAULT); + + SdrModel* pSdrModel = new SdrModel(); + OSL_ENSURE(0 != pSdrModel, "XLineEndList: no SdrModel created!" ); + pSdrModel->GetItemPool().FreezeIdRanges(); + + const Rectangle aBackgroundSize(aZero, aSize); + SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize); + OSL_ENSURE(0 != pBackgroundObject, "XLineEndList: no BackgroundObject created!" ); + pBackgroundObject->SetModel(pSdrModel); + pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID)); + pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); + pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor())); + + const basegfx::B2DPoint aStart(0, aSize.Height() / 2); + const basegfx::B2DPoint aEnd(aSize.Width(), aSize.Height() / 2); + basegfx::B2DPolygon aPolygon; + aPolygon.append(aStart); + aPolygon.append(aEnd); + SdrObject* pLineObject = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygon)); + OSL_ENSURE(0 != pLineObject, "XLineEndList: no LineObject created!" ); + pLineObject->SetModel(pSdrModel); + pLineObject->SetMergedItem(XLineStartWidthItem(aSize.Height())); + pLineObject->SetMergedItem(XLineEndWidthItem(aSize.Height())); + pLineObject->SetMergedItem(XLineColorItem(String(), rStyleSettings.GetFieldTextColor())); + + mpData = new impXLineEndList(pVirDev, pSdrModel, pBackgroundObject, pLineObject); + OSL_ENSURE(0 != mpData, "XLineEndList: data creation went wrong!" ); + } +} + +void XLineEndList::impDestroy() +{ + if(mpData) + { + delete mpData; + mpData = 0; + } +} + +XLineEndList::XLineEndList(const String& rPath, XOutdevItemPool* _pXPool, sal_uInt16 nInitSize, sal_uInt16 nReSize) +: XPropertyList(rPath, _pXPool, nInitSize, nReSize), + mpData(0) +{ + pBmpList = new List(nInitSize, nReSize); +} + +XLineEndList::~XLineEndList() +{ + impDestroy(); +} + +XLineEndEntry* XLineEndList::Replace(XLineEndEntry* pEntry, long nIndex ) +{ + return (XLineEndEntry*) XPropertyList::Replace(pEntry, nIndex); +} + +XLineEndEntry* XLineEndList::Remove(long nIndex) +{ + return (XLineEndEntry*) XPropertyList::Remove(nIndex, 0); +} + +XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const +{ + return (XLineEndEntry*) XPropertyList::Get(nIndex, 0); +} + +BOOL XLineEndList::Load() +{ + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtLineEnd, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); + } + return( FALSE ); +} + +BOOL XLineEndList::Save() +{ + INetURLObject aURL( aPath ); + + if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) + { + DBG_ASSERT( !aPath.Len(), "invalid URL" ); + return FALSE; + } + + aURL.Append( aName ); + + if( !aURL.getExtension().getLength() ) + aURL.setExtension( rtl::OUString( pszExtLineEnd, 3 ) ); + + uno::Reference< container::XNameContainer > xTable( SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY ); + return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); +} + +BOOL XLineEndList::Create() +{ + basegfx::B2DPolygon aTriangle; + aTriangle.append(basegfx::B2DPoint(10.0, 0.0)); + aTriangle.append(basegfx::B2DPoint(0.0, 30.0)); + aTriangle.append(basegfx::B2DPoint(20.0, 30.0)); + aTriangle.setClosed(true); + Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) ); + + basegfx::B2DPolygon aSquare; + aSquare.append(basegfx::B2DPoint(0.0, 0.0)); + aSquare.append(basegfx::B2DPoint(10.0, 0.0)); + aSquare.append(basegfx::B2DPoint(10.0, 10.0)); + aSquare.append(basegfx::B2DPoint(0.0, 10.0)); + aSquare.setClosed(true); + Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) ); + + basegfx::B2DPolygon aCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 100.0)); + Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) ); + + return( TRUE ); +} + +BOOL XLineEndList::CreateBitmapsForUI() +{ + impCreate(); + + for( long i = 0; i < Count(); i++) + { + Bitmap* pBmp = CreateBitmapForUI( i, FALSE ); + OSL_ENSURE(0 != pBmp, "XLineEndList: Bitmap(UI) could not be created!" ); + + if( pBmp ) + pBmpList->Insert( pBmp, i ); + } + + impDestroy(); + + return( TRUE ); +} + +Bitmap* XLineEndList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + impCreate(); + VirtualDevice* pVD = mpData->getVirtualDevice(); + SdrObject* pLine = mpData->getLineObject(); + + pLine->SetMergedItem(XLineStyleItem(XLINE_SOLID)); + pLine->SetMergedItem(XLineStartItem(String(), GetLineEnd(nIndex)->GetLineEnd())); + pLine->SetMergedItem(XLineEndItem(String(), GetLineEnd(nIndex)->GetLineEnd())); + + sdr::contact::SdrObjectVector aObjectVector; + aObjectVector.push_back(mpData->getBackgroundObject()); + aObjectVector.push_back(pLine); + sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0); + sdr::contact::DisplayInfo aDisplayInfo; + + aPainter.ProcessDisplay(aDisplayInfo); + + const Point aZero(0, 0); + Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize())); + + if(bDelete) + { + impDestroy(); + } + + return pBitmap; +} + +////////////////////////////////////////////////////////////////////////////// +// eof |