diff options
Diffstat (limited to 'svx/source/unodraw')
31 files changed, 19882 insertions, 0 deletions
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx new file mode 100644 index 000000000000..6417be63f45c --- /dev/null +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -0,0 +1,1290 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <vector> +#include <vos/mutex.hxx> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/document/XMimeTypeInfo.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/graphic/XGraphicRenderer.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/task/XInteractionContinuation.hpp> + +#include <framework/interaction.hxx> +#include <com/sun/star/drawing/GraphicFilterRequest.hpp> +#include <com/sun/star/util/URL.hpp> +#include <cppuhelper/implbase4.hxx> +#include <osl/diagnose.h> +#include <osl/mutex.hxx> +#include <vcl/metaact.hxx> +#include <vcl/svapp.hxx> +#include <vcl/virdev.hxx> +#include <svtools/FilterConfigItem.hxx> +#include <svl/outstrm.hxx> +#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <svx/sdr/contact/viewcontact.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <svx/sdr/contact/viewcontactofsdrobj.hxx> +#include <editeng/numitem.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdograf.hxx> +#include "xoutbmp.hxx" +#include "svtools/filter.hxx" +#include "unoapi.hxx" +#include <svx/svdpage.hxx> +#include <svx/svdmodel.hxx> +#include <svx/fmview.hxx> +#include <svx/fmmodel.hxx> +#include <svx/unopage.hxx> +#include <svx/pageitem.hxx> +#include <editeng/eeitem.hxx> +#include <svx/svdoutl.hxx> +#include <editeng/flditem.hxx> + +#include "boost/scoped_ptr.hpp" + +#define MAX_EXT_PIX 2048 + +using namespace ::comphelper; +using namespace ::osl; +using namespace ::vos; +using ::rtl::OUString; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::task; +#include <svx/sdr/contact/viewobjectcontactredirector.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <svx/sdr/contact/viewcontact.hxx> + +// #i102251# +#include <editeng/editstat.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace svx +{ + struct ExportSettings + { + OUString maFilterName; + OUString maMediaType; + URL maURL; + com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > mxOutputStream; + com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicRenderer > mxGraphicRenderer; + com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > mxStatusIndicator; + com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > mxInteractionHandler; + + sal_Int32 mnWidth; + sal_Int32 mnHeight; + sal_Bool mbExportOnlyBackground; + sal_Bool mbVerboseComments; + sal_Bool mbScrollText; + sal_Bool mbUseHighContrast; + sal_Bool mbTranslucent; + + Sequence< PropertyValue > maFilterData; + + Fraction maScaleX; + Fraction maScaleY; + + ExportSettings( SdrModel* pDoc ); + }; + + ExportSettings::ExportSettings( SdrModel* pDoc ) + : mnWidth( 0 ) + , mnHeight( 0 ) + , mbExportOnlyBackground( false ) + , mbVerboseComments( false ) + , mbScrollText( false ) + , mbUseHighContrast( false ) + , mbTranslucent( sal_False ) + , maScaleX( 1, 1 ) + , maScaleY( 1, 1 ) + { + if( pDoc ) + { + maScaleX = pDoc->GetScaleFraction(); + maScaleY = pDoc->GetScaleFraction(); + } + } + + /** implements a component to export shapes or pages to external graphic formats. + + @implements com.sun.star.drawing.GraphicExportFilter + */ + class GraphicExporter : public WeakImplHelper4< XFilter, XExporter, XServiceInfo, XMimeTypeInfo > + { + public: + GraphicExporter(); + virtual ~GraphicExporter(); + + // XFilter + virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException); + virtual void SAL_CALL cancel( ) throw(RuntimeException); + + // XExporter + virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); + + // XMimeTypeInfo + virtual sal_Bool SAL_CALL supportsMimeType( const ::rtl::OUString& MimeTypeName ) throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedMimeTypeNames( ) throw (RuntimeException); + + VirtualDevice* CreatePageVDev( SdrPage* pPage, ULONG nWidthPixel, ULONG nHeightPixel ) const; + + DECL_LINK( CalcFieldValueHdl, EditFieldInfo* ); + + void ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings ); + bool GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, sal_Bool bVectorType ); + + private: + Reference< XShape > mxShape; + Reference< XDrawPage > mxPage; + Reference< XShapes > mxShapes; + + SvxDrawPage* mpUnoPage; + + Link maOldCalcFieldValueHdl; + sal_Int32 mnPageNumber; + SdrPage* mpCurrentPage; + SdrModel* mpDoc; + }; + + SVX_DLLPUBLIC Reference< XInterface > SAL_CALL GraphicExporter_createInstance(const Reference< XMultiServiceFactory > & ) + throw( Exception ) + { + return (XWeak*)new GraphicExporter(); + } + + SVX_DLLPUBLIC Sequence< OUString > SAL_CALL GraphicExporter_getSupportedServiceNames() + throw() + { + Sequence< OUString > aSupportedServiceNames( 1 ); + aSupportedServiceNames[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicExportFilter" ) ); + return aSupportedServiceNames; + } + + SVX_DLLPUBLIC OUString SAL_CALL GraphicExporter_getImplementationName() + throw() + { + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Draw.GraphicExporter" ) ); + } + + /** creates a bitmap that is optionaly transparent from a metafile + */ + BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, BOOL bTransparent, const Size* pSize ) + { + Graphic aGraphic( rMtf ); + BitmapEx aBmpEx; + + // #i102089# support user's settings of AA and LineSnap when the MetaFile gets + // rasterconverted to a bitmap + const SvtOptionsDrawinglayer aDrawinglayerOpt; + const GraphicConversionParameters aParameters( + pSize ? *pSize : Size(0, 0), + true, // allow unlimited size + aDrawinglayerOpt.IsAntiAliasing(), + aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete()); + + if( bTransparent ) + { + Graphic aMaskGraphic(rMtf.GetMonochromeMtf(COL_BLACK)); + Bitmap aMaskBmp(aMaskGraphic.GetBitmap(aParameters)); + + aMaskBmp.Convert(BMP_CONVERSION_1BIT_THRESHOLD); + aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters), aMaskBmp); + } + else + { + aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters)); + } + + aBmpEx.SetPrefMapMode( rMtf.GetPrefMapMode() ); + aBmpEx.SetPrefSize( rMtf.GetPrefSize() ); + + return aBmpEx; + } + + Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize ) + { + if( (nWidth == 0) && (nHeight == 0) ) + return NULL; + + if( (nWidth == 0) && (nHeight != 0) && (aBoundSize.Height() != 0) ) + { + nWidth = ( nHeight * aBoundSize.Width() ) / aBoundSize.Height(); + } + else if( (nWidth != 0) && (nHeight == 0) && (aBoundSize.Width() != 0) ) + { + nHeight = ( nWidth * aBoundSize.Height() ) / aBoundSize.Width(); + } + + aOutSize.Width() = nWidth; + aOutSize.Height() = nHeight; + + return &aOutSize; + } +} + +class ImplExportCheckVisisbilityRedirector : public ::sdr::contact::ViewObjectContactRedirector +{ +public: + ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage ); + virtual ~ImplExportCheckVisisbilityRedirector(); + + virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence( + const sdr::contact::ViewObjectContact& rOriginal, + const sdr::contact::DisplayInfo& rDisplayInfo); + +private: + SdrPage* mpCurrentPage; +}; + +ImplExportCheckVisisbilityRedirector::ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage ) +: ViewObjectContactRedirector(), mpCurrentPage( pCurrentPage ) +{ +} + +ImplExportCheckVisisbilityRedirector::~ImplExportCheckVisisbilityRedirector() +{ +} + +drawinglayer::primitive2d::Primitive2DSequence ImplExportCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence( + const sdr::contact::ViewObjectContact& rOriginal, + const sdr::contact::DisplayInfo& rDisplayInfo) +{ + SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject(); + + if(pObject) + { + SdrPage* pPage = mpCurrentPage; + if( pPage == 0 ) + pPage = pObject->GetPage(); + + if( (pPage == 0) || pPage->checkVisibility(rOriginal, rDisplayInfo, false) ) + { + return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo); + } + + return drawinglayer::primitive2d::Primitive2DSequence(); + } + else + { + // not an object, maybe a page + return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo); + } +} + +using namespace ::svx; + +GraphicExporter::GraphicExporter() +: mpUnoPage( NULL ), mnPageNumber(-1), mpCurrentPage(0), mpDoc( NULL ) +{ +} + +GraphicExporter::~GraphicExporter() +{ +} + +IMPL_LINK(GraphicExporter, CalcFieldValueHdl, EditFieldInfo*, pInfo) +{ + if( pInfo ) + { + if( mpCurrentPage ) + { + pInfo->SetSdrPage( mpCurrentPage ); + } + else if( mnPageNumber != -1 ) + { + const SvxFieldData* pField = pInfo->GetField().GetField(); + if( pField && pField->ISA( SvxPageField ) ) + { + String aPageNumValue; + BOOL bUpper = FALSE; + + switch(mpDoc->GetPageNumType()) + { + case SVX_CHARS_UPPER_LETTER: + aPageNumValue += (sal_Unicode)(char)((mnPageNumber - 1) % 26 + 'A'); + break; + case SVX_CHARS_LOWER_LETTER: + aPageNumValue += (sal_Unicode)(char)((mnPageNumber - 1) % 26 + 'a'); + break; + case SVX_ROMAN_UPPER: + bUpper = TRUE; + case SVX_ROMAN_LOWER: + aPageNumValue += SvxNumberFormat::CreateRomanString(mnPageNumber, bUpper); + break; + case SVX_NUMBER_NONE: + aPageNumValue.Erase(); + aPageNumValue += sal_Unicode(' '); + break; + default: + aPageNumValue += String::CreateFromInt32( (sal_Int32)mnPageNumber ); + } + + pInfo->SetRepresentation( aPageNumValue ); + + return(0); + } + } + } + + long nRet = maOldCalcFieldValueHdl.Call( pInfo ); + + if( pInfo && mpCurrentPage ) + pInfo->SetSdrPage( 0 ); + + return nRet; +} + +/** creates an virtual device for the given page + + @return the returned VirtualDevice is owned by the caller +*/ +VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, ULONG nWidthPixel, ULONG nHeightPixel ) const +{ + VirtualDevice* pVDev = new VirtualDevice(); + MapMode aMM( MAP_100TH_MM ); + + Point aPoint( 0, 0 ); + Size aPageSize(pPage->GetSize()); + + // use scaling? + if( nWidthPixel ) + { + const Fraction aFrac( (long) nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() ); + + aMM.SetScaleX( aFrac ); + + if( nHeightPixel == 0 ) + aMM.SetScaleY( aFrac ); + } + + if( nHeightPixel ) + { + const Fraction aFrac( (long) nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() ); + + if( nWidthPixel == 0 ) + aMM.SetScaleX( aFrac ); + + aMM.SetScaleY( aFrac ); + } + + pVDev->SetMapMode( aMM ); +#ifdef DBG_UTIL + BOOL bAbort = ! +#endif + pVDev->SetOutputSize(aPageSize); + DBG_ASSERT(!bAbort, "virt. Device nicht korrekt erzeugt"); + + SdrView* pView = new SdrView(mpDoc, pVDev); + pView->SetPageVisible( FALSE ); + pView->SetBordVisible( FALSE ); + pView->SetGridVisible( FALSE ); + pView->SetHlplVisible( FALSE ); + pView->SetGlueVisible( FALSE ); + pView->ShowSdrPage(pPage); + Region aRegion (Rectangle( aPoint, aPageSize ) ); + + ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage ); + + pView->CompleteRedraw(pVDev, aRegion, &aRedirector); + + delete pView; + return pVDev; +} + +void GraphicExporter::ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings ) +{ + sal_Int32 nArgs = aDescriptor.getLength(); + const PropertyValue* pValues = aDescriptor.getConstArray(); + while( nArgs-- ) + { + if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterName" ) ) ) + { + pValues->Value >>= rSettings.maFilterName; + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) + { + pValues->Value >>= rSettings.maMediaType; + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "URL" ) ) ) + { + if( !( pValues->Value >>= rSettings.maURL ) ) + { + pValues->Value >>= rSettings.maURL.Complete; + } + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OutputStream" ) ) ) + { + pValues->Value >>= rSettings.mxOutputStream; + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicRenderer" ) ) ) + { + pValues->Value >>= rSettings.mxGraphicRenderer; + } + else if ( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StatusIndicator" ) ) ) + { + pValues->Value >>= rSettings.mxStatusIndicator; + } + else if ( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "InteractionHandler" ) ) ) + { + pValues->Value >>= rSettings.mxInteractionHandler; + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) ) // for compatibility reasons, deprecated + { + pValues->Value >>= rSettings.mnWidth; + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Height" ) ) ) // for compatibility reasons, deprecated + { + pValues->Value >>= rSettings.mnHeight; + } + else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ExportOnlyBackground" ) ) ) // for compatibility reasons, deprecated + { + pValues->Value >>= rSettings.mbExportOnlyBackground; + } + else if ( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterData" ) ) ) + { + pValues->Value >>= rSettings.maFilterData; + + sal_Int32 nFilterArgs = rSettings.maFilterData.getLength(); + PropertyValue* pDataValues = rSettings.maFilterData.getArray(); + while( nFilterArgs-- ) + { + if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Translucent" ) ) ) + { + if ( !( pDataValues->Value >>= rSettings.mbTranslucent ) ) // SJ: TODO: The GIF Transparency is stored as int32 in + { // configuration files, this has to be changed to boolean + sal_Int32 nTranslucent = 0; + if ( pDataValues->Value >>= nTranslucent ) + rSettings.mbTranslucent = nTranslucent != 0; + } + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PixelWidth" ) ) ) + { + pDataValues->Value >>= rSettings.mnWidth; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PixelHeight" ) ) ) + { + pDataValues->Value >>= rSettings.mnHeight; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) ) // for compatibility reasons, deprecated + { + pDataValues->Value >>= rSettings.mnWidth; + pDataValues->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PixelWidth" ) ); + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Height" ) ) ) // for compatibility reasons, deprecated + { + pDataValues->Value >>= rSettings.mnHeight; + pDataValues->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PixelHeight" ) ); + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ExportOnlyBackground" ) ) ) + { + pDataValues->Value >>= rSettings.mbExportOnlyBackground; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HighContrast" ) ) ) + { + pDataValues->Value >>= rSettings.mbUseHighContrast; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PageNumber" ) ) ) + { + pDataValues->Value >>= mnPageNumber; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VerboseComments" ) ) ) + { + // #110496# Read flag for verbose metafile comments + pDataValues->Value >>= rSettings.mbVerboseComments; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScrollText" ) ) ) + { + // #110496# Read flag solitary scroll text metafile + pDataValues->Value >>= rSettings.mbScrollText; + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CurrentPage" ) ) ) + { + Reference< XDrawPage > xPage; + pDataValues->Value >>= xPage; + if( xPage.is() ) + { + SvxDrawPage* pUnoPage = SvxDrawPage::getImplementation( xPage ); + if( pUnoPage && pUnoPage->GetSdrPage() ) + mpCurrentPage = pUnoPage->GetSdrPage(); + } + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleXNumerator" ) ) ) + { + sal_Int32 nVal = 1; + if( pDataValues->Value >>= nVal ) + rSettings.maScaleX = Fraction( nVal, rSettings.maScaleX.GetDenominator() ); + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleXDenominator" ) ) ) + { + sal_Int32 nVal = 1; + if( pDataValues->Value >>= nVal ) + rSettings.maScaleX = Fraction( rSettings.maScaleX.GetNumerator(), nVal ); + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleYNumerator" ) ) ) + { + sal_Int32 nVal = 1; + if( pDataValues->Value >>= nVal ) + rSettings.maScaleY = Fraction( nVal, rSettings.maScaleY.GetDenominator() ); + } + else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleYDenominator" ) ) ) + { + sal_Int32 nVal = 1; + if( pDataValues->Value >>= nVal ) + rSettings.maScaleY = Fraction( rSettings.maScaleY.GetNumerator(), nVal ); + } + + pDataValues++; + } + } + + pValues++; + } + + // putting the StatusIndicator that we got from the MediaDescriptor into our local FilterData copy + if ( rSettings.mxStatusIndicator.is() ) + { + rtl::OUString sStatusIndicator( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) ); + int i = rSettings.maFilterData.getLength(); + rSettings.maFilterData.realloc( i + 1 ); + rSettings.maFilterData[ i ].Name = sStatusIndicator; + rSettings.maFilterData[ i ].Value <<= rSettings.mxStatusIndicator; + } +} + +bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, sal_Bool bVectorType ) +{ + if( !mpDoc || !mpUnoPage ) + return false; + + SdrPage* pPage = mpUnoPage->GetSdrPage(); + if( !pPage ) + return false; + + VirtualDevice aVDev; + const MapMode aMap( mpDoc->GetScaleUnit(), Point(), rSettings.maScaleX, rSettings.maScaleY ); + + // create a view + SdrView* pView; + + if( PTR_CAST( FmFormModel, mpDoc ) ) + { + pView = new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ); + } + else + { + pView = new SdrView( mpDoc, &aVDev ); + } + + pView->SetBordVisible( FALSE ); + pView->SetPageVisible( FALSE ); + pView->ShowSdrPage( pPage ); + + SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL); + maOldCalcFieldValueHdl = rOutl.GetCalcFieldValueHdl(); + rOutl.SetCalcFieldValueHdl( LINK(this, GraphicExporter, CalcFieldValueHdl) ); + rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pView->GetSdrPageView()) ); + + // #i102251# + const sal_uInt32 nOldCntrl(rOutl.GetControlWord()); + sal_uInt32 nCntrl = nOldCntrl & ~EE_CNTRL_ONLINESPELLING; + rOutl.SetControlWord(nCntrl); + + std::vector< SdrObject* > aShapes; + bool bRet = true; + + // export complete page? + if ( !mxShape.is() ) + { + if( rSettings.mbExportOnlyBackground ) + { + SdrObject* pShape = 0; + if( pPage->IsMasterPage() ) + { + if( pPage->GetObjCount() > 0 ) + pShape = pPage->GetObj(0); + } + else + { + pShape = pPage->GetBackgroundObj(); + } + + if( pShape ) + aShapes.push_back( pShape ); + } + else + { + const Size aSize( pPage->GetSize() ); + + // generate a bitmap to convert it to a pixel format. + // For gif pictures there can also be a vector format used (bTranslucent) + if ( !bVectorType && !rSettings.mbTranslucent ) + { + long nWidthPix = 0; + long nHeightPix = 0; + if ( rSettings.mnWidth > 0 && rSettings.mnHeight > 0 ) + { + nWidthPix = rSettings.mnWidth; + nHeightPix = rSettings.mnHeight; + } + else + { + const Size aSizePix( Application::GetDefaultDevice()->LogicToPixel( aSize, aMap ) ); + if (aSizePix.Width() > MAX_EXT_PIX || aSizePix.Height() > MAX_EXT_PIX) + { + if (aSizePix.Width() > MAX_EXT_PIX) + nWidthPix = MAX_EXT_PIX; + else + nWidthPix = aSizePix.Width(); + if (aSizePix.Height() > MAX_EXT_PIX) + nHeightPix = MAX_EXT_PIX; + else + nHeightPix = aSizePix.Height(); + + double fWidthDif = aSizePix.Width() / nWidthPix; + double fHeightDif = aSizePix.Height() / nHeightPix; + + if (fWidthDif > fHeightDif) + nHeightPix = static_cast<long>(aSizePix.Height() / fWidthDif); + else + nWidthPix = static_cast<long>(aSizePix.Width() / fHeightDif); + } + else + { + nWidthPix = aSizePix.Width(); + nHeightPix = aSizePix.Height(); + } + } + + boost::scoped_ptr< SdrView > pLocalView; + if( PTR_CAST( FmFormModel, mpDoc ) ) + { + pLocalView.reset( new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ) ); + } + else + { + pLocalView.reset( new SdrView( mpDoc, &aVDev ) ); + } + + + VirtualDevice* pVDev = CreatePageVDev( pPage, nWidthPix, nHeightPix ); + + if( pVDev ) + { + aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() ); + aGraphic.SetPrefMapMode( aMap ); + aGraphic.SetPrefSize( aSize ); + delete pVDev; + } + } + // create a metafile to export a vector format + else + { + GDIMetaFile aMtf; + + aVDev.SetMapMode( aMap ); + if( rSettings.mbUseHighContrast ) + aVDev.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ); + aVDev.EnableOutput( FALSE ); + aMtf.Record( &aVDev ); + + Size aNewSize; + if ( pView && pPage ) + { + pView->SetBordVisible( FALSE ); + pView->SetPageVisible( FALSE ); + pView->ShowSdrPage( pPage ); + + const Point aNewOrg( pPage->GetLftBorder(), pPage->GetUppBorder() ); + aNewSize = Size( aSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder(), + aSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder() ); + const Rectangle aClipRect( aNewOrg, aNewSize ); + MapMode aVMap( aMap ); + + aVDev.Push(); + aVMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) ); + aVDev.SetRelativeMapMode( aVMap ); + aVDev.IntersectClipRegion( aClipRect ); + + // Use new StandardCheckVisisbilityRedirector + ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage ); + + pView->CompleteRedraw(&aVDev, Region(Rectangle(Point(), aNewSize)), &aRedirector); + + aVDev.Pop(); + + aMtf.Stop(); + aMtf.WindStart(); + aMtf.SetPrefMapMode( aMap ); + aMtf.SetPrefSize( aNewSize ); + + // AW: Here the current version was filtering out the META_CLIPREGION_ACTIONs + // from the metafile. I asked some other developers why this was done, but no + // one knew a direct reason. Since it's in for long time, it may be an old + // piece of code. MetaFiles save and load ClipRegions with polygons with preserving + // the polygons, so a resolution-indepent roundtrip is supported. Removed this + // code since it destroys some MetaFiles where ClipRegions are used. Anyways, + // just filtering them out is a hack, at least the encapsulated content would need + // to be clipped geometrically. + aGraphic = Graphic(aMtf); + } + + if( rSettings.mbTranslucent ) + { + Size aOutSize; + aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), TRUE, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) ); + } + } + } + } + + // export only single shape or shape collection + else + { + // build list of SdrObject + if( mxShapes.is() ) + { + Reference< XShape > xShape; + const sal_Int32 nCount = mxShapes->getCount(); + + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + mxShapes->getByIndex( nIndex ) >>= xShape; + SdrObject* pObj = GetSdrObjectFromXShape( xShape ); + if( pObj ) + aShapes.push_back( pObj ); + } + } + else + { + // only one shape + SdrObject* pObj = GetSdrObjectFromXShape( mxShape ); + if( pObj ) + aShapes.push_back( pObj ); + } + + if( 0 == aShapes.size() ) + bRet = false; + } + + if( bRet && aShapes.size() ) + { + // special treatment for only one SdrGrafObj that has text + sal_Bool bSingleGraphic = sal_False; + + if( 1 == aShapes.size() ) + { + if( !bVectorType ) + { + SdrObject* pObj = aShapes.front(); + if( pObj && pObj->ISA( SdrGrafObj ) && !( (SdrGrafObj*) pObj )->HasText() ) + { + aGraphic = ( (SdrGrafObj*) pObj )->GetTransformedGraphic(); + if ( aGraphic.GetType() == GRAPHIC_BITMAP ) + { + Size aSizePixel( aGraphic.GetSizePixel() ); + if( rSettings.mnWidth && rSettings.mnHeight && + ( ( rSettings.mnWidth != aSizePixel.Width() ) || + ( rSettings.mnHeight != aSizePixel.Height() ) ) ) + { + BitmapEx aBmpEx( aGraphic.GetBitmapEx() ); + aBmpEx.Scale( Size( rSettings.mnWidth, rSettings.mnHeight ) ); + aGraphic = aBmpEx; + } + } + bSingleGraphic = sal_True; + } + } + else if( rSettings.mbScrollText ) + { + SdrObject* pObj = aShapes.front(); + if( pObj && pObj->ISA( SdrTextObj ) + && ( (SdrTextObj*) pObj )->HasText() ) + { + Rectangle aScrollRectangle; + Rectangle aPaintRectangle; + + const boost::scoped_ptr< GDIMetaFile > pMtf( + ( (SdrTextObj*) pObj )->GetTextScrollMetaFileAndRectangle( + aScrollRectangle, aPaintRectangle ) ); + + // take the larger one of the two rectangles (that + // should be the bound rect of the retrieved + // metafile) + Rectangle aTextRect; + + if( aScrollRectangle.IsInside( aPaintRectangle ) ) + aTextRect = aScrollRectangle; + else + aTextRect = aPaintRectangle; + + // setup pref size and mapmode + pMtf->SetPrefSize( aTextRect.GetSize() ); + + // set actual origin (mtf is at actual shape + // output position) + MapMode aLocalMapMode( aMap ); + aLocalMapMode.SetOrigin( + Point( -aPaintRectangle.Left(), + -aPaintRectangle.Top() ) ); + pMtf->SetPrefMapMode( aLocalMapMode ); + + pMtf->AddAction( new MetaCommentAction( + "XTEXT_SCROLLRECT", 0, + reinterpret_cast<BYTE const*>(&aScrollRectangle), + sizeof( Rectangle ) ) ); + pMtf->AddAction( new MetaCommentAction( + "XTEXT_PAINTRECT", 0, + reinterpret_cast<BYTE const*>(&aPaintRectangle), + sizeof( Rectangle ) ) ); + + aGraphic = Graphic( *pMtf ); + + bSingleGraphic = sal_True; + } + } + } + + if( !bSingleGraphic ) + { + // create a metafile for all shapes + VirtualDevice aOut; + + // calculate bound rect for all shapes + Rectangle aBound; + + if(rSettings.mbExportOnlyBackground) + { + // shape is MPBGO and if it's not yet set, it's size will + // be empty when using GetCurrentBoundRect(). Since anyways + // the page size is used by MPBGO and MPBGO is EOLd, get + // the wanted size from the page model directly + aBound = Rectangle(Point(0,0), pPage->GetSize()); + } + else + { + std::vector< SdrObject* >::iterator aIter = aShapes.begin(); + const std::vector< SdrObject* >::iterator aEnd = aShapes.end(); + + while( aIter != aEnd ) + { + SdrObject* pObj = (*aIter++); + Rectangle aR1(pObj->GetCurrentBoundRect()); + if (aBound.IsEmpty()) + aBound=aR1; + else + aBound.Union(aR1); + } + } + + aOut.EnableOutput( FALSE ); + aOut.SetMapMode( aMap ); + if( rSettings.mbUseHighContrast ) + aOut.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ); + + GDIMetaFile aMtf; + aMtf.Clear(); + aMtf.Record( &aOut ); + + MapMode aOutMap( aMap ); + aOutMap.SetOrigin( Point( -aBound.TopLeft().X(), -aBound.TopLeft().Y() ) ); + aOut.SetRelativeMapMode( aOutMap ); + + sdr::contact::DisplayInfo aDisplayInfo; + + if(mpCurrentPage) + { + if(mpCurrentPage->TRG_HasMasterPage() && pPage->IsMasterPage()) + { + // MasterPage is processed as another page's SubContent + aDisplayInfo.SetProcessLayers(mpCurrentPage->TRG_GetMasterPageVisibleLayers()); + aDisplayInfo.SetSubContentActive(true); + } + } + + if(aShapes.size()) + { + // more effective way to paint a vector of SdrObjects. Hand over the processed page + // to have it in the + sdr::contact::ObjectContactOfObjListPainter aMultiObjectPainter(aOut, aShapes, mpCurrentPage); + ImplExportCheckVisisbilityRedirector aCheckVisibilityRedirector(mpCurrentPage); + aMultiObjectPainter.SetViewObjectContactRedirector(&aCheckVisibilityRedirector); + + aMultiObjectPainter.ProcessDisplay(aDisplayInfo); + } + + aMtf.Stop(); + aMtf.WindStart(); + + const Size aExtSize( aOut.PixelToLogic( Size( 0, 0 ) ) ); + Size aBoundSize( aBound.GetWidth() + ( aExtSize.Width() ), + aBound.GetHeight() + ( aExtSize.Height() ) ); + + aMtf.SetPrefMapMode( aMap ); + aMtf.SetPrefSize( aBoundSize ); + + if( !bVectorType ) + { + Size aOutSize; + aGraphic = GetBitmapFromMetaFile( aMtf, rSettings.mbTranslucent, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) ); + } + else + { + aGraphic = aMtf; + } + } + } + + if ( pView ) + { + pView->HideSdrPage(); + delete pView; + } + + rOutl.SetCalcFieldValueHdl( maOldCalcFieldValueHdl ); + + // #i102251# + rOutl.SetControlWord(nOldCntrl); + + return bRet; + +} + +// XFilter +sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDescriptor ) + throw(RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( NULL == mpUnoPage ) + return sal_False; + + GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter(); + + if( NULL == pFilter || NULL == mpUnoPage->GetSdrPage() || NULL == mpDoc ) + return sal_False; + + // get the arguments from the descriptor + ExportSettings aSettings( mpDoc ); + ParseSettings( aDescriptor, aSettings ); + + const sal_uInt16 nFilter = aSettings.maMediaType.getLength() + ? pFilter->GetExportFormatNumberForMediaType( aSettings.maMediaType ) + : pFilter->GetExportFormatNumberForShortName( aSettings.maFilterName ); + sal_Bool bVectorType = !pFilter->IsExportPixelFormat( nFilter ); + + // create the output stuff + Graphic aGraphic; + + USHORT nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? GRFILTER_OK : GRFILTER_FILTERERROR; + + if( nStatus == GRFILTER_OK ) + { + // export graphic only if it has a size + const Size aGraphSize( aGraphic.GetPrefSize() ); + if ( ( aGraphSize.Width() == 0 ) || ( aGraphSize.Height() == 0 ) ) + { + nStatus = GRFILTER_FILTERERROR; + } + else + { + // now we have a graphic, so export it + if( aSettings.mxGraphicRenderer.is() ) + { + // render graphic directly into given renderer + aSettings.mxGraphicRenderer->render( aGraphic.GetXGraphic() ); + } + else if( aSettings.mxOutputStream.is() ) + { + // TODO: Either utilize optional XSeekable functionality for the + // SvOutputStream, or adapt the graphic filter to not seek anymore. + SvMemoryStream aStream( 1024, 1024 ); + + nStatus = pFilter->ExportGraphic( aGraphic, String(), aStream, nFilter, &aSettings.maFilterData ); + + // copy temp stream to XOutputStream + SvOutputStream aOutputStream( aSettings.mxOutputStream ); + aStream.Seek(0); + aOutputStream << aStream; + } + else + { + INetURLObject aURLObject( aSettings.maURL.Complete ); + DBG_ASSERT( aURLObject.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); + + nStatus = XOutBitmap::ExportGraphic( aGraphic, aURLObject, *pFilter, nFilter, &aSettings.maFilterData ); + } + } + } + + if ( aSettings.mxInteractionHandler.is() && ( nStatus != GRFILTER_OK ) ) + { + Any aInteraction; + Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations(1); + ::framework::ContinuationApprove* pApprove = new ::framework::ContinuationApprove(); + lContinuations[0] = Reference< XInteractionContinuation >(static_cast< XInteractionContinuation* >(pApprove), UNO_QUERY); + + GraphicFilterRequest aErrorCode; + aErrorCode.ErrCode = nStatus; + aInteraction <<= aErrorCode; + framework::InteractionRequest* pRequest = new framework::InteractionRequest( aInteraction, lContinuations ); + Reference< XInteractionRequest >xRequest( static_cast< XInteractionRequest* >(pRequest), UNO_QUERY ); + aSettings.mxInteractionHandler->handle( xRequest ); + } + return nStatus == GRFILTER_OK; +} + +void SAL_CALL GraphicExporter::cancel() + throw(RuntimeException) +{ +} + +// XExporter + +/** the source 'document' could be a XDrawPage, a XShape or a generic XShapes */ +void SAL_CALL GraphicExporter::setSourceDocument( const Reference< lang::XComponent >& xComponent ) + throw(IllegalArgumentException, RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + mxShapes = NULL; + mpUnoPage = NULL; + + try + { + // any break inside this one loop while will throw a IllegalArgumentException + do + { + mxPage = Reference< XDrawPage >::query( xComponent ); + mxShapes = Reference< XShapes >::query( xComponent ); + mxShape = Reference< XShape >::query( xComponent ); + + // Step 1: try a generic XShapes + if( !mxPage.is() && !mxShape.is() && mxShapes.is() ) + { + // we do not support empty shape collections + if( 0 == mxShapes->getCount() ) + break; + + // get first shape to detect corresponding page and model + mxShapes->getByIndex(0) >>= mxShape; + } + else + { + mxShapes = NULL; + } + + // Step 2: try a shape + if( mxShape.is() ) + { + if( NULL == GetSdrObjectFromXShape( mxShape ) ) + break; + + // get page for this shape + Reference< XChild > xChild( mxShape, UNO_QUERY ); + if( !xChild.is() ) + break; + + Reference< XInterface > xInt; + do + { + xInt = xChild->getParent(); + mxPage = Reference< XDrawPage >::query( xInt ); + if( !mxPage.is() ) + xChild = Reference< XChild >::query( xInt ); + } + while( !mxPage.is() && xChild.is() ); + + if( !mxPage.is() ) + break; + } + + // Step 3: check the page + if( !mxPage.is() ) + break; + + mpUnoPage = SvxDrawPage::getImplementation( mxPage ); + + if( NULL == mpUnoPage || NULL == mpUnoPage->GetSdrPage() ) + break; + + mpDoc = mpUnoPage->GetSdrPage()->GetModel(); + + // Step 4: If we got a generic XShapes test all contained shapes + // if they belong to the same XDrawPage + + if( mxShapes.is() ) + { + SdrPage* pPage = mpUnoPage->GetSdrPage(); + SdrObject* pObj; + Reference< XShape > xShape; + + sal_Bool bOk = sal_True; + + const sal_Int32 nCount = mxShapes->getCount(); + + // test all but the first shape if they have the same page than + // the first shape + for( sal_Int32 nIndex = 1; bOk && ( nIndex < nCount ); nIndex++ ) + { + mxShapes->getByIndex( nIndex ) >>= xShape; + pObj = GetSdrObjectFromXShape( xShape ); + bOk = pObj && pObj->GetPage() == pPage; + } + + if( !bOk ) + break; + } + + // no errors so far + return; + } + while( 0 ); + } + catch( Exception& ) + { + } + + throw IllegalArgumentException(); +} + +// XServiceInfo +OUString SAL_CALL GraphicExporter::getImplementationName( ) + throw(RuntimeException) +{ + return GraphicExporter_getImplementationName(); +} + +sal_Bool SAL_CALL GraphicExporter::supportsService( const OUString& ServiceName ) + throw(RuntimeException) +{ + Sequence< OUString > aSeq( GraphicExporter_getSupportedServiceNames() ); + sal_Int32 nArgs = aSeq.getLength(); + const OUString* pService = aSeq.getConstArray(); + while( nArgs-- ) + if( *pService++ == ServiceName ) + return sal_True; + + return sal_False; +} + +Sequence< OUString > SAL_CALL GraphicExporter::getSupportedServiceNames( ) + throw(RuntimeException) +{ + return GraphicExporter_getSupportedServiceNames(); +} + +// XMimeTypeInfo +sal_Bool SAL_CALL GraphicExporter::supportsMimeType( const OUString& MimeTypeName ) throw (RuntimeException) +{ + const String aMimeTypeName( MimeTypeName ); + + GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter(); + sal_uInt16 nCount = pFilter->GetExportFormatCount(); + sal_uInt16 nFilter; + for( nFilter = 0; nFilter < nCount; nFilter++ ) + { + if( aMimeTypeName.Equals( pFilter->GetExportFormatMediaType( nFilter ) ) ) + { + return sal_True; + } + } + + return sal_False; +} + +Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames( ) throw (RuntimeException) +{ + GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter(); + sal_uInt16 nCount = pFilter->GetExportFormatCount(); + sal_uInt16 nFilter; + sal_uInt16 nFound = 0; + + Sequence< OUString > aSeq( nCount ); + OUString* pStr = aSeq.getArray(); + + for( nFilter = 0; nFilter < nCount; nFilter++ ) + { + OUString aMimeType( pFilter->GetExportFormatMediaType( nFilter ) ); + if( aMimeType.getLength() ) + { + *pStr++ = aMimeType; + nFound++; + } + } + + if( nFound < nCount ) + aSeq.realloc( nFound ); + + return aSeq; +} + +Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector ) +{ + Graphic aGraphic; + try + { + rtl::Reference< GraphicExporter > xExporter( new GraphicExporter() ); + Reference< XComponent > xComp( rShape.getUnoShape(), UNO_QUERY_THROW ); + xExporter->setSourceDocument( xComp ); + ExportSettings aSettings( rShape.GetModel() ); + xExporter->GetGraphic( aSettings, aGraphic, bVector ); + } + catch( Exception& ) + { + DBG_ERROR("SvxGetGraphicForShape(), exception caught!"); + } + return aGraphic; +} + diff --git a/svx/source/unodraw/UnoGraphicExporter.hxx b/svx/source/unodraw/UnoGraphicExporter.hxx new file mode 100644 index 000000000000..ebf0ac7a7a9c --- /dev/null +++ b/svx/source/unodraw/UnoGraphicExporter.hxx @@ -0,0 +1,40 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SVX_UNOGRAPHICEXPORTER_HXX_ +#define _SVX_UNOGRAPHICEXPORTER_HXX_ + +#include <com/sun/star/uno/XInterface.hpp> + +namespace svx +{ + SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GraphicExporter_createInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( ::com::sun::star::uno::Exception ); + SVX_DLLPUBLIC ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GraphicExporter_getSupportedServiceNames() throw(); + SVX_DLLPUBLIC ::rtl::OUString SAL_CALL GraphicExporter_getImplementationName() throw(); +} + +#endif diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx new file mode 100644 index 000000000000..a802af33fbbd --- /dev/null +++ b/svx/source/unodraw/UnoNameItemTable.cxx @@ -0,0 +1,341 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <set> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <comphelper/stl_types.hxx> + +#include <svx/svdmodel.hxx> +#include "UnoNameItemTable.hxx" +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +#include "unoapi.hxx" + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; +using namespace ::vos; + +SvxUnoNameItemTable::SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich, BYTE nMemberId ) throw() +: mpModel( pModel ), + mpModelPool( pModel ? &pModel->GetItemPool() : NULL ), + mnWhich( nWhich ), mnMemberId( nMemberId ) +{ + if( pModel ) + StartListening( *pModel ); +} + +SvxUnoNameItemTable::~SvxUnoNameItemTable() throw() +{ + if( mpModel ) + EndListening( *mpModel ); + dispose(); +} + +bool SvxUnoNameItemTable::isValid( const NameOrIndex* pItem ) const +{ + return pItem && (pItem->GetName().Len() != 0); +} + +void SvxUnoNameItemTable::dispose() +{ + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + while( aIter != aEnd ) + { + delete (*aIter++); + } + + maItemSetVector.clear(); +} + +void SvxUnoNameItemTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() +{ + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + + if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() ) + dispose(); +} + +sal_Bool SAL_CALL SvxUnoNameItemTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); + const OUString * pArray = aSNL.getConstArray(); + + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + + return FALSE; +} + +void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement ) +{ + SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich ); + maItemSetVector.push_back( mpInSet ); + + NameOrIndex* pNewItem = createItem(); + pNewItem->SetName( String( aName ) ); + pNewItem->PutValue( aElement, mnMemberId ); + mpInSet->Put( *pNewItem, mnWhich ); + delete pNewItem; +} + +// XNameContainer +void SAL_CALL SvxUnoNameItemTable::insertByName( const OUString& aApiName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( hasByName( aApiName ) ) + throw container::ElementExistException(); + + String aName; + SvxUnogetInternalNameForItem( mnWhich, aApiName, aName ); + + ImplInsertByName( aName, aElement ); +} + + + +void SAL_CALL SvxUnoNameItemTable::removeByName( const OUString& aApiName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + // a little quickfix for 2.0 to let applications clear api + // created items that are not used + if( aApiName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("~clear~") ) ) + { + dispose(); + return; + } + + String Name; + SvxUnogetInternalNameForItem( mnWhich, aApiName, Name ); + + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( Name ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter)->Get( mnWhich ) ); + if( pItem->GetName() == aSearchName ) + { + delete (*aIter); + maItemSetVector.erase( aIter ); + return; + } + aIter++; + } + + if( !hasByName( Name ) ) + throw container::NoSuchElementException(); +} + +// XNameReplace +void SAL_CALL SvxUnoNameItemTable::replaceByName( const OUString& aApiName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aName; + SvxUnogetInternalNameForItem( mnWhich, aApiName, aName ); + + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( aName ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter)->Get( mnWhich ) ); + if( pItem->GetName() == aSearchName ) + { + NameOrIndex* pNewItem = createItem(); + pNewItem->SetName( aSearchName ); + if( !pNewItem->PutValue( aElement, mnMemberId ) || !isValid( pNewItem ) ) + throw lang::IllegalArgumentException(); + + (*aIter)->Put( *pNewItem ); + return; + } + aIter++; + } + + // if it is not in our own sets, modify the pool! + sal_Bool bFound = sal_False; + + USHORT nSurrogate; + USHORT nCount = mpModelPool ? mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) + { + pItem->PutValue( aElement, mnMemberId ); + bFound = sal_True; + break; + } + } + + if( bFound ) + ImplInsertByName( aName, aElement ); + else + throw container::NoSuchElementException(); + + if( !hasByName( aName ) ) + throw container::NoSuchElementException(); +} + +// XNameAccess +uno::Any SAL_CALL SvxUnoNameItemTable::getByName( const OUString& aApiName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aName; + SvxUnogetInternalNameForItem( mnWhich, aApiName, aName ); + + uno::Any aAny; + + if( mpModelPool && aName.Len() != 0 ) + { + const String aSearchName( aName ); + NameOrIndex *pItem; + sal_Int32 nSurrogate; + + sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( isValid( pItem ) && (pItem->GetName() == aSearchName) ) + { + pItem->QueryValue( aAny, mnMemberId ); + return aAny; + } + } + } + + throw container::NoSuchElementException(); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoNameItemTable::getElementNames( ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + std::set< OUString, comphelper::UStringLess > aNameSet; + + NameOrIndex *pItem; + OUString aApiName; + + const sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0; + sal_Int32 nSurrogate; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( !isValid( pItem ) ) + continue; + + SvxUnogetApiNameForItem( mnWhich, pItem->GetName(), aApiName ); + aNameSet.insert( aApiName ); + } + + uno::Sequence< OUString > aSeq( aNameSet.size() ); + OUString* pNames = aSeq.getArray(); + + std::set< OUString, comphelper::UStringLess >::iterator aIter( aNameSet.begin() ); + const std::set< OUString, comphelper::UStringLess >::iterator aEnd( aNameSet.end() ); + + while( aIter != aEnd ) + { + *pNames++ = *aIter++; + } + + return aSeq; +} + +sal_Bool SAL_CALL SvxUnoNameItemTable::hasByName( const OUString& aApiName ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aName; + SvxUnogetInternalNameForItem( mnWhich, aApiName, aName ); + + if( aName.Len() == 0 ) + return sal_False; + + const String aSearchName( aName ); + USHORT nSurrogate; + + const NameOrIndex *pItem; + + USHORT nCount = mpModelPool ? mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, nSurrogate ); + if( isValid( pItem ) && (pItem->GetName() == aSearchName) ) + return sal_True; + } + + return sal_False; +} + +sal_Bool SAL_CALL SvxUnoNameItemTable::hasElements( ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const NameOrIndex *pItem; + + sal_Int32 nSurrogate; + const sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( isValid( pItem ) ) + return sal_True; + } + + return sal_False; +} diff --git a/svx/source/unodraw/UnoNameItemTable.hxx b/svx/source/unodraw/UnoNameItemTable.hxx new file mode 100644 index 000000000000..2f864f6f72d2 --- /dev/null +++ b/svx/source/unodraw/UnoNameItemTable.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#define _SVX_UNONAMEITEMTABLE_HXX_ + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameContainer.hpp> + +#include <cppuhelper/implbase2.hxx> + +#include <vector> +#include <svl/lstner.hxx> +#include <svx/xit.hxx> + +#include <svx/xdef.hxx> + +class SdrModel; +class SfxItemPool; +class SfxItemSet; + +typedef std::vector< SfxItemSet* > ItemPoolVector; +class SvxUnoNameItemTable : public cppu::WeakImplHelper2< com::sun::star::container::XNameContainer, com::sun::star::lang::XServiceInfo >, + public SfxListener +{ +private: + SdrModel* mpModel; + SfxItemPool* mpModelPool; + USHORT mnWhich; + BYTE mnMemberId; + + ItemPoolVector maItemSetVector; + + void SAL_CALL ImplInsertByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ); + +public: + SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich, BYTE nMemberId ) throw(); + virtual ~SvxUnoNameItemTable() throw(); + + virtual NameOrIndex* createItem() const throw() = 0; + virtual bool isValid( const NameOrIndex* pItem ) const; + + void dispose(); + + // SfxListener + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw (); + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( com::sun::star::uno::RuntimeException); + + // XNameContainer + virtual void SAL_CALL insertByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::ElementExistException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const rtl::OUString& Name ) throw( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + + // XNameAccess + virtual com::sun::star::uno::Any SAL_CALL getByName( const rtl::OUString& aName ) throw( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw( com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) throw( com::sun::star::uno::RuntimeException); +}; + +#endif // _SVX_UNONAMEITEMTABLE_HXX_ diff --git a/svx/source/unodraw/UnoNamespaceMap.cxx b/svx/source/unodraw/UnoNamespaceMap.cxx new file mode 100644 index 000000000000..5c7ad5226aff --- /dev/null +++ b/svx/source/unodraw/UnoNamespaceMap.cxx @@ -0,0 +1,314 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <set> + +#include "UnoNamespaceMap.hxx" +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#include <osl/diagnose.h> +#include <osl/mutex.hxx> +#include <comphelper/stl_types.hxx> +#include <svl/itempool.hxx> +#include "unoapi.hxx" +#include "editeng/xmlcnitm.hxx" + + +using namespace ::comphelper; +using namespace ::osl; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; + +namespace svx +{ + /** implements a component to export namespaces of all SvXMLAttrContainerItem inside + one or two pools with a variable count of which ids. + */ + class NamespaceMap : public WeakImplHelper2< XNameAccess, XServiceInfo > + { + private: + sal_uInt16* mpWhichIds; + SfxItemPool* mpPool; + + public: + NamespaceMap( sal_uInt16* pWhichIds, SfxItemPool* pPool ); + virtual ~NamespaceMap(); + + // XNameAccess + virtual Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (RuntimeException); + + // XElementAccess + virtual Type SAL_CALL getElementType( ) throw (RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); + }; + + Reference< XInterface > SAL_CALL NamespaceMap_createInstance( sal_uInt16* pWhichIds, SfxItemPool* pPool1, SfxItemPool* ) + { + return (XWeak*)new NamespaceMap( pWhichIds, pPool1 ); + } + + Reference< XInterface > SAL_CALL NamespaceMap_createInstance( sal_uInt16* pWhichIds, SfxItemPool* pPool ) + { + return (XWeak*)new NamespaceMap( pWhichIds, pPool ); + } + + Sequence< ::rtl::OUString > SAL_CALL NamespaceMap_getSupportedServiceNames() + throw() + { + Sequence< ::rtl::OUString > aSupportedServiceNames( 1 ); + aSupportedServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.NamespaceMap" ) ); + return aSupportedServiceNames; + } + + ::rtl::OUString SAL_CALL NamespaceMap_getImplementationName() + throw() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Svx.NamespaceMap" ) ); + } + + + + class NamespaceIteratorImpl + { + private: + SfxItemPool* mpPool; + + sal_uInt16* mpWhichId; + + sal_uInt16 mnItemCount; + sal_uInt16 mnItem; + + const SvXMLAttrContainerItem* mpCurrentAttr; + sal_uInt16 mnCurrentAttr; + + public: + + NamespaceIteratorImpl( sal_uInt16* pWhichIds, SfxItemPool* pPool ); + + sal_Bool next( ::rtl::OUString& rPrefix, ::rtl::OUString& rURL ); + }; +} + +using namespace ::svx; + +// ------------- + +NamespaceIteratorImpl::NamespaceIteratorImpl( sal_uInt16* pWhichIds, SfxItemPool* pPool ) +{ + mpPool = pPool; + mpCurrentAttr = NULL; + mnCurrentAttr = 0; + + mpWhichId = pWhichIds; + + mnItem = 0; + mnItemCount = (mpWhichId && (0 != *mpWhichId) && mpPool) ? mpPool->GetItemCount( *mpWhichId ) : 0; +} + +sal_Bool NamespaceIteratorImpl::next( ::rtl::OUString& rPrefix, ::rtl::OUString& rURL ) +{ + // we still need to process the current attribute + if( mpCurrentAttr && (mnCurrentAttr != USHRT_MAX) ) + { + rPrefix = mpCurrentAttr->GetPrefix( mnCurrentAttr ); + rURL = mpCurrentAttr->GetNamespace( mnCurrentAttr ); + + mnCurrentAttr = mpCurrentAttr->GetNextNamespaceIndex( mnCurrentAttr ); + return sal_True; + } + + // we need the next namespace item + mpCurrentAttr = NULL; + + const SfxPoolItem* pItem = 0; + // look for the next available item in the current pool + while( (mnItem < mnItemCount) && ( NULL == (pItem = mpPool->GetItem( *mpWhichId, mnItem ) ) ) ) + mnItem++; + + // are we finished with the current whichid? + if( mnItem == mnItemCount ) + { + mpWhichId++; + + // are we finished with the current pool? + if( 0 != *mpWhichId ) + { + mnItem = 0; + mnItemCount = (mpWhichId && (0 != *mpWhichId) && mpPool) ? mpPool->GetItemCount( *mpWhichId ) : 0; + return next( rPrefix, rURL ); + } + + pItem = NULL; + } + + if( pItem ) + { + mnItem++; + + // get that item and see if there namespaces inside + const SvXMLAttrContainerItem *pUnknown = (const SvXMLAttrContainerItem *)pItem; + if( (pUnknown->GetAttrCount() > 0) ) + { + mpCurrentAttr = pUnknown; + mnCurrentAttr = pUnknown->GetFirstNamespaceIndex(); + } + return next( rPrefix, rURL ); + } + + return false; +} + +// ------------- + +NamespaceMap::NamespaceMap( sal_uInt16* pWhichIds, SfxItemPool* pPool ) +: mpWhichIds( pWhichIds ), mpPool( pPool ) +{ +} + +NamespaceMap::~NamespaceMap() +{ +} + +// XNameAccess +Any SAL_CALL NamespaceMap::getByName( const ::rtl::OUString& aName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException) +{ + NamespaceIteratorImpl aIter( mpWhichIds, mpPool ); + + ::rtl::OUString aPrefix; + ::rtl::OUString aURL; + + sal_Bool bFound; + + do + { + bFound = aIter.next( aPrefix, aURL ); + } + while( bFound && (aPrefix != aName ) ); + + if( !bFound ) + throw NoSuchElementException(); + + return makeAny( aURL ); +} + +Sequence< ::rtl::OUString > SAL_CALL NamespaceMap::getElementNames() throw (RuntimeException) +{ + NamespaceIteratorImpl aIter( mpWhichIds, mpPool ); + + ::rtl::OUString aPrefix; + ::rtl::OUString aURL; + + std::set< ::rtl::OUString, comphelper::UStringLess > aPrefixSet; + + while( aIter.next( aPrefix, aURL ) ) + aPrefixSet.insert( aPrefix ); + + Sequence< ::rtl::OUString > aSeq( aPrefixSet.size() ); + ::rtl::OUString* pPrefixes = aSeq.getArray(); + + std::set< ::rtl::OUString, comphelper::UStringLess >::iterator aPrefixIter( aPrefixSet.begin() ); + const std::set< ::rtl::OUString, comphelper::UStringLess >::iterator aEnd( aPrefixSet.end() ); + + while( aPrefixIter != aEnd ) + { + *pPrefixes++ = *aPrefixIter++; + } + + return aSeq; +} + +sal_Bool SAL_CALL NamespaceMap::hasByName( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + NamespaceIteratorImpl aIter( mpWhichIds, mpPool ); + + ::rtl::OUString aPrefix; + ::rtl::OUString aURL; + + sal_Bool bFound; + + do + { + bFound = aIter.next( aPrefix, aURL ); + } + while( bFound && (aPrefix != aName ) ); + + return bFound; +} + +// XElementAccess +Type SAL_CALL NamespaceMap::getElementType() throw (RuntimeException) +{ + return ::getCppuType( (const ::rtl::OUString*) 0 ); +} + +sal_Bool SAL_CALL NamespaceMap::hasElements() throw (RuntimeException) +{ + NamespaceIteratorImpl aIter( mpWhichIds, mpPool ); + + ::rtl::OUString aPrefix; + ::rtl::OUString aURL; + + return aIter.next( aPrefix, aURL ); +} + +// XServiceInfo +::rtl::OUString SAL_CALL NamespaceMap::getImplementationName( ) + throw(RuntimeException) +{ + return NamespaceMap_getImplementationName(); +} + +sal_Bool SAL_CALL NamespaceMap::supportsService( const ::rtl::OUString& ) + throw(RuntimeException) +{ + return sal_True; +} + +Sequence< ::rtl::OUString > SAL_CALL NamespaceMap::getSupportedServiceNames( ) + throw(RuntimeException) +{ + return NamespaceMap_getSupportedServiceNames(); +} diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx new file mode 100644 index 000000000000..6f69b1405d0e --- /dev/null +++ b/svx/source/unodraw/XPropertyTable.cxx @@ -0,0 +1,743 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "XPropertyTable.hxx" +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include <com/sun/star/drawing/LineDash.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/drawing/Hatch.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +#include <cppuhelper/implbase2.hxx> +#include "unopolyhelper.hxx" +#include <svx/xdef.hxx> + +#include "unoapi.hxx" +#include <editeng/unoprnms.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> + +using namespace com::sun::star; +using namespace ::cppu; +using namespace ::rtl; +using namespace ::vos; + +class SvxUnoXPropertyTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +{ +private: + XPropertyTable* mpTable; + XPropertyList* mpList; + sal_Int16 mnWhich; + + long getCount() const { return mpList ? mpList->Count() : (mpTable?mpTable->Count():0); } + XPropertyEntry* get( long index ) const; +public: + SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw(); + SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyTable* pTable ) throw(); + + virtual ~SvxUnoXPropertyTable() throw(); + + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() = 0; + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() = 0; + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); + virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XNameAccess + virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); + + // XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); +}; + +SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyTable* pTable ) throw() +: mpTable( pTable ), mpList( NULL ), mnWhich( nWhich ) +{ +} + +SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw() +: mpTable( NULL ), mpList( pList ), mnWhich( nWhich ) +{ +} + +SvxUnoXPropertyTable::~SvxUnoXPropertyTable() throw() +{ +} + +XPropertyEntry* SvxUnoXPropertyTable::get( long index ) const +{ + if( mpTable ) + return mpTable->Get( index, 0 ); + else if( mpList ) + return mpList->Get( index, 0 ); + else + return NULL; +} + +// XServiceInfo +sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName ) + throw( uno::RuntimeException) +{ + const uno::Sequence< OUString > aServices( getSupportedServiceNames() ); + const OUString* pServices = aServices.getConstArray(); + const sal_Int32 nCount = aServices.getLength(); + sal_Int32 i; + for( i = 0; i < nCount; i++ ) + { + if( *pServices++ == ServiceName ) + return sal_True; + } + + return sal_False; +} + +// XNameContainer +void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( NULL == mpList && NULL == mpTable ) + throw lang::IllegalArgumentException(); + + if( hasByName( aName ) ) + throw container::ElementExistException(); + + String aInternalName; + SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName ); + + XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement ); + if( NULL == pNewEntry ) + throw lang::IllegalArgumentException(); + + if( mpList ) + mpList->Insert( pNewEntry ); + else + mpTable->Insert( mpTable->Count(), pNewEntry ); +} + +void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aInternalName; + SvxUnogetInternalNameForItem( mnWhich, Name, aInternalName ); + + const long nCount = getCount(); + long i; + XPropertyEntry* pEntry; + for( i = 0; i < nCount; i++ ) + { + pEntry = get( i ); + if( pEntry && pEntry->GetName() == aInternalName ) + { + if( mpList ) + delete mpList->Remove( i, 0 ); + else + delete mpTable->Remove( i, 0 ); + return; + } + } + + throw container::NoSuchElementException(); +} + +// XNameReplace +void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aInternalName; + SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName ); + + const long nCount = getCount(); + long i; + XPropertyEntry* pEntry; + for( i = 0; i < nCount; i++ ) + { + pEntry = get( i ); + if( pEntry && pEntry->GetName() == aInternalName ) + { + XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement ); + if( NULL == pNewEntry ) + throw lang::IllegalArgumentException(); + + if( mpList ) + delete mpList->Replace( pNewEntry, i ); + else + delete mpTable->Replace( i, pNewEntry ); + return; + } + } + + throw container::NoSuchElementException(); +} + +// XNameAccess +uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aInternalName; + SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName ); + + const long nCount = getCount(); + long i; + XPropertyEntry* pEntry; + for( i = 0; i < nCount; i++ ) + { + pEntry = get( i ); + + if( pEntry && pEntry->GetName() == aInternalName ) + return getAny( pEntry ); + } + + throw container::NoSuchElementException(); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames() + throw( uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const long nCount = getCount(); + uno::Sequence< OUString > aNames( nCount ); + OUString* pNames = aNames.getArray(); + long i; + XPropertyEntry* pEntry; + for( i = 0; i < nCount; i++ ) + { + pEntry = get( i ); + + if( pEntry ) + { + SvxUnogetApiNameForItem( mnWhich, pEntry->GetName(), *pNames ); + pNames++; + } + } + + return aNames; +} + +sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName ) + throw( uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aInternalName; + SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName ); + + const long nCount = mpList?mpList->Count():0; + long i; + XPropertyEntry* pEntry; + for( i = 0; i < nCount; i++ ) + { + pEntry = get( i ); + if( pEntry && pEntry->GetName() == aInternalName ) + return sal_True; + } + + return sal_False; +} + +// XElementAccess +sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( ) + throw( uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + return getCount() != 0; +} + +/////////////////////////////////////////////////////////////////////// + +class SvxUnoXColorTable : public SvxUnoXPropertyTable +{ +public: + SvxUnoXColorTable( XPropertyTable* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pTable ) {}; + + // SvxUnoXPropertyTable + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(); + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); +}; + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoXColorTable_createInstance( XPropertyTable* pTable ) throw() +{ + return (OWeakObject*) new SvxUnoXColorTable( pTable ); +} + +// SvxUnoXPropertyTable +uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw() +{ + uno::Any aAny; + aAny <<= (sal_Int32)((XColorEntry*)pEntry)->GetColor().GetColor(); + return aAny; +} + +XPropertyEntry* SvxUnoXColorTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +{ + sal_Int32 nColor = 0; + if( !(rAny >>= nColor) ) + return NULL; + + const Color aColor( (ColorData)nColor ); + const String aName( rName ); + return new XColorEntry( aColor, aName ); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoXColorTable::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType((const sal_Int32*)0); +} + +// XServiceInfo +OUString SAL_CALL SvxUnoXColorTable::getImplementationName( ) throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXColorTable" ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( ) throw( uno::RuntimeException) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ColorTable" ) ); + uno::Sequence< OUString > aServices( &aServiceName, 1 ); + return aServices; +} + +/////////////////////////////////////////////////////////////////////// + +class SvxUnoXLineEndTable : public SvxUnoXPropertyTable +{ +public: + SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {}; + + // SvxUnoXPropertyTable + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(); + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); +}; + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw() +{ + return (OWeakObject*)new SvxUnoXLineEndTable( pTable ); +} + +// SvxUnoXPropertyTable +uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw() +{ + + uno::Any aAny; + drawing::PolyPolygonBezierCoords aBezier; + SvxConvertB2DPolyPolygonToPolyPolygonBezier( ((XLineEndEntry*)pEntry)->GetLineEnd(), aBezier ); + aAny <<= aBezier; + return aAny; +} + +XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +{ + + if( !rAny.getValue() || rAny.getValueType() != ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) ) + return NULL; + + basegfx::B2DPolyPolygon aPolyPolygon; + drawing::PolyPolygonBezierCoords* pCoords = (drawing::PolyPolygonBezierCoords*)rAny.getValue(); + if( pCoords->Coordinates.getLength() > 0 ) + aPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords ); + + // #86265# make sure polygon is closed + aPolyPolygon.setClosed(true); + + const String aName( rName ); + return new XLineEndEntry( aPolyPolygon, aName ); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType((const drawing::PolyPolygonBezierCoords*)0); +} + +// XServiceInfo +OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( ) throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXLineEndTable" ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( ) throw( uno::RuntimeException) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineEndTable" ) ); + uno::Sequence< OUString > aServices( &aServiceName, 1 ); + return aServices; +} + +/////////////////////////////////////////////////////////////////////// + +class SvxUnoXDashTable : public SvxUnoXPropertyTable +{ +public: + SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {}; + + // SvxUnoXPropertyTable + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(); + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); +}; + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw() +{ + return (OWeakObject*)new SvxUnoXDashTable( pTable ); +} + +// SvxUnoXPropertyTable +uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw() +{ + const XDash& rXD = ((XDashEntry*)pEntry)->GetDash(); + + 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(); + + uno::Any aAny; + aAny <<= aLineDash; + return aAny; +} + +XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +{ + drawing::LineDash aLineDash; + if(!(rAny >>= aLineDash)) + return NULL; + + 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); + + const String aName( rName ); + return new XDashEntry( aXDash, aName ); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoXDashTable::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType((const drawing::LineDash*)0); +} + +// XServiceInfo +OUString SAL_CALL SvxUnoXDashTable::getImplementationName( ) throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXDashTable" ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( ) throw( uno::RuntimeException) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) ); + uno::Sequence< OUString > aServices( &aServiceName, 1 ); + return aServices; +} + +/////////////////////////////////////////////////////////////////////// + +class SvxUnoXHatchTable : public SvxUnoXPropertyTable +{ +public: + SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {}; + + // SvxUnoXPropertyTable + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(); + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); +}; + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw() +{ + return (OWeakObject*)new SvxUnoXHatchTable( pTable ); +} + +// SvxUnoXPropertyTable +uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw() +{ + const XHatch& aHatch = ((XHatchEntry*)pEntry)->GetHatch(); + + drawing::Hatch aUnoHatch; + + aUnoHatch.Style = (drawing::HatchStyle)aHatch.GetHatchStyle(); + aUnoHatch.Color = aHatch.GetColor().GetColor(); + aUnoHatch.Distance = aHatch.GetDistance(); + aUnoHatch.Angle = aHatch.GetAngle(); + + uno::Any aAny; + aAny <<= aUnoHatch; + return aAny; +} + +XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +{ + drawing::Hatch aUnoHatch; + if(!(rAny >>= aUnoHatch)) + return NULL; + + XHatch aXHatch; + aXHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style ); + aXHatch.SetColor( aUnoHatch.Color ); + aXHatch.SetDistance( aUnoHatch.Distance ); + aXHatch.SetAngle( aUnoHatch.Angle ); + + const String aName( rName ); + return new XHatchEntry( aXHatch, aName ); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoXHatchTable::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType((const drawing::Hatch*)0); +} + +// XServiceInfo +OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( ) throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXHatchTable" ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( ) throw( uno::RuntimeException) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) ); + uno::Sequence< OUString > aServices( &aServiceName, 1 ); + return aServices; +} + +/////////////////////////////////////////////////////////////////////// + +class SvxUnoXGradientTable : public SvxUnoXPropertyTable +{ +public: + SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {}; + + // SvxUnoXPropertyTable + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(); + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); +}; + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw() +{ + return (OWeakObject*)new SvxUnoXGradientTable( pTable ); +} + +// SvxUnoXPropertyTable +uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw() +{ + const XGradient& aXGradient = ((XGradientEntry*)pEntry)->GetGradient(); + awt::Gradient aGradient; + + aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle(); + aGradient.StartColor = (INT32)aXGradient.GetStartColor().GetColor(); + aGradient.EndColor = (INT32)aXGradient.GetEndColor().GetColor(); + aGradient.Angle = (short)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(); + + uno::Any aAny; + aAny <<= aGradient; + return aAny; +} + +XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +{ + awt::Gradient aGradient; + if(!(rAny >>= aGradient)) + return NULL; + + 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 ); + + const String aName( rName ); + return new XGradientEntry( aXGradient, aName ); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoXGradientTable::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType((const awt::Gradient*)0); +} + +// XServiceInfo +OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( ) throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXGradientTable" ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) ); + uno::Sequence< OUString > aServices( &aServiceName, 1 ); + return aServices; +} + +/////////////////////////////////////////////////////////////////////// + +class SvxUnoXBitmapTable : public SvxUnoXPropertyTable +{ +public: + SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {}; + + // SvxUnoXPropertyTable + virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(); + virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); +}; + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw() +{ + return (OWeakObject*)new SvxUnoXBitmapTable( pTable ); +} + +// SvxUnoXPropertyTable +uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const throw() +{ + OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); + aURL += OUString::createFromAscii( ((XBitmapEntry*)pEntry)->GetXBitmap().GetGraphicObject().GetUniqueID().GetBuffer() ); + + uno::Any aAny; + aAny <<= aURL; + return aAny; +} + +XPropertyEntry* SvxUnoXBitmapTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +{ + OUString aURL; + if(!(rAny >>= aURL)) + return NULL; + + GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); + XOBitmap aBMP( aGrafObj ); + + const String aName( rName ); + return new XBitmapEntry( aBMP, aName ); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType((const OUString*)0); +} + +// XServiceInfo +OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( ) throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXBitmapTable" ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( ) throw( uno::RuntimeException) +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ); + uno::Sequence< OUString > aServices( &aServiceName, 1 ); + return aServices; +} diff --git a/svx/source/unodraw/gluepts.cxx b/svx/source/unodraw/gluepts.cxx new file mode 100644 index 000000000000..eb5cd8ec5231 --- /dev/null +++ b/svx/source/unodraw/gluepts.cxx @@ -0,0 +1,548 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/container/XIdentifierContainer.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#ifndef _COM_SUN_STAR_DRAWING_GLUEPOINT2_HDL_ +#include <com/sun/star/drawing/GluePoint2.hpp> +#endif + +#include <cppuhelper/implbase2.hxx> + +#include <svx/svdmodel.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdglue.hxx> +#include <svx/svdpage.hxx> + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +const USHORT NON_USER_DEFINED_GLUE_POINTS = 4; + +class SvxUnoGluePointAccess : public WeakImplHelper2< container::XIndexContainer, container::XIdentifierContainer > +{ +private: + SdrObjectWeakRef mpObject; + +public: + SvxUnoGluePointAccess( SdrObject* pObject ) throw(); + virtual ~SvxUnoGluePointAccess() throw(); + + // XIdentifierContainer + virtual sal_Int32 SAL_CALL insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); + virtual void SAL_CALL removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XIdentifierReplace + virtual void SAL_CALL replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XIdentifierReplace + virtual uno::Any SAL_CALL getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + virtual uno::Sequence< sal_Int32 > SAL_CALL getIdentifiers( ) throw (uno::RuntimeException); + + /* deprecated */ + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + + /* deprecated */ + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + + /* deprecated */ + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) throw(uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); +}; + +static void convert( const SdrGluePoint& rSdrGlue, drawing::GluePoint2& rUnoGlue ) throw() +{ + rUnoGlue.Position.X = rSdrGlue.GetPos().X(); + rUnoGlue.Position.Y = rSdrGlue.GetPos().Y(); + rUnoGlue.IsRelative = rSdrGlue.IsPercent(); + + switch( rSdrGlue.GetAlign() ) + { + case SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT: + rUnoGlue.PositionAlignment = drawing::Alignment_TOP_LEFT; + break; + case SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP: + rUnoGlue.PositionAlignment = drawing::Alignment_TOP; + break; + case SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT: + rUnoGlue.PositionAlignment = drawing::Alignment_TOP_RIGHT; + break; + case SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER: + rUnoGlue.PositionAlignment = drawing::Alignment_CENTER; + break; + case SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER: + rUnoGlue.PositionAlignment = drawing::Alignment_RIGHT; + break; + case SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM: + rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_LEFT; + break; + case SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM: + rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM; + break; + case SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM: + rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_RIGHT; + break; +// case SDRHORZALIGN_LEFT: + default: + rUnoGlue.PositionAlignment = drawing::Alignment_LEFT; + break; + } + + switch( rSdrGlue.GetEscDir() ) + { + case SDRESC_LEFT: + rUnoGlue.Escape = drawing::EscapeDirection_LEFT; + break; + case SDRESC_RIGHT: + rUnoGlue.Escape = drawing::EscapeDirection_RIGHT; + break; + case SDRESC_TOP: + rUnoGlue.Escape = drawing::EscapeDirection_UP; + break; + case SDRESC_BOTTOM: + rUnoGlue.Escape = drawing::EscapeDirection_DOWN; + break; + case SDRESC_HORZ: + rUnoGlue.Escape = drawing::EscapeDirection_HORIZONTAL; + break; + case SDRESC_VERT: + rUnoGlue.Escape = drawing::EscapeDirection_VERTICAL; + break; +// case SDRESC_SMART: + default: + rUnoGlue.Escape = drawing::EscapeDirection_SMART; + break; + } +} + +static void convert( const drawing::GluePoint2& rUnoGlue, SdrGluePoint& rSdrGlue ) throw() +{ + rSdrGlue.SetPos( Point( rUnoGlue.Position.X, rUnoGlue.Position.Y ) ); + rSdrGlue.SetPercent( rUnoGlue.IsRelative ); + + switch( rUnoGlue.PositionAlignment ) + { + case drawing::Alignment_TOP_LEFT: + rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT ); + break; + case drawing::Alignment_TOP: + rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP ); + break; + case drawing::Alignment_TOP_RIGHT: + rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT ); + break; + case drawing::Alignment_CENTER: + rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER ); + break; + case drawing::Alignment_RIGHT: + rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER ); + break; + case drawing::Alignment_BOTTOM_LEFT: + rSdrGlue.SetAlign( SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM ); + break; + case drawing::Alignment_BOTTOM: + rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM ); + break; + case drawing::Alignment_BOTTOM_RIGHT: + rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM ); + break; +// case SDRHORZALIGN_LEFT: + default: + rSdrGlue.SetAlign( SDRHORZALIGN_LEFT ); + break; + } + switch( rUnoGlue.Escape ) + { + case drawing::EscapeDirection_LEFT: + rSdrGlue.SetEscDir(SDRESC_LEFT); + break; + case drawing::EscapeDirection_RIGHT: + rSdrGlue.SetEscDir(SDRESC_RIGHT); + break; + case drawing::EscapeDirection_UP: + rSdrGlue.SetEscDir(SDRESC_TOP); + break; + case drawing::EscapeDirection_DOWN: + rSdrGlue.SetEscDir(SDRESC_BOTTOM); + break; + case drawing::EscapeDirection_HORIZONTAL: + rSdrGlue.SetEscDir(SDRESC_HORZ); + break; + case drawing::EscapeDirection_VERTICAL: + rSdrGlue.SetEscDir(SDRESC_VERT); + break; +// case drawing::EscapeDirection_SMART: + default: + rSdrGlue.SetEscDir(SDRESC_SMART); + break; + } +} + +SvxUnoGluePointAccess::SvxUnoGluePointAccess( SdrObject* pObject ) throw() +: mpObject( pObject ) +{ +} + +SvxUnoGluePointAccess::~SvxUnoGluePointAccess() throw() +{ +} + +// XIdentifierContainer +sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpObject.is() ) + { + SdrGluePointList* pList = mpObject->ForceGluePointList(); + if( pList ) + { + // second, insert the new glue point + drawing::GluePoint2 aUnoGlue; + + if( aElement >>= aUnoGlue ) + { + SdrGluePoint aSdrGlue; + convert( aUnoGlue, aSdrGlue ); + USHORT nId = pList->Insert( aSdrGlue ); + + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); + + return (sal_Int32)((*pList)[nId].GetId() + NON_USER_DEFINED_GLUE_POINTS) - 1; + } + + throw lang::IllegalArgumentException(); + } + } + + return -1; +} + +void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpObject.is() && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS )) + { + const USHORT nId = (USHORT)(Identifier - NON_USER_DEFINED_GLUE_POINTS) + 1; + + SdrGluePointList* pList = const_cast<SdrGluePointList*>(mpObject->GetGluePointList()); + const USHORT nCount = pList ? pList->GetCount() : 0; + USHORT i; + + for( i = 0; i < nCount; i++ ) + { + if( (*pList)[i].GetId() == nId ) + { + pList->Delete( i ); + + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); + + return; + } + } + } + + throw container::NoSuchElementException(); +} + +// XIdentifierReplace +void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpObject.is() && mpObject->IsNode() ) + { + struct drawing::GluePoint2 aGluePoint; + if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint)) + throw lang::IllegalArgumentException(); + + const USHORT nId = (USHORT)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1; + + SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() ); + const USHORT nCount = pList ? pList->GetCount() : 0; + USHORT i; + for( i = 0; i < nCount; i++ ) + { + if( (*pList)[i].GetId() == nId ) + { + // change the glue point + SdrGluePoint& rTempPoint = (*pList)[i]; + convert( aGluePoint, rTempPoint ); + + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); + + return; + } + } + + throw container::NoSuchElementException(); + } +} + +// XIdentifierAccess +uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpObject.is() && mpObject->IsNode() ) + { + struct drawing::GluePoint2 aGluePoint; + + if( Identifier < NON_USER_DEFINED_GLUE_POINTS ) // default glue point? + { + SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (USHORT)Identifier ); + aGluePoint.IsUserDefined = sal_False; + convert( aTempPoint, aGluePoint ); + return uno::makeAny( aGluePoint ); + } + else + { + const USHORT nId = (USHORT)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1; + + const SdrGluePointList* pList = mpObject->GetGluePointList(); + const USHORT nCount = pList ? pList->GetCount() : 0; + for( USHORT i = 0; i < nCount; i++ ) + { + const SdrGluePoint& rTempPoint = (*pList)[i]; + if( rTempPoint.GetId() == nId ) + { + // #i38892# + if(rTempPoint.IsUserDefined()) + { + aGluePoint.IsUserDefined = sal_True; + } + + convert( rTempPoint, aGluePoint ); + return uno::makeAny( aGluePoint ); + } + } + } + } + + throw lang::IndexOutOfBoundsException(); +} + +uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers() throw (uno::RuntimeException) +{ + if( mpObject.is() ) + { + const SdrGluePointList* pList = mpObject->GetGluePointList(); + const USHORT nCount = pList ? pList->GetCount() : 0; + + USHORT i; + + uno::Sequence< sal_Int32 > aIdSequence( nCount + NON_USER_DEFINED_GLUE_POINTS ); + sal_Int32 *pIdentifier = aIdSequence.getArray(); + + for( i = 0; i < NON_USER_DEFINED_GLUE_POINTS; i++ ) + *pIdentifier++ = (sal_Int32)i; + + for( i = 0; i < nCount; i++ ) + *pIdentifier++ = (sal_Int32) ( (*pList)[i].GetId() + NON_USER_DEFINED_GLUE_POINTS ) - 1; + + return aIdSequence; + } + else + { + uno::Sequence< sal_Int32 > aEmpty; + return aEmpty; + } +} + +/* deprecated */ + +// XIndexContainer +void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& Element ) + throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpObject.is() ) + { + SdrGluePointList* pList = mpObject->ForceGluePointList(); + if( pList ) + { + SdrGluePoint aSdrGlue; + drawing::GluePoint2 aUnoGlue; + + if( Element >>= aUnoGlue ) + { + convert( aUnoGlue, aSdrGlue ); + pList->Insert( aSdrGlue ); + + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); + + return; + } + + throw lang::IllegalArgumentException(); + } + } + + throw lang::IndexOutOfBoundsException(); +} + +void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpObject.is() ) + { + SdrGluePointList* pList = mpObject->ForceGluePointList(); + if( pList ) + { + Index -= 4; + if( Index >= 0 && Index < pList->GetCount() ) + { + pList->Delete( (USHORT)Index ); + + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); + + return; + } + } + } + + throw lang::IndexOutOfBoundsException(); +} + +// XIndexReplace +void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno::Any& Element ) + throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) +{ + drawing::GluePoint2 aUnoGlue; + if(!(Element >>= aUnoGlue)) + throw lang::IllegalArgumentException(); + + Index -= 4; + if( mpObject.is() && Index >= 0 ) + { + SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() ); + if( pList && Index < pList->GetCount() ) + { + SdrGluePoint& rGlue = (*pList)[(USHORT)Index]; + convert( aUnoGlue, rGlue ); + + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); + } + } + + throw lang::IndexOutOfBoundsException(); +} + +// XIndexAccess +sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount() + throw(uno::RuntimeException) +{ + sal_Int32 nCount = 0; + if( mpObject.is() ) + { + // each node has a default of 4 glue points + // and any number of user defined glue points + if( mpObject->IsNode() ) + { + nCount += 4; + + const SdrGluePointList* pList = mpObject->GetGluePointList(); + if( pList ) + nCount += pList->GetCount(); + } + } + + return nCount; +} + +uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( Index >= 0 && mpObject.is() && mpObject->IsNode() ) + { + struct drawing::GluePoint2 aGluePoint; + + if( Index < 4 ) // default glue point? + { + SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (USHORT)Index ); + aGluePoint.IsUserDefined = sal_False; + convert( aTempPoint, aGluePoint ); + uno::Any aAny; + aAny <<= aGluePoint; + return aAny; + } + else + { + Index -= 4; + const SdrGluePointList* pList = mpObject->GetGluePointList(); + if( pList && Index < pList->GetCount() ) + { + const SdrGluePoint& rTempPoint = (*pList)[(USHORT)Index]; + aGluePoint.IsUserDefined = sal_True; + convert( rTempPoint, aGluePoint ); + uno::Any aAny; + aAny <<= aGluePoint; + return aAny; + } + } + } + + throw lang::IndexOutOfBoundsException(); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType() + throw( uno::RuntimeException) +{ + return ::getCppuType((const struct drawing::GluePoint2*)0); +} + +sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements() + throw( uno::RuntimeException) +{ + return mpObject.is() && mpObject->IsNode(); +} + +/** + * Create a SvxUnoGluePointAccess + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject ) +{ + return *new SvxUnoGluePointAccess(pObject); +} diff --git a/svx/source/unodraw/makefile.mk b/svx/source/unodraw/makefile.mk new file mode 100644 index 000000000000..6815f28f4c79 --- /dev/null +++ b/svx/source/unodraw/makefile.mk @@ -0,0 +1,83 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=svx +TARGET=unodraw +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +LIB1TARGET= $(SLB)$/$(TARGET)-core.lib +LIB1OBJFILES= \ + $(SLO)$/UnoGraphicExporter.obj \ + $(SLO)$/XPropertyTable.obj \ + $(SLO)$/UnoNameItemTable.obj \ + $(SLO)$/unoshape.obj \ + $(SLO)$/unoshap2.obj \ + $(SLO)$/unoshap3.obj \ + $(SLO)$/unoshap4.obj \ + $(SLO)$/unopage.obj \ + $(SLO)$/unoshtxt.obj \ + $(SLO)$/unoprov.obj \ + $(SLO)$/unomod.obj \ + $(SLO)$/unomlstr.obj \ + $(SLO)$/unogtabl.obj \ + $(SLO)$/unohtabl.obj \ + $(SLO)$/unobtabl.obj \ + $(SLO)$/unottabl.obj \ + $(SLO)$/unomtabl.obj \ + $(SLO)$/unodtabl.obj \ + $(SLO)$/gluepts.obj \ + $(SLO)$/tableshape.obj \ + $(SLO)$/shapepropertynotifier.obj + +LIB2TARGET= $(SLB)$/$(TARGET).lib +LIB2OBJFILES= \ + $(SLO)$/UnoNamespaceMap.obj \ + $(SLO)$/unopool.obj \ + $(SLO)$/unoctabl.obj \ + $(SLO)$/unoshcol.obj \ + $(SLO)$/recoveryui.obj + +SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES) + +SRS1NAME=unodraw +SRC1FILES = \ + unodraw.src + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/svx/source/unodraw/recoveryui.cxx b/svx/source/unodraw/recoveryui.cxx new file mode 100644 index 000000000000..a945105a5eba --- /dev/null +++ b/svx/source/unodraw/recoveryui.cxx @@ -0,0 +1,399 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +//=============================================== +// includes +#include "recoveryui.hxx" +#include "docrecovery.hxx" +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFramesSupplier.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <osl/file.hxx> +#include <rtl/bootstrap.hxx> +#include <comphelper/configurationhelper.hxx> + +#include <vcl/svapp.hxx> + +//=============================================== +// const + +#define IMPLEMENTATIONNAME_RECOVERYUI ::rtl::OUString::createFromAscii("com.sun.star.comp.svx.RecoveryUI") +#define SERVICENAME_RECOVERYUI ::rtl::OUString::createFromAscii("com.sun.star.dialog.RecoveryUI") + +//=============================================== +// namespace + +namespace svx +{ + +namespace css = ::com::sun::star; +namespace svxdr = ::svx::DocRecovery; + +using namespace ::rtl; +using namespace ::osl; + +//=============================================== +RecoveryUI::RecoveryUI(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) + : m_xSMGR (xSMGR ) + , m_pParentWindow(0 ) + , m_eJob (RecoveryUI::E_JOB_UNKNOWN) +{ +} + +//=============================================== +RecoveryUI::~RecoveryUI() +{ +} + +//=============================================== +::rtl::OUString SAL_CALL RecoveryUI::getImplementationName() + throw(css::uno::RuntimeException) +{ + return RecoveryUI::st_getImplementationName(); +} + +//=============================================== +sal_Bool SAL_CALL RecoveryUI::supportsService(const ::rtl::OUString& sServiceName) + throw(css::uno::RuntimeException) +{ + const css::uno::Sequence< ::rtl::OUString > lServices = RecoveryUI::st_getSupportedServiceNames(); + sal_Int32 c = lServices.getLength(); + sal_Int32 i = 0; + for (i=0; i<c; ++i) + { + const ::rtl::OUString& sSupportedService = lServices[i]; + if (sSupportedService.equals(sServiceName)) + return sal_True; + } + return sal_False; +} + +//=============================================== +css::uno::Sequence< ::rtl::OUString > SAL_CALL RecoveryUI::getSupportedServiceNames() + throw(css::uno::RuntimeException) +{ + return RecoveryUI::st_getSupportedServiceNames(); +} + +//=============================================== +css::uno::Any SAL_CALL RecoveryUI::dispatchWithReturnValue(const css::util::URL& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& ) + throw(css::uno::RuntimeException) +{ + // Internaly we use VCL ... every call into vcl based code must + // be guarded by locking the global solar mutex. + ::vos::OGuard aSolarLock(&Application::GetSolarMutex()); + + css::uno::Any aRet; + RecoveryUI::EJob eJob = impl_classifyJob(aURL); + // TODO think about outside arguments + + switch(eJob) + { + case RecoveryUI::E_DO_EMERGENCY_SAVE : + { + sal_Bool bRet = impl_doEmergencySave(); + aRet <<= bRet; + break; + } + + case RecoveryUI::E_DO_RECOVERY : + impl_doRecovery(); + break; + + case RecoveryUI::E_DO_CRASHREPORT : + impl_doCrashReport(); + break; + + default : + break; + } + + return aRet; +} + +//=============================================== +void SAL_CALL RecoveryUI::dispatch(const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments) + throw(css::uno::RuntimeException) +{ + // recycle this method :-) + dispatchWithReturnValue(aURL, lArguments); +} + +//=============================================== +void SAL_CALL RecoveryUI::addStatusListener(const css::uno::Reference< css::frame::XStatusListener >&, const css::util::URL& ) throw(css::uno::RuntimeException) +{ + // TODO + OSL_ENSURE(sal_False, "RecoveryUI::addStatusListener()\nNot implemented yet!"); +} + +//=============================================== +void SAL_CALL RecoveryUI::removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >&, const css::util::URL& ) + throw(css::uno::RuntimeException) +{ + // TODO + OSL_ENSURE(sal_False, "RecoveryUI::removeStatusListener()\nNot implemented yet!"); +} + +//=============================================== +::rtl::OUString RecoveryUI::st_getImplementationName() +{ + static ::rtl::OUString IMPLEMENTATIONNAME = IMPLEMENTATIONNAME_RECOVERYUI; + return IMPLEMENTATIONNAME; +} + +//=============================================== +css::uno::Sequence< ::rtl::OUString > RecoveryUI::st_getSupportedServiceNames() +{ + css::uno::Sequence< ::rtl::OUString > lServiceNames(1); lServiceNames.getArray() [0] = SERVICENAME_RECOVERYUI; + return lServiceNames; +} + +//=============================================== +css::uno::Reference< css::uno::XInterface > SAL_CALL RecoveryUI::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) +{ + RecoveryUI* pNew = new RecoveryUI(xSMGR); + return css::uno::Reference< css::uno::XInterface >(static_cast< css::lang::XServiceInfo* >(pNew)); +} + +//=============================================== + +static OUString GetCrashConfigDir() +{ + +#if defined(WNT) || defined(OS2) + OUString ustrValue = OUString::createFromAscii("${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}"); +#elif defined(MACOSX) + OUString ustrValue = OUString::createFromAscii("~"); +#else + OUString ustrValue = OUString::createFromAscii("$SYSUSERCONFIG"); +#endif + Bootstrap::expandMacros( ustrValue ); + +#if defined(WNT) || defined(OS2) + ustrValue += OUString::createFromAscii("/user/crashdata"); +#endif + return ustrValue; +} + +//=============================================== + +#if defined(WNT) || defined(OS2) +#define LCKFILE "crashdat.lck" +#else +#define LCKFILE ".crash_report_unsent" +#endif + + +static OUString GetUnsentURL() +{ + OUString aURL = GetCrashConfigDir(); + + aURL += OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); + aURL += OUString( RTL_CONSTASCII_USTRINGPARAM( LCKFILE ) ); + + return aURL; +} + +//=============================================== + +static bool new_crash_pending() +{ + OUString aUnsentURL = GetUnsentURL(); + File aFile( aUnsentURL ); + + if ( FileBase::E_None == aFile.open( OpenFlag_Read ) ) + { + aFile.close(); + return true; + } + + return false; +} +//=============================================== + +static bool delete_pending_crash() +{ + OUString aUnsentURL = GetUnsentURL(); + return ( FileBase::E_None == File::remove( aUnsentURL ) ); +} + +RecoveryUI::EJob RecoveryUI::impl_classifyJob(const css::util::URL& aURL) +{ + m_eJob = RecoveryUI::E_JOB_UNKNOWN; + if (aURL.Protocol.equals(RECOVERY_CMDPART_PROTOCOL)) + { + if (aURL.Path.equals(RECOVERY_CMDPART_DO_EMERGENCY_SAVE)) + m_eJob = RecoveryUI::E_DO_EMERGENCY_SAVE; + else + if (aURL.Path.equals(RECOVERY_CMDPART_DO_RECOVERY)) + m_eJob = RecoveryUI::E_DO_RECOVERY; + else + if (aURL.Path.equals(RECOVERY_CMDPART_DO_CRASHREPORT)) + m_eJob = RecoveryUI::E_DO_CRASHREPORT; + } + + return m_eJob; +} + +//=============================================== +sal_Bool RecoveryUI::impl_doEmergencySave() +{ + // create core service, which implements the real "emergency save" algorithm. + svxdr::RecoveryCore* pCore = new svxdr::RecoveryCore(m_xSMGR, sal_True); + css::uno::Reference< css::frame::XStatusListener > xCore(pCore); + + // create all needed dialogs for this operation + // and bind it to the used core service + svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery(m_pParentWindow); + svxdr::IExtendedTabPage* pPage1 = new svxdr::SaveDialog (pWizard, pCore ); + pWizard->addTabPage(pPage1); + + // start the wizard + short nRet = pWizard->Execute(); + + delete pPage1 ; + delete pWizard; + + return (nRet==DLG_RET_OK_AUTOLUNCH); +} + +//=============================================== +void RecoveryUI::impl_doRecovery() +{ + sal_Bool bRecoveryOnly( sal_False ); + + ::rtl::OUString CFG_PACKAGE_RECOVERY( RTL_CONSTASCII_USTRINGPARAM ( "org.openoffice.Office.Recovery/" )); + ::rtl::OUString CFG_PATH_CRASHREPORTER( RTL_CONSTASCII_USTRINGPARAM( "CrashReporter" )); + ::rtl::OUString CFG_ENTRY_ENABLED( RTL_CONSTASCII_USTRINGPARAM ( "Enabled" )); + + sal_Bool bCrashRepEnabled( sal_True ); + css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey( + m_xSMGR, + CFG_PACKAGE_RECOVERY, + CFG_PATH_CRASHREPORTER, + CFG_ENTRY_ENABLED, + ::comphelper::ConfigurationHelper::E_READONLY); + aVal >>= bCrashRepEnabled; + bRecoveryOnly = !bCrashRepEnabled; + + // create core service, which implements the real "emergency save" algorithm. + svxdr::RecoveryCore* pCore = new svxdr::RecoveryCore(m_xSMGR, sal_False); + css::uno::Reference< css::frame::XStatusListener > xCore(pCore); + + // create all needed dialogs for this operation + // and bind it to the used core service + svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery (m_pParentWindow); + svxdr::IExtendedTabPage* pPage1 = new svxdr::RecoveryDialog (pWizard, pCore ); + svxdr::IExtendedTabPage* pPage2 = 0; + svxdr::IExtendedTabPage* pPage3 = 0; + + pWizard->addTabPage(pPage1); + if ( !bRecoveryOnly && new_crash_pending() ) + { + pPage2 = new svxdr::ErrorRepWelcomeDialog(pWizard ); + pPage3 = new svxdr::ErrorRepSendDialog (pWizard ); + pWizard->addTabPage(pPage2); + pWizard->addTabPage(pPage3); + } + + // start the wizard + pWizard->Execute(); + + impl_showAllRecoveredDocs(); + + delete pPage3 ; + delete pPage2 ; + delete pPage1 ; + delete pWizard; + + delete_pending_crash(); +} + +//=============================================== + +void RecoveryUI::impl_doCrashReport() +{ + if ( new_crash_pending() ) + { + svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery (m_pParentWindow ); + svxdr::IExtendedTabPage* pPage1 = new svxdr::ErrorRepWelcomeDialog(pWizard, sal_False); + svxdr::IExtendedTabPage* pPage2 = new svxdr::ErrorRepSendDialog (pWizard ); + pWizard->addTabPage(pPage1); + pWizard->addTabPage(pPage2); + + // start the wizard + pWizard->Execute(); + + delete pPage2 ; + delete pPage1 ; + delete pWizard; + + delete_pending_crash(); + } +} + +//=============================================== +void RecoveryUI::impl_showAllRecoveredDocs() +{ + css::uno::Reference< css::frame::XFramesSupplier > xDesktop( + m_xSMGR->createInstance(SERVICENAME_DESKTOP), + css::uno::UNO_QUERY_THROW); + + css::uno::Reference< css::container::XIndexAccess > xTaskContainer( + xDesktop->getFrames(), + css::uno::UNO_QUERY_THROW); + + sal_Int32 c = xTaskContainer->getCount(); + sal_Int32 i = 0; + for (i=0; i<c; ++i) + { + try + { + css::uno::Reference< css::frame::XFrame > xTask; + xTaskContainer->getByIndex(i) >>= xTask; + if (!xTask.is()) + continue; + + css::uno::Reference< css::awt::XWindow > xWindow = xTask->getContainerWindow(); + if (!xWindow.is()) + continue; + + xWindow->setVisible(sal_True); + } + catch(const css::uno::RuntimeException& exRun) + { throw exRun; } + catch(const css::uno::Exception&) + { continue; } + } +} + +} // namespace svx diff --git a/svx/source/unodraw/shapeimpl.hxx b/svx/source/unodraw/shapeimpl.hxx new file mode 100644 index 000000000000..d59d13e94795 --- /dev/null +++ b/svx/source/unodraw/shapeimpl.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SVX_SHAPEIMPL_HXX +#define _SVX_SHAPEIMPL_HXX + +#include <svx/unoshape.hxx> + +class SvGlobalName; + +/*********************************************************************** +* * +***********************************************************************/ + +class SvxShapeCaption : public SvxShapeText +{ +public: + SvxShapeCaption( SdrObject* pObj ) throw(); + virtual ~SvxShapeCaption() throw(); +}; + +/*********************************************************************** +* * +***********************************************************************/ + +class SvxPluginShape : public SvxOle2Shape +{ +protected: + // overide these for special property handling in subcasses. Return true if property is handled + virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +public: + SvxPluginShape( SdrObject* pObj ) throw(); + virtual ~SvxPluginShape() throw(); + + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); +}; + +/*********************************************************************** +* * +***********************************************************************/ + +class SvxAppletShape : public SvxOle2Shape +{ +protected: + // overide these for special property handling in subcasses. Return true if property is handled + virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +public: + SvxAppletShape( SdrObject* pObj ) throw(); + virtual ~SvxAppletShape() throw(); + + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ); +}; + +/*********************************************************************** +* * +***********************************************************************/ + +class SvxFrameShape : public SvxOle2Shape +{ +protected: + // overide these for special property handling in subcasses. Return true if property is handled + virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +public: + SvxFrameShape( SdrObject* pObj ) throw(); + virtual ~SvxFrameShape() throw(); + + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw (); +}; + + +// ==================================================================== + +class SvxTableShape : public SvxShape +{ +protected: + // overide these for special property handling in subcasses. Return true if property is handled + virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void lock(); + virtual void unlock(); + +public: + + SvxTableShape( SdrObject* pObj ) throw(); + virtual ~SvxTableShape() throw(); +}; + +#endif + + diff --git a/svx/source/unodraw/shapepropertynotifier.cxx b/svx/source/unodraw/shapepropertynotifier.cxx new file mode 100644 index 000000000000..408587d31822 --- /dev/null +++ b/svx/source/unodraw/shapepropertynotifier.cxx @@ -0,0 +1,207 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "svx/shapepropertynotifier.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/XPropertySet.hpp> +/** === end UNO includes === **/ + +#include <comphelper/stl_types.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/weak.hxx> +#include <tools/diagnose_ex.h> + +#include <hash_map> + +namespace +{ + + struct ShapePropertyHash + { + size_t operator()( ::svx::ShapeProperty __x ) const + { + return size_t( __x ); + } + }; +} + +//........................................................................ +namespace svx +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::beans::XPropertyChangeListener; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::XPropertySet; + /** === end UNO using === **/ + + typedef ::std::hash_map< ShapeProperty, PPropertyValueProvider, ShapePropertyHash > PropertyProviders; + + typedef ::cppu::OMultiTypeInterfaceContainerHelperVar < ::rtl::OUString + , ::comphelper::UStringHash + , ::comphelper::UStringEqual + > PropertyChangeListenerContainer; + + //==================================================================== + //= IPropertyValueProvider + //==================================================================== + IPropertyValueProvider::~IPropertyValueProvider() + { + } + + //==================================================================== + //= PropertyChangeNotifier_Data + //==================================================================== + struct PropertyChangeNotifier_Data + { + ::cppu::OWeakObject& m_rContext; + PropertyProviders m_aProviders; + PropertyChangeListenerContainer m_aPropertyChangeListeners; + + PropertyChangeNotifier_Data( ::cppu::OWeakObject& _rContext, ::osl::Mutex& _rMutex ) + :m_rContext( _rContext ) + ,m_aPropertyChangeListeners( _rMutex ) + { + } + }; + //==================================================================== + //= PropertyValueProvider + //==================================================================== + //-------------------------------------------------------------------- + ::rtl::OUString PropertyValueProvider::getPropertyName() const + { + return m_sPropertyName; + } + + //-------------------------------------------------------------------- + void PropertyValueProvider::getCurrentValue( Any& _out_rValue ) const + { + Reference< XPropertySet > xContextProps( const_cast< PropertyValueProvider* >( this )->m_rContext, UNO_QUERY_THROW ); + _out_rValue = xContextProps->getPropertyValue( getPropertyName() ); + } + + //==================================================================== + //= PropertyChangeNotifier + //==================================================================== + //-------------------------------------------------------------------- + PropertyChangeNotifier::PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex ) + :m_pData( new PropertyChangeNotifier_Data( _rOwner, _rMutex ) ) + { + } + + //-------------------------------------------------------------------- + PropertyChangeNotifier::~PropertyChangeNotifier() + { + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::registerProvider( const ShapeProperty _eProperty, const PPropertyValueProvider _pProvider ) + { + ENSURE_OR_THROW( _eProperty != eInvalidShapeProperty, "Illegal ShapeProperty value!" ); + ENSURE_OR_THROW( !!_pProvider, "NULL factory not allowed." ); + + OSL_ENSURE( m_pData->m_aProviders.find( _eProperty ) == m_pData->m_aProviders.end(), + "PropertyChangeNotifier::registerProvider: factory for this ID already present!" ); + + m_pData->m_aProviders[ _eProperty ] = _pProvider; + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::notifyPropertyChange( const ShapeProperty _eProperty ) const + { + ENSURE_OR_THROW( _eProperty != eInvalidShapeProperty, "Illegal ShapeProperty value!" ); + + PropertyProviders::const_iterator provPos = m_pData->m_aProviders.find( _eProperty ); + OSL_ENSURE( provPos != m_pData->m_aProviders.end(), "PropertyChangeNotifier::notifyPropertyChange: no factory!" ); + if ( provPos == m_pData->m_aProviders.end() ) + return; + + ::rtl::OUString sPropertyName( provPos->second->getPropertyName() ); + + ::cppu::OInterfaceContainerHelper* pPropListeners = m_pData->m_aPropertyChangeListeners.getContainer( sPropertyName ); + ::cppu::OInterfaceContainerHelper* pAllListeners = m_pData->m_aPropertyChangeListeners.getContainer( ::rtl::OUString() ); + if ( !pPropListeners && !pAllListeners ) + return; + + try + { + PropertyChangeEvent aEvent; + aEvent.Source = m_pData->m_rContext; + // Handle/OldValue not supported + aEvent.PropertyName = provPos->second->getPropertyName(); + provPos->second->getCurrentValue( aEvent.NewValue ); + + if ( pPropListeners ) + pPropListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent ); + if ( pAllListeners ) + pAllListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::addPropertyChangeListener( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener ) + { + m_pData->m_aPropertyChangeListeners.addInterface( _rPropertyName, _rxListener ); + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::removePropertyChangeListener( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener ) + { + m_pData->m_aPropertyChangeListeners.removeInterface( _rPropertyName, _rxListener ); + } + + //-------------------------------------------------------------------- + void PropertyChangeNotifier::disposing() + { + EventObject aEvent; + aEvent.Source = m_pData->m_rContext; + m_pData->m_aPropertyChangeListeners.disposeAndClear( aEvent ); + } + +//........................................................................ +} // namespace svx +//........................................................................ diff --git a/svx/source/unodraw/tableshape.cxx b/svx/source/unodraw/tableshape.cxx new file mode 100644 index 000000000000..9bedf71db64d --- /dev/null +++ b/svx/source/unodraw/tableshape.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "shapeimpl.hxx" +#include "svx/unoshprp.hxx" +#include "svx/svdotable.hxx" +#include <svx/svdpool.hxx> + +/////////////////////////////////////////////////////////////////////// + +using ::rtl::OUString; + +using namespace ::osl; +using namespace ::cppu; +using namespace ::sdr::table; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; + +SvxTableShape::SvxTableShape( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_TABLE), aSvxMapProvider.GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TableShape" ) ) ); +} + +//---------------------------------------------------------------------- +SvxTableShape::~SvxTableShape() throw() +{ +} + +//---------------------------------------------------------------------- + +bool SvxTableShape::setPropertyValueImpl( + const ::rtl::OUString& rName, + const SfxItemPropertySimpleEntry* pProperty, + const ::com::sun::star::uno::Any& rValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_TABLETEMPLATE: + { + Reference< XIndexAccess > xTemplate; + + if( !(rValue >>= xTemplate) ) + throw IllegalArgumentException(); + + if( mpObj.is() ) + static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate); + + return true; + } + case OWN_ATTR_TABLETEMPLATE_FIRSTROW: + case OWN_ATTR_TABLETEMPLATE_LASTROW: + case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: + case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: + case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: + case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: + { + if( mpObj.is() ) + { + TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() ); + + switch( pProperty->nWID ) + { + case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break; + case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break; + case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break; + case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break; + case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break; + case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break; + } + + static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings); + } + + return true; + } + default: + { + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + } +} + +extern Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector ); + +bool SvxTableShape::getPropertyValueImpl( + const ::rtl::OUString& rName, + const SfxItemPropertySimpleEntry* pProperty, + ::com::sun::star::uno::Any& rValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_OLEMODEL: + { + if( mpObj.is() ) + { + rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable(); + } + return true; + } + case OWN_ATTR_TABLETEMPLATE: + { + if( mpObj.is() ) + { + rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle(); + } + return true; + } + case OWN_ATTR_BITMAP: + { + if( mpObj.is() ) + { + Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) ); + rValue <<= aGraphic.GetXGraphic(); + } + return true; + } + case OWN_ATTR_TABLETEMPLATE_FIRSTROW: + case OWN_ATTR_TABLETEMPLATE_LASTROW: + case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: + case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: + case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: + case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: + { + if( mpObj.is() ) + { + TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() ); + + switch( pProperty->nWID ) + { + case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break; + case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break; + case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break; + case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break; + case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break; + case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break; + } + } + + return true; + } + default: + { + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + } +} + +void SvxTableShape::lock() +{ + SvxShape::lock(); + if( mpObj.is() ) + static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock(); +} + +void SvxTableShape::unlock() +{ + if( mpObj.is() ) + static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock(); + SvxShape::unlock(); +} + diff --git a/svx/source/unodraw/unobtabl.cxx b/svx/source/unodraw/unobtabl.cxx new file mode 100644 index 000000000000..70576f4fab95 --- /dev/null +++ b/svx/source/unodraw/unobtabl.cxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <svl/itempool.hxx> +#include <vcl/cvtgrf.hxx> +#include <svl/itemset.hxx> +#include <svx/xit.hxx> +#include "UnoNameItemTable.hxx" + +#include <svx/xbtmpit.hxx> +#include <svx/svdmodel.hxx> +#include <svx/xflhtit.hxx> +#include "unoapi.hxx" +#include <svx/unomid.hxx> +#include <editeng/unoprnms.hxx> +#include "unofill.hxx" +#include <editeng/memberids.hrc> + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +class SvxUnoBitmapTable : public SvxUnoNameItemTable +{ +public: + SvxUnoBitmapTable( SdrModel* pModel ) throw(); + virtual ~SvxUnoBitmapTable() throw(); + + virtual NameOrIndex* createItem() const throw(); + virtual bool isValid( const NameOrIndex* pItem ) const; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); +}; + +SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw() +: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL ) +{ +} + +SvxUnoBitmapTable::~SvxUnoBitmapTable() throw() +{ +} + +bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const +{ + if( SvxUnoNameItemTable::isValid( pItem ) ) + { + const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem ); + if( pBitmapItem ) + { + const GraphicObject& rGraphic = pBitmapItem->GetBitmapValue().GetGraphicObject(); + return rGraphic.GetSizeBytes() > 0; + } + } + + return false; +} + +OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoBitmapTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" )); + return aSNS; +} + +NameOrIndex* SvxUnoBitmapTable::createItem() const throw() +{ + return new XFillBitmapItem(); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType( (const ::rtl::OUString*)0 ); +} + +/** + * Create a bitmaptable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel ) +{ + return *new SvxUnoBitmapTable(pModel); +} + diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx new file mode 100644 index 000000000000..5dd4814c6ab5 --- /dev/null +++ b/svx/source/unodraw/unoctabl.cxx @@ -0,0 +1,399 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <unotools/pathoptions.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <cppuhelper/implbase2.hxx> + +#include "../customshapes/EnhancedCustomShapeEngine.hxx" + +#include <svx/xtable.hxx> +#include "unoshcol.hxx" +#include "recoveryui.hxx" +#include "xmlgrhlp.hxx" +#include "tbunocontroller.hxx" + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +class SvxUnoColorTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +{ +private: + XColorTable* pTable; + +public: + SvxUnoColorTable() throw(); + virtual ~SvxUnoColorTable() throw(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + static OUString getImplementationName_Static() throw() + { + return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoColorTable")); + } + + static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); + virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XNameAccess + virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); +}; + +SvxUnoColorTable::SvxUnoColorTable() throw() +{ + pTable = new XColorTable( SvtPathOptions().GetPalettePath() ); +} + +SvxUnoColorTable::~SvxUnoColorTable() throw() +{ + delete pTable; +} + +sal_Bool SAL_CALL SvxUnoColorTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); + const OUString * pArray = aSNL.getConstArray(); + + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + + return FALSE; +} + +OUString SAL_CALL SvxUnoColorTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoColorTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +uno::Sequence< OUString > SvxUnoColorTable::getSupportedServiceNames_Static(void) throw() +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ColorTable" )); + return aSNS; +} + +// XNameContainer +void SAL_CALL SvxUnoColorTable::insertByName( const OUString& aName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) +{ + if( hasByName( aName ) ) + throw container::ElementExistException(); + + INT32 nColor = 0; + if( !(aElement >>= nColor) ) + throw lang::IllegalArgumentException(); + + if( pTable ) + { + XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName ); + pTable->Insert( pTable->Count(), pEntry ); + } +} + +void SAL_CALL SvxUnoColorTable::removeByName( const OUString& Name ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( Name ) : -1; + if( nIndex == -1 ) + throw container::NoSuchElementException(); + + pTable->Remove( nIndex ); +} + +// XNameReplace +void SAL_CALL SvxUnoColorTable::replaceByName( const OUString& aName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +{ + INT32 nColor = 0; + if( !(aElement >>= nColor) ) + throw lang::IllegalArgumentException(); + + long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1; + if( nIndex == -1 ) + throw container::NoSuchElementException(); + + XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName ); + delete pTable->Replace( nIndex, pEntry ); +} + +// XNameAccess +uno::Any SAL_CALL SvxUnoColorTable::getByName( const OUString& aName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1; + if( nIndex == -1 ) + throw container::NoSuchElementException(); + + XColorEntry* pEntry = ((XColorTable*)pTable)->GetColor( nIndex ); + return uno::Any( (sal_Int32) pEntry->GetColor().GetRGBColor() ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getElementNames( ) + throw( uno::RuntimeException ) +{ + const long nCount = pTable ? pTable->Count() : 0; + + uno::Sequence< OUString > aSeq( nCount ); + OUString* pStrings = aSeq.getArray(); + + for( long nIndex = 0; nIndex < nCount; nIndex++ ) + { + XColorEntry* pEntry = pTable->GetColor( (long)nIndex ); + pStrings[nIndex] = pEntry->GetName(); + } + + return aSeq; +} + +sal_Bool SAL_CALL SvxUnoColorTable::hasByName( const OUString& aName ) + throw( uno::RuntimeException ) +{ + long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1; + return nIndex != -1; +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoColorTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType((const sal_Int32*)0); +} + +sal_Bool SAL_CALL SvxUnoColorTable::hasElements( ) + throw( uno::RuntimeException ) +{ + return pTable && pTable->Count() != 0; +} + +/** + * Create a colortable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoColorTable_createInstance(const uno::Reference< lang::XMultiServiceFactory > & ) throw(uno::Exception) +{ + return *new SvxUnoColorTable(); +} +uno::Reference< uno::XInterface > SAL_CALL create_EnhancedCustomShapeEngine( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) throw(uno::Exception) +{ + return *new EnhancedCustomShapeEngine( rxFact ); +} + +// +// export this service +// + +#ifndef SVX_LIGHT +#include "UnoGraphicExporter.hxx" +#endif +#include "unogalthemeprovider.hxx" +#include <com/sun/star/registry/XRegistryKey.hpp> +#include "sal/types.h" +#include "osl/diagnose.h" +#include "cppuhelper/factory.hxx" +#include "uno/lbnames.h" +#include <svx/sdr/primitive2d/primitiveFactory2d.hxx> + +extern "C" +{ + +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment ( + const sal_Char ** ppEnvTypeName, uno_Environment ** ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +static void writeInfo ( + registry::XRegistryKey * pRegistryKey, + const OUString& rImplementationName, + const uno::Sequence< OUString >& rServices) +{ + uno::Reference< registry::XRegistryKey > xNewKey( + pRegistryKey->createKey( + OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + rImplementationName + OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) ) ); + + for( sal_Int32 i = 0; i < rServices.getLength(); i++ ) + xNewKey->createKey( rServices.getConstArray()[i]); +} + +SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo ( + void * , void * pRegistryKey) +{ + if( pRegistryKey ) + { + try + { + registry::XRegistryKey *pKey = reinterpret_cast< registry::XRegistryKey * >( pRegistryKey ); + + writeInfo( pKey, SvxShapeCollection::getImplementationName_Static(), SvxShapeCollection::getSupportedServiceNames_Static() ); + writeInfo( pKey, SvxUnoColorTable::getImplementationName_Static(), SvxUnoColorTable::getSupportedServiceNames_Static() ); + writeInfo( pKey, EnhancedCustomShapeEngine_getImplementationName(), EnhancedCustomShapeEngine_getSupportedServiceNames() ); + writeInfo( pKey, svx::RecoveryUI::st_getImplementationName(), svx::RecoveryUI::st_getSupportedServiceNames() ); +#ifndef SVX_LIGHT + writeInfo( pKey, svx::GraphicExporter_getImplementationName(), svx::GraphicExporter_getSupportedServiceNames() ); +#endif + writeInfo( pKey, svx::FontHeightToolBoxControl::getImplementationName_Static(), svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() ); + writeInfo( pKey, ::unogallery::GalleryThemeProvider_getImplementationName(),::unogallery::GalleryThemeProvider_getSupportedServiceNames() ); + + // XPrimitiveFactory2D + writeInfo( pKey, + drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static(), + drawinglayer::primitive2d::PrimitiveFactory2D::getSupportedServiceNames_Static() ); + + writeInfo( pKey, ::svx::SvXMLGraphicImportHelper_getImplementationName(),::svx::SvXMLGraphicImportHelper_getSupportedServiceNames() ); + writeInfo( pKey, ::svx::SvXMLGraphicExportHelper_getImplementationName(),::svx::SvXMLGraphicExportHelper_getSupportedServiceNames() ); + } + catch (registry::InvalidRegistryException &) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return sal_True; +} + +SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory ( + const sal_Char * pImplName, void * pServiceManager, void * ) +{ + void * pRet = 0; + if( pServiceManager ) + { + uno::Reference< lang::XSingleServiceFactory > xFactory; + + if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxUnoColorTable" ) == 0 ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + SvxUnoColorTable::getImplementationName_Static(), + SvxUnoColorTable_createInstance, + SvxUnoColorTable::getSupportedServiceNames_Static() ); + } + else if ( rtl_str_compare( pImplName, "com.sun.star.drawing.EnhancedCustomShapeEngine" ) == 0 ) + { + xFactory = createSingleFactory( reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ), + EnhancedCustomShapeEngine_getImplementationName(), + create_EnhancedCustomShapeEngine, + EnhancedCustomShapeEngine_getSupportedServiceNames() ); + } + else if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxShapeCollection" ) == 0 ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + SvxShapeCollection::getImplementationName_Static(), + SvxShapeCollection_createInstance, + SvxShapeCollection::getSupportedServiceNames_Static() ); + } + else if( svx::RecoveryUI::st_getImplementationName().equalsAscii( pImplName ) ) + { + xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::RecoveryUI::st_getImplementationName(), + svx::RecoveryUI::st_createInstance, + svx::RecoveryUI::st_getSupportedServiceNames() ); + } +#ifndef SVX_LIGHT + else if( svx::GraphicExporter_getImplementationName().equalsAscii( pImplName ) ) + { + xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::GraphicExporter_getImplementationName(), + svx::GraphicExporter_createInstance, + svx::GraphicExporter_getSupportedServiceNames() ); + } +#endif + else if ( svx::FontHeightToolBoxControl::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::FontHeightToolBoxControl::getImplementationName_Static(), + svx::FontHeightToolBoxControl_createInstance, + svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() ); + } + else if( ::unogallery::GalleryThemeProvider_getImplementationName().equalsAscii( pImplName ) ) + { + xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + ::unogallery::GalleryThemeProvider_getImplementationName(), + ::unogallery::GalleryThemeProvider_createInstance, + ::unogallery::GalleryThemeProvider_getSupportedServiceNames() ); + } + else if( drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static().equalsAscii( pImplName ) ) + { + // XPrimitiveFactory2D + xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static(), + drawinglayer::primitive2d::XPrimitiveFactory2DProvider_createInstance, + drawinglayer::primitive2d::PrimitiveFactory2D::getSupportedServiceNames_Static() ); + } + else if( ::svx::SvXMLGraphicImportHelper_getImplementationName().equalsAscii( pImplName ) ) + { + xFactory = ::cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + ::svx::SvXMLGraphicImportHelper_getImplementationName(), + ::svx::SvXMLGraphicImportHelper_createInstance, + ::svx::SvXMLGraphicImportHelper_getSupportedServiceNames() ); + } + else if( ::svx::SvXMLGraphicExportHelper_getImplementationName().equalsAscii( pImplName ) ) + { + xFactory = ::cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + ::svx::SvXMLGraphicExportHelper_getImplementationName(), + ::svx::SvXMLGraphicExportHelper_createInstance, + ::svx::SvXMLGraphicExportHelper_getSupportedServiceNames() ); + } + + if( xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} diff --git a/svx/source/unodraw/unodraw.src b/svx/source/unodraw/unodraw.src new file mode 100644 index 000000000000..1e8fcf12d9ad --- /dev/null +++ b/svx/source/unodraw/unodraw.src @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <svx/dialogs.hrc> + +Bitmap RID_UNODRAW_OBJECTS +{ + File = "objects.bmp" ; +}; +Bitmap RID_UNODRAW_OLE2 +{ + File = "ole.bmp" ; +}; +Bitmap RID_UNODRAW_GRAPHICS +{ + File = "graphic.bmp" ; +}; + diff --git a/svx/source/unodraw/unodtabl.cxx b/svx/source/unodraw/unodtabl.cxx new file mode 100644 index 000000000000..19663ab08ade --- /dev/null +++ b/svx/source/unodraw/unodtabl.cxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/drawing/LineDash.hpp> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> + +#include <vector> +#include "UnoNameItemTable.hxx" +#include <svx/xlndsit.hxx> +#include <svx/unomid.hxx> + +#include <svx/xdash.hxx> +#include <svx/svdmodel.hxx> +#include "unofill.hxx" + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +class SvxUnoDashTable : public SvxUnoNameItemTable +{ +public: + SvxUnoDashTable( SdrModel* pModel ) throw(); + virtual ~SvxUnoDashTable() throw(); + + virtual NameOrIndex* createItem() const throw(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); +}; + +SvxUnoDashTable::SvxUnoDashTable( SdrModel* pModel ) throw() +: SvxUnoNameItemTable( pModel, XATTR_LINEDASH, MID_LINEDASH ) +{ +} + +SvxUnoDashTable::~SvxUnoDashTable() throw() +{ +} + +OUString SAL_CALL SvxUnoDashTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDashTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoDashTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable" )); + return aSNS; +} + +NameOrIndex* SvxUnoDashTable::createItem() const throw() +{ + XLineDashItem* pNewItem = new XLineDashItem(); + pNewItem->SetWhich( XATTR_LINEDASH ); // set which id for pooling + return pNewItem; +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoDashTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType((const struct drawing::LineDash*)0); +} + +/** + * Create a gradienttable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoDashTable_createInstance( SdrModel* pModel ) +{ + return *new SvxUnoDashTable(pModel); +} + + + diff --git a/svx/source/unodraw/unogtabl.cxx b/svx/source/unodraw/unogtabl.cxx new file mode 100644 index 000000000000..3cd4b13ac38e --- /dev/null +++ b/svx/source/unodraw/unogtabl.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/awt/Gradient.hpp> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include "UnoNameItemTable.hxx" + +#include <svx/xgrad.hxx> +#include <svx/svdmodel.hxx> +#include <svx/xdef.hxx> +#include <svx/xflgrit.hxx> +#include "unofill.hxx" +#include <svx/unomid.hxx> + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +class SvxUnoGradientTable : public SvxUnoNameItemTable +{ +public: + SvxUnoGradientTable( SdrModel* pModel ) throw(); + virtual ~SvxUnoGradientTable() throw(); + + virtual NameOrIndex* createItem() const throw(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); +}; + +SvxUnoGradientTable::SvxUnoGradientTable( SdrModel* pModel ) throw() + : SvxUnoNameItemTable( pModel, XATTR_FILLGRADIENT, MID_FILLGRADIENT ) +{ +} + +SvxUnoGradientTable::~SvxUnoGradientTable() throw() +{ +} + +OUString SAL_CALL SvxUnoGradientTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoGradientTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoGradientTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable" )); + return aSNS; +} + + +// XNameContainer +NameOrIndex* SvxUnoGradientTable::createItem() const throw() +{ + return new XFillGradientItem(); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoGradientTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType((const struct awt::Gradient*)0); +} + +/** + * Create a gradienttable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoGradientTable_createInstance( SdrModel* pModel ) +{ + return *new SvxUnoGradientTable(pModel); +} + + + diff --git a/svx/source/unodraw/unohtabl.cxx b/svx/source/unodraw/unohtabl.cxx new file mode 100644 index 000000000000..b774afe5c7ad --- /dev/null +++ b/svx/source/unodraw/unohtabl.cxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/drawing/Hatch.hpp> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include "UnoNameItemTable.hxx" + +#include <svx/xhatch.hxx> +#include <svx/svdmodel.hxx> +#include <svx/xdef.hxx> +#include <svx/xflhtit.hxx> +#include <svx/unomid.hxx> +#include "unofill.hxx" + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +class SvxUnoHatchTable : public SvxUnoNameItemTable +{ +public: + SvxUnoHatchTable( SdrModel* pModel ) throw(); + virtual ~SvxUnoHatchTable() throw(); + + virtual NameOrIndex* createItem() const throw(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); +}; + +SvxUnoHatchTable::SvxUnoHatchTable( SdrModel* pModel ) throw() +: SvxUnoNameItemTable( pModel, XATTR_FILLHATCH, MID_FILLHATCH ) +{ +} + +SvxUnoHatchTable::~SvxUnoHatchTable() throw() +{ +} + +OUString SAL_CALL SvxUnoHatchTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoHatchTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoHatchTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable" )); + return aSNS; +} + +NameOrIndex* SvxUnoHatchTable::createItem() const throw() +{ + return new XFillHatchItem(); +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoHatchTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType((const struct drawing::Hatch*)0); +} + +/** + * Create a hatchtable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoHatchTable_createInstance( SdrModel* pModel ) +{ + return *new SvxUnoHatchTable(pModel); +} + + + diff --git a/svx/source/unodraw/unomlstr.cxx b/svx/source/unodraw/unomlstr.cxx new file mode 100644 index 000000000000..2519a2c36d1c --- /dev/null +++ b/svx/source/unodraw/unomlstr.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <svx/svdobj.hxx> +// header for class OGuard +#include <vos/mutex.hxx> +// header for class Application +#include <vcl/svapp.hxx> + +#include "unomlstr.hxx" + +using namespace ::com::sun::star; + +SvxUnoShapeModifyListener::SvxUnoShapeModifyListener( SdrObject* pObj ) throw() +{ + mpObj = pObj; +} + +SvxUnoShapeModifyListener::~SvxUnoShapeModifyListener() throw() +{ +} + +// ::com::sun::star::util::XModifyListener +void SAL_CALL SvxUnoShapeModifyListener::modified(const lang::EventObject& ) throw( uno::RuntimeException ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( mpObj ) + { + mpObj->SetChanged(); + mpObj->BroadcastObjectChange(); + } +} + +// ::com::sun::star::lang::XEventListener +void SvxUnoShapeModifyListener::disposing(const lang::EventObject& ) throw( uno::RuntimeException ) +{ + invalidate(); +} + +// internal +void SvxUnoShapeModifyListener::invalidate() throw() +{ + mpObj = NULL; +} + + diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx new file mode 100644 index 000000000000..a10d097981f5 --- /dev/null +++ b/svx/source/unodraw/unomod.cxx @@ -0,0 +1,778 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#define _SVX_USE_UNOGLOBALS_ +#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> +#include <com/sun/star/lang/NoSupportException.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <tools/list.hxx> +#include <svl/itemprop.hxx> +#include <svtools/unoevent.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/serviceinfohelper.hxx> + +#include <cppuhelper/implbase2.hxx> +#include <unofill.hxx> +#include <editeng/unonrule.hxx> +#include <svtools/unoimap.hxx> +#include <svx/fmdpage.hxx> +#include <svx/fmmodel.hxx> +#include <svx/fmpage.hxx> +#include <sfx2/sfx.hrc> +#include <unoapi.hxx> + +#include <svx/svdmodel.hxx> +#include "globl3d.hxx" +#include <svx/svdtypes.hxx> +#include <svx/unoprov.hxx> +#include <svx/unopage.hxx> +#include <editeng/unofield.hxx> +#include <svx/unomod.hxx> +#include <svx/unomodel.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdpage.hxx> +#include <svx/unoshape.hxx> + +extern UHashMapEntry pSdrShapeIdentifierMap[]; + +//-//////////////////////////////////////////////////////////////////// + +using namespace ::rtl; +using namespace ::osl; +using namespace ::vos; +using namespace ::com::sun::star; + +//-//////////////////////////////////////////////////////////////////// + +#define QUERYINT( xint ) \ + if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \ + aAny <<= uno::Reference< xint >(this) + +#define ITYPE( xint ) \ + ::getCppuType((const uno::Reference< xint >*)0) + +//-//////////////////////////////////////////////////////////////////// + +#ifndef SVX_LIGHT + +class SvxUnoDrawPagesAccess : public ::cppu::WeakImplHelper2< ::com::sun::star::drawing::XDrawPages, ::com::sun::star::lang::XServiceInfo > +{ +private: + SvxUnoDrawingModel& mrModel; + +public: + SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw(); + virtual ~SvxUnoDrawPagesAccess() throw(); + + // XDrawPages + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) throw(::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); +}; +#endif +//-//////////////////////////////////////////////////////////////////// + +#ifndef SVX_LIGHT +const SvEventDescription* ImplGetSupportedMacroItems() +{ + static const SvEventDescription aMacroDescriptionsImpl[] = + { + { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" }, + { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" }, + { 0, NULL } + }; + + return aMacroDescriptionsImpl; +} +#endif + +//-//////////////////////////////////////////////////////////////////// + +/** fills the given EventObject from the given SdrHint. + @returns + true if the SdrHint could be translated to an EventObject<br> + false if not +*/ +sal_Bool SvxUnoDrawMSFactory::createEvent( const SdrModel* pDoc, const SdrHint* pSdrHint, ::com::sun::star::document::EventObject& aEvent ) +{ + const SdrObject* pObj = NULL; + const SdrPage* pPage = NULL; + + switch( pSdrHint->GetKind() ) + { +// case HINT_LAYERCHG: // Layerdefinition geaendert +// case HINT_LAYERORDERCHG: // Layerreihenfolge geaendert (Insert/Remove/ChangePos) +// case HINT_LAYERSETCHG: // Layerset geaendert +// case HINT_LAYERSETORDERCHG: // Layersetreihenfolge geaendert (Insert/Remove/ChangePos) + +// #115423# +// case HINT_PAGECHG: // Page geaendert +// aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageModified" ) ); +// pPage = pSdrHint->GetPage(); +// break; + case HINT_PAGEORDERCHG: // Reihenfolge der Seiten (Zeichenseiten oder Masterpages) geaendert (Insert/Remove/ChangePos) + aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOrderModified" ) ); + pPage = pSdrHint->GetPage(); + break; + case HINT_OBJCHG: // Objekt geaendert + aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeModified" ) ); + pObj = pSdrHint->GetObject(); + break; + case HINT_OBJINSERTED: // Neues Zeichenobjekt eingefuegt + aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeInserted" ) ); + pObj = pSdrHint->GetObject(); + break; + case HINT_OBJREMOVED: // Zeichenobjekt aus Liste entfernt + aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeRemoved" ) ); + pObj = pSdrHint->GetObject(); + break; +// HINT_DEFAULTTABCHG, // Default Tabulatorweite geaendert +// HINT_DEFFONTHGTCHG, // Default FontHeight geaendert +// HINT_SWITCHTOPAGE, // #94278# UNDO/REDO at an object evtl. on another page +// HINT_OBJLISTCLEAR // Is called before an SdrObjList will be cleared + default: + return sal_False; + } + + if( pObj ) + aEvent.Source = const_cast<SdrObject*>(pObj)->getUnoShape(); + else if( pPage ) + aEvent.Source = const_cast<SdrPage*>(pPage)->getUnoPage(); + else + aEvent.Source = (const_cast<SdrModel*>(pDoc))->getUnoModel(); + + return sal_True; +} + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& ServiceSpecifier ) + throw( uno::Exception, uno::RuntimeException ) +{ + const OUString aDrawingPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.") ); + + if( ServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 ) + { + UINT32 nType = aSdrShapeIdentifierMap.getId( ServiceSpecifier ); + if( nType != UHASHMAP_NOTFOUND ) + { + UINT16 nT = (UINT16)(nType & ~E3D_INVENTOR_FLAG); + UINT32 nI = (nType & E3D_INVENTOR_FLAG)?E3dInventor:SdrInventor; + + return uno::Reference< uno::XInterface >( (drawing::XShape*) SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI ) ); + } + } + + uno::Reference< uno::XInterface > xRet( createTextField( ServiceSpecifier ) ); + if( !xRet.is() ) + throw lang::ServiceNotRegisteredException(); + + return xRet; +} + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createTextField( const ::rtl::OUString& ServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + return SvxUnoTextCreateTextField( ServiceSpecifier ); +} + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWithArguments( const OUString&, const uno::Sequence< ::com::sun::star::uno::Any >& ) + throw( uno::Exception, uno::RuntimeException ) +{ + throw lang::NoSupportException(); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoDrawMSFactory::getAvailableServiceNames() + throw( uno::RuntimeException ) +{ + UHashMapEntry* pMap = pSdrShapeIdentifierMap; + + UINT32 nCount = 0; + while (pMap->aIdentifier.getLength()) + { + pMap++; + nCount++; + } + + uno::Sequence< OUString > aSeq( nCount ); + OUString* pStrings = aSeq.getArray(); + + pMap = pSdrShapeIdentifierMap; + UINT32 nIdx = 0; + while(pMap->aIdentifier.getLength()) + { + pStrings[nIdx] = pMap->aIdentifier; + pMap++; + nIdx++; + } + + return aSeq; +} + +uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence< OUString >& rServices1, uno::Sequence< OUString >& rServices2 ) throw() +{ + const sal_Int32 nLen1 = rServices1.getLength(); + const sal_Int32 nLen2 = rServices2.getLength(); + + uno::Sequence< OUString > aSeq( nLen1+nLen2 ); + OUString* pStrings = aSeq.getArray(); + + sal_Int32 nIdx; + OUString* pStringDst = pStrings; + const OUString* pStringSrc = rServices1.getArray(); + + for( nIdx = 0; nIdx < nLen1; nIdx++ ) + *pStringDst++ = *pStringSrc++; + + pStringSrc = rServices2.getArray(); + + for( nIdx = 0; nIdx < nLen2; nIdx++ ) + *pStringDst++ = *pStringSrc++; + + return aSeq; +} + + +#ifndef SVX_LIGHT + +/// +SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc ) throw() +: mpDoc( pDoc ) +{ +} + +SvxUnoDrawingModel::~SvxUnoDrawingModel() throw() +{ +} + +uno::Any SAL_CALL SvxUnoDrawingModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT(lang::XServiceInfo); + else QUERYINT(lang::XMultiServiceFactory); + else QUERYINT(drawing::XDrawPagesSupplier); + else QUERYINT(com::sun::star::ucb::XAnyCompareFactory); + else + return SfxBaseModel::queryInterface( rType ); + + return aAny; +} + +void SAL_CALL SvxUnoDrawingModel::acquire() throw ( ) +{ + SfxBaseModel::acquire(); +} + +void SAL_CALL SvxUnoDrawingModel::release() throw ( ) +{ + SfxBaseModel::release(); +} + +// XTypeProvider +uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes( ) throw(uno::RuntimeException) +{ + if( maTypeSequence.getLength() == 0 ) + { + const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() ); + const sal_Int32 nBaseTypes = aBaseTypes.getLength(); + const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); + + const sal_Int32 nOwnTypes = 4; // !DANGER! Keep this updated! + + maTypeSequence.realloc( nBaseTypes + nOwnTypes ); + uno::Type* pTypes = maTypeSequence.getArray(); + + *pTypes++ = ITYPE(lang::XServiceInfo); + *pTypes++ = ITYPE(lang::XMultiServiceFactory); + *pTypes++ = ITYPE(drawing::XDrawPagesSupplier); + *pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory); + + for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) + *pTypes++ = *pBaseTypes++; + } + + return maTypeSequence; +} + +uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawingModel::getImplementationId( ) throw(uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +void SAL_CALL SvxUnoDrawingModel::lockControllers( ) + throw(uno::RuntimeException) +{ + if( mpDoc ) + mpDoc->setLock( sal_True ); +} + +void SAL_CALL SvxUnoDrawingModel::unlockControllers( ) + throw(uno::RuntimeException) +{ + if( mpDoc && mpDoc->isLocked() ) + { + mpDoc->setLock( sal_False ); + } +} + +sal_Bool SAL_CALL SvxUnoDrawingModel::hasControllersLocked( ) + throw(uno::RuntimeException) +{ + return mpDoc && mpDoc->isLocked(); +} + +// XDrawPagesSupplier +uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess ); + + if( !xDrawPages.is() ) + mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SvxUnoDrawPagesAccess(*this); + + return xDrawPages; +} + +// XMultiServiceFactory ( SvxFmMSFactory ) +uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( const OUString& aServiceSpecifier ) + throw(uno::Exception, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) ) + { + if( !mxDashTable.is() ) + mxDashTable = SvxUnoDashTable_createInstance( mpDoc ); + return mxDashTable; + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) ) + { + if( !mxGradientTable.is() ) + mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc ); + return mxGradientTable; + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) ) + { + if( !mxHatchTable.is() ) + mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc ); + return mxHatchTable; + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) ) + { + if( !mxBitmapTable.is() ) + mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc ); + return mxBitmapTable; + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ) + { + if( !mxTransGradientTable.is() ) + mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc ); + return mxTransGradientTable; + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) ) + { + if( !mxMarkerTable.is() ) + mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc ); + return mxMarkerTable; + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) ) + { + return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY ); + } + + if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapRectangleObject") ) ) + { + return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() ); + } + + if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapCircleObject") ) ) + { + return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() ); + } + + if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapPolygonObject") ) ) + { + return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() ); + } + + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) ) + { + return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD ); + } + + uno::Reference< uno::XInterface > xRet; + + const String aType( aServiceSpecifier ); + if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) ) + { + SvxShape* pShape = NULL; + + sal_uInt16 nType = OBJ_TEXT; + // create a shape wrapper + if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) ) + { + nType = OBJ_GRAF; + } + else if( aType.EqualsAscii( "PageShape", 26, 9 ) ) + { + nType = OBJ_PAGE; + } + else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "ChartShape", 26, 10 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "TableShape", 26, 10 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "NotesShape", 26, 10 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "HandoutShape", 26, 12 ) ) + { + nType = OBJ_PAGE; + } + else if( aType.EqualsAscii( "FooterShape", 26, 12 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "TableShape", 26, 10 ) ) + { + nType = OBJ_TABLE; + } + else + { + throw lang::ServiceNotRegisteredException(); + } + + // create the API wrapper + pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor ); + + // set shape type + if( pShape ) + pShape->SetShapeType(aServiceSpecifier); + + xRet = (uno::XWeak*)pShape; + } + else + { + xRet = SvxFmMSFactory::createInstance( aServiceSpecifier ); + } + + return xRet; +} + +uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames() + throw(uno::RuntimeException) +{ + const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() ); + + uno::Sequence< OUString > aSNS( 21 ); + + sal_uInt16 i = 0; + + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject")); + + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape")); + aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape")); + + DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" ); + + return comphelper::concatSequences( aSNS_ORG, aSNS ); +} + +// lang::XServiceInfo +OUString SAL_CALL SvxUnoDrawingModel::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawingModel")); +} + +sal_Bool SAL_CALL SvxUnoDrawingModel::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getSupportedServiceNames() throw(uno::RuntimeException) +{ + OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument")); + uno::Sequence< OUString > aSeq( &aSN, 1 ); + return aSeq; +} + +// XAnyCompareFactory +uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxUnoDrawingModel::createAnyCompareByName( const OUString& ) + throw(uno::RuntimeException) +{ + return SvxCreateNumRuleCompare(); +} + +//============================================================================= +// class SvxUnoDrawPagesAccess +//============================================================================= + +SvxUnoDrawPagesAccess::SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw() +: mrModel(rMyModel) +{ +} + +SvxUnoDrawPagesAccess::~SvxUnoDrawPagesAccess() throw() +{ +} + +// XIndexAccess +sal_Int32 SAL_CALL SvxUnoDrawPagesAccess::getCount() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_Int32 nCount = 0; + + if( mrModel.mpDoc ) + nCount = mrModel.mpDoc->GetPageCount(); + + return( nCount ); +} + +uno::Any SAL_CALL SvxUnoDrawPagesAccess::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + + if( mrModel.mpDoc ) + { + if( (Index < 0) || (Index >= mrModel.mpDoc->GetPageCount() ) ) + throw lang::IndexOutOfBoundsException(); + + SdrPage* pPage = mrModel.mpDoc->GetPage( (sal_uInt16)Index ); + if( pPage ) + { + uno::Reference< uno::XInterface > xPage( pPage->mxUnoPage ); + + if( !xPage.is() ) + { + if( PTR_CAST( FmFormModel, mrModel.mpDoc ) ) + xPage = (drawing::XDrawPage*)new SvxFmDrawPage( pPage ); + else + xPage = (drawing::XDrawPage*)new SvxDrawPage( pPage ); + + pPage->mxUnoPage = xPage; + } + + aAny <<= xPage; + } + } + return aAny; +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoDrawPagesAccess::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE( drawing::XDrawPage ); +} + +sal_Bool SAL_CALL SvxUnoDrawPagesAccess::hasElements() + throw(uno::RuntimeException) +{ + return getCount() > 0; +} + +// XDrawPages + +/****************************************************************************** +* Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die * +* dazugehoerige SdDrawPage zurueck. * +******************************************************************************/ +uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XDrawPage > xDrawPage; + + if( mrModel.mpDoc ) + { + SdrPage* pPage; + + if( PTR_CAST( FmFormModel, mrModel.mpDoc ) ) + pPage = new FmFormPage(*(FmFormModel*)mrModel.mpDoc, NULL); + else + pPage = new SdrPage(*mrModel.mpDoc); + + mrModel.mpDoc->InsertPage( pPage, (sal_uInt16)nIndex ); + xDrawPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ); + } + + return xDrawPage; +} + +void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount(); + if( nPageCount > 1 ) + { + // pPage von xPage besorgen und dann die Id (nPos )ermitteln + SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage ); + if( pSvxPage ) + { + SdrPage* pPage = pSvxPage->GetSdrPage(); + if(pPage) + { + sal_uInt16 nPage = pPage->GetPageNum(); + mrModel.mpDoc->DeletePage( nPage ); + } + } + } +} + +// XServiceInfo +sal_Char pSvxUnoDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages"; + +OUString SAL_CALL SvxUnoDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoDrawPagesAccess" ) ); +} + +sal_Bool SAL_CALL SvxUnoDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoDrawPagesAccessService ) ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoDrawPagesAccessService ) ); + uno::Sequence< OUString > aSeq( &aService, 1 ); + return aSeq; +} +#include <editeng/unonrule.hxx> +com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( SdrModel* pModel ) throw() +{ + SvxNumRule* pDefaultRule = NULL; + if( pModel ) + { + SvxNumBulletItem* pItem = (SvxNumBulletItem*) pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); + if( pItem ) + { + pDefaultRule = pItem->GetNumRule(); + } + } + + if( pDefaultRule ) + { + return SvxCreateNumRule( pDefaultRule ); + } + else + { + SvxNumRule aTempRule( 0, 10, false ); + return SvxCreateNumRule( &aTempRule ); + } +} + +/////////////////////////////////////////////////////////////////////// + +#endif diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx new file mode 100644 index 000000000000..dbb7269c1318 --- /dev/null +++ b/svx/source/unodraw/unomtabl.cxx @@ -0,0 +1,482 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <set> +#include <comphelper/stl_types.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/drawing/PointSequence.hpp> +#include <svl/style.hxx> + +#include <cppuhelper/implbase2.hxx> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <svl/lstner.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xlnstit.hxx> +#include <svx/svdmodel.hxx> +#include <svx/xdef.hxx> +#include <svx/xflhtit.hxx> + +#include <vector> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + + +#include "unofill.hxx" + +#include "unoapi.hxx" + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; +using namespace ::vos; + +typedef std::vector< SfxItemSet* > ItemPoolVector; + +class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >, + public SfxListener +{ +private: + SdrModel* mpModel; + SfxItemPool* mpModelPool; + + ItemPoolVector maItemSetVector; + +public: + SvxUnoMarkerTable( SdrModel* pModel ) throw(); + virtual ~SvxUnoMarkerTable() throw(); + + void dispose(); + + // SfxListener + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw (); + + void SAL_CALL ImplInsertByName( const OUString& aName, const uno::Any& aElement ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); + virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + + // XNameAccess + virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); +}; + +SvxUnoMarkerTable::SvxUnoMarkerTable( SdrModel* pModel ) throw() +: mpModel( pModel ), + mpModelPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) +{ + if( pModel ) + StartListening( *pModel ); +} + +SvxUnoMarkerTable::~SvxUnoMarkerTable() throw() +{ + if( mpModel ) + EndListening( *mpModel ); + dispose(); +} + +void SvxUnoMarkerTable::dispose() +{ + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + while( aIter != aEnd ) + { + delete (*aIter++); + } + + maItemSetVector.clear(); +} + +// SfxListener +void SvxUnoMarkerTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() +{ + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + + if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() ) + dispose(); +} + +sal_Bool SAL_CALL SvxUnoMarkerTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); + const OUString * pArray = aSNL.getConstArray(); + + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + + return FALSE; +} + +OUString SAL_CALL SvxUnoMarkerTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoMarkerTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable" )); + return aSNS; +} + +void SAL_CALL SvxUnoMarkerTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement ) +{ + SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, XATTR_LINESTART, XATTR_LINEEND ); + maItemSetVector.push_back( mpInSet ); + + XLineEndItem aEndMarker; + aEndMarker.SetName( String( aName ) ); + aEndMarker.PutValue( aElement ); + + mpInSet->Put( aEndMarker, XATTR_LINEEND ); + + XLineStartItem aStartMarker; + aStartMarker.SetName( String( aName ) ); + aStartMarker.PutValue( aElement ); + + mpInSet->Put( aStartMarker, XATTR_LINESTART ); +} + +// XNameContainer +void SAL_CALL SvxUnoMarkerTable::insertByName( const OUString& aApiName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( hasByName( aApiName ) ) + throw container::ElementExistException(); + + String aName; + SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName ); + + ImplInsertByName( aName, aElement ); +} + +void SAL_CALL SvxUnoMarkerTable::removeByName( const OUString& aApiName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + // a little quickfix for 2.0 to let applications clear api + // created items that are not used + if( aApiName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("~clear~") ) ) + { + dispose(); + return; + } + + String Name; + SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, Name ); + + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( Name ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) ); + if( pItem->GetName() == aSearchName ) + { + delete (*aIter); + maItemSetVector.erase( aIter ); + return; + } + aIter++; + } + + if( !hasByName( Name ) ) + throw container::NoSuchElementException(); +} + +// XNameReplace +void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aName; + SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName ); + + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( aName ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) ); + if( pItem->GetName() == aSearchName ) + { + XLineEndItem aEndMarker; + aEndMarker.SetName( aSearchName ); + if( !aEndMarker.PutValue( aElement ) ) + throw lang::IllegalArgumentException(); + + (*aIter)->Put( aEndMarker, XATTR_LINEEND ); + + XLineStartItem aStartMarker; + aStartMarker.SetName( aSearchName ); + aStartMarker.PutValue( aElement ); + + (*aIter)->Put( aStartMarker, XATTR_LINESTART ); + return; + } + aIter++; + } + + // if it is not in our own sets, modify the pool! + sal_Bool bFound = sal_False; + + USHORT nSurrogate; + const USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0; + for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) + { + pItem->PutValue( aElement ); + bFound = sal_True; + break; + } + } + + const USHORT nEndCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINEEND ) : 0; + for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINEEND, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) + { + pItem->PutValue( aElement ); + bFound = sal_True; + break; + } + } + + if( bFound ) + ImplInsertByName( aName, aElement ); + else + throw container::NoSuchElementException(); +} + +static sal_Bool getByNameFromPool( const String& rSearchName, SfxItemPool* pPool, USHORT nWhich, uno::Any& rAny ) +{ + NameOrIndex *pItem; + const sal_Int32 nSurrogateCount = pPool ? (sal_Int32)pPool->GetItemCount( nWhich ) : 0; + for( sal_Int32 nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)pPool->GetItem( nWhich, (USHORT)nSurrogate ); + + if( pItem && pItem->GetName() == rSearchName ) + { + pItem->QueryValue( rAny, 0 ); + return sal_True; + } + } + + return sal_False; +} + +// XNameAccess +uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const OUString& aApiName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + String aName; + SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName ); + + uno::Any aAny; + + if( mpModelPool && aName.Len() != 0 ) + { + do + { + const String aSearchName( aName ); + if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINESTART, aAny ) ) + break; + + if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINEEND, aAny ) ) + break; + + throw container::NoSuchElementException(); + } + while(0); + } + + return aAny; +} + +static void createNamesForPool( SfxItemPool* pPool, USHORT nWhich, std::set< OUString, comphelper::UStringLess >& rNameSet ) +{ + const sal_Int32 nSuroCount = pPool->GetItemCount( nWhich ); + sal_Int32 nSurrogate; + + NameOrIndex *pItem; + OUString aName; + + for( nSurrogate = 0; nSurrogate < nSuroCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)pPool->GetItem( nWhich, (USHORT)nSurrogate ); + + if( pItem == NULL || pItem->GetName().Len() == 0 ) + continue; + + SvxUnogetApiNameForItem( XATTR_LINEEND, pItem->GetName(), aName ); + rNameSet.insert( aName ); + } +} + +uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames() + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + std::set< OUString, comphelper::UStringLess > aNameSet; + + // search model pool for line starts + createNamesForPool( mpModelPool, XATTR_LINESTART, aNameSet ); + + // search model pool for line ends + createNamesForPool( mpModelPool, XATTR_LINEEND, aNameSet ); + + uno::Sequence< OUString > aSeq( aNameSet.size() ); + OUString* pNames = aSeq.getArray(); + + std::set< OUString, comphelper::UStringLess >::iterator aIter( aNameSet.begin() ); + const std::set< OUString, comphelper::UStringLess >::iterator aEnd( aNameSet.end() ); + + while( aIter != aEnd ) + { + *pNames++ = *aIter++; + } + + return aSeq; +} + +sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const OUString& aName ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( aName.getLength() == 0 ) + return sal_False; + + String aSearchName; + + NameOrIndex *pItem; + + SvxUnogetInternalNameForItem( XATTR_LINESTART, aName, aSearchName ); + USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0; + USHORT nSurrogate; + for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) + return sal_True; + } + + SvxUnogetInternalNameForItem( XATTR_LINEEND, aName, aSearchName ); + USHORT nEndCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINEEND ) : 0; + for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINEEND, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) + return sal_True; + } + + return sal_False; +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoMarkerTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType((const drawing::PointSequence*)0); +} + +sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements( ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + NameOrIndex *pItem; + + const USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0; + USHORT nSurrogate; + for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate); + if( pItem && pItem->GetName().Len() != 0 ) + return sal_True; + } + + const USHORT nEndCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINEEND ) : 0; + for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINEEND, nSurrogate); + if( pItem && pItem->GetName().Len() != 0 ) + return sal_True; + } + + return sal_False; +} + +/** + * Create a hatchtable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoMarkerTable_createInstance( SdrModel* pModel ) +{ + return *new SvxUnoMarkerTable(pModel); +} + + + diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx new file mode 100644 index 000000000000..9fea6a6fda5d --- /dev/null +++ b/svx/source/unodraw/unopage.cxx @@ -0,0 +1,1002 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#define _SVX_USE_UNOGLOBALS_ +#include <com/sun/star/document/EventObject.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <vos/mutex.hxx> +#include <osl/mutex.hxx> +#include <sfx2/dispatch.hxx> +#include <sot/clsids.hxx> +#include <comphelper/serviceinfohelper.hxx> + +#include <rtl/uuid.h> +#include <rtl/memory.h> +#include <sfx2/objsh.hxx> +#include <svx/svdpool.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdview.hxx> +#include <svx/svdpagv.hxx> +#include <svx/unopage.hxx> +#include "shapeimpl.hxx" +#include "globl3d.hxx" +#include <svx/polysc3d.hxx> +#include <svx/unoprov.hxx> +#include <svx/svdopath.hxx> +#include "unoapi.hxx" +#include <svx/svdomeas.hxx> +#include <svx/extrud3d.hxx> +#include <svx/lathe3d.hxx> +#include <vcl/svapp.hxx> + +using ::rtl::OUString; +using namespace ::vos; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::drawing; + +#define INTERFACE_TYPE( xint ) \ + ::getCppuType((const Reference< xint >*)0) + +#define QUERYINT( xint ) \ + if( rType == ::getCppuType((const Reference< xint >*)0) ) \ + aAny <<= Reference< xint >(this) + +DECLARE_LIST( SvxDrawPageList, SvxDrawPage * ) + + +/********************************************************************** +* class SvxDrawPage * +**********************************************************************/ + +UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage ); +DBG_NAME(SvxDrawPage) +SvxDrawPage::SvxDrawPage( SdrPage* pInPage ) throw() +: mrBHelper( getMutex() ) +, mpPage( pInPage ) +, mpModel( 0 ) +{ + DBG_CTOR(SvxDrawPage,NULL); + // Am Broadcaster anmelden + if( mpPage ) + mpModel = mpPage->GetModel(); + if( mpModel ) + StartListening( *mpModel ); + + + // Erzeugen der (hidden) ::com::sun::star::sdbcx::View + mpView = new SdrView( mpModel ); + if( mpView ) + mpView->SetDesignMode(sal_True); +} + +//---------------------------------------------------------------------- +// Ctor fuer SvxDrawPage_NewInstance() +//---------------------------------------------------------------------- +SvxDrawPage::SvxDrawPage() throw() +: mrBHelper( getMutex() ) +, mpPage( NULL ) +, mpModel( NULL ) +, mpView( NULL ) +{ + DBG_CTOR(SvxDrawPage,NULL); +} + +//---------------------------------------------------------------------- +SvxDrawPage::~SvxDrawPage() throw() +{ + DBG_ASSERT( mrBHelper.bDisposed, "SvxDrawPage must be disposed!" ); + if( !mrBHelper.bDisposed ) + { + acquire(); + dispose(); + } + DBG_DTOR(SvxDrawPage,NULL); +} + +//---------------------------------------------------------------------- + +// XInterface +void SvxDrawPage::release() throw() +{ +/* + uno::Reference< uno::XInterface > x( xDelegator ); + if (! x.is()) + { + if (osl_decrementInterlockedCount( &m_refCount ) == 0) + { + if (! mrBHelper.bDisposed) + { + uno::Reference< uno::XInterface > xHoldAlive( (uno::XWeak*)this ); + // First dispose + try + { + dispose(); + } + catch(::com::sun::star::uno::Exception&) + { + // release should not throw exceptions + } + + // only the alive ref holds the object + OSL_ASSERT( m_refCount == 1 ); + // destroy the object if xHoldAlive decrement the refcount to 0 + return; + } + } + // restore the reference count + osl_incrementInterlockedCount( &m_refCount ); + } +*/ + OWeakAggObject::release(); +} + +//---------------------------------------------------------------------- + +SvxDrawPage* SvxDrawPage::GetPageForSdrPage( SdrPage* mpPage ) throw() +{ + return getImplementation( mpPage->getUnoPage() ); +} + +// XComponent +void SvxDrawPage::disposing() throw() +{ + if( mpModel ) + { + EndListening( *mpModel ); + mpModel = NULL; + } + + if( mpView ) + { + delete mpView; + mpView = NULL; + } + mpPage = 0; +} + +//---------------------------------------------------------------------- +// XComponent +//---------------------------------------------------------------------- + +void SvxDrawPage::dispose() + throw(::com::sun::star::uno::RuntimeException) +{ + OGuard aSolarGuard( Application::GetSolarMutex() ); + + // An frequently programming error is to release the last + // reference to this object in the disposing message. + // Make it rubust, hold a self Reference. + uno::Reference< lang::XComponent > xSelf( this ); + + // Guard dispose against multible threading + // Remark: It is an error to call dispose more than once + sal_Bool bDoDispose = sal_False; + { + osl::MutexGuard aGuard( mrBHelper.rMutex ); + if( !mrBHelper.bDisposed && !mrBHelper.bInDispose ) + { + // only one call go into this section + mrBHelper.bInDispose = sal_True; + bDoDispose = sal_True; + } + } + + // Do not hold the mutex because we are broadcasting + if( bDoDispose ) + { + // Create an event with this as sender + try + { + uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( (lang::XComponent *)this ) ); + ::com::sun::star::document::EventObject aEvt; + aEvt.Source = xSource; + // inform all listeners to release this object + // The listener container are automaticly cleared + mrBHelper.aLC.disposeAndClear( aEvt ); + // notify subclasses to do their dispose + disposing(); + } + catch(::com::sun::star::uno::Exception& e) + { + // catch exception and throw again but signal that + // the object was disposed. Dispose should be called + // only once. + mrBHelper.bDisposed = sal_True; + mrBHelper.bInDispose = sal_False; + throw e; + } + + // the values bDispose and bInDisposing must set in this order. + // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard. + mrBHelper.bDisposed = sal_True; + mrBHelper.bInDispose = sal_False; + } + +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxDrawPage::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpModel == 0 ) + throw lang::DisposedException(); + + mrBHelper.addListener( ::getCppuType( &aListener ) , aListener ); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxDrawPage::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpModel == 0 ) + throw lang::DisposedException(); + + mrBHelper.removeListener( ::getCppuType( &aListener ) , aListener ); +} + +//---------------------------------------------------------------------- +// SfxListener +//---------------------------------------------------------------------- + +void SvxDrawPage::Notify( SfxBroadcaster&, const SfxHint& /*rHint*/ ) +{ +/* + if( mpModel ) + { + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + if( pSdrHint ) + { + switch( pSdrHint->GetKind() ) + { + case HINT_MODELCLEARED: + dispose(); + break; + default: + break; + } + } + } +*/ +} + +//---------------------------------------------------------------------- +// ::com::sun::star::drawing::XShapes +//---------------------------------------------------------------------- + +void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + + if( NULL == pShape ) + return; + + SdrObject *pObj = pShape->GetSdrObject(); + + if(!pObj) + { + pObj = CreateSdrObject( xShape ); + } + else if ( !pObj->IsInserted() ) + { + pObj->SetModel(mpModel); + mpPage->InsertObject( pObj ); + } + + if(pObj == NULL) + return; + + if(pShape) + pShape->Create( pObj, this ); + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if(pObj) + { + // SdrObject aus der Page loeschen + sal_uInt32 nCount = mpPage->GetObjCount(); + for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ ) + { + if(mpPage->GetObj(nNum) == pObj) + { + OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj ); + SdrObject::Free( pObj ); + break; + } + } + } + } + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +// ::com::sun::star::container::XIndexAccess +//---------------------------------------------------------------------- + +sal_Int32 SAL_CALL SvxDrawPage::getCount() + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + return( (sal_Int32) mpPage->GetObjCount() ); +} + +//---------------------------------------------------------------------- +uno::Any SAL_CALL SvxDrawPage::getByIndex( sal_Int32 Index ) + throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + if ( Index < 0 || Index >= (sal_Int32)mpPage->GetObjCount() ) + throw lang::IndexOutOfBoundsException(); + + SdrObject* pObj = mpPage->GetObj( Index ); + if( pObj == NULL ) + throw uno::RuntimeException(); + + + return makeAny(Reference< drawing::XShape >( pObj->getUnoShape(), uno::UNO_QUERY )); +} + + +//---------------------------------------------------------------------- +// ::com::sun::star::container::XElementAccess +//---------------------------------------------------------------------- + +uno::Type SAL_CALL SvxDrawPage::getElementType() + throw( uno::RuntimeException ) +{ + return INTERFACE_TYPE( drawing::XShape ); +} + +//---------------------------------------------------------------------- +sal_Bool SAL_CALL SvxDrawPage::hasElements() + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + return mpPage && mpPage->GetObjCount()>0; +} + +namespace +{ + void lcl_markSdrObjectOfShape( const Reference< drawing::XShape >& _rxShape, SdrView& _rView, SdrPageView& _rPageView ) + { + SvxShape* pShape = SvxShape::getImplementation( _rxShape ); + if ( !pShape ) + return; + + SdrObject* pObj = pShape->GetSdrObject(); + if ( !pObj ) + return; + + _rView.MarkObj( pObj, &_rPageView ); + } +} + +//---------------------------------------------------------------------- +// ACHTUNG: _SelectObjectsInView selektiert die ::com::sun::star::drawing::Shapes nur in der angegebennen +// SdrPageView. Dies muß nicht die sichtbare SdrPageView sein. +//---------------------------------------------------------------------- +void SvxDrawPage::_SelectObjectsInView( const Reference< drawing::XShapes > & aShapes, SdrPageView* pPageView ) throw () +{ + DBG_ASSERT(pPageView,"SdrPageView ist NULL! [CL]"); + DBG_ASSERT(mpView, "SdrView ist NULL! [CL]"); + + if(pPageView!=NULL && mpView!=NULL) + { + mpView->UnmarkAllObj( pPageView ); + + long nCount = aShapes->getCount(); + for( long i = 0; i < nCount; i++ ) + { + uno::Any aAny( aShapes->getByIndex(i) ); + Reference< drawing::XShape > xShape; + if( aAny >>= xShape ) + lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView ); + } + } +} + +//---------------------------------------------------------------------- +// ACHTUNG: _SelectObjectInView selektiert das Shape *nur* in der angegebennen +// SdrPageView. Dies muß nicht die sichtbare SdrPageView sein. +//---------------------------------------------------------------------- +void SvxDrawPage::_SelectObjectInView( const Reference< drawing::XShape > & xShape, SdrPageView* pPageView ) throw() +{ + DBG_ASSERT(pPageView,"SdrPageView ist NULL! [CL]"); + DBG_ASSERT(mpView, "SdrView ist NULL! [CL]"); + + if(pPageView!=NULL && mpView != NULL) + { + mpView->UnmarkAllObj( pPageView ); + lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView ); + } +} + +//---------------------------------------------------------------------- +Reference< drawing::XShapeGroup > SAL_CALL SvxDrawPage::group( const Reference< drawing::XShapes >& xShapes ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + DBG_ASSERT(mpPage,"SdrPage ist NULL! [CL]"); + DBG_ASSERT(mpView, "SdrView ist NULL! [CL]"); + + Reference< ::com::sun::star::drawing::XShapeGroup > xShapeGroup; + if(mpPage==NULL||mpView==NULL||!xShapes.is()) + return xShapeGroup; + + SdrPageView* pPageView = mpView->ShowSdrPage( mpPage ); + + _SelectObjectsInView( xShapes, pPageView ); + + mpView->GroupMarked(); + + mpView->AdjustMarkHdl(); + const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if( pObj ) + xShapeGroup = Reference< drawing::XShapeGroup >::query( pObj->getUnoShape() ); + } + + mpView->HideSdrPage(); + + if( mpModel ) + mpModel->SetChanged(); + + return xShapeGroup; +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxDrawPage::ungroup( const Reference< drawing::XShapeGroup >& aGroup ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpModel == 0) || (mpPage == 0) ) + throw lang::DisposedException(); + + DBG_ASSERT(mpPage,"SdrPage ist NULL! [CL]"); + DBG_ASSERT(mpView, "SdrView ist NULL! [CL]"); + + if(mpPage==NULL||mpView==NULL||!aGroup.is()) + return; + + SdrPageView* pPageView = mpView->ShowSdrPage( mpPage ); + + Reference< drawing::XShape > xShape( aGroup, UNO_QUERY ); + _SelectObjectInView( xShape, pPageView ); + mpView->UnGroupMarked(); + + mpView->HideSdrPage(); + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +SdrObject *SvxDrawPage::_CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw() +{ + sal_uInt16 nType; + sal_uInt32 nInventor; + + GetTypeAndInventor( nType, nInventor, xShape->getShapeType() ); + SdrObject* pNewObj = 0; + + if( nType != 0 ) + { + awt::Size aSize = xShape->getSize(); + aSize.Width += 1; + aSize.Height += 1; + awt::Point aPos = xShape->getPosition(); + Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ); + + // special cases + if( nInventor == SdrInventor ) + { + switch( nType ) + { + case OBJ_MEASURE: + { + pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() ); + break; + } + case OBJ_LINE: + { + basegfx::B2DPolygon aPoly; + aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top())); + aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom())); + pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly)); + break; + } + } + } + + if( pNewObj == NULL ) + pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage ); + + if(pNewObj) + { + pNewObj->SetSnapRect(aRect); + + if( pNewObj->ISA(E3dPolyScene)) + { + // Szene initialisieren + E3dScene* pScene = (E3dScene*)pNewObj; + + double fW = (double)aSize.Width; + double fH = (double)aSize.Height; + + Camera3D aCam(pScene->GetCamera()); + aCam.SetAutoAdjustProjection(sal_False); + aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH); + basegfx::B3DPoint aLookAt; + basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0); + aCam.SetPosAndLookAt(aCamPos, aLookAt); + aCam.SetFocalLength(100.0); + aCam.SetDefaults(aCamPos, aLookAt, 10000.0); + pScene->SetCamera(aCam); + + pScene->SetRectsDirty(); + } + else if(pNewObj->ISA(E3dExtrudeObj)) + { + E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj; + basegfx::B2DPolygon aNewPolygon; + aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0)); + aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0)); + aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0)); + aNewPolygon.setClosed(true); + pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon)); + + // #107245# pObj->SetExtrudeCharacterMode(TRUE); + pObj->SetMergedItem(Svx3DCharacterModeItem(sal_True)); + } + else if(pNewObj->ISA(E3dLatheObj)) + { + E3dLatheObj* pObj = (E3dLatheObj*)pNewObj; + basegfx::B2DPolygon aNewPolygon; + aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0)); + aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0)); + aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0)); + aNewPolygon.setClosed(true); + pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon)); + + // #107245# pObj->SetLatheCharacterMode(TRUE); + pObj->SetMergedItem(Svx3DCharacterModeItem(sal_True)); + } + } + } + + return pNewObj; +} + +//---------------------------------------------------------------------- +void SvxDrawPage::GetTypeAndInventor( sal_uInt16& rType, sal_uInt32& rInventor, const OUString& aName ) const throw() +{ + sal_uInt32 nTempType = aSdrShapeIdentifierMap.getId( aName ); + + if( nTempType == UHASHMAP_NOTFOUND ) + { + if( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) ) + { + rInventor = SdrInventor; + rType = OBJ_TABLE; + } + } + else if(nTempType & E3D_INVENTOR_FLAG) + { + rInventor = E3dInventor; + rType = (sal_uInt16)(nTempType & ~E3D_INVENTOR_FLAG); + } + else + { + rInventor = SdrInventor; + rType = (sal_uInt16)nTempType; + + switch( rType ) + { + case OBJ_FRAME: + case OBJ_OLE2_PLUGIN: + case OBJ_OLE2_APPLET: + rType = OBJ_OLE2; + break; + } + } +} + +//---------------------------------------------------------------------- +SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor, SdrObject *pObj, SvxDrawPage *mpPage ) throw() +{ + SvxShape* pRet = NULL; + switch( nInventor ) + { + case E3dInventor: + { + switch( nType ) + { + case E3D_SCENE_ID : + case E3D_POLYSCENE_ID : + pRet = new Svx3DSceneObject( pObj, mpPage ); + break; + case E3D_CUBEOBJ_ID : + pRet = new Svx3DCubeObject( pObj ); + break; + case E3D_SPHEREOBJ_ID : + pRet = new Svx3DSphereObject( pObj ); + break; + case E3D_LATHEOBJ_ID : + pRet = new Svx3DLatheObject( pObj ); + break; + case E3D_EXTRUDEOBJ_ID : + pRet = new Svx3DExtrudeObject( pObj ); + break; + case E3D_POLYGONOBJ_ID : + pRet = new Svx3DPolygonObject( pObj ); + break; + default: // unbekanntes 3D-Objekt auf der Page + pRet = new SvxShape( pObj ); + break; + } + break; + } + case SdrInventor: + { + switch( nType ) + { +// case OBJ_NONE: +// break; + case OBJ_GRUP: + pRet = new SvxShapeGroup( pObj, mpPage ); + break; + case OBJ_LINE: + pRet = new SvxShapePolyPolygon( pObj , PolygonKind_LINE ); + break; + case OBJ_RECT: + pRet = new SvxShapeRect( pObj ); + break; + case OBJ_CIRC: + case OBJ_SECT: + case OBJ_CARC: + case OBJ_CCUT: + pRet = new SvxShapeCircle( pObj ); + break; + case OBJ_POLY: + pRet = new SvxShapePolyPolygon( pObj , PolygonKind_POLY ); + break; + case OBJ_PLIN: + pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PLIN ); + break; + case OBJ_SPLNLINE: + case OBJ_PATHLINE: + pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHLINE ); + break; + case OBJ_SPLNFILL: + case OBJ_PATHFILL: + pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHFILL ); + break; + case OBJ_FREELINE: + pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_FREELINE ); + break; + case OBJ_FREEFILL: + pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_FREEFILL ); + break; + case OBJ_CAPTION: + pRet = new SvxShapeCaption( pObj ); + break; + case OBJ_TITLETEXT: + case OBJ_OUTLINETEXT: + case OBJ_TEXT: + pRet = new SvxShapeText( pObj ); + break; + case OBJ_GRAF: + pRet = new SvxGraphicObject( pObj ); + break; + case OBJ_FRAME: + pRet = new SvxFrameShape( pObj ); + break; + case OBJ_OLE2_APPLET: + pRet = new SvxAppletShape( pObj ); + break; + case OBJ_OLE2_PLUGIN: + pRet = new SvxPluginShape( pObj ); + break; + case OBJ_OLE2: + { + if( pObj && !pObj->IsEmptyPresObj() && mpPage ) + { + SdrPage* pSdrPage = mpPage->GetSdrPage(); + if( pSdrPage ) + { + SdrModel* pSdrModel = pSdrPage->GetModel(); + if( pSdrModel ) + { + ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist(); + if( pPersist ) + { + uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer(). + GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ); + + // TODO CL->KA: Why is this not working anymore? + if( xObject.is() ) + { + SvGlobalName aClassId( xObject->getClassID() ); + + const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); + const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); + const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); + + if( aPluginClassId == aClassId ) + { + pRet = new SvxPluginShape( pObj ); + nType = OBJ_OLE2_PLUGIN; + } + else if( aAppletClassId == aClassId ) + { + pRet = new SvxAppletShape( pObj ); + nType = OBJ_OLE2_APPLET; + } + else if( aIFrameClassId == aClassId ) + { + pRet = new SvxFrameShape( pObj ); + nType = OBJ_FRAME; + } + } + } + } + } + } + if( pRet == NULL ) + { + pRet = new SvxOle2Shape( pObj, aSvxMapProvider.GetMap(SVXMAP_OLE2), aSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) ); + } + } + break; + case OBJ_EDGE: + pRet = new SvxShapeConnector( pObj ); + break; + case OBJ_PATHPOLY: + pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PATHPOLY ); + break; + case OBJ_PATHPLIN: + pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PATHPLIN ); + break; + case OBJ_PAGE: + pRet = new SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_PAGE), aSvxMapProvider.GetPropertySet(SVXMAP_PAGE, SdrObject::GetGlobalDrawObjectItemPool()) ); + break; + case OBJ_MEASURE: + pRet = new SvxShapeDimensioning( pObj ); + break; +// case OBJ_DUMMY: +// break; + case OBJ_UNO: + pRet = new SvxShapeControl( pObj ); + break; + case OBJ_CUSTOMSHAPE: + pRet = new SvxCustomShape( pObj ); + break; + case OBJ_MEDIA: + pRet = new SvxMediaShape( pObj ); + break; + case OBJ_TABLE: + pRet = new SvxTableShape( pObj ); + break; + default: // unbekanntes 2D-Objekt auf der Page + DBG_ERROR("Nicht implementierter Starone-Shape erzeugt! [CL]"); + pRet = new SvxShapeText( pObj ); + break; + } + break; + } + default: // Unbekannter Inventor + { + DBG_ERROR("AW: Unknown Inventor in SvxDrawPage::_CreateShape()"); + break; + } + } + + if(pRet) + { + sal_uInt32 nObjId = nType; + + if( nInventor == E3dInventor ) + nObjId |= E3D_INVENTOR_FLAG; + + switch(nObjId) + { + case OBJ_CCUT: // Kreisabschnitt + case OBJ_CARC: // Kreisbogen + case OBJ_SECT: // Kreissektor + nObjId = OBJ_CIRC; + break; + + case E3D_SCENE_ID | E3D_INVENTOR_FLAG: + nObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG; + break; + + case OBJ_TITLETEXT: + case OBJ_OUTLINETEXT: + nObjId = OBJ_TEXT; + break; + } + + pRet->setShapeKind(nObjId); + } + + return pRet; +} + +//---------------------------------------------------------------------- +Reference< drawing::XShape > SvxDrawPage::_CreateShape( SdrObject *pObj ) const throw() +{ + Reference< drawing::XShape > xShape( CreateShapeByTypeAndInventor(pObj->GetObjIdentifier(), + pObj->GetObjInventor(), + pObj, + (SvxDrawPage*)this)); + return xShape; +} + +//---------------------------------------------------------------------- +SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw() +{ + SdrObject* pObj = _CreateSdrObject( xShape ); + if( pObj && !pObj->IsInserted() ) + mpPage->InsertObject( pObj ); + + return pObj; +} + +//---------------------------------------------------------------------- +// ::com::sun::star::lang::XServiceInfo +//---------------------------------------------------------------------- +OUString SAL_CALL SvxDrawPage::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxDrawPage")); +} + +sal_Bool SAL_CALL SvxDrawPage::supportsService( const OUString& ServiceName ) + throw(::com::sun::star::uno::RuntimeException) +{ + return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSeq( 1 ); + aSeq.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ShapeCollection" )); + return aSeq; +} + +SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor ) throw() +{ + return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor ); +} + +void SvxDrawPage::ChangeModel( SdrModel* pNewModel ) +{ + if( pNewModel != mpModel ) + { + if( mpModel ) + EndListening( *mpModel ); + + if( pNewModel ) + StartListening( *pNewModel ); + + mpModel = pNewModel; + + if( mpView ) + { + delete mpView; + mpView = new SdrView( mpModel ); + if( mpView ) + mpView->SetDesignMode(sal_True); + } + } +} + +/** returns a StarOffice API wrapper for the given SdrPage */ +uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage( SdrPage* pPage ) throw () +{ + if(pPage) + { + uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); + + return xDrawPage; + } + + return uno::Reference< drawing::XDrawPage >(); +} + +/** returns the SdrObject from the given StarOffice API wrapper */ +SdrPage* GetSdrPageFromXDrawPage( uno::Reference< drawing::XDrawPage > xDrawPage ) throw() +{ + if(xDrawPage.is()) + { + SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xDrawPage ); + + if(pDrawPage) + { + return pDrawPage->GetSdrPage(); + } + } + + return NULL; +} + +// eof diff --git a/svx/source/unodraw/unopool.cxx b/svx/source/unodraw/unopool.cxx new file mode 100644 index 000000000000..8c2d7ecde19a --- /dev/null +++ b/svx/source/unodraw/unopool.cxx @@ -0,0 +1,430 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/lang/XServiceInfo.hpp> +#ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HDL_ +#include <com/sun/star/beans/PropertyState.hpp> +#endif + +#include <comphelper/propertysetinfo.hxx> +#include <rtl/uuid.h> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include "unopool.hxx" +#include <svx/svdmodel.hxx> +#include <svx/svdpool.hxx> +#include <svx/unoprov.hxx> +#include <svx/svdobj.hxx> +#include <svx/unoshprp.hxx> +#include <svx/xflbstit.hxx> +#include <svx/xflbmtit.hxx> +#include <svx/unopage.hxx> +#include <svx/svdetc.hxx> +#include <editeng/editeng.hxx> + +#include "unoapi.hxx" +#include <memory> + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel, sal_Int32 nServiceId ) throw() +: PropertySetHelper( SvxPropertySetInfoPool::getOrCreate( nServiceId ) ), mpModel( pModel ) +{ + init(); +} + +/* deprecated */ +SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel ) throw() +: PropertySetHelper( SvxPropertySetInfoPool::getOrCreate( SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS ) ), mpModel( pModel ) +{ + init(); +} + +SvxUnoDrawPool::~SvxUnoDrawPool() throw() +{ + SfxItemPool::Free(mpDefaultsPool); +} + +void SvxUnoDrawPool::init() +{ + mpDefaultsPool = new SdrItemPool(); + SfxItemPool* pOutlPool=EditEngine::CreatePool(); + mpDefaultsPool->SetSecondaryPool(pOutlPool); + + SdrModel::SetTextDefaults( mpDefaultsPool, SdrEngineDefaults::GetFontHeight() ); + mpDefaultsPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit()); + mpDefaultsPool->FreezeIdRanges(); +} + +SfxItemPool* SvxUnoDrawPool::getModelPool( sal_Bool bReadOnly ) throw() +{ + if( mpModel ) + { + return &mpModel->GetItemPool(); + } + else + { + if( bReadOnly ) + return mpDefaultsPool; + else + return NULL; + } +} + +void SvxUnoDrawPool::getAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, uno::Any& rValue ) + throw(beans::UnknownPropertyException) +{ + switch( pEntry->mnHandle ) + { + case OWN_ATTR_FILLBMP_MODE: + { + XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&pPool->GetDefaultItem(XATTR_FILLBMP_STRETCH); + XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&pPool->GetDefaultItem(XATTR_FILLBMP_TILE); + if( pTileItem && pTileItem->GetValue() ) + { + rValue <<= drawing::BitmapMode_REPEAT; + } + else if( pStretchItem && pStretchItem->GetValue() ) + { + rValue <<= drawing::BitmapMode_STRETCH; + } + else + { + rValue <<= drawing::BitmapMode_NO_REPEAT; + } + break; + } + default: + { + const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((USHORT)pEntry->mnHandle) : SFX_MAPUNIT_100TH_MM; + + BYTE nMemberId = pEntry->mnMemberId & (~SFX_METRIC_ITEM); + if( eMapUnit == SFX_MAPUNIT_100TH_MM ) + nMemberId &= (~CONVERT_TWIPS); + + // DVO, OD 10.10.2003 #i18732# + // Assure, that ID is a Which-ID (it could be a Slot-ID.) + // Thus, convert handle to Which-ID. + pPool->GetDefaultItem( pPool->GetWhich( (USHORT)pEntry->mnHandle ) ).QueryValue( rValue, nMemberId ); + } + } + + + // check for needed metric translation + const SfxMapUnit eMapUnit = pPool->GetMetric((USHORT)pEntry->mnHandle); + if(pEntry->mnMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM) + { + SvxUnoConvertToMM( eMapUnit, rValue ); + } + // convert int32 to correct enum type if needed + else if ( pEntry->mpType->getTypeClass() == uno::TypeClass_ENUM && rValue.getValueType() == ::getCppuType((const sal_Int32*)0) ) + { + sal_Int32 nEnum; + rValue >>= nEnum; + + rValue.setValue( &nEnum, *pEntry->mpType ); + } +} + +void SvxUnoDrawPool::putAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, const uno::Any& rValue ) + throw(beans::UnknownPropertyException, lang::IllegalArgumentException) +{ + uno::Any aValue( rValue ); + + const SfxMapUnit eMapUnit = pPool->GetMetric((USHORT)pEntry->mnHandle); + if(pEntry->mnMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM) + { + SvxUnoConvertFromMM( eMapUnit, aValue ); + } + + // DVO, OD 10.10.2003 #i18732# + // Assure, that ID is a Which-ID (it could be a Slot-ID.) + // Thus, convert handle to Which-ID. + const sal_uInt16 nWhich = pPool->GetWhich( (sal_uInt16)pEntry->mnHandle ); + switch( nWhich ) + { + case OWN_ATTR_FILLBMP_MODE: + do + { + drawing::BitmapMode eMode; + if(!(aValue >>= eMode) ) + { + sal_Int32 nMode = 0; + if(!(aValue >>= nMode)) + throw lang::IllegalArgumentException(); + + eMode = (drawing::BitmapMode)nMode; + } + + pPool->SetPoolDefaultItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) ); + pPool->SetPoolDefaultItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) ); + return; + } + while(0); + + default: + { + ::std::auto_ptr<SfxPoolItem> pNewItem( pPool->GetDefaultItem( nWhich ).Clone() ); + BYTE nMemberId = pEntry->mnMemberId & (~SFX_METRIC_ITEM); + if( !pPool || (pPool->GetMetric(nWhich) == SFX_MAPUNIT_100TH_MM) ) + nMemberId &= (~CONVERT_TWIPS); + + if( !pNewItem->PutValue( aValue, nMemberId ) ) + throw lang::IllegalArgumentException(); + + pPool->SetPoolDefaultItem( *pNewItem ); + } + } +} + +void SvxUnoDrawPool::_setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const uno::Any* pValues ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException ) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + SfxItemPool* pPool = getModelPool( sal_False ); + + DBG_ASSERT( pPool, "I need a SfxItemPool!" ); + if( NULL == pPool ) + throw beans::UnknownPropertyException(); + + while( *ppEntries ) + putAny( pPool, *ppEntries++, *pValues++ ); +} + +void SvxUnoDrawPool::_getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, uno::Any* pValue ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException ) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + SfxItemPool* pPool = getModelPool( sal_True ); + + DBG_ASSERT( pPool, "I need a SfxItemPool!" ); + if( NULL == pPool ) + throw beans::UnknownPropertyException(); + + while( *ppEntries ) + getAny( pPool, *ppEntries++, *pValue++ ); +} + +void SvxUnoDrawPool::_getPropertyStates( const comphelper::PropertyMapEntry** ppEntries, beans::PropertyState* pStates ) + throw(beans::UnknownPropertyException ) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + SfxItemPool* pPool = getModelPool( sal_True ); + + if( pPool && pPool != mpDefaultsPool ) + { + while( *ppEntries ) + { + // OD 13.10.2003 #i18732# + // Assure, that ID is a Which-ID (it could be a Slot-ID.) + // Thus, convert handle to Which-ID. + const sal_uInt16 nWhich = pPool->GetWhich( ((sal_uInt16)(*ppEntries)->mnHandle) ); + + switch( nWhich ) + { + case OWN_ATTR_FILLBMP_MODE: + { + // use method <IsStaticDefaultItem(..)> instead of using + // probably incompatible item pool <mpDefaultPool>. + if ( IsStaticDefaultItem( &(pPool->GetDefaultItem( XATTR_FILLBMP_STRETCH )) ) || + IsStaticDefaultItem( &(pPool->GetDefaultItem( XATTR_FILLBMP_TILE )) ) ) + { + *pStates = beans::PropertyState_DEFAULT_VALUE; + } + else + { + *pStates = beans::PropertyState_DIRECT_VALUE; + } + } + break; + default: + // OD 13.10.2003 #i18732# - correction: + // use method <IsStaticDefaultItem(..)> instead of using probably + // incompatible item pool <mpDefaultPool>. + const SfxPoolItem& r1 = pPool->GetDefaultItem( nWhich ); + //const SfxPoolItem& r2 = mpDefaultPool->GetDefaultItem( nWhich ); + + if ( IsStaticDefaultItem( &r1 ) ) + { + *pStates = beans::PropertyState_DEFAULT_VALUE; + } + else + { + *pStates = beans::PropertyState_DIRECT_VALUE; + } + } + + pStates++; + ppEntries++; + } + } + else + { + // as long as we have no model, all properties are default + while( *ppEntries++ ) + *pStates++ = beans::PropertyState_DEFAULT_VALUE; + return; + } +} + +void SvxUnoDrawPool::_setPropertyToDefault( const comphelper::PropertyMapEntry* pEntry ) + throw(beans::UnknownPropertyException ) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + SfxItemPool* pPool = getModelPool( sal_True ); + + // OD 10.10.2003 #i18732# + // Assure, that ID is a Which-ID (it could be a Slot-ID.) + // Thus, convert handle to Which-ID. + const sal_uInt16 nWhich = pPool->GetWhich( (USHORT)pEntry->mnHandle ); + if ( pPool && pPool != mpDefaultsPool ) + { + // OD 13.10.2003 #i18732# - use method <ResetPoolDefaultItem(..)> + // instead of using probably incompatible item pool <mpDefaultsPool>. + pPool->ResetPoolDefaultItem( nWhich ); + } +} + +uno::Any SvxUnoDrawPool::_getPropertyDefault( const comphelper::PropertyMapEntry* pEntry ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException ) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + // OD 13.10.2003 #i18732# - use method <GetPoolDefaultItem(..)> instead of + // using probably incompatible item pool <mpDefaultsPool> + uno::Any aAny; + SfxItemPool* pPool = getModelPool( sal_True ); + const sal_uInt16 nWhich = pPool->GetWhich( (USHORT)pEntry->mnHandle ); + const SfxPoolItem *pItem = pPool->GetPoolDefaultItem ( nWhich ); + pItem->QueryValue( aAny, pEntry->mnMemberId ); + + return aAny; +} + +// XInterface + +uno::Any SAL_CALL SvxUnoDrawPool::queryInterface( const uno::Type & rType ) + throw( uno::RuntimeException ) +{ + return OWeakAggObject::queryInterface( rType ); +} + +uno::Any SAL_CALL SvxUnoDrawPool::queryAggregation( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + uno::Any aAny; + + if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) ) + aAny <<= uno::Reference< lang::XServiceInfo >(this); + else if( rType == ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0) ) + aAny <<= uno::Reference< lang::XTypeProvider >(this); + else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ) + aAny <<= uno::Reference< beans::XPropertySet >(this); + else if( rType == ::getCppuType((const uno::Reference< beans::XPropertyState >*)0) ) + aAny <<= uno::Reference< beans::XPropertyState >(this); + else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) ) + aAny <<= uno::Reference< beans::XMultiPropertySet >(this); + else + aAny <<= OWeakAggObject::queryAggregation( rType ); + + return aAny; +} + +void SAL_CALL SvxUnoDrawPool::acquire() throw ( ) +{ + OWeakAggObject::acquire(); +} + +void SAL_CALL SvxUnoDrawPool::release() throw ( ) +{ + OWeakAggObject::release(); +} + +uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawPool::getTypes() + throw (uno::RuntimeException) +{ + uno::Sequence< uno::Type > aTypes( 6 ); + uno::Type* pTypes = aTypes.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< uno::XAggregation>*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet>*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState>*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet>*)0); + + return aTypes; +} + +uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawPool::getImplementationId() + throw (uno::RuntimeException) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// XServiceInfo + +sal_Bool SAL_CALL SvxUnoDrawPool::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); + const OUString * pArray = aSNL.getConstArray(); + + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + + return FALSE; +} + +OUString SAL_CALL SvxUnoDrawPool::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawPool") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoDrawPool::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults" )); + return aSNS; +} diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx new file mode 100644 index 000000000000..9a9717b34495 --- /dev/null +++ b/svx/source/unodraw/unoprov.cxx @@ -0,0 +1,1425 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#define _SVX_USE_UNOGLOBALS_ + +#include <com/sun/star/table/XTable.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/embed/XEmbeddedObject.hpp> +#include <com/sun/star/util/MeasureUnit.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/media/ZoomLevel.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <vcl/fldunit.hxx> +#include <tools/shl.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <comphelper/propertysetinfo.hxx> +#include <svx/dialmgr.hxx> +#include "unoapi.hxx" +#include <editeng/unotext.hxx> +#include <svx/unoshprp.hxx> +#include <editeng/editeng.hxx> +#include "globl3d.hxx" +#include <svx/dialogs.hrc> +#include <svx/svdpool.hxx> +#include <svx/svdobj.hxx> + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans::PropertyAttribute; +using ::com::sun::star::drawing::TextVerticalAdjust; + +SfxItemPropertyMapEntry* ImplGetSvxShapePropertyMap() +{ + static SfxItemPropertyMapEntry aShapePropertyMap_Impl[] = + { + EDGERADIUS_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + CUSTOMSHAPE_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aShapePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxTextShapePropertyMap() +{ + static SfxItemPropertyMapEntry aTextShapePropertyMap_Impl[] = + { + EDGERADIUS_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES_NO_SHEAR + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + CUSTOMSHAPE_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aTextShapePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxConnectorPropertyMap() +{ + static SfxItemPropertyMapEntry aConnectorPropertyMap_Impl[] = + { + SPECIAL_CONNECTOR_PROPERTIES + EDGERADIUS_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aConnectorPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxDimensioningPropertyMap() +{ + static SfxItemPropertyMapEntry aDimensioningPropertyMap_Impl[] = + { + SPECIAL_DIMENSIONING_PROPERTIES + EDGERADIUS_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aDimensioningPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxCirclePropertyMap() +{ + static SfxItemPropertyMapEntry aCirclePropertyMap_Impl[] = + { + SPECIAL_CIRCLE_PROPERTIES + EDGERADIUS_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + CUSTOMSHAPE_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aCirclePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxPolyPolygonPropertyMap() +{ + static SfxItemPropertyMapEntry aPolyPolygonPropertyMap_Impl[] = + { + { MAP_CHAR_LEN("Geometry"), OWN_ATTR_BASE_GEOMETRY, SEQTYPE(::getCppuType((const ::com::sun::star::drawing::PointSequenceSequence*)0)), 0, 0 }, + SPECIAL_POLYGON_PROPERTIES + SPECIAL_POLYPOLYGON_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + CUSTOMSHAPE_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aPolyPolygonPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxPolyPolygonBezierPropertyMap() +{ + static SfxItemPropertyMapEntry aPolyPolygonBezierPropertyMap_Impl[] = + { + { MAP_CHAR_LEN("Geometry"), OWN_ATTR_BASE_GEOMETRY, &::getCppuType((const ::com::sun::star::drawing::PolyPolygonBezierCoords*)0), 0, 0 }, + SPECIAL_POLYGON_PROPERTIES + SPECIAL_POLYPOLYGONBEZIER_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + CUSTOMSHAPE_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aPolyPolygonBezierPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxGraphicObjectPropertyMap() +{ + static SfxItemPropertyMapEntry aGraphicObjectPropertyMap_Impl[] = + { + SPECIAL_GRAPHOBJ_PROPERTIES + + // #i25616# + FILL_PROPERTIES + + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES_NO_SHEAR + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + { MAP_CHAR_LEN("IsMirrored"), OWN_ATTR_MIRRORED , &::getCppuBooleanType(), 0, 0}, + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("GraphicStream"), OWN_ATTR_GRAPHIC_STREAM, &::com::sun::star::io::XInputStream::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + {0,0,0,0,0,0} + + }; + + return aGraphicObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvx3DSceneObjectPropertyMap() +{ + static SfxItemPropertyMapEntry a3DSceneObjectPropertyMap_Impl[] = + { + SPECIAL_3DSCENEOBJECT_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + {0,0,0,0,0,0} + + }; + + return a3DSceneObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvx3DCubeObjectPropertyMap() +{ + static SfxItemPropertyMapEntry a3DCubeObjectPropertyMap_Impl[] = + { + SPECIAL_3DCUBEOBJECT_PROPERTIES + MISC_3D_OBJ_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return a3DCubeObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvx3DSphereObjectPropertyMap() +{ + static SfxItemPropertyMapEntry a3DSphereObjectPropertyMap_Impl[] = + { + SPECIAL_3DSPHEREOBJECT_PROPERTIES + MISC_3D_OBJ_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + return a3DSphereObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvx3DLatheObjectPropertyMap() +{ + static SfxItemPropertyMapEntry a3DLatheObjectPropertyMap_Impl[] = + { + SPECIAL_3DLATHEOBJECT_PROPERTIES + + // #107245# New 3D properties which are possible for lathe and extrude 3d objects + SPECIAL_3DLATHEANDEXTRUDEOBJ_PROPERTIES + + SPECIAL_3DBACKSCALE_PROPERTIES + MISC_3D_OBJ_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return a3DLatheObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvx3DExtrudeObjectPropertyMap() +{ + static SfxItemPropertyMapEntry a3DExtrudeObjectPropertyMap_Impl[] = + { + SPECIAL_3DEXTRUDEOBJECT_PROPERTIES + + // #107245# New 3D properties which are possible for lathe and extrude 3d objects + SPECIAL_3DLATHEANDEXTRUDEOBJ_PROPERTIES + + SPECIAL_3DBACKSCALE_PROPERTIES + MISC_3D_OBJ_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return a3DExtrudeObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvx3DPolygonObjectPropertyMap() +{ + static SfxItemPropertyMapEntry a3DPolygonObjectPropertyMap_Impl[] = + { + SPECIAL_3DPOLYGONOBJECT_PROPERTIES + MISC_3D_OBJ_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return a3DPolygonObjectPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxAllPropertyMap() +{ + static SfxItemPropertyMapEntry aAllPropertyMap_Impl[] = + { + SHADOW_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + FILL_PROPERTIES + EDGERADIUS_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SPECIAL_CONNECTOR_PROPERTIES + SPECIAL_DIMENSIONING_PROPERTIES + SPECIAL_CIRCLE_PROPERTIES + SPECIAL_POLYGON_PROPERTIES + SPECIAL_POLYPOLYGON_PROPERTIES + SPECIAL_POLYPOLYGONBEZIER_PROPERTIES + SPECIAL_GRAPHOBJ_PROPERTIES + SPECIAL_3DSCENEOBJECT_PROPERTIES + MISC_3D_OBJ_PROPERTIES + SPECIAL_3DCUBEOBJECT_PROPERTIES + SPECIAL_3DSPHEREOBJECT_PROPERTIES + SPECIAL_3DLATHEOBJECT_PROPERTIES + SPECIAL_3DEXTRUDEOBJECT_PROPERTIES + + // #107245# New 3D properties which are possible for lathe and extrude 3d objects + SPECIAL_3DLATHEANDEXTRUDEOBJ_PROPERTIES + + SPECIAL_3DBACKSCALE_PROPERTIES + SPECIAL_3DPOLYGONOBJECT_PROPERTIES + CUSTOMSHAPE_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aAllPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxGroupPropertyMap() +{ + static SfxItemPropertyMapEntry aGroupPropertyMap_Impl[] = + { + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + {0,0,0,0,0,0} + + }; + + return aGroupPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxOle2PropertyMap() +{ + static SfxItemPropertyMapEntry aOle2PropertyMap_Impl[] = + { + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \ + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("Model"), OWN_ATTR_OLEMODEL , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("EmbeddedObject"), OWN_ATTR_OLE_EMBEDDED_OBJECT , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("OriginalSize"), OWN_ATTR_OLESIZE , &::getCppuType(( const ::com::sun::star::awt::Size*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("CLSID"), OWN_ATTR_CLSID , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("IsInternal"), OWN_ATTR_INTERNAL_OLE , &::getBooleanCppuType() , ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0}, + { MAP_CHAR_LEN("Aspect"), OWN_ATTR_OLE_ASPECT , &::getCppuType((const sal_Int64*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_GRAPHOBJ_GRAPHIC), OWN_ATTR_VALUE_GRAPHIC , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic>*)0), 0, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aOle2PropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxPluginPropertyMap() +{ + static SfxItemPropertyMapEntry aPluginPropertyMap_Impl[] = + { + { MAP_CHAR_LEN("PluginMimeType"), OWN_ATTR_PLUGIN_MIMETYPE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("PluginURL"), OWN_ATTR_PLUGIN_URL , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("PluginCommands"), OWN_ATTR_PLUGIN_COMMANDS , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0)), 0, 0}, + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \ + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aPluginPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxFramePropertyMap() +{ + //TODO/LATER: new properties for ScrollingMode and DefaultBorder + static SfxItemPropertyMapEntry aFramePropertyMap_Impl[] = + { + { MAP_CHAR_LEN("FrameURL"), OWN_ATTR_FRAME_URL , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("FrameName"), OWN_ATTR_FRAME_NAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("FrameIsAutoScroll"), OWN_ATTR_FRAME_ISAUTOSCROLL , &::getBooleanCppuType() , ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_CHAR_LEN("FrameIsBorder"), OWN_ATTR_FRAME_ISBORDER , &::getBooleanCppuType() , 0, 0}, + { MAP_CHAR_LEN("FrameMarginWidth"), OWN_ATTR_FRAME_MARGIN_WIDTH , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN("FrameMarginHeight"), OWN_ATTR_FRAME_MARGIN_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \ + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aFramePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxAppletPropertyMap() +{ + static SfxItemPropertyMapEntry aAppletPropertyMap_Impl[] = + { + { MAP_CHAR_LEN("AppletCodeBase"), OWN_ATTR_APPLET_CODEBASE , &::getCppuType(( const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("AppletName"), OWN_ATTR_APPLET_NAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("AppletCode"), OWN_ATTR_APPLET_CODE , &::getCppuType(( const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("AppletCommands"), OWN_ATTR_APPLET_COMMANDS , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0)), 0, 0}, + { MAP_CHAR_LEN("AppletDocBase"), OWN_ATTR_APPLET_DOCBASE , &::getCppuType(( const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("AppletIsScript"), OWN_ATTR_APPLET_ISSCRIPT , &::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \ + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aAppletPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxControlShapePropertyMap() +{ + static SfxItemPropertyMapEntry aControlPropertyMap_Impl[] = + { + // the following properties are mapped to the XControl Model of this shape + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), 0, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), 0, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), 0, &::getCppuType((const float*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), 0, &::getCppuType((const ::com::sun::star::awt::FontSlant*)0),0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), 0, &::getCppuType((const float*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), 0, &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR), 0, &::getCppuType((const sal_Int32*)0), 0, 0 }, + { MAP_CHAR_LEN("CharRelief"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN("CharUnderlineColor"), 0, &::getCppuType((const sal_Int32*)0), 0, 0 }, + { MAP_CHAR_LEN("CharKerning"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN("CharWordMode"), 0, &::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN("TextVerticalAdjust"), 0, &::getCppuType((const TextVerticalAdjust*)0), MAYBEVOID, 0 }, + { MAP_CHAR_LEN("ControlBackground"), 0, &::getCppuType((const sal_Int32*)0), 0, 0 }, + { MAP_CHAR_LEN("ControlBorder"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN("ControlBorderColor"), 0, &::getCppuType((const sal_Int32*)0), 0, 0 }, + { MAP_CHAR_LEN("ControlSymbolColor"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN("ImageScaleMode"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("ControlTextEmphasis"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 }, + { MAP_CHAR_LEN("ControlWritingMode"), 0, &::cppu::UnoType< sal_Int16 >::get(), 0, 0}, + // the following properties are handled by SvxShape + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aControlPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxPageShapePropertyMap() +{ + static SfxItemPropertyMapEntry aPageShapePropertyMap_Impl[] = + { + { MAP_CHAR_LEN("PageNumber"), OWN_ATTR_PAGE_NUMBER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \ + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aPageShapePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxCaptionPropertyMap() +{ + static SfxItemPropertyMapEntry aCaptionPropertyMap_Impl[] = + { + { MAP_CHAR_LEN("CaptionPoint"), OWN_ATTR_CAPTION_POINT, &::getCppuType((const com::sun::star::awt::Point*)0), 0, 0 }, + { MAP_CHAR_LEN("CaptionType"), SDRATTR_CAPTIONTYPE, &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN("CaptionIsFixedAngle"), SDRATTR_CAPTIONFIXEDANGLE, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN("CaptionAngle"), SDRATTR_CAPTIONANGLE, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN("CaptionGap"), SDRATTR_CAPTIONGAP, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, + { MAP_CHAR_LEN("CaptionEscapeDirection"), SDRATTR_CAPTIONESCDIR, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN("CaptionIsEscapeRelative"), SDRATTR_CAPTIONESCISREL, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN("CaptionEscapeRelative"), SDRATTR_CAPTIONESCREL, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN("CaptionEscapeAbsolute"), SDRATTR_CAPTIONESCABS, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, + { MAP_CHAR_LEN("CaptionLineLength"), SDRATTR_CAPTIONLINELEN, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, + { MAP_CHAR_LEN("CaptionIsFitLineLength"), SDRATTR_CAPTIONFITLINELEN, &::getBooleanCppuType(), 0, 0}, + EDGERADIUS_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + // #FontWork# + FONTWORK_PROPERTIES + { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + + return aCaptionPropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxCustomShapePropertyMap() +{ + static SfxItemPropertyMapEntry aCustomShapePropertyMap_Impl[] = + { + { MAP_CHAR_LEN("CustomShapeEngine"), SDRATTR_CUSTOMSHAPE_ENGINE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("CustomShapeData"), SDRATTR_CUSTOMSHAPE_DATA, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, + { MAP_CHAR_LEN("CustomShapeGeometry"), SDRATTR_CUSTOMSHAPE_GEOMETRY, SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0)), 0, 0 }, + { MAP_CHAR_LEN("CustomShapeGraphicURL"), SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + CUSTOMSHAPE_PROPERTIES + FILL_PROPERTIES + LINE_PROPERTIES + LINE_PROPERTIES_START_END + SHAPE_DESCRIPTOR_PROPERTIES + MISC_OBJ_PROPERTIES + LINKTARGET_PROPERTIES + SHADOW_PROPERTIES + TEXT_PROPERTIES + {MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + + }; + return aCustomShapePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxMediaShapePropertyMap() +{ + static SfxItemPropertyMapEntry aMediaShapePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID, &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME), SDRATTR_LAYERNAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP, &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME, &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION, &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, + { MAP_CHAR_LEN("MediaURL"), OWN_ATTR_MEDIA_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("PreferredSize"), OWN_ATTR_MEDIA_PREFERREDSIZE, &::getCppuType((const ::com::sun::star::awt::Size*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("Loop"), OWN_ATTR_MEDIA_LOOP, &::getCppuType((const sal_Bool*)0), 0, 0}, + { MAP_CHAR_LEN("Mute"), OWN_ATTR_MEDIA_MUTE, &::getCppuType((const sal_Bool*)0), 0, 0}, + { MAP_CHAR_LEN("VolumeDB"), OWN_ATTR_MEDIA_VOLUMEDB, &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN("Zoom"), OWN_ATTR_MEDIA_ZOOM, &::getCppuType((const ::com::sun::star::media::ZoomLevel*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + // #i68101# + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aMediaShapePropertyMap_Impl; +} + +SfxItemPropertyMapEntry* ImplGetSvxTableShapePropertyMap() +{ + static SfxItemPropertyMapEntry aTableShapePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID, &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME), SDRATTR_LAYERNAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP, &::com::sun::star::awt::XBitmap::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME, &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION, &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0}, + { MAP_CHAR_LEN("Model"), OWN_ATTR_OLEMODEL , &::com::sun::star::table::XTable::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN("TableTemplate"), OWN_ATTR_TABLETEMPLATE , &::com::sun::star::container::XIndexAccess::static_type(), 0, 0}, + { MAP_CHAR_LEN("UseFirstRowStyle"), OWN_ATTR_TABLETEMPLATE_FIRSTROW, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("UseLastRowStyle"), OWN_ATTR_TABLETEMPLATE_LASTROW, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("UseFirstColumnStyle"), OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("UseLastColumnStyle"), OWN_ATTR_TABLETEMPLATE_LASTCOLUMN, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("UseBandingRowStyle"), OWN_ATTR_TABLETEMPLATE_BANDINGROWS, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("UseBandingColumnStyle"), OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS, &::getBooleanCppuType(),0, 0}, + { MAP_CHAR_LEN("ReplacementGraphic"), OWN_ATTR_BITMAP, &::com::sun::star::graphic::XGraphic::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + + {0,0,0,0,0,0} + }; + + return aTableShapePropertyMap_Impl; +} + +comphelper::PropertyMapEntry* ImplGetSvxDrawingDefaultsPropertyMap() +{ + static comphelper::PropertyMapEntry aSvxDrawingDefaultsPropertyMap_Impl[] = + { + SHADOW_PROPERTIES + LINE_PROPERTIES_DEFAULTS + FILL_PROPERTIES_BMP + FILL_PROPERTIES_DEFAULTS + EDGERADIUS_PROPERTIES + TEXT_PROPERTIES_DEFAULTS + CONNECTOR_PROPERTIES + SPECIAL_DIMENSIONING_PROPERTIES_DEFAULTS + MISC_3D_OBJ_PROPERTIES + SPECIAL_3DBACKSCALE_PROPERTIES + {0,0,0,0,0,0} + + }; + + return aSvxDrawingDefaultsPropertyMap_Impl; +} + +// OD 13.10.2003 #i18732# +comphelper::PropertyMapEntry* ImplGetAdditionalWriterDrawingDefaultsPropertyMap() +{ + static comphelper::PropertyMapEntry aSvxAdditionalDefaultsPropertyMap_Impl[] = + { + { MAP_CHAR_LEN("IsFollowingTextFlow"), SID_SW_FOLLOW_TEXT_FLOW, &::getBooleanCppuType(), 0, 0}, + {0,0,0,0,0,0} + + }; + + return aSvxAdditionalDefaultsPropertyMap_Impl; +} + +// --------------------------------------------------------------------- + +SvxUnoPropertyMapProvider aSvxMapProvider; + +UHashMapEntry pSdrShapeIdentifierMap[] = +{ + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.RectangleShape"), OBJ_RECT ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.EllipseShape"), OBJ_CIRC ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape"), OBJ_UNO ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ConnectorShape"), OBJ_EDGE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MeasureShape"), OBJ_MEASURE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.LineShape"), OBJ_LINE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonShape"), OBJ_POLY ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLineShape"), OBJ_PLIN ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenBezierShape"), OBJ_PATHLINE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedBezierShape"), OBJ_PATHFILL ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenFreeHandShape"), OBJ_FREELINE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape"), OBJ_FREEFILL ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape"), OBJ_PATHPOLY ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLinePathShape"), OBJ_PATHPLIN ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape"), OBJ_GRAF ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape"), OBJ_GRUP ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape"), OBJ_TEXT ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape"), OBJ_OLE2 ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape"), OBJ_PAGE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CaptionShape"), OBJ_CAPTION ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.FrameShape"), OBJ_FRAME ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PluginShape"), OBJ_OLE2_PLUGIN ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.AppletShape"), OBJ_OLE2_APPLET ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CustomShape"), OBJ_CUSTOMSHAPE ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MediaShape"), OBJ_MEDIA ), + + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject"), E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject"), E3D_CUBEOBJ_ID | E3D_INVENTOR_FLAG ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject"), E3D_SPHEREOBJ_ID | E3D_INVENTOR_FLAG ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"), E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG ), + UHashMapEntry (RTL_CONSTASCII_STRINGPARAM(""), 0 ) +}; + +// --------------------------------------------------------------------- + +UHashMap aSdrShapeIdentifierMap( pSdrShapeIdentifierMap ); + +/*********************************************************************** +* class UHashMap * +***********************************************************************/ + +UHashMap::UHashMap( UHashMapEntry* pMap ) +{ + while( pMap->aIdentifier.getLength() ) + { + OUString aStr( pMap->aIdentifier ); + size_t nHash = aStr.hashCode() & (HASHARRAYSIZE-1); + + m_aHashList[nHash].Insert(pMap); + pMap++; + } +} + +// --------------------------------------------------------------------- + +UINT32 UHashMap::getId( const OUString& rCompareString ) +{ + size_t nHash = rCompareString.hashCode() & (HASHARRAYSIZE-1); + + UHashMapEntryList& rList = m_aHashList[nHash]; + + UHashMapEntry * pMap = rList.First(); + + while(pMap) + { + if( rCompareString == pMap->aIdentifier ) + return pMap->nId; + + pMap = rList.Next(); + } + + return UHASHMAP_NOTFOUND; +} + +/*********************************************************************** +* class SvxUnoPropertyMapProvider * +***********************************************************************/ + +EXTERN_C +#if defined( PM2 ) && (!defined( CSET ) && !defined ( MTW ) && !defined( WTC )) +int _stdcall +#else +#ifdef WNT +int _cdecl +#else +int +#endif +#endif +Svx_CompareMap(const void* pSmaller, const void* pBigger ) +{ + int nDiff = strcmp( ((const SfxItemPropertyMapEntry*)pSmaller)->pName, + ((const SfxItemPropertyMapEntry*)pBigger)->pName ); + return nDiff; +} + +// --------------------------------------------------------------------- + +SvxUnoPropertyMapProvider::SvxUnoPropertyMapProvider() +{ + for(UINT16 i=0;i<SVXMAP_END; i++) + { + aSetArr[i] = 0; + aMapArr[i] = 0; + } +} + +SvxUnoPropertyMapProvider::~SvxUnoPropertyMapProvider() +{ + for(UINT16 i=0;i<SVXMAP_END; i++) + delete aSetArr[i]; +} + +// --------------------------------------------------------------------- + +/*void SvxUnoPropertyMapProvider::Sort(USHORT nId) +{ + SfxItemPropertyMapEntry* pTemp = aMapArr[nId]; + UINT16 i = 0; + while(pTemp[i].pName) { i++; } + qsort(aMapArr[nId], i, sizeof(SfxItemPropertyMapEntry), Svx_CompareMap); +}*/ + +// --------------------------------------------------------------------- + +const SfxItemPropertyMapEntry* SvxUnoPropertyMapProvider::GetMap(UINT16 nPropertyId) +{ + DBG_ASSERT(nPropertyId < SVXMAP_END, "Id ?" ); + if(!aMapArr[nPropertyId]) { + switch(nPropertyId) { + case SVXMAP_SHAPE: aMapArr[SVXMAP_SHAPE]=ImplGetSvxShapePropertyMap(); break; + case SVXMAP_CONNECTOR: aMapArr[SVXMAP_CONNECTOR]=ImplGetSvxConnectorPropertyMap(); break; + case SVXMAP_DIMENSIONING: aMapArr[SVXMAP_DIMENSIONING]=ImplGetSvxDimensioningPropertyMap(); break; + case SVXMAP_CIRCLE: aMapArr[SVXMAP_CIRCLE]=ImplGetSvxCirclePropertyMap(); break; + case SVXMAP_POLYPOLYGON: aMapArr[SVXMAP_POLYPOLYGON]=ImplGetSvxPolyPolygonPropertyMap(); break; + case SVXMAP_POLYPOLYGONBEZIER: aMapArr[SVXMAP_POLYPOLYGONBEZIER]=ImplGetSvxPolyPolygonBezierPropertyMap(); break; + case SVXMAP_GRAPHICOBJECT: aMapArr[SVXMAP_GRAPHICOBJECT]=ImplGetSvxGraphicObjectPropertyMap(); break; + case SVXMAP_3DSCENEOBJECT: aMapArr[SVXMAP_3DSCENEOBJECT]=ImplGetSvx3DSceneObjectPropertyMap(); break; + case SVXMAP_3DCUBEOBJEKT: aMapArr[SVXMAP_3DCUBEOBJEKT]=ImplGetSvx3DCubeObjectPropertyMap(); break; + case SVXMAP_3DSPHEREOBJECT: aMapArr[SVXMAP_3DSPHEREOBJECT]=ImplGetSvx3DSphereObjectPropertyMap(); break; + case SVXMAP_3DLATHEOBJECT: aMapArr[SVXMAP_3DLATHEOBJECT]=ImplGetSvx3DLatheObjectPropertyMap(); break; + case SVXMAP_3DEXTRUDEOBJECT: aMapArr[SVXMAP_3DEXTRUDEOBJECT]=ImplGetSvx3DExtrudeObjectPropertyMap(); break; + case SVXMAP_3DPOLYGONOBJECT: aMapArr[SVXMAP_3DPOLYGONOBJECT]=ImplGetSvx3DPolygonObjectPropertyMap(); break; + case SVXMAP_ALL: aMapArr[SVXMAP_ALL]=ImplGetSvxAllPropertyMap(); break; + case SVXMAP_GROUP: aMapArr[SVXMAP_GROUP]=ImplGetSvxGroupPropertyMap(); break; + case SVXMAP_CAPTION: aMapArr[SVXMAP_CAPTION]=ImplGetSvxCaptionPropertyMap(); break; + case SVXMAP_OLE2: aMapArr[SVXMAP_OLE2]=ImplGetSvxOle2PropertyMap(); break; + case SVXMAP_PLUGIN: aMapArr[SVXMAP_PLUGIN]=ImplGetSvxPluginPropertyMap(); break; + case SVXMAP_FRAME: aMapArr[SVXMAP_FRAME]=ImplGetSvxFramePropertyMap(); break; + case SVXMAP_APPLET: aMapArr[SVXMAP_APPLET]=ImplGetSvxAppletPropertyMap(); break; + case SVXMAP_CONTROL: aMapArr[SVXMAP_CONTROL]=ImplGetSvxControlShapePropertyMap(); break; + case SVXMAP_TEXT: aMapArr[SVXMAP_TEXT]=ImplGetSvxTextShapePropertyMap(); break; + case SVXMAP_CUSTOMSHAPE: aMapArr[SVXMAP_CUSTOMSHAPE]=ImplGetSvxCustomShapePropertyMap(); break; + case SVXMAP_MEDIA: aMapArr[SVXMAP_MEDIA]=ImplGetSvxMediaShapePropertyMap(); break; + case SVXMAP_TABLE: aMapArr[SVXMAP_TABLE]=ImplGetSvxTableShapePropertyMap(); break; + case SVXMAP_PAGE: aMapArr[SVXMAP_PAGE] = ImplGetSvxPageShapePropertyMap(); break; + + default: + DBG_ERROR( "Unknown property map for SvxUnoPropertyMapProvider!" ); + } +// Sort(nPropertyId); + } + return aMapArr[nPropertyId]; +} +const SvxItemPropertySet* SvxUnoPropertyMapProvider::GetPropertySet(UINT16 nPropertyId, SfxItemPool& rPool) +{ + if( !aSetArr[nPropertyId] ) + aSetArr[nPropertyId] = new SvxItemPropertySet( GetMap( nPropertyId ), rPool ); + return aSetArr[nPropertyId]; +} + +// ##################################################################### + +/** maps the API constant MeasureUnit to a vcl MapUnit enum. + Returns false if conversion is not supported. + + @cl: for warnings01 I found out that this method never worked so I thin + it is not used at all +sal_Bool SvxMeasureUnitToMapUnit( const short eApi, int& eVcl ) throw() +{ + switch( eVcl ) + { + case util::MeasureUnit::MM_100TH: eVcl = MAP_100TH_MM; break; + case util::MeasureUnit::MM_10TH: eVcl = MAP_10TH_MM; break; + case util::MeasureUnit::MM: eVcl = MAP_MM; break; + case util::MeasureUnit::CM: eVcl = MAP_CM; break; + case util::MeasureUnit::INCH_1000TH: eVcl = MAP_1000TH_INCH; break; + case util::MeasureUnit::INCH_100TH: eVcl = MAP_100TH_INCH; break; + case util::MeasureUnit::INCH_10TH: eVcl = MAP_10TH_INCH; break; + case util::MeasureUnit::INCH: eVcl = MAP_INCH; break; + case util::MeasureUnit::POINT: eVcl = MAP_POINT; break; + case util::MeasureUnit::TWIP: eVcl = MAP_TWIP; break; + case util::MeasureUnit::PERCENT: eVcl = MAP_RELATIVE; break; + default: + return false; + } + + return true; +} +*/ + +/** maps the vcl MapUnit enum to a API constant MeasureUnit. + Returns false if conversion is not supported. +*/ +sal_Bool SvxMapUnitToMeasureUnit( const short eVcl, short& eApi ) throw() +{ + switch( eVcl ) + { + case MAP_100TH_MM: eApi = util::MeasureUnit::MM_100TH; break; + case MAP_10TH_MM: eApi = util::MeasureUnit::MM_10TH; break; + case MAP_MM: eApi = util::MeasureUnit::MM; break; + case MAP_CM: eApi = util::MeasureUnit::CM; break; + case MAP_1000TH_INCH: eApi = util::MeasureUnit::INCH_1000TH; break; + case MAP_100TH_INCH: eApi = util::MeasureUnit::INCH_100TH; break; + case MAP_10TH_INCH: eApi = util::MeasureUnit::INCH_10TH; break; + case MAP_INCH: eApi = util::MeasureUnit::INCH; break; + case MAP_POINT: eApi = util::MeasureUnit::POINT; break; + case MAP_TWIP: eApi = util::MeasureUnit::TWIP; break; + case MAP_RELATIVE: eApi = util::MeasureUnit::PERCENT; break; + default: + return false; + } + + return true; +} + +/** maps the API constant MeasureUnit to a vcl MapUnit enum. + Returns false if conversion is not supported. +*/ + +sal_Bool SvxMeasureUnitToFieldUnit( const short eApi, short& eVcl ) throw() +{ + switch( eApi ) + { + case util::MeasureUnit::MM: eVcl = FUNIT_MM; break; + case util::MeasureUnit::CM: eVcl = FUNIT_CM; break; + case util::MeasureUnit::M: eVcl = FUNIT_M; break; + case util::MeasureUnit::KM: eVcl = FUNIT_KM; break; + case util::MeasureUnit::TWIP: eVcl = FUNIT_TWIP; break; + case util::MeasureUnit::POINT: eVcl = FUNIT_POINT; break; + case util::MeasureUnit::PICA: eVcl = FUNIT_PICA; break; + case util::MeasureUnit::INCH: eVcl = FUNIT_INCH; break; + case util::MeasureUnit::FOOT: eVcl = FUNIT_FOOT; break; + case util::MeasureUnit::MILE: eVcl = FUNIT_MILE; break; + case util::MeasureUnit::PERCENT: eVcl = FUNIT_PERCENT; break; + case util::MeasureUnit::MM_100TH: eVcl = FUNIT_100TH_MM; break; + default: + return sal_False; + } + + return sal_True; +} + +/** maps the vcl MapUnit enum to a API constant MeasureUnit. + Returns false if conversion is not supported. +*/ +sal_Bool SvxFieldUnitToMeasureUnit( const short eVcl, short& eApi ) throw() +{ + switch( eVcl ) + { + case FUNIT_MM: eApi = util::MeasureUnit::MM; break; + case FUNIT_CM: eApi = util::MeasureUnit::CM; break; + case FUNIT_M: eApi = util::MeasureUnit::M; break; + case FUNIT_KM: eApi = util::MeasureUnit::KM; break; + case FUNIT_TWIP: eApi = util::MeasureUnit::TWIP; break; + case FUNIT_POINT: eApi = util::MeasureUnit::POINT; break; + case FUNIT_PICA: eApi = util::MeasureUnit::PICA; break; + case FUNIT_INCH: eApi = util::MeasureUnit::INCH; break; + case FUNIT_FOOT: eApi = util::MeasureUnit::FOOT; break; + case FUNIT_MILE: eApi = util::MeasureUnit::MILE; break; + case FUNIT_PERCENT: eApi = util::MeasureUnit::PERCENT; break; + case FUNIT_100TH_MM: eApi = util::MeasureUnit::MM_100TH; break; + default: + return sal_False; + } + + return sal_True; +} + +bool SvxUnoGetResourceRanges( const short nWhich, int& nApiResIds, int& nIntResIds, int& nCount ) throw() +{ + switch( nWhich ) + { + case XATTR_FILLBITMAP: + nApiResIds = RID_SVXSTR_BMP_DEF_START; + nIntResIds = RID_SVXSTR_BMP_START; + nCount = RID_SVXSTR_BMP_DEF_END - RID_SVXSTR_BMP_DEF_START + 1; + break; + + case XATTR_LINEDASH: + nApiResIds = RID_SVXSTR_DASH_DEF_START; + nIntResIds = RID_SVXSTR_DASH_START; + nCount = RID_SVXSTR_DASH_DEF_END - RID_SVXSTR_DASH_DEF_START + 1; + break; + + case XATTR_LINESTART: + case XATTR_LINEEND: + nApiResIds = RID_SVXSTR_LEND_DEF_START; + nIntResIds = RID_SVXSTR_LEND_START; + nCount = RID_SVXSTR_LEND_DEF_END - RID_SVXSTR_LEND_DEF_START + 1; + break; + + case XATTR_FILLGRADIENT: + nApiResIds = RID_SVXSTR_GRDT_DEF_START; + nIntResIds = RID_SVXSTR_GRDT_START; + nCount = RID_SVXSTR_GRDT_DEF_END - RID_SVXSTR_GRDT_DEF_START + 1; + break; + + case XATTR_FILLHATCH: + nApiResIds = RID_SVXSTR_HATCH_DEF_START; + nIntResIds = RID_SVXSTR_HATCH_START; + nCount = RID_SVXSTR_HATCH_DEF_END - RID_SVXSTR_HATCH_DEF_START + 1; + break; + + case XATTR_FILLFLOATTRANSPARENCE: + nApiResIds = RID_SVXSTR_TRASNGR_DEF_START; + nIntResIds = RID_SVXSTR_TRASNGR_START; + nCount = RID_SVXSTR_TRASNGR_DEF_END - RID_SVXSTR_TRASNGR_DEF_START + 1; + break; + + default: + return FALSE; + } + + return TRUE; +} + +/*sal_Int16 SvxUnoGetWhichIdForNamedProperty( const ::rtl::OUString & rPropName ) +{ + sal_Int16 nWhich = 0; + + const SfxItemPropertyMapEntry* pMap = aSvxMapProvider.GetMap( SVXMAP_SHAPE ); + if( pMap ) + { + const SfxItemPropertyMapEntry* pFound = SfxItemPropertyMapEntry::getByName( pMap, rPropName ); + if( pFound ) + nWhich = pFound->nWID; + } + + return nWhich; +} */ + +bool SvxUnoConvertResourceString( int nSourceResIds, int nDestResIds, int nCount, String& rString ) throw() +{ + // first, calculate the search string length without an optional number behind the name + xub_StrLen nLength = rString.Len(); + while( nLength > 0 ) + { + const sal_Unicode nChar = rString.GetChar( nLength - 1 ); + if( (nChar < '0') || (nChar > '9') ) + break; + + nLength--; + } + + // if we cut off a number, also cut of some spaces + if( nLength != rString.Len() ) + { + while( nLength > 0 ) + { + const sal_Unicode nChar = rString.GetChar( nLength - 1 ); + if( nChar != ' ' ) + break; + + nLength--; + } + } + + const String aShortString( rString.Copy( 0, nLength ) ); + + int i; + for( i = 0; i < nCount; i++ ) + { + USHORT nResId = (USHORT)(nSourceResIds + i); + const ResId aRes( SVX_RES(nResId)); + const String aCompare( aRes ); + if( aShortString == aCompare ) + { + USHORT nNewResId = (USHORT)(nDestResIds + i); + ResId aNewRes( SVX_RES( nNewResId )); + rString.Replace( 0, aShortString.Len(), String( aNewRes ) ); + return TRUE; + } + else if( rString == aCompare ) + { + USHORT nNewResId = (USHORT)(nDestResIds + i); + ResId aNewRes( SVX_RES( nNewResId )); + rString = String( aNewRes ); + return TRUE; + } + } + + return FALSE; +} + +static USHORT __READONLY_DATA SvxUnoColorNameDefResId[] = +{ + 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, + RID_SVXSTR_COLOR_CHART_DEF +}; + +static USHORT __READONLY_DATA SvxUnoColorNameResId[] = +{ + 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, + RID_SVXSTR_COLOR_CHART +}; + +bool SvxUnoConvertResourceString( USHORT* pSourceResIds, USHORT* pDestResIds, int nCount, String& rString ) throw() +{ + int i = 0; + + for( i = 0; i < nCount; i++ ) + { + String aStrDefName = SVX_RESSTR( pSourceResIds[i] ); + if( rString.Search( aStrDefName ) == 0 ) + { + String aReplace = SVX_RESSTR( pDestResIds[i] ); + rString.Replace( 0, aStrDefName.Len(), aReplace ); + return true; + } + } + + return false; +} + +/** if the given name is a predefined name for the current language it is replaced by + the corresponding api name. +*/ +void SvxUnogetApiNameForItem( const sal_Int16 nWhich, const String& rInternalName, rtl::OUString& rApiName ) throw() +{ +#ifndef SVX_LIGHT + String aNew = rInternalName; + + if( nWhich == XATTR_LINECOLOR ) + { + if( SvxUnoConvertResourceString( (USHORT*)SvxUnoColorNameResId, (USHORT*)SvxUnoColorNameDefResId, sizeof( SvxUnoColorNameResId ) / sizeof( USHORT ), aNew ) ) + { + rApiName = aNew; + return; + } + } + else + { + int nApiResIds; + int nIntResIds; + int nCount; + + if( SvxUnoGetResourceRanges( nWhich, nApiResIds, nIntResIds, nCount ) ) + { + if(SvxUnoConvertResourceString( nIntResIds, nApiResIds, nCount, aNew ) ) + { + rApiName = aNew; + return; + } + } + } +#endif + + // just use previous name, if nothing else was found. + rApiName = rInternalName; +} + +/** if the given name is a predefined api name it is replaced by the predefined name + for the current language. +*/ +void SvxUnogetInternalNameForItem( const sal_Int16 nWhich, const rtl::OUString& rApiName, String& rInternalName ) throw() +{ +#ifndef SVX_LIGHT + String aNew = rApiName; + + if( nWhich == XATTR_LINECOLOR ) + { + if( SvxUnoConvertResourceString( (USHORT*)SvxUnoColorNameDefResId, (USHORT*)SvxUnoColorNameResId, sizeof( SvxUnoColorNameResId ) / sizeof( USHORT ), aNew ) ) + { + rInternalName = aNew; + return; + } + } + else + { + int nApiResIds; + int nIntResIds; + int nCount; + + if( SvxUnoGetResourceRanges( nWhich, nApiResIds, nIntResIds, nCount ) ) + { + if(SvxUnoConvertResourceString( nApiResIds, nIntResIds, nCount, aNew ) ) + { + rInternalName = aNew; + return; + } + } + } +#endif // !SVX_LIGHT + + // just use previous name, if nothing else was found. + rInternalName = rApiName; +} + +/////////////////////////////////////////////////////////////////////// + +comphelper::PropertySetInfo* SvxPropertySetInfoPool::getOrCreate( sal_Int32 nServiceId ) throw() +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + + if( nServiceId > SVXUNO_SERVICEID_LASTID ) + { + DBG_ERROR( "unknown service id!" ); + return NULL; + } + + if( mpInfos[ nServiceId ] == NULL ) + { + mpInfos[nServiceId] = new comphelper::PropertySetInfo(); + mpInfos[nServiceId]->acquire(); + + switch( nServiceId ) + { + case SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS: + mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS]->add( ImplGetSvxDrawingDefaultsPropertyMap() ); + break; + case SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER: + mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetSvxDrawingDefaultsPropertyMap() ); + mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->remove( OUString( RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION ) ) ); + // OD 13.10.2003 #i18732# - add property map for writer item 'IsFollowingTextFlow' + mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetAdditionalWriterDrawingDefaultsPropertyMap() ); + break; + + default: + DBG_ERROR( "unknown service id!" ); + } + } + + return mpInfos[ nServiceId ]; +} + +comphelper::PropertySetInfo* SvxPropertySetInfoPool::mpInfos[SVXUNO_SERVICEID_LASTID+1] = { NULL }; + diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx new file mode 100644 index 000000000000..1f2d4fd3145b --- /dev/null +++ b/svx/source/unodraw/unoshap2.cxx @@ -0,0 +1,2148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#define _SVX_USE_UNOGLOBALS_ +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> +#include <com/sun/star/awt/TextAlign.hpp> //added by BerryJia for fixing Bug102407 2002-11-4 +#include <com/sun/star/style/ParagraphAdjust.hpp> //added by BerryJia for fixing Bug102407 2002-11-4 +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#include <com/sun/star/drawing/PointSequence.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <tools/urlobj.hxx> +#include <unotools/localfilehelper.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <svtools/fltcall.hxx> +#include <svtools/filter.hxx> + +#include <boost/scoped_ptr.hpp> +#include <svx/svdpool.hxx> +#include <rtl/uuid.h> +#include <rtl/memory.h> +#include <tools/urlobj.hxx> + +#include <editeng/unoprnms.hxx> +#include <svx/unoshape.hxx> +#include <svx/unopage.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdouno.hxx> +#include "shapeimpl.hxx" +#include "svx/unoshprp.hxx" +#include <svx/svdoashp.hxx> +#include "unopolyhelper.hxx" + +// #i29181# +#include "svdviter.hxx" +#include <svx/svdview.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> + +using ::rtl::OUString; +using namespace ::osl; +using namespace ::vos; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; + +#define INTERFACE_TYPE( xint ) \ + ::getCppuType((const Reference< xint >*)0) + +#define QUERYINT( xint ) \ + if( rType == ::getCppuType((const Reference< xint >*)0) ) \ + aAny <<= Reference< xint >(this) + +class GDIMetaFile; +class SvStream; +sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, + FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True ); + +/*********************************************************************** +* class SvxShapeGroup * +***********************************************************************/ + +SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw() : + SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_GROUP), aSvxMapProvider.GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ), + mxPage( pDrawPage ) +{ +} + +//---------------------------------------------------------------------- +SvxShapeGroup::~SvxShapeGroup() throw() +{ +} + +//---------------------------------------------------------------------- +void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) +{ + SvxShape::Create( pNewObj, pNewPage ); + mxPage = pNewPage; +} + +//---------------------------------------------------------------------- +uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + return SvxShape::queryInterface( rType ); +} + +uno::Any SAL_CALL SvxShapeGroup::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT( drawing::XShapeGroup ); + else QUERYINT( drawing::XShapes ); + else QUERYINT( container::XIndexAccess ); + else QUERYINT( container::XElementAccess ); + else + return SvxShape::queryAggregation( rType ); + + return aAny; +} + +void SAL_CALL SvxShapeGroup::acquire() throw ( ) +{ + SvxShape::acquire(); +} + +void SAL_CALL SvxShapeGroup::release() throw ( ) +{ + SvxShape::release(); +} + +uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes() + throw (uno::RuntimeException) +{ + return SvxShape::getTypes(); +} + +uno::Sequence< sal_Int8 > SAL_CALL SvxShapeGroup::getImplementationId() + throw (uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// ::com::sun::star::drawing::XShape + +//---------------------------------------------------------------------- +OUString SAL_CALL SvxShapeGroup::getShapeType() + throw( uno::RuntimeException ) +{ + return SvxShape::getShapeType(); +} + +//------------------------------------------------------------------1---- +awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException) +{ + return SvxShape::getPosition(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException) +{ + SvxShape::setPosition(Position); +} + +//---------------------------------------------------------------------- + +awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException) +{ + return SvxShape::getSize(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeGroup::setSize( const awt::Size& rSize ) + throw(beans::PropertyVetoException, uno::RuntimeException) +{ + SvxShape::setSize( rSize ); +} + +// drawing::XShapeGroup + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeGroup::enterGroup( ) throw(uno::RuntimeException) +{ + // Todo +// pDrView->EnterMarkedGroup(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeGroup::leaveGroup( ) throw(uno::RuntimeException) +{ + // Todo +// pDrView->LeaveOneGroup(); +} + +//---------------------------------------------------------------------- + +// XShapes +void SAL_CALL SvxShapeGroup::add( const uno::Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + + if( mpObj.is()&& mxPage.is() && pShape ) + { + SdrObject* pSdrShape = pShape->GetSdrObject(); + if( pSdrShape == NULL ) + pSdrShape = mxPage->_CreateSdrObject( xShape ); + + if( pSdrShape->IsInserted() ) + pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() ); + + mpObj->GetSubList()->InsertObject( pSdrShape ); + pSdrShape->SetModel(mpObj->GetModel()); + + // #85922# It makes no sense to set the layer asked + // from the group object since these is an iteration + // over the contained objects. In consequence, this + // statement erases all layer information from the draw + // objects. Layers need to be set at draw objects directly + // and have nothing to do with grouping at all. + // pSdrShape->SetLayer(pObject->GetLayer()); + + // Establish connection between new SdrObject and its wrapper before + // inserting the new shape into the group. There a new wrapper + // would be created when this connection would not already exist. + if(pShape) + pShape->Create( pSdrShape, mxPage.get() ); + + if( mpModel ) + mpModel->SetChanged(); + } + else + { + DBG_ERROR("could not add XShape to group shape!"); + } +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdrObject* pSdrShape = NULL; + SvxShape* pShape = SvxShape::getImplementation( xShape ); + + if( pShape ) + pSdrShape = pShape->GetSdrObject(); + + if( !mpObj.is() || pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() ) + throw uno::RuntimeException(); + + SdrObjList& rList = *pSdrShape->GetObjList(); + + const sal_uInt32 nObjCount = rList.GetObjCount(); + sal_uInt32 nObjNum = 0; + while( nObjNum < nObjCount ) + { + if(rList.GetObj( nObjNum ) == pSdrShape ) + break; + nObjNum++; + } + + if( nObjNum < nObjCount ) + { + // #i29181# + // If the SdrObject which is about to be deleted is in any selection, + // deselect it first. + SdrViewIter aIter( pSdrShape ); + + for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() ) + { + if(CONTAINER_ENTRY_NOTFOUND != pView->TryToFindMarkedObject(pSdrShape)) + { + pView->MarkObj(pSdrShape, pView->GetSdrPageView(), sal_True, sal_False); + } + } + + SdrObject* pObject = rList.NbcRemoveObject( nObjNum ); + SdrObject::Free( pObject ); + } + else + { + DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" ); + } + + if( mpModel ) + mpModel->SetChanged(); +} + +// XIndexAccess + +//---------------------------------------------------------------------- +sal_Int32 SAL_CALL SvxShapeGroup::getCount() throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_Int32 nRetval = 0; + + if(mpObj.is() && mpObj->GetSubList()) + nRetval = mpObj->GetSubList()->GetObjCount(); + else + throw uno::RuntimeException(); + + return nRetval; +} + +//---------------------------------------------------------------------- +uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index ) + throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( !mpObj.is() || mpObj->GetSubList() == NULL ) + throw uno::RuntimeException(); + + if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index ) + throw lang::IndexOutOfBoundsException(); + + SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index ); + + if(pDestObj == NULL) + throw lang::IndexOutOfBoundsException(); + + Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY ); + return uno::makeAny( xShape ); +} + +// ::com::sun::star::container::XElementAccess + +//---------------------------------------------------------------------- +uno::Type SAL_CALL SvxShapeGroup::getElementType() throw( uno::RuntimeException ) +{ + return ::getCppuType(( const Reference< drawing::XShape >*)0); +} + +//---------------------------------------------------------------------- +sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0); +} + +//---------------------------------------------------------------------- +// ::com::sun::star::lang::XServiceInfo + +uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + return SvxShape::getSupportedServiceNames(); +} + +/*********************************************************************** +* * +***********************************************************************/ + +SvxShapeConnector::SvxShapeConnector( SdrObject* pObj ) throw() : + SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONNECTOR), aSvxMapProvider.GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +SvxShapeConnector::~SvxShapeConnector() throw() +{ +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + return SvxShapeText::queryInterface( rType ); +} + +uno::Any SAL_CALL SvxShapeConnector::queryAggregation( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT( drawing::XConnectorShape ); + else + return SvxShapeText::queryAggregation( rType ); + + return aAny; +} + +void SAL_CALL SvxShapeConnector::acquire() throw ( ) +{ + SvxShapeText::acquire(); +} + +void SAL_CALL SvxShapeConnector::release() throw ( ) +{ + SvxShapeText::release(); +} +// XTypeProvider + +uno::Sequence< uno::Type > SAL_CALL SvxShapeConnector::getTypes() + throw (uno::RuntimeException) +{ + return SvxShape::getTypes(); +} + +uno::Sequence< sal_Int8 > SAL_CALL SvxShapeConnector::getImplementationId() + throw (uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// ::com::sun::star::drawing::XShape + +//---------------------------------------------------------------------- +OUString SAL_CALL SvxShapeConnector::getShapeType() + throw( uno::RuntimeException ) +{ + return SvxShapeText::getShapeType(); +} + +//------------------------------------------------------------------1---- +awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException) +{ + return SvxShapeText::getPosition(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException) +{ + SvxShapeText::setPosition(Position); +} + +//---------------------------------------------------------------------- + +awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException) +{ + return SvxShapeText::getSize(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeConnector::setSize( const awt::Size& rSize ) + throw(beans::PropertyVetoException, uno::RuntimeException) +{ + SvxShapeText::setSize( rSize ); +} + +//---------------------------------------------------------------------- + +// XConnectorShape + +void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType ) throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + Reference< drawing::XShape > xRef( xShape, UNO_QUERY ); + SvxShape* pShape = SvxShape::getImplementation( xRef ); + + if( pShape ) + mpObj->ConnectToNode( sal_True, pShape->mpObj.get() ); + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + Reference< drawing::XShape > xRef( xShape, UNO_QUERY ); + SvxShape* pShape = SvxShape::getImplementation( xRef ); + + if( mpObj.is() && pShape ) + mpObj->ConnectToNode( sal_False, pShape->mpObj.get() ); + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing::XConnectableShape >& ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpObj.is()) + mpObj->DisconnectFromNode( sal_True ); + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::XConnectableShape >& ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpObj.is()) + mpObj->DisconnectFromNode( sal_False ); + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +// ::com::sun::star::lang::XServiceInfo +//---------------------------------------------------------------------- +uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShapeText::getSupportedServiceNames(); +} + +/*********************************************************************** +* class SvxShapeControl * +***********************************************************************/ +DBG_NAME(SvxShapeControl) + +SvxShapeControl::SvxShapeControl( SdrObject* pObj ) throw() : + SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONTROL), aSvxMapProvider.GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ + DBG_CTOR(SvxShapeControl,NULL); + setShapeKind( OBJ_UNO ); +} + +//---------------------------------------------------------------------- +SvxShapeControl::~SvxShapeControl() throw() +{ + DBG_DTOR(SvxShapeControl,NULL); +} + +//---------------------------------------------------------------------- +uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + return SvxShapeText::queryInterface( rType ); +} + +uno::Any SAL_CALL SvxShapeControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT( drawing::XControlShape ); + else + return SvxShapeText::queryAggregation( rType ); + + return aAny; +} + +void SAL_CALL SvxShapeControl::acquire() throw ( ) +{ + SvxShapeText::acquire(); +} + +void SAL_CALL SvxShapeControl::release() throw ( ) +{ + SvxShapeText::release(); +} +// XTypeProvider + +uno::Sequence< uno::Type > SAL_CALL SvxShapeControl::getTypes() + throw (uno::RuntimeException) +{ + return SvxShape::getTypes(); +} + +uno::Sequence< sal_Int8 > SAL_CALL SvxShapeControl::getImplementationId() + throw (uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// ::com::sun::star::drawing::XShape + +//---------------------------------------------------------------------- +OUString SAL_CALL SvxShapeControl::getShapeType() + throw( uno::RuntimeException ) +{ + return SvxShapeText::getShapeType(); +} + +//------------------------------------------------------------------1---- +awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException) +{ + return SvxShapeText::getPosition(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException) +{ + SvxShapeText::setPosition(Position); +} + +//---------------------------------------------------------------------- + +awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException) +{ + return SvxShapeText::getSize(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeControl::setSize( const awt::Size& rSize ) + throw(beans::PropertyVetoException, uno::RuntimeException) +{ + SvxShapeText::setSize( rSize ); +} + +//---------------------------------------------------------------------- +// XControlShape + +Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl() + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + Reference< awt::XControlModel > xModel; + + SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get()); + if( pUnoObj ) + xModel = pUnoObj->GetUnoControlModel(); + + return xModel; +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >& xControl ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get()); + if( pUnoObj ) + pUnoObj->SetUnoControlModel( xControl ); + + if( mpModel ) + mpModel->SetChanged(); +} + +// XServiceInfo +uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShapeText::getSupportedServiceNames(); +} + +static struct +{ + const sal_Char* mpAPIName; + sal_uInt16 mnAPINameLen; + + const sal_Char* mpFormName; + sal_uInt16 mnFormNameLen; +} +SvxShapeControlPropertyMapping[] = +{ + // Warning: The first entry must be FontSlant because the any needs to be converted + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), MAP_CHAR_LEN("FontSlant") }, // const sal_Int16 => ::com::sun::star::awt::FontSlant + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), MAP_CHAR_LEN("FontName") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), MAP_CHAR_LEN("FontStyleName") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), MAP_CHAR_LEN("FontFamily") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), MAP_CHAR_LEN("FontCharset") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), MAP_CHAR_LEN("FontHeight") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), MAP_CHAR_LEN("FontPitch" ) }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), MAP_CHAR_LEN("FontWeight" ) }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), MAP_CHAR_LEN("FontUnderline") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), MAP_CHAR_LEN("FontStrikeout") }, + { MAP_CHAR_LEN("CharKerning"), MAP_CHAR_LEN("FontKerning") }, + { MAP_CHAR_LEN("CharWordMode"), MAP_CHAR_LEN("FontWordLineMode" ) }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR), MAP_CHAR_LEN("TextColor") }, + { MAP_CHAR_LEN("CharRelief"), MAP_CHAR_LEN("FontRelief") }, + { MAP_CHAR_LEN("CharUnderlineColor"), MAP_CHAR_LEN("TextLineColor") }, + { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), MAP_CHAR_LEN("Align") }, + { MAP_CHAR_LEN("TextVerticalAdjust"), MAP_CHAR_LEN("VerticalAlign") }, + { MAP_CHAR_LEN("ControlBackground"), MAP_CHAR_LEN("BackgroundColor") }, + { MAP_CHAR_LEN("ControlSymbolColor"), MAP_CHAR_LEN("SymbolColor") }, + { MAP_CHAR_LEN("ControlBorder"), MAP_CHAR_LEN("Border") }, + { MAP_CHAR_LEN("ControlBorderColor"), MAP_CHAR_LEN("BorderColor") }, + { MAP_CHAR_LEN("ControlTextEmphasis"), MAP_CHAR_LEN("FontEmphasisMark") }, + { MAP_CHAR_LEN("ImageScaleMode"), MAP_CHAR_LEN("ScaleMode") }, + { MAP_CHAR_LEN("ControlWritingMode"), MAP_CHAR_LEN("WritingMode") }, + { NULL,0, NULL, 0 } +}; + +namespace +{ + static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName ) + { + sal_uInt16 i = 0; + while( SvxShapeControlPropertyMapping[i].mpAPIName ) + { + if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 ) + { + rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US ); + } + ++i; + } + return rInternalName.getLength() > 0; + } + + struct EnumConversionMap + { + sal_Int16 nAPIValue; + sal_Int16 nFormValue; + }; + + EnumConversionMap aMapAdjustToAlign[] = + { + // note that order matters: + // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_ + // and use the first matching entry + {style::ParagraphAdjust_LEFT, (sal_Int16)awt::TextAlign::LEFT}, + {style::ParagraphAdjust_CENTER, (sal_Int16)awt::TextAlign::CENTER}, + {style::ParagraphAdjust_RIGHT, (sal_Int16)awt::TextAlign::RIGHT}, + {style::ParagraphAdjust_BLOCK, (sal_Int16)awt::TextAlign::RIGHT}, + {style::ParagraphAdjust_STRETCH, (sal_Int16)awt::TextAlign::LEFT}, + {-1,-1} + }; + + static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap ) + { + sal_Int16 nValue = sal_Int16(); + OSL_VERIFY( _rValue >>= nValue ); + + const EnumConversionMap* pEntry = _pMap; + while ( pEntry && ( pEntry->nFormValue != -1 ) ) + { + if ( nValue == pEntry->nFormValue ) + { + _rValue <<= pEntry->nAPIValue; + return; + } + ++pEntry; + } + } + + static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap ) + { + sal_Int32 nValue = 0; + OSL_VERIFY( _rValue >>= nValue ); + + const EnumConversionMap* pEntry = _pMap; + while ( pEntry && ( pEntry->nAPIValue != -1 ) ) + { + if ( nValue == pEntry->nAPIValue ) + { + _rValue <<= pEntry->nFormValue; + return; + } + ++pEntry; + } + } + + static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue ) + { + lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign ); + } + + static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue ) + { + lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign ); + } + + void convertVerticalAdjustToVerticalAlign( Any& _rValue ) SAL_THROW( ( lang::IllegalArgumentException ) ) + { + if ( !_rValue.hasValue() ) + return; + + drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP; + style::VerticalAlignment eAlign = style::VerticalAlignment_TOP; + if ( !( _rValue >>= eAdjust ) ) + throw lang::IllegalArgumentException(); + switch ( eAdjust ) + { + case drawing::TextVerticalAdjust_TOP: eAlign = style::VerticalAlignment_TOP; break; + case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break; + default: eAlign = style::VerticalAlignment_MIDDLE; break; + } + _rValue <<= eAlign; + } + + void convertVerticalAlignToVerticalAdjust( Any& _rValue ) + { + if ( !_rValue.hasValue() ) + return; + style::VerticalAlignment eAlign = style::VerticalAlignment_TOP; + drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP; + OSL_VERIFY( _rValue >>= eAlign ); + switch ( eAlign ) + { + case style::VerticalAlignment_TOP: eAdjust = drawing::TextVerticalAdjust_TOP; break; + case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break; + default: eAdjust = drawing::TextVerticalAdjust_CENTER; break; + } + _rValue <<= eAdjust; + } +} + +void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) + throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException) +{ + OUString aFormsName; + if ( lcl_convertPropertyName( aPropertyName, aFormsName ) ) + { + uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY ); + if( xControl.is() ) + { + uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() ); + if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) ) + { + uno::Any aConvertedValue( aValue ); + if ( aFormsName.equalsAscii( "FontSlant" ) ) + { + awt::FontSlant nSlant; + if( !(aValue >>= nSlant ) ) + throw lang::IllegalArgumentException(); + aConvertedValue <<= (sal_Int16)nSlant; + } + else if ( aFormsName.equalsAscii( "Align" ) ) + { + lcl_convertParaAdjustmentToTextAlignment( aConvertedValue ); + } + else if ( aFormsName.equalsAscii( "VerticalAlign" ) ) + { + convertVerticalAdjustToVerticalAlign( aConvertedValue ); + } + + xControl->setPropertyValue( aFormsName, aConvertedValue ); + } + } + } + else + { + SvxShape::setPropertyValue( aPropertyName, aValue ); + } +} + +uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName ) + throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OUString aFormsName; + if ( lcl_convertPropertyName( aPropertyName, aFormsName ) ) + { + uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY ); + + uno::Any aValue; + if( xControl.is() ) + { + uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() ); + if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) ) + { + aValue = xControl->getPropertyValue( aFormsName ); + if ( aFormsName.equalsAscii( "FontSlant" ) ) + { + awt::FontSlant eSlant = awt::FontSlant_NONE; + sal_Int16 nSlant = sal_Int16(); + if ( aValue >>= nSlant ) + { + eSlant = (awt::FontSlant)nSlant; + } + else + { + OSL_VERIFY( aValue >>= eSlant ); + } + aValue <<= eSlant; + } + else if ( aFormsName.equalsAscii( "Align" ) ) + { + lcl_convertTextAlignmentToParaAdjustment( aValue ); + } + else if ( aFormsName.equalsAscii( "VerticalAlign" ) ) + { + convertVerticalAlignToVerticalAdjust( aValue ); + } + } + } + + return aValue; + } + else + { + return SvxShape::getPropertyValue( aPropertyName ); + } + +} + +// XPropertyState +beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException ) +{ + OUString aFormsName; + if ( lcl_convertPropertyName( PropertyName, aFormsName ) ) + { + uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY ); + + if( xControl.is() && xPropSet.is() ) + { + uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() ); + if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) ) + { + return xControl->getPropertyState( aFormsName ); + } + } + + return beans::PropertyState_DEFAULT_VALUE; + } + else + { + return SvxShape::getPropertyState( PropertyName ); + } +} + +void SAL_CALL SvxShapeControl::setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException ) +{ + OUString aFormsName; + if ( lcl_convertPropertyName( PropertyName, aFormsName ) ) + { + uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY ); + + if( xControl.is() && xPropSet.is() ) + { + uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() ); + if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) ) + { + xControl->setPropertyToDefault( aFormsName ); + } + } + } + else + { + SvxShape::setPropertyToDefault( PropertyName ); + } +} + +uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const ::rtl::OUString& aPropertyName ) + throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +{ + OUString aFormsName; + if ( lcl_convertPropertyName( aPropertyName, aFormsName ) ) + { + uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY ); + + if( xControl.is() ) + { + Any aDefault( xControl->getPropertyDefault( aFormsName ) ); + if ( aFormsName.equalsAscii( "FontSlant" ) ) + { + sal_Int16 nSlant( 0 ); + aDefault >>= nSlant; + aDefault <<= (awt::FontSlant)nSlant; + } + else if ( aFormsName.equalsAscii( "Align" ) ) + { + lcl_convertTextAlignmentToParaAdjustment( aDefault ); + } + else if ( aFormsName.equalsAscii( "VerticalAlign" ) ) + { + convertVerticalAlignToVerticalAdjust( aDefault ); + } + return aDefault; + } + + throw beans::UnknownPropertyException(); + } + else + { + return SvxShape::getPropertyDefault( aPropertyName ); + } +} + + +/*********************************************************************** +* class SvxShapeDimensioning * +***********************************************************************/ + +//---------------------------------------------------------------------- +SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw() +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_DIMENSIONING), aSvxMapProvider.GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +SvxShapeDimensioning::~SvxShapeDimensioning() throw() +{ +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShapeText::getSupportedServiceNames(); +} + +/*********************************************************************** +* * +***********************************************************************/ + +//---------------------------------------------------------------------- +SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw() +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CIRCLE), aSvxMapProvider.GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +SvxShapeCircle::~SvxShapeCircle() throw() +{ +} + +// ::com::sun::star::lang::XServiceInfo +// XServiceInfo +uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShapeText::getSupportedServiceNames(); +} + +/*********************************************************************** +* * +***********************************************************************/ + +#include <svx/svdopath.hxx> + +//---------------------------------------------------------------------- +SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew ) + throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException) +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGON), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) ) +, mePolygonKind( eNew ) +{ +} + +//---------------------------------------------------------------------- +SvxShapePolyPolygon::~SvxShapePolyPolygon() throw() +{ +} + +basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw() +{ + basegfx::B2DPolyPolygon aRetval; + + // Zeiger auf innere sequences holen + const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray(); + const drawing::PointSequence* pInnerSeqEnd = pInnerSequence + pOuterSequence->getLength(); + + for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence) + { + // Neues Polygon vorbereiten + basegfx::B2DPolygon aNewPolygon; + + // Zeiger auf Arrays holen + const awt::Point* pArray = pInnerSequence->getConstArray(); + const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength(); + + for(;pArray != pArrayEnd;++pArray) + { + aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y)); + } + + // check for closed state flag + basegfx::tools::checkClosed(aNewPolygon); + + // Neues Teilpolygon einfuegen + aRetval.append(aNewPolygon); + } + + return aRetval; +} + +//---------------------------------------------------------------------- + +bool SvxShapePolyPolygon::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_VALUE_POLYPOLYGON: + { + if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ) ) + { + basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( (drawing::PointSequenceSequence*)rValue.getValue())); + SetPolygon(aNewPolyPolygon); + return true; + } + break; + } + case OWN_ATTR_BASE_GEOMETRY: + { + if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0))) + { + if( mpObj.is() ) + { + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon((drawing::PointSequenceSequence*)rValue.getValue()); + mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + } + return true; + } + break; + } + case OWN_ATTR_VALUE_POLYGON: + { + if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) )) + { + drawing::PointSequence* pSequence = (drawing::PointSequence*)rValue.getValue(); + + // Neues Polygon vorbereiten + basegfx::B2DPolygon aNewPolygon; + + // Zeiger auf Arrays holen + // Zeiger auf Arrays holen + const awt::Point* pArray = pSequence->getConstArray(); + const awt::Point* pArrayEnd = pArray + pSequence->getLength(); + + for(;pArray != pArrayEnd;++pArray) + { + aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y)); + } + + // check for closed state flag + basegfx::tools::checkClosed(aNewPolygon); + + // Polygon setzen + SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon)); + return true; + } + break; + } + default: + return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw lang::IllegalArgumentException(); +} + +void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval ) +{ + if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() ) + rRetval.realloc( rPolyPoly.count() ); + + // Zeiger auf aeussere Arrays holen + drawing::PointSequence* pOuterSequence = rRetval.getArray(); + + for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++) + { + // Einzelpolygon holen + const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(a)); + + // #i75974# take closed stae into account, the API polygon still uses the old closed definition + // with last/first point are identical (cannot hold information about open polygons with identical + // first and last point, though) + const sal_uInt32 nPointCount(aPoly.count()); + const bool bIsClosed(aPoly.isClosed()); + + // Platz in Arrays schaffen + pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount); + + // Pointer auf arrays holen + awt::Point* pInnerSequence = pOuterSequence->getArray(); + + for(sal_uInt32 b(0L); b < nPointCount; b++) + { + const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b)); + *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) ); + pInnerSequence++; + } + + // #i75974# copy first point + if(bIsClosed) + { + *pInnerSequence = *pOuterSequence->getArray(); + } + + pOuterSequence++; + } +} + +//---------------------------------------------------------------------- + +bool SvxShapePolyPolygon::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_VALUE_POLYPOLYGON: + { + // PolyPolygon in eine struct PolyPolygon packen + const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon(); + drawing::PointSequenceSequence aRetval( rPolyPoly.count() ); + + B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval ); + + rValue <<= aRetval; + break; + } + case OWN_ATTR_BASE_GEOMETRY: + { + // pack a PolyPolygon in struct PolyPolygon + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + + if(mpObj.is()) + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + + drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count()); + B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval); + rValue <<= aRetval; + break; + } + case OWN_ATTR_VALUE_POLYGON: + { + // PolyPolygon in eine struct PolyPolygon packen + const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon(); + + sal_Int32 nCount = 0; + if( rPolyPoly.count() > 0 ) + nCount = rPolyPoly.getB2DPolygon(0L).count(); + + drawing::PointSequence aRetval( nCount ); + + if( nCount > 0 ) + { + // Einzelpolygon holen + const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L)); + + // Pointer auf arrays holen + awt::Point* pSequence = aRetval.getArray(); + + for(sal_Int32 b=0;b<nCount;b++) + { + const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b)); + *pSequence++ = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) ); + } + } + + rValue <<= aRetval; + break; + } + case OWN_ATTR_VALUE_POLYGONKIND: + { + rValue <<= GetPolygonKind(); + break; + } + default: + return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +//---------------------------------------------------------------------- +drawing::PolygonKind SvxShapePolyPolygon::GetPolygonKind() const throw() +{ + return mePolygonKind; +} + +//---------------------------------------------------------------------- +void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw() +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpObj.is()) + ((SdrPathObj*)mpObj.get())->SetPathPoly(rNew); +} + +//---------------------------------------------------------------------- +basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw() +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpObj.is()) + { + return ((SdrPathObj*)mpObj.get())->GetPathPoly(); + } + else + { + return basegfx::B2DPolyPolygon(); + } +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShapeText::getSupportedServiceNames(); +} + +/*********************************************************************** +* class SvxShapePolyPolygonBezier * +***********************************************************************/ +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include <com/sun/star/drawing/FlagSequence.hpp> +//---------------------------------------------------------------------- +SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw() +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGONBEZIER), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) ) +, mePolygonKind( eNew ) +{ +} + +//---------------------------------------------------------------------- +SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw() +{ +} + +basegfx::B2DPolyPolygon SvxConvertPolyPolygonBezierToB2DPolyPolygon(const drawing::PolyPolygonBezierCoords* pSourcePolyPolygon) + throw( IllegalArgumentException ) +{ + const sal_Int32 nOuterSequenceCount(pSourcePolyPolygon->Coordinates.getLength()); + basegfx::B2DPolyPolygon aNewPolyPolygon; + + if(pSourcePolyPolygon->Flags.getLength() != nOuterSequenceCount) + { + throw IllegalArgumentException(); + } + + // get pointers to inner sequence + const drawing::PointSequence* pInnerSequence = pSourcePolyPolygon->Coordinates.getConstArray(); + const drawing::FlagSequence* pInnerSequenceFlags = pSourcePolyPolygon->Flags.getConstArray(); + + for(sal_Int32 a(0); a < nOuterSequenceCount; a++) + { + const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength()); + + if(pInnerSequenceFlags->getLength() != nInnerSequenceCount) + { + throw IllegalArgumentException(); + } + + // prepare new polygon + basegfx::B2DPolygon aNewPolygon; + const awt::Point* pArray = pInnerSequence->getConstArray(); + const drawing::PolygonFlags* pArrayFlags = pInnerSequenceFlags->getConstArray(); + + // get first point and flag + basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y); pArray++; + XPolyFlags ePolyFlag((XPolyFlags)((sal_uInt16)*pArrayFlags)); pArrayFlags++; + basegfx::B2DPoint aControlA; + basegfx::B2DPoint aControlB; + + // first point is not allowed to be a control point + if(XPOLY_CONTROL == ePolyFlag) + { + throw IllegalArgumentException(); + } + + // add first point as start point + aNewPolygon.append(aNewCoordinatePair); + + for(sal_Int32 b(1); b < nInnerSequenceCount;) + { + // prepare loop + bool bControlA(false); + bool bControlB(false); + + // get next point and flag + aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y); + ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags)); + pArray++; pArrayFlags++; b++; + + if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag) + { + aControlA = aNewCoordinatePair; + bControlA = true; + + // get next point and flag + aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y); + ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags)); + pArray++; pArrayFlags++; b++; + } + + if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag) + { + aControlB = aNewCoordinatePair; + bControlB = true; + + // get next point and flag + aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y); + ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags)); + pArray++; pArrayFlags++; b++; + } + + // two or no control points are consumed, another one would be an error. + // It's also an error if only one control point was read + if(XPOLY_CONTROL == ePolyFlag || bControlA != bControlB) + { + throw IllegalArgumentException(); + } + + // the previous writes used the B2DPolyPoygon -> PolyPolygon converter + // which did not create minimal PolyPolygons, but created all control points + // as null vectors (identical points). Because of the former P(CA)(CB)-norm of + // B2DPolygon and it's unused sign of being the zero-vector and CA and CB being + // relative to P, an empty edge was exported as P == CA == CB. Luckily, the new + // export format can be read without errors by the old OOo-versions, so we need only + // to correct here at read and do not need to export a wrong but compatible version + // for the future. + if(bControlA + && aControlA.equal(aControlB) + && aControlA.equal(aNewPolygon.getB2DPoint(aNewPolygon.count() - 1))) + { + bControlA = bControlB = false; + } + + if(bControlA) + { + // add bezier edge + aNewPolygon.appendBezierSegment(aControlA, aControlB, aNewCoordinatePair); + } + else + { + // add edge + aNewPolygon.append(aNewCoordinatePair); + } + } + + // next sequence + pInnerSequence++; + pInnerSequenceFlags++; + + // #i72807# API import uses old line start/end-equal definition for closed, + // so we need to correct this to closed state here + basegfx::tools::checkClosed(aNewPolygon); + + // add new subpolygon + aNewPolyPolygon.append(aNewPolygon); + } + + return aNewPolyPolygon; +} + +//---------------------------------------------------------------------- + +bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_VALUE_POLYPOLYGONBEZIER: + { + if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0) ) ) + { + basegfx::B2DPolyPolygon aNewPolyPolygon(SvxConvertPolyPolygonBezierToB2DPolyPolygon( (drawing::PolyPolygonBezierCoords*)rValue.getValue())); + SetPolygon(aNewPolyPolygon); + return true; + } + break; + } + case OWN_ATTR_BASE_GEOMETRY: + { + if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0)) ) + { + if( mpObj.is() ) + { + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + aNewPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon((drawing::PolyPolygonBezierCoords*)rValue.getValue()); + mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + } + return true; + } + break; + } + default: + return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +void SvxConvertB2DPolyPolygonToPolyPolygonBezier( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PolyPolygonBezierCoords& rRetval ) +{ + // use PolyPolygon converter as base. Since PolyPolygonBezierCoords uses + // integer coordinates, this is no precision loss at all. + const PolyPolygon aPolyPoly(rPolyPoly); + + // Polygone innerhalb vrobereiten + rRetval.Coordinates.realloc((sal_Int32)aPolyPoly.Count()); + rRetval.Flags.realloc((sal_Int32)aPolyPoly.Count()); + + // Zeiger auf aeussere Arrays holen + drawing::PointSequence* pOuterSequence = rRetval.Coordinates.getArray(); + drawing::FlagSequence* pOuterFlags = rRetval.Flags.getArray(); + + for(sal_uInt16 a=0;a<aPolyPoly.Count();a++) + { + // Einzelpolygon holen + const Polygon& rPoly = aPolyPoly[a]; + + // Platz in Arrays schaffen + pOuterSequence->realloc((sal_Int32)rPoly.GetSize()); + pOuterFlags->realloc((sal_Int32)rPoly.GetSize()); + + // Pointer auf arrays holen + awt::Point* pInnerSequence = pOuterSequence->getArray(); + drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray(); + + for(sal_uInt16 b=0;b<rPoly.GetSize();b++) + { + *pInnerSequence++ = awt::Point( rPoly[b].X(), rPoly[b].Y() ); + *pInnerFlags++ = (drawing::PolygonFlags)((sal_uInt16)rPoly.GetFlags(b)); + } + + pOuterSequence++; + pOuterFlags++; + } +} + +//---------------------------------------------------------------------- + +bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_VALUE_POLYPOLYGONBEZIER: + { + // PolyPolygon in eine struct PolyPolygon packen + const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon(); + drawing::PolyPolygonBezierCoords aRetval; + SvxConvertB2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval ); + + rValue <<= aRetval; + break; + } + case OWN_ATTR_BASE_GEOMETRY: + { + // PolyPolygon in eine struct PolyPolygon packen + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + drawing::PolyPolygonBezierCoords aRetval; + SvxConvertB2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval); + + rValue <<= aRetval; + break; + } + case OWN_ATTR_VALUE_POLYGONKIND: + { + rValue <<= mePolygonKind; + break; + } + default: + return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue ); + } + return true; +} + +//---------------------------------------------------------------------- +drawing::PolygonKind SvxShapePolyPolygonBezier::GetPolygonKind() const throw() +{ + return mePolygonKind; +} + +//---------------------------------------------------------------------- +void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw() +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpObj.is()) + static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew); +} + +//---------------------------------------------------------------------- +basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw() +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpObj.is()) + { + return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly(); + } + else + { + return basegfx::B2DPolyPolygon(); + } +} + + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShapeText::getSupportedServiceNames(); +} + +/*********************************************************************** +* class SvxGraphicObject * +***********************************************************************/ +#include <com/sun/star/awt/XBitmap.hpp> +#include <vcl/cvtgrf.hxx> +#include <svx/svdograf.hxx> +#ifndef SVX_LIGHT +#ifndef _SFXDOCFILE_HXX +#include <sfx2/docfile.hxx> +#endif +#include <sfx2/app.hxx> +#include <sfx2/fcontnr.hxx> +#endif + +#include "toolkit/unohlp.hxx" + +//---------------------------------------------------------------------- +SvxGraphicObject::SvxGraphicObject( SdrObject* pObj ) throw() +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_GRAPHICOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +SvxGraphicObject::~SvxGraphicObject() throw() +{ +} + +//---------------------------------------------------------------------- + +bool SvxGraphicObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + bool bOk = false; + switch( pProperty->nWID ) + { + case OWN_ATTR_VALUE_FILLBITMAP: + { + if( rValue.getValue() ) + { + if( rValue.getValueType() == ::getCppuType(( const uno::Sequence< sal_Int8 >*)0) ) + { + uno::Sequence<sal_Int8>* pSeq( (uno::Sequence<sal_Int8>*)rValue.getValue() ); + SvMemoryStream aMemStm; + Graphic aGraphic; + + aMemStm.SetBuffer( (char*)pSeq->getConstArray(), pSeq->getLength(), sal_False, pSeq->getLength() ); + + if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE ) + { + static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic); + bOk = true; + } + } + } + else if( (rValue.getValueType() == awt::XBitmap::static_type()) || (rValue.getValueType() == graphic::XGraphic::static_type())) + { + Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY ); + if( xGraphic.is() ) + { + ((SdrGrafObj*)mpObj.get())->SetGraphic(Graphic(xGraphic)); + bOk = true; + } + else + { + // Bitmap in das Objekt packen + Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY ); + if( xBmp.is() ) + { + // Bitmap einsetzen + Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp )); + ((SdrGrafObj*)mpObj.get())->SetGraphic(aGraphic); + bOk = true; + } + } + } + break; + } + case OWN_ATTR_GRAFURL: + { + OUString aURL; + if( rValue >>= aURL ) + { + if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) + { + // graphic manager url + aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ); + String aTmpStr(aURL); + ByteString aUniqueID( aTmpStr, RTL_TEXTENCODING_UTF8 ); + GraphicObject aGrafObj( aUniqueID ); + + // #101808# since loading a graphic can cause a reschedule of the office + // it is possible that our shape is removed while where in this + // method. + if( mpObj.is() ) + { + static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink(); + static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj ); + } + } + else if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 ) + { + // normal link + String aFilterName; + const SfxFilter* pSfxFilter = NULL; + SfxMedium aSfxMedium( aURL, STREAM_READ | STREAM_SHARE_DENYNONE, FALSE ); + + SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE ); + + if( !pSfxFilter ) + { + INetURLObject aURLObj( aURL ); + + if( aURLObj.GetProtocol() == INET_PROT_NOT_VALID ) + { + String aValidURL; + + if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) ) + aURLObj = INetURLObject( aValidURL ); + } + + if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID ) + { + GraphicFilter* pGrfFilter = GraphicFilter::GetGraphicFilter(); + aFilterName = pGrfFilter->GetImportFormatName( pGrfFilter->GetImportFormatNumberForShortName( aURLObj.getExtension() ) ); + } + } + else + aFilterName = pSfxFilter->GetFilterName(); + + // #101808# since loading a graphic can cause a reschedule of the office + // it is possible that our shape is removed while where in this + // method. + if( mpObj.is() ) + static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, aFilterName ); + + } + bOk = true; + } + break; + } + + case OWN_ATTR_GRAFSTREAMURL: + { + OUString aStreamURL; + + if( rValue >>= aStreamURL ) + { + if( aStreamURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 ) + aStreamURL = OUString(); + + if( mpObj.is() ) + { + static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL ); + static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut(); + } + bOk = true; + } + break; + } + + case OWN_ATTR_VALUE_GRAPHIC: + { + Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY ); + if( xGraphic.is() ) + { + static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic ); + bOk = true; + } + break; + } + default: + return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue ); + } + + if( !bOk ) + throw lang::IllegalArgumentException(); + + if( mpModel ) + mpModel->SetChanged(); + + return true; +} + +//---------------------------------------------------------------------- + +bool SvxGraphicObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_VALUE_FILLBITMAP: + { + const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic(); + + if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE) + { + // Objekt in eine Bitmap packen + Reference< ::com::sun::star::awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) ); + rValue <<= xBitmap; + } + else + { + SvMemoryStream aDestStrm( 65535, 65535 ); + + ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False ); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); + rValue <<= aSeq; + } + break; + } + + case OWN_ATTR_GRAFURL: + { + if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() ) + { + rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() ); + } + else + { + const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true); + OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); + aURL += OUString::createFromAscii( rGrafObj.GetUniqueID().GetBuffer() ); + rValue <<= aURL; + } + break; + } + + case OWN_ATTR_GRAFSTREAMURL: + { + const OUString aStreamURL( ( (SdrGrafObj*) mpObj.get() )->GetGrafStreamURL() ); + if( aStreamURL.getLength() ) + rValue <<= aStreamURL; + break; + } + + case OWN_ATTR_VALUE_GRAPHIC: + { + Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() ); + rValue <<= xGraphic; + break; + } + + case OWN_ATTR_GRAPHIC_STREAM: + { + rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream(); + break; + } + default: + return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue); + } + + return true; +} + +/////////////////////////////////////////////////////////////////////// + +SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw() +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CAPTION), aSvxMapProvider.GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +SvxShapeCaption::~SvxShapeCaption() throw() +{ +} + +/*********************************************************************** +* class SvxCustomShape * +***********************************************************************/ + +SvxCustomShape::SvxCustomShape( SdrObject* pObj ) throw() : + SvxShapeText( pObj, aSvxMapProvider.GetMap( SVXMAP_CUSTOMSHAPE ), aSvxMapProvider.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +SvxCustomShape::~SvxCustomShape() throw() +{ +} + +//---------------------------------------------------------------------- + +void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) +{ + SvxShapeText::Create( pNewObj, pNewPage ); +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + return SvxShapeText::queryInterface( rType ); +} + +uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType ); + if ( !aReturn.hasValue() ) + aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) ); + return aReturn; +} + +void SAL_CALL SvxCustomShape::acquire() throw ( ) +{ + SvxShapeText::acquire(); +} + +void SAL_CALL SvxCustomShape::release() throw ( ) +{ + SvxShapeText::release(); +} + +//---------------------------------------------------------------------- + +uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes() + throw (uno::RuntimeException) +{ + return SvxShapeText::getTypes(); +} + +uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId() + throw (uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// ::com::sun::star::drawing::XShape + +//---------------------------------------------------------------------- +OUString SAL_CALL SvxCustomShape::getShapeType() + throw( uno::RuntimeException ) +{ + return SvxShape::getShapeType(); +} + +//------------------------------------------------------------------1---- +awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + if ( mpModel && mpObj.is() ) + { + SdrAShapeObjGeoData aCustomShapeGeoData; + ((SdrObjCustomShape*)mpObj.get())->SaveGeoData( aCustomShapeGeoData ); + + sal_Bool bMirroredX = sal_False; + sal_Bool bMirroredY = sal_False; + + if ( mpObj.is() ) + { + bMirroredX = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredX() ); + bMirroredY = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredY() ); + } + // get aRect, this is the unrotated snaprect + Rectangle aRect(((SdrObjCustomShape*)mpObj.get())->GetLogicRect()); + Rectangle aRectangle( aRect ); + + if ( bMirroredX || bMirroredY ) + { // we have to retrieve the unmirrored rect + + GeoStat aNewGeo( aCustomShapeGeoData.aGeo ); + if ( bMirroredX ) + { + Polygon aPol( Rect2Poly( aRect, aNewGeo ) ); + Rectangle aBoundRect( aPol.GetBoundRect() ); + + Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() ); + Point aRef2( aRef1.X(), aRef1.Y() + 1000 ); + USHORT i; + USHORT nPntAnz=aPol.GetSize(); + for (i=0; i<nPntAnz; i++) + { + MirrorPoint(aPol[i],aRef1,aRef2); + } + // Polygon wenden und etwas schieben + Polygon aPol0(aPol); + aPol[0]=aPol0[1]; + aPol[1]=aPol0[0]; + aPol[2]=aPol0[3]; + aPol[3]=aPol0[2]; + aPol[4]=aPol0[1]; + Poly2Rect(aPol,aRectangle,aNewGeo); + } + if ( bMirroredY ) + { + Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) ); + Rectangle aBoundRect( aPol.GetBoundRect() ); + + Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 ); + Point aRef2( aRef1.X() + 1000, aRef1.Y() ); + USHORT i; + USHORT nPntAnz=aPol.GetSize(); + for (i=0; i<nPntAnz; i++) + { + MirrorPoint(aPol[i],aRef1,aRef2); + } + // Polygon wenden und etwas schieben + Polygon aPol0(aPol); + aPol[0]=aPol0[1]; + aPol[1]=aPol0[0]; + aPol[2]=aPol0[3]; + aPol[3]=aPol0[2]; + aPol[4]=aPol0[1]; + Poly2Rect( aPol, aRectangle, aNewGeo ); + } + } + Point aPt( aRectangle.TopLeft() ); + + if( mpModel->IsWriter() ) + aPt -= mpObj->GetAnchorPos(); + + ForceMetricTo100th_mm(aPt); + return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() ); + } + else + return SvxShape::getPosition(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException) +{ + SvxShapeText::setPosition(Position); +} + +//---------------------------------------------------------------------- + +awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException) +{ + return SvxShapeText::getSize(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize ) + throw(beans::PropertyVetoException, uno::RuntimeException) +{ + SvxShapeText::setSize( rSize ); +} + +//---------------------------------------------------------------------- + +//---------------------------------------------------------------------- +void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) + throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + SdrObject* pObject = mpObj.get(); + + sal_Bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) ); + + sal_Bool bMirroredX = sal_False; + sal_Bool bMirroredY = sal_False; + + if ( bCustomShapeGeometry ) + { + bMirroredX = ( ((SdrObjCustomShape*)pObject)->IsMirroredX() ); + bMirroredY = ( ((SdrObjCustomShape*)pObject)->IsMirroredY() ); + } + + SvxShape::setPropertyValue( aPropertyName, aValue ); + + if ( bCustomShapeGeometry ) + { + ((SdrObjCustomShape*)pObject)->MergeDefaultAttributes(0); + Rectangle aRect( pObject->GetSnapRect() ); + + // #i38892# + bool bNeedsMirrorX = ((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX; + bool bNeedsMirrorY = ((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY; + + boost::scoped_ptr< SdrGluePointList > pListCopy; + if( bNeedsMirrorX || bNeedsMirrorY ) + { + const SdrGluePointList* pList = pObject->GetGluePointList(); + if( pList ) + pListCopy.reset( new SdrGluePointList(*pList) ); + } + + if ( bNeedsMirrorX ) + { + Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() ); + Point aBottom( aTop.X(), aTop.Y() + 1000 ); + pObject->NbcMirror( aTop, aBottom ); + // NbcMirroring is flipping the current mirror state, + // so we have to set the correct state again + ((SdrObjCustomShape*)pObject)->SetMirroredX( bMirroredX ? sal_False : sal_True ); + } + if ( bNeedsMirrorY ) + { + Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 ); + Point aRight( aLeft.X() + 1000, aLeft.Y() ); + pObject->NbcMirror( aLeft, aRight ); + // NbcMirroring is flipping the current mirror state, + // so we have to set the correct state again + ((SdrObjCustomShape*)pObject)->SetMirroredY( bMirroredY ? sal_False : sal_True ); + } + + if( pListCopy ) + { + SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() ); + if(pNewList) + *pNewList = *pListCopy; + } + } +} + +bool SvxCustomShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case SDRATTR_ROTATEANGLE: + { + double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation(); + fAngle *= 100; + rValue <<= (sal_Int32)fAngle; + return true; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } +} +//---------------------------------------------------------------------- + +void SvxCustomShape::createCustomShapeDefaults( const rtl::OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException) +{ + ((SdrObjCustomShape*)mpObj.get())->MergeDefaultAttributes( &rValueType ); +} diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx new file mode 100644 index 000000000000..92d1706d4e6a --- /dev/null +++ b/svx/source/unodraw/unoshap3.cxx @@ -0,0 +1,1210 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#define _SVX_USE_UNOGLOBALS_ +#include <com/sun/star/drawing/HomogenMatrix.hpp> +#include <com/sun/star/drawing/Position3D.hpp> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <com/sun/star/drawing/DoubleSequence.hpp> +#include <com/sun/star/drawing/CameraGeometry.hpp> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <comphelper/serviceinfohelper.hxx> + +#include <rtl/uuid.h> +#include <rtl/memory.h> +#include <svx/svdpool.hxx> +#include <svx/unoshape.hxx> +#include <svx/unopage.hxx> +#include <editeng/unoprnms.hxx> +#include <svx/polysc3d.hxx> +#include "globl3d.hxx" +#include <svx/cube3d.hxx> +#include <svx/sphere3d.hxx> +#include <svx/lathe3d.hxx> +#include <svx/extrud3d.hxx> +#include <svx/polygn3d.hxx> +#include "svx/unoshprp.hxx" +#include "svx/svdmodel.hxx" +#include <basegfx/polygon/b3dpolygon.hxx> +#include <basegfx/polygon/b3dpolygontools.hxx> +#include <com/sun/star/drawing/PolyPolygonShape3D.hpp> +#include <basegfx/polygon/b2dpolypolygontools.hxx> + +using ::rtl::OUString; +using namespace ::vos; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; + +#define INTERFACE_TYPE( xint ) \ + ::getCppuType((const Reference< xint >*)0) + +#define QUERYINT( xint ) \ + if( rType == ::getCppuType((const Reference< xint >*)0) ) \ + aAny <<= Reference< xint >(this) + +/*********************************************************************** +* class Svx3DSceneObject * +***********************************************************************/ + +//---------------------------------------------------------------------- +Svx3DSceneObject::Svx3DSceneObject( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DSCENEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DSCENEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) +, mxPage( pDrawPage ) +{ +} + +//---------------------------------------------------------------------- +Svx3DSceneObject::~Svx3DSceneObject() throw() +{ +} + +//---------------------------------------------------------------------- +void Svx3DSceneObject::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) +{ + SvxShape::Create( pNewObj, pNewPage ); + mxPage = pNewPage; +} + +//---------------------------------------------------------------------- +uno::Any SAL_CALL Svx3DSceneObject::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT( drawing::XShapes ); + else QUERYINT( container::XIndexAccess ); + else QUERYINT( container::XElementAccess ); + else + return SvxShape::queryAggregation( rType ); + + return aAny; +} + +uno::Any SAL_CALL Svx3DSceneObject::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException ) +{ + return SvxShape::queryInterface( rType ); +} + +void SAL_CALL Svx3DSceneObject::acquire() throw ( ) +{ + SvxShape::acquire(); +} + +void SAL_CALL Svx3DSceneObject::release() throw ( ) +{ + SvxShape::release(); +} + +// XTypeProvider + +uno::Sequence< uno::Type > SAL_CALL Svx3DSceneObject::getTypes() + throw (uno::RuntimeException) +{ + + return SvxShape::getTypes(); +} + +uno::Sequence< sal_Int8 > SAL_CALL Svx3DSceneObject::getImplementationId() + throw (uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +//---------------------------------------------------------------------- +void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + + if(!mpObj.is() || !mxPage.is() || pShape == NULL || NULL != pShape->GetSdrObject() ) + throw uno::RuntimeException(); + + SdrObject* pSdrShape = mxPage->_CreateSdrObject( xShape ); + if( pSdrShape->ISA(E3dObject) ) + { + mpObj->GetSubList()->NbcInsertObject( pSdrShape ); + + if(pShape) + pShape->Create( pSdrShape, mxPage.get() ); + } + else + { + SdrObject::Free( pSdrShape ); + throw uno::RuntimeException(); + } + + if( mpModel ) + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- +void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + + if(!mpObj.is() || pShape == NULL) + throw uno::RuntimeException(); + + SdrObject* pSdrShape = pShape->GetSdrObject(); + if(pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get()) + { + throw uno::RuntimeException(); + } + else + { + SdrObjList& rList = *pSdrShape->GetObjList(); + + const sal_uInt32 nObjCount = rList.GetObjCount(); + sal_uInt32 nObjNum = 0; + while( nObjNum < nObjCount ) + { + if(rList.GetObj( nObjNum ) == pSdrShape ) + break; + nObjNum++; + } + + if( nObjNum < nObjCount ) + { + SdrObject* pObject = rList.NbcRemoveObject( nObjNum ); + SdrObject::Free( pObject ); + } + else + { + DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" ); + } + } +} + +//---------------------------------------------------------------------- +sal_Int32 SAL_CALL Svx3DSceneObject::getCount() + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_Int32 nRetval = 0; + + if(mpObj.is() && mpObj->ISA(E3dPolyScene) && mpObj->GetSubList()) + nRetval = mpObj->GetSubList()->GetObjCount(); + return nRetval; +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL Svx3DSceneObject::getByIndex( sal_Int32 Index ) + throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( !mpObj.is() || mpObj->GetSubList() == NULL ) + throw uno::RuntimeException(); + + if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index ) + throw lang::IndexOutOfBoundsException(); + + SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index ); + if(pDestObj == NULL) + throw lang::IndexOutOfBoundsException(); + + Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY ); + uno::Any aAny; + aAny <<= xShape; + return aAny; +} + +//---------------------------------------------------------------------- +// ::com::sun::star::container::XElementAccess + +uno::Type SAL_CALL Svx3DSceneObject::getElementType() + throw( uno::RuntimeException ) +{ + return ::getCppuType(( const Reference< drawing::XShape>*)0); +} + +//---------------------------------------------------------------------- +sal_Bool SAL_CALL Svx3DSceneObject::hasElements() + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0); +} + +//---------------------------------------------------------------------- + +static bool ConvertHomogenMatrixToObject( E3dObject* pObject, const Any& rValue ) +{ + drawing::HomogenMatrix m; + if( rValue >>= m ) + { + basegfx::B3DHomMatrix aMat; + aMat.set(0, 0, m.Line1.Column1); + aMat.set(0, 1, m.Line1.Column2); + aMat.set(0, 2, m.Line1.Column3); + aMat.set(0, 3, m.Line1.Column4); + aMat.set(1, 0, m.Line2.Column1); + aMat.set(1, 1, m.Line2.Column2); + aMat.set(1, 2, m.Line2.Column3); + aMat.set(1, 3, m.Line2.Column4); + aMat.set(2, 0, m.Line3.Column1); + aMat.set(2, 1, m.Line3.Column2); + aMat.set(2, 2, m.Line3.Column3); + aMat.set(2, 3, m.Line3.Column4); + aMat.set(3, 0, m.Line4.Column1); + aMat.set(3, 1, m.Line4.Column2); + aMat.set(3, 2, m.Line4.Column3); + aMat.set(3, 3, m.Line4.Column4); + pObject->SetTransform(aMat); + return true; + } + return false; +} + +static void ConvertObjectToHomogenMatric( E3dObject* pObject, Any& rValue ) +{ + drawing::HomogenMatrix aHomMat; + const basegfx::B3DHomMatrix& rMat = pObject->GetTransform(); + aHomMat.Line1.Column1 = rMat.get(0, 0); + aHomMat.Line1.Column2 = rMat.get(0, 1); + aHomMat.Line1.Column3 = rMat.get(0, 2); + aHomMat.Line1.Column4 = rMat.get(0, 3); + aHomMat.Line2.Column1 = rMat.get(1, 0); + aHomMat.Line2.Column2 = rMat.get(1, 1); + aHomMat.Line2.Column3 = rMat.get(1, 2); + aHomMat.Line2.Column4 = rMat.get(1, 3); + aHomMat.Line3.Column1 = rMat.get(2, 0); + aHomMat.Line3.Column2 = rMat.get(2, 1); + aHomMat.Line3.Column3 = rMat.get(2, 2); + aHomMat.Line3.Column4 = rMat.get(2, 3); + aHomMat.Line4.Column1 = rMat.get(3, 0); + aHomMat.Line4.Column2 = rMat.get(3, 1); + aHomMat.Line4.Column3 = rMat.get(3, 2); + aHomMat.Line4.Column4 = rMat.get(3, 3); + rValue <<= aHomMat; +} + +//---------------------------------------------------------------------- +#include <svditer.hxx> + +struct ImpRememberTransAndRect +{ + basegfx::B3DHomMatrix maMat; + Rectangle maRect; +}; + +bool Svx3DSceneObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformationsmatrix in das Objekt packen + if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) + return true; + break; + } + case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY: + { + // set CameraGeometry at scene + E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() ); + drawing::CameraGeometry aCamGeo; + + if(rValue >>= aCamGeo) + { + basegfx::B3DPoint aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ); + basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ); + basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ); + + // rescue scene transformation + ImpRememberTransAndRect aSceneTAR; + aSceneTAR.maMat = pScene->GetTransform(); + aSceneTAR.maRect = pScene->GetSnapRect(); + + // rescue object transformations + SdrObjListIter aIter(*pScene->GetSubList(), IM_DEEPWITHGROUPS); + List aObjTrans; + while(aIter.IsMore()) + { + E3dObject* p3DObj = (E3dObject*)aIter.Next(); + basegfx::B3DHomMatrix* pNew = new basegfx::B3DHomMatrix; + *pNew = p3DObj->GetTransform(); + aObjTrans.Insert(pNew, LIST_APPEND); + } + + // reset object transformations + aIter.Reset(); + while(aIter.IsMore()) + { + E3dObject* p3DObj = (E3dObject*)aIter.Next(); + p3DObj->NbcSetTransform(basegfx::B3DHomMatrix()); + } + + // reset scene transformation and make a complete recalc + pScene->NbcSetTransform(basegfx::B3DHomMatrix()); + + // fill old camera from new parameters + Camera3D aCam(pScene->GetCamera()); + const basegfx::B3DRange& rVolume = pScene->GetBoundVolume(); + double fW = rVolume.getWidth(); + double fH = rVolume.getHeight(); + + const SfxItemSet& rSceneSet = pScene->GetMergedItemSet(); + double fCamPosZ = + (double)((const SfxUInt32Item&)rSceneSet.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue(); + double fCamFocal = + (double)((const SfxUInt32Item&)rSceneSet.Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue(); + + aCam.SetAutoAdjustProjection(FALSE); + aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH); + basegfx::B3DPoint aLookAt; + basegfx::B3DPoint aCamPos(0.0, 0.0, fCamPosZ); + aCam.SetPosAndLookAt(aCamPos, aLookAt); + aCam.SetFocalLength(fCamFocal / 100.0); + aCam.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fCamPosZ), aLookAt, fCamFocal / 100.0); + aCam.SetDeviceWindow(Rectangle(0, 0, (long)fW, (long)fH)); + + // set at scene + pScene->SetCamera(aCam); + + // #91047# use imported VRP, VPN and VUP (if used) + sal_Bool bVRPUsed(!aVRP.equal(basegfx::B3DPoint(0.0, 0.0, 1.0))); + sal_Bool bVPNUsed(!aVPN.equal(basegfx::B3DVector(0.0, 0.0, 1.0))); + sal_Bool bVUPUsed(!aVUP.equal(basegfx::B3DVector(0.0, 1.0, 0.0))); + + if(bVRPUsed || bVPNUsed || bVUPUsed) + { + pScene->GetCameraSet().SetViewportValues(aVRP, aVPN, aVUP); + } + + // set object transformations again at objects + aIter.Reset(); + sal_uInt32 nIndex(0L); + while(aIter.IsMore()) + { + E3dObject* p3DObj = (E3dObject*)aIter.Next(); + basegfx::B3DHomMatrix* pMat = (basegfx::B3DHomMatrix*)aObjTrans.GetObject(nIndex++); + p3DObj->NbcSetTransform(*pMat); + delete pMat; + } + + // set scene transformation again at scene + pScene->NbcSetTransform(aSceneTAR.maMat); + pScene->NbcSetSnapRect(aSceneTAR.maRect); + + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl(rName, pProperty, rValue); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- + +bool Svx3DSceneObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Objekt in eine homogene 4x4 Matrix packen + ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); + break; + } + case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY: + { + // get CameraGeometry from scene + E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() ); + drawing::CameraGeometry aCamGeo; + + // fill Vectors from scene camera + B3dCamera& aCameraSet = pScene->GetCameraSet(); + basegfx::B3DPoint aVRP(aCameraSet.GetVRP()); + basegfx::B3DVector aVPN(aCameraSet.GetVPN()); + basegfx::B3DVector aVUP(aCameraSet.GetVUV()); + + // transfer to structure + aCamGeo.vrp.PositionX = aVRP.getX(); + aCamGeo.vrp.PositionY = aVRP.getY(); + aCamGeo.vrp.PositionZ = aVRP.getZ(); + aCamGeo.vpn.DirectionX = aVPN.getX(); + aCamGeo.vpn.DirectionY = aVPN.getY(); + aCamGeo.vpn.DirectionZ = aVPN.getZ(); + aCamGeo.vup.DirectionX = aVUP.getX(); + aCamGeo.vup.DirectionY = aVUP.getY(); + aCamGeo.vup.DirectionZ = aVUP.getZ(); + + rValue <<= aCamGeo; + break; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL Svx3DSceneObject::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); + comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.Shape3DScene" ); + return aSeq; +} + +/*********************************************************************** +* * +***********************************************************************/ + +//---------------------------------------------------------------------- +Svx3DCubeObject::Svx3DCubeObject( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DCUBEOBJEKT), aSvxMapProvider.GetPropertySet(SVXMAP_3DCUBEOBJEKT, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +Svx3DCubeObject::~Svx3DCubeObject() throw() +{ +} + +//---------------------------------------------------------------------- +bool Svx3DCubeObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformationsmatrix in das Objekt packen + if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) + return true; + break; + } + case OWN_ATTR_3D_VALUE_POSITION: + { + // Position in das Objekt packen + drawing::Position3D aUnoPos; + if( rValue >>= aUnoPos ) + { + basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ); + static_cast< E3dCubeObj* >( mpObj.get() )->SetCubePos(aPos); + return true; + } + break; + } + case OWN_ATTR_3D_VALUE_SIZE: + { + // Groesse in das Objekt packen + drawing::Direction3D aDirection; + if( rValue >>= aDirection ) + { + basegfx::B3DVector aSize(aDirection.DirectionX, aDirection.DirectionY, aDirection.DirectionZ); + static_cast< E3dCubeObj* >( mpObj.get() )->SetCubeSize(aSize); + return true; + } + break; + } + case OWN_ATTR_3D_VALUE_POS_IS_CENTER: + { + sal_Bool bNew = sal_False; + // sal_Bool bPosIsCenter in das Objekt packen + if( rValue >>= bNew ) + { + static_cast< E3dCubeObj* >( mpObj.get() )->SetPosIsCenter(bNew); + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- + +bool Svx3DCubeObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformation in eine homogene Matrix packen + ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); + break; + } + case OWN_ATTR_3D_VALUE_POSITION: + { + // Position packen + const basegfx::B3DPoint& rPos = ((E3dCubeObj*)mpObj.get())->GetCubePos(); + drawing::Position3D aPos; + + aPos.PositionX = rPos.getX(); + aPos.PositionY = rPos.getY(); + aPos.PositionZ = rPos.getZ(); + + rValue <<= aPos; + break; + } + case OWN_ATTR_3D_VALUE_SIZE: + { + // Groesse packen + const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(mpObj.get())->GetCubeSize(); + drawing::Direction3D aDir; + + aDir.DirectionX = rSize.getX(); + aDir.DirectionY = rSize.getY(); + aDir.DirectionZ = rSize.getZ(); + + rValue <<= aDir; + break; + } + case OWN_ATTR_3D_VALUE_POS_IS_CENTER: + { + rValue <<= static_cast<E3dCubeObj*>(mpObj.get())->GetPosIsCenter(); + break; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL Svx3DCubeObject::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); + comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", + "com.sun.star.drawing.Shape3DCube"); + return aSeq; +} + +/*********************************************************************** +* * +***********************************************************************/ + +//---------------------------------------------------------------------- +Svx3DSphereObject::Svx3DSphereObject( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DSPHEREOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DSPHEREOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +Svx3DSphereObject::~Svx3DSphereObject() throw() +{ +} + +//---------------------------------------------------------------------- + +bool Svx3DSphereObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformationsmatrix in das Objekt packen + if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) + return true; + break; + } + + case OWN_ATTR_3D_VALUE_POSITION: + { + // Position in das Objekt packen + drawing::Position3D aUnoPos; + if( rValue >>= aUnoPos ) + { + basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ); + static_cast<E3dSphereObj*>(mpObj.get())->SetCenter(aPos); + return true; + } + break; + } + + case OWN_ATTR_3D_VALUE_SIZE: + { + // Groesse in das Objekt packen + drawing::Direction3D aDir; + if( rValue >>= aDir ) + { + basegfx::B3DVector aPos(aDir.DirectionX, aDir.DirectionY, aDir.DirectionZ); + static_cast<E3dSphereObj*>(mpObj.get())->SetSize(aPos); + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- + +bool Svx3DSphereObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformation in eine homogene Matrix packen + ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); + break; + } + case OWN_ATTR_3D_VALUE_POSITION: + { + // Position packen + const basegfx::B3DPoint& rPos = ((E3dSphereObj*)mpObj.get())->Center(); + drawing::Position3D aPos; + + aPos.PositionX = rPos.getX(); + aPos.PositionY = rPos.getY(); + aPos.PositionZ = rPos.getZ(); + + rValue <<= aPos; + break; + } + case OWN_ATTR_3D_VALUE_SIZE: + { + // Groesse packen + const basegfx::B3DVector& rSize = ((E3dSphereObj*)mpObj.get())->Size(); + drawing::Direction3D aDir; + + aDir.DirectionX = rSize.getX(); + aDir.DirectionY = rSize.getY(); + aDir.DirectionZ = rSize.getZ(); + + rValue <<= aDir; + break; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL Svx3DSphereObject::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); + comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", + "com.sun.star.drawing.Shape3DSphere"); + return aSeq; +} + +/*********************************************************************** +* * +***********************************************************************/ + +//---------------------------------------------------------------------- +Svx3DLatheObject::Svx3DLatheObject( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DLATHEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DLATHEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +Svx3DLatheObject::~Svx3DLatheObject() throw() +{ +} + +bool PolyPolygonShape3D_to_B3dPolyPolygon( + const Any& rValue, + basegfx::B3DPolyPolygon& rResultPolygon, + bool bCorrectPolygon) +{ + drawing::PolyPolygonShape3D aSourcePolyPolygon; + if( !(rValue >>= aSourcePolyPolygon) ) + return false; + + sal_Int32 nOuterSequenceCount = aSourcePolyPolygon.SequenceX.getLength(); + if(nOuterSequenceCount != aSourcePolyPolygon.SequenceY.getLength() || nOuterSequenceCount != aSourcePolyPolygon.SequenceZ.getLength()) + return false; + + drawing::DoubleSequence* pInnerSequenceX = aSourcePolyPolygon.SequenceX.getArray(); + drawing::DoubleSequence* pInnerSequenceY = aSourcePolyPolygon.SequenceY.getArray(); + drawing::DoubleSequence* pInnerSequenceZ = aSourcePolyPolygon.SequenceZ.getArray(); + for(sal_Int32 a(0L);a<nOuterSequenceCount;a++) + { + sal_Int32 nInnerSequenceCount = pInnerSequenceX->getLength(); + if(nInnerSequenceCount != pInnerSequenceY->getLength() || nInnerSequenceCount != pInnerSequenceZ->getLength()) + { + return false; + } + basegfx::B3DPolygon aNewPolygon; + double* pArrayX = pInnerSequenceX->getArray(); + double* pArrayY = pInnerSequenceY->getArray(); + double* pArrayZ = pInnerSequenceZ->getArray(); + for(sal_Int32 b(0L);b<nInnerSequenceCount;b++) + { + aNewPolygon.append(basegfx::B3DPoint(*pArrayX++,*pArrayY++,*pArrayZ++)); + } + pInnerSequenceX++; + pInnerSequenceY++; + pInnerSequenceZ++; + + // #i101520# correction is needed for imported polygons of old format, + // see callers + if(bCorrectPolygon) + { + basegfx::tools::checkClosed(aNewPolygon); + } + + rResultPolygon.append(aNewPolygon); + } + return true; +} + +static void B3dPolyPolygon_to_PolyPolygonShape3D( const basegfx::B3DPolyPolygon& rSourcePolyPolygon, Any& rValue ) +{ + drawing::PolyPolygonShape3D aRetval; + aRetval.SequenceX.realloc(rSourcePolyPolygon.count()); + aRetval.SequenceY.realloc(rSourcePolyPolygon.count()); + aRetval.SequenceZ.realloc(rSourcePolyPolygon.count()); + drawing::DoubleSequence* pOuterSequenceX = aRetval.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aRetval.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aRetval.SequenceZ.getArray(); + for(sal_uInt32 a(0L);a<rSourcePolyPolygon.count();a++) + { + const basegfx::B3DPolygon aPoly(rSourcePolyPolygon.getB3DPolygon(a)); + sal_Int32 nPointCount(aPoly.count()); + if(aPoly.isClosed()) nPointCount++; + pOuterSequenceX->realloc(nPointCount); + pOuterSequenceY->realloc(nPointCount); + pOuterSequenceZ->realloc(nPointCount); + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + for(sal_uInt32 b(0L);b<aPoly.count();b++) + { + const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(b)); + *pInnerSequenceX++ = aPoint.getX(); + *pInnerSequenceY++ = aPoint.getY(); + *pInnerSequenceZ++ = aPoint.getZ(); + } + if(aPoly.isClosed()) + { + const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(0L)); + *pInnerSequenceX++ = aPoint.getX(); + *pInnerSequenceY++ = aPoint.getY(); + *pInnerSequenceZ++ = aPoint.getZ(); + } + pOuterSequenceX++; + pOuterSequenceY++; + pOuterSequenceZ++; + } + rValue <<= aRetval; +} + +//---------------------------------------------------------------------- + +bool Svx3DLatheObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformationsmatrix in das Objekt packen + if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) + return true; + break; + } + case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: + { + // Polygondefinition in das Objekt packen + basegfx::B3DPolyPolygon aNewB3DPolyPolygon; + + // #i101520# Probably imported + if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) ) + { + // #105127# SetPolyPoly3D sets the Svx3DVerticalSegmentsItem to the number + // of points of the polygon. Thus, value gets lost. To avoid this, rescue + // item here and re-set after setting the polygon. + const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments()); + + // Polygon setzen + const basegfx::B3DHomMatrix aIdentity; + const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); + static_cast<E3dLatheObj*>(mpObj.get())->SetPolyPoly2D(aB2DPolyPolygon); + const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments()); + + if(nPrevVerticalSegs != nPostVerticalSegs) + { + // restore the vertical segment count + static_cast<E3dLatheObj*>(mpObj.get())->SetMergedItem(Svx3DVerticalSegmentsItem(nPrevVerticalSegs)); + } + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- +bool Svx3DLatheObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformation in eine homogene Matrix packen + drawing::HomogenMatrix aHomMat; + basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform(); + + // pack evtl. transformed matrix to output + aHomMat.Line1.Column1 = aMat.get(0, 0); + aHomMat.Line1.Column2 = aMat.get(0, 1); + aHomMat.Line1.Column3 = aMat.get(0, 2); + aHomMat.Line1.Column4 = aMat.get(0, 3); + aHomMat.Line2.Column1 = aMat.get(1, 0); + aHomMat.Line2.Column2 = aMat.get(1, 1); + aHomMat.Line2.Column3 = aMat.get(1, 2); + aHomMat.Line2.Column4 = aMat.get(1, 3); + aHomMat.Line3.Column1 = aMat.get(2, 0); + aHomMat.Line3.Column2 = aMat.get(2, 1); + aHomMat.Line3.Column3 = aMat.get(2, 2); + aHomMat.Line3.Column4 = aMat.get(2, 3); + aHomMat.Line4.Column1 = aMat.get(3, 0); + aHomMat.Line4.Column2 = aMat.get(3, 1); + aHomMat.Line4.Column3 = aMat.get(3, 2); + aHomMat.Line4.Column4 = aMat.get(3, 3); + + rValue <<= aHomMat; + break; + } + case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: + { + const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(mpObj.get())->GetPolyPoly2D(); + const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); + + B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue); + break; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL Svx3DLatheObject::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); + comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", + "com.sun.star.drawing.Shape3DLathe"); + return aSeq; +} + +/*********************************************************************** +* * +***********************************************************************/ + +Svx3DExtrudeObject::Svx3DExtrudeObject( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DEXTRUDEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DEXTRUDEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +Svx3DExtrudeObject::~Svx3DExtrudeObject() throw() +{ +} + +//---------------------------------------------------------------------- + +bool Svx3DExtrudeObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformationsmatrix in das Objekt packen + if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) + return true; + break; + } + + case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: + { + // Polygondefinition in das Objekt packen + basegfx::B3DPolyPolygon aNewB3DPolyPolygon; + + // #i101520# Probably imported + if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) ) + { + // Polygon setzen + const basegfx::B3DHomMatrix aIdentity; + const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); + static_cast<E3dExtrudeObj*>(mpObj.get())->SetExtrudePolygon(aB2DPolyPolygon); + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- + +bool Svx3DExtrudeObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformation in eine homogene Matrix packen + drawing::HomogenMatrix aHomMat; + basegfx::B3DHomMatrix aMat = ((E3dObject*)mpObj.get())->GetTransform(); + + // pack evtl. transformed matrix to output + aHomMat.Line1.Column1 = aMat.get(0, 0); + aHomMat.Line1.Column2 = aMat.get(0, 1); + aHomMat.Line1.Column3 = aMat.get(0, 2); + aHomMat.Line1.Column4 = aMat.get(0, 3); + aHomMat.Line2.Column1 = aMat.get(1, 0); + aHomMat.Line2.Column2 = aMat.get(1, 1); + aHomMat.Line2.Column3 = aMat.get(1, 2); + aHomMat.Line2.Column4 = aMat.get(1, 3); + aHomMat.Line3.Column1 = aMat.get(2, 0); + aHomMat.Line3.Column2 = aMat.get(2, 1); + aHomMat.Line3.Column3 = aMat.get(2, 2); + aHomMat.Line3.Column4 = aMat.get(2, 3); + aHomMat.Line4.Column1 = aMat.get(3, 0); + aHomMat.Line4.Column2 = aMat.get(3, 1); + aHomMat.Line4.Column3 = aMat.get(3, 2); + aHomMat.Line4.Column4 = aMat.get(3, 3); + + rValue <<= aHomMat; + break; + } + + case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: + { + // Polygondefinition packen + const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(mpObj.get())->GetExtrudePolygon(); + const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); + + B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue); + break; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL Svx3DExtrudeObject::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); + comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", + "com.sun.star.drawing.Shape3DExtrude"); + return aSeq; +} + +/*********************************************************************** +* * +***********************************************************************/ + +//---------------------------------------------------------------------- +Svx3DPolygonObject::Svx3DPolygonObject( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DPOLYGONOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DPOLYGONOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +//---------------------------------------------------------------------- +Svx3DPolygonObject::~Svx3DPolygonObject() throw() +{ +} + +//---------------------------------------------------------------------- +bool Svx3DPolygonObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + // Transformationsmatrix in das Objekt packen + if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) ) + return true; + break; + } + + case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: + { + // Polygondefinition in das Objekt packen + basegfx::B3DPolyPolygon aNewB3DPolyPolygon; + + // #i101520# Direct API data (e.g. from chart) + if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) + { + // Polygon setzen + static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyPolygon3D(aNewB3DPolyPolygon); + return true; + } + break; + } + case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D: + { + // Normalendefinition in das Objekt packen + basegfx::B3DPolyPolygon aNewB3DPolyPolygon; + + // #i101520# Direct API data (e.g. from chart) + if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) + { + // Polygon setzen + static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyNormals3D(aNewB3DPolyPolygon); + return true; + } + break; + } + case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D: + { + // Texturdefinition in das Objekt packen + basegfx::B3DPolyPolygon aNewB3DPolyPolygon; + + // #i101520# Direct API data (e.g. from chart) + if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) + { + // Polygon setzen + const basegfx::B3DHomMatrix aIdentity; + const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); + static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyTexture2D(aB2DPolyPolygon); + return true; + } + break; + } + case OWN_ATTR_3D_VALUE_LINEONLY: + { + sal_Bool bNew = sal_False; + if( rValue >>= bNew ) + { + static_cast<E3dPolygonObj*>(mpObj.get())->SetLineOnly(bNew); + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- +bool Svx3DPolygonObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: + { + ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue ); + break; + } + + case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: + { + B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyPolygon3D(),rValue); + break; + } + + case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D: + { + B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyNormals3D(),rValue); + break; + } + + case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D: + { + // Texturdefinition packen + const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyTexture2D(); + const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); + + B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon,rValue); + break; + } + + case OWN_ATTR_3D_VALUE_LINEONLY: + { + rValue <<= (sal_Bool)static_cast<E3dPolygonObj*>(mpObj.get())->GetLineOnly(); + break; + } + + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +// ::com::sun::star::lang::XServiceInfo +uno::Sequence< OUString > SAL_CALL Svx3DPolygonObject::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() ); + comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D", + "com.sun.star.drawing.Shape3DPolygon"); + return aSeq; +} + +// eof diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx new file mode 100644 index 000000000000..cf3bdc6621f0 --- /dev/null +++ b/svx/source/unodraw/unoshap4.cxx @@ -0,0 +1,992 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/embed/XLinkageSupport.hpp> +#include <com/sun/star/embed/NoVisualAreaSizeException.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> + +#define _SVX_USE_UNOGLOBALS_ + +#include <vcl/virdev.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdomedia.hxx> +#include <svx/svdpool.hxx> +#ifndef SVX_LIGHT +#ifndef _SOT_CLSIDS_HXX +#include <sot/clsids.hxx> +#endif +#include <sfx2/frmdescr.hxx> +#endif +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> + +#include <toolkit/helper/vclunohelper.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/docfile.hxx> + +#include <sot/storage.hxx> +#include <sot/exchange.hxx> +#include <svtools/FilterConfigItem.hxx> + +#include <svx/svdmodel.hxx> +#include "shapeimpl.hxx" + +#include <svx/unoshprp.hxx> + +#include "unoapi.hxx" +#include "svx/svdpagv.hxx" +#include "svx/svdview.hxx" +#include "svdglob.hxx" +#include "svdstr.hrc" + +/////////////////////////////////////////////////////////////////////// + +extern sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True ); + +/////////////////////////////////////////////////////////////////////// + +using namespace ::osl; +using namespace ::vos; +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; + +/////////////////////////////////////////////////////////////////////// +SvxOle2Shape::SvxOle2Shape( SdrObject* pObject ) throw() +: SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_OLE2), aSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ +} + +SvxOle2Shape::SvxOle2Shape( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw () +: SvxShape( pObject, pPropertyMap, pPropertySet ) +{ +} + +SvxOle2Shape::~SvxOle2Shape() throw() +{ +} + +::com::sun::star::uno::Any SAL_CALL SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + return SvxShape::queryAggregation( rType ); +} + +//XPropertySet +bool SvxOle2Shape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { +/* + case OWN_ATTR_CLSID: + { + OUString aCLSID; + if( rValue >>= aCLSID ) + { + // init an ole object with a global name + SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + if( pOle2 ) + { + uno::Reference < embed::XEmbeddedObject > xObj = pOle2->GetObjRef(); + if ( !xObj.is() ) + { + SvGlobalName aClassName; + if( aClassName.MakeId( aCLSID ) ) + { + SfxObjectShell* pPersist = mpModel->GetPersist(); + ::rtl::OUString aPersistName; + Any aAny( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) ); + aAny >>= aPersistName; + + //TODO/LATER: how to cope with creation failure?! + xObj = pPersist->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ); + if( xObj.is() ) + { + aAny <<= aPersistName; + setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), aAny ); + pOle2->SetObjRef( xObj ); + + Rectangle aRect = pOle2->GetLogicRect(); + awt::Size aSz; + Size aSize( pOle2->GetLogicRect().GetSize() ); + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( pOle2->GetAspect(), aSz ); + } + } + } + } + return true; + } + break; + } +*/ + case OWN_ATTR_OLE_VISAREA: + { + // TODO/LATER: seems to make no sence for iconified object + + awt::Rectangle aVisArea; + if( (rValue >>= aVisArea) && mpObj->ISA(SdrOle2Obj)) + { + Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height ); + uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)mpObj.get())->GetObjRef(); + if( xObj.is() ) + { + try + { + MapUnit aMapUnit( MAP_100TH_MM ); // the API handles with MAP_100TH_MM map mode + MapUnit aObjUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( embed::Aspects::MSOLE_CONTENT ) ); + aTmp = OutputDevice::LogicToLogic( aTmp, aMapUnit, aObjUnit ); + xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, awt::Size( aTmp.Width(), aTmp.Height() ) ); + } + catch( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Couldn't set the visual area for the object!\n" ); + } + } + + return true; + } + break; + } + case OWN_ATTR_OLE_ASPECT: + { + sal_Int64 nAspect = 0; + if( rValue >>= nAspect ) + { + static_cast<SdrOle2Obj*>(mpObj.get())->SetAspect( nAspect ); + return true; + } + break; + } + case OWN_ATTR_CLSID: + { + OUString aCLSID; + if( rValue >>= aCLSID ) + { + // init a ole object with a global name + SvGlobalName aClassName; + if( aClassName.MakeId( aCLSID ) ) + { + if( createObject( aClassName ) ) + return true; + } + } + break; + } + case OWN_ATTR_THUMBNAIL: + { + OUString aURL; + if( rValue >>= aURL ) + { + GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); + static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic( &aGrafObj.GetGraphic() ); + return true; + } + break; + } + case OWN_ATTR_VALUE_GRAPHIC: + { + uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY ); + if( xGraphic.is() ) + { + SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + if( pOle ) + { + GraphicObject aGrafObj( xGraphic ); + const Graphic aGraphic( aGrafObj.GetGraphic() ); + pOle->SetGraphicToObj( aGraphic, rtl::OUString() ); + } + return true; + } + break; + } + case OWN_ATTR_PERSISTNAME: + { + OUString aPersistName; + if( rValue >>= aPersistName ) + { + static_cast<SdrOle2Obj*>(mpObj.get())->SetPersistName( aPersistName ); + return true; + } + break; + } + case OWN_ATTR_OLE_LINKURL: + { + OUString aLinkURL; + if( rValue >>= aLinkURL ) + { + createLink( aLinkURL ); + return true; + } + break; + } + default: + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_CLSID: + { + OUString aCLSID; + SvGlobalName aClassName = GetClassName_Impl(aCLSID); + rValue <<= aCLSID; + break; + } + + case OWN_ATTR_INTERNAL_OLE: + { + rtl::OUString sCLSID; + rValue <<= SotExchange::IsInternal( GetClassName_Impl(sCLSID) ); + break; + } + + case OWN_ATTR_METAFILE: + { + SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get()); + if( pObj ) + { + Graphic* pGraphic = pObj->GetGraphic(); + if( pGraphic ) + { + BOOL bIsWMF = FALSE; + if ( pGraphic->IsLink() ) + { + GfxLink aLnk = pGraphic->GetLink(); + if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF ) + { + bIsWMF = TRUE; + uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize()); + rValue <<= aSeq; + } + } + if ( !bIsWMF ) + { + GDIMetaFile aMtf; + if ( pGraphic->GetType() != GRAPHIC_BITMAP ) + aMtf = pObj->GetGraphic()->GetGDIMetaFile(); + else + { + VirtualDevice aVirDev; + aMtf.Record( &aVirDev ); + pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() ); + aMtf.Stop(); + aMtf.SetPrefSize( pGraphic->GetPrefSize() ); + aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() ); + } + SvMemoryStream aDestStrm( 65535, 65535 ); + ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); + rValue <<= aSeq; + } + } + } + else + { + rValue = GetBitmap( sal_True ); + } + break; + } + + case OWN_ATTR_OLE_VISAREA: + { + awt::Rectangle aVisArea; + if( mpObj->ISA(SdrOle2Obj)) + { + MapMode aMapMode( MAP_100TH_MM ); // the API uses this map mode + Size aTmp = ((SdrOle2Obj*)mpObj.get())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode + aVisArea = awt::Rectangle( 0, 0, aTmp.Width(), aTmp.Height() ); + } + + rValue <<= aVisArea; + break; + } + + case OWN_ATTR_OLESIZE: + { + Size aTmp( static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize() ); + rValue <<= awt::Size( aTmp.Width(), aTmp.Height() ); + break; + } + + case OWN_ATTR_OLE_ASPECT: + { + rValue <<= static_cast<SdrOle2Obj*>(mpObj.get())->GetAspect(); + break; + } + + case OWN_ATTR_OLEMODEL: + case OWN_ATTR_OLE_EMBEDDED_OBJECT: + { + SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( mpObj.get() ); + if( pObj ) + { + uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() ); + if ( xObj.is() + && ( pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT || svt::EmbeddedObjectRef::TryRunningState( xObj ) ) ) + { + // Discussed with CL fue to the before GetPaintingPageView + // usage. Removed it, former fallback is used now +#ifdef DBG_UTIL + const sal_Bool bSuccess(pObj->AddOwnLightClient()); + OSL_ENSURE( bSuccess, "An object without client is provided!" ); +#else + pObj->AddOwnLightClient(); +#endif + + if ( pProperty->nWID == OWN_ATTR_OLEMODEL ) + rValue <<= pObj->GetObjRef()->getComponent(); + else + rValue <<= xObj; + } + } + break; + } + + case OWN_ATTR_VALUE_GRAPHIC: + { + uno::Reference< graphic::XGraphic > xGraphic; + Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic(); + if( pGraphic ) + xGraphic = pGraphic->GetXGraphic(); + rValue <<= xGraphic; + break; + } + + case OWN_ATTR_THUMBNAIL: + { + OUString aURL; + SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + if( pOle ) + { + Graphic* pGraphic = pOle->GetGraphic(); + + // if there isn't already a preview graphic set, check if we need to generate + // one if model says so + if( pGraphic == NULL && !pOle->IsEmptyPresObj() && mpModel->IsSaveOLEPreview() ) + pGraphic = pOle->GetGraphic(); + + if( pGraphic ) + { + GraphicObject aObj( *pGraphic ); + aURL = OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); + aURL += OUString::createFromAscii( aObj.GetUniqueID().GetBuffer() ); + } + } + rValue <<= aURL; + break; + } + case OWN_ATTR_PERSISTNAME: + { + OUString aPersistName; + SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + + if( pOle ) + { + aPersistName = pOle->GetPersistName(); + if( aPersistName.getLength() ) + { + ::comphelper::IEmbeddedHelper *pPersist = mpObj->GetModel()->GetPersist(); + if( (NULL == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) ) + aPersistName = OUString(); + } + } + + rValue <<= aPersistName; + break; + } + case OWN_ATTR_OLE_LINKURL: + { + OUString aLinkURL; + SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + + if( pOle ) + { + uno::Reference< embed::XLinkageSupport > xLink( pOle->GetObjRef(), uno::UNO_QUERY ); + if ( xLink.is() && xLink->isLink() ) + aLinkURL = xLink->getLinkURL(); + } + + rValue <<= aLinkURL; + break; + } + default: + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } + + return true; +} + +sal_Bool SvxOle2Shape::createObject( const SvGlobalName &aClassName ) +{ + DBG_TESTSOLARMUTEX(); + + SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + if ( !pOle2Obj || !pOle2Obj->IsEmpty() ) + return sal_False; + + // create storage and inplace object + ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); + ::rtl::OUString aPersistName; + OUString aTmpStr; + if( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) >>= aTmpStr ) + aPersistName = aTmpStr; + + //TODO/LATER: how to cope with creation failure?! + uno::Reference < embed::XEmbeddedObject > xObj( pPersist->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ) ); + if( xObj.is() ) + { + Rectangle aRect = pOle2Obj->GetLogicRect(); + if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 ) + { + // TODO/LATER: is it possible that this method is used to create an iconified object? + // default size + try + { + awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); + aRect.SetSize( Size( aSz.Width, aSz.Height ) ); + } + catch( embed::NoVisualAreaSizeException& ) + {} + pOle2Obj->SetLogicRect( aRect ); + } + else + { + awt::Size aSz; + Size aSize = pOle2Obj->GetLogicRect().GetSize(); + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); + } + + // connect the object after the visual area is set + setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), Any( aTmpStr = aPersistName ) ); + + // the object is inserted during setting of PersistName property usually + if( pOle2Obj->IsEmpty() ) + pOle2Obj->SetObjRef( xObj ); + } + + return xObj.is(); +} + +sal_Bool SvxOle2Shape::createLink( const ::rtl::OUString& aLinkURL ) +{ + DBG_TESTSOLARMUTEX(); + + SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + if ( !pOle2Obj || !pOle2Obj->IsEmpty() ) + return sal_False; + + ::rtl::OUString aPersistName; + + ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); + + uno::Sequence< beans::PropertyValue > aMediaDescr( 1 ); + aMediaDescr[0].Name = ::rtl::OUString::createFromAscii( "URL" ); + aMediaDescr[0].Value <<= aLinkURL; + + uno::Reference< task::XInteractionHandler > xInteraction = pPersist->getInteractionHandler(); + if ( xInteraction.is() ) + { + aMediaDescr.realloc( 2 ); + aMediaDescr[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) ); + aMediaDescr[1].Value <<= xInteraction; + } + + //TODO/LATER: how to cope with creation failure?! + uno::Reference< embed::XEmbeddedObject > xObj = + pPersist->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr , aPersistName ); + + if( xObj.is() ) + { + Rectangle aRect = pOle2Obj->GetLogicRect(); + if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 ) + { + // default size + try + { + awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); + aRect.SetSize( Size( aSz.Width, aSz.Height ) ); + } + catch( embed::NoVisualAreaSizeException& ) + {} + pOle2Obj->SetLogicRect( aRect ); + } + else + { + awt::Size aSz; + Size aSize = pOle2Obj->GetLogicRect().GetSize(); + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); + } + + // connect the object after the visual area is set + setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), uno::makeAny( aPersistName ) ); + + // the object is inserted during setting of PersistName property usually + if ( pOle2Obj->IsEmpty() ) + pOle2Obj->SetObjRef( xObj ); + } + + return xObj.is(); +} + +void SvxOle2Shape::resetModifiedState() +{ + ::comphelper::IEmbeddedHelper* pPersist = mpModel ? mpModel->GetPersist() : 0; + if( pPersist && !pPersist->isEnableSetModified() ) + { + SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + if( pOle && !pOle->IsEmpty() ) + { + uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY ); + if( xMod.is() ) + // TODO/MBA: what's this?! + xMod->setModified( sal_False ); + } + } +} + +const SvGlobalName SvxOle2Shape::GetClassName_Impl(rtl::OUString& rHexCLSID) +{ + DBG_TESTSOLARMUTEX(); + SvGlobalName aClassName; + SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); + + if( pOle2Obj ) + { + rHexCLSID = rtl::OUString(); + + if( pOle2Obj->IsEmpty() ) + { + ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); + if( pPersist ) + { + uno::Reference < embed::XEmbeddedObject > xObj = + pPersist->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj->GetPersistName() ); + if ( xObj.is() ) + { + aClassName = SvGlobalName( xObj->getClassID() ); + rHexCLSID = aClassName.GetHexName(); + } + } + } + + if (!rHexCLSID.getLength()) + { + uno::Reference < embed::XEmbeddedObject > xObj( pOle2Obj->GetObjRef() ); + if ( xObj.is() ) + { + aClassName = SvGlobalName( xObj->getClassID() ); + rHexCLSID = aClassName.GetHexName(); + } + } + } + + return aClassName; +} + +/////////////////////////////////////////////////////////////////////// + +SvxAppletShape::SvxAppletShape( SdrObject* pObject ) throw() +: SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_APPLET), aSvxMapProvider.GetPropertySet(SVXMAP_APPLET, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) ); +} + +SvxAppletShape::~SvxAppletShape() throw() +{ +} + +void SvxAppletShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) +{ + SvxShape::Create( pNewObj, pNewPage ); + const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); + createObject(aAppletClassId); + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) ); +} + +void SAL_CALL SvxAppletShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + SvxShape::setPropertyValue( aPropertyName, rValue ); + resetModifiedState(); +} + +void SAL_CALL SvxAppletShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + SvxShape::setPropertyValues( aPropertyNames, rValues ); + resetModifiedState(); +} + +bool SvxAppletShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) ) + { + if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) + { + uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); + if( xSet.is() ) + { + // allow exceptions to pass through + xSet->setPropertyValue( rName, rValue ); + } + } + return true; + } + else + { + return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); + } +} + +bool SvxAppletShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) ) + { + if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) + { + uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); + if( xSet.is() ) + { + rValue = xSet->getPropertyValue( rName ); + } + } + return true; + } + else + { + return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); + } +} + +/////////////////////////////////////////////////////////////////////// + +SvxPluginShape::SvxPluginShape( SdrObject* pObject ) throw() +: SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_PLUGIN), aSvxMapProvider.GetPropertySet(SVXMAP_PLUGIN, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) ); +} + +SvxPluginShape::~SvxPluginShape() throw() +{ +} + +void SvxPluginShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) +{ + SvxShape::Create( pNewObj, pNewPage ); + const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); + createObject(aPluginClassId); + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) ); +} + +void SAL_CALL SvxPluginShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + SvxShape::setPropertyValue( aPropertyName, rValue ); + resetModifiedState(); +} + +void SAL_CALL SvxPluginShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + SvxOle2Shape::setPropertyValues( aPropertyNames, rValues ); + resetModifiedState(); +} + +bool SvxPluginShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) ) + { + if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) + { + uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); + if( xSet.is() ) + { + // allow exceptions to pass through + xSet->setPropertyValue( rName, rValue ); + } + } + return true; + } + else + { + return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); + } +} + +bool SvxPluginShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) ) + { + if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) + { + uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); + if( xSet.is() ) + { + rValue <<= xSet->getPropertyValue( rName ); + } + } + return true; + } + else + { + return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); + } +} + +/////////////////////////////////////////////////////////////////////// + +SvxFrameShape::SvxFrameShape( SdrObject* pObject ) throw() +: SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_FRAME), aSvxMapProvider.GetPropertySet(SVXMAP_FRAME, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) ); +} + +SvxFrameShape::~SvxFrameShape() throw() +{ +} + +void SvxFrameShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw () +{ + SvxShape::Create( pNewObj, pNewPage ); + const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); + createObject(aIFrameClassId); + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) ); +} + +void SAL_CALL SvxFrameShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + SvxShape::setPropertyValue( aPropertyName, rValue ); + resetModifiedState(); +} + +void SAL_CALL SvxFrameShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + SvxOle2Shape::setPropertyValues( aPropertyNames, rValues ); + resetModifiedState(); +} + +bool SvxFrameShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) ) + { + if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) + { + uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); + if( xSet.is() ) + { + // allow exceptions to pass through + xSet->setPropertyValue( rName, rValue ); + } + } + return true; + } + else + { + return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); + } +} + +bool SvxFrameShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) ) + { + if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) + { + uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); + if( xSet.is() ) + { + rValue <<= xSet->getPropertyValue( rName ); + } + } + return true; + } + else + { + return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); + } +} + +/*********************************************************************** +* * +***********************************************************************/ + +SvxMediaShape::SvxMediaShape( SdrObject* pObj ) throw() +: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_MEDIA), aSvxMapProvider.GetPropertySet(SVXMAP_MEDIA, SdrObject::GetGlobalDrawObjectItemPool()) ) +{ + SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MediaShape" ) ) ); +} + +//---------------------------------------------------------------------- +SvxMediaShape::~SvxMediaShape() throw() +{ +} + +//---------------------------------------------------------------------- + +bool SvxMediaShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( (pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM) ) + { + SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() ); + ::avmedia::MediaItem aItem; + bool bOk = false; + + switch( pProperty->nWID ) + { + case OWN_ATTR_MEDIA_URL: + { + OUString aURL; + if( rValue >>= aURL ) + { + bOk = true; + aItem.setURL( aURL ); + } + } + break; + + case( OWN_ATTR_MEDIA_LOOP ): + { + sal_Bool bLoop = sal_Bool(); + + if( rValue >>= bLoop ) + { + bOk = true; + aItem.setLoop( bLoop ); + } + } + break; + + case( OWN_ATTR_MEDIA_MUTE ): + { + sal_Bool bMute = sal_Bool(); + + if( rValue >>= bMute ) + { + bOk = true; + aItem.setMute( bMute ); + } + } + break; + + case( OWN_ATTR_MEDIA_VOLUMEDB ): + { + sal_Int16 nVolumeDB = sal_Int16(); + + if( rValue >>= nVolumeDB ) + { + bOk = true; + aItem.setVolumeDB( nVolumeDB ); + } + } + break; + + case( OWN_ATTR_MEDIA_ZOOM ): + { + ::com::sun::star::media::ZoomLevel eLevel; + + if( rValue >>= eLevel ) + { + bOk = true; + aItem.setZoom( eLevel ); + } + } + break; + + default: + DBG_ERROR("SvxMediaShape::setPropertyValueImpl(), unknown argument!"); + } + + if( bOk ) + { + pMedia->setMediaProperties( aItem ); + return true; + } + } + else + { + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); + } + + throw IllegalArgumentException(); +} + +//---------------------------------------------------------------------- + +bool SvxMediaShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( ( pProperty->nWID >= OWN_ATTR_MEDIA_URL ) && ( pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM ) ) + { + SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() ); + const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() ); + + switch( pProperty->nWID ) + { + case OWN_ATTR_MEDIA_URL: + rValue <<= aItem.getURL(); + break; + + case( OWN_ATTR_MEDIA_LOOP ): + rValue <<= (sal_Bool) aItem.isLoop(); + break; + + case( OWN_ATTR_MEDIA_MUTE ): + rValue <<= (sal_Bool) aItem.isMute(); + break; + + case( OWN_ATTR_MEDIA_VOLUMEDB ): + rValue <<= (sal_Int16) aItem.getVolumeDB(); + break; + + case( OWN_ATTR_MEDIA_ZOOM ): + rValue <<= aItem.getZoom(); + break; + + default: + DBG_ERROR("SvxMediaShape::getPropertyValueImpl(), unknown property!"); + } + return true; + } + else + { + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); + } +} diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx new file mode 100644 index 000000000000..1e79962736aa --- /dev/null +++ b/svx/source/unodraw/unoshape.cxx @@ -0,0 +1,4567 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#define _SVX_USE_UNOGLOBALS_ +#include <cppuhelper/typeprovider.hxx> +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/drawing/CircleKind.hpp> +#include <com/sun/star/embed/NoVisualAreaSizeException.hpp> +#include <vcl/svapp.hxx> +#include <svl/itemprop.hxx> +#include <svtools/fltcall.hxx> +#include <vos/mutex.hxx> +#include <editeng/unotext.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdoole2.hxx> +#include <osl/mutex.hxx> +#include <comphelper/extract.hxx> +#include "svx/shapepropertynotifier.hxx" +#include <comphelper/serviceinfohelper.hxx> +#include <toolkit/unohlp.hxx> +#include <comphelper/serviceinfohelper.hxx> +#include <rtl/uuid.h> +#include <rtl/memory.h> +#include <vcl/gfxlink.hxx> +#include <vcl/virdev.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> +#include "svx/svdopage.hxx" +#include "svx/xflbstit.hxx" +#include "svx/xflbmtit.hxx" +#include "svx/xlnstit.hxx" +#include "svx/xlnedit.hxx" +#include "svx/svdogrp.hxx" +#include "svx/scene3d.hxx" +#include "svx/svdmodel.hxx" +#include "globl3d.hxx" +#include "svx/fmglob.hxx" +#include "svx/unopage.hxx" +#include "svx/view3d.hxx" +#include "svx/unoshape.hxx" +#include "svx/svxids.hrc" +#include "svx/unoshtxt.hxx" +#include "svx/svdpage.hxx" +#include "svx/unoshprp.hxx" +#include "svx/sxciaitm.hxx" // todo: remove +#include "svx/svdograf.hxx" +#include "unoapi.hxx" +#include "svx/svdomeas.hxx" +#include "svx/svdpagv.hxx" +#include "svx/svdpool.hxx" +#include <tools/shl.hxx> // +#include "svx/dialmgr.hxx" // not nice, we need our own resources some day +#include "svx/dialogs.hrc" // +#include "svx/svdocapt.hxx" +#include <svx/obj3d.hxx> +#include <tools/diagnose_ex.h> +#include "svx/xflftrit.hxx" +#include "svx/xtable.hxx" +#include "svx/xbtmpit.hxx" +#include "svx/xflgrit.hxx" +#include "svx/xflhtit.hxx" +#include "svx/xlnedit.hxx" +#include "svx/xlnstit.hxx" +#include "svx/xlndsit.hxx" +#include "svdglob.hxx" +#include "svdstr.hrc" +#include "unomaster.hxx" +#include <editeng/outlobj.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> + +#include <vector> + +// #i68523# +#include "svx/lathe3d.hxx" +#include "svx/extrud3d.hxx" +#include "unopolyhelper.hxx" + +#include <comphelper/scopeguard.hxx> +#include <boost/bind.hpp> + +using ::rtl::OUString; +using namespace ::osl; +using namespace ::vos; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using ::svx::PropertyValueProvider; +using ::svx::IPropertyValueProvider; + +#define QUERYINT( xint ) \ + if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \ + aAny <<= uno::Reference< xint >(this) + +class GDIMetaFile; +class SvStream; +sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, + FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True ); + +uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject ); + +/*********************************************************************** +* class SvxShapeImpl * +***********************************************************************/ + +struct SvxShapeImpl +{ + SvxShape& mrAntiImpl; + SfxItemSet* mpItemSet; + sal_uInt32 mnObjId; + SvxShapeMaster* mpMaster; + bool mbHasSdrObjectOwnership; + bool mbDisposing; + + /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when + * a SvxShape::Create() call is executed. It is then set to the created + * SdrObject so a multiple call to SvxShape::Create() with same SdrObject + * is prohibited. + */ + SdrObject* mpCreatedObj; + + // for xComponent + ::cppu::OInterfaceContainerHelper maDisposeListeners; + ::svx::PropertyChangeNotifier maPropertyNotifier; + + SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex ) + :mrAntiImpl( _rAntiImpl ) + ,mpItemSet( NULL ) + ,mnObjId( 0 ) + ,mpMaster( NULL ) + ,mbHasSdrObjectOwnership( false ) + ,mbDisposing( false ) + ,mpCreatedObj( NULL ) + ,maDisposeListeners( _rMutex ) + ,maPropertyNotifier( _rAntiImpl, _rMutex ) + { + } +}; + +/**********************************************************************/ +class ShapePositionProvider : public PropertyValueProvider +{ +public: + ShapePositionProvider( const SvxShapeImpl& _shapeImpl ) + :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Position" ) + { + } + +protected: + virtual void getCurrentValue( Any& _out_rCurrentValue ) const + { + _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getPosition(); + } +}; + +//---------------------------------------------------------------------- +class ShapeSizeProvider : public PropertyValueProvider +{ +public: + ShapeSizeProvider( const SvxShapeImpl& _shapeImpl ) + :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Size" ) + { + } + +protected: + virtual void getCurrentValue( Any& _out_rCurrentValue ) const + { + _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getSize(); + } +}; + +/*********************************************************************** +* class SvxShape * +***********************************************************************/ + +DBG_NAME(SvxShape) + +SvxShape::SvxShape( SdrObject* pObject ) throw() +: maSize(100,100) +, mpImpl( new SvxShapeImpl( *this, maMutex ) ) +, mbIsMultiPropertyCall(false) +, mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool())) +, maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE)) +, mpObj(pObject) +, mpModel(NULL) +, mnLockCount(0) +{ + DBG_CTOR(SvxShape,NULL); + impl_construct(); +} + +//---------------------------------------------------------------------- +SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet ) throw() +: maSize(100,100) +, mpImpl( new SvxShapeImpl( *this, maMutex ) ) +, mbIsMultiPropertyCall(false) +, mpPropSet(pPropertySet) +, maPropMapEntries(pEntries) +, mpObj(pObject) +, mpModel(NULL) +, mnLockCount(0) +{ + DBG_CTOR(SvxShape,NULL); + impl_construct(); +} + +//---------------------------------------------------------------------- +SvxShape::SvxShape() throw() +: maSize(100,100) +, mpImpl( new SvxShapeImpl( *this, maMutex ) ) +, mbIsMultiPropertyCall(false) +, mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool())) +, maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE)) +, mpObj(NULL) +, mpModel(NULL) +, mnLockCount(0) +{ + DBG_CTOR(SvxShape,NULL); + impl_construct(); +} + +//---------------------------------------------------------------------- +SvxShape::~SvxShape() throw() +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" ); + + if ( mpModel ) + EndListening( *mpModel ); + + if ( mpImpl->mpMaster ) + mpImpl->mpMaster->dispose(); + + if ( mpObj.is() ) + mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); + + if( HasSdrObjectOwnership() && mpObj.is() ) + { + mpImpl->mbHasSdrObjectOwnership = false; + SdrObject* pObject = mpObj.get(); + SdrObject::Free( pObject ); + } + + delete mpImpl, mpImpl = NULL; + + DBG_DTOR(SvxShape,NULL); +} + +//---------------------------------------------------------------------- + +void SvxShape::TakeSdrObjectOwnership() +{ + mpImpl->mbHasSdrObjectOwnership = true; +} + +//---------------------------------------------------------------------- + +bool SvxShape::HasSdrObjectOwnership() const +{ + if ( !mpImpl->mbHasSdrObjectOwnership ) + return false; + + OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" ); + return mpObj.is(); +} + +//---------------------------------------------------------------------- + +void SvxShape::setShapeKind( sal_uInt32 nKind ) +{ + mpImpl->mnObjId = nKind; +} + +//---------------------------------------------------------------------- + +sal_uInt32 SvxShape::getShapeKind() const +{ + return mpImpl->mnObjId; +} + +//---------------------------------------------------------------------- + +void SvxShape::setMaster( SvxShapeMaster* pMaster ) +{ + mpImpl->mpMaster = pMaster; +} + +SvxShapeMaster* SvxShape::getMaster() +{ + return mpImpl->mpMaster; +} + +const SvxShapeMaster* SvxShape::getMaster() const +{ + return mpImpl->mpMaster; +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL SvxShape::queryAggregation( const uno::Type& rType ) throw (uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + uno::Any aAny; + if( mpImpl->mpMaster->queryAggregation( rType, aAny ) ) + return aAny; + } + + return SvxShape_UnoImplHelper::queryAggregation(rType); +} + +//---------------------------------------------------------------------- +const ::com::sun::star::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() throw() +{ + static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; + if( !pSeq ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pSeq ) + { + static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; +} + +//---------------------------------------------------------------------- +SvxShape* SvxShape::getImplementation( const uno::Reference< uno::XInterface >& xInt ) +{ + uno::Reference< lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY ); + if( xUT.is() ) + return reinterpret_cast<SvxShape*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxShape::getUnoTunnelId()))); + else + return NULL; +} + +//---------------------------------------------------------------------- +sal_Int64 SAL_CALL SvxShape::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) \ +{ + if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) + { + return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); + } + else + { + return 0; + } +} + +//---------------------------------------------------------------------- +SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw() +{ + return getImplementation( pObj->getUnoShape() ); +} + +//---------------------------------------------------------------------- +::svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier() +{ + return mpImpl->maPropertyNotifier; +} + +//---------------------------------------------------------------------- +void SvxShape::impl_construct() +{ + mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapePosition, + ::svx::PPropertyValueProvider( new ShapePositionProvider( *mpImpl ) ) ); + mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapeSize, + ::svx::PPropertyValueProvider( new ShapeSizeProvider( *mpImpl ) ) ); + + if ( mpObj.is() ) + impl_initFromSdrObject(); +} + +//---------------------------------------------------------------------- +void SvxShape::impl_initFromSdrObject() +{ + DBG_TESTSOLARMUTEX(); + OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" ); + if ( !mpObj.is() ) + return; + + osl_incrementInterlockedCount( &m_refCount ); + { + mpObj->setUnoShape( *this, SdrObject::GrantXShapeAccess() ); + } + osl_decrementInterlockedCount( &m_refCount ); + + mpModel = mpObj->GetModel(); + + // #i40944# + // Do not simply return when no model but do the type corrections + // following below. + if(mpModel) + { + StartListening( *mpModel ); + } + + const sal_uInt32 nInventor = mpObj->GetObjInventor(); + + // is it one of ours (svx) ? + if( nInventor == SdrInventor || nInventor == E3dInventor || nInventor == FmFormInventor ) + { + if(nInventor == FmFormInventor) + { + mpImpl->mnObjId = OBJ_UNO; + } + else + { + mpImpl->mnObjId = mpObj->GetObjIdentifier(); + if( nInventor == E3dInventor ) + mpImpl->mnObjId |= E3D_INVENTOR_FLAG; + } + + switch(mpImpl->mnObjId) + { + case OBJ_CCUT: // Kreisabschnitt + case OBJ_CARC: // Kreisbogen + case OBJ_SECT: // Kreissektor + mpImpl->mnObjId = OBJ_CIRC; + break; + + case E3D_SCENE_ID | E3D_INVENTOR_FLAG: + mpImpl->mnObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG; + break; + } + } +} + +//---------------------------------------------------------------------- +void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) +{ + DBG_TESTSOLARMUTEX(); + + OSL_PRECOND( pNewObj, "SvxShape::Create: invalid new object!" ); + if ( !pNewObj ) + return; + + OSL_ENSURE( ( mpImpl->mpCreatedObj == NULL ) || ( mpImpl->mpCreatedObj == pNewObj ), + "SvxShape::Create: the same shape used for two different objects?! Strange ..." ); + + // --> CL, OD 2005-07-19 #i52126# - correct condition + if ( mpImpl->mpCreatedObj != pNewObj ) + // <-- + { + DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" ); + // --> CL, OD 2005-07-19 #i52126# + mpImpl->mpCreatedObj = pNewObj; + // <-- + + if( mpObj.is() && mpObj->GetModel() ) + { + EndListening( *mpObj->GetModel() ); + } + + mpObj.reset( pNewObj ); + + OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" ); + // this was previously set in impl_initFromSdrObject, but I think it was superfluous + // (it definitely was in the other context where it was called, but I strongly suppose + // it was also superfluous when called from here) + impl_initFromSdrObject(); + + ObtainSettingsFromPropertySet( *mpPropSet ); + + // save user call + SdrObjUserCall* pUser = mpObj->GetUserCall(); + mpObj->SetUserCall(NULL); + + setPosition( maPosition ); + setSize( maSize ); + + // restore user call after we set the initial size + mpObj->SetUserCall( pUser ); + + // if this shape was already named, use this name + if( maShapeName.getLength() ) + { + mpObj->SetName( maShapeName ); + maShapeName = OUString(); + } + } +} + +//---------------------------------------------------------------------- + +void SvxShape::ChangeModel( SdrModel* pNewModel ) +{ + DBG_TESTSOLARMUTEX(); + if( mpObj.is() && mpObj->GetModel() ) + { + if( mpObj->GetModel() != pNewModel ) + { + EndListening( *mpObj->GetModel() ); + } + } + + // --> CL, OD 2005-07-19 #i52126# - always listen to new model + if( pNewModel ) + { + StartListening( *pNewModel ); + } + // <-- + + // HACK #i53696# ChangeModel should be virtual, but it isn't. can't change that for 2.0.1 + SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( this ); + if( pShapeText ) + { + SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() ); + if( pTextEditSource ) + pTextEditSource->ChangeModel( pNewModel ); + } + + mpModel = pNewModel; + + if( mpImpl->mpMaster ) + mpImpl->mpMaster->modelChanged( pNewModel ); +} + +//---------------------------------------------------------------------- + +void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() +{ + DBG_TESTSOLARMUTEX(); + if(mpModel) + { + SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + rPoint.A() = MM_TO_TWIPS(rPoint.A()); + rPoint.B() = MM_TO_TWIPS(rPoint.B()); + break; + } + default: + { + DBG_ERROR("AW: Missing unit translation to PoolMetric!"); + } + } + } + } +} + +//---------------------------------------------------------------------- +void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() +{ + DBG_TESTSOLARMUTEX(); + SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM; + if(mpModel) + { + eMapUnit = mpModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + rPoint.A() = TWIPS_TO_MM(rPoint.A()); + rPoint.B() = TWIPS_TO_MM(rPoint.B()); + break; + } + default: + { + DBG_ERROR("AW: Missing unit translation to 100th mm!"); + } + } + } + } +} + +//---------------------------------------------------------------------- +//---------------------------------------------------------------------- +void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet, + SfxItemSet& rSet, uno::Reference< beans::XPropertySet > xSet, const SfxItemPropertyMap* pMap ) +{ + if(rPropSet.AreThereOwnUsrAnys()) + { + const SfxItemPropertyMap* pSrc = rPropSet.getPropertyMap(); + PropertyEntryVector_t aSrcPropVector = pSrc->getPropertyEntries(); + PropertyEntryVector_t::const_iterator aSrcIt = aSrcPropVector.begin(); + while(aSrcIt != aSrcPropVector.end()) + { + if(aSrcIt->nWID) + { + uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(aSrcIt->nWID); + if(pUsrAny) + { + // Aequivalenten Eintrag in pDst suchen + const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aSrcIt->sName ); + if(pEntry) + { + // entry found + if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END) + { + // Special ID im PropertySet, kann nur direkt am + // Objekt gesetzt werden+ + xSet->setPropertyValue( aSrcIt->sName, *pUsrAny); + } + else + { + if(rSet.GetPool()->IsWhich(pEntry->nWID)) + rSet.Put(rSet.GetPool()->GetDefaultItem(pEntry->nWID)); + + // setzen + SvxItemPropertySet_setPropertyValue(rPropSet, pEntry, *pUsrAny, rSet); + } + } + } + } + + // next entry + ++aSrcIt; + } + } +} + + + +void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet) +{ + DBG_TESTSOLARMUTEX(); + if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel) + { + SfxItemSet aSet( mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END, 0); + Reference< beans::XPropertySet > xShape( (OWeakObject*)this, UNO_QUERY ); + SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, mpPropSet->getPropertyMap() ); + + mpObj->SetMergedItemSetAndBroadcast(aSet); + + mpObj->ApplyNotPersistAttr( aSet ); + } +} + +//---------------------------------------------------------------------- + +uno::Any SvxShape::GetBitmap( sal_Bool bMetaFile /* = sal_False */ ) const throw() +{ + DBG_TESTSOLARMUTEX(); + uno::Any aAny; + + if( !mpObj.is() || mpModel == NULL || !mpObj->IsInserted() || NULL == mpObj->GetPage() ) + return aAny; + + VirtualDevice aVDev; + aVDev.SetMapMode(MapMode(MAP_100TH_MM)); + + SdrModel* pModel = mpObj->GetModel(); + SdrPage* pPage = mpObj->GetPage(); + + E3dView* pView = new E3dView( pModel, &aVDev ); + pView->hideMarkHandles(); + SdrPageView* pPageView = pView->ShowSdrPage(pPage); + + SdrObject *pTempObj = mpObj.get(); + pView->MarkObj(pTempObj,pPageView); + + Rectangle aRect(pTempObj->GetCurrentBoundRect()); + aRect.Justify(); + Size aSize(aRect.GetSize()); + + GDIMetaFile aMtf( pView->GetAllMarkedMetaFile() ); + if( bMetaFile ) + { + SvMemoryStream aDestStrm( 65535, 65535 ); + ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); + aAny.setValue( &aSeq, ::getCppuType((const uno::Sequence< sal_Int8 >*)0) ); + } + else + { + Graphic aGraph(aMtf); + aGraph.SetPrefSize(aSize); + aGraph.SetPrefMapMode(MAP_100TH_MM); + + Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY ); + aAny <<= xBmp; + } + + pView->UnmarkAll(); + delete pView; + + return aAny; +} + +//---------------------------------------------------------------------- + +uno::Sequence< uno::Type > SAL_CALL SvxShape::getTypes() + throw (uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + return mpImpl->mpMaster->getTypes(); + } + else + { + return _getTypes(); + } +} + +//---------------------------------------------------------------------- + +uno::Sequence< uno::Type > SAL_CALL SvxShape::_getTypes() + throw(uno::RuntimeException) +{ + switch( mpImpl->mnObjId ) + { + // shapes without text + case OBJ_OLE2: + case OBJ_PAGE: + case OBJ_FRAME: + case OBJ_OLE2_PLUGIN: + case OBJ_OLE2_APPLET: + case E3D_CUBEOBJ_ID|E3D_INVENTOR_FLAG: + case E3D_SPHEREOBJ_ID|E3D_INVENTOR_FLAG: + case E3D_LATHEOBJ_ID|E3D_INVENTOR_FLAG: + case E3D_EXTRUDEOBJ_ID|E3D_INVENTOR_FLAG: + case E3D_POLYGONOBJ_ID|E3D_INVENTOR_FLAG: + case OBJ_MEDIA: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 12 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + } + } + return aTypeSequence; + } + // group shape + case OBJ_GRUP: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 14 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapeGroup>*)0); + } + } + return aTypeSequence; + } + // connector shape + case OBJ_EDGE: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 17 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XConnectorShape>*)0); + // from SvxUnoTextBase::getTypes() + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); + } + } + return aTypeSequence; + } + // control shape + case OBJ_UNO: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 13 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XControlShape>*)0); + } + } + return aTypeSequence; + } + // 3d scene shape + case E3D_POLYSCENE_ID|E3D_INVENTOR_FLAG: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 13 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0); + } + } + return aTypeSequence; + } + case OBJ_CUSTOMSHAPE: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 16 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + // from SvxUnoTextBase::getTypes() + *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< drawing::XEnhancedCustomShapeDefaulter >*)0); + } + } + return aTypeSequence; + } + // shapes with text + case OBJ_RECT: + case OBJ_CIRC: + case OBJ_MEASURE: + case OBJ_LINE: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + case OBJ_GRAF: + case OBJ_TEXT: + case OBJ_CAPTION: + case OBJ_TABLE: + default: + { + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; + + if( aTypeSequence.getLength() == 0 ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if( aTypeSequence.getLength() == 0 ) + { + aTypeSequence.realloc( 16 ); + uno::Type* pTypes = aTypeSequence.getArray(); + + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); +// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); + *pTypes++ = beans::XMultiPropertyStates::static_type(); + *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); + *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); + // from SvxUnoTextBase::getTypes() + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); + *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); + } + } + return aTypeSequence; + } + } +} + +//---------------------------------------------------------------------- + +uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId() + throw (uno::RuntimeException) +{ + static ::cppu::OImplementationId* pID = NULL ; + + if ( pID == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pID == NULL ) + { + // Create a new static ID ... + static ::cppu::OImplementationId aID( sal_False ) ; + // ... and set his address to static pointer! + pID = &aID ; + } + } + + return pID->getImplementationId() ; +} + +//---------------------------------------------------------------------- + +Reference< uno::XInterface > SvxShape_NewInstance() +{ + return uno::Reference< uno::XInterface >(static_cast< OWeakObject* >( new SvxShape() ) ); +} + +//---------------------------------------------------------------------- + +void SvxShape::onUserCall(SdrUserCallType /*_eUserCall*/, const Rectangle& /*_rNewBoundRect*/ ) +{ + // obsolete, not called anymore +} + +//---------------------------------------------------------------------- +// SfxListener +//---------------------------------------------------------------------- + +void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() +{ + DBG_TESTSOLARMUTEX(); + if( !mpObj.is() ) + return; + + // #i55919# HINT_OBJCHG is only interesting if it's for this object + + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + if (!pSdrHint || ( /* (pSdrHint->GetKind() != HINT_OBJREMOVED) && */ + (pSdrHint->GetKind() != HINT_MODELCLEARED) && + // #110094#-9 (pSdrHint->GetKind() != HINT_OBJLISTCLEAR) && + ((pSdrHint->GetKind() != HINT_OBJCHG || pSdrHint->GetObject() != mpObj.get() )))) + return; + + uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() ); + if( !xSelf.is() ) + { + mpObj.reset( NULL ); + return; + } + + sal_Bool bClearMe = sal_False; + + switch( pSdrHint->GetKind() ) + { + case HINT_OBJCHG: + { + updateShapeKind(); + break; + } + case HINT_MODELCLEARED: + { + bClearMe = sal_True; + mpModel = NULL; + break; + } + default: + break; + }; + + if( bClearMe ) + { + if( !HasSdrObjectOwnership() ) + mpObj.reset( NULL ); + if ( !mpImpl->mbDisposing ) + dispose(); + } +} + +// XShape + +//---------------------------------------------------------------------- +// The "*LogicRectHack" functions also existed in sch, and those +// duplicate symbols cause Bad Things To Happen (TM) #i9462#. +// Prefixing with 'svx' and marking static to make sure name collisions +// do not occur. + +static sal_Bool svx_needLogicRectHack( SdrObject* pObj ) +{ + if( pObj->GetObjInventor() == SdrInventor) + { + switch(pObj->GetObjIdentifier()) + { + case OBJ_GRUP: + case OBJ_LINE: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_SPLNLINE: + case OBJ_SPLNFILL: + case OBJ_EDGE: + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + case OBJ_MEASURE: + return sal_True; + } + } + return sal_False; +} + +//---------------------------------------------------------------------- + +static Rectangle svx_getLogicRectHack( SdrObject* pObj ) +{ + if(svx_needLogicRectHack(pObj)) + { + return pObj->GetSnapRect(); + } + else + { + return pObj->GetLogicRect(); + } +} + +//---------------------------------------------------------------------- + +static void svx_setLogicRectHack( SdrObject* pObj, const Rectangle& rRect ) +{ + if(svx_needLogicRectHack(pObj)) + { + pObj->SetSnapRect( rRect ); + } + else + { + pObj->SetLogicRect( rRect ); + } +} + +//---------------------------------------------------------------------- + +awt::Point SAL_CALL SvxShape::getPosition() throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpObj.is() && mpModel) + { + Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); + Point aPt( aRect.Left(), aRect.Top() ); + + // Position is relativ to anchor, so recalc to absolut position + if( mpModel->IsWriter() ) + aPt -= mpObj->GetAnchorPos(); + + ForceMetricTo100th_mm(aPt); + return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() ); + } + else + { + return maPosition; + } +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpObj.is() && mpModel ) + { + // do NOT move 3D objects, this would change the homogen + // transformation matrix + if(!mpObj->ISA(E3dCompoundObject)) + { + Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); + Point aLocalPos( Position.X, Position.Y ); + ForceMetricToItemPoolMetric(aLocalPos); + + // Position ist absolut, relativ zum Anker stellen + if( mpModel->IsWriter() ) + aLocalPos += mpObj->GetAnchorPos(); + + long nDX = aLocalPos.X() - aRect.Left(); + long nDY = aLocalPos.Y() - aRect.Top(); + + mpObj->Move( Size( nDX, nDY ) ); + mpModel->SetChanged(); + } + } + + maPosition = Position; +} + +//---------------------------------------------------------------------- +awt::Size SAL_CALL SvxShape::getSize() throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpObj.is() && mpModel) + { + Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); + Size aObjSize( aRect.getWidth(), aRect.getHeight() ); + ForceMetricTo100th_mm(aObjSize); + return ::com::sun::star::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() ); + } + else + return maSize; +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShape::setSize( const awt::Size& rSize ) + throw(beans::PropertyVetoException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpObj.is() && mpModel) + { + Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); + Size aLocalSize( rSize.Width, rSize.Height ); + ForceMetricToItemPoolMetric(aLocalSize); + + if(mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_MEASURE ) + { + Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left()); + Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top()); + Point aPt = mpObj->GetSnapRect().TopLeft(); + mpObj->Resize(aPt,aWdt,aHgt); + } + else + { + //aRect.SetSize(aLocalSize); // this call substract 1 // http://www.openoffice.org/issues/show_bug.cgi?id=83193 + if ( !aLocalSize.Width() ) + { + aRect.Right() = RECT_EMPTY; + } + else + aRect.setWidth(aLocalSize.Width()); + if ( !aLocalSize.Height() ) + { + aRect.Bottom() = RECT_EMPTY; + } + else + aRect.setHeight(aLocalSize.Height()); + + svx_setLogicRectHack( mpObj.get(), aRect ); + } + + mpModel->SetChanged(); + } + maSize = rSize; +} + +//---------------------------------------------------------------------- + +// XNamed +OUString SAL_CALL SvxShape::getName( ) throw(::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + if( mpObj.is() ) + { + return mpObj->GetName(); + } + else + { + return maShapeName; + } +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + if( mpObj.is() ) + { + mpObj->SetName( aName ); + } + else + { + maShapeName = aName; + } +} + +// XShapeDescriptor + +//---------------------------------------------------------------------- +OUString SAL_CALL SvxShape::getShapeType() throw(uno::RuntimeException) +{ + if( 0 == maShapeType.getLength() ) + { + UHashMapEntry* pMap = pSdrShapeIdentifierMap; + while ( ( pMap->nId != mpImpl->mnObjId ) && pMap->aIdentifier.getLength() ) + ++pMap; + + if ( pMap->aIdentifier.getLength() ) + { + return pMap->aIdentifier; + } + else + { + DBG_ERROR("[CL] unknown SdrObjekt identifier"); + } + } + + return maShapeType; +} + +// XComponent + +//---------------------------------------------------------------------- +void SAL_CALL SvxShape::dispose() throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpImpl->mbDisposing ) + return; // caught a recursion + + mpImpl->mbDisposing = true; + + lang::EventObject aEvt; + aEvt.Source = *(OWeakAggObject*) this; + mpImpl->maDisposeListeners.disposeAndClear(aEvt); + mpImpl->maPropertyNotifier.disposing(); + + if ( mpObj.is() ) + { + bool bFreeSdrObject = false; + + if ( mpObj->IsInserted() && mpObj->GetPage() ) + { + OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); + // normally, we are allowed to free the SdrObject only if we have its ownership. + // Why isn't this checked here? + + SdrPage* pPage = mpObj->GetPage(); + // SdrObject aus der Page loeschen + sal_uInt32 nCount = pPage->GetObjCount(); + for ( sal_uInt32 nNum = 0; nNum < nCount; ++nNum ) + { + if ( pPage->GetObj( nNum ) == mpObj.get() ) + { + OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() ); + bFreeSdrObject = true; + break; + } + } + } + + mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); + + if ( bFreeSdrObject ) + { + // in case we have the ownership of the SdrObject, a Free + // would do nothing. So ensure the ownership is reset. + mpImpl->mbHasSdrObjectOwnership = false; + SdrObject* pObject = mpObj.get(); + SdrObject::Free( pObject ); + } + } + + if( mpModel ) + { + EndListening( *mpModel ); + mpModel = NULL; + } +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener ) + throw(uno::RuntimeException) +{ + mpImpl->maDisposeListeners.addInterface(xListener); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException) +{ + mpImpl->maDisposeListeners.removeInterface(aListener); +} + +// XPropertySet + +//---------------------------------------------------------------------- + +Reference< beans::XPropertySetInfo > SAL_CALL + SvxShape::getPropertySetInfo() throw(uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + return mpImpl->mpMaster->getPropertySetInfo(); + } + else + { + return _getPropertySetInfo(); + } +} + +Reference< beans::XPropertySetInfo > SAL_CALL + SvxShape::_getPropertySetInfo() throw(uno::RuntimeException) +{ + return mpPropSet->getPropertySetInfo(); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener ); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener ); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE( false, "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" ); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE( false, "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" ); +} + +//---------------------------------------------------------------------- + +sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName ) +{ + SfxItemSet aSet( mpModel->GetItemPool(), (USHORT)nWID, (USHORT)nWID ); + + if( SetFillAttribute( nWID, rName, aSet, mpModel ) ) + { + //mpObj->SetItemSetAndBroadcast(aSet); + mpObj->SetMergedItemSetAndBroadcast(aSet); + + return sal_True; + } + else + { + return sal_False; + } +} + +//---------------------------------------------------------------------- + +sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const ::rtl::OUString& rName, SfxItemSet& rSet, SdrModel* pModel ) +{ + // check if an item with the given name and which id is inside the models + // pool or the stylesheet pool, if found its puttet in the itemse + if( !SetFillAttribute( nWID, rName, rSet ) ) + { + // we did not find such item in one of the pools, so we check + // the property lists that are loaded for the model for items + // that support such. + String aStrName; + SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aStrName ); + + switch( nWID ) + { + case XATTR_FILLBITMAP: + { + XBitmapList* pBitmapList = pModel->GetBitmapList(); + + if( !pBitmapList ) + return sal_False; + + long nPos = ((XPropertyList*)pBitmapList)->Get(aStrName); + if( nPos == -1 ) + return sal_False; + + XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos ); + XFillBitmapItem aBmpItem; + aBmpItem.SetWhich( XATTR_FILLBITMAP ); + aBmpItem.SetName( rName ); + aBmpItem.SetBitmapValue( pEntry->GetXBitmap() ); + rSet.Put( aBmpItem ); + break; + } + case XATTR_FILLGRADIENT: + { + XGradientList* pGradientList = pModel->GetGradientList(); + + if( !pGradientList ) + return sal_False; + + long nPos = ((XPropertyList*)pGradientList)->Get(aStrName); + if( nPos == -1 ) + return sal_False; + + XGradientEntry* pEntry = pGradientList->GetGradient( nPos ); + XFillGradientItem aGrdItem; + aGrdItem.SetWhich( XATTR_FILLGRADIENT ); + aGrdItem.SetName( rName ); + aGrdItem.SetGradientValue( pEntry->GetGradient() ); + rSet.Put( aGrdItem ); + break; + } + case XATTR_FILLHATCH: + { + XHatchList* pHatchList = pModel->GetHatchList(); + + if( !pHatchList ) + return sal_False; + + long nPos = ((XPropertyList*)pHatchList)->Get(aStrName); + if( nPos == -1 ) + return sal_False; + + XHatchEntry* pEntry = pHatchList->GetHatch( nPos ); + XFillHatchItem aHatchItem; + aHatchItem.SetWhich( XATTR_FILLHATCH ); + aHatchItem.SetName( rName ); + aHatchItem.SetHatchValue( pEntry->GetHatch() ); + rSet.Put( aHatchItem ); + break; + } + case XATTR_LINEEND: + case XATTR_LINESTART: + { + XLineEndList* pLineEndList = pModel->GetLineEndList(); + + if( !pLineEndList ) + return sal_False; + + long nPos = ((XPropertyList*)pLineEndList)->Get(aStrName); + if( nPos == -1 ) + return sal_False; + + XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); + if( XATTR_LINEEND == nWID ) + { + XLineEndItem aLEItem; + aLEItem.SetWhich( XATTR_LINEEND ); + aLEItem.SetName( rName ); + aLEItem.SetLineEndValue( pEntry->GetLineEnd() ); + rSet.Put( aLEItem ); + } + else + { + XLineStartItem aLSItem; + aLSItem.SetWhich( XATTR_LINESTART ); + aLSItem.SetName( rName ); + aLSItem.SetLineStartValue( pEntry->GetLineEnd() ); + rSet.Put( aLSItem ); + } + + break; + } + case XATTR_LINEDASH: + { + XDashList* pDashList = pModel->GetDashList(); + + if( !pDashList ) + return sal_False; + + long nPos = ((XPropertyList*)pDashList)->Get(aStrName); + if( nPos == -1 ) + return sal_False; + + XDashEntry* pEntry = pDashList->GetDash( nPos ); + XLineDashItem aDashItem; + aDashItem.SetWhich( XATTR_LINEDASH ); + aDashItem.SetName( rName ); + aDashItem.SetDashValue( pEntry->GetDash() ); + rSet.Put( aDashItem ); + break; + } + default: + return sal_False; + } + } + + return sal_True; +} + +//---------------------------------------------------------------------- + +sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, SfxItemSet& rSet ) +{ + String aName; + SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aName ); + + if( aName.Len() == 0 ) + { + switch( nWID ) + { + case XATTR_LINEEND: + case XATTR_LINESTART: + { + const String aEmpty; + const basegfx::B2DPolyPolygon aEmptyPoly; + if( nWID == XATTR_LINEEND ) + rSet.Put( XLineEndItem( aEmpty, aEmptyPoly ) ); + else + rSet.Put( XLineStartItem( aEmpty, aEmptyPoly ) ); + + return sal_True; + } + case XATTR_FILLFLOATTRANSPARENCE: + { + // #85953# Set a disabled XFillFloatTransparenceItem + rSet.Put(XFillFloatTransparenceItem()); + + return sal_True; + } + } + + return sal_False; + } + + const SfxItemPool* pPool = rSet.GetPool(); + + const String aSearchName( aName ); + const USHORT nCount = pPool->GetItemCount((USHORT)nWID); + const NameOrIndex *pItem; + + for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)pPool->GetItem((USHORT)nWID, nSurrogate); + if( pItem && ( pItem->GetName() == aSearchName ) ) + { + rSet.Put( *pItem ); + return sal_True; + } + } + + return sal_False; +} + +//---------------------------------------------------------------------- + +// static +/* os: unused function + uno::Any SAL_CALL SvxShape::GetFillAttributeByName( + const ::rtl::OUString& rPropertyName, const ::rtl::OUString& rName, SdrModel* pModel ) +{ + uno::Any aResult; + DBG_ASSERT( pModel, "Invalid Model in GetFillAttributeByName()" ); + if( ! pModel ) + return aResult; + + sal_Int16 nWhich = SvxUnoGetWhichIdForNamedProperty( rPropertyName ); + + // search pool for item + const SfxItemPool& rPool = pModel->GetItemPool(); + + const String aSearchName( rName ); + const USHORT nCount = rPool.GetItemCount((USHORT)nWhich); + const NameOrIndex *pItem = 0; + bool bFound = false; + + for( USHORT nSurrogate = 0; ! bFound && nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)rPool.GetItem((USHORT)nWhich, nSurrogate); + if( pItem && ( pItem->GetName() == aSearchName ) ) + { + bFound = true; + } + } + + // check the property lists that are loaded for the model for items that + // support such. + String aStrName; + SvxUnogetInternalNameForItem( nWhich, rName, aStrName ); + + switch( nWhich ) + { + case XATTR_FILLBITMAP: + { + XFillBitmapItem aBmpItem; + if( ! bFound ) + { + XBitmapList* pBitmapList = pModel->GetBitmapList(); + + if( !pBitmapList ) + break; + + long nPos = ((XPropertyList*)pBitmapList)->Get(aStrName); + if( nPos == -1 ) + break; + + XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos ); + aBmpItem.SetWhich( XATTR_FILLBITMAP ); + aBmpItem.SetName( rName ); + aBmpItem.SetBitmapValue( pEntry->GetXBitmap() ); + pItem = & aBmpItem; + } + DBG_ASSERT( pItem, "Invalid Item" ); + if( pItem ) + pItem->QueryValue( aResult ); // default: XBitmap. MID_GRAFURL instead? + } + break; + + case XATTR_FILLGRADIENT: + { + XFillGradientItem aGrdItem; + if( ! bFound ) + { + XGradientList* pGradientList = pModel->GetGradientList(); + + if( !pGradientList ) + break; + + long nPos = ((XPropertyList*)pGradientList)->Get(aStrName); + if( nPos == -1 ) + break; + + XGradientEntry* pEntry = pGradientList->GetGradient( nPos ); + aGrdItem.SetWhich( XATTR_FILLGRADIENT ); + aGrdItem.SetName( rName ); + aGrdItem.SetGradientValue( pEntry->GetGradient() ); + pItem = & aGrdItem; + } + DBG_ASSERT( pItem, "Invalid Item" ); + if( pItem ) + pItem->QueryValue( aResult, MID_FILLGRADIENT ); + } + break; + + case XATTR_FILLHATCH: + { + XFillHatchItem aHatchItem; + if( ! bFound ) + { + XHatchList* pHatchList = pModel->GetHatchList(); + + if( !pHatchList ) + break; + + long nPos = ((XPropertyList*)pHatchList)->Get(aStrName); + if( nPos == -1 ) + break; + + XHatchEntry* pEntry = pHatchList->GetHatch( nPos ); + aHatchItem.SetWhich( XATTR_FILLHATCH ); + aHatchItem.SetName( rName ); + aHatchItem.SetHatchValue( pEntry->GetHatch() ); + pItem = & aHatchItem; + } + DBG_ASSERT( pItem, "Invalid Item" ); + if( pItem ) + pItem->QueryValue( aResult, MID_FILLHATCH ); + } + break; + + case XATTR_LINEEND: + case XATTR_LINESTART: + { + if( ! bFound ) + { + XLineEndList* pLineEndList = pModel->GetLineEndList(); + + if( !pLineEndList ) + break; + + long nPos = ((XPropertyList*)pLineEndList)->Get(aStrName); + if( nPos == -1 ) + break; + + XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); + if( nWhich == XATTR_LINEEND ) + { + XLineEndItem aLEItem; + aLEItem.SetWhich( XATTR_LINEEND ); + aLEItem.SetName( rName ); + aLEItem.SetLineEndValue( pEntry->GetLineEnd() ); + aLEItem.QueryValue( aResult ); + } + else + { + XLineStartItem aLSItem; + aLSItem.SetWhich( XATTR_LINESTART ); + aLSItem.SetName( rName ); + aLSItem.SetLineStartValue( pEntry->GetLineEnd() ); + aLSItem.QueryValue( aResult ); + } + } + else + { + DBG_ASSERT( pItem, "Invalid Item" ); + if( pItem ) + pItem->QueryValue( aResult ); + } + } + break; + + case XATTR_LINEDASH: + { + XLineDashItem aDashItem; + if( ! bFound ) + { + XDashList* pDashList = pModel->GetDashList(); + + if( !pDashList ) + break; + + long nPos = ((XPropertyList*)pDashList)->Get(aStrName); + if( nPos == -1 ) + break; + + XDashEntry* pEntry = pDashList->GetDash( nPos ); + aDashItem.SetWhich( XATTR_LINEDASH ); + aDashItem.SetName( rName ); + aDashItem.SetDashValue( pEntry->GetDash() ); + pItem = & aDashItem; + } + DBG_ASSERT( pItem, "Invalid Item" ); + if( pItem ) + pItem->QueryValue( aResult, MID_LINEDASH ); + } + break; + } + + return aResult; +} */ + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + mpImpl->mpMaster->setPropertyValue( rPropertyName, rVal ); + } + else + { + _setPropertyValue( rPropertyName, rVal ); + } +} + +void SAL_CALL SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName); + + if( mpObj.is() && mpModel ) + { + if( pMap == NULL ) + throw beans::UnknownPropertyException(); + + if( (pMap->nFlags & beans::PropertyAttribute::READONLY ) != 0 ) + throw beans::PropertyVetoException(); + + mpModel->SetChanged(); + + if(!setPropertyValueImpl( rPropertyName, pMap, rVal ) ) + { + DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST, "Not persist item not handled!" ); + DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" ); + + sal_Bool bIsNotPersist = pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST && pMap->nWID != SDRATTR_TEXTDIRECTION; + + if( pMap->nWID == SDRATTR_ECKENRADIUS ) + { + sal_Int32 nCornerRadius = 0; + if( !(rVal >>= nCornerRadius) || (nCornerRadius < 0) || (nCornerRadius > 5000000)) + throw IllegalArgumentException(); + } + + SfxItemSet* pSet; + if( mbIsMultiPropertyCall && !bIsNotPersist ) + { + if( mpImpl->mpItemSet == NULL ) + { + pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone(); + } + else + { + pSet = mpImpl->mpItemSet; + } + } + else + { + pSet = new SfxItemSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID); + } + + if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET ) + pSet->Put(mpObj->GetMergedItem(pMap->nWID)); + + if( !SvxUnoTextRangeBase::SetPropertyValueHelper( *pSet, pMap, rVal, *pSet )) + { + if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET ) + { + if(bIsNotPersist) + { + // Not-Persistant Attribute, hole diese extra + mpObj->TakeNotPersistAttr(*pSet, sal_False); + } + } + + if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET ) + { + // Default aus ItemPool holen + if(mpModel->GetItemPool().IsWhich(pMap->nWID)) + pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); + } + + if( pSet->GetItemState( pMap->nWID ) == SFX_ITEM_SET ) + { + SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rVal, *pSet ); + } + } + + if(bIsNotPersist) + { + // Not-Persist Attribute extra setzen + mpObj->ApplyNotPersistAttr( *pSet ); + delete pSet; + } + else + { + // if we have a XMultiProperty call then the item set + // will be set in setPropertyValues later + if( !mbIsMultiPropertyCall ) + { + mpObj->SetMergedItemSetAndBroadcast( *pSet ); + + delete pSet; + } + } + return; + } + } + else + { + // since we have no actual sdr object right now + // remember all properties in a list. These + // properties will be set when the sdr object is + // created + + if(pMap && pMap->nWID) +// Fixme: We should throw a UnknownPropertyException here. +// But since this class is aggregated from classes +// that support additional properties that we don't +// know here we silently store *all* properties, even +// if they may be not supported after creation + mpPropSet->setPropertyValue( pMap, rVal ); + } +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if ( mpImpl->mpMaster ) + return mpImpl->mpMaster->getPropertyValue( PropertyName ); + else + return _getPropertyValue( PropertyName ); +} + +//---------------------------------------------------------------------- + +uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); + + uno::Any aAny; + if( mpObj.is() && mpModel ) + { + if(pMap == NULL ) + throw beans::UnknownPropertyException(); + + if( !getPropertyValueImpl( PropertyName, pMap, aAny ) ) + { + DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" ); + DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" ); + + SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID); + aSet.Put(mpObj->GetMergedItem(pMap->nWID)); + + if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny )) + return aAny; + + if(!aSet.Count()) + { + if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST) + { + // Not-Persistant Attribute, hole diese extra + mpObj->TakeNotPersistAttr(aSet, sal_False); + } + } + + if(!aSet.Count()) + { + // Default aus ItemPool holen + if(mpModel->GetItemPool().IsWhich(pMap->nWID)) + aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); + } + + if(aSet.Count()) + aAny = GetAnyForItem( aSet, pMap ); + } + } + else + { + +// Fixme: we should return default values for OWN_ATTR ! + + if(pMap && pMap->nWID) +// FixMe: see setPropertyValue + aAny = mpPropSet->getPropertyValue( pMap ); + + } + return aAny; +} + +//---------------------------------------------------------------------- + +// XMultiPropertySet +void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + OGuard aSolarGuard( Application::GetSolarMutex() ); + + const sal_Int32 nCount = aPropertyNames.getLength(); + const OUString* pNames = aPropertyNames.getConstArray(); + + const uno::Any* pValues = aValues.getConstArray(); + + // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are + // reseted even when an execption is thrown + const ::comphelper::ScopeGuard aGuard( boost::bind( &SvxShape::endSetPropertyValues, this ) ); + + mbIsMultiPropertyCall = sal_True; + + if( mpImpl->mpMaster ) + { + for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ ) + { + try + { + setPropertyValue( *pNames, *pValues ); + } + catch( beans::UnknownPropertyException& e ) + { + (void)e; + } + catch( uno::Exception& ex ) + { + (void)ex; + } + } + } + else + { + uno::Reference< beans::XPropertySet > xSet; + queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet; + + for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ ) + { + try + { + xSet->setPropertyValue( *pNames, *pValues ); + } + catch( beans::UnknownPropertyException& e ) + { + (void)e; + } + catch( uno::Exception& ex ) + { + (void)ex; + } + } + } + + if( mpImpl->mpItemSet && mpObj.is() ) + mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet ); +} + +//---------------------------------------------------------------------- + +void SvxShape::endSetPropertyValues() +{ + mbIsMultiPropertyCall = sal_False; + if( mpImpl->mpItemSet ) + { + delete mpImpl->mpItemSet; + mpImpl->mpItemSet = 0; + } +} + +//---------------------------------------------------------------------- + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL SvxShape::getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException) +{ + const sal_Int32 nCount = aPropertyNames.getLength(); + const OUString* pNames = aPropertyNames.getConstArray(); + + uno::Sequence< uno::Any > aRet( nCount ); + uno::Any* pValue = aRet.getArray();; + + if( mpImpl->mpMaster ) + { + for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ ) + { + try + { + *pValue = getPropertyValue( *pNames ); + } + catch( uno::Exception& ) + { + DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" ); + } + } + } + else + { + uno::Reference< beans::XPropertySet > xSet; + queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet; + + for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ ) + { + try + { + *pValue = xSet->getPropertyValue( *pNames ); + } + catch( uno::Exception& ) + { + DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" ); + } + } + } + + return aRet; +} + +void SAL_CALL SvxShape::addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException) +{ +} + +void SAL_CALL SvxShape::removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException) +{ +} + +void SAL_CALL SvxShape::firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException) +{ +} + +//---------------------------------------------------------------------- + +uno::Any SvxShape::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap ) const +{ + DBG_TESTSOLARMUTEX(); + uno::Any aAny; + + switch(pMap->nWID) + { + case SDRATTR_CIRCSTARTANGLE: + { + const SfxPoolItem* pPoolItem=NULL; + if(aSet.GetItemState(SDRATTR_CIRCSTARTANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET) + { + sal_Int32 nAngle = ((SdrCircStartAngleItem*)pPoolItem)->GetValue(); + aAny <<= nAngle; + } + break; + } + + case SDRATTR_CIRCENDANGLE: + { + const SfxPoolItem* pPoolItem=NULL; + if (aSet.GetItemState(SDRATTR_CIRCENDANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET) + { + sal_Int32 nAngle = ((SdrCircEndAngleItem*)pPoolItem)->GetValue(); + aAny <<= nAngle; + } + break; + } + + case SDRATTR_CIRCKIND: + { + if( mpObj->GetObjInventor() == SdrInventor) + { + drawing::CircleKind eKind; + switch(mpObj->GetObjIdentifier()) + { + case OBJ_CIRC: // Kreis, Ellipse + eKind = drawing::CircleKind_FULL; + break; + case OBJ_CCUT: // Kreisabschnitt + eKind = drawing::CircleKind_CUT; + break; + case OBJ_CARC: // Kreisbogen + eKind = drawing::CircleKind_ARC; + break; + case OBJ_SECT: // Kreissektor + eKind = drawing::CircleKind_SECTION; + break; + } + aAny <<= eKind; + } + break; + } + default: + { + // Hole Wert aus ItemSet + aAny = SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ); + + if( *pMap->pType != aAny.getValueType() ) + { + // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here + if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) ) + { + sal_Int32 nValue = 0; + aAny >>= nValue; + aAny <<= (sal_Int16)nValue; + } + else + { + DBG_ERROR("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" ); + } + } + + } + } + + return aAny; +} + +//---------------------------------------------------------------------- + +// XPropertyState +beans::PropertyState SAL_CALL SvxShape::getPropertyState( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + return mpImpl->mpMaster->getPropertyState( PropertyName ); + } + else + { + return _getPropertyState( PropertyName ); + } +} + +beans::PropertyState SAL_CALL SvxShape::_getPropertyState( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); + + if( !mpObj.is() || pMap == NULL ) + throw beans::UnknownPropertyException(); + + beans::PropertyState eState; + if( !getPropertyStateImpl( pMap, eState ) ) + { + const SfxItemSet& rSet = mpObj->GetMergedItemSet(); + + switch( rSet.GetItemState( pMap->nWID, sal_False ) ) + { + case SFX_ITEM_READONLY: + case SFX_ITEM_SET: + eState = beans::PropertyState_DIRECT_VALUE; + break; + case SFX_ITEM_DEFAULT: + eState = beans::PropertyState_DEFAULT_VALUE; + break; +// case SFX_ITEM_UNKNOWN: +// case SFX_ITEM_DONTCARE: +// case SFX_ITEM_DISABLED: + default: + eState = beans::PropertyState_AMBIGUOUS_VALUE; + break; + } + + // if a item is set, this doesn't mean we want it :) + if( ( beans::PropertyState_DIRECT_VALUE == eState ) ) + { + switch( pMap->nWID ) + { + // the following items are disabled by changing the + // fill style or the line style. so there is no need + // to export items without names which should be empty + case XATTR_FILLBITMAP: + case XATTR_FILLGRADIENT: + case XATTR_FILLHATCH: + case XATTR_LINEDASH: + { + NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((USHORT)pMap->nWID); + if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) ) + eState = beans::PropertyState_DEFAULT_VALUE; + } + break; + + // #i36115# + // If e.g. the LineStart is on NONE and thus the string has length 0, it still + // may be a hard attribute covering the set LineStart of the parent (Style). + // #i37644# + // same is for fill float transparency + case XATTR_LINEEND: + case XATTR_LINESTART: + case XATTR_FILLFLOATTRANSPARENCE: + { + NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((USHORT)pMap->nWID); + if( ( pItem == NULL ) ) + eState = beans::PropertyState_DEFAULT_VALUE; + } + break; + } + } + } + return eState; +} + +//---------------------------------------------------------------------- + +bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { + case OWN_ATTR_CAPTION_POINT: + { + awt::Point aPnt; + if( rValue >>= aPnt ) + { + Point aVclPoint( aPnt.X, aPnt.Y ); + + // #90763# position is relative to top left, make it absolute + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + + aVclPoint.X() += basegfx::fround(aNewHomogenMatrix.get(0, 2)); + aVclPoint.Y() += basegfx::fround(aNewHomogenMatrix.get(1, 2)); + + // #88657# metric of pool maybe twips (writer) + ForceMetricToItemPoolMetric(aVclPoint); + + // #88491# position relative to anchor + if( mpModel->IsWriter() ) + { + aVclPoint += mpObj->GetAnchorPos(); + } + + ((SdrCaptionObj*)mpObj.get())->SetTailPos(aVclPoint); + + return true; + } + break; + } + case OWN_ATTR_TRANSFORMATION: + { + drawing::HomogenMatrix3 aMatrix; + if(rValue >>= aMatrix) + { + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + + aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1); + aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2); + aNewHomogenMatrix.set(0, 2, aMatrix.Line1.Column3); + aNewHomogenMatrix.set(1, 0, aMatrix.Line2.Column1); + aNewHomogenMatrix.set(1, 1, aMatrix.Line2.Column2); + aNewHomogenMatrix.set(1, 2, aMatrix.Line2.Column3); + aNewHomogenMatrix.set(2, 0, aMatrix.Line3.Column1); + aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2); + aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3); + + mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + return true; + } + break; + } + + case OWN_ATTR_ZORDER: + { + sal_Int32 nNewOrdNum = 0; + if(rValue >>= nNewOrdNum) + { + SdrObjList* pObjList = mpObj->GetObjList(); + if( pObjList ) + { +#ifdef DBG_UTIL + SdrObject* pCheck = +#endif + pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), (ULONG)nNewOrdNum ); + DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" ); + } + return true; + } + break; + } + case OWN_ATTR_FRAMERECT: + { + awt::Rectangle aUnoRect; + if(rValue >>= aUnoRect) + { + Point aTopLeft( aUnoRect.X, aUnoRect.Y ); + Size aObjSize( aUnoRect.Width, aUnoRect.Height ); + ForceMetricToItemPoolMetric(aTopLeft); + ForceMetricToItemPoolMetric(aObjSize); + Rectangle aRect; + aRect.SetPos(aTopLeft); + aRect.SetSize(aObjSize); + mpObj->SetSnapRect(aRect); + return true; + } + break; + } + case OWN_ATTR_MIRRORED: + { + sal_Bool bMirror = sal_Bool(); + if(rValue >>= bMirror ) + { + SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() ); + if( pObj ) + pObj->SetMirrored(bMirror); + return true; + } + break; + } + case OWN_ATTR_EDGE_START_OBJ: + case OWN_ATTR_EDGE_END_OBJ: + case OWN_ATTR_GLUEID_HEAD: + case OWN_ATTR_GLUEID_TAIL: + case OWN_ATTR_EDGE_START_POS: + case OWN_ATTR_EDGE_END_POS: + case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: + { + SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get()); + if(pEdgeObj) + { + switch(pProperty->nWID) + { + case OWN_ATTR_EDGE_START_OBJ: + case OWN_ATTR_EDGE_END_OBJ: + { + Reference< drawing::XShape > xShape; + if( rValue >>= xShape ) + { + SdrObject* pNode = GetSdrObjectFromXShape( xShape ); + if( pNode ) + { + pEdgeObj->ConnectToNode( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, pNode ); + pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, -1 ); + return true; + } + } + break; + } + + case OWN_ATTR_EDGE_START_POS: + case OWN_ATTR_EDGE_END_POS: + { + awt::Point aUnoPoint; + if( rValue >>= aUnoPoint ) + { + Point aPoint( aUnoPoint.X, aUnoPoint.Y ); + if( mpModel->IsWriter() ) + aPoint += mpObj->GetAnchorPos(); + + ForceMetricToItemPoolMetric( aPoint ); + pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint ); + return true; + } + break; + } + + case OWN_ATTR_GLUEID_HEAD: + case OWN_ATTR_GLUEID_TAIL: + { + sal_Int32 nId = 0; + if( rValue >>= nId ) + { + pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD, nId ); + return true; + } + break; + } + case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: + { + drawing::PolyPolygonBezierCoords aPolyPoly; + if ( rValue >>= aPolyPoly ) + { + basegfx::B2DPolyPolygon aNewPolyPolygon( SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aPolyPoly ) ); + if( mpModel->IsWriter() ) + { + Point aPoint( mpObj->GetAnchorPos() ); + aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y())); + } + pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon ); + return true; + } + } + } + } + break; + } + case OWN_ATTR_MEASURE_START_POS: + case OWN_ATTR_MEASURE_END_POS: + { + SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get()); + awt::Point aUnoPoint; + if(pMeasureObj && ( rValue >>= aUnoPoint ) ) + { + Point aPoint( aUnoPoint.X, aUnoPoint.Y ); + + if( mpModel->IsWriter() ) + aPoint += mpObj->GetAnchorPos(); + + pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0L : 1L ); + pMeasureObj->SetChanged(); + pMeasureObj->BroadcastObjectChange(); + return true; + } + break; + } + case OWN_ATTR_FILLBMP_MODE: + { + drawing::BitmapMode eMode; + if(!(rValue >>= eMode) ) + { + sal_Int32 nMode = 0; + if(!(rValue >>= nMode)) + break; + + eMode = (drawing::BitmapMode)nMode; + } + mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) ); + mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) ); + return true; + } + + case SDRATTR_LAYERID: + { + sal_Int16 nLayerId = sal_Int16(); + if( rValue >>= nLayerId ) + { + SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID((unsigned char)nLayerId); + if( pLayer ) + { + mpObj->SetLayer((unsigned char)nLayerId); + return true; + } + } + break; + } + + case SDRATTR_LAYERNAME: + { + OUString aLayerName; + if( rValue >>= aLayerName ) + { + const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName, TRUE); + if( pLayer != NULL ) + { + mpObj->SetLayer( pLayer->GetID() ); + return true; + } + } + break; + } + case SDRATTR_ROTATEANGLE: + { + sal_Int32 nAngle = 0; + if( rValue >>= nAngle ) + { + Point aRef1(mpObj->GetSnapRect().Center()); + nAngle -= mpObj->GetRotateAngle(); + if (nAngle!=0) + { + double nSin=sin(nAngle*nPi180); + double nCos=cos(nAngle*nPi180); + mpObj->Rotate(aRef1,nAngle,nSin,nCos); + } + return true; + } + + break; + } + + case SDRATTR_SHEARANGLE: + { + sal_Int32 nShear = 0; + if( rValue >>= nShear ) + { + nShear -= mpObj->GetShearAngle(); + if(nShear != 0 ) + { + Point aRef1(mpObj->GetSnapRect().Center()); + double nTan=tan(nShear*nPi180); + mpObj->Shear(aRef1,nShear,nTan,FALSE); + return true; + } + } + + break; + } + + case SDRATTR_OBJMOVEPROTECT: + { + sal_Bool bMoveProtect = sal_Bool(); + if( rValue >>= bMoveProtect ) + { + mpObj->SetMoveProtect(bMoveProtect); + return true; + } + break; + } + case SDRATTR_OBJECTNAME: + { + OUString aName; + if( rValue >>= aName ) + { + mpObj->SetName( aName ); + return true; + } + break; + } + + // #i68101# + case OWN_ATTR_MISC_OBJ_TITLE: + { + OUString aTitle; + if( rValue >>= aTitle ) + { + mpObj->SetTitle( aTitle ); + return true; + } + break; + } + case OWN_ATTR_MISC_OBJ_DESCRIPTION: + { + OUString aDescription; + if( rValue >>= aDescription ) + { + mpObj->SetDescription( aDescription ); + return true; + } + break; + } + + case SDRATTR_OBJPRINTABLE: + { + sal_Bool bPrintable = sal_Bool(); + if( rValue >>= bPrintable ) + { + mpObj->SetPrintable(bPrintable); + return true; + } + break; + } + case SDRATTR_OBJSIZEPROTECT: + { + sal_Bool bResizeProtect = sal_Bool(); + if( rValue >>= bResizeProtect ) + { + mpObj->SetResizeProtect(bResizeProtect); + return true; + } + break; + } + case OWN_ATTR_PAGE_NUMBER: + { + sal_Int32 nPageNum = 0; + if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) ) + { + SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get()); + if( pPageObj ) + { + SdrModel* pModel = pPageObj->GetModel(); + SdrPage* pNewPage = 0L; + const sal_uInt16 nDestinationPageNum((sal_uInt16)((nPageNum << 1L) - 1L)); + + if(pModel) + { + if(nDestinationPageNum < pModel->GetPageCount()) + { + pNewPage = pModel->GetPage(nDestinationPageNum); + } + } + + pPageObj->SetReferencedPage(pNewPage); + } + + return true; + } + break; + } + case XATTR_FILLBITMAP: + case XATTR_FILLGRADIENT: + case XATTR_FILLHATCH: + case XATTR_FILLFLOATTRANSPARENCE: + case XATTR_LINEEND: + case XATTR_LINESTART: + case XATTR_LINEDASH: + { + if( pProperty->nMemberId == MID_NAME ) + { + OUString aApiName; + if( rValue >>= aApiName ) + { + if( SetFillAttribute( pProperty->nWID, aApiName ) ) + return true; + } + break; + } + else + { + return false; + } + } + default: + { + return false; + } + } + throw lang::IllegalArgumentException(); +} + +//---------------------------------------------------------------------- + +bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + switch( pProperty->nWID ) + { +/* + case OWN_ATTR_HASLEVELS: + { + rValue <<= SvxTextEditSource::hasLevels( mpObj.get() ); + break; + } +*/ + case OWN_ATTR_CAPTION_POINT: + { + Point aVclPoint = ((SdrCaptionObj*)mpObj.get())->GetTailPos(); + + // #88491# make pos relative to anchor + if( mpModel->IsWriter() ) + { + aVclPoint -= mpObj->GetAnchorPos(); + } + + // #88657# metric of pool maybe twips (writer) + ForceMetricTo100th_mm(aVclPoint); + + // #90763# pos is absolute, make it relative to top left + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + + aVclPoint.X() -= basegfx::fround(aNewHomogenMatrix.get(0, 2)); + aVclPoint.Y() -= basegfx::fround(aNewHomogenMatrix.get(1, 2)); + + awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() ); + rValue <<= aPnt; + break; + } + + case OWN_ATTR_TRANSFORMATION: + { + basegfx::B2DPolyPolygon aNewPolyPolygon; + basegfx::B2DHomMatrix aNewHomogenMatrix; + mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + drawing::HomogenMatrix3 aMatrix; + + aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0); + aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1); + aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2); + aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0); + aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1); + aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2); + aMatrix.Line3.Column1 = aNewHomogenMatrix.get(2, 0); + aMatrix.Line3.Column2 = aNewHomogenMatrix.get(2, 1); + aMatrix.Line3.Column3 = aNewHomogenMatrix.get(2, 2); + + rValue <<= aMatrix; + + break; + } + + case OWN_ATTR_ZORDER: + { + rValue <<= (sal_Int32)mpObj->GetOrdNum(); + break; + } + + case OWN_ATTR_BITMAP: + { + rValue = GetBitmap(); + if(!rValue.hasValue()) + throw uno::RuntimeException(); + + break; + } + + case OWN_ATTR_ISFONTWORK: + { + rValue <<= (sal_Bool)(mpObj->ISA(SdrTextObj) && ((SdrTextObj*)mpObj.get())->IsFontwork()); + break; + } + + case OWN_ATTR_FRAMERECT: + { + Rectangle aRect( mpObj->GetSnapRect() ); + Point aTopLeft( aRect.TopLeft() ); + Size aObjSize( aRect.GetWidth(), aRect.GetHeight() ); + ForceMetricTo100th_mm(aTopLeft); + ForceMetricTo100th_mm(aObjSize); + ::com::sun::star::awt::Rectangle aUnoRect( + aTopLeft.X(), aTopLeft.Y(), + aObjSize.getWidth(), aObjSize.getHeight() ); + rValue <<= aUnoRect; + break; + } + + case OWN_ATTR_BOUNDRECT: + { + Rectangle aRect( mpObj->GetCurrentBoundRect() ); + Point aTopLeft( aRect.TopLeft() ); + Size aObjSize( aRect.GetWidth(), aRect.GetHeight() ); + ForceMetricTo100th_mm(aTopLeft); + ForceMetricTo100th_mm(aObjSize); + ::com::sun::star::awt::Rectangle aUnoRect( + aTopLeft.X(), aTopLeft.Y(), + aObjSize.getWidth(), aObjSize.getHeight() ); + rValue <<= aUnoRect; + break; + } + + case OWN_ATTR_LDNAME: + { + OUString aName( mpObj->GetName() ); + rValue <<= aName; + break; + } + + case OWN_ATTR_LDBITMAP: + { + sal_uInt16 nId; + if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_OLE2 ) + { + nId = RID_UNODRAW_OLE2; + } + else if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_GRAF ) + { + nId = RID_UNODRAW_GRAPHICS; + } + else + { + nId = RID_UNODRAW_OBJECTS; + } + + BitmapEx aBmp( SVX_RES(nId) ); + Reference< awt::XBitmap > xBmp( VCLUnoHelper::CreateBitmap( aBmp ) ); + + rValue <<= xBmp; + break; + } + + case OWN_ATTR_MIRRORED: + { + sal_Bool bMirror = sal_False; + if( mpObj.is() && mpObj->ISA(SdrGrafObj) ) + bMirror = ((SdrGrafObj*)mpObj.get())->IsMirrored(); + + rValue <<= bMirror; + } + + case OWN_ATTR_EDGE_START_OBJ: + case OWN_ATTR_EDGE_START_POS: + case OWN_ATTR_EDGE_END_POS: + case OWN_ATTR_EDGE_END_OBJ: + case OWN_ATTR_GLUEID_HEAD: + case OWN_ATTR_GLUEID_TAIL: + case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: + { + SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get()); + if(pEdgeObj) + { + switch(pProperty->nWID) + { + case OWN_ATTR_EDGE_START_OBJ: + case OWN_ATTR_EDGE_END_OBJ: + { + SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ); + if(pNode) + { + Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) ); + if(xShape.is()) + rValue <<= xShape; + + } + break; + } + + case OWN_ATTR_EDGE_START_POS: + case OWN_ATTR_EDGE_END_POS: + { + Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) ); + if( mpModel->IsWriter() ) + aPoint -= mpObj->GetAnchorPos(); + + ForceMetricTo100th_mm( aPoint ); + awt::Point aUnoPoint( aPoint.X(), aPoint.Y() ); + + rValue <<= aUnoPoint; + break; + } + case OWN_ATTR_GLUEID_HEAD: + case OWN_ATTR_GLUEID_TAIL: + { + rValue <<= pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD ); + break; + } + case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: + { + basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() ); + if( mpModel->IsWriter() ) + { + Point aPoint( mpObj->GetAnchorPos() ); + aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y())); + } + drawing::PolyPolygonBezierCoords aRetval; + SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval); + rValue <<= aRetval; + break; + } + } + } + break; + } + + case OWN_ATTR_MEASURE_START_POS: + case OWN_ATTR_MEASURE_END_POS: + { + SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get()); + if(pMeasureObj) + { + Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) ); + if( mpModel->IsWriter() ) + aPoint -= mpObj->GetAnchorPos(); + + awt::Point aUnoPoint( aPoint.X(), aPoint.Y() ); + + rValue <<= aUnoPoint; + break; + } + break; + } + + case OWN_ATTR_FILLBMP_MODE: + { + const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet(); + + XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&rObjItemSet.Get(XATTR_FILLBMP_STRETCH); + XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&rObjItemSet.Get(XATTR_FILLBMP_TILE); + + if( pTileItem && pTileItem->GetValue() ) + { + rValue <<= drawing::BitmapMode_REPEAT; + } + else if( pStretchItem && pStretchItem->GetValue() ) + { + rValue <<= drawing::BitmapMode_STRETCH; + } + else + { + rValue <<= drawing::BitmapMode_NO_REPEAT; + } + break; + } + case SDRATTR_LAYERID: + rValue <<= (sal_Int16)mpObj->GetLayer(); + break; + + case SDRATTR_LAYERNAME: + { + SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer()); + if( pLayer ) + { + OUString aName( pLayer->GetName() ); + rValue <<= aName; + } + break; + } + + case SDRATTR_ROTATEANGLE: + rValue <<= mpObj->GetRotateAngle(); + break; + + case SDRATTR_SHEARANGLE: + rValue <<= mpObj->GetShearAngle(); + break; + + case SDRATTR_OBJMOVEPROTECT: + rValue = uno::makeAny( (sal_Bool) mpObj->IsMoveProtect() ); + break; + + case SDRATTR_OBJECTNAME: + { + OUString aName( mpObj->GetName() ); + rValue <<= aName; + break; + } + + // #i68101# + case OWN_ATTR_MISC_OBJ_TITLE: + { + OUString aTitle( mpObj->GetTitle() ); + rValue <<= aTitle; + break; + } + + case OWN_ATTR_MISC_OBJ_DESCRIPTION: + { + OUString aDescription( mpObj->GetDescription() ); + rValue <<= aDescription; + break; + } + + case SDRATTR_OBJPRINTABLE: + rValue = uno::makeAny( (sal_Bool) mpObj->IsPrintable() ); + break; + + case SDRATTR_OBJSIZEPROTECT: + rValue = uno::makeAny( (sal_Bool)mpObj->IsResizeProtect() ); + break; + + case OWN_ATTR_PAGE_NUMBER: + { + SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get()); + if(pPageObj) + { + SdrPage* pPage = pPageObj->GetReferencedPage(); + sal_Int32 nPageNumber = (pPage) ? pPage->GetPageNum() : 0L; + nPageNumber++; + nPageNumber >>= 1; + rValue <<= nPageNumber; + } + break; + } + + case OWN_ATTR_UINAME_SINGULAR: + { + String aTmp; + mpObj->TakeObjNameSingul( aTmp ); + rValue <<= OUString( aTmp ); + break; + } + + case OWN_ATTR_UINAME_PLURAL: + { + String aTmp; + mpObj->TakeObjNamePlural( aTmp ); + rValue <<= OUString( aTmp ); + break; + } + case OWN_ATTR_METAFILE: + { + SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get()); + if( pObj ) + { + Graphic* pGraphic = pObj->GetGraphic(); + if( pGraphic ) + { + BOOL bIsWMF = FALSE; + if ( pGraphic->IsLink() ) + { + GfxLink aLnk = pGraphic->GetLink(); + if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF ) + { + bIsWMF = TRUE; + uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize()); + rValue <<= aSeq; + } + } + if ( !bIsWMF ) + { + GDIMetaFile aMtf; + if ( pGraphic->GetType() != GRAPHIC_BITMAP ) + aMtf = pObj->GetGraphic()->GetGDIMetaFile(); + else + { + VirtualDevice aVirDev; + aMtf.Record( &aVirDev ); + pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() ); + aMtf.Stop(); + aMtf.SetPrefSize( pGraphic->GetPrefSize() ); + aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() ); + } + SvMemoryStream aDestStrm( 65535, 65535 ); + ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); + rValue <<= aSeq; + } + } + } + else + { + rValue = GetBitmap( sal_True ); + } + break; + } + + + default: + return false; + } + return true; +} + +//---------------------------------------------------------------------- + +bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE ) + { + const SfxItemSet& rSet = mpObj->GetMergedItemSet(); + + if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET || + rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET ) + { + rState = beans::PropertyState_DIRECT_VALUE; + } + else + { + rState = beans::PropertyState_AMBIGUOUS_VALUE; + } + } + else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) || + ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) ) + { + rState = beans::PropertyState_DIRECT_VALUE; + } + else + { + return false; + } + + return true; +} + +//---------------------------------------------------------------------- + +bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE ) + { + mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH ); + mpObj->ClearMergedItem( XATTR_FILLBMP_TILE ); + return true; + } + else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) || + ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) + { + return true; + } + else + { + return false; + } +} + +//---------------------------------------------------------------------- + +uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + const sal_Int32 nCount = aPropertyName.getLength(); + const OUString* pNames = aPropertyName.getConstArray(); + + uno::Sequence< beans::PropertyState > aRet( nCount ); + beans::PropertyState* pState = aRet.getArray(); + + if( mpImpl->mpMaster ) + { + for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ ) + pState[nIdx] = getPropertyState( pNames[nIdx] ); + + } + else + { + for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ ) + pState[nIdx] = getPropertyState( pNames[nIdx] ); + } + + return aRet; +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + mpImpl->mpMaster->setPropertyToDefault( PropertyName ); + } + else + { + _setPropertyToDefault( PropertyName ); + } +} + +void SAL_CALL SvxShape::_setPropertyToDefault( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName); + + if( !mpObj.is() || mpModel == NULL || pProperty == NULL ) + throw beans::UnknownPropertyException(); + + if( !setPropertyToDefaultImpl( pProperty ) ) + { + mpObj->ClearMergedItem( pProperty->nWID ); + } + + mpModel->SetChanged(); +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName ) + throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + return mpImpl->mpMaster->getPropertyDefault( aPropertyName ); + } + else + { + return _getPropertyDefault( aPropertyName ); + } +} + +uno::Any SAL_CALL SvxShape::_getPropertyDefault( const OUString& aPropertyName ) + throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName); + + if( !mpObj.is() || pMap == NULL || mpModel == NULL ) + throw beans::UnknownPropertyException(); + + if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) || + ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST )) + { + return getPropertyValue( aPropertyName ); + } + + // Default aus ItemPool holen + if(!mpModel->GetItemPool().IsWhich(pMap->nWID)) + throw beans::UnknownPropertyException(); + + SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID); + aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); + + return GetAnyForItem( aSet, pMap ); +} + +// XMultiPropertyStates +void SvxShape::setAllPropertiesToDefault() throw (uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( !mpObj.is() ) + throw lang::DisposedException(); + mpObj->ClearMergedItem(); // nWhich == 0 => all + + if(mpObj->ISA(SdrGrafObj)) + { + // defaults for graphic objects have changed: + mpObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) ); + mpObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) ); + } + + // #i68523# special handling for Svx3DCharacterModeItem, this is not saved + // but needs to be TRUE in svx, pool default (false) in sch. Since sch + // does not load lathe or extrude objects, it is possible to set the items + // here. + // For other solution possibilities, see task description. + if(mpObj->ISA(E3dLatheObj) || mpObj->ISA(E3dExtrudeObj)) + { + mpObj->SetMergedItem(Svx3DCharacterModeItem(true)); + } + + mpModel->SetChanged(); +} + +void SvxShape::setPropertiesToDefault( + const uno::Sequence<OUString>& aPropertyNames ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos ) + setPropertyToDefault( aPropertyNames[pos] ); +} + +uno::Sequence<uno::Any> SvxShape::getPropertyDefaults( + const uno::Sequence<OUString>& aPropertyNames ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + ::std::vector<uno::Any> ret; + for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos ) + ret.push_back( getPropertyDefault( aPropertyNames[pos] ) ); + return uno::Sequence<uno::Any>( &ret[0], ret.size() ); +} + +//---------------------------------------------------------------------- + +//---------------------------------------------------------------------- +// XServiceInfo +//---------------------------------------------------------------------- +OUString SAL_CALL SvxShape::getImplementationName() + throw(uno::RuntimeException) +{ + static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShape") ); + return aServiceName; +} + +#define STAR_NAMESPACE "com.sun.star." + +const char* sUNO_service_style_ParagraphProperties = STAR_NAMESPACE "style.ParagraphProperties"; +const char* sUNO_service_style_ParagraphPropertiesComplex = STAR_NAMESPACE "style.ParagraphPropertiesComplex"; +const char* sUNO_service_style_ParagraphPropertiesAsian = STAR_NAMESPACE "style.ParagraphPropertiesAsian"; +const char* sUNO_service_style_CharacterProperties = STAR_NAMESPACE "style.CharacterProperties"; +const char* sUNO_service_style_CharacterPropertiesComplex = STAR_NAMESPACE "style.CharacterPropertiesComplex"; +const char* sUNO_service_style_CharacterPropertiesAsian = STAR_NAMESPACE "style.CharacterPropertiesAsian"; + +const char* sUNO_service_drawing_FillProperties = STAR_NAMESPACE "drawing.FillProperties"; +const char* sUNO_service_drawing_TextProperties = STAR_NAMESPACE "drawing.TextProperties"; +const char* sUNO_service_drawing_LineProperties = STAR_NAMESPACE "drawing.LineProperties"; +const char* sUNO_service_drawing_ConnectorProperties = STAR_NAMESPACE "drawing.ConnectorProperties"; +const char* sUNO_service_drawing_MeasureProperties = STAR_NAMESPACE "drawing.MeasureProperties"; +const char* sUNO_service_drawing_ShadowProperties = STAR_NAMESPACE "drawing.ShadowProperties"; + +const char* sUNO_service_drawing_RotationDescriptor = STAR_NAMESPACE "drawing.RotationDescriptor"; + +const char* sUNO_service_drawing_Text = STAR_NAMESPACE "drawing.Text"; +const char* sUNO_service_drawing_GroupShape = STAR_NAMESPACE "drawing.GroupShape"; + +const char* sUNO_service_drawing_CustomShapeProperties = STAR_NAMESPACE "drawing.CustomShapeProperties"; +const char* sUNO_service_drawing_CustomShape = STAR_NAMESPACE "drawing.CustomShape"; + +const char* sUNO_service_drawing_PolyPolygonDescriptor = STAR_NAMESPACE "drawing.PolyPolygonDescriptor"; +const char* sUNO_service_drawing_PolyPolygonBezierDescriptor= STAR_NAMESPACE "drawing.PolyPolygonBezierDescriptor"; + +const char* sUNO_service_drawing_LineShape = STAR_NAMESPACE "drawing.LineShape"; +const char* sUNO_service_drawing_Shape = STAR_NAMESPACE "drawing.Shape"; +const char* sUNO_service_drawing_RectangleShape = STAR_NAMESPACE "drawing.RectangleShape"; +const char* sUNO_service_drawing_EllipseShape = STAR_NAMESPACE "drawing.EllipseShape"; +const char* sUNO_service_drawing_PolyPolygonShape = STAR_NAMESPACE "drawing.PolyPolygonShape"; +const char* sUNO_service_drawing_PolyLineShape = STAR_NAMESPACE "drawing.PolyLineShape"; +const char* sUNO_service_drawing_OpenBezierShape = STAR_NAMESPACE "drawing.OpenBezierShape"; +const char* sUNO_service_drawing_ClosedBezierShape = STAR_NAMESPACE "drawing.ClosedBezierShape"; +const char* sUNO_service_drawing_TextShape = STAR_NAMESPACE "drawing.TextShape"; +const char* sUNO_service_drawing_GraphicObjectShape = STAR_NAMESPACE "drawing.GraphicObjectShape"; +const char* sUNO_service_drawing_OLE2Shape = STAR_NAMESPACE "drawing.OLE2Shape"; +const char* sUNO_service_drawing_PageShape = STAR_NAMESPACE "drawing.PageShape"; +const char* sUNO_service_drawing_CaptionShape = STAR_NAMESPACE "drawing.CaptionShape"; +const char* sUNO_service_drawing_MeasureShape = STAR_NAMESPACE "drawing.MeasureShape"; +const char* sUNO_service_drawing_FrameShape = STAR_NAMESPACE "drawing.FrameShape"; +const char* sUNO_service_drawing_ControlShape = STAR_NAMESPACE "drawing.ControlShape"; +const char* sUNO_service_drawing_ConnectorShape = STAR_NAMESPACE "drawing.ConnectorShape"; +const char* sUNO_service_drawing_MediaShape = STAR_NAMESPACE "drawing.MediaShape"; + + +uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + if( mpImpl->mpMaster ) + { + return mpImpl->mpMaster->getSupportedServiceNames(); + } + else + { + return _getSupportedServiceNames(); + } +} + +uno::Sequence< OUString > SAL_CALL SvxShape::_getSupportedServiceNames() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor) + { + const UINT16 nIdent = mpObj->GetObjIdentifier(); + + switch(nIdent) + { + case OBJ_GRUP: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_GroupServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, 2, + sUNO_service_drawing_GroupShape, + sUNO_service_drawing_Shape ); + + pSeq = &SvxShape_GroupServices; + } + } + + return *pSeq; + } + case OBJ_CUSTOMSHAPE: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_CustomShapeServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, 13, + sUNO_service_drawing_CustomShape, + sUNO_service_drawing_Shape, + sUNO_service_drawing_CustomShapeProperties, + sUNO_service_drawing_FillProperties, + sUNO_service_drawing_LineProperties, + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + pSeq = &SvxShape_CustomShapeServices; + } + } + return *pSeq; + } + case OBJ_LINE: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_LineServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices,14, + sUNO_service_drawing_LineShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_PolyPolygonDescriptor, + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_LineServices; + } + } + return *pSeq; + } + + case OBJ_RECT: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_RectServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices,14, + sUNO_service_drawing_RectangleShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_FillProperties, + sUNO_service_drawing_LineProperties, + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + pSeq = &SvxShape_RectServices; + } + + } + return *pSeq; + } + + case OBJ_CIRC: + case OBJ_SECT: + case OBJ_CARC: + case OBJ_CCUT: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_CircServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices,14, + sUNO_service_drawing_EllipseShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_FillProperties, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_CircServices; + } + } + + return *pSeq; + } + + case OBJ_PATHPLIN: + case OBJ_PLIN: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_PathServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices,14, + sUNO_service_drawing_PolyLineShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_PolyPolygonDescriptor, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + pSeq = &SvxShape_PathServices; + } + } + return *pSeq; + } + + case OBJ_PATHPOLY: + case OBJ_POLY: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_PolyServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices,15, + sUNO_service_drawing_PolyPolygonShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + sUNO_service_drawing_FillProperties, + + sUNO_service_drawing_PolyPolygonDescriptor, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_PolyServices; + } + } + return *pSeq; + } + + case OBJ_FREELINE: + case OBJ_PATHLINE: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_FreeLineServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices,15, + sUNO_service_drawing_OpenBezierShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + sUNO_service_drawing_FillProperties, + + sUNO_service_drawing_PolyPolygonBezierDescriptor, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_FreeLineServices; + } + } + + return *pSeq; + } + + case OBJ_FREEFILL: + case OBJ_PATHFILL: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_FreeFillServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices,15, + sUNO_service_drawing_ClosedBezierShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + sUNO_service_drawing_FillProperties, + + sUNO_service_drawing_PolyPolygonBezierDescriptor, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_FreeFillServices; + } + } + return *pSeq; + } + + case OBJ_OUTLINETEXT: + case OBJ_TITLETEXT: + case OBJ_TEXT: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_TextServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices,14, + sUNO_service_drawing_TextShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_FillProperties, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_TextServices; + } + } + return *pSeq; + } + + case OBJ_GRAF: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_GrafServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, 12, + sUNO_service_drawing_GraphicObjectShape, + + sUNO_service_drawing_Shape, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_GrafServices; + } + } + return *pSeq; + } + + case OBJ_OLE2: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_Ole2Services; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, 2, + sUNO_service_drawing_OLE2Shape, + sUNO_service_drawing_Shape); + + pSeq = &SvxShape_Ole2Services; + } + } + return *pSeq; + } + + case OBJ_CAPTION: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_CaptionServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices,14, + sUNO_service_drawing_CaptionShape, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_FillProperties, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_CaptionServices; + } + } + + return *pSeq; + } + + case OBJ_PAGE: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_PageServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, 2, + sUNO_service_drawing_PageShape, + sUNO_service_drawing_Shape ); + + pSeq = &SvxShape_PageServices; + } + } + + return *pSeq; + } + + case OBJ_MEASURE: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_MeasureServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices,15, + sUNO_service_drawing_MeasureShape, + + sUNO_service_drawing_MeasureProperties, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_PolyPolygonDescriptor, + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_MeasureServices; + } + } + + return *pSeq; + } + + case OBJ_FRAME: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_FrameServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, 2, + sUNO_service_drawing_FrameShape, + sUNO_service_drawing_Shape ); + + pSeq = &SvxShape_FrameServices; + } + } + + return *pSeq; + } + + case OBJ_UNO: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard _aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_UnoServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2, + sUNO_service_drawing_ControlShape, + sUNO_service_drawing_Shape ); + + pSeq = &SvxShape_UnoServices; + } + } + return *pSeq; + } + + case OBJ_EDGE: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_EdgeServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices,15, + sUNO_service_drawing_ConnectorShape, + sUNO_service_drawing_ConnectorProperties, + + sUNO_service_drawing_Shape, + sUNO_service_drawing_LineProperties, + + sUNO_service_drawing_Text, + sUNO_service_drawing_TextProperties, + sUNO_service_style_ParagraphProperties, + sUNO_service_style_ParagraphPropertiesComplex, + sUNO_service_style_ParagraphPropertiesAsian, + sUNO_service_style_CharacterProperties, + sUNO_service_style_CharacterPropertiesComplex, + sUNO_service_style_CharacterPropertiesAsian, + + sUNO_service_drawing_PolyPolygonDescriptor, + sUNO_service_drawing_ShadowProperties, + sUNO_service_drawing_RotationDescriptor); + + pSeq = &SvxShape_EdgeServices; + } + } + return *pSeq; + } + case OBJ_MEDIA: + { + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_MediaServices; + + comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, 2, + sUNO_service_drawing_MediaShape, + sUNO_service_drawing_Shape); + + pSeq = &SvxShape_MediaServices; + } + } + return *pSeq; + } + } + } + else if( mpObj.is() && mpObj->GetObjInventor() == FmFormInventor) + { +#if OSL_DEBUG_LEVEL > 0 + const UINT16 nIdent = mpObj->GetObjIdentifier(); + OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: FmFormInventor, but no UNO object?" ); +#endif + static uno::Sequence< OUString > *pSeq = 0; + if( 0 == pSeq ) + { +// OGuard aGuard( Application::GetSolarMutex() ); +// if( 0 == pSeq ) + { + static uno::Sequence< OUString > SvxShape_UnoServices; + comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2, + sUNO_service_drawing_ControlShape, + sUNO_service_drawing_Shape ); + + pSeq = &SvxShape_UnoServices; + } + } + return *pSeq; + } + OSL_ENSURE( false, "SvxShape::_getSupportedServiceNames: could not determine object type!" ); + uno::Sequence< OUString > aSeq; + return aSeq; +} + +//---------------------------------------------------------------------- +sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException ) +{ + Sequence< OUString > SupportedServices( getSupportedServiceNames() ); + const ::rtl::OUString * pArray = SupportedServices.getConstArray(); + const sal_Int32 nCount = SupportedServices.getLength(); + sal_Int32 i; + for( i = 0; i < nCount; i++ ) + if( *pArray++ == ServiceName ) + return sal_True; + return sal_False; +} + +//---------------------------------------------------------------------- + +// XGluePointsSupplier +uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints ); + + if( mpObj.is() && !xGluePoints.is() ) + { + uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY ); + mxGluePoints = xGluePoints = xNew; + } + + return xGluePoints; +} + +//---------------------------------------------------------------------- + +// XChild +uno::Reference< uno::XInterface > SAL_CALL SvxShape::getParent( ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mpObj.is() && mpObj->GetObjList() ) + { + SdrObjList* pObjList = mpObj->GetObjList(); + + switch( pObjList->GetListKind() ) + { + case SDROBJLIST_GROUPOBJ: + if( pObjList->GetOwnerObj()->ISA( SdrObjGroup ) ) + return PTR_CAST( SdrObjGroup, pObjList->GetOwnerObj())->getUnoShape(); + else if( pObjList->GetOwnerObj()->ISA( E3dScene ) ) + return PTR_CAST( E3dScene, pObjList->GetOwnerObj())->getUnoShape(); + break; + case SDROBJLIST_DRAWPAGE: + case SDROBJLIST_MASTERPAGE: + return PTR_CAST( SdrPage, pObjList )->getUnoPage(); + default: + DBG_ERROR( "SvxShape::getParent( ): unexpected SdrObjListKind" ); + break; + } + } + + uno::Reference< uno::XInterface > xParent; + return xParent; +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& ) + throw(lang::NoSupportException, uno::RuntimeException) +{ + throw lang::NoSupportException(); +} + +//---------------------------------------------------------------------- + +/** called from the XActionLockable interface methods on initial locking */ +void SvxShape::lock() +{ +} + +//---------------------------------------------------------------------- + +/** called from the XActionLockable interface methods on final unlock */ +void SvxShape::unlock() +{ +} + +//---------------------------------------------------------------------- + +// XActionLockable +sal_Bool SAL_CALL SvxShape::isActionLocked( ) throw (::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + return mnLockCount != 0; +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::addActionLock( ) throw (::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" ); + mnLockCount++; + + if( mnLockCount == 1 ) + lock(); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::removeActionLock( ) throw (::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" ); + mnLockCount--; + + if( mnLockCount == 0 ) + unlock(); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock ) throw (::com::sun::star::uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mnLockCount == 0) && (nLock != 0) ) + unlock(); + + if( (mnLockCount != 0) && (nLock == 0) ) + lock(); + + mnLockCount = (sal_uInt16)nLock; +} + +//---------------------------------------------------------------------- + +sal_Int16 SAL_CALL SvxShape::resetActionLocks( ) throw (::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( mnLockCount != 0 ) + unlock(); + + sal_Int16 nOldLocks = (sal_Int16)mnLockCount; + mnLockCount = 0; + + return nOldLocks; +} + +//---------------------------------------------------------------------- + +/** since polygon shapes can change theire kind during editing, we have + to recheck it here. + Circle shapes also change theire kind, but theire all treated equal + so no update is necessary. +*/ +void SvxShape::updateShapeKind() +{ + switch( mpImpl->mnObjId ) + { + case OBJ_LINE: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + { + const sal_uInt32 nId = mpObj->GetObjIdentifier(); + + if( nId != mpImpl->mnObjId ) + { + mpImpl->mnObjId = nId; + + } + break; + } + }; +} + +/*********************************************************************** +* class SvxShapeText * +***********************************************************************/ +SvxShapeText::SvxShapeText() throw () +: SvxShape(NULL, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) +{ +} + +//---------------------------------------------------------------------- +SvxShapeText::SvxShapeText( SdrObject* pObject ) throw () +: SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) +{ + if( pObject && pObject->GetModel() ) + SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) ); +} + +//---------------------------------------------------------------------- +SvxShapeText::SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw () +: SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) +{ + if( pObject && pObject->GetModel() ) + SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) ); +} + +//---------------------------------------------------------------------- +SvxShapeText::~SvxShapeText() throw () +{ + // check if only this instance is registered at the ranges + DBG_ASSERT( (NULL == GetEditSource()) || (GetEditSource()->getRanges().size()==1), + "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!"); +} + +void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) +{ + if( pNewObj && (NULL == GetEditSource())) + SetEditSource( new SvxTextEditSource( pNewObj, 0, static_cast< uno::XWeak* >(this) ) ); + + SvxShape::Create( pNewObj, pNewPage ); +} + +// XInterface +//---------------------------------------------------------------------- +uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType ) + throw( uno::RuntimeException ) +{ + return SvxShape::queryInterface( rType ); +} + +//---------------------------------------------------------------------- + +uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType ) + throw( uno::RuntimeException ) +{ + uno::Any aAny( SvxShape::queryAggregation( rType ) ); + if( aAny.hasValue() ) + return aAny; + + return SvxUnoTextBase::queryAggregation( rType ); +} + +//---------------------------------------------------------------------- + +void SAL_CALL SvxShapeText::acquire() throw() +{ + SvxShape::acquire(); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeText::release() throw() +{ + SvxShape::release(); +} + +// XServiceInfo +//---------------------------------------------------------------------- +OUString SAL_CALL SvxShapeText::getImplementationName() throw( uno::RuntimeException ) +{ + static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShapeText") ); + return aServiceName; +} + +//---------------------------------------------------------------------- +uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return SvxShape::getSupportedServiceNames(); +} + +//---------------------------------------------------------------------- +sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException ) +{ + return SvxShape::supportsService(ServiceName); +} + + // XTypeProvider +//---------------------------------------------------------------------- +uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes() + throw( uno::RuntimeException ) +{ + return SvxShape::getTypes(); +} + +sal_Int64 SAL_CALL SvxShapeText::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) \ +{ + const sal_Int64 nReturn = SvxShape::getSomething( rId ); + if( nReturn ) + return nReturn; + + return SvxUnoTextBase::getSomething( rId ); +} + +//---------------------------------------------------------------------- +uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId() + throw( uno::RuntimeException ) +{ + static ::cppu::OImplementationId* pID = NULL ; + + if ( pID == NULL ) + { + // Ready for multithreading; get global mutex for first call of this method only! see before + MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; + + // Control these pointer again ... it can be, that another instance will be faster then these! + if ( pID == NULL ) + { + // Create a new static ID ... + static ::cppu::OImplementationId aID( sal_False ) ; + // ... and set his address to static pointer! + pID = &aID ; + } + } + + return pID->getImplementationId() ; +} + +//---------------------------------------------------------------------- + +/** called from the XActionLockable interface methods on initial locking */ +void SvxShapeText::lock() +{ + SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource(); + if( pEditSource ) + pEditSource->lock(); +} + +//---------------------------------------------------------------------- + +/** called from the XActionLockable interface methods on final unlock */ +void SvxShapeText::unlock() +{ + SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource(); + if( pEditSource ) + pEditSource->unlock(); +} + +// ::com::sun::star::text::XTextRange +uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart() throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; + if( pForwarder ) + ::GetSelection( maSelection, pForwarder ); + return SvxUnoTextBase::getStart(); + +} + +uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd() throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; + if( pForwarder ) + ::GetSelection( maSelection, pForwarder ); + return SvxUnoTextBase::getEnd(); +} + +OUString SAL_CALL SvxShapeText::getString() throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; + if( pForwarder ) + ::GetSelection( maSelection, pForwarder ); + return SvxUnoTextBase::getString(); +} + + +void SAL_CALL SvxShapeText::setString( const OUString& aString ) throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; + if( pForwarder ) + ::GetSelection( maSelection, pForwarder ); + SvxUnoTextBase::setString( aString ); +} + +// overide these for special property handling in subcasses. Return true if property is handled +bool SvxShapeText::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + // HACK-fix #99090# + // since SdrTextObj::SetVerticalWriting exchanges + // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT, + // we have to set the textdirection here + + if( pProperty->nWID == SDRATTR_TEXTDIRECTION ) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() ); + if( pTextObj ) + { + com::sun::star::text::WritingMode eMode; + if( rValue >>= eMode ) + { + pTextObj->SetVerticalWriting( eMode == com::sun::star::text::WritingMode_TB_RL ); + } + } + return true; + } + return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); +} + +bool SvxShapeText::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if( pProperty->nWID == SDRATTR_TEXTDIRECTION ) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() ); + if( pTextObj && pTextObj->IsVerticalWriting() ) + rValue <<= com::sun::star::text::WritingMode_TB_RL; + else + rValue <<= com::sun::star::text::WritingMode_LR_TB; + return true; + } + + return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); +} + +bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + return SvxShape::getPropertyStateImpl( pProperty, rState ); +} + +bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + return SvxShape::setPropertyToDefaultImpl( pProperty ); +} + +/*********************************************************************** +* class SvxShapeRect * +***********************************************************************/ +DBG_NAME(SvxShapeRect) +SvxShapeRect::SvxShapeRect( SdrObject* pObj ) throw() +: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_SHAPE), aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool())) +{ + DBG_CTOR(SvxShapeRect,NULL); +} + +SvxShapeRect::~SvxShapeRect() throw() +{ + DBG_DTOR(SvxShapeRect,NULL); +} + +uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) +{ + return SvxShapeText::queryInterface( rType ); +} + +uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) +{ + return SvxShapeText::queryAggregation( rType ); +} + +void SAL_CALL SvxShapeRect::acquire() throw() +{ + OWeakAggObject::acquire(); +} + +void SAL_CALL SvxShapeRect::release() throw() +{ + OWeakAggObject::release(); +} +//---------------------------------------------------------------------- +// XServiceInfo +//---------------------------------------------------------------------- +uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames(void) throw( uno::RuntimeException ) +{ + return SvxShape::getSupportedServiceNames(); +} + +/** returns a StarOffice API wrapper for the given SdrObject */ +uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw () +{ + uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY ); + return xShape; +} + +/** returns the SdrObject from the given StarOffice API wrapper */ +SdrObject* GetSdrObjectFromXShape( uno::Reference< drawing::XShape > xShape ) throw() +{ + SvxShape* pShape = SvxShape::getImplementation( xShape ); + return pShape ? pShape->GetSdrObject() : 0; +} + +//---------------------------------------------------------------------- + +SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt ) +{ + SvxShape* pSvxShape = SvxShape::getImplementation( xInt ); + return pSvxShape ? pSvxShape->GetSdrObject() : 0; +} + +uno::Any SvxItemPropertySet_getPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet ) +{ + if(!pMap || !pMap->nWID) + return uno::Any(); + + // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ. + bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY ); + return rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues ); +} + +void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet ) +{ + if(!pMap || !pMap->nWID) + return; + + bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY ); + rPropSet.setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues ); +} diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx new file mode 100644 index 000000000000..3b45753175e6 --- /dev/null +++ b/svx/source/unodraw/unoshcol.cxx @@ -0,0 +1,258 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/document/EventObject.hpp> + +#include "unoshcol.hxx" +#include <svx/unoprov.hxx> +#include <comphelper/serviceinfohelper.hxx> + +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::drawing; + +/*********************************************************************** +* * +***********************************************************************/ +SvxShapeCollection::SvxShapeCollection() throw() +: maShapeContainer( maMutex ), mrBHelper( maMutex ) +{ +} + +//---------------------------------------------------------------------- +SvxShapeCollection::~SvxShapeCollection() throw() +{ +} + + +//---------------------------------------------------------------------- +Reference< uno::XInterface > SvxShapeCollection_NewInstance() throw() +{ + Reference< drawing::XShapes > xShapes( new SvxShapeCollection() ); + Reference< uno::XInterface > xRef( xShapes, UNO_QUERY ); + return xRef; +} + +// XInterface +void SvxShapeCollection::release() throw() +{ + uno::Reference< uno::XInterface > x( xDelegator ); + if (! x.is()) + { + if (osl_decrementInterlockedCount( &m_refCount ) == 0) + { + if (! mrBHelper.bDisposed) + { + uno::Reference< uno::XInterface > xHoldAlive( (uno::XWeak*)this ); + // First dispose + try + { + dispose(); + } + catch(::com::sun::star::uno::Exception&) + { + // release should not throw exceptions + } + + // only the alive ref holds the object + OSL_ASSERT( m_refCount == 1 ); + // destroy the object if xHoldAlive decrement the refcount to 0 + return; + } + } + // restore the reference count + osl_incrementInterlockedCount( &m_refCount ); + } + OWeakAggObject::release(); +} + +// XComponent +void SvxShapeCollection::disposing() throw() +{ + maShapeContainer.clear(); +} + +// XComponent +void SvxShapeCollection::dispose() + throw(::com::sun::star::uno::RuntimeException) +{ + // An frequently programming error is to release the last + // reference to this object in the disposing message. + // Make it rubust, hold a self Reference. + uno::Reference< lang::XComponent > xSelf( this ); + + // Guard dispose against multible threading + // Remark: It is an error to call dispose more than once + sal_Bool bDoDispose = sal_False; + { + osl::MutexGuard aGuard( mrBHelper.rMutex ); + if( !mrBHelper.bDisposed && !mrBHelper.bInDispose ) + { + // only one call go into this section + mrBHelper.bInDispose = sal_True; + bDoDispose = sal_True; + } + } + + // Do not hold the mutex because we are broadcasting + if( bDoDispose ) + { + // Create an event with this as sender + try + { + uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( (lang::XComponent *)this ) ); + document::EventObject aEvt; + aEvt.Source = xSource; + // inform all listeners to release this object + // The listener container are automaticly cleared + mrBHelper.aLC.disposeAndClear( aEvt ); + // notify subclasses to do their dispose + disposing(); + } + catch(::com::sun::star::uno::Exception& e) + { + // catch exception and throw again but signal that + // the object was disposed. Dispose should be called + // only once. + mrBHelper.bDisposed = sal_True; + mrBHelper.bInDispose = sal_False; + throw e; + } + + // the values bDispose and bInDisposing must set in this order. + // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard. + mrBHelper.bDisposed = sal_True; + mrBHelper.bInDispose = sal_False; + } + else + { + // in a multithreaded environment, it can't be avoided, that dispose is called twice. + // However this condition is traced, because it MAY indicate an error. + OSL_TRACE( "OComponentHelper::dispose() - dispose called twice" ); + } +} + +// XComponent +void SAL_CALL SvxShapeCollection::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException) +{ + mrBHelper.addListener( ::getCppuType( &aListener ) , aListener ); +} + +// XComponent +void SAL_CALL SvxShapeCollection::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException) +{ + mrBHelper.removeListener( ::getCppuType( &aListener ) , aListener ); +} + +// XShapes +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeCollection::add( const Reference< drawing::XShape >& xShape ) throw( uno::RuntimeException ) +{ + maShapeContainer.addInterface( xShape ); +} + +//---------------------------------------------------------------------- +void SAL_CALL SvxShapeCollection::remove( const uno::Reference< drawing::XShape >& xShape ) throw( uno::RuntimeException ) +{ + maShapeContainer.removeInterface( xShape ); +} + +//---------------------------------------------------------------------- +sal_Int32 SAL_CALL SvxShapeCollection::getCount() throw( uno::RuntimeException ) +{ + return maShapeContainer.getLength(); +} + +//---------------------------------------------------------------------- +uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index ) + throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +{ + if( Index < 0 || Index >= getCount() ) + throw lang::IndexOutOfBoundsException(); + + uno::Sequence< Reference< uno::XInterface> > xElements( maShapeContainer.getElements() ); + + + return uno::makeAny( Reference< XShape>(static_cast< drawing::XShape* >( xElements.getArray()[Index].get())) ); +} + +// XElementAccess + +//---------------------------------------------------------------------- +uno::Type SAL_CALL SvxShapeCollection::getElementType() throw( uno::RuntimeException ) +{ + return ::getCppuType(( const Reference< drawing::XShape >*)0); +} + +//---------------------------------------------------------------------- +sal_Bool SAL_CALL SvxShapeCollection::hasElements() throw( uno::RuntimeException ) +{ + return getCount() != 0; +} + +//---------------------------------------------------------------------- +// XServiceInfo +//---------------------------------------------------------------------- +::rtl::OUString SAL_CALL SvxShapeCollection::getImplementationName() + throw( uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +::rtl::OUString SvxShapeCollection::getImplementationName_Static() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxShapeCollection") ); +} + +sal_Bool SAL_CALL SvxShapeCollection::supportsService( const ::rtl::OUString& ServiceName ) + throw( uno::RuntimeException ) +{ + return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL SvxShapeCollection::getSupportedServiceNames() throw( uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +uno::Sequence< ::rtl::OUString > SvxShapeCollection::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aSeq(2); + aSeq.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shapes") ); + aSeq.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ShapeCollection") ); + return aSeq; +} + +Reference< XInterface > SAL_CALL SvxShapeCollection_createInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) +{ + return *( new SvxShapeCollection() ); +} diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx new file mode 100644 index 000000000000..05551414507c --- /dev/null +++ b/svx/source/unodraw/unoshtxt.cxx @@ -0,0 +1,1149 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/uno/XInterface.hpp> +#include <vcl/svapp.hxx> + +#include <svx/unoshtxt.hxx> +#include <editeng/unoedhlp.hxx> +#include <svl/lstner.hxx> +#include <rtl/ref.hxx> +#include <osl/mutex.hxx> +#include <svl/hint.hxx> +#include <svl/style.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdview.hxx> +#include <svx/svdetc.hxx> +#include <editeng/outliner.hxx> +#include <editeng/unoforou.hxx> +#include <editeng/unoviwou.hxx> +#include <editeng/outlobj.hxx> +#include <svx/svdotext.hxx> +#include <svx/svdpage.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editobj.hxx> + +#include <editeng/unotext.hxx> +#include <com/sun/star/linguistic2/XLinguServiceManager.hpp> +#include <comphelper/processfactory.hxx> +#include <vos/mutex.hxx> +#include <sdrpaintwindow.hxx> + +using namespace ::osl; +using namespace ::vos; +using namespace ::rtl; + +using ::com::sun::star::uno::XInterface; + +namespace css = ::com::sun::star; + + +//------------------------------------------------------------------------ +// SvxTextEditSourceImpl +//------------------------------------------------------------------------ + +/** @descr + <p>This class essentially provides the text and view forwarders. If + no SdrView is given, this class handles the UNO objects, which are + currently not concerned with view issues. In this case, + GetViewForwarder() always returns NULL and the underlying + EditEngine of the SvxTextForwarder is a background one (i.e. not + the official DrawOutliner, but one created exclusively for this + object, with no relation to a view). + </p> + + <p>If a SdrView is given at construction time, the caller is + responsible for destroying this object when the view becomes + invalid (the views cannot notify). If GetViewForwarder(sal_True) + is called, the underlying shape is put into edit mode, the view + forwarder returned encapsulates the OutlinerView and the next call + to GetTextForwarder() yields a forwarder encapsulating the actual + DrawOutliner. Thus, changes on that Outliner are immediately + reflected on the screen. If the object leaves edit mode, the old + behaviour is restored.</p> + */ +class SvxTextEditSourceImpl : public SfxListener, public SfxBroadcaster, public sdr::ObjectUser +{ +private: + oslInterlockedCount maRefCount; + + SdrObject* mpObject; + SdrText* mpText; + SdrView* mpView; + const Window* mpWindow; + SdrModel* mpModel; + SdrOutliner* mpOutliner; + SvxOutlinerForwarder* mpTextForwarder; + SvxDrawOutlinerViewForwarder* mpViewForwarder; // if non-NULL, use GetViewModeTextForwarder text forwarder + css::uno::Reference< css::linguistic2::XLinguServiceManager > m_xLinguServiceManager; + Point maTextOffset; + BOOL mbDataValid; + BOOL mbDestroyed; + BOOL mbIsLocked; + BOOL mbNeedsUpdate; + BOOL mbOldUndoMode; + BOOL mbForwarderIsEditMode; // have to reflect that, since ENDEDIT can happen more often + BOOL mbShapeIsEditMode; // #104157# only true, if HINT_BEGEDIT was received + BOOL mbNotificationsDisabled; // prevent EditEngine/Outliner notifications (e.g. when setting up forwarder) + + XInterface* mpOwner; + SvxUnoTextRangeBaseList maTextRanges; + + SvxTextForwarder* GetBackgroundTextForwarder(); + SvxTextForwarder* GetEditModeTextForwarder(); + SvxDrawOutlinerViewForwarder* CreateViewForwarder(); + + void SetupOutliner(); + void UpdateOutliner(); + + sal_Bool HasView() const { return mpView ? sal_True : sal_False; } + sal_Bool IsEditMode() const + { + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + return mbShapeIsEditMode && pTextObj && pTextObj->IsTextEditActive() ? sal_True : sal_False; + } + + void dispose(); + +public: + SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText, XInterface* pOwner ); + SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText, SdrView& rView, const Window& rWindow ); + ~SvxTextEditSourceImpl(); + + void SAL_CALL acquire(); + void SAL_CALL release(); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + + SvxEditSource* Clone() const; + SvxTextForwarder* GetTextForwarder(); + SvxEditViewForwarder* GetEditViewForwarder( sal_Bool ); + void UpdateData(); + + void addRange( SvxUnoTextRangeBase* pNewRange ); + void removeRange( SvxUnoTextRangeBase* pOldRange ); + const SvxUnoTextRangeBaseList& getRanges() const; + + SdrObject* GetSdrObject() const { return mpObject; } + + void lock(); + void unlock(); + + BOOL IsValid() const; + + Rectangle GetVisArea(); + Point LogicToPixel( const Point&, const MapMode& rMapMode ); + Point PixelToLogic( const Point&, const MapMode& rMapMode ); + + DECL_LINK( NotifyHdl, EENotify* ); + + virtual void ObjectInDestruction(const SdrObject& rObject); + + void ChangeModel( SdrModel* pNewModel ); +}; + +//------------------------------------------------------------------------ + +SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText, XInterface* pOwner ) + : maRefCount ( 0 ), + mpObject ( pObject ), + mpText ( pText ), + mpView ( NULL ), + mpWindow ( NULL ), + mpModel ( pObject ? pObject->GetModel() : NULL ), + mpOutliner ( NULL ), + mpTextForwarder ( NULL ), + mpViewForwarder ( NULL ), + mbDataValid ( FALSE ), + mbDestroyed ( FALSE ), + mbIsLocked ( FALSE ), + mbNeedsUpdate ( FALSE ), + mbOldUndoMode ( FALSE ), + mbForwarderIsEditMode ( FALSE ), + mbShapeIsEditMode ( FALSE ), + mbNotificationsDisabled ( FALSE ), + mpOwner( pOwner ) +{ + DBG_ASSERT( mpObject, "invalid pObject!" ); + + if( !mpText ) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject ); + if( pTextObj ) + mpText = pTextObj->getText( 0 ); + } + + if( mpModel ) + StartListening( *mpModel ); + + if( mpObject ) + mpObject->AddObjectUser( *this ); +} + +//------------------------------------------------------------------------ + +SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText, SdrView& rView, const Window& rWindow ) + : maRefCount ( 0 ), + mpObject ( &rObject ), + mpText ( pText ), + mpView ( &rView ), + mpWindow ( &rWindow ), + mpModel ( rObject.GetModel() ), + mpOutliner ( NULL ), + mpTextForwarder ( NULL ), + mpViewForwarder ( NULL ), + mbDataValid ( FALSE ), + mbDestroyed ( FALSE ), + mbIsLocked ( FALSE ), + mbNeedsUpdate ( FALSE ), + mbOldUndoMode ( FALSE ), + mbForwarderIsEditMode ( FALSE ), + mbShapeIsEditMode ( TRUE ), + mbNotificationsDisabled ( FALSE ), + mpOwner(0) +{ + if( !mpText ) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject ); + if( pTextObj ) + mpText = pTextObj->getText( 0 ); + } + + if( mpModel ) + StartListening( *mpModel ); + if( mpView ) + StartListening( *mpView ); + if( mpObject ) + mpObject->AddObjectUser( *this ); + + // #104157# Init edit mode state from shape info (IsTextEditActive()) + mbShapeIsEditMode = IsEditMode(); +} + +//------------------------------------------------------------------------ + +SvxTextEditSourceImpl::~SvxTextEditSourceImpl() +{ + DBG_ASSERT( mbIsLocked == sal_False, "text edit source was not unlocked before dispose!" ); + if( mpObject ) + mpObject->RemoveObjectUser( *this ); + + dispose(); +} + +//------------------------------------------------------------------------ + +void SvxTextEditSourceImpl::addRange( SvxUnoTextRangeBase* pNewRange ) +{ + if( pNewRange ) + if( std::find( maTextRanges.begin(), maTextRanges.end(), pNewRange ) == maTextRanges.end() ) + maTextRanges.push_back( pNewRange ); +} + +//------------------------------------------------------------------------ + +void SvxTextEditSourceImpl::removeRange( SvxUnoTextRangeBase* pOldRange ) +{ + if( pOldRange ) + maTextRanges.remove( pOldRange ); +} + +//------------------------------------------------------------------------ + +const SvxUnoTextRangeBaseList& SvxTextEditSourceImpl::getRanges() const +{ + return maTextRanges; +} + +//------------------------------------------------------------------------ + +void SAL_CALL SvxTextEditSourceImpl::acquire() +{ + osl_incrementInterlockedCount( &maRefCount ); +} + +//------------------------------------------------------------------------ + +void SAL_CALL SvxTextEditSourceImpl::release() +{ + if( ! osl_decrementInterlockedCount( &maRefCount ) ) + delete this; +} + +void SvxTextEditSourceImpl::ChangeModel( SdrModel* pNewModel ) +{ + if( mpModel != pNewModel ) + { + if( mpModel ) + EndListening( *mpModel ); + + if( mpOutliner ) + { + if( mpModel ) + mpModel->disposeOutliner( mpOutliner ); + else + delete mpOutliner; + mpOutliner = 0; + } + + if( mpView ) + { + EndListening( *mpView ); + mpView = 0; + } + + mpWindow = 0; + m_xLinguServiceManager.clear(); + mpOwner = 0; + + mpModel = pNewModel; + + if( mpTextForwarder ) + { + delete mpTextForwarder; + mpTextForwarder = 0; + } + + if( mpViewForwarder ) + { + delete mpViewForwarder; + mpViewForwarder = 0; + } + + if( mpModel ) + StartListening( *mpModel ); + } +} + +//------------------------------------------------------------------------ + +void SvxTextEditSourceImpl::Notify( SfxBroadcaster&, const SfxHint& rHint ) +{ + // #i105988 keep reference to this object + rtl::Reference< SvxTextEditSourceImpl > xThis( this ); + + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint ); + + if( pViewHint ) + { + switch( pViewHint->GetHintType() ) + { + case SvxViewHint::SVX_HINT_VIEWCHANGED: + Broadcast( *pViewHint ); + break; + } + } + else if( pSdrHint ) + { + switch( pSdrHint->GetKind() ) + { + case HINT_OBJCHG: + { + mbDataValid = FALSE; // Text muss neu geholt werden + + if( HasView() ) + { + // #104157# Update maTextOffset, object has changed + // #105196#, #105203#: Cannot call that // here, + // since TakeTextRect() (called from there) // + // changes outliner content. + // UpdateOutliner(); + + // #101029# Broadcast object changes, as they might change visible attributes + SvxViewHint aHint(SvxViewHint::SVX_HINT_VIEWCHANGED); + Broadcast( aHint ); + } + break; + } + + case HINT_BEGEDIT: + if( mpObject == pSdrHint->GetObject() ) + { + // invalidate old forwarder + if( !mbForwarderIsEditMode ) + { + delete mpTextForwarder; + mpTextForwarder = NULL; + } + + // register as listener - need to broadcast state change messages + if( mpView && mpView->GetTextEditOutliner() ) + mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) ); + + // #104157# Only now we're really in edit mode + mbShapeIsEditMode = TRUE; + + Broadcast( *pSdrHint ); + } + break; + + case HINT_ENDEDIT: + if( mpObject == pSdrHint->GetObject() ) + { + Broadcast( *pSdrHint ); + + // #104157# We're no longer in edit mode + mbShapeIsEditMode = FALSE; + + // remove as listener - outliner might outlive ourselves + if( mpView && mpView->GetTextEditOutliner() ) + mpView->GetTextEditOutliner()->SetNotifyHdl( Link() ); + + // destroy view forwarder, OutlinerView no longer + // valid (no need for UpdateData(), it's been + // synched on SdrEndTextEdit) + delete mpViewForwarder; + mpViewForwarder = NULL; + + // #100424# Invalidate text forwarder, we might + // not be called again before entering edit mode a + // second time! Then, the old outliner might be + // invalid. + if( mbForwarderIsEditMode ) + { + mbForwarderIsEditMode = sal_False; + delete mpTextForwarder; + mpTextForwarder = NULL; + } + } + break; + + case HINT_MODELCLEARED: + dispose(); + break; + default: + break; + } + } +} + +/* this is a callback from the attached SdrObject when it is actually deleted */ +void SvxTextEditSourceImpl::ObjectInDestruction(const SdrObject&) +{ + mpObject = 0; + dispose(); + Broadcast( SfxSimpleHint( SFX_HINT_DYING ) ); +} + +/* unregister at all objects and set all references to 0 */ +void SvxTextEditSourceImpl::dispose() +{ + if( mpTextForwarder ) + { + delete mpTextForwarder; + mpTextForwarder = 0; + } + + if( mpViewForwarder ) + { + delete mpViewForwarder; + mpViewForwarder = 0; + } + + if( mpOutliner ) + { + if( mpModel ) + { + mpModel->disposeOutliner( mpOutliner ); + } + else + { + delete mpOutliner; + } + mpOutliner = 0; + } + + if( mpModel ) + { + EndListening( *mpModel ); + mpModel = 0; + } + + if( mpView ) + { + EndListening( *mpView ); + mpView = 0; + } + + if( mpObject ) + { + mpObject->RemoveObjectUser( *this ); + mpObject = 0; + } + mpWindow = 0; +} + +//------------------------------------------------------------------------ + +void SvxTextEditSourceImpl::SetupOutliner() +{ + // #101029# + // only for UAA edit source: setup outliner equivalently as in + // SdrTextObj::Paint(), such that formatting equals screen + // layout + if( mpObject && mpOutliner ) + { + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + Rectangle aPaintRect; + if( pTextObj ) + { + Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); + pTextObj->SetupOutlinerFormatting( *mpOutliner, aPaintRect ); + + // #101029# calc text offset from shape anchor + maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft(); + } + } +} + +//------------------------------------------------------------------------ + +void SvxTextEditSourceImpl::UpdateOutliner() +{ + // #104157# + // only for UAA edit source: update outliner equivalently as in + // SdrTextObj::Paint(), such that formatting equals screen + // layout + if( mpObject && mpOutliner ) + { + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + Rectangle aPaintRect; + if( pTextObj ) + { + Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); + pTextObj->UpdateOutlinerFormatting( *mpOutliner, aPaintRect ); + + // #101029# calc text offset from shape anchor + maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft(); + } + } +} + +//------------------------------------------------------------------------ + + + +SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder() +{ + sal_Bool bCreated = sal_False; + + // #99840#: prevent EE/Outliner notifications during setup + mbNotificationsDisabled = sal_True; + + if (!mpTextForwarder) + { + if( mpOutliner == NULL ) + { + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + USHORT nOutlMode = OUTLINERMODE_TEXTOBJECT; + if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_OUTLINETEXT ) + nOutlMode = OUTLINERMODE_OUTLINEOBJECT; + + mpOutliner = mpModel->createOutliner( nOutlMode ); + + // #109151# Do the setup after outliner creation, would be useless otherwise + if( HasView() ) + { + // #101029#, #104157# Setup outliner _before_ filling it + SetupOutliner(); + } + + mpOutliner->SetTextObjNoInit( pTextObj ); +/* + mpOutliner = SdrMakeOutliner( nOutlMode, pModel ); + Outliner& aDrawOutliner = pModel->GetDrawOutliner(); + mpOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() ); +*/ + if( mbIsLocked ) + { + ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False ); + mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled(); + ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False ); + } + +// - + if ( !m_xLinguServiceManager.is() ) + { + css::uno::Reference< css::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); + m_xLinguServiceManager = css::uno::Reference< css::linguistic2::XLinguServiceManager >( + xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.linguistic2.LinguServiceManager" ))), css::uno::UNO_QUERY ); + } + + if ( m_xLinguServiceManager.is() ) + { + css::uno::Reference< css::linguistic2::XHyphenator > xHyphenator( m_xLinguServiceManager->getHyphenator(), css::uno::UNO_QUERY ); + if( xHyphenator.is() ) + mpOutliner->SetHyphenator( xHyphenator ); + } +// - + } + + + mpTextForwarder = new SvxOutlinerForwarder( *mpOutliner, (mpObject->GetObjInventor() == SdrInventor) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) ); + // delay listener subscription and UAA initialization until Outliner is fully setup + bCreated = sal_True; + + mbForwarderIsEditMode = sal_False; + } + + if( mpObject && mpText && !mbDataValid && mpObject->IsInserted() && mpObject->GetPage() ) + { + mpTextForwarder->flushCache(); + + OutlinerParaObject* pOutlinerParaObject = NULL; + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + if( pTextObj && pTextObj->getActiveText() == mpText ) + pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active + bool bOwnParaObj(false); + + if( pOutlinerParaObject ) + bOwnParaObj = true; // text edit active + else + pOutlinerParaObject = mpText->GetOutlinerParaObject(); + + if( pOutlinerParaObject && ( bOwnParaObj || !mpObject->IsEmptyPresObj() || mpObject->GetPage()->IsMasterPage() ) ) + { + mpOutliner->SetText( *pOutlinerParaObject ); + + // #91254# put text to object and set EmptyPresObj to FALSE + if( mpText && bOwnParaObj && pOutlinerParaObject && mpObject->IsEmptyPresObj() && pTextObj->IsRealyEdited() ) + { + mpObject->SetEmptyPresObj( FALSE ); + static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( pOutlinerParaObject, mpText ); + + // #i103982# Here, due to mpObject->NbcSetOutlinerParaObjectForText, we LOSE ownership of the + // OPO, so do NOT delete it when leaving this method (!) + bOwnParaObj = false; + } + } + else + { + sal_Bool bVertical = pOutlinerParaObject ? pOutlinerParaObject->IsVertical() : sal_False; + + // set objects style sheet on empty outliner + SfxStyleSheetPool* pPool = (SfxStyleSheetPool*)mpObject->GetModel()->GetStyleSheetPool(); + if( pPool ) + mpOutliner->SetStyleSheetPool( pPool ); + + SfxStyleSheet* pStyleSheet = mpObject->GetPage()->GetTextStyleSheetForObject( mpObject ); + if( pStyleSheet ) + mpOutliner->SetStyleSheet( 0, pStyleSheet ); + + if( bVertical ) + mpOutliner->SetVertical( sal_True ); + } + + // evtually we have to set the border attributes + if (mpOutliner->GetParagraphCount()==1) + { + // if we only have one paragraph we check if it is empty + XubString aStr( mpOutliner->GetText( mpOutliner->GetParagraph( 0 ) ) ); + + if(!aStr.Len()) + { + // its empty, so we have to force the outliner to initialise itself + mpOutliner->SetText( String(), mpOutliner->GetParagraph( 0 ) ); + + if(mpObject->GetStyleSheet()) + mpOutliner->SetStyleSheet( 0, mpObject->GetStyleSheet()); + } + } + + mbDataValid = TRUE; + + if( bOwnParaObj ) + delete pOutlinerParaObject; + } + + if( bCreated && mpOutliner && HasView() ) + { + // register as listener - need to broadcast state change messages + // registration delayed until outliner is completely set up + mpOutliner->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) ); + } + + // #99840#: prevent EE/Outliner notifications during setup + mbNotificationsDisabled = sal_False; + + return mpTextForwarder; +} + +//------------------------------------------------------------------------ + +SvxTextForwarder* SvxTextEditSourceImpl::GetEditModeTextForwarder() +{ + if( !mpTextForwarder && HasView() ) + { + SdrOutliner* pEditOutliner = mpView->GetTextEditOutliner(); + + if( pEditOutliner ) + { + mpTextForwarder = new SvxOutlinerForwarder( *pEditOutliner, (mpObject->GetObjInventor() == SdrInventor) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) ); + mbForwarderIsEditMode = sal_True; + } + } + + return mpTextForwarder; +} + +//------------------------------------------------------------------------ + +SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder() +{ + if( mbDestroyed || mpObject == NULL ) + return NULL; + + if( mpModel == NULL ) + mpModel = mpObject->GetModel(); + + if( mpModel == NULL ) + return NULL; + + // distinguish the cases + // a) connected to view, maybe edit mode is active, can work directly on the EditOutliner + // b) background Outliner, reflect changes into ParaOutlinerObject (this is exactly the old UNO code) + if( HasView() ) + { + if( IsEditMode() != mbForwarderIsEditMode ) + { + // forwarder mismatch - create new + delete mpTextForwarder; + mpTextForwarder = NULL; + } + + if( IsEditMode() ) + return GetEditModeTextForwarder(); + else + return GetBackgroundTextForwarder(); + } + else + return GetBackgroundTextForwarder(); +} + +//------------------------------------------------------------------------ + +SvxDrawOutlinerViewForwarder* SvxTextEditSourceImpl::CreateViewForwarder() +{ + if( mpView->GetTextEditOutlinerView() && mpObject ) + { + // register as listener - need to broadcast state change messages + mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) ); + + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + if( pTextObj ) + { + Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); + OutlinerView& rOutlView = *mpView->GetTextEditOutlinerView(); + + return new SvxDrawOutlinerViewForwarder( rOutlView, aBoundRect.TopLeft() ); + } + } + + return NULL; +} + +SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( sal_Bool bCreate ) +{ + if( mbDestroyed || mpObject == NULL ) + return NULL; + + if( mpModel == NULL ) + mpModel = mpObject->GetModel(); + + if( mpModel == NULL ) + return NULL; + + // shall we delete? + if( mpViewForwarder ) + { + if( !IsEditMode() ) + { + // destroy all forwarders (no need for UpdateData(), + // it's been synched on SdrEndTextEdit) + delete mpViewForwarder; + mpViewForwarder = NULL; + } + } + // which to create? Directly in edit mode, create new, or none? + else if( mpView ) + { + if( IsEditMode() ) + { + // create new view forwarder + mpViewForwarder = CreateViewForwarder(); + } + else if( bCreate ) + { + // dispose old text forwarder + UpdateData(); + + delete mpTextForwarder; + mpTextForwarder = NULL; + + // enter edit mode + mpView->SdrEndTextEdit(); + + if(mpView->SdrBeginTextEdit(mpObject, 0L, 0L, sal_False, (SdrOutliner*)0L, 0L, sal_False, sal_False)) + { + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + if( pTextObj->IsTextEditActive() ) + { + // create new view forwarder + mpViewForwarder = CreateViewForwarder(); + } + else + { + // failure. Somehow, SdrBeginTextEdit did not set + // our SdrTextObj into edit mode + mpView->SdrEndTextEdit(); + } + } + } + } + + return mpViewForwarder; +} + +//------------------------------------------------------------------------ + +void SvxTextEditSourceImpl::UpdateData() +{ + // if we have a view and in edit mode, we're working with the + // DrawOutliner. Thus, all changes made on the text forwarder are + // reflected on the view and committed to the model on + // SdrEndTextEdit(). Thus, no need for explicit updates here. + if( !HasView() || !IsEditMode() ) + { + if( mbIsLocked ) + { + mbNeedsUpdate = sal_True; + } + else + { + if( mpOutliner && mpObject && mpText && !mbDestroyed ) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject ); + if( pTextObj ) + { + if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) ) + { + if( mpOutliner->GetParagraphCount() > 1 ) + { + if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_TITLETEXT ) + { + while( mpOutliner->GetParagraphCount() > 1 ) + { + ESelection aSel( 0,mpOutliner->GetEditEngine().GetTextLen( 0 ), 1,0 ); + mpOutliner->QuickInsertLineBreak( aSel ); + } + } + } + + pTextObj->NbcSetOutlinerParaObjectForText( mpOutliner->CreateParaObject(), mpText ); + } + else + { + pTextObj->NbcSetOutlinerParaObjectForText( NULL,mpText ); + } + } + + if( mpObject->IsEmptyPresObj() ) + mpObject->SetEmptyPresObj(sal_False); + } + } + } +} + +void SvxTextEditSourceImpl::lock() +{ + mbIsLocked = sal_True; + if( mpOutliner ) + { + ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False ); + mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled(); + ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False ); + } +} + +void SvxTextEditSourceImpl::unlock() +{ + mbIsLocked = sal_False; + + if( mbNeedsUpdate ) + { + UpdateData(); + mbNeedsUpdate = sal_False; + } + + if( mpOutliner ) + { + ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_True ); + ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( mbOldUndoMode ); + } +} + +BOOL SvxTextEditSourceImpl::IsValid() const +{ + return mpView && mpWindow ? TRUE : FALSE; +} + +Rectangle SvxTextEditSourceImpl::GetVisArea() +{ + if( IsValid() ) + { + SdrPaintWindow* pPaintWindow = mpView->FindPaintWindow(*mpWindow); + Rectangle aVisArea; + + if(pPaintWindow) + { + aVisArea = pPaintWindow->GetVisibleArea(); + } + + // offset vis area by edit engine left-top position + SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject ); + if( pTextObj ) + { + Rectangle aAnchorRect; + pTextObj->TakeTextAnchorRect( aAnchorRect ); + aVisArea.Move( -aAnchorRect.Left(), -aAnchorRect.Top() ); + + MapMode aMapMode(mpWindow->GetMapMode()); + aMapMode.SetOrigin(Point()); + return mpWindow->LogicToPixel( aVisArea, aMapMode ); + } + } + + return Rectangle(); +} + +Point SvxTextEditSourceImpl::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) +{ + // #101029#: The responsibilities of ViewForwarder happen to be + // somewhat mixed in this case. On the one hand, we need the + // different interface queries on the SvxEditSource interface, + // since we need both VisAreas. On the other hand, if an + // EditViewForwarder exists, maTextOffset does not remain static, + // but may change with every key press. + if( IsEditMode() ) + { + SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False); + + if( pForwarder ) + return pForwarder->LogicToPixel( rPoint, rMapMode ); + } + else if( IsValid() && mpModel ) + { + // #101029# + Point aPoint1( rPoint ); + aPoint1.X() += maTextOffset.X(); + aPoint1.Y() += maTextOffset.Y(); + + Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode, + MapMode(mpModel->GetScaleUnit()) ) ); + MapMode aMapMode(mpWindow->GetMapMode()); + aMapMode.SetOrigin(Point()); + return mpWindow->LogicToPixel( aPoint2, aMapMode ); + } + + return Point(); +} + +Point SvxTextEditSourceImpl::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) +{ + // #101029#: The responsibilities of ViewForwarder happen to be + // somewhat mixed in this case. On the one hand, we need the + // different interface queries on the SvxEditSource interface, + // since we need both VisAreas. On the other hand, if an + // EditViewForwarder exists, maTextOffset does not remain static, + // but may change with every key press. + if( IsEditMode() ) + { + SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False); + + if( pForwarder ) + return pForwarder->PixelToLogic( rPoint, rMapMode ); + } + else if( IsValid() && mpModel ) + { + MapMode aMapMode(mpWindow->GetMapMode()); + aMapMode.SetOrigin(Point()); + Point aPoint1( mpWindow->PixelToLogic( rPoint, aMapMode ) ); + Point aPoint2( OutputDevice::LogicToLogic( aPoint1, + MapMode(mpModel->GetScaleUnit()), + rMapMode ) ); + // #101029# + aPoint2.X() -= maTextOffset.X(); + aPoint2.Y() -= maTextOffset.Y(); + + return aPoint2; + } + + return Point(); +} + +IMPL_LINK(SvxTextEditSourceImpl, NotifyHdl, EENotify*, aNotify) +{ + if( aNotify && !mbNotificationsDisabled ) + { + ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) ); + + if( aHint.get() ) + Broadcast( *aHint.get() ); + } + + return 0; +} + +//------------------------------------------------------------------------ + +// -------------------------------------------------------------------- +// SvxTextEditSource +// -------------------------------------------------------------------- + +SvxTextEditSource::SvxTextEditSource( SdrObject* pObject, SdrText* pText, XInterface* pOwner ) +{ + mpImpl = new SvxTextEditSourceImpl( pObject, pText, pOwner ); + mpImpl->acquire(); +} + +// -------------------------------------------------------------------- +SvxTextEditSource::SvxTextEditSource( SdrObject& rObj, SdrText* pText, SdrView& rView, const Window& rWindow ) +{ + mpImpl = new SvxTextEditSourceImpl( rObj, pText, rView, rWindow ); + mpImpl->acquire(); +} + +// -------------------------------------------------------------------- + +SvxTextEditSource::SvxTextEditSource( SvxTextEditSourceImpl* pImpl ) +{ + mpImpl = pImpl; + mpImpl->acquire(); +} + +//------------------------------------------------------------------------ +SvxTextEditSource::~SvxTextEditSource() +{ + OGuard aGuard( Application::GetSolarMutex() ); + + mpImpl->release(); +} + +//------------------------------------------------------------------------ +SvxEditSource* SvxTextEditSource::Clone() const +{ + return new SvxTextEditSource( mpImpl ); +} + +//------------------------------------------------------------------------ +SvxTextForwarder* SvxTextEditSource::GetTextForwarder() +{ + return mpImpl->GetTextForwarder(); +} + +//------------------------------------------------------------------------ +SvxEditViewForwarder* SvxTextEditSource::GetEditViewForwarder( sal_Bool bCreate ) +{ + return mpImpl->GetEditViewForwarder( bCreate ); +} + +//------------------------------------------------------------------------ +SvxViewForwarder* SvxTextEditSource::GetViewForwarder() +{ + return this; +} + +//------------------------------------------------------------------------ +void SvxTextEditSource::UpdateData() +{ + mpImpl->UpdateData(); +} + +SfxBroadcaster& SvxTextEditSource::GetBroadcaster() const +{ + return *mpImpl; +} + +SdrObject* SvxTextEditSource::GetSdrObject() const +{ + return mpImpl->GetSdrObject(); +} + +void SvxTextEditSource::lock() +{ + mpImpl->lock(); +} + +void SvxTextEditSource::unlock() +{ + mpImpl->unlock(); +} + +BOOL SvxTextEditSource::IsValid() const +{ + return mpImpl->IsValid(); +} + +Rectangle SvxTextEditSource::GetVisArea() const +{ + return mpImpl->GetVisArea(); +} + +Point SvxTextEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const +{ + return mpImpl->LogicToPixel( rPoint, rMapMode ); +} + +Point SvxTextEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const +{ + return mpImpl->PixelToLogic( rPoint, rMapMode ); +} + +void SvxTextEditSource::addRange( SvxUnoTextRangeBase* pNewRange ) +{ + mpImpl->addRange( pNewRange ); +} + +void SvxTextEditSource::removeRange( SvxUnoTextRangeBase* pOldRange ) +{ + mpImpl->removeRange( pOldRange ); +} + +const SvxUnoTextRangeBaseList& SvxTextEditSource::getRanges() const +{ + return mpImpl->getRanges(); +} + +void SvxTextEditSource::ChangeModel( SdrModel* pNewModel ) +{ + mpImpl->ChangeModel( pNewModel ); +} diff --git a/svx/source/unodraw/unottabl.cxx b/svx/source/unodraw/unottabl.cxx new file mode 100644 index 000000000000..58dcbc39d03c --- /dev/null +++ b/svx/source/unodraw/unottabl.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include <com/sun/star/awt/Gradient.hpp> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <svx/xgrad.hxx> +#include <svx/xflftrit.hxx> + +#include <svx/svdmodel.hxx> +#include <svx/xflhtit.hxx> +#include "unofill.hxx" +#include <svx/unomid.hxx> +#include "UnoNameItemTable.hxx" + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +class SvxUnoTransGradientTable : public SvxUnoNameItemTable +{ +public: + SvxUnoTransGradientTable( SdrModel* pModel ) throw(); + virtual ~SvxUnoTransGradientTable() throw(); + + virtual NameOrIndex* createItem() const throw(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); +}; + +SvxUnoTransGradientTable::SvxUnoTransGradientTable( SdrModel* pModel ) throw() +: SvxUnoNameItemTable( pModel, XATTR_FILLFLOATTRANSPARENCE, MID_FILLGRADIENT ) +{ +} + +SvxUnoTransGradientTable::~SvxUnoTransGradientTable() throw() +{ +} + +OUString SAL_CALL SvxUnoTransGradientTable::getImplementationName() throw( uno::RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoTransGradientTable") ); +} + +uno::Sequence< OUString > SAL_CALL SvxUnoTransGradientTable::getSupportedServiceNames( ) + throw( uno::RuntimeException ) +{ + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable" )); + return aSNS; +} + +NameOrIndex* SvxUnoTransGradientTable::createItem() const throw() +{ + XFillFloatTransparenceItem* pNewItem = new XFillFloatTransparenceItem(); + pNewItem->SetEnabled( TRUE ); + return pNewItem; +} + +// XElementAccess +uno::Type SAL_CALL SvxUnoTransGradientTable::getElementType( ) + throw( uno::RuntimeException ) +{ + return ::getCppuType((const struct awt::Gradient*)0); +} + +/** + * Create a hatchtable + */ +uno::Reference< uno::XInterface > SAL_CALL SvxUnoTransGradientTable_createInstance( SdrModel* pModel ) +{ + return *new SvxUnoTransGradientTable(pModel); +} + + + |