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 <boost/scoped_ptr.hpp>
32 : #include <cppuhelper/supportsservice.hxx>
33 :
34 : namespace oox { namespace shape {
35 :
36 : using namespace ::com::sun::star;
37 : using namespace core;
38 : using namespace drawingml;
39 :
40 144 : OUString SAL_CALL ShapeContextHandler_getImplementationName()
41 : {
42 144 : return OUString( "com.sun.star.comp.oox.ShapeContextHandler" );
43 : }
44 :
45 : uno::Sequence< OUString > SAL_CALL
46 32 : ShapeContextHandler_getSupportedServiceNames()
47 : {
48 32 : uno::Sequence< OUString > s(1);
49 32 : s[0] = "com.sun.star.xml.sax.FastShapeContextHandler";
50 32 : return s;
51 : }
52 :
53 : uno::Reference< uno::XInterface > SAL_CALL
54 1510 : ShapeContextHandler_createInstance( const uno::Reference< uno::XComponentContext > & context)
55 : throw (uno::Exception)
56 : {
57 1510 : return static_cast< ::cppu::OWeakObject* >( new ShapeContextHandler(context) );
58 : }
59 :
60 1510 : ShapeContextHandler::ShapeContextHandler
61 : (uno::Reference< uno::XComponentContext > const & context) :
62 1510 : mnStartToken(0), m_xContext(context)
63 : {
64 : try
65 : {
66 1510 : mxFilterBase.set( new ShapeFilterBase(context) );
67 : }
68 0 : catch( uno::Exception& )
69 : {
70 : }
71 1510 : }
72 :
73 3020 : ShapeContextHandler::~ShapeContextHandler()
74 : {
75 3020 : }
76 :
77 162 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getLockedCanvasContext(sal_Int32 nElement)
78 : {
79 162 : if (!mxLockedCanvasContext.is())
80 : {
81 24 : FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
82 48 : ShapePtr pMasterShape;
83 :
84 24 : switch (nElement & 0xffff)
85 : {
86 : case XML_lockedCanvas:
87 24 : mxLockedCanvasContext.set(new LockedCanvasContext(*rFragmentHandler));
88 24 : break;
89 : default:
90 0 : break;
91 24 : }
92 : }
93 :
94 162 : return mxLockedCanvasContext;
95 : }
96 :
97 : /*
98 : * This method creates new ChartGraphicDataContext Object.
99 : */
100 876 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getChartShapeContext(sal_Int32 nElement)
101 : {
102 876 : if (!mxChartShapeContext.is())
103 : {
104 180 : switch (nElement & 0xffff)
105 : {
106 : case XML_chart:
107 : {
108 : boost::scoped_ptr<ContextHandler2Helper> pFragmentHandler(
109 180 : new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
110 180 : mpShape.reset(new Shape("com.sun.star.drawing.OLE2Shape" ));
111 180 : mxChartShapeContext.set(new ChartGraphicDataContext(*pFragmentHandler, mpShape, true));
112 180 : break;
113 : }
114 : default:
115 0 : break;
116 : }
117 : }
118 :
119 876 : return mxChartShapeContext;
120 : }
121 :
122 15440 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement)
123 : {
124 15440 : if (!mxWpsContext.is())
125 : {
126 2336 : FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
127 4672 : ShapePtr pMasterShape;
128 :
129 4672 : 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 2336 : if (!nElement || nElement == WPS_TOKEN(bodyPr))
132 : // Assume that this is just a continuation of the previous shape.
133 730 : xShape = mxSavedShape;
134 :
135 2336 : switch (getBaseToken(nStartElement))
136 : {
137 : case XML_wsp:
138 2336 : mxWpsContext.set(new WpsContext(*rFragmentHandler, xShape));
139 2336 : break;
140 : default:
141 0 : break;
142 2336 : }
143 : }
144 :
145 15440 : return mxWpsContext;
146 : }
147 :
148 1732 : uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpgContext(sal_Int32 nElement)
149 : {
150 1732 : if (!mxWpgContext.is())
151 : {
152 130 : FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
153 260 : ShapePtr pMasterShape;
154 :
155 130 : switch (getBaseToken(nElement))
156 : {
157 : case XML_wgp:
158 130 : mxWpgContext.set(new WpgContext(*rFragmentHandler));
159 130 : break;
160 : default:
161 0 : break;
162 130 : }
163 : }
164 :
165 1732 : return mxWpgContext;
166 : }
167 :
168 : uno::Reference<xml::sax::XFastContextHandler>
169 4220 : ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
170 : {
171 4220 : if (! mxGraphicShapeContext.is())
172 : {
173 : boost::shared_ptr<ContextHandler2Helper> pFragmentHandler
174 526 : (new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
175 1052 : ShapePtr pMasterShape;
176 :
177 526 : 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 526 : mpShape.reset(new Shape("com.sun.star.drawing.GraphicObjectShape" ));
186 : mxGraphicShapeContext.set
187 526 : (new GraphicShapeContext(*pFragmentHandler, pMasterShape, mpShape));
188 526 : break;
189 : default:
190 0 : break;
191 526 : }
192 : }
193 :
194 4220 : return mxGraphicShapeContext;
195 : }
196 :
197 : uno::Reference<xml::sax::XFastContextHandler>
198 11038 : ShapeContextHandler::getDrawingShapeContext()
199 : {
200 11038 : if (!mxDrawingFragmentHandler.is())
201 : {
202 1508 : 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 1508 : ( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
207 : }
208 : else
209 : {
210 : // Reset the handler if fragment path has changed
211 9530 : OUString sHandlerFragmentPath = dynamic_cast<ContextHandler&>(*mxDrawingFragmentHandler.get()).getFragmentPath();
212 9530 : if ( !msRelationFragmentPath.equals(sHandlerFragmentPath) )
213 : {
214 16 : mxDrawingFragmentHandler.clear();
215 : mxDrawingFragmentHandler.set
216 : (dynamic_cast<ContextHandler *>
217 : (new oox::vml::DrawingFragment
218 16 : ( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
219 9530 : }
220 : }
221 11038 : return mxDrawingFragmentHandler;
222 : }
223 :
224 : uno::Reference<xml::sax::XFastContextHandler>
225 360 : ShapeContextHandler::getDiagramShapeContext()
226 : {
227 360 : if (!mxDiagramShapeContext.is())
228 : {
229 72 : boost::shared_ptr<ContextHandler2Helper> pFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
230 72 : mpShape.reset(new Shape());
231 72 : mxDiagramShapeContext.set(new DiagramGraphicDataContext(*pFragmentHandler, mpShape));
232 : }
233 :
234 360 : return mxDiagramShapeContext;
235 : }
236 :
237 : uno::Reference<xml::sax::XFastContextHandler>
238 27404 : ShapeContextHandler::getContextHandler(sal_Int32 nElement)
239 : {
240 27404 : uno::Reference<xml::sax::XFastContextHandler> xResult;
241 :
242 27404 : switch (getNamespace( mnStartToken ))
243 : {
244 : case NMSP_doc:
245 : case NMSP_vml:
246 4614 : xResult.set(getDrawingShapeContext());
247 4614 : break;
248 : case NMSP_dmlDiagram:
249 360 : xResult.set(getDiagramShapeContext());
250 360 : break;
251 : case NMSP_dmlLockedCanvas:
252 162 : xResult.set(getLockedCanvasContext(mnStartToken));
253 162 : break;
254 : case NMSP_dmlChart:
255 876 : xResult.set(getChartShapeContext(mnStartToken));
256 876 : break;
257 : case NMSP_wps:
258 15440 : xResult.set(getWpsContext(mnStartToken, nElement));
259 15440 : break;
260 : case NMSP_wpg:
261 1732 : xResult.set(getWpgContext(mnStartToken));
262 1732 : break;
263 : default:
264 4220 : xResult.set(getGraphicShapeContext(mnStartToken));
265 4220 : break;
266 : }
267 :
268 27404 : return xResult;
269 : }
270 :
271 : // ::com::sun::star::xml::sax::XFastContextHandler:
272 3212 : 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 3212 : ("InputStream");
279 :
280 3212 : uno::Sequence<beans::PropertyValue> aSeq(1);
281 3212 : aSeq[0].Name = sInputStream;
282 3212 : aSeq[0].Value <<= mxInputStream;
283 3212 : mxFilterBase->filter(aSeq);
284 :
285 3212 : mpThemePtr.reset(new Theme());
286 :
287 3212 : if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) ||
288 1346 : 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 2488 : 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 2488 : FragmentHandlerRef rFragmentHandlerRef(new ShapeFragmentHandler(*mxFilterBase, "/"));
296 4976 : 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 4976 : FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, aOfficeDocumentFragmentPath));
301 4976 : OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
302 :
303 2488 : if(!aThemeFragmentPath.isEmpty())
304 : {
305 2404 : uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
306 2404 : mxFilterBase->importFragment(new ThemeFragmentHandler(*mxFilterBase, aThemeFragmentPath, *mpThemePtr ), xDoc);
307 2404 : ShapeFilterBase* pShapeFilterBase(dynamic_cast<ShapeFilterBase*>(mxFilterBase.get()));
308 2404 : if (pShapeFilterBase)
309 2404 : pShapeFilterBase->setCurrentTheme(mpThemePtr);
310 2488 : }
311 : }
312 :
313 2488 : createFastChildContext(Element, Attribs);
314 : }
315 :
316 : // Entering VML block (startFastElement() is called for the outermost tag),
317 : // handle possible recursion.
318 3212 : if ( getContextHandler() == getDrawingShapeContext() )
319 724 : mpDrawing->getShapes().pushMark();
320 :
321 6424 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
322 :
323 3212 : if (xContextHandler.is())
324 6424 : xContextHandler->startFastElement(Element, Attribs);
325 3212 : }
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 3212 : void SAL_CALL ShapeContextHandler::endFastElement(::sal_Int32 Element)
342 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
343 : {
344 3212 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
345 :
346 3212 : if (xContextHandler.is())
347 3212 : 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 3212 : if (Element == (NMSP_wps | XML_wsp))
351 : {
352 1606 : uno::Reference<lang::XServiceInfo> xServiceInfo(mxSavedShape, uno::UNO_QUERY);
353 1606 : bool bTextFrame = xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame");
354 1606 : bool bTextBox = false;
355 1606 : if (!bTextFrame)
356 : {
357 1606 : uno::Reference<beans::XPropertySet> xPropertySet(mxSavedShape, uno::UNO_QUERY);
358 1606 : if (xPropertySet.is())
359 1296 : bTextBox = xPropertySet->getPropertyValue("TextBox").get<bool>();
360 : }
361 1606 : if (bTextFrame || bTextBox)
362 804 : mxWpsContext.clear();
363 1606 : mxSavedShape.clear();
364 3212 : }
365 3212 : }
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 12300 : 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 12300 : uno::Reference< xml::sax::XFastContextHandler > xResult;
385 24600 : uno::Reference< xml::sax::XFastContextHandler > xContextHandler(getContextHandler(Element));
386 :
387 12300 : if (xContextHandler.is())
388 12300 : xResult.set(xContextHandler->createFastChildContext
389 12300 : (Element, Attribs));
390 :
391 24600 : 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 2256 : void SAL_CALL ShapeContextHandler::characters(const OUString & aChars)
411 : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
412 : {
413 2256 : uno::Reference<XFastContextHandler> xContextHandler(getContextHandler());
414 :
415 2256 : if (xContextHandler.is())
416 2256 : xContextHandler->characters(aChars);
417 2256 : }
418 :
419 : // ::com::sun::star::xml::sax::XFastShapeContextHandler:
420 : uno::Reference< drawing::XShape > SAL_CALL
421 3212 : ShapeContextHandler::getShape() throw (uno::RuntimeException, std::exception)
422 : {
423 3212 : uno::Reference< drawing::XShape > xResult;
424 6424 : uno::Reference< drawing::XShapes > xShapes( mxDrawPage, uno::UNO_QUERY );
425 :
426 3212 : if (mxFilterBase.is() && xShapes.is())
427 : {
428 3212 : if ( getContextHandler() == getDrawingShapeContext() )
429 : {
430 724 : mpDrawing->finalizeFragmentImport();
431 724 : if( boost::shared_ptr< vml::ShapeBase > pShape = mpDrawing->getShapes().takeLastShape() )
432 718 : xResult = pShape->convertAndInsert( xShapes );
433 : // Only now remove the recursion mark, because getShape() is called in writerfilter
434 : // after endFastElement().
435 724 : mpDrawing->getShapes().popMark();
436 : }
437 2488 : else if (mxDiagramShapeContext.is())
438 : {
439 72 : basegfx::B2DHomMatrix aMatrix;
440 72 : if (mpShape->getExtDrawings().size() == 0)
441 : {
442 20 : mpShape->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, mpShape->getFillProperties() );
443 20 : xResult = mpShape->getXShape();
444 : }
445 : else
446 : {
447 : // Prerendered diagram output is available, then use that, and throw away the original result.
448 104 : for (std::vector<OUString>::const_iterator aIt = mpShape->getExtDrawings().begin(); aIt != mpShape->getExtDrawings().end(); ++aIt)
449 : {
450 52 : DiagramGraphicDataContext* pDiagramGraphicDataContext = dynamic_cast<DiagramGraphicDataContext*>(mxDiagramShapeContext.get());
451 52 : if (!pDiagramGraphicDataContext)
452 0 : break;
453 52 : OUString aFragmentPath(pDiagramGraphicDataContext->getFragmentPathFromRelId(*aIt));
454 104 : oox::drawingml::ShapePtr pShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) );
455 52 : pShapePtr->setDiagramType();
456 52 : mxFilterBase->importFragment(new ShapeDrawingFragmentHandler(*mxFilterBase, aFragmentPath, pShapePtr));
457 :
458 104 : uno::Sequence<beans::PropertyValue> aValue(mpShape->getDiagramDoms());
459 104 : uno::Sequence < uno::Any > diagramDrawing(2);
460 : // drawingValue[0] => dom, drawingValue[1] => Sequence of associated relationships
461 :
462 52 : sal_Int32 length = aValue.getLength();
463 52 : aValue.realloc(length+1);
464 :
465 52 : diagramDrawing[0] = uno::makeAny( mxFilterBase->importFragment( aFragmentPath ) );
466 156 : diagramDrawing[1] = uno::makeAny( pShapePtr->resolveRelationshipsOfTypeFromOfficeDoc(
467 104 : *mxFilterBase, aFragmentPath, "image" ) );
468 :
469 52 : beans::PropertyValue* pValue = aValue.getArray();
470 52 : pValue[length].Name = "OOXDrawing";
471 52 : pValue[length].Value = uno::makeAny( diagramDrawing );
472 :
473 52 : pShapePtr->setDiagramDoms( aValue );
474 :
475 52 : pShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShapePtr->getFillProperties() );
476 52 : xResult = pShapePtr->getXShape();
477 52 : }
478 52 : mpShape.reset((Shape*)0);
479 : }
480 72 : mxDiagramShapeContext.clear();
481 : }
482 2416 : else if (mxLockedCanvasContext.is())
483 : {
484 16 : ShapePtr pShape = dynamic_cast<LockedCanvasContext&>(*mxLockedCanvasContext.get()).getShape();
485 16 : if (pShape)
486 : {
487 12 : basegfx::B2DHomMatrix aMatrix;
488 12 : pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
489 12 : xResult = pShape->getXShape();
490 12 : mxLockedCanvasContext.clear();
491 16 : }
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 2400 : else if (mxChartShapeContext.is() && (NMSP_dmlChart == getNamespace( mnStartToken )))
497 : {
498 172 : ChartGraphicDataContext* pChartGraphicDataContext = dynamic_cast<ChartGraphicDataContext*>(mxChartShapeContext.get());
499 172 : if (pChartGraphicDataContext)
500 : {
501 172 : basegfx::B2DHomMatrix aMatrix;
502 344 : oox::drawingml::ShapePtr xShapePtr( pChartGraphicDataContext->getShape());
503 : // See SwXTextDocument::createInstance(), ODF import uses the same hack.
504 172 : xShapePtr->setServiceName("com.sun.star.drawing.temporaryForXMLImportOLE2Shape");
505 172 : xShapePtr->addShape( *mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, xShapePtr->getFillProperties() );
506 344 : xResult = xShapePtr->getXShape();
507 : }
508 172 : mxChartShapeContext.clear();
509 : }
510 2228 : else if (mxWpsContext.is())
511 : {
512 1606 : ShapePtr pShape = dynamic_cast<WpsContext&>(*mxWpsContext.get()).getShape();
513 1606 : if (pShape)
514 : {
515 1606 : basegfx::B2DHomMatrix aMatrix;
516 1606 : pShape->setPosition(maPosition);
517 1606 : pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
518 1606 : xResult = pShape->getXShape();
519 1606 : mxSavedShape = xResult;
520 1606 : mxWpsContext.clear();
521 1606 : }
522 : }
523 622 : else if (mxWpgContext.is())
524 : {
525 130 : ShapePtr pShape = dynamic_cast<WpgContext&>(*mxWpgContext.get()).getShape();
526 130 : if (pShape)
527 : {
528 130 : basegfx::B2DHomMatrix aMatrix;
529 130 : pShape->setPosition(maPosition);
530 130 : pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
531 130 : xResult = pShape->getXShape();
532 130 : mxWpgContext.clear();
533 130 : }
534 : }
535 492 : else if (mpShape.get() != NULL)
536 : {
537 492 : basegfx::B2DHomMatrix aTransformation;
538 492 : mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aTransformation, mpShape->getFillProperties() );
539 492 : xResult.set(mpShape->getXShape());
540 492 : mxGraphicShapeContext.clear( );
541 : }
542 : }
543 :
544 6424 : 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 3212 : void SAL_CALL ShapeContextHandler::setDrawPage
554 : (const css::uno::Reference< css::drawing::XDrawPage > & the_value)
555 : throw (css::uno::RuntimeException, std::exception)
556 : {
557 3212 : mxDrawPage = the_value;
558 3212 : }
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 3212 : void SAL_CALL ShapeContextHandler::setModel
569 : (const css::uno::Reference< css::frame::XModel > & the_value)
570 : throw (css::uno::RuntimeException, std::exception)
571 : {
572 3212 : if( !mxFilterBase.is() )
573 0 : throw uno::RuntimeException();
574 3212 : uno::Reference<lang::XComponent> xComp(the_value, uno::UNO_QUERY_THROW);
575 3212 : mxFilterBase->setTargetDocument(xComp);
576 3212 : }
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 3212 : void SAL_CALL ShapeContextHandler::setInputStream
585 : (const uno::Reference< io::XInputStream > & the_value)
586 : throw (uno::RuntimeException, std::exception)
587 : {
588 3212 : mxInputStream = the_value;
589 3212 : }
590 :
591 0 : OUString SAL_CALL ShapeContextHandler::getRelationFragmentPath()
592 : throw (uno::RuntimeException, std::exception)
593 : {
594 0 : return msRelationFragmentPath;
595 : }
596 :
597 3212 : void SAL_CALL ShapeContextHandler::setRelationFragmentPath(const OUString & the_value)
598 : throw (uno::RuntimeException, std::exception)
599 : {
600 3212 : msRelationFragmentPath = the_value;
601 3212 : }
602 :
603 9956 : ::sal_Int32 SAL_CALL ShapeContextHandler::getStartToken() throw (::com::sun::star::uno::RuntimeException, std::exception)
604 : {
605 9956 : return mnStartToken;
606 : }
607 :
608 3212 : void SAL_CALL ShapeContextHandler::setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException, std::exception)
609 : {
610 3212 : mnStartToken = _starttoken;
611 3212 : }
612 :
613 0 : awt::Point SAL_CALL ShapeContextHandler::getPosition() throw (uno::RuntimeException, std::exception)
614 : {
615 0 : return maPosition;
616 : }
617 :
618 3212 : void SAL_CALL ShapeContextHandler::setPosition(const awt::Point& rPosition) throw (uno::RuntimeException, std::exception)
619 : {
620 3212 : maPosition = rPosition;
621 3212 : }
622 :
623 0 : OUString ShapeContextHandler::getImplementationName()
624 : throw (css::uno::RuntimeException, std::exception)
625 : {
626 0 : return ShapeContextHandler_getImplementationName();
627 : }
628 :
629 0 : uno::Sequence< OUString > ShapeContextHandler::getSupportedServiceNames()
630 : throw (css::uno::RuntimeException, std::exception)
631 : {
632 0 : return ShapeContextHandler_getSupportedServiceNames();
633 : }
634 :
635 0 : sal_Bool SAL_CALL ShapeContextHandler::supportsService(const OUString & ServiceName)
636 : throw (css::uno::RuntimeException, std::exception)
637 : {
638 0 : return cppu::supportsService(this, ServiceName);
639 : }
640 :
641 408 : }}
642 :
643 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|