diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
commit | fd069bee7e57ad529c3c0974559fd2d84ec3151a (patch) | |
tree | ef2eddeefb786feaf966d6a1c0c291872c0ae420 /svx/source/xoutdev | |
parent | 04c1c754ab9d0ad07f2c5362d46597d13efe75c2 (diff) |
initial import
Diffstat (limited to 'svx/source/xoutdev')
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 904 | ||||
-rw-r--r-- | svx/source/xoutdev/_xpoly.cxx | 2444 | ||||
-rw-r--r-- | svx/source/xoutdev/makefile.mk | 191 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 4159 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr2.cxx | 1742 | ||||
-rw-r--r-- | svx/source/xoutdev/xattrbmp.cxx | 801 | ||||
-rw-r--r-- | svx/source/xoutdev/xexch.cxx | 229 | ||||
-rw-r--r-- | svx/source/xoutdev/xpool.cxx | 475 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabbtmp.cxx | 662 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabcolr.cxx | 856 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabdash.cxx | 655 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabgrdt.cxx | 776 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabhtch.cxx | 657 | ||||
-rw-r--r-- | svx/source/xoutdev/xtable.cxx | 544 | ||||
-rw-r--r-- | svx/source/xoutdev/xtablend.cxx | 705 |
15 files changed, 15800 insertions, 0 deletions
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx new file mode 100644 index 000000000000..92ace6bc9269 --- /dev/null +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -0,0 +1,904 @@ +/************************************************************************* + * + * $RCSfile: _xoutbmp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <sot/factory.hxx> +#include <tools/urlobj.hxx> +#include <tools/fsys.hxx> +#include <vcl/bmpacc.hxx> +#include <vcl/poly.hxx> +#include <vcl/virdev.hxx> +#include <vcl/wrkwin.hxx> +#include <svtools/solar.hrc> +#include <sfx2/docfile.hxx> +#include <sfx2/app.hxx> +#include "impgrf.hxx" +#include "xoutbmp.hxx" + +// ----------- +// - Defines - +// ----------- + +#define FORMAT_BMP "bmp" +#define FORMAT_GIF "gif" +#define FORMAT_JPG "jpg" + +#define OPT_BMP "BMP-COLORS" +#define OPT_JPG "JPG_EXPORT_COLORMODE" + +#define TRANSFILTER "GIF - Graphics Interchange" +#define BMPFILTER "BMP - MS Windows" +#define JPGFILTER "JPG - JPEG" + +// -------------- +// - 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(); +} + +// ------------------------------------------------------------------------ + +Bitmap XOutBitmap::GetBitmapFromGraphic( const Graphic& rGraphic ) +{ + DBG_ERROR( "Please use Graphic::GetBitmap()!" ); + return rGraphic.GetBitmap(); +} + +// ------------------------------------------------------------------------ + +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 ) +{ +#ifndef SVX_LIGHT + if( rGraphic.GetType() != GRAPHIC_NONE ) + { + Graphic aGraphic; + String aFilter( rFilterName ); + String aExt; + GraphicFilter* pFilter = GetGrfFilter(); + USHORT nErr = GRFILTER_FILTERERROR; + USHORT nFilter = GRFILTER_FORMAT_NOTFOUND; + BOOL bWriteTransGrf; + BOOL bAnimated = rGraphic.IsAnimated(); + + aFilter.ToLowerAscii(); + bWriteTransGrf = ( aFilter.EqualsAscii("transgrf") ) || ( aFilter.EqualsAscii("gif") ) || ( nFlags & XOUTBMP_USE_GIF_IF_POSSIBLE ); + + if ( !bWriteTransGrf ) + bWriteTransGrf = ( nFlags & XOUTBMP_USE_GIF_IF_SENSIBLE ) && ( bAnimated || rGraphic.IsTransparent() ); + + // richtige Filternummer bestimmen + if( !bWriteTransGrf ) + { + const USHORT nCount = pFilter->GetExportFormatCount(); + + for( USHORT n = 0; n < nCount; n++ ) + { + if( aFilter == pFilter->GetExportFormatShortName( n ).ToLowerAscii() ) + { + nFilter = n; + aExt = aFilter; + break; + } + } + } + else + { + nFilter = pFilter->GetExportFormatNumber( String(TRANSFILTER, gsl_getSystemTextEncoding()) ); + aExt = pFilter->GetExportFormatShortName( nFilter ).ToLowerAscii(); + } + + // Graphic erstellen + if( bWriteTransGrf && ( GRFILTER_FORMAT_NOTFOUND != nFilter ) ) + { + 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(); + } + + // Falls Filter nicht gefunden, erst einmal JPEG probieren, dann BMP + if( GRFILTER_FORMAT_NOTFOUND == nFilter ) + { + nFilter = pFilter->GetExportFormatNumber( String(JPGFILTER, gsl_getSystemTextEncoding()) ); + aExt = pFilter->GetExportFormatShortName( nFilter ).ToLowerAscii(); + + if ( GRFILTER_FORMAT_NOTFOUND == nFilter ) + { + nFilter = pFilter->GetExportFormatNumber( String(BMPFILTER, gsl_getSystemTextEncoding()) ); + aExt = pFilter->GetExportFormatShortName( nFilter ).ToLowerAscii(); + } + } + + // Pixel-Graphic ggf. spiegeln + if( nFlags ) + aGraphic = MirrorGraphic( aGraphic, nFlags ); + + if( GRFILTER_FORMAT_NOTFOUND != nFilter ) + { + INetURLObject aURL; + + aURL.SetSmartURL( rFileName ); + aURL.setExtension( aExt ); + + if( INET_PROT_FILE == aURL.GetProtocol() ) + { + if( !( nFlags & XOUTBMP_DONT_EXPAND_FILENAME ) ) + { + String aName( aURL.getName() ); + xub_StrLen nNameLen = aName.Len(); + + if( nNameLen > 3 ) + { + nNameLen -= 3; + + if( aName.GetChar( nNameLen - 1 ) == sal_Unicode( '.' ) ) + --nNameLen; + } + + aURL.setName( aName.Insert( sal_Unicode( '*' ), nNameLen ) ); + + // !!!DirEntry; create temporary file name + DirEntry aPath( aURL.PathToFileName() ); + aURL.SetSmartURL( aPath.TempName().GetFull() ); + } + + rFileName = aURL.PathToFileName(); + + if( ( nFlags & XOUTBMP_USE_GIF_IF_SENSIBLE ) && ( aExt.ToLowerAscii().EqualsAscii( "bmp" ) ) ) + { + SvFileStream aOStm( rFileName, STREAM_WRITE | STREAM_TRUNC ); + + if( aOStm.IsOpen() ) + { + aGraphic.GetBitmap().Write( aOStm, TRUE ); + nErr = aOStm.GetError() != 0 ? GRFILTER_IOERROR : 0; + } + else + nErr = GRFILTER_IOERROR; + } + else + nErr = ExportGraphic( aGraphic, aURL, *pFilter, nFilter, TRUE ); + } + else if( INET_PROT_NOT_VALID != aURL.GetProtocol() ) + { + if( !( nFlags & XOUTBMP_DONT_EXPAND_FILENAME ) ) + { + String aTimeStr( UniString::CreateFromInt32( Time().GetTime() ) ); + String aName( aURL.getName() ); + xub_StrLen nNameLen = aName.Len(); + + if( nNameLen > 3 ) + { + nNameLen -= 3; + + if( aName.GetChar( nNameLen - 1 ) == sal_Unicode( '.' ) ) + --nNameLen; + } + + aTimeStr.Insert( sal_Unicode('_'), 0 ); + aName.Insert( aTimeStr, nNameLen ); + aURL.SetName( aName ); + } + + SfxMedium aMedium( rFileName = aURL.PathToFileName(), STREAM_WRITE | STREAM_SHARE_DENYNONE, TRUE, FALSE ); + + aMedium.DownLoad(); + + INetURLObject aPhysURL; aPhysURL.SetSmartURL( aMedium.GetPhysicalName() ); + nErr = ExportGraphic( aGraphic, aPhysURL, *pFilter, nFilter, TRUE ); + + // uebertragen + aMedium.Close(); + aMedium.Commit(); + + if( aMedium.GetError() && nErr == GRFILTER_OK ) + nErr = 1; + } + } + + return nErr; + } + else +#endif + return GRFILTER_OK; +} + +// ------------------------------------------------------------------------ + +#ifdef WNT +#pragma optimize ( "", off ) +#endif + +// !!!DirEntry +USHORT XOutBitmap::ExportGraphic( const Graphic& rGraphic, const DirEntry& rPath, + GraphicFilter& rFilter, const USHORT nFormat, + BOOL bIgnoreOptions ) +{ + INetURLObject aURL; aURL.SetSmartURL( rPath.GetFull() ); + return ExportGraphic( rGraphic, aURL, rFilter, nFormat, bIgnoreOptions ); +} + +// ------------------------------------------------------------------------ + +USHORT XOutBitmap::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rURL, + GraphicFilter& rFilter, const USHORT nFormat, + BOOL bIgnoreOptions ) +{ + const String aPath( rURL.PathToFileName() ); + SvFileStream aOStm( aPath, STREAM_WRITE | STREAM_TRUNC ); + Config* pOptionsConfig = rFilter.GetOptionsConfig(); + USHORT nRet; + + pGrfFilter = &rFilter; + + if( bIgnoreOptions && rFilter.AreOptionsEnabled() ) + { + rFilter.EnableOptions( FALSE ); + nRet = rFilter.ExportGraphic( rGraphic, aPath, aOStm, nFormat ); + rFilter.EnableOptions( TRUE ); + } + else + { + Graphic aGraphic; + + if( pOptionsConfig ) + { + const String aFormat( rFilter.GetExportFormatShortName( nFormat ).ToLowerAscii() ); + + // Optionen fuer die einzelnen Format beruecksichtigen + if( aFormat.EqualsAscii( FORMAT_BMP ) ) + { + USHORT nColorRes = pOptionsConfig->ReadKey( ByteString(OPT_BMP) ).ToInt32(); + + if( !nColorRes || ( nColorRes > (USHORT) BMP_CONVERSION_24BIT ) ) + aGraphic = rGraphic; + else + { + Bitmap aTmp( rGraphic.GetBitmap() ); + + if( aTmp.Convert( (BmpConversion) nColorRes ) ) + aGraphic = aTmp; + else + aGraphic = rGraphic; + } + } + else if( aFormat.EqualsAscii(FORMAT_JPG) ) + { + Bitmap aTmp( rGraphic.GetBitmap() ); + const BOOL bGreys = (BOOL)pOptionsConfig->ReadKey( ByteString(OPT_JPG) ).ToInt32(); + const BmpConversion eConv = bGreys ? BMP_CONVERSION_8BIT_GREYS : BMP_CONVERSION_24BIT; + + if( aTmp.Convert( eConv ) ) + aGraphic = aTmp; + else + aGraphic = rGraphic; + } + else if( aFormat.EqualsAscii(FORMAT_GIF) ) + aGraphic = rGraphic; + else + aGraphic = rGraphic; + } + else + aGraphic = rGraphic; + + nRet = rFilter.ExportGraphic( aGraphic, aPath, aOStm, nFormat ); + } + + pGrfFilter = NULL; + + return nRet; +} + +#ifdef WNT +#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..f5c2b215002f --- /dev/null +++ b/svx/source/xoutdev/_xpoly.cxx @@ -0,0 +1,2444 @@ +/************************************************************************* + * + * $RCSfile: _xpoly.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <math.h> +#include <string.h> +#include <tools/stream.hxx> +#include <tools/debug.hxx> +#include <vcl/poly.hxx> + +#pragma hdrstop + +#include "xoutx.hxx" +#include "xpoly.hxx" +#include "xpolyimp.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; + ImpXPolygon::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 +|* +*************************************************************************/ + + +FASTBOOL 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 ) +{ + USHORT nOldSize = nSize; + + 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 += 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 -= 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(OutputDevice *pOut) const +{ + pImpXPolygon->CheckPointDelete(); + + Rectangle aRect(XOutCalcXPolyExtent(*this, pOut)); + +// USHORT nCount = pImpXPolygon->nPoints; +// if( !nCount ) +// return Rectangle(); + +// Polygon aPoly = XOutCreatePolygon(*this, pOut); +// Rectangle aRect = aPoly.GetBoundRect(); +/* + if ( pOut == NULL ) + { + BOOL bHasBezier = FALSE; + + for (USHORT i = 0; i < nCount; i++) + { + if ( pImpXPolygon->pFlagAry[i] == (BYTE) XPOLY_CONTROL ) + { + bHasBezier = TRUE; + i = nCount; + } + } + if ( bHasBezier ) + { // Breite und Hoehe um 1 Prozent erweitern, um Differenzen zur + // ungenauen Bezierberechnung (wg. fehlendem OutputDevice) auszugleichen + long nWDiff = aRect.GetWidth() / 200; + long nHDiff = aRect.GetHeight() / 200; + aRect.Left() -= nWDiff; + aRect.Right() += nWDiff; + aRect.Top() -= nHDiff; + aRect.Bottom() += nHDiff; + } + } +*/ return aRect; +} + +/************************************************************************* +|* +|* 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 += nPosInc; + 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 += nPosInc; + 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; + } +} + +/************************************************************************* +|* +|* XPolygon::operator>>() +|* +|* Beschreibung Stream-Leseoperator +|* Ersterstellung ESO 04.04.95 +|* Letzte Aenderung ESO 04.04.95 +|* +*************************************************************************/ + +SvStream& operator>>( SvStream& rIStream, XPolygon& rXPoly ) +{ + DBG_CHKOBJ( &rXPoly, XPolygon, NULL ); + + USHORT i; + USHORT nStart; + USHORT nCurPoints; + USHORT nReadPoints; // Anzahl der Punkte im Stream + USHORT nMerkPoints; // Anzahl der Punkte die ich speichern kann + unsigned char bShort; + short nShortX; + short nShortY; + long nLongX; + long nLongY; + + rXPoly.pImpXPolygon->CheckPointDelete(); + + // Anzahl der Punkte einlesen und Array erzeugen + rIStream >> nReadPoints; + nMerkPoints=nReadPoints; + if (nMerkPoints>XPOLY_MAXPOINTS) { + nMerkPoints=XPOLY_MAXPOINTS; + // hier koennte man ein Flag am Stream setzen um zu vermerken + // dass beim Lesen Informationsverlusst aufgetreten ist !!!!! + } + rXPoly.pImpXPolygon->nPoints = nMerkPoints; + + if ( rXPoly.pImpXPolygon->nRefCount != 1 ) + { + if ( rXPoly.pImpXPolygon->nRefCount ) + rXPoly.pImpXPolygon->nRefCount--; + rXPoly.pImpXPolygon = new ImpXPolygon( nMerkPoints ); + } + else + rXPoly.pImpXPolygon->Resize( nMerkPoints ); + + // Je nach CompressMode das Polygon einlesen + if ( rIStream.GetCompressMode() == COMPRESSMODE_FULL ) + { + i = 0; + while ( i < nReadPoints ) + { + rIStream >> bShort >> nCurPoints; + + if ( bShort ) + { + for ( nStart = i; i < nStart+nCurPoints; i++ ) + { + rIStream >> nShortX >> nShortY; + if (i<nMerkPoints) { // restliche Punkte ueberspringen + rXPoly.pImpXPolygon->pPointAry[i].X() = nShortX; + rXPoly.pImpXPolygon->pPointAry[i].Y() = nShortY; + } + } + } + else + { + for ( nStart = i; i < nStart+nCurPoints; i++ ) + { + rIStream >> nLongX >> nLongY; + if (i<nMerkPoints) { // restliche Punkte ueberspringen + rXPoly.pImpXPolygon->pPointAry[i].X() = nLongX; + rXPoly.pImpXPolygon->pPointAry[i].Y() = nLongY; + } + } + } + } + } + else + { + // Feststellen, ob ueber die Operatoren gelesen werden muss +#if (__SIZEOFLONG) != 4 + if ( 1 ) +#else +#ifdef __BIGENDIAN + if ( rIStream.GetNumberFormatInt() != NUMBERFORMAT_INT_BIGENDIAN ) +#else + if ( rIStream.GetNumberFormatInt() != NUMBERFORMAT_INT_LITTLEENDIAN ) +#endif +#endif + { + for( i = 0; i < nReadPoints; i++ ) { + long x,y; + rIStream >> x >> y; + if (i<nMerkPoints) { // restliche Punkte ueberspringen + rXPoly.pImpXPolygon->pPointAry[i].X()=x; + rXPoly.pImpXPolygon->pPointAry[i].Y()=y; + } + } + } else { + rIStream.Read( rXPoly.pImpXPolygon->pPointAry, nMerkPoints*sizeof(Point) ); + if (nReadPoints>nMerkPoints) { // restliche Punkte ueberspringen + rIStream.SeekRel( ULONG(nReadPoints-nMerkPoints)*sizeof(Point) ); + } + } + } + rIStream.Read( rXPoly.pImpXPolygon->pFlagAry, nMerkPoints ); + if (nReadPoints>nMerkPoints) { // Flags der restlichen Punkte ueberspringen + rIStream.SeekRel( ULONG(nReadPoints-nMerkPoints) ); + // Poly muesste hier noch etwas korregiert werden (Bezier-Kontrollpunkte am Ende..., geschlossen?) + } + while (rXPoly.GetPointCount()>0 && rXPoly.GetFlags(USHORT(rXPoly.GetPointCount()-1))==XPOLY_CONTROL) { + // Kontrollpunkte am Ende entfernen (kann auftreten bei truncate wg. 64k-Grenze!) + rXPoly.Remove(USHORT(rXPoly.GetPointCount()-1),1); + } + + return rIStream; +} + +/************************************************************************* +|* +|* XPolygon::operator<<() +|* +|* Beschreibung Stream-Schreiboperator +|* Ersterstellung ESO 04.04.95 +|* Letzte Aenderung ESO 04.04.95 +|* +*************************************************************************/ + +SvStream& operator<<( SvStream& rOStream, const XPolygon& rXPoly ) +{ + DBG_CHKOBJ( &rXPoly, XPolygon, NULL ); + + unsigned char bShort; + unsigned char bCurShort; + USHORT nStart; + USHORT i; + USHORT nPoints = rXPoly.GetPointCount(); + + rXPoly.pImpXPolygon->CheckPointDelete(); + + // Anzahl der Punkte rausschreiben + rOStream << nPoints; + + // Je nach CompressMode das Polygon rausschreiben + if ( rOStream.GetCompressMode() == COMPRESSMODE_FULL ) + { + i = 0; + while ( i < nPoints ) + { + nStart = i; + + // Feststellen, welcher Typ geschrieben werden soll + if ( ((rXPoly.pImpXPolygon->pPointAry[nStart].X() >= SHRT_MIN) && + (rXPoly.pImpXPolygon->pPointAry[nStart].X() <= SHRT_MAX)) && + ((rXPoly.pImpXPolygon->pPointAry[nStart].Y() >= SHRT_MIN) && + (rXPoly.pImpXPolygon->pPointAry[nStart].Y() <= SHRT_MAX)) ) + bShort = TRUE; + else + bShort = FALSE; + while ( i < nPoints ) + { + // Feststellen, welcher Typ geschrieben werden soll + if ( ((rXPoly.pImpXPolygon->pPointAry[nStart].X() >= SHRT_MIN) && + (rXPoly.pImpXPolygon->pPointAry[nStart].X() <= SHRT_MAX)) && + ((rXPoly.pImpXPolygon->pPointAry[nStart].Y() >= SHRT_MIN) && + (rXPoly.pImpXPolygon->pPointAry[nStart].Y() <= SHRT_MAX)) ) + bCurShort = TRUE; + else + bCurShort = FALSE; + + // Wenn sich die Werte in einen anderen Bereich begeben, + // muessen wir neu rausschreiben + if ( bCurShort != bShort ) + { + bShort = bCurShort; + break; + } + + i++; + } + + rOStream << bShort << (USHORT)(i-nStart); + + if ( bShort ) + { + for( ; nStart < i; nStart++ ) + { + rOStream << (short)rXPoly.pImpXPolygon->pPointAry[nStart].X() + << (short)rXPoly.pImpXPolygon->pPointAry[nStart].Y(); + } + } + else + { + for( ; nStart < i; nStart++ ) + { + rOStream << rXPoly.pImpXPolygon->pPointAry[nStart].X() + << rXPoly.pImpXPolygon->pPointAry[nStart].Y(); + } + } + } + } + else + { + // Feststellen, ob ueber die Operatoren geschrieben werden muss +#if (__SIZEOFLONG) != 4 + if ( 1 ) +#else +#ifdef __BIGENDIAN + if ( rOStream.GetNumberFormatInt() != NUMBERFORMAT_INT_BIGENDIAN ) +#else + if ( rOStream.GetNumberFormatInt() != NUMBERFORMAT_INT_LITTLEENDIAN ) +#endif +#endif + { + for( i = 0; i < nPoints; i++ ) + rOStream << rXPoly.pImpXPolygon->pPointAry[i].X() + << rXPoly.pImpXPolygon->pPointAry[i].Y(); + } + else if ( nPoints ) + rOStream.Write( rXPoly.pImpXPolygon->pPointAry, nPoints*sizeof(Point) ); + } + + if ( nPoints ) + rOStream.Write( rXPoly.pImpXPolygon->pFlagAry, nPoints ); + + return rOStream; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +//+--------------- 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 +|* +*************************************************************************/ + + +FASTBOOL ImpXPolyPolygon::operator==(const ImpXPolyPolygon& rImpXPolyPoly) const +{ + USHORT nAnz=(USHORT)aXPolyList.Count(); + const XPolygonList& rCmpList=rImpXPolyPoly.aXPolyList; + if (nAnz!=(USHORT)rCmpList.Count()) return FALSE; + FASTBOOL 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(OutputDevice* pOut) 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(pOut) ); + } + + 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); +} + + +/************************************************************************* +|* +|* XPolyPolygon::operator>>() +|* +|* Beschreibung Stream-Leseoperator +|* Ersterstellung ESO 04.04.95 +|* Letzte Aenderung Joe 10.10.95 64k Begrenzung +|* +*************************************************************************/ + +SvStream& operator>>( SvStream& rIStream, XPolyPolygon& rXPolyPoly ) +{ + DBG_CHKOBJ( &rXPolyPoly, XPolyPolygon, NULL ); + + XPolygon* pXPoly; + + // Anzahl der Polygone einlesen + USHORT nXPolyCount; + rIStream >> nXPolyCount; + + FASTBOOL bTruncated=FALSE; + ULONG nAllPointCount=0; // Gesamtanzahl der Punkte mitzaehlen + + if ( rXPolyPoly.pImpXPolyPolygon->nRefCount > 1 ) { + rXPolyPoly.pImpXPolyPolygon->nRefCount--; + } else { + delete rXPolyPoly.pImpXPolyPolygon; + } + rXPolyPoly.pImpXPolyPolygon = new ImpXPolyPolygon( nXPolyCount ); + + while (nXPolyCount>0) { + pXPoly = new XPolygon; + rIStream >> *pXPoly; + nAllPointCount+=pXPoly->GetPointCount(); + if (!bTruncated) { + if (nAllPointCount>XPOLY_MAXPOINTS) { + USHORT nDel=(USHORT)(nAllPointCount-XPOLY_MAXPOINTS); + USHORT nPos=pXPoly->GetPointCount()-nDel; + pXPoly->Remove(nPos,nDel); + bTruncated=TRUE; // Alle nachfolgenden Polygone werden ignoriert + } + rXPolyPoly.pImpXPolyPolygon->aXPolyList.Insert( pXPoly, LIST_APPEND ); + } else { + delete pXPoly; + } + nXPolyCount--; + } + + if (bTruncated) { + // hier koennte man ein Flag am Stream setzen um zu vermerken + // dass beim Lesen Informationsverlusst aufgetreten ist !!!!! + } + + return rIStream; +} + +/************************************************************************* +|* +|* XPolyPolygon::operator<<() +|* +|* Beschreibung Stream-Schreiboperator +|* Ersterstellung ESO 04.04.95 +|* Letzte Aenderung ESO 04.04.95 +|* +*************************************************************************/ + +SvStream& operator<<( SvStream& rOStream, const XPolyPolygon& rXPolyPoly ) +{ + DBG_CHKOBJ( &rXPolyPoly, XPolyPolygon, NULL ); + + // Anzahl der Polygone rausschreiben + rOStream << rXPolyPoly.Count(); + + // Die einzelnen Polygone ausgeben + XPolygon* pXPoly = rXPolyPoly.pImpXPolyPolygon->aXPolyList.First(); + + while( pXPoly ) + { + rOStream << *pXPoly; + pXPoly = rXPolyPoly.pImpXPolyPolygon->aXPolyList.Next(); + } + + return rOStream; +} + + diff --git a/svx/source/xoutdev/makefile.mk b/svx/source/xoutdev/makefile.mk new file mode 100644 index 000000000000..2a632505ede0 --- /dev/null +++ b/svx/source/xoutdev/makefile.mk @@ -0,0 +1,191 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=SVX +PROJECTPCH=xout +PROJECTPCHSOURCE=xoutpch +TARGET=xout +AUTOSEG=true +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +HXX1TARGET = xoutx +HXX1EXT = hxx +HXX1FILES = $(INC)$/xoutx.hxx +HXX1EXCL = -K:*compat.hxx + +HXX2TARGET = xattr +HXX2EXT = hxx +HXX2FILES = $(INC)$/xattr.hxx +HXX2EXCL = -K:*compat.hxx + +HXX3TARGET = xpoly +HXX3EXT = hxx +HXX3FILES = $(INC)$/xpoly.hxx +HXX3EXCL = -K:*compat.hxx + +HXX4TARGET = xtable +HXX4EXT = hxx +HXX4FILES = $(INC)$/xtable.hxx +HXX4EXCL = -K:*compat.hxx + +HXX5TARGET = xoutbmp +HXX5EXT = hxx +HXX5FILES = $(INC)$/xoutbmp.hxx +HXX5EXCL = -K:*compat.hxx + +HXX6TARGET = xpool +HXX6EXT = hxx +HXX6FILES = $(INC)$/xpool.hxx +HXX6EXCL = -K:*compat.hxx + +.IF "$(header)" == "" + +CXXFILES= \ + xcpoly.cxx \ + xoutpch.cxx \ + xout.cxx \ + xout1.cxx \ + xattr.cxx \ + xattr2.cxx \ + xattrbmp.cxx \ + xline.cxx \ + xpool.cxx \ + xtable.cxx \ + xtabcolr.cxx \ + xtablend.cxx \ + xtabdash.cxx \ + xtabhtch.cxx \ + xtabgrdt.cxx \ + xtabbtmp.cxx \ + xexch.cxx \ + xiocomp.cxx \ + _xpoly.cxx \ + _ximp.cxx \ + _ximp2.cxx \ + _xoutbmp.cxx \ + _xfont.cxx + +SLOFILES= \ + $(SLO)$/xcpoly.obj \ + $(SLO)$/xout.obj \ + $(SLO)$/xout1.obj \ + $(SLO)$/xattr.obj \ + $(SLO)$/xattr2.obj \ + $(SLO)$/xattrbmp.obj \ + $(SLO)$/xline.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)$/xiocomp.obj \ + $(SLO)$/_xpoly.obj \ + $(SLO)$/_ximp.obj \ + $(SLO)$/_xoutbmp.obj \ + $(SLO)$/_xfont.obj + +SVXLIGHTOBJFILES= \ + $(OBJ)$/xcpoly.obj \ + $(OBJ)$/xout.obj \ + $(OBJ)$/xout1.obj \ + $(OBJ)$/xattr.obj \ + $(OBJ)$/xattr2.obj \ + $(OBJ)$/xattrbmp.obj \ + $(OBJ)$/xline.obj \ + $(OBJ)$/xpool.obj \ + $(OBJ)$/xtable.obj \ + $(OBJ)$/xtabcolr.obj \ + $(OBJ)$/xtablend.obj \ + $(OBJ)$/xtabdash.obj \ + $(OBJ)$/xtabhtch.obj \ + $(OBJ)$/xtabgrdt.obj \ + $(OBJ)$/xtabbtmp.obj \ + $(OBJ)$/xexch.obj \ + $(OBJ)$/xiocomp.obj \ + $(OBJ)$/_xpoly.obj \ + $(OBJ)$/_ximp.obj \ + $(OBJ)$/_ximp2.obj \ + $(OBJ)$/_xoutbmp.obj \ + $(OBJ)$/_xfont.obj + +.ENDIF + +HXXCOPYFILES=\ + $(PRJ)$/inc$/xenum.hxx + + +.INCLUDE : target.mk diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx new file mode 100644 index 000000000000..723cd308cca7 --- /dev/null +++ b/svx/source/xoutdev/xattr.cxx @@ -0,0 +1,4159 @@ +/************************************************************************* + * + * $RCSfile: xattr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#ifndef _COM_SUN_STAR_DRAWING_HATCH_HPP_ +#include <com/sun/star/drawing/Hatch.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_ +#include <com/sun/star/drawing/LineStyle.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_LINEDASH_HPP_ +#include <com/sun/star/drawing/LineDash.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_DASHSTYLE_HPP_ +#include <com/sun/star/drawing/DashStyle.hpp> +#endif + +#ifndef _COM_SUN_STAR_AWT_POINT_HPP_ +#include <com/sun/star/awt/Point.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCE_HPP_ +#include <com/sun/star/drawing/PointSequence.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_FILLSTYLE_HPP_ +#include <com/sun/star/drawing/FillStyle.hpp> +#endif + +#ifndef _COM_SUN_STAR_AWT_GRADIENT_HPP_ +#include <com/sun/star/awt/Gradient.hpp> +#endif + +#include <tools/stream.hxx> + +#include <tools/bigint.hxx> +#include <svtools/itemset.hxx> +#include "dialogs.hrc" +#include "xattr.hxx" +#include "xtable.hxx" +#include "xoutx.hxx" +#include "dialmgr.hxx" +#include "itemtype.hxx" +#include "xdef.hxx" +#include "unomid.hxx" + +#define GLOBALOVERFLOW + +/************************************************************************/ + +#ifdef VCL +#define VCLTOSVCOL( rCol ) (USHORT)((((USHORT)(rCol))<<8)|(rCol)) +#endif + +/************************************************************************/ + +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, long nIndex) +|* +|* Beschreibung +|* Ersterstellung 14.11.94 +|* Letzte Aenderung 14.11.94 +|* +*************************************************************************/ + +NameOrIndex::NameOrIndex(USHORT nWhich, long 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((long)-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 << (INT32)nPalIndex; + return rOut; +} + +// ------------------- +// class XColorItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XColorItem, NameOrIndex); + +/************************************************************************* +|* +|* XColorItem::XColorItem(USHORT nWhich, long nIndex, const Color& rTheColor) +|* +\************************************************************************/ + +XColorItem::XColorItem(USHORT nWhich, long 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::GetValue(const XColorTable* pTable) const +|* +\************************************************************************/ + +const Color& XColorItem::GetValue(const XColorTable* pTable) const +{ + if (!IsIndex()) + return aColor; + else + return pTable->Get(GetIndex())->GetColor(); + +} + +sal_Bool XColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + rVal <<= (sal_Int32)GetValue().GetRGBColor(); + return sal_True; +} + +sal_Bool XColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + sal_Int32 nValue; + rVal >>= nValue; + SetValue( 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, 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 International * +) 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; + } + } + 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 )) + return sal_False; + + SetValue( (XLineStyle)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 +|* +*************************************************************************/ + +int 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 ); +} + + +// ------------------- +// class XLineDashItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XLineDashItem, NameOrIndex); + +/************************************************************************* +|* +|* XLineDashItem::XLineDashItem(long nIndex, const XDash& rTheDash) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineDashItem::XLineDashItem(long 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::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::GetValue(const XDashTable* pTable) const +{ + if (!IsIndex()) + return aDash; + else + return pTable->Get(GetIndex())->GetDash(); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineDashItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const International * +) 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; + } + 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 +{ + const XDash& rXD = GetValue(); + + ::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; + + return sal_True; +} + +sal_Bool XLineDashItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + ::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); + + SetValue( aXDash ); + return sal_True; +} + + +// ------------------- +// 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 International * +) 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); + rText += SVX_RESSTR( GetMetricId( ePresUnit) ); + return ePres; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +sal_Bool XLineWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + rVal <<= (sal_Int32)GetValue(); + return sal_True; +} + +sal_Bool XLineWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + sal_Int32 nValue; + rVal >>= nValue; + + SetValue( nValue ); + return sal_True; +} + +// ------------------- +// class XLineColorItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XLineColorItem, XColorItem); + +/************************************************************************* +|* +|* XLineColorItem::XLineColorItem(long nIndex, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XLineColorItem::XLineColorItem(long 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 International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +sal_Bool XLineColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + rVal <<= (sal_Int32)GetValue().GetRGBColor(); + return sal_True; +} + +sal_Bool XLineColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + sal_Int32 nValue; + if(!(rVal >>= nValue)) + return sal_False; + + SetValue( nValue ); + return sal_True; +} + +// ----------------------- +// class XLineStartItem +// ----------------------- +TYPEINIT1_AUTOFACTORY(XLineStartItem, NameOrIndex); + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(long nIndex) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(long nIndex) : + NameOrIndex(XATTR_LINESTART, nIndex) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(const XubString& rName, +|* const XPolygon& rXPolygon) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(const XubString& rName, + const XPolygon& rXPolygon): + NameOrIndex(XATTR_LINESTART, rName), + aXPolygon(rXPolygon) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(const XLineStartItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(const XLineStartItem& rItem) : + NameOrIndex(rItem), + aXPolygon(rItem.aXPolygon) +{ +} + +/************************************************************************* +|* +|* XLineStartItem::XLineStartItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XLineStartItem::XLineStartItem(SvStream& rIn) : + NameOrIndex(XATTR_LINESTART, rIn) +{ + if (!IsIndex()) + { + UINT32 nPoints; + INT32 nFlags; + rIn >> nPoints; + aXPolygon.SetSize((USHORT)nPoints); + for (USHORT nIndex = 0; nIndex < (USHORT)nPoints; nIndex++) + { + rIn >> aXPolygon[nIndex].X(); + rIn >> aXPolygon[nIndex].Y(); + rIn >> nFlags; aXPolygon.SetFlags(nIndex, (XPolyFlags)nFlags); + } + } +} + +/************************************************************************* +|* +|* 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).aXPolygon == aXPolygon ); +} + +/************************************************************************* +|* +|* 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()) + { + UINT32 nPoints = (UINT32)aXPolygon.GetPointCount(); + rOut << nPoints; + for (USHORT nIndex = 0; nIndex < (USHORT)nPoints; nIndex++) + { + rOut << aXPolygon[nIndex].X(); + rOut << aXPolygon[nIndex].Y(); + rOut << (INT32)aXPolygon.GetFlags(nIndex); + } + } + + return rOut; +} + +/************************************************************************* +|* +|* const XPolygon& XLineStartItem::GetValue(const XLineEndTable* pTable) +|* const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +const XPolygon& XLineStartItem::GetValue(const XLineEndTable* pTable) const +{ + if (!IsIndex()) + return aXPolygon; + else + return pTable->Get(GetIndex())->GetLineEnd(); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineStartItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +sal_Bool XLineStartItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + if( nMemberId == MID_NAME ) + { + rVal <<= ::rtl::OUString( GetName() ); + } + else + { + rVal.clear(); + + const UINT16 nCount = aXPolygon.GetPointCount(); + if( nCount != 0 ) + { + ::com::sun::star::drawing::PointSequence aLineStartEnd(nCount); + + ::com::sun::star::awt::Point* pMemAddr = aLineStartEnd.getArray(); + + // XPolygon aXPolygon in aLineStartEnd kopieren + for(UINT16 a=0;a<nCount;a++) + *pMemAddr++ = ::com::sun::star::awt::Point( aXPolygon[a].X(), aXPolygon[a].Y() ); + + + rVal <<= aLineStartEnd; + } + } + + return sal_True; +} + +sal_Bool XLineStartItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + if( !rVal.hasValue() ) + { + aXPolygon.SetSize( 0 ); + } + else + { + ::com::sun::star::drawing::PointSequence aLinePolygon; + if(!(rVal >>= aLinePolygon)) + return sal_False; + + sal_Int32 nPointCount = aLinePolygon.getLength(); + + aXPolygon.SetSize((UINT16)nPointCount); + ::com::sun::star::awt::Point* pMemAddr = aLinePolygon.getArray(); + + for(UINT32 a=0;a<nPointCount;a++) + { + aXPolygon[a] = Point( pMemAddr->X, pMemAddr->Y ); + pMemAddr++; + } + } + + return sal_False; +} + + +// --------------------- +// class XLineEndItem +// --------------------- +TYPEINIT1_AUTOFACTORY(XLineEndItem, NameOrIndex); + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(long nIndex) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(long nIndex) : + NameOrIndex(XATTR_LINEEND, nIndex) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(const XubString& rName, +|* const XPolygon& rXPolygon) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(const XubString& rName, const XPolygon& rPolygon) : + NameOrIndex(XATTR_LINEEND, rName), + aXPolygon(rPolygon) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(const XLineEndItem& rItem) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(const XLineEndItem& rItem) : + NameOrIndex(rItem), + aXPolygon(rItem.aXPolygon) +{ +} + +/************************************************************************* +|* +|* XLineEndItem::XLineEndItem(SvStream& rIn) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 17.11.94 +|* +*************************************************************************/ + +XLineEndItem::XLineEndItem(SvStream& rIn) : + NameOrIndex(XATTR_LINEEND, rIn) +{ + if (!IsIndex()) + { + UINT32 nPoints; + INT32 nFlags; + rIn >> nPoints; + aXPolygon.SetSize((USHORT)nPoints); + for (USHORT nIndex = 0; nIndex < (USHORT)nPoints; nIndex++) + { + rIn >> aXPolygon[nIndex].X(); + rIn >> aXPolygon[nIndex].Y(); + rIn >> nFlags; aXPolygon.SetFlags(nIndex, (XPolyFlags)nFlags); + } + } +} + +/************************************************************************* +|* +|* 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).aXPolygon == aXPolygon ); +} + +/************************************************************************* +|* +|* 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()) + { + UINT32 nPoints = (UINT32)aXPolygon.GetPointCount(); + rOut << nPoints; + for (USHORT nIndex = 0; nIndex < (USHORT)nPoints; nIndex++) + { + rOut << aXPolygon[nIndex].X(); + rOut << aXPolygon[nIndex].Y(); + rOut << (INT32)aXPolygon.GetFlags(nIndex); + } + } + + return rOut; +} + +/************************************************************************* +|* +|* const XPolygon& XLineEndItem::GetValue(const XLineEndTable* pTable) const +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 18.11.94 +|* +*************************************************************************/ + +const XPolygon& XLineEndItem::GetValue(const XLineEndTable* pTable) const +{ + if (!IsIndex()) + return aXPolygon; + else + return pTable->Get(GetIndex())->GetLineEnd(); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XLineEndItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +sal_Bool XLineEndItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + if( nMemberId == MID_NAME ) + { + rVal <<= ::rtl::OUString( GetName() ); + } + else + { + rVal.clear(); + + const UINT16 nCount = aXPolygon.GetPointCount(); + if( nCount != 0 ) + { + ::com::sun::star::drawing::PointSequence aLineStartEnd(nCount); + + ::com::sun::star::awt::Point* pMemAddr = aLineStartEnd.getArray(); + + // XPolygon aXPolygon in aLineStartEnd kopieren + for(UINT16 a=0;a<nCount;a++) + { + *pMemAddr++ = ::com::sun::star::awt::Point( aXPolygon[a].X(), aXPolygon[a].Y() ); + } + + rVal <<= aLineStartEnd; + } + } + + return sal_True; +} + +sal_Bool XLineEndItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + if( !rVal.hasValue() ) + { + aXPolygon.SetSize( 0 ); + } + else + { + ::com::sun::star::drawing::PointSequence aLinePolygon; + if(!(rVal >>= aLinePolygon)) + return sal_False; + + sal_Int32 nPointCount = aLinePolygon.getLength(); + + aXPolygon.SetSize((UINT16)nPointCount); + ::com::sun::star::awt::Point* pMemAddr = aLinePolygon.getArray(); + + for(UINT32 a=0;a<nPointCount;a++) + { + aXPolygon[a] = Point( pMemAddr->X, pMemAddr->Y ); + pMemAddr++; + } + } + + return sal_True; +} + + +// ---------------------------- +// class XLineStartWidthItem +// ---------------------------- +TYPEINIT1_AUTOFACTORY(XLineStartWidthItem, SfxMetricItem); + +/************************************************************************* +|* +|* XLineStartWidthItem::XLineStartWidthItem(long 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 International * +) 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); + rText += SVX_RESSTR( GetMetricId( ePresUnit) ); + return ePres; + } + 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; + 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 International * +) 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); + rText += SVX_RESSTR( GetMetricId( ePresUnit) ); + return ePres; + } + 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; + 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 International * +) 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; + } + 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 International * +) 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; + } + 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, 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 International * +) 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; + } + } + 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)) + return sal_False; + + SetValue( (XFillStyle)eFS ); + + return sal_True; +} + + +// ------------------- +// class XFillColorItem +// ------------------- +TYPEINIT1_AUTOFACTORY(XFillColorItem, XColorItem); + +/************************************************************************* +|* +|* XFillColorItem::XFillColorItem(long nIndex, const Color& rTheColor) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillColorItem::XFillColorItem(long 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 International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +// ----------------------------------------------------------------------- + +sal_Bool XFillColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + rVal <<= (sal_Int32)GetValue().GetRGBColor(); + + return sal_True; +} + +// ----------------------------------------------------------------------- + +sal_Bool XFillColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + sal_Int32 nValue; + if(!(rVal >>= nValue )) + return sal_False; + + SetValue( nValue ); + return sal_True; +} + + + +// ---------------- +// class XGradient +// ---------------- + +/************************************************************************* +|* +|* 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) : + aStartColor(rStart), + aEndColor(rEnd), + eStyle(eTheStyle), + 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 +|* +*************************************************************************/ + +int 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(long nIndex, +|* const XGradient& rTheGradient) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillGradientItem::XFillGradientItem(long 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; +#ifdef VCL + Color aCol; + aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) ); +#else + Color aCol( COL_USER ); + aCol = Color( nRed, nGreen, nBlue ); + aCol.SetColorName(COL_USER); +#endif + aGradient.SetStartColor( aCol ); + + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) ); +#else + aCol = Color( nRed, nGreen, nBlue ); + aCol.SetColorName(COL_USER); +#endif + 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::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(); + +#ifdef VCL + 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; +#else + rOut << aGradient.GetStartColor().GetRed(); + rOut << aGradient.GetStartColor().GetGreen(); + rOut << aGradient.GetStartColor().GetBlue(); + rOut << aGradient.GetEndColor().GetRed(); + rOut << aGradient.GetEndColor().GetGreen(); + rOut << aGradient.GetEndColor().GetBlue(); +#endif + + 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::GetValue(const XGradientTable* pTable) const +{ + if (!IsIndex()) + return aGradient; + else + return pTable->Get(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 International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillGradientItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + if( nMemberId == MID_NAME ) + { + rVal <<= ::rtl::OUString( GetName() ); + } + else + { + const XGradient& aXGradient = GetValue(); + ::com::sun::star::awt::Gradient aGradient; + + aGradient.Style = (::com::sun::star::awt::GradientStyle) aXGradient.GetGradientStyle(); + aGradient.StartColor = (INT32)aXGradient.GetStartColor().GetColor(); + aGradient.EndColor = (INT32)aXGradient.GetEndColor().GetColor(); + aGradient.Angle = aXGradient.GetAngle(); + aGradient.Border = aXGradient.GetBorder(); + aGradient.XOffset = aXGradient.GetXOffset(); + aGradient.YOffset = aXGradient.GetYOffset(); + aGradient.StartIntensity = aXGradient.GetStartIntens(); + aGradient.EndIntensity = aXGradient.GetEndIntens(); + aGradient.StepCount = aXGradient.GetSteps(); + + rVal <<= aGradient; + } + + return sal_True; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillGradientItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + ::com::sun::star::awt::Gradient aGradient; + if(!(rVal >>= aGradient)) + return sal_False; + + XGradient aXGradient; + + aXGradient.SetGradientStyle( (XGradientStyle) aGradient.Style ); + aXGradient.SetStartColor( aGradient.StartColor ); + aXGradient.SetEndColor( aGradient.EndColor ); + aXGradient.SetAngle( aGradient.Angle ); + aXGradient.SetBorder( aGradient.Border ); + aXGradient.SetXOffset( aGradient.XOffset ); + aXGradient.SetYOffset( aGradient.YOffset ); + aXGradient.SetStartIntens( aGradient.StartIntensity ); + aXGradient.SetEndIntens( aGradient.EndIntensity ); + aXGradient.SetSteps( aGradient.StepCount ); + + SetValue( aXGradient ); + + return sal_True; +} + +// ---------------------------------- +// class XFillFloatTransparenceItem - +// ---------------------------------- + +TYPEINIT1_AUTOFACTORY( XFillFloatTransparenceItem, XFillGradientItem ); + +// ----------------------------------------------------------------------------- + +XFillFloatTransparenceItem::XFillFloatTransparenceItem() : + bEnabled( FALSE ) +{ + SetWhich( XATTR_FILLFLOATTRANSPARENCE ); +} + +//------------------------------------------------------------------------ + +XFillFloatTransparenceItem::XFillFloatTransparenceItem( long 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; +} + +//------------------------------------------------------------------------ + +int XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const +{ + return( XFillGradientItem::operator==( rItem ) && + 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 International * pInternational ) const +{ + return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, pInternational ); +} + +// ------------- +// 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) : + aColor(rCol), + eStyle(eTheStyle), + nDistance(nTheDistance), + nAngle(nTheAngle) +{ +} + +/************************************************************************* +|* +|* int XHatch::operator==(const SfxPoolItem& rItem) const +|* +|* Beschreibung +|* Ersterstellung 29.11.94 +|* Letzte Aenderung 29.11.94 +|* +*************************************************************************/ + +int 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(long nIndex, +|* const XHatch& rTheHatch) +|* +|* Beschreibung +|* Ersterstellung 15.11.94 +|* Letzte Aenderung 15.11.94 +|* +*************************************************************************/ + +XFillHatchItem::XFillHatchItem(long 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; + +#ifdef VCL + Color aCol; + aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) ); +#else + Color aCol( COL_USER ); + aCol = Color( nRed, nGreen, nBlue ); + aCol.SetColorName(COL_USER); +#endif + aHatch.SetColor(aCol); + rIn >> nLTemp; aHatch.SetDistance(nLTemp); + rIn >> nLTemp; aHatch.SetAngle(nLTemp); + } +} + +/************************************************************************* +|* +|* 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(); + +#ifdef VCL + USHORT nTmp; + nTmp = VCLTOSVCOL( aHatch.GetColor().GetRed() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aHatch.GetColor().GetGreen() ); rOut << nTmp; + nTmp = VCLTOSVCOL( aHatch.GetColor().GetBlue() ); rOut << nTmp; +#else + rOut << aHatch.GetColor().GetRed(); + rOut << aHatch.GetColor().GetGreen(); + rOut << aHatch.GetColor().GetBlue(); +#endif + + 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::GetValue(const XHatchTable* pTable) const +{ + if (!IsIndex()) + return aHatch; + else + return pTable->Get(GetIndex())->GetHatch(); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation XFillHatchItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, const International * +) 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; + } + 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 +{ + if( nMemberId == MID_NAME ) + { + rVal <<= ::rtl::OUString( GetName() ); + } + else + { + ::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; + } + + return sal_True; +} + +// ----------------------------------------------------------------------- +sal_Bool XFillHatchItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + ::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 ); + return sal_True; +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// 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, 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; +} + + +//------------------------- +// 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, 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; +} + + +//---------------------------- +// 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, 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; +} + + +// ------------------------------- +// class XFormTextShadowColorItem +// ------------------------------- +TYPEINIT1_AUTOFACTORY(XFormTextShadowColorItem, XColorItem); + +/************************************************************************* +|* +|* XFormTextShadowColorItem::XFormTextShadowColorItem() +|* +|* Beschreibung +|* Ersterstellung 27.06.95 +|* Letzte Aenderung 27.06.95 +|* +*************************************************************************/ + +XFormTextShadowColorItem::XFormTextShadowColorItem(long 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, 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; +} + + +// -------------------------- +// 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 *pSet = new SfxItemSet( *GetItemSet().GetPool(), + XATTR_LINE_FIRST, XATTR_LINE_LAST); + pSet->Load( rStream ); + return new XLineAttrSetItem( pSet ); +} + +/************************************************************************* +|* +|* 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 *pSet = new SfxItemSet( *GetItemSet().GetPool(), + XATTR_FILL_FIRST, XATTR_FILL_LAST); + pSet->Load( rStream ); + return new XFillAttrSetItem( pSet ); +} + +/************************************************************************* +|* +|* SetItem in Stream speichern +|* +\************************************************************************/ + +SvStream& XFillAttrSetItem::Store( SvStream& rStream, USHORT nItemVersion ) const +{ + return SfxSetItem::Store( rStream, nItemVersion ); +} + + +TYPEINIT1(XTextAttrSetItem, SfxSetItem); + +/************************************************************************* +|* +|* Konstruktoren fuer Textattribute-SetItem +|* +\************************************************************************/ + +XTextAttrSetItem::XTextAttrSetItem( SfxItemSet* pItemSet ) : + SfxSetItem( XATTRSET_TEXT, pItemSet) +{ +} + +/************************************************************************/ + +XTextAttrSetItem::XTextAttrSetItem( SfxItemPool* pItemPool ) : + SfxSetItem( XATTRSET_TEXT, + new SfxItemSet( *pItemPool, XATTR_TEXT_FIRST, XATTR_TEXT_LAST)) +{ +} + +/************************************************************************/ + +XTextAttrSetItem::XTextAttrSetItem( const XTextAttrSetItem& rTextAttr ) : + SfxSetItem( rTextAttr ) +{ +} + +/************************************************************************/ + +XTextAttrSetItem::XTextAttrSetItem( const XTextAttrSetItem& rTextAttr, + SfxItemPool* pItemPool ) : + SfxSetItem( rTextAttr, pItemPool ) +{ +} + +/************************************************************************* +|* +|* Clone-Funktion +|* +\************************************************************************/ + +SfxPoolItem* XTextAttrSetItem::Clone( SfxItemPool* pPool ) const +{ + return new XTextAttrSetItem( *this, pPool ); +} + +/************************************************************************* +|* +|* SetItem aus Stream erzeugen +|* +\************************************************************************/ + +SfxPoolItem* XTextAttrSetItem::Create( SvStream& rStream, USHORT nVersion ) const +{ + SfxItemSet *pSet = new SfxItemSet( *GetItemSet().GetPool(), + XATTR_TEXT_FIRST, XATTR_TEXT_LAST); + pSet->Load( rStream ); + return new XTextAttrSetItem( pSet ); +} + +/************************************************************************* +|* +|* SetItem in Stream speichern +|* +\************************************************************************/ + +SvStream& XTextAttrSetItem::Store( SvStream& rStream, USHORT nItemVersion ) const +{ + return SfxSetItem::Store( rStream, nItemVersion ); +} + + + + diff --git a/svx/source/xoutdev/xattr2.cxx b/svx/source/xoutdev/xattr2.cxx new file mode 100644 index 000000000000..994cddebeb90 --- /dev/null +++ b/svx/source/xoutdev/xattr2.cxx @@ -0,0 +1,1742 @@ +/************************************************************************* + * + * $RCSfile: xattr2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#pragma hdrstop + +#ifndef _COM_SUN_STAR_DRAWING_LINEJOINT_HPP_ +#include <com/sun/star/drawing/LineJoint.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + +#include "dialogs.hrc" +#include "xattr.hxx" +#include "xtable.hxx" +#include "xoutx.hxx" +#include "dialmgr.hxx" +#include "itemtype.hxx" +#include "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 International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//----------------------- +// class XLineJointItem - +//----------------------- + +TYPEINIT1_AUTOFACTORY(XLineJointItem, SfxEnumItem); + +// ----------------------------------------------------------------------------- + +XLineJointItem::XLineJointItem( XLineJoint eLineJoint ) : + SfxEnumItem(XATTR_LINEJOINT, 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 International*) 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; + } + } + + 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)) + return sal_False; + + switch( eUnoJoint ) + { + case ::com::sun::star::drawing::LineJoint_NONE: + break; + 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; + } + + SetValue( 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 International * +) 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; + } + 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 International * +) 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; + } + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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, 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International * +) const +{ + rText.Erase(); + + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + } + + 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 International*) const +{ + rText.Erase(); + + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + return ePres; + break; + + case SFX_ITEM_PRESENTATION_COMPLETE: + case SFX_ITEM_PRESENTATION_NAMELESS: + return ePres; + break; + } + + 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..189b2658e11d --- /dev/null +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -0,0 +1,801 @@ +/************************************************************************* + * + * $RCSfile: xattrbmp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <com/sun/star/awt/XBitmap.hpp> +#include <tools/stream.hxx> +#include <vcl/window.hxx> +#include <vcl/virdev.hxx> +#include <vcl/bitmapex.hxx> +#include <toolkit/unohlp.hxx> +#include "xattr.hxx" +#include "xtable.hxx" +#include "xoutx.hxx" +#include "xdef.hxx" +#include "unomid.hxx" +#include "unoprnms.hxx" +#include "unoapi.hxx" + +#define GLOBALOVERFLOW + +// --------------- +// 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; + BOOL bPixelColor = FALSE; + 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; + } + } + } +} + +/************************************************************************* +|* +|* 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::GetValue(const XBitmapTable* pTable) const +{ + if (!IsIndex()) + return aXOBitmap; + else + return pTable->Get(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 International * +) 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; + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//------------------------------------------------------------------------ + +sal_Bool XFillBitmapItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + if( nMemberId == MID_NAME ) + { + rVal <<= ::rtl::OUString( GetName() ); + } + else if( nMemberId == MID_GRAFURL ) + { + XOBitmap aXOBitmap( GetValue() ); + ::rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); + aURL += ::rtl::OUString::createFromAscii( aXOBitmap.GetGraphicObject().GetUniqueID().GetBuffer() ); + rVal <<= aURL; + } + else + { + XOBitmap aXOBitmap( GetValue() ); + Bitmap aBmp( aXOBitmap.GetBitmap() ); + BitmapEx aBmpEx( aBmp ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp( + VCLUnoHelper::CreateBitmap( aBmpEx ) ); + + rVal <<= xBmp; + } + + return sal_True; +} + +//------------------------------------------------------------------------ + +sal_Bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + if( nMemberId == MID_NAME ) + { + ::rtl::OUString aName; + if(rVal >>= aName) + { + SetName( aName ); + return sal_True; + } + } +#ifndef SVX_LIGHT + else if( nMemberId == MID_GRAFURL ) + { + ::rtl::OUString aURL; + if(rVal >>= aURL) + { + GraphicObject aGrafObj( CreateGraphicObjectFromURL( aURL ) ); + XOBitmap aBMP( aGrafObj ); + SetValue( aBMP ); + return sal_True; + } + } +#endif + else + { + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; + if( rVal >>= xBmp) + { + BitmapEx aInputEx( VCLUnoHelper::GetBitmap( xBmp ) ); + Bitmap aInput( aInputEx.GetBitmap() ); + + // Bitmap einsetzen + 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 sal_True; + } + } + return sal_False; +} + + + diff --git a/svx/source/xoutdev/xexch.cxx b/svx/source/xoutdev/xexch.cxx new file mode 100644 index 000000000000..20ab2786987c --- /dev/null +++ b/svx/source/xoutdev/xexch.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * $RCSfile: xexch.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#ifndef _CLIP_HXX +#include <vcl/clip.hxx> +#endif +#ifndef _DRAG_HXX +#include <vcl/drag.hxx> +#endif +#ifndef _SVX_XFLASIT_HXX +#include <xflasit.hxx> +#endif +#ifndef SVX_XFILLIT0_HXX +#include <xfillit0.hxx> +#endif +#ifndef _SFXIPOOL_HXX +#include <svtools/itempool.hxx> +#endif +#ifndef _SFXIPOOL_HXX +#include <svtools/itempool.hxx> +#endif +#ifndef _SFXITEMSET_HXX +#include <svtools/itemset.hxx> +#endif +#include "xdef.hxx" +#include "xexch.hxx" + + +TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream ); + + +/************************************************************************* +|* +|* Default-Ctor (Fuer Assign()) +|* +*************************************************************************/ +XFillExchangeData::XFillExchangeData() : + pPool(NULL), + pXFillAttrSetItem(NULL) +{ +} + + +/************************************************************************* +|* +|* Ctor +|* +*************************************************************************/ +XFillExchangeData::XFillExchangeData(const XFillAttrSetItem rXFillAttrSetItem) : + pPool(NULL), + pXFillAttrSetItem(NULL) +{ + const SfxItemSet& rSet = rXFillAttrSetItem.GetItemSet(); + const XFillStyleItem& rItem = (const XFillStyleItem&) rSet.Get(XATTR_FILLSTYLE); + pPool = rSet.GetPool(); + + pXFillAttrSetItem = (XFillAttrSetItem*) rXFillAttrSetItem.Clone(pPool); +} + + +/************************************************************************* +|* +|* Dtor +|* +*************************************************************************/ +XFillExchangeData::~XFillExchangeData() +{ + delete pXFillAttrSetItem; +} + + +/************************************************************************* +|* +|* Laden +|* +*************************************************************************/ +void XFillExchangeData::Load( SvStream& rIStm ) +{ + rIStm >> *this; +} + + +/************************************************************************* +|* +|* Speichern +|* +*************************************************************************/ +void XFillExchangeData::Save( SvStream& rOStm ) +{ + rOStm << *this; +} + + +/************************************************************************* +|* +|* Zuweisen +|* +*************************************************************************/ +void XFillExchangeData::Assign( const SvDataCopyStream& rCopyStream ) +{ + *this = (const XFillExchangeData& ) rCopyStream; +} + + +/************************************************************************* +|* +|* +|* +*************************************************************************/ +ULONG XFillExchangeData::RegisterClipboardFormatName() +{ + static ULONG nFormat = 0; + + if ( !nFormat ) + { + String aName("XFA (XOutDev FillAttr)", gsl_getSystemTextEncoding()); + nFormat = Clipboard::RegisterFormatName( aName ); + } + + return nFormat; +} + + +/****************************************************************************** +|* +|* Binaer-Export (z.Z. ohne Versionsverwaltung, da nicht persistent!) +|* +\******************************************************************************/ + +SvStream& operator<<( SvStream& rOStm, const XFillExchangeData& rData ) +{ + USHORT nItemVersion = rData.pXFillAttrSetItem->GetVersion( (USHORT) rOStm.GetVersion() ); + rData.pXFillAttrSetItem->Store( rOStm, nItemVersion ); + return rOStm; +} + + +/****************************************************************************** +|* +|* Binaer-Import (z.Z. ohne Versionsverwaltung, da nicht persistent!) +|* +\******************************************************************************/ + +SvStream& operator>>( SvStream& rIStm, XFillExchangeData& rData ) +{ + SfxItemSet* pSet = new SfxItemSet(*rData.pPool, + XATTR_FILL_FIRST, XATTR_FILL_LAST); + pSet->Load( rIStm ); + rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet ); + + return rIStm; +} + + + +/************************************************************************* +|* +|* XBitmap& XBitmap::operator=( const XBitmap& rXBmp ) +|* +*************************************************************************/ + +XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData ) +{ + pXFillAttrSetItem = (XFillAttrSetItem*) rData.pXFillAttrSetItem->Clone(pPool); + + return( *this ); +} + + diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx new file mode 100644 index 000000000000..bb3d17d9a5cc --- /dev/null +++ b/svx/source/xoutdev/xpool.cxx @@ -0,0 +1,475 @@ +/************************************************************************* + * + * $RCSfile: xpool.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#include "xtable.hxx" +#include "xattr.hxx" +#include "xpool.hxx" +#include "svdattr.hxx" +#include "svxids.hrc" + +#define GLOBALOVERFLOW3 + +static USHORT nVersion1Map[40]; +static USHORT nVersion2Map[66]; +static USHORT nVersion3Map[124]; +static USHORT nVersion4Map[141]; + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + + +XOutdevItemPool::XOutdevItemPool(USHORT nAttrStart, USHORT nAttrEnd, FASTBOOL bLoadRefCounts): + SfxItemPool(String("XOutdevItemPool", gsl_getSystemTextEncoding()), nAttrStart, nAttrEnd, NULL, NULL, bLoadRefCounts) +{ + Ctor(NULL,nAttrStart,nAttrEnd); +} + + +XOutdevItemPool::XOutdevItemPool(SfxItemPool* pMaster, USHORT nAttrStart, USHORT nAttrEnd, FASTBOOL bLoadRefCounts): + SfxItemPool(String("XOutdevItemPool", gsl_getSystemTextEncoding()), nAttrStart, nAttrEnd, NULL, NULL, bLoadRefCounts) +{ + Ctor(pMaster,nAttrStart,nAttrEnd); +} + + +void XOutdevItemPool::Ctor(SfxItemPool* pMaster, USHORT nAttrStart, USHORT nAttrEnd) +{ + // Mich als Secondary an den MasterPool (Joe) + if (pMaster==NULL) { + pMaster=this; + } else { + // Ich ganz hinten dran + SfxItemPool* pParent=pMaster; + while (pParent->GetSecondaryPool()!=NULL) { + pParent=pParent->GetSecondaryPool(); + } + pParent->SetSecondaryPool(this); + } + + SfxItemSet* pSet; + + nStart=nAttrStart; + nEnd =nAttrEnd; + ppPoolDefaults = new SfxPoolItem* [nEnd-nStart+1]; + + USHORT i; + + // Am 27-06-1995 hat Elmar 13 neue Whiches fuer XATTR_FORMTXT bei Which 1021 + // eingebaut. + // Alles was zu diesem Zeitpunkt >1021 war verschiebt sich also um + // 13 Positionen nach hinten. + // Alles was davor liegt (11 LineItems, 6 FillItems, 5 von 6 FormTextItems) + // behaelt seine WhichId. + + for (i=1000; i<=1021; i++) { + nVersion1Map[i-1000]=i; + } + for (i=1022; i<=1039; i++) { + nVersion1Map[i-1000]=i+13; + } + SetVersionMap(1,1000,1039,nVersion1Map); + + // Am 09-11-1995 haben dann wiederum Kai Ahrens 14 und Joe 44 (also beide + // insgesamt 58) neue Whiches an verschiedenen Stellen spendiert (siehe + // auch die Beschreibung in svx\inc\SvdAttr.HXX). + + for (i=1000; i<=1009; i++) { // XOut + nVersion2Map[i-1000]=i; + } + for (i=1010; i<=1015; i++) { // XOut + nVersion2Map[i-1000]=i+7; + } + for (i=1016; i<=1035; i++) { // XOut + nVersion2Map[i-1000]=i+14; + } + for (i=1036; i<=1039; i++) { // SvDraw + nVersion2Map[i-1000]=i+14; + } + for (i=1040; i<=1050; i++) { // SvDraw + nVersion2Map[i-1000]=i+22; + } + for (i=1051; i<=1056; i++) { // SvDraw + nVersion2Map[i-1000]=i+27; + } + for (i=1057; i<=1065; i++) { // SvDraw + nVersion2Map[i-1000]=i+52; + } + SetVersionMap(2,1000,1065,nVersion2Map); + + + // Am 29-02-1996 hat KA 17 neue Whiches + // fuer das XOut spendiert + + for (i=1000; i<=1029; i++) { + nVersion3Map[i-1000]=i; + } + for (i=1030; i<=1123; i++) { + nVersion3Map[i-1000]=i+17; + } + SetVersionMap(3,1000,1123,nVersion3Map); + + + // Am 10-08-1996 hat Joe 45 neue Items in SvDraw eingebaut + // fuer Bemassung, Verbinder und Laufschrift + + for (i=1000; i<=1126; i++) { + nVersion4Map[i-1000]=i; + } + for (i=1127; i<=1140; i++) { + nVersion4Map[i-1000]=i+45; + } + SetVersionMap(4,1000,1140,nVersion4Map); + + + XubString aNullStr; + Bitmap aNullBmp; + XPolygon aNullPol; + Color aNullLineCol(RGB_Color(COL_BLACK)); + +#ifndef VCL + Color aNullFillCol(Color(0<<8,184<<8,255<<8)); // "Blau 7" +#else + Color aNullFillCol(Color(0,184,255)); // "Blau 7" +#endif + + Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY)); + XDash aNullDash; + XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE)); + XHatch aNullHatch(aNullLineCol); + + // LineItems + ppPoolDefaults[XATTR_LINESTYLE -XATTR_START] = new XLineStyleItem; + ppPoolDefaults[XATTR_LINEDASH -XATTR_START] = new XLineDashItem(aNullStr,aNullDash); + ppPoolDefaults[XATTR_LINEWIDTH -XATTR_START] = new XLineWidthItem; + ppPoolDefaults[XATTR_LINECOLOR -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol); + ppPoolDefaults[XATTR_LINESTART -XATTR_START] = new XLineStartItem(aNullStr,aNullPol); + ppPoolDefaults[XATTR_LINEEND -XATTR_START] = new XLineEndItem (aNullStr,aNullPol); + ppPoolDefaults[XATTR_LINESTARTWIDTH -XATTR_START] = new XLineStartWidthItem; + ppPoolDefaults[XATTR_LINEENDWIDTH -XATTR_START] = new XLineEndWidthItem; + ppPoolDefaults[XATTR_LINESTARTCENTER -XATTR_START] = new XLineStartCenterItem; + ppPoolDefaults[XATTR_LINEENDCENTER -XATTR_START] = new XLineEndCenterItem; + ppPoolDefaults[XATTR_LINETRANSPARENCE -XATTR_START] = new XLineTransparenceItem; + ppPoolDefaults[XATTR_LINEJOINT -XATTR_START] = new XLineJointItem; + + // Reserven fuer LineItems + ppPoolDefaults[XATTR_LINERESERVED2 -XATTR_START] = new SfxVoidItem(XATTR_LINERESERVED2); + ppPoolDefaults[XATTR_LINERESERVED3 -XATTR_START] = new SfxVoidItem(XATTR_LINERESERVED3); + ppPoolDefaults[XATTR_LINERESERVED4 -XATTR_START] = new SfxVoidItem(XATTR_LINERESERVED4); + ppPoolDefaults[XATTR_LINERESERVED5 -XATTR_START] = new SfxVoidItem(XATTR_LINERESERVED5); + ppPoolDefaults[XATTR_LINERESERVED_LAST -XATTR_START] = new SfxVoidItem(XATTR_LINERESERVED_LAST); + + // FillItems + ppPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem; + ppPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol); + ppPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(aNullStr,aNullGrad); + ppPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (aNullStr,aNullHatch); + ppPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (aNullStr,aNullBmp); + ppPoolDefaults[XATTR_FILLTRANSPARENCE -XATTR_START] = new XFillTransparenceItem; + ppPoolDefaults[XATTR_GRADIENTSTEPCOUNT -XATTR_START] = new XGradientStepCountItem; + ppPoolDefaults[XATTR_FILLBMP_TILE -XATTR_START] = new XFillBmpTileItem; + ppPoolDefaults[XATTR_FILLBMP_POS -XATTR_START] = new XFillBmpPosItem; + ppPoolDefaults[XATTR_FILLBMP_SIZEX -XATTR_START] = new XFillBmpSizeXItem; + ppPoolDefaults[XATTR_FILLBMP_SIZEY -XATTR_START] = new XFillBmpSizeYItem; + ppPoolDefaults[XATTR_FILLBMP_SIZELOG -XATTR_START] = new XFillBmpSizeLogItem; + ppPoolDefaults[XATTR_FILLBMP_TILEOFFSETX -XATTR_START] = new XFillBmpTileOffsetXItem; + ppPoolDefaults[XATTR_FILLBMP_TILEOFFSETY -XATTR_START] = new XFillBmpTileOffsetYItem; + ppPoolDefaults[XATTR_FILLBMP_STRETCH -XATTR_START] = new XFillBmpStretchItem; + ppPoolDefaults[XATTR_FILLBMP_POSOFFSETX -XATTR_START] = new XFillBmpPosOffsetXItem; + ppPoolDefaults[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = new XFillBmpPosOffsetYItem; + ppPoolDefaults[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = new XFillFloatTransparenceItem( aNullStr, aNullGrad, FALSE ); + + // Reserven fuer FillItems + ppPoolDefaults[XATTR_FILLRESERVED2 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED2); + ppPoolDefaults[XATTR_FILLRESERVED3 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED3); + ppPoolDefaults[XATTR_FILLRESERVED4 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED4); + ppPoolDefaults[XATTR_FILLRESERVED5 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED5); + ppPoolDefaults[XATTR_FILLRESERVED6 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED6); + ppPoolDefaults[XATTR_FILLRESERVED7 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED7); + ppPoolDefaults[XATTR_FILLRESERVED8 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED8); + ppPoolDefaults[XATTR_FILLBACKGROUND -XATTR_START] = new XFillBackgroundItem; + ppPoolDefaults[XATTR_FILLRESERVED10 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED10); + ppPoolDefaults[XATTR_FILLRESERVED11 -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED11); + ppPoolDefaults[XATTR_FILLRESERVED_LAST -XATTR_START] = new SfxVoidItem(XATTR_FILLRESERVED_LAST); + + // FormTextItems + ppPoolDefaults[XATTR_FORMTXTSTYLE -XATTR_START] = new XFormTextStyleItem; + ppPoolDefaults[XATTR_FORMTXTADJUST -XATTR_START] = new XFormTextAdjustItem; + ppPoolDefaults[XATTR_FORMTXTDISTANCE -XATTR_START] = new XFormTextDistanceItem; + ppPoolDefaults[XATTR_FORMTXTSTART -XATTR_START] = new XFormTextStartItem; + ppPoolDefaults[XATTR_FORMTXTMIRROR -XATTR_START] = new XFormTextMirrorItem; + ppPoolDefaults[XATTR_FORMTXTOUTLINE -XATTR_START] = new XFormTextOutlineItem; + ppPoolDefaults[XATTR_FORMTXTSHADOW -XATTR_START] = new XFormTextShadowItem; + ppPoolDefaults[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol); + ppPoolDefaults[XATTR_FORMTXTSHDWXVAL -XATTR_START] = new XFormTextShadowXValItem; + ppPoolDefaults[XATTR_FORMTXTSHDWYVAL -XATTR_START] = new XFormTextShadowYValItem; + ppPoolDefaults[XATTR_FORMTXTSTDFORM -XATTR_START] = new XFormTextStdFormItem; + ppPoolDefaults[XATTR_FORMTXTHIDEFORM -XATTR_START] = new XFormTextHideFormItem; + + // Reserven fuer FormTextItems + ppPoolDefaults[XATTR_FORMTXTSHDWTRANSP -XATTR_START] = new XFormTextShadowTranspItem; + ppPoolDefaults[XATTR_FTRESERVED2 -XATTR_START] = new SfxVoidItem(XATTR_FTRESERVED2); + ppPoolDefaults[XATTR_FTRESERVED3 -XATTR_START] = new SfxVoidItem(XATTR_FTRESERVED3); + ppPoolDefaults[XATTR_FTRESERVED4 -XATTR_START] = new SfxVoidItem(XATTR_FTRESERVED4); + ppPoolDefaults[XATTR_FTRESERVED5 -XATTR_START] = new SfxVoidItem(XATTR_FTRESERVED5); + ppPoolDefaults[XATTR_FTRESERVED_LAST -XATTR_START] = new SfxVoidItem(XATTR_FTRESERVED_LAST); + + // SetItems erzeugen + pSet=new SfxItemSet(*pMaster, XATTR_LINE_FIRST, XATTR_LINE_LAST); + ppPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(pSet); + pSet=new SfxItemSet(*pMaster, XATTR_FILL_FIRST, XATTR_FILL_LAST); + ppPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(pSet); + pSet=new SfxItemSet(*pMaster, XATTR_TEXT_FIRST, XATTR_TEXT_LAST); + ppPoolDefaults[XATTRSET_TEXT - XATTR_START] = new XTextAttrSetItem(pSet); + + // ItemInfos + pItemInfos=new SfxItemInfo[nEnd-nStart+1]; + for (i=nStart; i<=nEnd; i++) { + pItemInfos[i-nStart]._nSID=0; + pItemInfos[i-nStart]._nFlags=SFX_ITEM_POOLABLE; + } + + pItemInfos[XATTR_LINESTYLE -XATTR_START]._nSID = SID_ATTR_LINE_STYLE; + pItemInfos[XATTR_LINEDASH -XATTR_START]._nSID = SID_ATTR_LINE_DASH; + pItemInfos[XATTR_LINEWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH; + pItemInfos[XATTR_LINECOLOR -XATTR_START]._nSID = SID_ATTR_LINE_COLOR; + pItemInfos[XATTR_LINESTART -XATTR_START]._nSID = SID_ATTR_LINE_START; + pItemInfos[XATTR_LINEEND -XATTR_START]._nSID = SID_ATTR_LINE_END; + pItemInfos[XATTR_LINESTARTWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH; + pItemInfos[XATTR_LINEENDWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH; + pItemInfos[XATTR_LINESTARTCENTER -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER; + pItemInfos[XATTR_LINEENDCENTER -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER; + + pItemInfos[XATTR_FILLSTYLE -XATTR_START]._nSID = SID_ATTR_FILL_STYLE; + pItemInfos[XATTR_FILLCOLOR -XATTR_START]._nSID = SID_ATTR_FILL_COLOR; + pItemInfos[XATTR_FILLGRADIENT -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT; + pItemInfos[XATTR_FILLHATCH -XATTR_START]._nSID = SID_ATTR_FILL_HATCH; + pItemInfos[XATTR_FILLBITMAP -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP; + + pItemInfos[XATTR_FORMTXTSTYLE -XATTR_START]._nSID = SID_FORMTEXT_STYLE; + pItemInfos[XATTR_FORMTXTADJUST -XATTR_START]._nSID = SID_FORMTEXT_ADJUST; + pItemInfos[XATTR_FORMTXTDISTANCE -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE; + pItemInfos[XATTR_FORMTXTSTART -XATTR_START]._nSID = SID_FORMTEXT_START; + pItemInfos[XATTR_FORMTXTMIRROR -XATTR_START]._nSID = SID_FORMTEXT_MIRROR; + pItemInfos[XATTR_FORMTXTOUTLINE -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE; + pItemInfos[XATTR_FORMTXTSHADOW -XATTR_START]._nSID = SID_FORMTEXT_SHADOW; + pItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR; + pItemInfos[XATTR_FORMTXTSHDWXVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL; + pItemInfos[XATTR_FORMTXTSHDWYVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL; + pItemInfos[XATTR_FORMTXTSTDFORM -XATTR_START]._nSID = SID_FORMTEXT_STDFORM; + pItemInfos[XATTR_FORMTXTHIDEFORM -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM; + +#if SUPD<355 + pSlotIds = new USHORT[nEnd-nStart+1]; + + pSlotIds[XATTR_LINESTYLE -XATTR_START] = SID_ATTR_LINE_STYLE; + pSlotIds[XATTR_LINEDASH -XATTR_START] = SID_ATTR_LINE_DASH; + pSlotIds[XATTR_LINEWIDTH -XATTR_START] = SID_ATTR_LINE_WIDTH; + pSlotIds[XATTR_LINECOLOR -XATTR_START] = SID_ATTR_LINE_COLOR; + pSlotIds[XATTR_LINESTART -XATTR_START] = SID_ATTR_LINE_START; + pSlotIds[XATTR_LINEEND -XATTR_START] = SID_ATTR_LINE_END; + pSlotIds[XATTR_LINESTARTWIDTH -XATTR_START] = SID_ATTR_LINE_STARTWIDTH; + pSlotIds[XATTR_LINEENDWIDTH -XATTR_START] = SID_ATTR_LINE_ENDWIDTH; + pSlotIds[XATTR_LINESTARTCENTER -XATTR_START] = SID_ATTR_LINE_STARTCENTER; + pSlotIds[XATTR_LINEENDCENTER -XATTR_START] = SID_ATTR_LINE_ENDCENTER; + pSlotIds[XATTR_LINETRANSPARENCE -XATTR_START] = 0; + pSlotIds[XATTR_LINEJOINT -XATTR_START] = 0; + + // Line-Reserven + pSlotIds[XATTR_LINERESERVED2 -XATTR_START] = 0; + pSlotIds[XATTR_LINERESERVED3 -XATTR_START] = 0; + pSlotIds[XATTR_LINERESERVED4 -XATTR_START] = 0; + pSlotIds[XATTR_LINERESERVED5 -XATTR_START] = 0; + pSlotIds[XATTR_LINERESERVED_LAST -XATTR_START] = 0; + + pSlotIds[XATTR_FILLSTYLE -XATTR_START] = SID_ATTR_FILL_STYLE; + pSlotIds[XATTR_FILLCOLOR -XATTR_START] = SID_ATTR_FILL_COLOR; + pSlotIds[XATTR_FILLGRADIENT -XATTR_START] = SID_ATTR_FILL_GRADIENT; + pSlotIds[XATTR_FILLHATCH -XATTR_START] = SID_ATTR_FILL_HATCH; + pSlotIds[XATTR_FILLBITMAP -XATTR_START] = SID_ATTR_FILL_BITMAP; + pSlotIds[XATTR_FILLTRANSPARENCE -XATTR_START] = 0; + pSlotIds[XATTR_GRADIENTSTEPCOUNT-XATTR_START] = 0; + + pSlotIds[XATTR_FILLBMP_TILE -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_POS -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_SIZEX -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_SIZEY -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_SIZELOG -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_TILEOFFSETX -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_TILEOFFSETY -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_STRETCH -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_POSOFFSETX -XATTR_START] = 0; + pSlotIds[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = 0; + pSlotIds[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = 0; + + // Fill-Reserven + pSlotIds[XATTR_FILLRESERVED2 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED3 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED4 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED5 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED6 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED7 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED8 -XATTR_START] = 0; + pSlotIds[XATTR_FILLBACKGROUND -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED10 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED11 -XATTR_START] = 0; + pSlotIds[XATTR_FILLRESERVED_LAST -XATTR_START] = 0; + + pSlotIds[XATTR_FORMTXTSTYLE -XATTR_START] = SID_FORMTEXT_STYLE; + pSlotIds[XATTR_FORMTXTADJUST -XATTR_START] = SID_FORMTEXT_ADJUST; + pSlotIds[XATTR_FORMTXTDISTANCE -XATTR_START] = SID_FORMTEXT_DISTANCE; + pSlotIds[XATTR_FORMTXTSTART -XATTR_START] = SID_FORMTEXT_START; + pSlotIds[XATTR_FORMTXTMIRROR -XATTR_START] = SID_FORMTEXT_MIRROR; + pSlotIds[XATTR_FORMTXTOUTLINE -XATTR_START] = SID_FORMTEXT_OUTLINE; + pSlotIds[XATTR_FORMTXTSHADOW -XATTR_START] = SID_FORMTEXT_SHADOW; + pSlotIds[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = SID_FORMTEXT_SHDWCOLOR; + pSlotIds[XATTR_FORMTXTSHDWXVAL -XATTR_START] = SID_FORMTEXT_SHDWXVAL; + pSlotIds[XATTR_FORMTXTSHDWYVAL -XATTR_START] = SID_FORMTEXT_SHDWYVAL; + pSlotIds[XATTR_FORMTXTSTDFORM -XATTR_START] = SID_FORMTEXT_STDFORM; + pSlotIds[XATTR_FORMTXTHIDEFORM -XATTR_START] = SID_FORMTEXT_HIDEFORM; + + // FormText-Reserven + pSlotIds[XATTR_FORMTXTSHDWTRANSP-XATTR_START] = 0; + pSlotIds[XATTR_FTRESERVED2 -XATTR_START] = 0; + pSlotIds[XATTR_FTRESERVED3 -XATTR_START] = 0; + pSlotIds[XATTR_FTRESERVED4 -XATTR_START] = 0; + pSlotIds[XATTR_FTRESERVED5 -XATTR_START] = 0; + pSlotIds[XATTR_FTRESERVED_LAST -XATTR_START] = 0; + + pSlotIds[XATTRSET_LINE - XATTR_START] = 0; // 20136; alter Hack von MI + pSlotIds[XATTRSET_FILL - XATTR_START] = 0; // 20135; alter Hack von MI + pSlotIds[XATTRSET_TEXT - XATTR_START] = 0; +#endif + + if (nAttrStart==XATTR_START && nAttrEnd==XATTR_END) + { + SetDefaults(ppPoolDefaults); + SetItemInfos(pItemInfos); +#if SUPD<355 + SetMap(pSlotIds); +#endif + } +} + + +/************************************************************************* +|* +|* copy ctor, sorgt dafuer, dass die static defaults gecloned werden +|* (Parameter 2 = TRUE) +|* +\************************************************************************/ + +XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool) : + SfxItemPool(rPool, TRUE) +{ + // damit geclonete Pools nicht im dtor auf die Nase fallen + // endgueltige Loesung --> MI + ppPoolDefaults = NULL; +} + +/************************************************************************* +|* +|* Clone() +|* +\************************************************************************/ + +SfxItemPool* XOutdevItemPool::Clone() const +{ + return new XOutdevItemPool(*this); +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +XOutdevItemPool::~XOutdevItemPool() +{ +#if SUPD<355 + if (pSlotIds!=NULL) delete pSlotIds; +#endif + + Delete(); + if ( ppPoolDefaults ) + { + SfxPoolItem** ppDefaultItem = ppPoolDefaults; + for ( USHORT i = nEnd - nStart + 1; i; --i, ++ppDefaultItem ) + { + if ( *ppDefaultItem ) //Teile schon von abgel. Klasse abgeraeumt! + { +#ifndef PRODUCT + SetRef( **ppDefaultItem, 0 ); +#endif + delete *ppDefaultItem; + } + } + delete ppPoolDefaults; + } + if (pItemInfos!=NULL) delete[] pItemInfos; + +} + + diff --git a/svx/source/xoutdev/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx new file mode 100644 index 000000000000..f856ccdbfc4b --- /dev/null +++ b/svx/source/xoutdev/xtabbtmp.cxx @@ -0,0 +1,662 @@ +/************************************************************************* + * + * $RCSfile: xtabbtmp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <svtools/itemset.hxx> +#include <sfx2/docfile.hxx> +#include "dialogs.hrc" +#include "dialmgr.hxx" +#include "xtable.hxx" +#include "xiocomp.hxx" +#include "xpool.hxx" +#include "xoutx.hxx" + +#define GLOBALOVERFLOW + +sal_Unicode const pszExtBitmap[] = {'s','o','b'}; +sal_Unicode const pszChckBitmap[] = {'S','O','B','L'}; +// Neuer Key, damit alte Version (3.00) nicht bei dem +// Versuch abstuerzt, eine neue Tabelle zu laden. +sal_Unicode const pszChckBitmap0[] = {'S','O','B','0'}; +sal_Unicode const pszChckBitmap1[] = {'S','O','B','1'}; + +// ------------------- +// 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::Get(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 ); +} + +/************************************************************************/ + +SvStream& XBitmapTable::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Tabellentyp schreiben (0 = gesamte Tabelle) + // Version statt Tabellentyp, um auch alte Tabellen zu lesen + rOut << (long) -1; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XBitmapEntry* pEntry = (XBitmapEntry*)aTable.First(); + + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // Versionsverwaltung: Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + rOut << (long)aTable.GetCurKey(); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + rOut << pEntry->GetXBitmap().GetBitmap(); + pEntry = (XBitmapEntry*)aTable.Next(); + } + + return rOut; +} + +/************************************************************************/ + +SvStream& XBitmapTable::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpTable; + pBmpTable = new Table( 16, 16 ); + + XBitmapEntry* pEntry = NULL; + long nType; + long nCount; + long nIndex; + String aName; + Bitmap aBitmap; + + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> aBitmap; + + pEntry = new XBitmapEntry (aBitmap, aName); + Insert (nIndex, pEntry); + } + } + else // Version ab 3.00a + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> aBitmap; + + if (aIOC.GetVersion() > 0) + { + // lesen neuer Daten ... + } + + pEntry = new XBitmapEntry (aBitmap, aName); + Insert (nIndex, pEntry); + } + } + return( rIn ); +} + +// ------------------ +// 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::Get(long nIndex) const +{ + return (XBitmapEntry*) XPropertyList::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XBitmapList::Load() +{ +#ifndef SVX_LIGHT + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtBitmap, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_READ | STREAM_NOCREATE, + TRUE, // direkt + TRUE ); // Download + + SvStream* pStream = aMedium.GetInStream(); + if( !pStream ) + return( FALSE ); + + String aCheck; + // UNICODE: *pStream >> aCheck; + pStream->ReadByteString(aCheck); + + // Handelt es sich um die gew"unschte Tabelle? + if( aCheck == String(pszChckBitmap, 4) || + aCheck == String(pszChckBitmap0, 4) || + aCheck == String(pszChckBitmap1, 4) ) + { + ImpRead( *pStream ); + } + else + return( FALSE ); + + return( pStream->GetError() == SVSTREAM_OK ); + } +#endif + return( FALSE ); +} + +/************************************************************************/ + +BOOL XBitmapList::Save() +{ +#ifndef SVX_LIGHT + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtBitmap, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_WRITE | STREAM_TRUNC, + TRUE, // direkt + FALSE ); // Upload + aMedium.IsRemote(); + + SvStream* pStream = aMedium.GetOutStream(); + if( !pStream ) + return( FALSE ); + + // UNICODE: *pStream << String( pszChckBitmap1, 4 ); + pStream->WriteByteString(String( pszChckBitmap1, 4 )); + ImpStore( *pStream ); + + aMedium.Close(); + aMedium.Commit(); + + return( aMedium.GetError() == 0 ); +#else + return FALSE; +#endif +} + +/************************************************************************/ +// 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 ); +} + +/************************************************************************/ + +SvStream& XBitmapList::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Version !!! + rOut << (long)-2; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XBitmapEntry* pEntry = NULL; + + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // Versionsverwaltung: Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + pEntry = Get(nIndex); + XOBitmap aXOBitmap( pEntry->GetXBitmap() ); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + rOut << (INT16) aXOBitmap.GetBitmapStyle(); + rOut << (INT16) aXOBitmap.GetBitmapType(); + + if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT ) + { + rOut << aXOBitmap.GetBitmap(); + } + 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; +} + +/************************************************************************/ + +XubString& XBitmapList::ConvertName( XubString& rStrName ) +{ + BOOL bFound = FALSE; + + for( USHORT i=0; i<(RID_SVXSTR_BMP_DEF_END-RID_SVXSTR_BMP_DEF_START+1) && !bFound; i++ ) + { + XubString aStrDefName = SVX_RESSTR( RID_SVXSTR_BMP_DEF_START + i ); + if( rStrName.Search( aStrDefName ) == 0 ) + { + rStrName.Replace( 0, aStrDefName.Len(), SVX_RESSTR( RID_SVXSTR_BMP_START + i ) ); + bFound = TRUE; + } + } + + return rStrName; +} + +/************************************************************************/ + +SvStream& XBitmapList::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpList; + pBmpList = new List( 16, 16 ); + + XBitmapEntry* pEntry = NULL; + long nCount; + String aName; + + rIn >> nCount; // Version oder Anzahl ? + + if( nCount >= 0 ) // Erste Version + { + for( long nIndex = 0; nIndex < nCount; nIndex++ ) + { + // Behandlung der alten Bitmaps + Bitmap aBmp; + XOBitmap aXOBitmap; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + 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 ); + + pEntry = new XBitmapEntry( aXOBitmap, aName ); + Insert( pEntry, nIndex ); + } + } + else if( nCount == -1 ) // Zweite Version + { + rIn >> nCount; + for( long nIndex = 0; nIndex < nCount; nIndex++ ) + { + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + + XOBitmap aXOBitmap; + 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; + } + + pEntry = new XBitmapEntry( aXOBitmap, aName ); + Insert( pEntry, nIndex ); + } + } + else // Version ab 3.00a + { + rIn >> nCount; + for( long nIndex = 0; nIndex < nCount; nIndex++ ) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + + XOBitmap aXOBitmap; + 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; + } + + if (aIOC.GetVersion() > 0) + { + // lesen neuer Daten ... + } + + pEntry = new XBitmapEntry( aXOBitmap, aName ); + Insert( pEntry, nIndex ); + } + } + + return( rIn ); +} + + + diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx new file mode 100644 index 000000000000..c1d297ba54c7 --- /dev/null +++ b/svx/source/xoutdev/xtabcolr.cxx @@ -0,0 +1,856 @@ +/************************************************************************* + * + * $RCSfile: xtabcolr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#include <sfx2/docfile.hxx> +#include "dialogs.hrc" +#include "dialmgr.hxx" +#include "xtable.hxx" +#include "xiocomp.hxx" +#include "xpool.hxx" +#include "xoutx.hxx" + +#define GLOBALOVERFLOW + +sal_Unicode const pszExtColor[] = {'s','o','c'}; +sal_Unicode const pszChckColor[] = {'S','O','C','L'}; +// Neuer Key, damit alte Version (3.00) nicht bei dem +// Versuch abstuerzt, eine neue Tabelle zu laden. +sal_Unicode const pszChckColor0[] = {'S','O','C','0'}; + +// ------------------ +// class XColorTable +// ------------------ + +/************************************************************************* +|* +|* 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() +{ +} + +/************************************************************************/ + +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::Get(long nIndex) const +{ + return (XColorEntry*) XPropertyTable::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XColorTable::Load() +{ +#ifndef SVX_LIGHT + if( bTableDirty ) + { + bTableDirty = FALSE; + + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtColor, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_READ | STREAM_NOCREATE, + TRUE, // direkt + TRUE ); // Download + + SvStream* pStream = aMedium.GetInStream(); + if( !pStream ) + return( FALSE ); + + String aCheck; + + // UNICODE: *pStream >> aCheck; + pStream->ReadByteString(aCheck); + + // Handelt es sich um die gew"unschte Tabelle? + if( aCheck == String(pszChckColor, 4) || + aCheck == String(pszChckColor0, 4) ) + { + ImpRead( *pStream ); + } + else + return( FALSE ); + + return( pStream->GetError() == SVSTREAM_OK ); + } +#endif + return( FALSE ); +} + +/************************************************************************/ + +BOOL XColorTable::Save() +{ +#ifndef SVX_LIGHT + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtColor, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_WRITE | STREAM_TRUNC, + TRUE, // direkt + FALSE ); // Upload + aMedium.IsRemote(); + + SvStream* pStream = aMedium.GetOutStream(); + if( !pStream ) + return( FALSE ); + + // UNICODE: *pStream << String( pszChckColor0, 4 ); + pStream->WriteByteString(String( pszChckColor0, 4 )); + + + ImpStore( *pStream ); + + aMedium.Close(); + aMedium.Commit(); + + return( aMedium.GetError() == 0 ); +#else + return FALSE; +#endif +} + +/************************************************************************/ + +BOOL XColorTable::Create() +{ + XubString aStr; + xub_StrLen nLen; + ResMgr* pRes = 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 ], pRes )) ) ); + } + + 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 ) ); + + return( Count() == 92 ); +} + +/************************************************************************/ + +BOOL XColorTable::CreateBitmapsForUI() +{ + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XColorTable::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + return( NULL ); +} + +/************************************************************************/ + +SvStream& XColorTable::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Tabellentyp schreiben (0 = gesamte Tabelle) + // Version statt Tabellentyp, um auch alte Tabellen zu lesen + rOut << (long) -1; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Farben + XColorEntry* pEntry = (XColorEntry*)aTable.First(); + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // Versionsverwaltung: Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + rOut << (long)aTable.GetCurKey(); + + // UNICODE:: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + +#ifdef VCL + USHORT nCol = pEntry->GetColor().GetRed(); + nCol = nCol << 8; + rOut << nCol; + + nCol = pEntry->GetColor().GetGreen(); + nCol = nCol << 8; + rOut << nCol; + + nCol = pEntry->GetColor().GetBlue(); + nCol = nCol << 8; + rOut << nCol; +#else + rOut << pEntry->GetColor().GetRed(); + rOut << pEntry->GetColor().GetGreen(); + rOut << pEntry->GetColor().GetBlue(); +#endif + pEntry = (XColorEntry*)aTable.Next(); + } + return( rOut ); +} + +/************************************************************************/ + +XubString& XColorTable::ConvertName( XubString& rStrName ) +{ + static USHORT __READONLY_DATA aDefResId[] = + { + RID_SVXSTR_BLUEGREY_DEF, + RID_SVXSTR_BLACK_DEF, + RID_SVXSTR_BLUE_DEF, + RID_SVXSTR_GREEN_DEF, + RID_SVXSTR_CYAN_DEF, + RID_SVXSTR_RED_DEF, + RID_SVXSTR_MAGENTA_DEF, + RID_SVXSTR_BROWN_DEF, + RID_SVXSTR_GREY_DEF, + RID_SVXSTR_LIGHTGREY_DEF, + RID_SVXSTR_LIGHTBLUE_DEF, + RID_SVXSTR_LIGHTGREEN_DEF, + RID_SVXSTR_LIGHTCYAN_DEF, + RID_SVXSTR_LIGHTRED_DEF, + RID_SVXSTR_LIGHTMAGENTA_DEF, + RID_SVXSTR_YELLOW_DEF, + RID_SVXSTR_WHITE_DEF, + RID_SVXSTR_ORANGE_DEF, + RID_SVXSTR_VIOLET_DEF, + RID_SVXSTR_BORDEAUX_DEF, + RID_SVXSTR_PALE_YELLOW_DEF, + RID_SVXSTR_PALE_GREEN_DEF, + RID_SVXSTR_DKVIOLET_DEF, + RID_SVXSTR_SALMON_DEF, + RID_SVXSTR_SEABLUE_DEF, + RID_SVXSTR_COLOR_SUN_DEF + }; + static USHORT __READONLY_DATA aResId[] = + { + RID_SVXSTR_BLUEGREY, + 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, + RID_SVXSTR_ORANGE, + RID_SVXSTR_VIOLET, + RID_SVXSTR_BORDEAUX, + RID_SVXSTR_PALE_YELLOW, + RID_SVXSTR_PALE_GREEN, + RID_SVXSTR_DKVIOLET, + RID_SVXSTR_SALMON, + RID_SVXSTR_SEABLUE, + RID_SVXSTR_COLOR_SUN + }; + + BOOL bFound = FALSE; + + for( int i=0; i<(sizeof(aDefResId) / sizeof(USHORT)) && !bFound; i++ ) + { + XubString aStrDefName = SVX_RESSTR( aDefResId[i] ); + if( rStrName.Search( aStrDefName ) == 0 ) + { + rStrName.Replace( 0, aStrDefName.Len(), SVX_RESSTR( aResId[i] ) ); + bFound = TRUE; + } + } + + return rStrName; +} + +/************************************************************************/ + +SvStream& XColorTable::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpTable; + pBmpTable = new Table( 16, 16 ); + + XColorEntry* pEntry = NULL; + long nType; + long nCount; + long nIndex; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + Color aColor; + XubString aName; + + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + aName = ConvertName( aName ); + + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + +#ifdef VCL + aColor = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aColor = Color( nRed, nGreen, nBlue ); +#endif + pEntry = new XColorEntry( aColor, aName); + Insert (nIndex, pEntry); + } + } + else // Version ab 3.00a + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + aName = ConvertName( aName ); + + if( aIOC.GetVersion() >= 0 ) + { + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aColor = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aColor = Color( nRed, nGreen, nBlue ); +#endif + } + /* + else if( aIOC.GetVersion() >= 1 ) + { + // lesen neuer Daten ... + } + */ + + pEntry = new XColorEntry( aColor, aName ); + Insert( nIndex, pEntry ); + } + } + return( rIn ); +} + +// -------------------- +// 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::Get(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 ); +} + +/************************************************************************/ + +SvStream& XColorList::ImpStore( SvStream& rOut ) +{ + // Erstmal von XColorTable uebernommen !!! + + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Tabellentyp schreiben (0 = gesamte Tabelle) + rOut << (long)0; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Farben + XColorEntry* pEntry = (XColorEntry*)aList.First(); + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // rOut << (long)aList.GetCurKey(); + + // UNICODE:rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + rOut << pEntry->GetColor().GetRed(); + rOut << pEntry->GetColor().GetGreen(); + rOut << pEntry->GetColor().GetBlue(); + pEntry = (XColorEntry*)aList.Next(); + } + return rOut; +} + +/************************************************************************/ + +SvStream& XColorList::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + // Erstmal von XColorTable uebernommen !!! + delete pBmpList; + pBmpList = new List( 16, 16 ); + + + XColorEntry* pEntry = NULL; + long nType; + long nCount; + long nIndex; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + XubString aName; + + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + + pEntry = new XColorEntry (Color(nRed, nGreen, nBlue), aName); + Insert (pEntry, nIndex); + } + } + return( rIn ); +} + + diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx new file mode 100644 index 000000000000..3b0906a9c8ea --- /dev/null +++ b/svx/source/xoutdev/xtabdash.cxx @@ -0,0 +1,655 @@ +/************************************************************************* + * + * $RCSfile: xtabdash.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#pragma hdrstop + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <vcl/window.hxx> +#include <svtools/itemset.hxx> +#include <sfx2/docfile.hxx> +#include "dialogs.hrc" +#include "dialmgr.hxx" +#include "xtable.hxx" +#include "xiocomp.hxx" +#include "xpool.hxx" +#include "xoutx.hxx" + +#ifndef _SVX_XLINEIT0_HXX //autogen +#include <xlineit0.hxx> +#endif + +#ifndef _SVX_XLNCLIT_HXX //autogen +#include <xlnclit.hxx> +#endif + +#ifndef _SVX_XLNWTIT_HXX //autogen +#include <xlnwtit.hxx> +#endif + +#ifndef _SVX_XLNDSIT_HXX //autogen +#include <xlndsit.hxx> +#endif + +#define GLOBALOVERFLOW + +sal_Unicode const pszExtDash[] = {'s','o','d'}; +sal_Unicode const pszChckDash[] = {'S','O','D','L'}; +// Neuer Key, damit alte Version (3.00) nicht bei dem +// Versuch abstuerzt, eine neue Tabelle zu laden. +sal_Unicode const pszChckDash0[] = {'S','O','D','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::Get(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 ); +} + +/************************************************************************/ + +SvStream& XDashTable::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Tabellentyp schreiben (0 = gesamte Tabelle) + rOut << (long)0; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XDashEntry* pEntry = (XDashEntry*)aTable.First(); + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + rOut << (long)aTable.GetCurKey(); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XDash& rDash = pEntry->GetDash(); + rOut << (long)rDash.GetDashStyle(); + rOut << (long)rDash.GetDots(); + rOut << rDash.GetDotLen(); + rOut << (long)rDash.GetDashes(); + rOut << rDash.GetDashLen(); + rOut << rDash.GetDistance(); + pEntry = (XDashEntry*)aTable.Next(); + } + + return rOut; +} + +/************************************************************************/ + +SvStream& XDashTable::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpTable; + pBmpTable = new Table( 16, 16 ); + + XDashEntry* pEntry = NULL; + long nType; + long nCount; + long nIndex; + XubString aName; + + long nStyle; + long nDots; + ULONG nDotLen; + long nDashes; + ULONG nDashLen; + ULONG nDistance; + + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> nStyle; + rIn >> nDots; + rIn >> nDotLen; + rIn >> nDashes; + rIn >> nDashLen; + rIn >> nDistance; + XDash aDash((XDashStyle)nStyle, (BYTE)nDots, nDotLen, + (BYTE)nDashes, nDashLen, nDistance); + pEntry = new XDashEntry (aDash, aName); + Insert (nIndex, pEntry); + } + } + return( rIn ); +} + + +// ---------------- +// class XDashList +// ---------------- + +/************************************************************************* +|* +|* XDashList::XDashList() +|* +*************************************************************************/ + +XDashList::XDashList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyList ( rPath, pInPool, nInitSize, nReSize), + pVD ( NULL ), + pXOut ( NULL ), + pXFSet ( NULL ), + pXLSet ( NULL ) +{ + pBmpList = new List( nInitSize, nReSize ); +} + +/************************************************************************/ + +XDashList::~XDashList() +{ + if( pVD ) delete pVD; + if( pXOut ) delete pXOut; + if( pXFSet ) delete pXFSet; + if( pXLSet ) delete pXLSet; +} + +/************************************************************************/ + +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::Get(long nIndex) const +{ + return (XDashEntry*) XPropertyList::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XDashList::Load() +{ +#ifndef SVX_LIGHT + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtDash, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_READ | STREAM_NOCREATE, + TRUE, // direkt + TRUE ); // Download + + SvStream* pStream = aMedium.GetInStream(); + if( !pStream ) + return( FALSE ); + + String aCheck; + + // UNICODE: *pStream >> aCheck; + pStream->ReadByteString(aCheck); + + // Handelt es sich um die gew"unschte Tabelle? + if( aCheck == String(pszChckDash, 4) || + aCheck == String(pszChckDash0, 4) ) + { + ImpRead( *pStream ); + } + else + return( FALSE ); + + return( pStream->GetError() == SVSTREAM_OK ); + } +#endif + return( FALSE ); +} + +/************************************************************************/ + +BOOL XDashList::Save() +{ +#ifndef SVX_LIGHT + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtDash, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_WRITE | STREAM_TRUNC, + TRUE, // direkt + FALSE ); // Upload + aMedium.IsRemote(); + + SvStream* pStream = aMedium.GetOutStream(); + if( !pStream ) + return( FALSE ); + + // UNICODE: *pStream << String( pszChckDash0, 4 ); + pStream->WriteByteString(String( pszChckDash0, 4 )); + + ImpStore( *pStream ); + + aMedium.Close(); + aMedium.Commit(); + + return( aMedium.GetError() == 0 ); +#else + return FALSE; +#endif +} + +/************************************************************************/ + +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() +{ + 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 ); + } + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + if( pXLSet ){ delete pXLSet; pXLSet = NULL; } + + return( TRUE ); +} + +/************************************************************************/ + +Bitmap* XDashList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + Point aZero; + + if( !pVD ) // und pXOut und pXFSet und pXLSet + { + pVD = new VirtualDevice; + DBG_ASSERT( pVD, "XDashList: Konnte kein VirtualDevice erzeugen!" ); + pVD->SetMapMode( MAP_100TH_MM ); + pVD->SetOutputSize( pVD->PixelToLogic( Size( BITMAP_WIDTH * 2, BITMAP_HEIGHT ) ) ); + const StyleSettings& rStyleSettings = pVD->GetSettings().GetStyleSettings(); + pVD->SetFillColor( rStyleSettings.GetFieldColor() ); + pVD->SetLineColor( rStyleSettings.GetFieldColor() ); + + pXOut = new XOutputDevice( pVD ); + DBG_ASSERT( pVD, "XDashList: Konnte kein XOutDevice erzeugen!" ); + + pXFSet = new XFillAttrSetItem( pXPool ); + DBG_ASSERT( pVD, "XDashList: Konnte kein XFillAttrSetItem erzeugen!" ); + + pXLSet = new XLineAttrSetItem( pXPool ); + DBG_ASSERT( pVD, "XDashList: Konnte kein XLineAttrSetItem erzeugen!" ); + pXLSet->GetItemSet().Put( XLineStyleItem( XLINE_DASH ) ); + pXLSet->GetItemSet().Put( XLineColorItem( String(), RGB_Color( COL_BLACK ) ) ); + pXLSet->GetItemSet().Put( XLineWidthItem( 30 ) ); + } + + Size aVDSize = pVD->GetOutputSize(); + pVD->DrawRect( Rectangle( aZero, aVDSize ) ); + pXLSet->GetItemSet().Put( XLineDashItem( String(), Get( nIndex )->GetDash() ) ); + pXOut->SetLineAttr( *pXLSet ); + pXOut->DrawLine( Point( 0, aVDSize.Height() / 2 ), + Point( aVDSize.Width(), aVDSize.Height() / 2 ) ); + + Bitmap* pBitmap = new Bitmap( pVD->GetBitmap( aZero, aVDSize ) ); + + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( bDelete ) + { + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + if( pXLSet ){ delete pXLSet; pXLSet = NULL; } + } + return( pBitmap ); +} + +/************************************************************************/ + +SvStream& XDashList::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Version statt Anzahl, um auch alte Tabellen zu lesen + rOut << (long) -1; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XDashEntry* pEntry = NULL; + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // Versionsverwaltung: Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + pEntry = Get(nIndex); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XDash& rDash = pEntry->GetDash(); + rOut << (long)rDash.GetDashStyle(); + rOut << (long)rDash.GetDots(); + rOut << rDash.GetDotLen(); + rOut << (long)rDash.GetDashes(); + rOut << rDash.GetDashLen(); + rOut << rDash.GetDistance(); + } + return rOut; +} + +/************************************************************************/ + +XubString& XDashList::ConvertName( XubString& rStrName ) +{ + static USHORT __READONLY_DATA aDefResId[] = + { + RID_SVXSTR_DASH5_DEF, + RID_SVXSTR_DASH0_DEF, + RID_SVXSTR_DASH1_DEF, + RID_SVXSTR_DASH2_DEF, + RID_SVXSTR_DASH3_DEF, + RID_SVXSTR_DASH4_DEF, + RID_SVXSTR_DASH6_DEF, + RID_SVXSTR_DASH7_DEF, + RID_SVXSTR_DASH8_DEF, + RID_SVXSTR_DASH9_DEF, + RID_SVXSTR_DASH10_DEF + }; + static USHORT __READONLY_DATA aResId[] = + { + RID_SVXSTR_DASH5, + RID_SVXSTR_DASH0, + RID_SVXSTR_DASH1, + RID_SVXSTR_DASH2, + RID_SVXSTR_DASH3, + RID_SVXSTR_DASH4, + RID_SVXSTR_DASH6, + RID_SVXSTR_DASH7, + RID_SVXSTR_DASH8, + RID_SVXSTR_DASH9, + RID_SVXSTR_DASH10 + }; + + BOOL bFound = FALSE; + + for( int i=0; i<(sizeof(aDefResId) / sizeof(USHORT)) && !bFound; i++ ) + { + XubString aStrDefName = SVX_RESSTR( aDefResId[i] ); + if( rStrName.Search( aStrDefName ) == 0 ) + { + rStrName.Replace( 0, aStrDefName.Len(), SVX_RESSTR( aResId[i] ) ); + bFound = TRUE; + } + } + + return rStrName; +} + +/************************************************************************/ + +SvStream& XDashList::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpList; + pBmpList = new List( 16, 16 ); + + XDashEntry* pEntry = NULL; + long nCount; + XubString aName; + + long nStyle; + long nDots; + ULONG nDotLen; + long nDashes; + ULONG nDashLen; + ULONG nDistance; + + rIn >> nCount; + + if( nCount >= 0 ) // Alte Tabellen (bis 3.00) + { + for (long nIndex = 0; nIndex < nCount; nIndex++) + { + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nDots; + rIn >> nDotLen; + rIn >> nDashes; + rIn >> nDashLen; + rIn >> nDistance; + XDash aDash((XDashStyle)nStyle, (BYTE)nDots, nDotLen, + (BYTE)nDashes, nDashLen, nDistance); + pEntry = new XDashEntry (aDash, aName); + Insert (pEntry, nIndex); + } + } + else // ab 3.00a + { + rIn >> nCount; + + for (long nIndex = 0; nIndex < nCount; nIndex++) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nDots; + rIn >> nDotLen; + rIn >> nDashes; + rIn >> nDashLen; + rIn >> nDistance; + + if (aIOC.GetVersion() > 0) + { + // lesen neuer Daten ... + } + + XDash aDash((XDashStyle)nStyle, (BYTE)nDots, nDotLen, + (BYTE)nDashes, nDashLen, nDistance); + pEntry = new XDashEntry (aDash, aName); + Insert (pEntry, nIndex); + } + } + return( rIn ); +} + + + diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx new file mode 100644 index 000000000000..1568172b15db --- /dev/null +++ b/svx/source/xoutdev/xtabgrdt.cxx @@ -0,0 +1,776 @@ +/************************************************************************* + * + * $RCSfile: xtabgrdt.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#pragma hdrstop + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <svtools/itemset.hxx> +#include <sfx2/docfile.hxx> +#include "dialogs.hrc" +#include "dialmgr.hxx" +#include "xtable.hxx" +#include "xiocomp.hxx" +#include "xpool.hxx" +#include "xoutx.hxx" + +#ifndef SVX_XFILLIT0_HXX //autogen +#include <xfillit0.hxx> +#endif + +#ifndef _SVX_XFLGRIT_HXX //autogen +#include <xflgrit.hxx> +#endif + +#define GLOBALOVERFLOW + +sal_Unicode const pszExtGradient[] = {'s','o','g'}; +sal_Unicode const pszChckGradient[] = {'S','O','G','L'}; +// Neuer Key, damit alte Version (3.00) nicht bei dem +// Versuch abstuerzt, eine neue Tabelle zu laden. +sal_Unicode const pszChckGradient0[] = {'S','O','G','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::Get(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 ); +} + +/************************************************************************/ + +SvStream& XGradientTable::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Tabellentyp schreiben (0 = gesamte Tabelle) + rOut << (long)0; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XGradientEntry* pEntry = (XGradientEntry*)aTable.First(); + + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + rOut << (long)aTable.GetCurKey(); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XGradient& rGradient = pEntry->GetGradient(); + rOut << (long)rGradient.GetGradientStyle(); + rOut << rGradient.GetStartColor().GetRed(); + rOut << rGradient.GetStartColor().GetGreen(); + rOut << rGradient.GetStartColor().GetBlue(); + rOut << rGradient.GetEndColor().GetRed(); + rOut << rGradient.GetEndColor().GetGreen(); + rOut << rGradient.GetEndColor().GetBlue(); + rOut << rGradient.GetAngle(); + rOut << (ULONG)rGradient.GetBorder(); + rOut << (ULONG)rGradient.GetXOffset(); + rOut << (ULONG)rGradient.GetYOffset(); + pEntry = (XGradientEntry*)aTable.Next(); + } + + return rOut; +} + +/************************************************************************/ + +SvStream& XGradientTable::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpTable; + pBmpTable = new Table( 16, 16 ); + + XGradientEntry* pEntry = NULL; + long nType; + long nCount; + long nIndex; + XubString aName; + + long nStyle; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + Color aStart; + Color aEnd; + long nAngle; + ULONG nBorder; + ULONG nXOfs; + ULONG nYOfs; + + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + +#ifdef VCL + aStart = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aStart = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + +#ifdef VCL + aEnd = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aEnd = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + + rIn >> nAngle; + rIn >> nBorder; + rIn >> nXOfs; + rIn >> nYOfs; + + XGradient aGradient(aStart, aEnd, (XGradientStyle)nStyle, nAngle, + (USHORT)nXOfs, (USHORT)nYOfs, (USHORT)nBorder); + pEntry = new XGradientEntry (aGradient, aName); + Insert (nIndex, pEntry); + } + } + return( rIn ); +} + +// -------------------- +// class XGradientList +// -------------------- + +/************************************************************************* +|* +|* XGradientList::XGradientList() +|* +*************************************************************************/ + +XGradientList::XGradientList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyList ( rPath, pInPool, nInitSize, nReSize), + pVD ( NULL ), + pXOut ( NULL ), + pXFSet ( NULL ) +{ + pBmpList = new List( nInitSize, nReSize ); +} + +/************************************************************************/ + +XGradientList::~XGradientList() +{ + if( pVD ) delete pVD; + if( pXOut ) delete pXOut; + if( pXFSet ) delete pXFSet; +} + +/************************************************************************/ + +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::Get(long nIndex) const +{ + return( (XGradientEntry*) XPropertyList::Get( nIndex, 0 ) ); +} + +/************************************************************************/ + +BOOL XGradientList::Load() +{ +#ifndef SVX_LIGHT + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtGradient, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_READ | STREAM_NOCREATE, + TRUE, // direkt + TRUE ); // Download + + SvStream* pStream = aMedium.GetInStream(); + if( !pStream ) + return( FALSE ); + + String aCheck; + // UNICODE: *pStream >> aCheck; + pStream->ReadByteString(aCheck); + + // Handelt es sich um die gew"unschte Tabelle? + if( aCheck == String(pszChckGradient, 4) || + aCheck == String(pszChckGradient0, 4) ) + { + ImpRead( *pStream ); + } + else + return( FALSE ); + + return( pStream->GetError() == SVSTREAM_OK ); + } +#endif + return( FALSE ); +} + +/************************************************************************/ + +BOOL XGradientList::Save() +{ +#ifndef SVX_LIGHT + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtGradient, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_WRITE | STREAM_TRUNC, + TRUE, // direkt + FALSE ); // Upload + aMedium.IsRemote(); + + SvStream* pStream = aMedium.GetOutStream(); + if( !pStream ) + return( FALSE ); + + // UNICODE: *pStream << String( pszChckGradient0, 4 ); + pStream->WriteByteString(String( pszChckGradient0, 4 )); + + ImpStore( *pStream ); + + aMedium.Close(); + aMedium.Commit(); + + return( aMedium.GetError() == 0 ); +#else + return FALSE; +#endif +} + +/************************************************************************/ + +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() +{ + 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 ); + } + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + + return( FALSE ); +} + +/************************************************************************/ + +Bitmap* XGradientList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + if( !pVD ) // und pXOut und pXFSet + { + pVD = new VirtualDevice; + DBG_ASSERT( pVD, "XGradientList: Konnte kein VirtualDevice erzeugen!" ); + pVD->SetOutputSizePixel( Size( BITMAP_WIDTH, BITMAP_HEIGHT ) ); + + pXOut = new XOutputDevice( pVD ); + DBG_ASSERT( pVD, "XGradientList: Konnte kein XOutDevice erzeugen!" ); + + pXFSet = new XFillAttrSetItem( pXPool ); + DBG_ASSERT( pVD, "XGradientList: Konnte kein XFillAttrSetItem erzeugen!" ); + pXFSet->GetItemSet().Put( XFillStyleItem( XFILL_GRADIENT ) ); + } + + pXFSet->GetItemSet().Put( + XFillGradientItem( String(), Get( nIndex )->GetGradient() ) ); + pXOut->SetFillAttr( *pXFSet ); + + // #73550# + pXOut->OverrideLineColor( Color( COL_BLACK ) ); + + Size aVDSize = pVD->GetOutputSizePixel(); + pXOut->DrawRect( Rectangle( Point(), aVDSize ) ); + Bitmap* pBitmap = new Bitmap( pVD->GetBitmap( Point(), aVDSize ) ); + + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( bDelete ) + { + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + } + return( pBitmap ); +} + +/************************************************************************/ + +SvStream& XGradientList::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + XGradientEntry* pEntry = NULL; + + // Kennung + rOut << (long) -2; + + // Anzahl der Eintraege + rOut << (long)Count(); + + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // Versionsverwaltung: Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + pEntry = Get(nIndex); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XGradient& rGradient = pEntry->GetGradient(); + rOut << (long)rGradient.GetGradientStyle(); + +#ifdef VCL + USHORT nCol = rGradient.GetStartColor().GetRed(); + nCol = nCol << 8; + rOut << nCol; + nCol = rGradient.GetStartColor().GetGreen(); + nCol = nCol << 8; + rOut << nCol; + nCol = rGradient.GetStartColor().GetBlue(); + nCol = nCol << 8; + rOut << nCol; + + nCol = rGradient.GetEndColor().GetRed(); + nCol = nCol << 8; + rOut << nCol; + nCol = rGradient.GetEndColor().GetGreen(); + nCol = nCol << 8; + rOut << nCol; + nCol = rGradient.GetEndColor().GetBlue(); + nCol = nCol << 8; + rOut << nCol; +#else + rOut << rGradient.GetStartColor().GetRed(); + rOut << rGradient.GetStartColor().GetGreen(); + rOut << rGradient.GetStartColor().GetBlue(); + + rOut << rGradient.GetEndColor().GetRed(); + rOut << rGradient.GetEndColor().GetGreen(); + rOut << rGradient.GetEndColor().GetBlue(); +#endif + rOut << rGradient.GetAngle(); + rOut << (ULONG)rGradient.GetBorder(); + rOut << (ULONG)rGradient.GetXOffset(); + rOut << (ULONG)rGradient.GetYOffset(); + rOut << (ULONG)rGradient.GetStartIntens(); + rOut << (ULONG)rGradient.GetEndIntens(); + } + + return rOut; +} + +/************************************************************************/ + +XubString& XGradientList::ConvertName( XubString& rStrName ) +{ + BOOL bFound = FALSE; + + for( USHORT i=0; i<(RID_SVXSTR_GRDT_DEF_END-RID_SVXSTR_GRDT_DEF_START+1) && !bFound; i++ ) + { + XubString aStrDefName = SVX_RESSTR( RID_SVXSTR_GRDT_DEF_START + i ); + if( rStrName.Search( aStrDefName ) == 0 ) + { + rStrName.Replace( 0, aStrDefName.Len(), SVX_RESSTR( RID_SVXSTR_GRDT_START + i ) ); + bFound = TRUE; + } + } + + return rStrName; +} + +/************************************************************************/ + +SvStream& XGradientList::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpList; + pBmpList = new List( 16, 16 ); + + XGradientEntry* pEntry = NULL; + long nCheck; + long nCount; + XubString aName; + + long nStyle; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + Color aStart; + Color aEnd; + long nAngle; + ULONG nBorder; + ULONG nXOfs; + ULONG nYOfs; + ULONG nStartIntens; + ULONG nEndIntens; + + // Kennung oder Anzahl + rIn >> nCheck; + + if( nCheck >= 0 ) + { + nCount = nCheck; + + for (long nIndex = 0; nIndex < nCount; nIndex++) + { + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aStart = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aStart = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aEnd = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aEnd = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + + rIn >> nAngle; + rIn >> nBorder; + rIn >> nXOfs; + rIn >> nYOfs; + + nStartIntens = 100L; + nEndIntens = 100L; + + XGradient aGradient( aStart, aEnd, (XGradientStyle)nStyle, nAngle, + (USHORT) nXOfs, (USHORT) nYOfs, (USHORT) nBorder, + (USHORT) nStartIntens, (USHORT) nEndIntens ); + pEntry = new XGradientEntry (aGradient, aName); + Insert (pEntry, nIndex); + } + } + else if( nCheck == -1L ) + { + rIn >> nCount; + for (long nIndex = 0; nIndex < nCount; nIndex++) + { + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aStart = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aStart = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aEnd = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aEnd = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + + rIn >> nAngle; + rIn >> nBorder; + rIn >> nXOfs; + rIn >> nYOfs; + + rIn >> nStartIntens; + rIn >> nEndIntens; + + XGradient aGradient( aStart, aEnd, (XGradientStyle)nStyle, nAngle, + (USHORT) nXOfs, (USHORT) nYOfs, (USHORT) nBorder, + (USHORT) nStartIntens, (USHORT) nEndIntens ); + pEntry = new XGradientEntry (aGradient, aName); + Insert (pEntry, nIndex); + } + } + else // ab 3.00a + { + rIn >> nCount; + for (long nIndex = 0; nIndex < nCount; nIndex++) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aStart = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aStart = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; +#ifdef VCL + aEnd = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aEnd = Color( (USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue ); +#endif + + rIn >> nAngle; + rIn >> nBorder; + rIn >> nXOfs; + rIn >> nYOfs; + + rIn >> nStartIntens; + rIn >> nEndIntens; + + if (aIOC.GetVersion() > 0) + { + // lesen neuer Daten ... + } + + XGradient aGradient( aStart, aEnd, (XGradientStyle)nStyle, nAngle, + (USHORT) nXOfs, (USHORT) nYOfs, (USHORT) nBorder, + (USHORT) nStartIntens, (USHORT) nEndIntens ); + pEntry = new XGradientEntry (aGradient, aName); + Insert (pEntry, nIndex); + } + } + return( rIn ); +} + + diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx new file mode 100644 index 000000000000..a912245fc810 --- /dev/null +++ b/svx/source/xoutdev/xtabhtch.cxx @@ -0,0 +1,657 @@ +/************************************************************************* + * + * $RCSfile: xtabhtch.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#pragma hdrstop + +#include <tools/urlobj.hxx> +#include <vcl/virdev.hxx> +#include <svtools/itemset.hxx> +#include <sfx2/docfile.hxx> +#include "dialogs.hrc" +#include "dialmgr.hxx" +#include "xtable.hxx" +#include "xiocomp.hxx" +#include "xpool.hxx" +#include "xoutx.hxx" + +#ifndef _SVX_XFLHTIT_HXX //autogen +#include <xflhtit.hxx> +#endif + +#ifndef _SVX_XFLCLIT_HXX //autogen +#include <xflclit.hxx> +#endif + +#ifndef SVX_XFILLIT0_HXX //autogen +#include <xfillit0.hxx> +#endif + +#define GLOBALOVERFLOW +#include <segmentc.hxx> + +sal_Unicode const pszExtHatch[] = {'s','o','h'}; +sal_Unicode const pszChckHatch[] = {'S','O','H','L'}; +// Neuer Key, damit alte Version (3.00) nicht bei dem +// Versuch abstuerzt, eine neue Tabelle zu laden. +sal_Unicode const pszChckHatch0[] = {'S','O','H','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::Get(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 ); +} + +/************************************************************************/ + +SvStream& XHatchTable::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Tabellentyp schreiben (0 = gesamte Tabelle) + rOut << (long)0; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XHatchEntry* pEntry = (XHatchEntry*)aTable.First();; + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + rOut << (long)aTable.GetCurKey(); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XHatch& rHatch = pEntry->GetHatch(); + rOut << (long)rHatch.GetHatchStyle(); + rOut << rHatch.GetColor().GetRed(); + rOut << rHatch.GetColor().GetGreen(); + rOut << rHatch.GetColor().GetBlue(); + rOut << rHatch.GetDistance(); + rOut << rHatch.GetAngle(); + pEntry = (XHatchEntry*)aTable.Next(); + } + + return rOut; +} + +/************************************************************************/ + +SvStream& XHatchTable::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpTable; + pBmpTable = new Table( 16, 16 ); + + XHatchEntry* pEntry = NULL; + long nType; + long nCount; + long nIndex; + XubString aName; + + long nStyle; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + long nDistance; + long nAngle; + + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + rIn >> nDistance; + rIn >> nAngle; + + Color aColor ((USHORT)nRed, (USHORT)nGreen, (USHORT)nBlue); + XHatch aHatch(aColor, (XHatchStyle)nStyle, nDistance, nAngle); + pEntry = new XHatchEntry (aHatch, aName); + Insert (nIndex, pEntry); + } + } + return( rIn ); +} + +// ----------------- +// class XHatchList +// ----------------- + +/************************************************************************* +|* +|* XHatchList::XHatchList() +|* +*************************************************************************/ + +XHatchList::XHatchList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyList ( rPath, pInPool, nInitSize, nReSize), + pVD ( NULL ), + pXOut ( NULL ), + pXFSet ( NULL ) +{ + pBmpList = new List( nInitSize, nReSize ); +} + +/************************************************************************/ + +XHatchList::~XHatchList() +{ + if( pVD ) delete pVD; + if( pXOut ) delete pXOut; + if( pXFSet ) delete pXFSet; +} + +/************************************************************************/ + +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::Get(long nIndex) const +{ + return (XHatchEntry*) XPropertyList::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XHatchList::Load() +{ +#ifndef SVX_LIGHT + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtHatch, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_READ | STREAM_NOCREATE, + TRUE, // direkt + TRUE ); // Download + + SvStream* pStream = aMedium.GetInStream(); + if( !pStream ) + return( FALSE ); + + String aCheck; + // UNICODE: *pStream >> aCheck; + pStream->ReadByteString(aCheck); + + // Handelt es sich um die gew"unschte Tabelle? + if( aCheck == String(pszChckHatch, 4) || + aCheck == String(pszChckHatch0, 4) ) + { + ImpRead( *pStream ); + } + else + return( FALSE ); + + return( pStream->GetError() == SVSTREAM_OK ); + } +#endif + return( FALSE ); +} + +/************************************************************************/ + +BOOL XHatchList::Save() +{ +#ifndef SVX_LIGHT + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtHatch, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_WRITE | STREAM_TRUNC, + TRUE, // direkt + FALSE ); // Upload + aMedium.IsRemote(); + + SvStream* pStream = aMedium.GetOutStream(); + if( !pStream ) + return( FALSE ); + + // UNICODE: *pStream << String( pszChckHatch0, 4 ); + pStream->WriteByteString(String( pszChckHatch0, 4 )); + + ImpStore( *pStream ); + + aMedium.Close(); + aMedium.Commit(); + + return( aMedium.GetError() == 0 ); +#else + return FALSE; +#endif +} + +/************************************************************************/ + +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() +{ + 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 ); + } + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + + return( TRUE ); +} + +/************************************************************************/ + +Bitmap* XHatchList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + Point aZero; + + if( !pVD ) // und pXOut und pXFSet + { + pVD = new VirtualDevice; + DBG_ASSERT( pVD, "XHatchList: Konnte kein VirtualDevice erzeugen!" ); + //pVD->SetMapMode( MAP_100TH_MM ); + //pVD->SetOutputSize( pVD->PixelToLogic( Size( BITMAP_WIDTH, BITMAP_HEIGHT ) ) ); + pVD->SetOutputSizePixel( Size( BITMAP_WIDTH, BITMAP_HEIGHT ) ); + + pXOut = new XOutputDevice( pVD ); + DBG_ASSERT( pVD, "XHatchList: Konnte kein XOutDevice erzeugen!" ); + + pXFSet = new XFillAttrSetItem( pXPool ); + DBG_ASSERT( pVD, "XHatchList: Konnte kein XFillAttrSetItem erzeugen!" ); + } + + // Damit die Schraffuren mit Rahmen angezeigt werden: + // MapMode-Aenderungen (100th mm <--> Pixel) + Size aPixelSize = pVD->GetOutputSizePixel(); + pVD->SetMapMode( MAP_PIXEL ); + + pXFSet->GetItemSet().Put( XFillStyleItem( XFILL_SOLID ) ); + pXFSet->GetItemSet().Put( XFillColorItem( String(), RGB_Color( COL_WHITE ) ) ); + pXOut->SetFillAttr( *pXFSet ); + + // #73550# + pXOut->OverrideLineColor( Color( COL_BLACK ) ); + + pXOut->DrawRect( Rectangle( aZero, aPixelSize ) ); + + pVD->SetMapMode( MAP_100TH_MM ); + Size aVDSize = pVD->GetOutputSize(); + // 1 Pixel (Rahmen) abziehen + aVDSize.Width() -= (long) ( aVDSize.Width() / aPixelSize.Width() + 1 ); + aVDSize.Height() -= (long) ( aVDSize.Height() / aPixelSize.Height() + 1 ); + + pXFSet->GetItemSet().Put( XFillStyleItem( XFILL_HATCH ) ); + pXFSet->GetItemSet().Put( XFillHatchItem( String(), Get( nIndex )->GetHatch() ) ); + pXOut->SetFillAttr( *pXFSet ); + pXOut->DrawRect( Rectangle( aZero, aVDSize ) ); + + Bitmap* pBitmap = new Bitmap( pVD->GetBitmap( aZero, pVD->GetOutputSize() ) ); + + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( bDelete ) + { + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + } + + return( pBitmap ); +} + +/************************************************************************/ + +SvStream& XHatchList::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // Version statt Anzahl, um auch alte Tabellen zu lesen + rOut << (long) -1; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Eintraege + XHatchEntry* pEntry = NULL; + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + // Versionsverwaltung: Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + pEntry = Get(nIndex); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XHatch& rHatch = pEntry->GetHatch(); + rOut << (long)rHatch.GetHatchStyle(); +#ifdef VCL + USHORT nCol = rHatch.GetColor().GetRed(); + nCol = nCol << 8; + rOut << nCol; + + nCol = rHatch.GetColor().GetGreen(); + nCol = nCol << 8; + rOut << nCol; + + nCol = rHatch.GetColor().GetBlue(); + nCol = nCol << 8; + rOut << nCol; +#else + rOut << rHatch.GetColor().GetRed(); + rOut << rHatch.GetColor().GetGreen(); + rOut << rHatch.GetColor().GetBlue(); +#endif + rOut << rHatch.GetDistance(); + rOut << rHatch.GetAngle(); + } + + return rOut; +} + +/************************************************************************/ + +XubString& XHatchList::ConvertName( XubString& rStrName ) +{ + BOOL bFound = FALSE; + + for( USHORT i=0; i<(RID_SVXSTR_HATCH_DEF_END-RID_SVXSTR_HATCH_DEF_START+1) && !bFound; i++ ) + { + XubString aStrDefName = SVX_RESSTR( RID_SVXSTR_HATCH_DEF_START + i ); + if( rStrName.Search( aStrDefName ) == 0 ) + { + rStrName.Replace( 0, aStrDefName.Len(), SVX_RESSTR( RID_SVXSTR_HATCH_START + i ) ); + bFound = TRUE; + } + } + + return rStrName; +} + +/************************************************************************/ + +SvStream& XHatchList::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpList; + pBmpList = new List( 16, 16 ); + + XHatchEntry* pEntry = NULL; + long nCount; + XubString aName; + + long nStyle; + USHORT nRed; + USHORT nGreen; + USHORT nBlue; + long nDistance; + long nAngle; + Color aColor; + + rIn >> nCount; + + if( nCount >= 0 ) // Alte Tabellen (bis 3.00) + { + for( long nIndex = 0; nIndex < nCount; nIndex++ ) + { + // UNICODE:rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + rIn >> nDistance; + rIn >> nAngle; + +#ifdef VCL + aColor = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aColor = Color( nRed, nGreen, nBlue ); +#endif + XHatch aHatch(aColor, (XHatchStyle)nStyle, nDistance, nAngle); + pEntry = new XHatchEntry (aHatch, aName); + Insert (pEntry, nIndex); + } + } + else // ab 3.00a + { + rIn >> nCount; + + for( long nIndex = 0; nIndex < nCount; nIndex++ ) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + rIn >> nStyle; + rIn >> nRed; + rIn >> nGreen; + rIn >> nBlue; + rIn >> nDistance; + rIn >> nAngle; + + if (aIOC.GetVersion() > 0) + { + // lesen neuer Daten ... + } + +#ifdef VCL + aColor = Color( (BYTE) ( nRed >> 8 ), + (BYTE) ( nGreen >> 8 ), + (BYTE) ( nBlue >> 8 ) ); +#else + aColor = Color( nRed, nGreen, nBlue ); +#endif + XHatch aHatch(aColor, (XHatchStyle)nStyle, nDistance, nAngle); + pEntry = new XHatchEntry (aHatch, aName); + Insert (pEntry, nIndex); + } + } + return( rIn ); +} + + + diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx new file mode 100644 index 000000000000..e83e50052968 --- /dev/null +++ b/svx/source/xoutdev/xtable.cxx @@ -0,0 +1,544 @@ +/************************************************************************* + * + * $RCSfile: xtable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#include "xtable.hxx" +#include "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 ) : + aTable ( nInitSize, nReSize ), + aPath ( rPath ), + aName ( pszStandard, 8 ), + pXPool ( pInPool ), + 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 ) + { + delete 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 ) : + aList ( nInitSize, nReSize ), + aPath ( rPath ), + aName ( pszStandard, 8 ), + pXPool ( pInPool ), + 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 ) + { + delete 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..fc81fff0cf58 --- /dev/null +++ b/svx/source/xoutdev/xtablend.cxx @@ -0,0 +1,705 @@ +/************************************************************************* + * + * $RCSfile: xtablend.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 17:01:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// include --------------------------------------------------------------- + +#pragma hdrstop + +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif + +#ifndef _SV_VIRDEV_HXX +#include <vcl/virdev.hxx> +#endif + +#ifndef _SV_APP_HXX +#include <vcl/svapp.hxx> +#endif + +#ifndef _SFXITEMSET_HXX +#include <svtools/itemset.hxx> +#endif + +#ifndef _SFXDOCFILE_HXX +#include <sfx2/docfile.hxx> +#endif + +#include "dialogs.hrc" +#include "dialmgr.hxx" + +#include "xtable.hxx" +#include "xiocomp.hxx" +#include "xpool.hxx" +#include "xoutx.hxx" + +#ifndef SVX_XFILLIT0_HXX //autogen +#include <xfillit0.hxx> +#endif + +#ifndef _SVX_XFLCLIT_HXX //autogen +#include <xflclit.hxx> +#endif + +#ifndef _SVX_XLNSTWIT_HXX //autogen +#include <xlnstwit.hxx> +#endif + +#ifndef _SVX_XLNEDWIT_HXX //autogen +#include <xlnedwit.hxx> +#endif + +#ifndef _SVX_XLNCLIT_HXX //autogen +#include <xlnclit.hxx> +#endif + +#ifndef _SVX_XLINEIT0_HXX //autogen +#include <xlineit0.hxx> +#endif + +#ifndef _SVX_XLNSTIT_HXX //autogen +#include <xlnstit.hxx> +#endif + +#ifndef _SVX_XLNEDIT_HXX //autogen +#include <xlnedit.hxx> +#endif + +#define GLOBALOVERFLOW + +sal_Unicode const pszExtLineEnd[] = {'s','o','e'}; +sal_Unicode const pszChckLineEnd[] = {'S','O','E','L'}; +// Neuer Key, damit alte Version (3.00) nicht bei dem +// Versuch abstuerzt, eine neue Tabelle zu laden. +sal_Unicode const pszChckLineEnd0[] = {'S','O','E','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::Get(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 ); +} + +/************************************************************************/ + +SvStream& XLineEndTable::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // 2. Version + rOut << (long)-1; + + // Tabellentyp schreiben (0 = gesamte Tabelle) + rOut << (long)0; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Polygone + XLineEndEntry* pEntry = (XLineEndEntry*)aTable.First(); + for (long nIndex = 0; nIndex < Count(); nIndex++) + { + rOut << (long)aTable.GetCurKey(); + + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XPolygon& rXPoly = pEntry->GetLineEnd(); + rOut << rXPoly; + + pEntry = (XLineEndEntry*)aTable.Next(); + } + return rOut; +} + +/************************************************************************/ + +SvStream& XLineEndTable::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpTable; + pBmpTable = new Table( 16, 16 ); + + XLineEndEntry* pEntry = NULL; + long nVersion; + long nType; + long nCount; + long nIndex; + XubString aName; + long nFlags; + + rIn >> nVersion; + + if( nVersion == -1L ) // 2. Version + { + rIn >> nType; + + // gesamte Tabelle? + if (nType == 0) + { + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + USHORT nPoints; + ULONG nTemp; + Point aPoint; + rIn >> nTemp; nPoints = (USHORT)nTemp; + XPolygon* pXPoly = new XPolygon(nPoints); + for (USHORT nPoint = 0; nPoint < nPoints; nPoint++) + { + rIn >> aPoint.X(); + rIn >> aPoint.Y(); + rIn >> nFlags; + pXPoly->Insert(nPoint, aPoint, (XPolyFlags)nFlags); + } + + pEntry = new XLineEndEntry (*pXPoly, aName); + Insert (nIndex, pEntry); + } + } + } + else // 1. Version + { + nType = nVersion; + + // gesamte Tabelle? + if (nType == 0) + { + XPolygon aXPoly; + + rIn >> nCount; + for (long nI = 0; nI < nCount; nI++) + { + rIn >> nIndex; + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + rIn >> aXPoly; + XPolygon* pXPoly = new XPolygon( aXPoly ); + + pEntry = new XLineEndEntry( *pXPoly, aName ); + Insert( nIndex, pEntry ); + } + } + } + return( rIn ); +} + +// -------------------- +// class XLineEndList +// -------------------- + +/************************************************************************* +|* +|* XLineEndList::XLineEndList() +|* +*************************************************************************/ + +XLineEndList::XLineEndList( const String& rPath, + XOutdevItemPool* pInPool, + USHORT nInitSize, USHORT nReSize ) : + XPropertyList( rPath, pInPool, nInitSize, nReSize), + pVD ( NULL ), + pXOut ( NULL ), + pXFSet ( NULL ), + pXLSet ( NULL ) +{ + pBmpList = new List( nInitSize, nReSize ); +} + +/************************************************************************/ + +XLineEndList::~XLineEndList() +{ + if( pVD ) delete pVD; + if( pXOut ) delete pXOut; + if( pXFSet ) delete pXFSet; + if( pXLSet ) delete pXLSet; +} + +/************************************************************************/ + +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::Get(long nIndex) const +{ + return (XLineEndEntry*) XPropertyList::Get(nIndex, 0); +} + +/************************************************************************/ + +BOOL XLineEndList::Load() +{ +#ifndef SVX_LIGHT + if( bListDirty ) + { + bListDirty = FALSE; + + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtLineEnd, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_READ | STREAM_NOCREATE, + TRUE, // direkt + TRUE ); // Download + + SvStream* pStream = aMedium.GetInStream(); + if( !pStream ) + return( FALSE ); + + String aCheck; + + // UNICODE: *pStream >> aCheck; + pStream->ReadByteString(aCheck); + + // Handelt es sich um die gew'unschte Tabelle? + if( aCheck == String(pszChckLineEnd, 4) || + aCheck == String(pszChckLineEnd0, 4) ) + { + ImpRead( *pStream ); + } + else + return( FALSE ); + + return( pStream->GetError() == SVSTREAM_OK ); + } +#endif + return( FALSE ); +} + +/************************************************************************/ + +BOOL XLineEndList::Save() +{ +#ifndef SVX_LIGHT + INetURLObject aURL; + + aURL.SetSmartURL( aPath ); + aURL.Append( aName ); + + if( !aURL.getExtension().Len() ) + aURL.setExtension( String( pszExtLineEnd, 3 ) ); + + SfxMedium aMedium( aURL.PathToFileName(), + STREAM_WRITE | STREAM_TRUNC, + TRUE, // direkt + FALSE ); // Upload + aMedium.IsRemote(); + + SvStream* pStream = aMedium.GetOutStream(); + if( !pStream ) + return( FALSE ); + + // UNICODE: *pStream << String( pszChckLineEnd0, 4 ); + pStream->WriteByteString(String( pszChckLineEnd0, 4 )); + + ImpStore( *pStream ); + + aMedium.Close(); + aMedium.Commit(); + + return( aMedium.GetError() == 0 ); +#else + return FALSE; +#endif +} + +/************************************************************************/ + +BOOL XLineEndList::Create() +{ + XPolygon aTriangle(3); + aTriangle[0].X()=10; aTriangle[0].Y()= 0; + aTriangle[1].X()= 0; aTriangle[1].Y()=30; + aTriangle[2].X()=20; aTriangle[2].Y()=30; + Insert( new XLineEndEntry( aTriangle, SVX_RESSTR( RID_SVXSTR_ARROW ) ) ); + + XPolygon aSquare(4); + aSquare[0].X()= 0; aSquare[0].Y()= 0; + aSquare[1].X()=10; aSquare[1].Y()= 0; + aSquare[2].X()=10; aSquare[2].Y()=10; + aSquare[3].X()= 0; aSquare[3].Y()=10; + Insert( new XLineEndEntry( aSquare, SVX_RESSTR( RID_SVXSTR_SQUARE ) ) ); + + XPolygon aCircle(Point(0,0),100,100); + Insert( new XLineEndEntry( aCircle, SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) ); + + return( TRUE ); +} + +/************************************************************************/ + +BOOL XLineEndList::CreateBitmapsForUI() +{ + for( long i = 0; i < Count(); i++) + { + Bitmap* pBmp = CreateBitmapForUI( i, FALSE ); + DBG_ASSERT( pBmp, "XLineEndList: Bitmap(UI) konnte nicht erzeugt werden!" ); + + if( pBmp ) + pBmpList->Insert( pBmp, i ); + } + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + if( pXLSet ){ delete pXLSet; pXLSet = NULL; } + + return( TRUE ); +} + +/************************************************************************/ + +Bitmap* XLineEndList::CreateBitmapForUI( long nIndex, BOOL bDelete ) +{ + Point aZero; + Size aVDSize; + + if( !pVD ) // und pXOut und pXFSet und pXLSet + { + pVD = new VirtualDevice; + DBG_ASSERT( pVD, "XLineEndList: Konnte kein VirtualDevice erzeugen!" ); + pVD->SetMapMode( MAP_100TH_MM ); + aVDSize = pVD->PixelToLogic( Size( BITMAP_WIDTH * 2, BITMAP_HEIGHT ) ); + pVD->SetOutputSize( aVDSize ); + + pXOut = new XOutputDevice( pVD ); + DBG_ASSERT( pVD, "XLineEndList: Konnte kein XOutDevice erzeugen!" ); + + pXFSet = new XFillAttrSetItem( pXPool ); + DBG_ASSERT( pVD, "XLineEndList: Konnte kein XFillAttrSetItem erzeugen!" ); + pXFSet->GetItemSet().Put( XFillStyleItem( XFILL_SOLID ) ); + const StyleSettings& rStyleSettings = pVD->GetSettings().GetStyleSettings(); + pXFSet->GetItemSet().Put( XFillColorItem( String(), rStyleSettings.GetFieldColor() ) ); + + pXLSet = new XLineAttrSetItem( pXPool ); + DBG_ASSERT( pVD, "XLineEndList: Konnte kein XLineAttrSetItem erzeugen!" ); + pXLSet->GetItemSet().Put( XLineStartWidthItem( aVDSize.Height() ) ); + pXLSet->GetItemSet().Put( XLineEndWidthItem( aVDSize.Height() ) ); + pXLSet->GetItemSet().Put( XLineColorItem( String(), RGB_Color( COL_BLACK ) ) ); + + } + else + aVDSize = pVD->GetOutputSize(); + + pXLSet->GetItemSet().Put( XLineStyleItem( XLINE_NONE ) ); + pXOut->SetLineAttr( *pXLSet ); + pXOut->SetFillAttr( *pXFSet ); + pXOut->DrawRect( Rectangle( aZero, aVDSize ) ); + + pXLSet->GetItemSet().Put( XLineStyleItem( XLINE_SOLID ) ); + pXLSet->GetItemSet().Put( XLineStartItem( String(), Get( nIndex )->GetLineEnd() ) ); + pXLSet->GetItemSet().Put( XLineEndItem( String(), Get( nIndex )->GetLineEnd() ) ); + pXOut->SetLineAttr( *pXLSet ); + pXOut->DrawLine( Point( 0, aVDSize.Height() / 2 ), + Point( aVDSize.Width(), aVDSize.Height() / 2 ) ); + + Bitmap* pBitmap = new Bitmap( pVD->GetBitmap( aZero, aVDSize ) ); + + // Loeschen, da JOE den Pool vorm Dtor entfernt! + if( bDelete ) + { + if( pVD ) { delete pVD; pVD = NULL; } + if( pXOut ) { delete pXOut; pXOut = NULL; } + if( pXFSet ){ delete pXFSet; pXFSet = NULL; } + if( pXLSet ){ delete pXLSet; pXLSet = NULL; } + } + + return( pBitmap ); +} + +/************************************************************************/ + +SvStream& XLineEndList::ImpStore( SvStream& rOut ) +{ + // Schreiben + rOut.SetStreamCharSet( gsl_getSystemTextEncoding() ); + + // 3. Version + rOut << (long) -2; + + // Anzahl der Eintraege + rOut << (long)Count(); + + // die Polygone + XLineEndEntry* pEntry = NULL; + for( long nIndex = 0; nIndex < Count(); nIndex++ ) + { + // Versionsverwaltung (auch abwaertskompatibel): Version 0 + XIOCompat aIOC( rOut, STREAM_WRITE, 0 ); + + pEntry = Get( nIndex ); + // UNICODE: rOut << pEntry->GetName(); + rOut.WriteByteString(pEntry->GetName()); + + XPolygon& rXPoly = pEntry->GetLineEnd(); + rOut << rXPoly; + } + return rOut; +} + +/************************************************************************/ + +XubString& XLineEndList::ConvertName( XubString& rStrName ) +{ + BOOL bFound = FALSE; + + for( USHORT i=0; i<(RID_SVXSTR_LEND_DEF_END-RID_SVXSTR_LEND_DEF_START+1) && !bFound; i++ ) + { + XubString aStrDefName = SVX_RESSTR( RID_SVXSTR_LEND_DEF_START + i ); + if( rStrName.Search( aStrDefName ) == 0 ) + { + rStrName.Replace( 0, aStrDefName.Len(), SVX_RESSTR( RID_SVXSTR_LEND_START + i ) ); + bFound = TRUE; + } + } + + return rStrName; +} + +/************************************************************************/ + +SvStream& XLineEndList::ImpRead( SvStream& rIn ) +{ + // Lesen + rIn.SetStreamCharSet( RTL_TEXTENCODING_IBM_850 ); + + delete pBmpList; + pBmpList = new List( 16, 16 ); + + XLineEndEntry* pEntry = NULL; + long nVersion; + long nCount; + XubString aName; + long nFlags; + + rIn >> nVersion; + + if( nVersion >= 0 ) // 1. Version + { + nCount = nVersion; + for( long nI = 0; nI < nCount; nI++ ) + { + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + + aName = ConvertName( aName ); + USHORT nPoints; + ULONG nTemp; + Point aPoint; + rIn >> nTemp; nPoints = (USHORT)nTemp; + XPolygon* pXPoly = new XPolygon(nPoints); + for (USHORT nPoint = 0; nPoint < nPoints; nPoint++) + { + rIn >> aPoint.X(); + rIn >> aPoint.Y(); + rIn >> nFlags; + pXPoly->Insert(nPoint, aPoint, (XPolyFlags)nFlags); + } + + pEntry = new XLineEndEntry( *pXPoly, aName ); + Insert( pEntry, nI ); + } + } + else if( nVersion == -1L ) // 2. Version + { + rIn >> nCount; + for( long nI = 0; nI < nCount; nI++ ) + { + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + aName = ConvertName( aName ); + + XPolygon* pXPoly = new XPolygon; + rIn >> *pXPoly; + + pEntry = new XLineEndEntry( *pXPoly, aName ); + Insert( pEntry, nI ); + } + } + else // ab 3.00a + { + rIn >> nCount; + for( long nI = 0; nI < nCount; nI++ ) + { + // Versionsverwaltung + XIOCompat aIOC( rIn, STREAM_READ ); + + // UNICODE: rIn >> aName; + rIn.ReadByteString(aName); + aName = ConvertName( aName ); + + XPolygon aXPoly; + rIn >> aXPoly; + + if (aIOC.GetVersion() > 0) + { + // lesen neuer Daten ... + } + + pEntry = new XLineEndEntry( aXPoly, aName ); + Insert( pEntry, nI ); + } + } + return( rIn ); +} + + + |