update ooo310-m15
[ooovba.git] / applied_patches / 0349-vba-support-export-palette.diff
blobff06b79a21ad19b4b3a0f36a66b77117b6c82c93
1 --- sc/source/filter/inc/xistyle.hxx.old 2009-04-02 10:44:58.000000000 +0000
2 +++ sc/source/filter/inc/xistyle.hxx 2009-04-06 16:41:58.000000000 +0000
3 @@ -72,8 +72,10 @@ public:
4 void ReadPalette( XclImpStream& rStrm );
6 private:
7 + void ExportPalette();
8 typedef ::std::vector< ColorData > ColorDataVec;
9 ColorDataVec maColorTable; /// Colors read from file.
10 + const XclImpRoot& mrRoot;
13 // FONT record - font information =============================================
14 --- sc/source/filter/excel/xistyle.cxx.old 2009-04-02 10:44:55.000000000 +0000
15 +++ sc/source/filter/excel/xistyle.cxx 2009-04-06 16:41:58.000000000 +0000
16 @@ -68,10 +68,70 @@
17 #include "root.hxx"
18 #include "colrowst.hxx"
20 +#include <cppuhelper/implbase1.hxx>
21 +#include <com/sun/star/container/XIndexAccess.hpp>
22 +#include <com/sun/star/beans/XPropertySet.hpp>
23 +using namespace ::com::sun::star;
25 +typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
26 +typedef ::std::vector< ColorData > ColorDataVec;
28 +class PaletteIndex : public XIndexAccess_BASE
30 +public:
31 + PaletteIndex( const ColorDataVec& rColorDataTable ) : maColorData( rColorDataTable ) {}
33 + // Methods XIndexAccess
34 + virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
35 + {
36 + return maColorData.size();
37 + }
39 + virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
40 + {
41 + //--Index; // apparently the palette is already 1 based
42 + return uno::makeAny( sal_Int32( maColorData[ Index ] ) );
43 + }
45 + // Methods XElementAcess
46 + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
47 + {
48 + return ::getCppuType( (sal_Int32*)0 );
49 + }
50 + virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
51 + {
52 + return (maColorData.size() > 0);
53 + }
55 +private:
56 + ColorDataVec maColorData;
57 +};
59 +void
60 +XclImpPalette::ExportPalette()
62 + if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() )
63 + {
64 + // copy values in color palette
65 + sal_Int16 nColors = maColorTable.size();
66 + ColorDataVec aColors;
67 + aColors.resize( nColors );
68 + for( sal_uInt16 nIndex = 0; nIndex < nColors; ++nIndex )
69 + aColors[ nIndex ] = GetColorData( nIndex );
71 + uno::Reference< beans::XPropertySet > xProps( pDocShell->GetModel(), uno::UNO_QUERY );
72 + if ( xProps.is() )
73 + {
74 + uno::Reference< container::XIndexAccess > xIndex( new PaletteIndex( aColors ) );
75 + xProps->setPropertyValue( CREATE_OUSTRING("ColorPalette"), uno::makeAny( xIndex ) );
76 + }
77 + }
80 // PALETTE record - color information =========================================
82 XclImpPalette::XclImpPalette( const XclImpRoot& rRoot ) :
83 - XclDefaultPalette( rRoot )
84 + XclDefaultPalette( rRoot ), mrRoot( rRoot )
88 @@ -105,6 +165,7 @@ void XclImpPalette::ReadPalette( XclImpS
89 rStrm >> aColor;
90 maColorTable[ nIndex ] = aColor.GetColor();
92 + ExportPalette();
95 // FONT record - font information =============================================