Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
21 :
22 : #include "ShapeContextHandler.hxx"
23 : #include "ShapeDrawingFragmentHandler.hxx"
24 : #include "LockedCanvasContext.hxx"
25 : #include "WpsContext.hxx"
26 : #include "WpgContext.hxx"
27 : #include "services.hxx"
28 : #include "oox/vml/vmldrawingfragment.hxx"
29 : #include "oox/vml/vmlshape.hxx"
30 : #include "oox/drawingml/themefragmenthandler.hxx"
31 : #include <cppuhelper/supportsservice.hxx>
32 : #include <memory>
33 :
34 : namespace oox { namespace shape {
35 :
36 : using namespace ::com::sun::star;
37 : using namespace core;
38 : using namespace drawingml;
39 :
40 91 : OUString SAL_CALL ShapeContextHandler_getImplementationName()
41 : {
42 91 : return OUString( "com.sun.star.comp.oox.ShapeContextHandler" );
43 : }
44 :
45 : uno::Sequence< OUString > SAL_CALL
46 20 : ShapeContextHandler_getSupportedServiceNames()
47 : {
48 20 : uno::Sequence< OUString > s(1);
49 20 : s[0] = "com.sun.star.xml.sax.FastShapeContextHandler";
50 20 : return s;
51 : }
52 :
53 : uno::Reference< uno::XInterface > SAL_CALL
54 800 : ShapeContextHandler_createInstance( const uno::Reference< uno::XComponentContext > & context)
55 : throw (uno::Exception)
56 : {
57 800 : return static_cast< ::cppu::OWeakObject* >( new ShapeContextHandler(context) );
58 : }
59 :
60 800 : ShapeContextHandler::ShapeContextHandler
61 : (uno::Reference< uno::XComponentContext > const & context) :
62 800 : mnStartToken(0), m_xContext(context)
63 : {
64 : try
65 : {
66 800 : mxFilterBase.set( new ShapeFilterBase(context) );
67 : }
68 0 : catch( uno::Exception& )
69 : {
70 : }
71 800 : }
72 :
73 1600 : ShapeContextHandler::~ShapeContextHandler()
74 : {
75 1600 : }
76 :
77 77 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getLockedCanvasContext(sal_Int32 nElement)
78 : {
79 77 : if (!mxLockedCanvasContext.is())
80 : {
81 12 : FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
82 24 : ShapePtr pMasterShape;
83 :
84 12 : switch (nElement & 0xffff)
85 : {
86 : case XML_lockedCanvas:
87 12 : mxLockedCanvasContext.set(new LockedCanvasContext(*rFragmentHandler));
88 12 : break;
89 : default:
90 0 : break;
91 12 : }
92 : }
93 :
94 77 : return mxLockedCanvasContext;
95 : }
96 :
97 : /*
98 : * This method creates new ChartGraphicDataContext Object.
99 : */
100 438 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getChartShapeContext(sal_Int32 nElement)
101 : {
102 438 : if (!mxChartShapeContext.is())
103 : {
104 90 : switch (nElement & 0xffff)
105 : {
106 : case XML_chart:
107 : {
108 : std::unique_ptr<ContextHandler2Helper> pFragmentHandler(
109 90 : new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
110 90 : mpShape.reset(new Shape("com.sun.star.drawing.OLE2Shape" ));
111 90 : mxChartShapeContext.set(new ChartGraphicDataContext(*pFragmentHandler, mpShape, true));
112 90 : break;
113 : }
114 : default:
115 0 : break;
116 : }
117 : }
118 :
119 438 : return mxChartShapeContext;
120 : }
121 :
122 7902 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement)
123 : {
124 7902 : if (!mxWpsContext.is())
125 : {
126 1242 : FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
127 2484 : ShapePtr pMasterShape;
128 :
129 2484 : uno::Reference<drawing::XShape> xShape;
130 : // No element happens in case of pretty-printed XML, bodyPr is the case when we are called again after <wps:txbx>.
131 1242 : if (!nElement || nElement == WPS_TOKEN(bodyPr))
132 : // Assume that this is just a continuation of the previous shape.
133 396 : xShape = mxSavedShape;
134 :
135 1242 : switch (getBaseToken(nStartElement))
136 : {
137 : case XML_wsp:
138 1242 : mxWpsContext.set(new WpsContext(*rFragmentHandler, xShape));
139 1242 : break;
140 : default:
141 0 : break;
142 1242 : }
143 : }
144 :
145 7902 : return mxWpsContext;
146 : }
147 :
148 887 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpgContext(sal_Int32 nElement)
149 : {
150 887 : if (!mxWpgContext.is())
151 : {
152 70 : FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
153 140 : ShapePtr pMasterShape;
154 :
155 70 : switch (getBaseToken(nElement))
156 : {
157 : case XML_wgp:
158 70 : mxWpgContext.set(new WpgContext(*rFragmentHandler));
159 70 : break;
160 : default:
161 0 : break;
162 70 : }
163 : }
164 :
165 887 : return mxWpgContext;
166 : }
167 :
168 : uno::Reference<xml::sax::XFastContextHandler>
169 2426 : ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
170 : {
171 2426 : if (! mxGraphicShapeContext.is())
172 : {
173 : std::shared_ptr<ContextHandler2Helper> pFragmentHandler
174 309 : (new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
175 618 : ShapePtr pMasterShape;
176 :
177 309 : switch (Element & 0xffff)
178 : {
179 : case XML_graphic:
180 0 : mpShape.reset(new Shape("com.sun.star.drawing.GraphicObjectShape" ));
181 : mxGraphicShapeContext.set
182 0 : (new GraphicalObjectFrameContext(*pFragmentHandler, pMasterShape, mpShape, true));
183 0 : break;
184 : case XML_pic:
185 309 : mpShape.reset(new Shape("com.sun.star.drawing.GraphicObjectShape" ));
186 : mxGraphicShapeContext.set
187 309 : (new GraphicShapeContext(*pFragmentHandler, pMasterShape, mpShape));
188 309 : break;
189 : default:
190 0 : break;
191 309 : }
192 : }
193 :
194 2426 : return mxGraphicShapeContext;
195 : }
196 :
197 : uno::Reference<xml::sax::XFastContextHandler>
198 5549 : ShapeContextHandler::getDrawingShapeContext()
199 : {
200 5549 : if (!mxDrawingFragmentHandler.is())
201 : {
202 799 : mpDrawing.reset( new oox::vml::Drawing( *mxFilterBase, mxDrawPage, oox::vml::VMLDRAWING_WORD ) );
203 : mxDrawingFragmentHandler.set
204 : (dynamic_cast<ContextHandler *>
205 : (new oox::vml::DrawingFragment
206 799 : ( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
207 : }
208 : else
209 : {
210 : // Reset the handler if fragment path has changed
211 4750 : OUString sHandlerFragmentPath = dynamic_cast<ContextHandler&>(*mxDrawingFragmentHandler.get()).getFragmentPath();
212 4750 : if ( !msRelationFragmentPath.equals(sHandlerFragmentPath) )
213 : {
214 8 : mxDrawingFragmentHandler.clear();
215 : mxDrawingFragmentHandler.set
216 : (dynamic_cast<ContextHandler *>
217 : (new oox::vml::DrawingFragment
218 8 : ( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
219 4750 : }
220 : }
221 5549 : return mxDrawingFragmentHandler;
222 : }
223 :
224 : uno::Reference<xml::sax::XFastContextHandler>
225 190 : ShapeContextHandler::getDiagramShapeContext()
226 : {
227 190 : if (!mxDiagramShapeContext.is())
228 : {
229 38 : std::shared_ptr<ContextHandler2Helper> pFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
230 38 : mpShape.reset(new Shape());
231 38 : mxDiagramShapeContext.set(new DiagramGraphicDataContext(*pFragmentHandler, mpShape));
232 : }
233 :
234 190 : return mxDiagramShapeContext;
235 : }
236 :
237 : uno::Reference<xml::sax::XFastContextHandler>
238 14065 : ShapeContextHandler::getContextHandler(sal_Int32 nElement)
239 : {
240 14065 : uno::Reference<xml::sax::XFastContextHandler> xResult;
241 :
242 14065 : switch (getNamespace( mnStartToken ))
243 : {
244 : case NMSP_doc:
245 : case NMSP_vml:
246 2145 : xResult.set(getDrawingShapeContext());
247 2145 : break;
248 : case NMSP_dmlDiagram:
249 190 : xResult.set(getDiagramShapeContext());
250 190 : break;
251 : case NMSP_dmlLockedCanvas:
252 77 : xResult.set(getLockedCanvasContext(mnStartToken));
253 77 : break;
254 : case NMSP_dmlChart:
255 438 : xResult.set(getChartShapeContext(mnStartToken));
256 438 : break;
257 : case NMSP_wps:
258 7902 : xResult.set(getWpsContext(mnStartToken, nElement));
259 7902 : break;
260 : case NMSP_wpg:
261 887 : xResult.set(getWpgContext(mnStartToken));
262 887 : break;
263 : default:
264 2426 : xResult.set(getGraphicShapeContext(mnStartToken));
265 2426 : break;
266 : }
267 :
268 14065 : return xResult;
269 : }
270 :
271 : // ::com::sun::star::xml::sax::XFastContextHandler:
272 1702 : void SAL_CALL ShapeContextHandler::startFastElement
273 : (::sal_Int32 Element,
274 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
275 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
276 : {
277 : static const OUString sInputStream
278 1702 : ("InputStream");
279 :
280 1702 : uno::Sequence<beans::PropertyValue> aSeq(1);
281 1702 : aSeq[0].Name = sInputStream;
282 1702 : aSeq[0].Value <<= mxInputStream;
283 1702 : mxFilterBase->filter(aSeq);
284 :
285 1702 : mpThemePtr.reset(new Theme());
286 :
287 1702 : if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) ||
288 724 : Element == WPS_TOKEN(wsp) || Element == WPG_TOKEN(wgp) || Element == OOX_TOKEN(dmlPicture, pic))
289 : {
290 : // Parse the theme relation, if available; the diagram won't have colors without it.
291 1338 : if (!msRelationFragmentPath.isEmpty())
292 : {
293 : // Get Target for Type = "officeDocument" from _rels/.rels file
294 : // aOfficeDocumentFragmentPath is pointing to "word/document.xml" for docx & to "ppt/presentation.xml" for pptx
295 1338 : FragmentHandlerRef rFragmentHandlerRef(new ShapeFragmentHandler(*mxFilterBase, "/"));
296 2676 : OUString aOfficeDocumentFragmentPath = rFragmentHandlerRef->getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
297 :
298 : // Get the theme DO NOT use msRelationFragmentPath for getting theme as for a document there is a single theme in document.xml.rels
299 : // and the same is used by header and footer as well.
300 2676 : FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, aOfficeDocumentFragmentPath));
301 2676 : OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
302 :
303 1338 : if(!aThemeFragmentPath.isEmpty())
304 : {
305 1242 : uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
306 1242 : mxFilterBase->importFragment(new ThemeFragmentHandler(*mxFilterBase, aThemeFragmentPath, *mpThemePtr ), xDoc);
307 1242 : ShapeFilterBase* pShapeFilterBase(dynamic_cast<ShapeFilterBase*>(mxFilterBase.get()));
308 1242 : if (pShapeFilterBase)
309 1242 : pShapeFilterBase->setCurrentTheme(mpThemePtr);
310 1338 : }
311 : }
312 :
313 1338 : createFastChildContext(Element, Attribs);
314 : }
315 :
316 : // Entering VML block (startFastElement() is called for the outermost tag),
317 : // handle possible recursion.
318 1702 : if ( getContextHandler() == getDrawingShapeContext() )
319 364 : mpDrawing->getShapes().pushMark();
320 :
321 3404 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
322 :
323 1702 : if (xContextHandler.is())
324 3404 : xContextHandler->startFastElement(Element, Attribs);
325 1702 : }
326 :
327 0 : void SAL_CALL ShapeContextHandler::startUnknownElement
328 : (const OUString & Namespace, const OUString & Name,
329 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
330 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
331 : {
332 0 : if ( getContextHandler() == getDrawingShapeContext() )
333 0 : mpDrawing->getShapes().pushMark();
334 :
335 0 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
336 :
337 0 : if (xContextHandler.is())
338 0 : xContextHandler->startUnknownElement(Namespace, Name, Attribs);
339 0 : }
340 :
341 1702 : void SAL_CALL ShapeContextHandler::endFastElement(::sal_Int32 Element)
342 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
343 : {
344 1702 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
345 :
346 1702 : if (xContextHandler.is())
347 1702 : xContextHandler->endFastElement(Element);
348 : // In case a textbox is sent, and later we get additional properties for
349 : // the textbox, then the wps context is not cleared, so do that here.
350 1702 : if (Element == (NMSP_wps | XML_wsp))
351 : {
352 846 : uno::Reference<lang::XServiceInfo> xServiceInfo(mxSavedShape, uno::UNO_QUERY);
353 846 : bool bTextFrame = xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame");
354 846 : bool bTextBox = false;
355 846 : if (!bTextFrame)
356 : {
357 846 : uno::Reference<beans::XPropertySet> xPropertySet(mxSavedShape, uno::UNO_QUERY);
358 846 : if (xPropertySet.is())
359 685 : bTextBox = xPropertySet->getPropertyValue("TextBox").get<bool>();
360 : }
361 846 : if (bTextFrame || bTextBox)
362 437 : mxWpsContext.clear();
363 846 : mxSavedShape.clear();
364 1702 : }
365 1702 : }
366 :
367 0 : void SAL_CALL ShapeContextHandler::endUnknownElement
368 : (const OUString & Namespace,
369 : const OUString & Name)
370 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
371 : {
372 0 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
373 :
374 0 : if (xContextHandler.is())
375 0 : xContextHandler->endUnknownElement(Namespace, Name);
376 0 : }
377 :
378 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
379 6639 : ShapeContextHandler::createFastChildContext
380 : (::sal_Int32 Element,
381 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
382 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
383 : {
384 6639 : uno::Reference< xml::sax::XFastContextHandler > xResult;
385 13278 : uno::Reference< xml::sax::XFastContextHandler > xContextHandler(getContextHandler(Element));
386 :
387 6639 : if (xContextHandler.is())
388 6639 : xResult.set(xContextHandler->createFastChildContext
389 6639 : (Element, Attribs));
390 :
391 13278 : return xResult;
392 : }
393 :
394 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
395 0 : ShapeContextHandler::createUnknownChildContext
396 : (const OUString & Namespace,
397 : const OUString & Name,
398 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
399 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
400 : {
401 0 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
402 :
403 0 : if (xContextHandler.is())
404 0 : return xContextHandler->createUnknownChildContext
405 0 : (Namespace, Name, Attribs);
406 :
407 0 : return uno::Reference< xml::sax::XFastContextHandler >();
408 : }
409 :
410 618 : void SAL_CALL ShapeContextHandler::characters(const OUString & aChars)
411 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
412 : {
413 618 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
414 :
415 618 : if (xContextHandler.is())
416 618 : xContextHandler->characters(aChars);
417 618 : }
418 :
419 : // ::com::sun::star::xml::sax::XFastShapeContextHandler:
420 : uno::Reference< drawing::XShape > SAL_CALL
421 1702 : ShapeContextHandler::getShape() throw (uno::RuntimeException, std::exception)
422 : {
423 1702 : uno::Reference< drawing::XShape > xResult;
424 3404 : uno::Reference< drawing::XShapes > xShapes( mxDrawPage, uno::UNO_QUERY );
425 :
426 1702 : if (mxFilterBase.is() && xShapes.is())
427 : {
428 1702 : if ( getContextHandler() == getDrawingShapeContext() )
429 : {
430 364 : mpDrawing->finalizeFragmentImport();
431 364 : if( std::shared_ptr< vml::ShapeBase > pShape = mpDrawing->getShapes().takeLastShape() )
432 361 : xResult = pShape->convertAndInsert( xShapes );
433 : // Only now remove the recursion mark, because getShape() is called in writerfilter
434 : // after endFastElement().
435 364 : mpDrawing->getShapes().popMark();
436 : }
437 1338 : else if (mxDiagramShapeContext.is())
438 : {
439 38 : basegfx::B2DHomMatrix aMatrix;
440 38 : if (mpShape->getExtDrawings().size() == 0)
441 : {
442 10 : mpShape->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, mpShape->getFillProperties() );
443 10 : xResult = mpShape->getXShape();
444 : }
445 : else
446 : {
447 : // Prerendered diagram output is available, then use that, and throw away the original result.
448 56 : for (std::vector<OUString>::const_iterator aIt = mpShape->getExtDrawings().begin(); aIt != mpShape->getExtDrawings().end(); ++aIt)
449 : {
450 28 : DiagramGraphicDataContext* pDiagramGraphicDataContext = dynamic_cast<DiagramGraphicDataContext*>(mxDiagramShapeContext.get());
451 28 : if (!pDiagramGraphicDataContext)
452 0 : break;
453 28 : OUString aFragmentPath(pDiagramGraphicDataContext->getFragmentPathFromRelId(*aIt));
454 56 : oox::drawingml::ShapePtr pShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) );
455 28 : pShapePtr->setDiagramType();
456 28 : mxFilterBase->importFragment(new ShapeDrawingFragmentHandler(*mxFilterBase, aFragmentPath, pShapePtr));
457 :
458 56 : uno::Sequence<beans::PropertyValue> aValue(mpShape->getDiagramDoms());
459 56 : uno::Sequence < uno::Any > diagramDrawing(2);
460 : // drawingValue[0] => dom, drawingValue[1] => Sequence of associated relationships
461 :
462 28 : sal_Int32 length = aValue.getLength();
463 28 : aValue.realloc(length+1);
464 :
465 28 : diagramDrawing[0] = uno::makeAny( mxFilterBase->importFragment( aFragmentPath ) );
466 84 : diagramDrawing[1] = uno::makeAny( pShapePtr->resolveRelationshipsOfTypeFromOfficeDoc(
467 56 : *mxFilterBase, aFragmentPath, "image" ) );
468 :
469 28 : beans::PropertyValue* pValue = aValue.getArray();
470 28 : pValue[length].Name = "OOXDrawing";
471 28 : pValue[length].Value = uno::makeAny( diagramDrawing );
472 :
473 28 : pShapePtr->setDiagramDoms( aValue );
474 :
475 28 : pShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShapePtr->getFillProperties() );
476 28 : xResult = pShapePtr->getXShape();
477 28 : }
478 28 : mpShape.reset();
479 : }
480 38 : mxDiagramShapeContext.clear();
481 : }
482 1300 : else if (mxLockedCanvasContext.is())
483 : {
484 8 : ShapePtr pShape = dynamic_cast<LockedCanvasContext&>(*mxLockedCanvasContext.get()).getShape();
485 8 : if (pShape)
486 : {
487 6 : basegfx::B2DHomMatrix aMatrix;
488 6 : pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
489 6 : xResult = pShape->getXShape();
490 6 : mxLockedCanvasContext.clear();
491 8 : }
492 : }
493 : //NMSP_dmlChart == getNamespace( mnStartToken ) check is introduced to make sure that
494 : //mnStartToken is set as NMSP_dmlChart in setStartToken.
495 : //Only in case it is set then only the below block of code for ChartShapeContext should be executed.
496 1292 : else if (mxChartShapeContext.is() && (NMSP_dmlChart == getNamespace( mnStartToken )))
497 : {
498 86 : ChartGraphicDataContext* pChartGraphicDataContext = dynamic_cast<ChartGraphicDataContext*>(mxChartShapeContext.get());
499 86 : if (pChartGraphicDataContext)
500 : {
501 86 : basegfx::B2DHomMatrix aMatrix;
502 172 : oox::drawingml::ShapePtr xShapePtr( pChartGraphicDataContext->getShape());
503 : // See SwXTextDocument::createInstance(), ODF import uses the same hack.
504 86 : xShapePtr->setServiceName("com.sun.star.drawing.temporaryForXMLImportOLE2Shape");
505 86 : xShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, xShapePtr->getFillProperties() );
506 172 : xResult = xShapePtr->getXShape();
507 : }
508 86 : mxChartShapeContext.clear();
509 : }
510 1206 : else if (mxWpsContext.is())
511 : {
512 846 : ShapePtr pShape = dynamic_cast<WpsContext&>(*mxWpsContext.get()).getShape();
513 846 : if (pShape)
514 : {
515 846 : basegfx::B2DHomMatrix aMatrix;
516 846 : pShape->setPosition(maPosition);
517 846 : pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
518 846 : xResult = pShape->getXShape();
519 846 : mxSavedShape = xResult;
520 846 : mxWpsContext.clear();
521 846 : }
522 : }
523 360 : else if (mxWpgContext.is())
524 : {
525 70 : ShapePtr pShape = dynamic_cast<WpgContext&>(*mxWpgContext.get()).getShape();
526 70 : if (pShape)
527 : {
528 70 : basegfx::B2DHomMatrix aMatrix;
529 70 : pShape->setPosition(maPosition);
530 70 : pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
531 70 : xResult = pShape->getXShape();
532 70 : mxWpgContext.clear();
533 70 : }
534 : }
535 290 : else if (mpShape.get() != NULL)
536 : {
537 290 : basegfx::B2DHomMatrix aTransformation;
538 290 : mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aTransformation, mpShape->getFillProperties() );
539 290 : xResult.set(mpShape->getXShape());
540 290 : mxGraphicShapeContext.clear( );
541 : }
542 : }
543 :
544 3404 : return xResult;
545 : }
546 :
547 : css::uno::Reference< css::drawing::XDrawPage > SAL_CALL
548 0 : ShapeContextHandler::getDrawPage() throw (css::uno::RuntimeException, std::exception)
549 : {
550 0 : return mxDrawPage;
551 : }
552 :
553 1702 : void SAL_CALL ShapeContextHandler::setDrawPage
554 : (const css::uno::Reference< css::drawing::XDrawPage > & the_value)
555 : throw (css::uno::RuntimeException, std::exception)
556 : {
557 1702 : mxDrawPage = the_value;
558 1702 : }
559 :
560 : css::uno::Reference< css::frame::XModel > SAL_CALL
561 0 : ShapeContextHandler::getModel() throw (css::uno::RuntimeException, std::exception)
562 : {
563 0 : if( !mxFilterBase.is() )
564 0 : throw uno::RuntimeException();
565 0 : return mxFilterBase->getModel();
566 : }
567 :
568 1702 : void SAL_CALL ShapeContextHandler::setModel
569 : (const css::uno::Reference< css::frame::XModel > & the_value)
570 : throw (css::uno::RuntimeException, std::exception)
571 : {
572 1702 : if( !mxFilterBase.is() )
573 0 : throw uno::RuntimeException();
574 1702 : uno::Reference<lang::XComponent> xComp(the_value, uno::UNO_QUERY_THROW);
575 1702 : mxFilterBase->setTargetDocument(xComp);
576 1702 : }
577 :
578 : uno::Reference< io::XInputStream > SAL_CALL
579 0 : ShapeContextHandler::getInputStream() throw (uno::RuntimeException, std::exception)
580 : {
581 0 : return mxInputStream;
582 : }
583 :
584 1702 : void SAL_CALL ShapeContextHandler::setInputStream
585 : (const uno::Reference< io::XInputStream > & the_value)
586 : throw (uno::RuntimeException, std::exception)
587 : {
588 1702 : mxInputStream = the_value;
589 1702 : }
590 :
591 0 : OUString SAL_CALL ShapeContextHandler::getRelationFragmentPath()
592 : throw (uno::RuntimeException, std::exception)
593 : {
594 0 : return msRelationFragmentPath;
595 : }
596 :
597 1702 : void SAL_CALL ShapeContextHandler::setRelationFragmentPath(const OUString & the_value)
598 : throw (uno::RuntimeException, std::exception)
599 : {
600 1702 : msRelationFragmentPath = the_value;
601 1702 : }
602 :
603 5375 : ::sal_Int32 SAL_CALL ShapeContextHandler::getStartToken() throw (::com::sun::star::uno::RuntimeException, std::exception)
604 : {
605 5375 : return mnStartToken;
606 : }
607 :
608 1702 : void SAL_CALL ShapeContextHandler::setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException, std::exception)
609 : {
610 1702 : mnStartToken = _starttoken;
611 1702 : }
612 :
613 0 : awt::Point SAL_CALL ShapeContextHandler::getPosition() throw (uno::RuntimeException, std::exception)
614 : {
615 0 : return maPosition;
616 : }
617 :
618 1702 : void SAL_CALL ShapeContextHandler::setPosition(const awt::Point& rPosition) throw (uno::RuntimeException, std::exception)
619 : {
620 1702 : maPosition = rPosition;
621 1702 : }
622 :
623 1702 : void SAL_CALL ShapeContextHandler::setDocumentProperties(const uno::Reference<document::XDocumentProperties>& xDocProps)
624 : throw (css::uno::RuntimeException, std::exception)
625 : {
626 1702 : mxDocumentProperties = xDocProps;
627 1702 : mxFilterBase->checkDocumentProperties(mxDocumentProperties);
628 1702 : }
629 :
630 0 : uno::Reference<document::XDocumentProperties> SAL_CALL ShapeContextHandler::getDocumentProperties()
631 : throw (css::uno::RuntimeException, std::exception)
632 : {
633 0 : return mxDocumentProperties;
634 : }
635 :
636 1 : OUString ShapeContextHandler::getImplementationName()
637 : throw (css::uno::RuntimeException, std::exception)
638 : {
639 1 : return ShapeContextHandler_getImplementationName();
640 : }
641 :
642 1 : uno::Sequence< OUString > ShapeContextHandler::getSupportedServiceNames()
643 : throw (css::uno::RuntimeException, std::exception)
644 : {
645 1 : return ShapeContextHandler_getSupportedServiceNames();
646 : }
647 :
648 0 : sal_Bool SAL_CALL ShapeContextHandler::supportsService(const OUString & ServiceName)
649 : throw (css::uno::RuntimeException, std::exception)
650 : {
651 0 : return cppu::supportsService(this, ServiceName);
652 : }
653 :
654 246 : }}
655 :
656 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|