drawshape.cxx (70f497fb) drawshape.cxx (78d93489)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 70 unchanged lines hidden (view full) ---

79
80using namespace ::com::sun::star;
81
82
83namespace slideshow
84{
85 namespace internal
86 {
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 70 unchanged lines hidden (view full) ---

79
80using namespace ::com::sun::star;
81
82
83namespace slideshow
84{
85 namespace internal
86 {
87 //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
88 //metafiles are resolution dependent when bitmaps are contained with is the case for 3D scenes for example
89 //in addition a chart has resolution dependent content as it might skip points that are not visible for a given resolution (this is done for performance reasons)
90 bool local_getMetafileForChart( const uno::Reference< lang::XComponent >& xSource,
91 const uno::Reference< drawing::XDrawPage >& xContainingPage,
92 GDIMetaFile& rMtf )
93 {
94 //get the chart model
95 uno::Reference< beans::XPropertySet > xPropSet( xSource, uno::UNO_QUERY );
96 uno::Reference< frame::XModel > xChartModel;
97 getPropertyValue( xChartModel, xPropSet, OUSTR("Model"));
98 uno::Reference< lang::XMultiServiceFactory > xFact( xChartModel, uno::UNO_QUERY );
99 OSL_ENSURE( xFact.is(), "Chart cannot be painted pretty!\n" );
100 if(!xFact.is())
101 return false;
102
103 //get the chart view
104 uno::Reference< datatransfer::XTransferable > xChartViewTransferable(
105 xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ChartView" ) ) ), uno::UNO_QUERY );
106 uno::Reference< beans::XPropertySet > xChartViewProp( xChartViewTransferable, uno::UNO_QUERY );
107 OSL_ENSURE( xChartViewProp.is(), "Chart cannot be painted pretty!\n" );
108 if( !xChartViewProp.is() )
109 return false;
110
111 //estimate zoom and resolution (this is only a workaround, correct would be to know and use the exact zoom and resoltion during slideshow display)
112 sal_Int32 nScaleXNumerator = 100;//zoom factor -> exact values are important for the quality of the created bitmap especially for 3D charts
113 sal_Int32 nScaleYNumerator = 100;
114 sal_Int32 nScaleXDenominator = 100;
115 sal_Int32 nScaleYDenominator = 100;
116 awt::Size aPixelPerChart( 1000, 1000 );//when data points happen to be on the same pixel as their predecessor no shape is created to safe performance
117
118 Window* pActiveTopWindow( Application::GetActiveTopWindow() );
119 WorkWindow* pWorkWindow( dynamic_cast<WorkWindow*>(pActiveTopWindow));
120 if( pWorkWindow && pWorkWindow->IsPresentationMode() )
121 {
122 Size aPixScreenSize( pActiveTopWindow->GetOutputSizePixel() );
123 aPixelPerChart = awt::Size( aPixScreenSize.getWidth(), aPixScreenSize.getHeight() );//this is still to much (but costs only seldom performance), correct would be pixel per chart object
124
125 uno::Reference< beans::XPropertySet > xPageProp( xContainingPage, uno::UNO_QUERY );
126 sal_Int32 nLogicPageWidth=1;
127 sal_Int32 nLogicPageHeight=1;
128 if( getPropertyValue( nLogicPageWidth, xPageProp, OUSTR("Width")) &&
129 getPropertyValue( nLogicPageHeight, xPageProp, OUSTR("Height")) )
130 {
131 Size aLogicScreenSize( pActiveTopWindow->PixelToLogic( aPixScreenSize, MAP_100TH_MM ) );
132 nScaleXNumerator = aLogicScreenSize.getWidth();
133 nScaleYNumerator = aLogicScreenSize.getHeight();
134 nScaleXDenominator = nLogicPageWidth;
135 nScaleYDenominator = nLogicPageHeight;
136 }
137 }
138 else
139 {
140 long nMaxPixWidth = 0;
141 long nMaxPixHeight = 0;
142 unsigned int nScreenCount( Application::GetScreenCount() );
143 for( unsigned int nScreen=0; nScreen<nScreenCount; nScreen++ )
144 {
145 Rectangle aCurScreenRect( Application::GetScreenPosSizePixel( nScreen ) );
146 if( aCurScreenRect.GetWidth() > nMaxPixWidth )
147 nMaxPixWidth = aCurScreenRect.GetWidth();
148 if( aCurScreenRect.GetHeight() > nMaxPixHeight )
149 nMaxPixHeight = aCurScreenRect.GetHeight();
150 }
151 if(nMaxPixWidth>1 && nMaxPixHeight>1)
152 aPixelPerChart = awt::Size( nMaxPixWidth, nMaxPixHeight );//this is still to much (but costs only seldom performance), correct would be pixel per chart object
153 }
154
155 try
156 {
157 uno::Sequence< beans::PropertyValue > aZoomFactors(4);
158 aZoomFactors[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleXNumerator") );
159 aZoomFactors[0].Value = uno::makeAny( nScaleXNumerator );
160 aZoomFactors[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleXDenominator") );
161 aZoomFactors[1].Value = uno::makeAny( nScaleXDenominator );
162 aZoomFactors[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleYNumerator") );
163 aZoomFactors[2].Value = uno::makeAny( nScaleYNumerator );
164 aZoomFactors[3].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleYDenominator") );
165 aZoomFactors[3].Value = uno::makeAny( nScaleYDenominator );
166
167 xChartViewProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomFactors") ), uno::makeAny( aZoomFactors ));
168 xChartViewProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Resolution") ), uno::makeAny( aPixelPerChart ));
169 }
170 catch (uno::Exception &)
171 {
172 OSL_ENSURE( false, rtl::OUStringToOString(
173 comphelper::anyToString(
174 cppu::getCaughtException() ),
175 RTL_TEXTENCODING_UTF8 ).getStr() );
176 }
177
178 //get a metafile from the prepared chart view
179 datatransfer::DataFlavor aDataFlavor(
180 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"") ),
181 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GDIMetaFile" ) ),
182 ::getCppuType( (const uno::Sequence< sal_Int8 >*) 0 ) );
183 uno::Any aData( xChartViewTransferable->getTransferData( aDataFlavor ) );
184 uno::Sequence< sal_Int8 > aSeq;
185 if( aData >>= aSeq )
186 {
187 ::std::auto_ptr< SvMemoryStream > pSrcStm( new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC ) );
188 *(pSrcStm.get() ) >> rMtf;
189 return true;
190 }
191 return false;
192 }
193
194 //same as getMetafile with an exception for charts
195 //for charts a metafile with a higher resolution is created, because charts have resolution dependent content
196 bool local_getMetaFile_WithSpecialChartHandling( const uno::Reference< lang::XComponent >& xSource,
197 const uno::Reference< drawing::XDrawPage >& xContainingPage,
198 GDIMetaFile& rMtf,
199 int mtfLoadFlags,
200 const uno::Reference< uno::XComponentContext >& rxContext )
201 {
202 uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY );
203 rtl::OUString sCLSID;
204 getPropertyValue( sCLSID, xProp, OUSTR("CLSID"));
205 if( sCLSID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("12DCAE26-281F-416F-a234-c3086127382e")) && local_getMetafileForChart( xSource, xContainingPage, rMtf ) )
206 return true;
207 return getMetaFile( xSource, xContainingPage, rMtf, mtfLoadFlags, rxContext );
208 }
209
210
211 //////////////////////////////////////////////////////////////////////
212 //
213 // Private methods
214 //
215 //////////////////////////////////////////////////////////////////////
216
217 GDIMetaFileSharedPtr DrawShape::forceScrollTextMetaFile()
218 {
219 if ((mnCurrMtfLoadFlags & MTF_LOAD_SCROLL_TEXT_MTF) != MTF_LOAD_SCROLL_TEXT_MTF)
220 {
221 // reload with added flags:
222 mpCurrMtf.reset( new GDIMetaFile );
223 mnCurrMtfLoadFlags |= MTF_LOAD_SCROLL_TEXT_MTF;
87 //////////////////////////////////////////////////////////////////////
88 //
89 // Private methods
90 //
91 //////////////////////////////////////////////////////////////////////
92
93 GDIMetaFileSharedPtr DrawShape::forceScrollTextMetaFile()
94 {
95 if ((mnCurrMtfLoadFlags & MTF_LOAD_SCROLL_TEXT_MTF) != MTF_LOAD_SCROLL_TEXT_MTF)
96 {
97 // reload with added flags:
98 mpCurrMtf.reset( new GDIMetaFile );
99 mnCurrMtfLoadFlags |= MTF_LOAD_SCROLL_TEXT_MTF;
224 local_getMetaFile_WithSpecialChartHandling(
100 getMetaFile(
225 uno::Reference<lang::XComponent>(mxShape, uno::UNO_QUERY),
226 mxPage, *mpCurrMtf, mnCurrMtfLoadFlags,
227 mxComponentContext );
228
229 // TODO(F1): Currently, the scroll metafile will
230 // never contain any verbose text comments. Thus,
231 // can only display the full mtf content, no
232 // subsets.

--- 53 unchanged lines hidden (view full) ---

286 "for an ALREADY SUBSETTED shape is not possible!" );
287
288 // re-fetch metafile with comments
289 // note that, in case of shapes without text, the new
290 // metafile might still not provide any useful
291 // subsetting information!
292 mpCurrMtf.reset( new GDIMetaFile );
293 mnCurrMtfLoadFlags |= MTF_LOAD_VERBOSE_COMMENTS;
101 uno::Reference<lang::XComponent>(mxShape, uno::UNO_QUERY),
102 mxPage, *mpCurrMtf, mnCurrMtfLoadFlags,
103 mxComponentContext );
104
105 // TODO(F1): Currently, the scroll metafile will
106 // never contain any verbose text comments. Thus,
107 // can only display the full mtf content, no
108 // subsets.

--- 53 unchanged lines hidden (view full) ---

162 "for an ALREADY SUBSETTED shape is not possible!" );
163
164 // re-fetch metafile with comments
165 // note that, in case of shapes without text, the new
166 // metafile might still not provide any useful
167 // subsetting information!
168 mpCurrMtf.reset( new GDIMetaFile );
169 mnCurrMtfLoadFlags |= MTF_LOAD_VERBOSE_COMMENTS;
294 local_getMetaFile_WithSpecialChartHandling(
170 getMetaFile(
295 uno::Reference<lang::XComponent>(mxShape, uno::UNO_QUERY),
296 mxPage, *mpCurrMtf, mnCurrMtfLoadFlags,
297 mxComponentContext );
298
299 maSubsetting.reset( maSubsetting.getSubsetNode(),
300 mpCurrMtf );
301 }
302 }

--- 274 unchanged lines hidden (view full) ---

577 if( xPropSet.is() )
578 getPropertyValue( eKind, xPropSet,
579 OUSTR("TextAnimationKind") );
580 mbDrawingLayerAnim = (eKind != drawing::TextAnimationKind_NONE);
581
582 // must NOT be called from within initializer list, uses
583 // state from mnCurrMtfLoadFlags!
584 mpCurrMtf.reset( new GDIMetaFile );
171 uno::Reference<lang::XComponent>(mxShape, uno::UNO_QUERY),
172 mxPage, *mpCurrMtf, mnCurrMtfLoadFlags,
173 mxComponentContext );
174
175 maSubsetting.reset( maSubsetting.getSubsetNode(),
176 mpCurrMtf );
177 }
178 }

--- 274 unchanged lines hidden (view full) ---

453 if( xPropSet.is() )
454 getPropertyValue( eKind, xPropSet,
455 OUSTR("TextAnimationKind") );
456 mbDrawingLayerAnim = (eKind != drawing::TextAnimationKind_NONE);
457
458 // must NOT be called from within initializer list, uses
459 // state from mnCurrMtfLoadFlags!
460 mpCurrMtf.reset( new GDIMetaFile );
585 local_getMetaFile_WithSpecialChartHandling(
461 getMetaFile(
586 uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY),
587 xContainingPage, *mpCurrMtf, mnCurrMtfLoadFlags,
588 mxComponentContext );
589 ENSURE_OR_THROW( mpCurrMtf,
590 "DrawShape::DrawShape(): Invalid metafile" );
591 maSubsetting.reset( mpCurrMtf );
592
593 prepareHyperlinkIndices();

--- 881 unchanged lines hidden ---
462 uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY),
463 xContainingPage, *mpCurrMtf, mnCurrMtfLoadFlags,
464 mxComponentContext );
465 ENSURE_OR_THROW( mpCurrMtf,
466 "DrawShape::DrawShape(): Invalid metafile" );
467 maSubsetting.reset( mpCurrMtf );
468
469 prepareHyperlinkIndices();

--- 881 unchanged lines hidden ---