LibreOffice Module xmloff (master) 1
ximpshap.cxx
Go to the documentation of this file.
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 <config_wasm_strip.h>
21
22#include <cassert>
23
24#include <sal/log.hxx>
25#include <com/sun/star/document/XEventsSupplier.hpp>
26#include <com/sun/star/container/XNameReplace.hpp>
27#include <com/sun/star/presentation/ClickAction.hpp>
28#include <com/sun/star/drawing/FillStyle.hpp>
29#include <com/sun/star/drawing/LineStyle.hpp>
30#include <utility>
32#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
33#include <com/sun/star/drawing/GluePoint2.hpp>
34#include <com/sun/star/drawing/Alignment.hpp>
35#include <com/sun/star/drawing/EscapeDirection.hpp>
36#include <com/sun/star/media/ZoomLevel.hpp>
37#include <com/sun/star/awt/Rectangle.hpp>
38#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
39#include <com/sun/star/container/XNameAccess.hpp>
40#include "ximpshap.hxx"
43#include <xmloff/xmluconv.hxx>
44#include <com/sun/star/container/XNamed.hpp>
45#include <com/sun/star/beans/XPropertySet.hpp>
46#include <com/sun/star/awt/XControlModel.hpp>
47#include <com/sun/star/drawing/XControlShape.hpp>
48#include <com/sun/star/drawing/PointSequenceSequence.hpp>
49#include <com/sun/star/drawing/PointSequence.hpp>
50#include <com/sun/star/lang/XServiceInfo.hpp>
51#include <com/sun/star/lang/XMultiServiceFactory.hpp>
52#include <com/sun/star/util/XCloneable.hpp>
53#include <com/sun/star/beans/XMultiPropertyStates.hpp>
54#include <xexptran.hxx>
55#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
56#include <com/sun/star/beans/XPropertySetInfo.hpp>
57#include <com/sun/star/drawing/HomogenMatrix3.hpp>
58#include <com/sun/star/graphic/XGraphic.hpp>
59#include <com/sun/star/style/XStyle.hpp>
60
64
65#include <xmloff/families.hxx>
67#include <xmloff/xmltoken.hxx>
71#include "sdpropls.hxx"
72#include "eventimp.hxx"
73#include "descriptionimp.hxx"
75#include "QRCodeContext.hxx"
76#include "ximpcustomshape.hxx"
78#include <xmloff/xmlerror.hxx>
82#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
83#include <com/sun/star/container/XChild.hpp>
84#include <com/sun/star/text/XTextDocument.hpp>
92#include <tools/urlobj.hxx>
93#include <o3tl/any.hxx>
94#include <o3tl/safeint.hxx>
95
96using namespace ::com::sun::star;
97using namespace ::com::sun::star::uno;
98using namespace ::com::sun::star::drawing;
99using namespace ::com::sun::star::style;
100using namespace ::com::sun::star::container;
101using namespace ::com::sun::star::document;
102using namespace ::xmloff::token;
103using namespace ::xmloff::EnhancedCustomShapeToken;
104
106{
107 { XML_TOP_LEFT, drawing::Alignment_TOP_LEFT },
108 { XML_TOP, drawing::Alignment_TOP },
109 { XML_TOP_RIGHT, drawing::Alignment_TOP_RIGHT },
110 { XML_LEFT, drawing::Alignment_LEFT },
111 { XML_CENTER, drawing::Alignment_CENTER },
112 { XML_RIGHT, drawing::Alignment_RIGHT },
113 { XML_BOTTOM_LEFT, drawing::Alignment_BOTTOM_LEFT },
114 { XML_BOTTOM, drawing::Alignment_BOTTOM },
115 { XML_BOTTOM_RIGHT, drawing::Alignment_BOTTOM_RIGHT },
116 { XML_TOKEN_INVALID, drawing::Alignment(0) }
117};
118
120{
121 { XML_AUTO, drawing::EscapeDirection_SMART },
122 { XML_LEFT, drawing::EscapeDirection_LEFT },
123 { XML_RIGHT, drawing::EscapeDirection_RIGHT },
124 { XML_UP, drawing::EscapeDirection_UP },
125 { XML_DOWN, drawing::EscapeDirection_DOWN },
126 { XML_HORIZONTAL, drawing::EscapeDirection_HORIZONTAL },
127 { XML_VERTICAL, drawing::EscapeDirection_VERTICAL },
128 { XML_TOKEN_INVALID, drawing::EscapeDirection(0) }
129};
130
131static bool ImpIsEmptyURL( std::u16string_view rURL )
132{
133 if( rURL.empty() )
134 return true;
135
136 // #i13140# Also compare against 'toplevel' URLs. which also
137 // result in empty filename strings.
138 if( rURL == u"#./" )
139 return true;
140
141 return false;
142}
143
144
146 SvXMLImport& rImport,
147 css::uno::Reference< css::xml::sax::XFastAttributeList> xAttrList,
148 uno::Reference< drawing::XShapes > xShapes,
149 bool bTemporaryShape)
150 : SvXMLShapeContext( rImport, bTemporaryShape )
151 , mxShapes(std::move( xShapes ))
152 , mxAttrList(std::move(xAttrList))
153 , mbListContextPushed( false )
154 , mnStyleFamily(XmlStyleFamily::SD_GRAPHICS_ID)
155 , mbIsPlaceholder(false)
156 , mbClearDefaultAttributes( true )
157 , mbIsUserTransformed(false)
158 , mnZOrder(-1)
159 , maSize(1, 1)
160 , mnRelWidth(0)
161 , mnRelHeight(0)
162 , maPosition(0, 0)
163 , mbVisible(true)
164 , mbPrintable(true)
165 , mbHaveXmlId(false)
166 , mbTextBox(false)
167{
168}
169
171{
172}
173
174css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLShapeContext::createFastChildContext(
175 sal_Int32 nElement,
176 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
177{
178 SvXMLImportContextRef xContext;
179 // #i68101#
180 if( nElement == XML_ELEMENT(SVG, XML_TITLE) || nElement == XML_ELEMENT(SVG, XML_DESC)
181 || nElement == XML_ELEMENT(SVG_COMPAT, XML_TITLE) || nElement == XML_ELEMENT(SVG_COMPAT, XML_DESC) )
182 {
183 xContext = new SdXMLDescriptionContext( GetImport(), nElement, mxShape );
184 }
185 else if( nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE) )
186 {
187 xContext = new SignatureLineContext( GetImport(), nElement, xAttrList, mxShape );
188 }
189 else if( nElement == XML_ELEMENT(LO_EXT, XML_QRCODE) )
190 {
191 xContext = new QRCodeContext( GetImport(), nElement, xAttrList, mxShape );
192 }
193 else if( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) )
194 {
195 xContext = new SdXMLEventsContext( GetImport(), mxShape );
196 }
197 else if( nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) )
198 {
199 addGluePoint( xAttrList );
200 }
201 else if( nElement == XML_ELEMENT(DRAW, XML_THUMBNAIL) )
202 {
203 // search attributes for xlink:href
204 maThumbnailURL = xAttrList->getOptionalValue(XML_ELEMENT(XLINK, XML_HREF));
205 }
206 else
207 {
208 // create text cursor on demand
209 if( !mxCursor.is() )
210 {
211 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
212 if( xText.is() )
213 {
215 GetImport().GetTextImport();
216 mxOldCursor = xTxtImport->GetCursor();
217 mxCursor = xText->createTextCursor();
218 if( mxCursor.is() )
219 {
220 xTxtImport->SetCursor( mxCursor );
221 }
222
223 // remember old list item and block (#91964#) and reset them
224 // for the text frame
225 xTxtImport->PushListContext();
226 mbListContextPushed = true;
227 }
228 }
229
230 // if we have a text cursor, lets try to import some text
231 if( mxCursor.is() )
232 {
233 xContext = GetImport().GetTextImport()->CreateTextChildContext(
234 GetImport(), nElement, xAttrList,
236 }
237 }
238
239 if (!xContext)
240 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
241
242 return xContext;
243}
244
245void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
246{
247 // get the gluepoints container for this shape if it's not already there
248 if( !mxGluePoints.is() )
249 {
250 uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
251 if( !xSupplier.is() )
252 return;
253
254 mxGluePoints.set( xSupplier->getGluePoints(), UNO_QUERY );
255
256 if( !mxGluePoints.is() )
257 return;
258 }
259
260 drawing::GluePoint2 aGluePoint;
261 aGluePoint.IsUserDefined = true;
262 aGluePoint.Position.X = 0;
263 aGluePoint.Position.Y = 0;
264 aGluePoint.Escape = drawing::EscapeDirection_SMART;
265 aGluePoint.PositionAlignment = drawing::Alignment_CENTER;
266 aGluePoint.IsRelative = true;
267
268 sal_Int32 nId = -1;
269
270 // read attributes for the 3DScene
271 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
272 {
273 switch(aIter.getToken())
274 {
275 case XML_ELEMENT(SVG, XML_X):
276 case XML_ELEMENT(SVG_COMPAT, XML_X):
277 GetImport().GetMM100UnitConverter().convertMeasureToCore(
278 aGluePoint.Position.X, aIter.toView());
279 break;
280 case XML_ELEMENT(SVG, XML_Y):
281 case XML_ELEMENT(SVG_COMPAT, XML_Y):
282 GetImport().GetMM100UnitConverter().convertMeasureToCore(
283 aGluePoint.Position.Y, aIter.toView());
284 break;
285 case XML_ELEMENT(DRAW, XML_ID):
286 nId = aIter.toInt32();
287 break;
289 {
290 drawing::Alignment eKind;
291 if( SvXMLUnitConverter::convertEnum( eKind, aIter.toView(), aXML_GlueAlignment_EnumMap ) )
292 {
293 aGluePoint.PositionAlignment = eKind;
294 aGluePoint.IsRelative = false;
295 }
296 break;
297 }
299 {
300 SvXMLUnitConverter::convertEnum( aGluePoint.Escape, aIter.toView(), aXML_GlueEscapeDirection_EnumMap );
301 break;
302 }
303 default:
304 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
305 }
306 }
307
308 if( nId != -1 )
309 {
310 try
311 {
312 sal_Int32 nInternalId = mxGluePoints->insert( uno::Any( aGluePoint ) );
313 GetImport().GetShapeImport()->addGluePointMapping( mxShape, nId, nInternalId );
314 }
315 catch(const uno::Exception&)
316 {
317 DBG_UNHANDLED_EXCEPTION( "xmloff", "during setting of gluepoints");
318 }
319 }
320}
321
322void SdXMLShapeContext::startFastElement (sal_Int32 /*nElement*/,
323 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
324{
325 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
326}
327
329{
330 if(mxCursor.is())
331 {
332 // tdf#72776 force UpdateData in the EditSource so we will not override text in SdrOutliner
333 if( mxLockable.is() )
334 {
335 mxLockable->removeActionLock();
336 mxLockable->addActionLock();
337 }
338
339 // delete addition newline
340 mxCursor->gotoEnd( false );
341 mxCursor->goLeft( 1, true );
342 mxCursor->setString( "" );
343
344 // reset cursor
345 GetImport().GetTextImport()->ResetCursor();
346 }
347
348 if(mxOldCursor.is())
349 GetImport().GetTextImport()->SetCursor( mxOldCursor );
350
351 // reinstall old list item (if necessary) #91964#
353 GetImport().GetTextImport()->PopListContext();
354 }
355
356 if( !msHyperlink.isEmpty() ) try
357 {
358 uno::Reference< beans::XPropertySet > xProp( mxShape, uno::UNO_QUERY );
359
360 if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName( "Hyperlink" ) )
361 xProp->setPropertyValue( "Hyperlink", uno::Any( msHyperlink ) );
362 Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY );
363
364 if( xEventsSupplier.is() )
365 {
366 Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_SET_THROW );
367
368 uno::Sequence< beans::PropertyValue > aProperties{
369 { /* Name */ "EventType",
370 /* Handle */ -1,
371 /* Value */ uno::Any(OUString( "Presentation" )),
372 /* State */ beans::PropertyState_DIRECT_VALUE },
373
374 { /* Name */ "ClickAction",
375 /* Handle */ -1,
376 /* Value */ uno::Any(css::presentation::ClickAction_DOCUMENT),
377 /* State */ beans::PropertyState_DIRECT_VALUE },
378
379 { /* Name */ "Bookmark",
380 /* Handle */ -1,
381 /* Value */ uno::Any(msHyperlink),
382 /* State */ beans::PropertyState_DIRECT_VALUE }
383 };
384
385 xEvents->replaceByName( "OnClick", Any( aProperties ) );
386 }
387 else
388 {
389 // in draw use the Bookmark property
390 Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
391 xSet->setPropertyValue( "Bookmark", Any( msHyperlink ) );
392 xSet->setPropertyValue("OnClick", Any( css::presentation::ClickAction_DOCUMENT ) );
393 }
394 }
395 catch(const Exception&)
396 {
397 DBG_UNHANDLED_EXCEPTION("xmloff", "while setting hyperlink");
398 }
399
400 if( mxLockable.is() )
401 mxLockable->removeActionLock();
402}
403
404void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
405{
406 if(xShape.is())
407 {
408 // set shape local
409 mxShape = xShape;
410
411 if(!maShapeName.isEmpty())
412 {
413 uno::Reference< container::XNamed > xNamed( mxShape, uno::UNO_QUERY );
414 if( xNamed.is() )
415 xNamed->setName( maShapeName );
416 }
417
418 rtl::Reference< XMLShapeImportHelper > xImp( GetImport().GetShapeImport() );
419 xImp->addShape( xShape, mxAttrList, mxShapes );
420
422 {
423 uno::Reference<beans::XMultiPropertyStates> xMultiPropertyStates(xShape, uno::UNO_QUERY );
424 if (xMultiPropertyStates.is())
425 xMultiPropertyStates->setAllPropertiesToDefault();
426 }
427
428 if( !mbVisible || !mbPrintable ) try
429 {
430 uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY_THROW );
431 if( !mbVisible )
432 xSet->setPropertyValue("Visible", uno::Any( false ) );
433
434 if( !mbPrintable )
435 xSet->setPropertyValue("Printable", uno::Any( false ) );
436 }
437 catch(const Exception&)
438 {
439 DBG_UNHANDLED_EXCEPTION( "xmloff", "while setting visible or printable" );
440 }
441
442 if(!mbTemporaryShape && (!GetImport().HasTextImport()
443 || !GetImport().GetTextImport()->IsInsideDeleteContext()))
444 {
445 xImp->shapeWithZIndexAdded( xShape, mnZOrder );
446 }
447
448 if (mnRelWidth || mnRelHeight)
449 {
450 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
451 uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
452 if (mnRelWidth && xPropertySetInfo->hasPropertyByName("RelativeWidth"))
453 xPropertySet->setPropertyValue("RelativeWidth", uno::Any(mnRelWidth));
454 if (mnRelHeight && xPropertySetInfo->hasPropertyByName("RelativeHeight"))
455 xPropertySet->setPropertyValue("RelativeHeight", uno::Any(mnRelHeight));
456 }
457
458 if( !maShapeId.isEmpty() )
459 {
460 uno::Reference< uno::XInterface > xRef( static_cast<uno::XInterface *>(xShape.get()) );
461 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef );
462 }
463
464 // #91065# count only if counting for shape import is enabled
465 if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
466 {
467 // #80365# increment progress bar at load once for each draw object
468 GetImport().GetProgressBarHelper()->Increment();
469 }
470 }
471
472 mxLockable.set( xShape, UNO_QUERY );
473
474 if( mxLockable.is() )
475 mxLockable->addActionLock();
476
477}
478
479void SdXMLShapeContext::AddShape(OUString const & serviceName)
480{
481 uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY);
482 if(!xServiceFact.is())
483 return;
484
485 try
486 {
487 /* Since fix for issue i33294 the Writer model doesn't support
488 com.sun.star.drawing.OLE2Shape anymore.
489 To handle Draw OLE objects it's decided to import these
490 objects as com.sun.star.drawing.OLE2Shape and convert these
491 objects after the import into com.sun.star.drawing.GraphicObjectShape.
492 */
493 uno::Reference< drawing::XShape > xShape;
494 if ( serviceName == "com.sun.star.drawing.OLE2Shape" &&
495 uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
496 {
497 xShape.set(xServiceFact->createInstance("com.sun.star.drawing.temporaryForXMLImportOLE2Shape"), uno::UNO_QUERY);
498 }
499 else if (serviceName == "com.sun.star.drawing.GraphicObjectShape"
500 || serviceName == "com.sun.star.drawing.MediaShape"
501 || serviceName == "com.sun.star.presentation.MediaShape")
502 {
503 xShape.set( xServiceFact->createInstanceWithArguments(serviceName, { css::uno::Any(GetImport().GetDocumentBase()) }),
504 css::uno::UNO_QUERY);
505 }
506 else
507 {
508 xShape.set(xServiceFact->createInstance(serviceName), uno::UNO_QUERY);
509 }
510 if( xShape.is() )
511 AddShape( xShape );
512 }
513 catch(const uno::Exception& e)
514 {
515 uno::Sequence<OUString> aSeq { serviceName };
517 aSeq, e.Message, nullptr );
518 }
519}
520
522{
523 if(!mxShape.is())
524 return;
525
526 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
527 if(!xPropSet.is())
528 return;
529
531
532 if(maSize.Width != 1 || maSize.Height != 1)
533 {
534 // take care there are no zeros used by error
535 if(0 == maSize.Width)
536 maSize.Width = 1;
537 if(0 == maSize.Height)
538 maSize.Height = 1;
539
540 // set global size. This should always be used.
542 }
543
544 if(maPosition.X != 0 || maPosition.Y != 0)
545 {
546 // if global position is used, add it to transformation
548 }
549
551 {
552 // transformation is used, apply to object.
553 // NOTICE: The transformation is applied AFTER evtl. used
554 // global positioning and scaling is used, so any shear or
555 // rotate used herein is applied around the (0,0) position
556 // of the PAGE object !!!
559
560 // now add to transformation
561 maUsedTransformation *= aMat;
562 }
563
564 // now set transformation for this object
565
566 // maUsedTransformtion contains the mathematical correct matrix, which if
567 // applied to a unit square would generate the transformed shape. But the property
568 // "Transformation" contains a matrix, which can be used in TRSetBaseGeometry
569 // and would be created by TRGetBaseGeometry. And those use a mathematically wrong
570 // sign for the shearing angle. So we need to adapt the matrix here.
571 basegfx::B2DTuple aScale;
572 basegfx::B2DTuple aTranslate;
573 double fRotate;
574 double fShearX;
575 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
576 basegfx::B2DHomMatrix aB2DHomMatrix;
578 aScale,
579 basegfx::fTools::equalZero(fShearX) ? 0.0 : -fShearX,
580 basegfx::fTools::equalZero(fRotate) ? 0.0 : fRotate,
581 aTranslate);
582 drawing::HomogenMatrix3 aUnoMatrix;
583
584 aUnoMatrix.Line1.Column1 = aB2DHomMatrix.get(0, 0);
585 aUnoMatrix.Line1.Column2 = aB2DHomMatrix.get(0, 1);
586 aUnoMatrix.Line1.Column3 = aB2DHomMatrix.get(0, 2);
587
588 aUnoMatrix.Line2.Column1 = aB2DHomMatrix.get(1, 0);
589 aUnoMatrix.Line2.Column2 = aB2DHomMatrix.get(1, 1);
590 aUnoMatrix.Line2.Column3 = aB2DHomMatrix.get(1, 2);
591
592 aUnoMatrix.Line3.Column1 = aB2DHomMatrix.get(2, 0);
593 aUnoMatrix.Line3.Column2 = aB2DHomMatrix.get(2, 1);
594 aUnoMatrix.Line3.Column3 = aB2DHomMatrix.get(2, 2);
595
596 xPropSet->setPropertyValue("Transformation", Any(aUnoMatrix));
597}
598
599void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
600{
601 try
602 {
603 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
604 if( !xPropSet.is() )
605 return;
606
607 do
608 {
609 // set style on shape
610 if(maDrawStyleName.isEmpty())
611 break;
612
613 const SvXMLStyleContext* pStyle = nullptr;
614 bool bAutoStyle(false);
615
616 if(GetImport().GetShapeImport()->GetAutoStylesContext())
617 pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
618
619 if(pStyle)
620 bAutoStyle = true;
621
622 if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
623 pStyle = GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
624
625 OUString aStyleName = maDrawStyleName;
626 uno::Reference< style::XStyle > xStyle;
627
628 XMLPropStyleContext* pDocStyle
629 = dynamic_cast<XMLShapeStyleContext*>(const_cast<SvXMLStyleContext*>(pStyle));
630 if (pDocStyle)
631 {
632 if( pDocStyle->GetStyle().is() )
633 {
634 xStyle = pDocStyle->GetStyle();
635 }
636 else
637 {
638 aStyleName = pDocStyle->GetParentName();
639 }
640 }
641
642 if( !xStyle.is() && !aStyleName.isEmpty() )
643 {
644 try
645 {
646
647 uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY );
648
649 if( xFamiliesSupplier.is() )
650 {
651 uno::Reference< container::XNameAccess > xFamilies( xFamiliesSupplier->getStyleFamilies() );
652 if( xFamilies.is() )
653 {
654
655 uno::Reference< container::XNameAccess > xFamily;
656
658 {
659 aStyleName = GetImport().GetStyleDisplayName(
661 aStyleName );
662 sal_Int32 nPos = aStyleName.lastIndexOf( '-' );
663 if( -1 != nPos )
664 {
665 OUString aFamily( aStyleName.copy( 0, nPos ) );
666
667 xFamilies->getByName( aFamily ) >>= xFamily;
668 aStyleName = aStyleName.copy( nPos + 1 );
669 }
670 }
671 else
672 {
673 // get graphics family
674 if (xFamilies->hasByName("graphics"))
675 xFamilies->getByName("graphics") >>= xFamily;
676 else
677 xFamilies->getByName("GraphicStyles") >>= xFamily;
678
679 aStyleName = GetImport().GetStyleDisplayName(
681 aStyleName );
682 }
683
684 if( xFamily.is() )
685 xFamily->getByName( aStyleName ) >>= xStyle;
686 }
687 }
688 }
689 catch(const uno::Exception&)
690 {
691 DBG_UNHANDLED_EXCEPTION( "xmloff", "finding style for shape" );
692 }
693 }
694
695 if( bSupportsStyle && xStyle.is() )
696 {
697 try
698 {
699 // set style on object
700 xPropSet->setPropertyValue("Style", Any(xStyle));
701 }
702 catch(const uno::Exception&)
703 {
704 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting style for shape" );
705 }
706 }
707
708 // Writer shapes: if this one has a TextBox, set it here. We need to do it before
709 // pDocStyle->FillPropertySet, because setting some properties depend on the format
710 // having RES_CNTNT attribute (e.g., UNO_NAME_TEXT_(LEFT|RIGHT|UPPER|LOWER)DIST; see
711 // SwTextBoxHelper::syncProperty, which indirectly calls SwTextBoxHelper::isTextBox)
712 uno::Reference<beans::XPropertySetInfo> xPropertySetInfo
713 = xPropSet->getPropertySetInfo();
714 static constexpr OUStringLiteral sTextBox = u"TextBox";
715 if (xPropertySetInfo->hasPropertyByName(sTextBox))
716 xPropSet->setPropertyValue(sTextBox, uno::Any(mbTextBox));
717
718 // if this is an auto style, set its properties
719 if(bAutoStyle && pDocStyle)
720 {
721 // set PropertySet on object
722 pDocStyle->FillPropertySet(xPropSet);
723 }
724
725 } while(false);
726
727 // try to set text auto style
728 do
729 {
730 // set style on shape
731 if( maTextStyleName.isEmpty() )
732 break;
733
734 if( nullptr == GetImport().GetShapeImport()->GetAutoStylesContext())
735 break;
736
737 const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XmlStyleFamily::TEXT_PARAGRAPH, maTextStyleName);
738 XMLPropStyleContext* pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast<const XMLPropStyleContext*>( pTempStyle ) ); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
739 if( pStyle == nullptr )
740 break;
741
742 // set PropertySet on object
743 pStyle->FillPropertySet(xPropSet);
744
745 } while(false);
746 }
747 catch(const uno::Exception&)
748 {
749 }
750}
751
753{
754 if( maLayerName.isEmpty() )
755 return;
756
757 try
758 {
759 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
760 if(xPropSet.is() )
761 {
762 xPropSet->setPropertyValue("LayerName", Any(maLayerName));
763 return;
764 }
765 }
766 catch(const uno::Exception&)
767 {
768 }
769}
770
772{
773 if( maThumbnailURL.isEmpty() )
774 return;
775
776 try
777 {
778 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
779 if( !xPropSet.is() )
780 return;
781
782 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
783 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( "ThumbnailGraphic" ) )
784 {
785 // load the thumbnail graphic and export it to a wmf stream so we can set
786 // it at the api
787
788 uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maThumbnailURL);
789 xPropSet->setPropertyValue("ThumbnailGraphic", uno::Any(xGraphic));
790 }
791 }
792 catch(const uno::Exception&)
793 {
794 }
795}
796
797// this is called from the parent group for each unparsed attribute in the attribute list
799{
800 sal_Int32 nTmp;
801 switch (aIter.getToken())
802 {
804 case XML_ELEMENT(DRAW_EXT, XML_ZINDEX):
805 mnZOrder = aIter.toInt32();
806 break;
807 case XML_ELEMENT(DRAW, XML_ID):
808 case XML_ELEMENT(DRAW_EXT, XML_ID):
809 if (!mbHaveXmlId) { maShapeId = aIter.toString(); }
810 break;
812 case XML_ELEMENT(DRAW_EXT, XML_NAME):
813 maShapeName = aIter.toString();
814 break;
816 case XML_ELEMENT(DRAW_EXT, XML_STYLE_NAME):
817 maDrawStyleName = aIter.toString();
818 break;
820 case XML_ELEMENT(DRAW_EXT, XML_TEXT_STYLE_NAME):
821 maTextStyleName = aIter.toString();
822 break;
824 case XML_ELEMENT(DRAW_EXT, XML_LAYER):
825 maLayerName = aIter.toString();
826 break;
828 case XML_ELEMENT(DRAW_EXT, XML_TRANSFORM):
829 mnTransform.SetString(aIter.toString(), GetImport().GetMM100UnitConverter());
830 break;
832 case XML_ELEMENT(DRAW_EXT, XML_DISPLAY):
833 mbVisible = IsXMLToken( aIter, XML_ALWAYS ) || IsXMLToken( aIter, XML_SCREEN );
834 mbPrintable = IsXMLToken( aIter, XML_ALWAYS ) || IsXMLToken( aIter, XML_PRINTER );
835 break;
836 case XML_ELEMENT(PRESENTATION, XML_USER_TRANSFORMED):
838 break;
839 case XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER):
841 if( mbIsPlaceholder )
843 break;
844 case XML_ELEMENT(PRESENTATION, XML_CLASS):
846 break;
847 case XML_ELEMENT(PRESENTATION, XML_STYLE_NAME):
848 maDrawStyleName = aIter.toString();
850 break;
851 case XML_ELEMENT(SVG, XML_X):
852 case XML_ELEMENT(SVG_COMPAT, XML_X):
853 GetImport().GetMM100UnitConverter().convertMeasureToCore(
854 maPosition.X, aIter.toView());
855 break;
856 case XML_ELEMENT(SVG, XML_Y):
857 case XML_ELEMENT(SVG_COMPAT, XML_Y):
858 GetImport().GetMM100UnitConverter().convertMeasureToCore(
859 maPosition.Y, aIter.toView());
860 break;
862 case XML_ELEMENT(SVG_COMPAT, XML_WIDTH):
863 GetImport().GetMM100UnitConverter().convertMeasureToCore(
864 maSize.Width, aIter.toView());
865 if (maSize.Width > 0)
866 maSize.Width = o3tl::saturating_add<sal_Int32>(maSize.Width, 1);
867 else if (maSize.Width < 0)
868 maSize.Width = o3tl::saturating_add<sal_Int32>(maSize.Width, -1);
869 break;
871 case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT):
872 GetImport().GetMM100UnitConverter().convertMeasureToCore(
873 maSize.Height, aIter.toView());
874 if (maSize.Height > 0)
875 maSize.Height = o3tl::saturating_add<sal_Int32>(maSize.Height, 1);
876 else if (maSize.Height < 0)
877 maSize.Height = o3tl::saturating_add<sal_Int32>(maSize.Height, -1);
878 break;
880 case XML_ELEMENT(SVG_COMPAT, XML_TRANSFORM):
881 // because of #85127# take svg:transform into account and handle like
882 // draw:transform for compatibility
883 mnTransform.SetString(aIter.toString(), GetImport().GetMM100UnitConverter());
884 break;
886 if (sax::Converter::convertPercent(nTmp, aIter.toView()))
887 mnRelWidth = static_cast<sal_Int16>(nTmp);
888 break;
890 if (sax::Converter::convertPercent(nTmp, aIter.toView()))
891 mnRelHeight = static_cast<sal_Int16>(nTmp);
892 break;
893 case XML_ELEMENT(NONE, XML_ID):
894 case XML_ELEMENT(XML, XML_ID):
895 maShapeId = aIter.toString();
896 mbHaveXmlId = true;
897 break;
898 default:
899 return false;
900 }
901 return true;
902}
903
905{
906 if( !maPresentationClass.isEmpty() && const_cast<SdXMLShapeContext*>(this)->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
907 {
909 {
910 return true;
911 }
912
915 {
916 return true;
917 }
918 }
919
920 return false;
921}
922
924 SvXMLImport& rImport,
925 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
926 uno::Reference< drawing::XShapes > const & rShapes,
927 bool bTemporaryShape)
928: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
929 mnRadius( 0 )
930{
931}
932
934{
935}
936
937// this is called from the parent group for each unparsed attribute in the attribute list
939{
940 switch (aIter.getToken())
941 {
943 GetImport().GetMM100UnitConverter().convertMeasureToCore(
944 mnRadius, aIter.toView());
945 break;
946 default:
948 }
949 return true;
950}
951
953 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
954{
955 // create rectangle shape
956 AddShape("com.sun.star.drawing.RectangleShape");
957 if(!mxShape.is())
958 return;
959
960 // Add, set Style and properties from base shape
961 SetStyle();
962 SetLayer();
963
964 // set pos, size, shear and rotate
966
967 if(mnRadius)
968 {
969 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
970 if(xPropSet.is())
971 {
972 try
973 {
974 xPropSet->setPropertyValue("CornerRadius", uno::Any( mnRadius ) );
975 }
976 catch(const uno::Exception&)
977 {
978 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
979 }
980 }
981 }
982 SdXMLShapeContext::startFastElement(nElement, xAttrList);
983}
984
985
987 SvXMLImport& rImport,
988 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
989 uno::Reference< drawing::XShapes > const & rShapes,
990 bool bTemporaryShape)
991: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
992 mnX1( 0 ),
993 mnY1( 0 ),
994 mnX2( 1 ),
995 mnY2( 1 )
996{
997}
998
1000{
1001}
1002
1003// this is called from the parent group for each unparsed attribute in the attribute list
1005{
1006 switch (aIter.getToken())
1007 {
1008 case XML_ELEMENT(SVG, XML_X1):
1009 case XML_ELEMENT(SVG_COMPAT, XML_X1):
1010 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1011 mnX1, aIter.toView());
1012 break;
1013 case XML_ELEMENT(SVG, XML_Y1):
1014 case XML_ELEMENT(SVG_COMPAT, XML_Y1):
1015 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1016 mnY1, aIter.toView());
1017 break;
1018 case XML_ELEMENT(SVG, XML_X2):
1019 case XML_ELEMENT(SVG_COMPAT, XML_X2):
1020 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1021 mnX2, aIter.toView());
1022 break;
1023 case XML_ELEMENT(SVG, XML_Y2):
1024 case XML_ELEMENT(SVG_COMPAT, XML_Y2):
1025 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1026 mnY2, aIter.toView());
1027 break;
1028 default:
1030 }
1031 return true;
1032}
1033
1035 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1036{
1037 // #85920# use SetTransformation() to handle import of simple lines.
1038 // This is necessary to take into account all anchor positions and
1039 // other things. All shape imports use the same import schemata now.
1040 // create necessary shape (Line Shape)
1041 AddShape("com.sun.star.drawing.PolyLineShape");
1042
1043 if(!mxShape.is())
1044 return;
1045
1046 // Add, set Style and properties from base shape
1047 SetStyle();
1048 SetLayer();
1049
1050 // get sizes and offsets
1051 awt::Point aTopLeft(mnX1, mnY1);
1052 awt::Point aBottomRight(mnX2, mnY2);
1053
1054 if(mnX1 > mnX2)
1055 {
1056 aTopLeft.X = mnX2;
1057 aBottomRight.X = mnX1;
1058 }
1059
1060 if(mnY1 > mnY2)
1061 {
1062 aTopLeft.Y = mnY2;
1063 aBottomRight.Y = mnY1;
1064 }
1065
1066 // set local parameters on shape
1067 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1068 if(xPropSet.is())
1069 {
1070 drawing::PointSequenceSequence aPolyPoly(1);
1071 drawing::PointSequence* pOuterSequence = aPolyPoly.getArray();
1072 pOuterSequence->realloc(2);
1073 awt::Point* pInnerSequence = pOuterSequence->getArray();
1074
1075 *pInnerSequence = awt::Point(o3tl::saturating_sub(mnX1, aTopLeft.X), o3tl::saturating_sub(mnY1, aTopLeft.Y));
1076 pInnerSequence++;
1077 *pInnerSequence = awt::Point(o3tl::saturating_sub(mnX2, aTopLeft.X), o3tl::saturating_sub(mnY2, aTopLeft.Y));
1078
1079 xPropSet->setPropertyValue("Geometry", Any(aPolyPoly));
1080 }
1081
1082 // Size is included in point coordinates
1083 maSize.Width = 1;
1084 maSize.Height = 1;
1085 maPosition.X = aTopLeft.X;
1086 maPosition.Y = aTopLeft.Y;
1087
1088 // set pos, size, shear and rotate and get copy of matrix
1090
1091 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1092}
1093
1094
1096 SvXMLImport& rImport,
1097 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1098 uno::Reference< drawing::XShapes > const & rShapes,
1099 bool bTemporaryShape)
1100: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
1101 mnCX( 0 ),
1102 mnCY( 0 ),
1103 mnRX( 1 ),
1104 mnRY( 1 ),
1105 meKind( drawing::CircleKind_FULL ),
1106 mnStartAngle( 0 ),
1107 mnEndAngle( 0 )
1108{
1109}
1110
1112{
1113}
1114
1115// this is called from the parent group for each unparsed attribute in the attribute list
1117{
1118 switch (aIter.getToken())
1119 {
1120 case XML_ELEMENT(SVG, XML_RX):
1121 case XML_ELEMENT(SVG_COMPAT, XML_RX):
1122 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1123 mnRX, aIter.toView());
1124 break;
1125 case XML_ELEMENT(SVG, XML_RY):
1126 case XML_ELEMENT(SVG_COMPAT, XML_RY):
1127 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1128 mnRY, aIter.toView());
1129 break;
1130 case XML_ELEMENT(SVG, XML_CX):
1131 case XML_ELEMENT(SVG_COMPAT, XML_CX):
1132 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1133 mnCX, aIter.toView());
1134 break;
1135 case XML_ELEMENT(SVG, XML_CY):
1136 case XML_ELEMENT(SVG_COMPAT, XML_CY):
1137 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1138 mnCY, aIter.toView());
1139 break;
1140 case XML_ELEMENT(SVG, XML_R):
1141 case XML_ELEMENT(SVG_COMPAT, XML_R):
1142 // single radius, it's a circle and both radii are the same
1143 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1144 mnRX, aIter.toView());
1145 mnRY = mnRX;
1146 break;
1147 case XML_ELEMENT(DRAW, XML_KIND):
1149 break;
1151 {
1152 double dStartAngle;
1153 if (::sax::Converter::convertDouble( dStartAngle, aIter.toView() ))
1154 mnStartAngle = static_cast<sal_Int32>(dStartAngle * 100.0);
1155 break;
1156 }
1158 {
1159 double dEndAngle;
1160 if (::sax::Converter::convertDouble( dEndAngle, aIter.toView() ))
1161 mnEndAngle = static_cast<sal_Int32>(dEndAngle * 100.0);
1162 break;
1163 }
1164 default:
1166 }
1167 return true;
1168}
1169
1171 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1172{
1173 // create rectangle shape
1174 AddShape("com.sun.star.drawing.EllipseShape");
1175 if(!mxShape.is())
1176 return;
1177
1178 // Add, set Style and properties from base shape
1179 SetStyle();
1180 SetLayer();
1181
1182 if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1)
1183 {
1184 // #i121972# center/radius is used, put to pos and size
1185 maSize.Width = 2 * mnRX;
1186 maSize.Height = 2 * mnRY;
1187 maPosition.X = mnCX - mnRX;
1188 maPosition.Y = mnCY - mnRY;
1189 }
1190 // set pos, size, shear and rotate
1192
1193 if( meKind != drawing::CircleKind_FULL )
1194 {
1195 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
1196 if( xPropSet.is() )
1197 {
1198 // calculate the correct start and end angle
1199 sal_Int32 mnOldStartAngle = mnStartAngle;
1200 sal_Int32 mnOldEndAngle = mnEndAngle;
1201 basegfx::B2DTuple aScale;
1202 basegfx::B2DTuple aTranslate;
1203 double fRotate;
1204 double fShearX;
1205 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
1206 if (aScale.getX() < 0 || aScale.getY() < 0)
1207 {
1208 // The angle for a horizontal flip is the same as the angle for a
1209 // vertical flip because a vertical flip is treated as a horizontal
1210 // flip plus a rotation.
1211
1212 // To perform the flip, the start and end angle are switched and we
1213 // use the fact performing a horizontal flip on a shape will change
1214 // the angle that a radius makes with the origin to 180 degrees
1215 // minus that angle (we use 54000 hundredths of a degree to get the
1216 // modulus operation to give a value between 0 and 36000).
1217
1218 mnStartAngle = (54000 - mnOldEndAngle) % 36000;
1219 mnEndAngle = (54000 - mnOldStartAngle) % 36000;
1220 }
1221
1222 xPropSet->setPropertyValue("CircleKind", Any( meKind) );
1223 xPropSet->setPropertyValue("CircleStartAngle", Any(mnStartAngle) );
1224 xPropSet->setPropertyValue("CircleEndAngle", Any(mnEndAngle) );
1225 }
1226 }
1227
1228 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1229}
1230
1231
1233 SvXMLImport& rImport,
1234 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1235 uno::Reference< drawing::XShapes > const & rShapes, bool bClosed, bool bTemporaryShape)
1236: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
1237 mbClosed( bClosed )
1238{
1239}
1240
1241// this is called from the parent group for each unparsed attribute in the attribute list
1243{
1244 switch (aIter.getToken())
1245 {
1247 case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX):
1248 maViewBox = aIter.toString();
1249 break;
1251 maPoints = aIter.toString();
1252 break;
1253 default:
1255 }
1256 return true;
1257}
1258
1260{
1261}
1262
1264 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1265{
1266 // Add, set Style and properties from base shape
1267 if(mbClosed)
1268 AddShape("com.sun.star.drawing.PolyPolygonShape");
1269 else
1270 AddShape("com.sun.star.drawing.PolyLineShape");
1271
1272 if( !mxShape.is() )
1273 return;
1274
1275 SetStyle();
1276 SetLayer();
1277
1278 // set local parameters on shape
1279 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1280 if(xPropSet.is())
1281 {
1282 // set polygon
1283 if(!maPoints.isEmpty() && !maViewBox.isEmpty())
1284 {
1285 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1286 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1287
1288 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1289 // sense to have the geometry content size different from object size
1290 if(maSize.Width != 0 && maSize.Height != 0)
1291 {
1292 aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1293 }
1294
1295 basegfx::B2DPolygon aPolygon;
1296
1298 {
1299 if(aPolygon.count())
1300 {
1301 const basegfx::B2DRange aSourceRange(
1302 aViewBox.GetX(), aViewBox.GetY(),
1303 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1304 const basegfx::B2DRange aTargetRange(
1305 aViewBox.GetX(), aViewBox.GetY(),
1306 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1307
1308 if(!aSourceRange.equal(aTargetRange))
1309 {
1310 aPolygon.transform(
1312 aSourceRange,
1313 aTargetRange));
1314 }
1315
1316 css::drawing::PointSequenceSequence aPointSequenceSequence;
1318 xPropSet->setPropertyValue("Geometry", Any(aPointSequenceSequence));
1319 // Size is now contained in the point coordinates, adapt maSize for
1320 // to use the correct transformation matrix in SetTransformation()
1321 maSize.Width = 1;
1322 maSize.Height = 1;
1323 }
1324 }
1325 }
1326 }
1327
1328 // set pos, size, shear and rotate and get copy of matrix
1330
1331 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1332}
1333
1334
1336 SvXMLImport& rImport,
1337 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1338 uno::Reference< drawing::XShapes > const & rShapes,
1339 bool bTemporaryShape)
1340: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape )
1341{
1342}
1343
1345{
1346}
1347
1348// this is called from the parent group for each unparsed attribute in the attribute list
1350{
1351 switch (aIter.getToken())
1352 {
1354 case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX):
1355 maViewBox = aIter.toString();
1356 break;
1357 case XML_ELEMENT(SVG, XML_D):
1358 case XML_ELEMENT(SVG_COMPAT, XML_D):
1359 maD = aIter.toString();
1360 break;
1361 default:
1363 }
1364 return true;
1365}
1366
1368 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1369{
1370 // create polygon shape
1371 if(maD.isEmpty())
1372 return;
1373
1374 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1375 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1376
1377 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1378 // sense to have the geometry content size different from object size
1379 if(maSize.Width != 0 && maSize.Height != 0)
1380 {
1381 aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1382 }
1383
1384 basegfx::B2DPolyPolygon aPolyPolygon;
1385
1386 if(!basegfx::utils::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), nullptr))
1387 return;
1388
1389 if(!aPolyPolygon.count())
1390 return;
1391
1392 const basegfx::B2DRange aSourceRange(
1393 aViewBox.GetX(), aViewBox.GetY(),
1394 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1395 const basegfx::B2DRange aTargetRange(
1396 aViewBox.GetX(), aViewBox.GetY(),
1397 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1398
1399 if(!aSourceRange.equal(aTargetRange))
1400 {
1401 aPolyPolygon.transform(
1403 aSourceRange,
1404 aTargetRange));
1405 }
1406
1407 // create shape
1408 OUString service;
1409
1410 if(aPolyPolygon.areControlPointsUsed())
1411 {
1412 if(aPolyPolygon.isClosed())
1413 {
1414 service = "com.sun.star.drawing.ClosedBezierShape";
1415 }
1416 else
1417 {
1418 service = "com.sun.star.drawing.OpenBezierShape";
1419 }
1420 }
1421 else
1422 {
1423 if(aPolyPolygon.isClosed())
1424 {
1425 service = "com.sun.star.drawing.PolyPolygonShape";
1426 }
1427 else
1428 {
1429 service = "com.sun.star.drawing.PolyLineShape";
1430 }
1431 }
1432
1433 // Add, set Style and properties from base shape
1434 AddShape(service);
1435
1436 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1437 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1438 // is used by the writer.
1439 if( !mxShape.is() )
1440 return;
1441
1442 SetStyle();
1443 SetLayer();
1444
1445 // set local parameters on shape
1446 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1447
1448 if(xPropSet.is())
1449 {
1450 uno::Any aAny;
1451
1452 // set polygon data
1453 if(aPolyPolygon.areControlPointsUsed())
1454 {
1455 drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1456
1458 aPolyPolygon,
1459 aSourcePolyPolygon);
1460 aAny <<= aSourcePolyPolygon;
1461 }
1462 else
1463 {
1464 drawing::PointSequenceSequence aSourcePolyPolygon;
1465
1467 aPolyPolygon,
1468 aSourcePolyPolygon);
1469 aAny <<= aSourcePolyPolygon;
1470 }
1471
1472 xPropSet->setPropertyValue("Geometry", aAny);
1473 // Size is now contained in the point coordinates, adapt maSize for
1474 // to use the correct transformation matrix in SetTransformation()
1475 maSize.Width = 1;
1476 maSize.Height = 1;
1477 }
1478
1479 // set pos, size, shear and rotate
1481
1482 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1483}
1484
1485
1487 SvXMLImport& rImport,
1488 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1489 uno::Reference< drawing::XShapes > const & rShapes)
1490: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ),
1491 mnRadius(0),
1492 maChainNextName("")
1493{
1494}
1495
1497{
1498}
1499
1500// this is called from the parent group for each unparsed attribute in the attribute list
1502{
1503 switch (aIter.getToken())
1504 {
1506 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1507 mnRadius, aIter.toView());
1508 break;
1510 maChainNextName = aIter.toString();
1511 break;
1512 default:
1514 }
1515 return true;
1516}
1517
1519 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1520{
1521 // create textbox shape
1522 bool bIsPresShape = false;
1523 bool bClearText = false;
1524
1525 OUString service;
1526
1527 if( isPresentationShape() )
1528 {
1529 // check if the current document supports presentation shapes
1530 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1531 {
1533 {
1534 // XmlShapeTypePresSubtitleShape
1535 service = "com.sun.star.presentation.SubtitleShape";
1536 }
1538 {
1539 // XmlShapeTypePresOutlinerShape
1540 service = "com.sun.star.presentation.OutlinerShape";
1541 }
1543 {
1544 // XmlShapeTypePresNotesShape
1545 service = "com.sun.star.presentation.NotesShape";
1546 }
1548 {
1549 // XmlShapeTypePresHeaderShape
1550 service = "com.sun.star.presentation.HeaderShape";
1551 bClearText = true;
1552 }
1554 {
1555 // XmlShapeTypePresFooterShape
1556 service = "com.sun.star.presentation.FooterShape";
1557 bClearText = true;
1558 }
1560 {
1561 // XmlShapeTypePresSlideNumberShape
1562 service = "com.sun.star.presentation.SlideNumberShape";
1563 bClearText = true;
1564 }
1566 {
1567 // XmlShapeTypePresDateTimeShape
1568 service = "com.sun.star.presentation.DateTimeShape";
1569 bClearText = true;
1570 }
1571 else // IsXMLToken( maPresentationClass, XML_TITLE ) )
1572 {
1573 // XmlShapeTypePresTitleTextShape
1574 service = "com.sun.star.presentation.TitleTextShape";
1575 }
1576 bIsPresShape = true;
1577 }
1578 }
1579
1580 if( service.isEmpty() )
1581 {
1582 // normal text shape
1583 service = "com.sun.star.drawing.TextShape";
1584 }
1585
1586 // Add, set Style and properties from base shape
1587 AddShape(service);
1588
1589 if( !mxShape.is() )
1590 return;
1591
1592 SetStyle();
1593 SetLayer();
1594
1595 if(bIsPresShape)
1596 {
1597 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
1598 if(xProps.is())
1599 {
1600 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
1601 if( xPropsInfo.is() )
1602 {
1603 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
1604 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
1605
1606 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
1607 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
1608 }
1609 }
1610 }
1611
1612 if( bClearText )
1613 {
1614 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1615 xText->setString( "" );
1616 }
1617
1618 // set parameters on shape
1619//A AW->CL: Eventually You need to strip scale and translate from the transformation
1620//A to reach the same goal again.
1621//A if(!bIsPresShape || mbIsUserTransformed)
1622//A {
1623//A // set pos and size on shape, this should remove binding
1624//A // to pres object on masterpage
1625//A SetSizeAndPosition();
1626//A }
1627
1628 // set pos, size, shear and rotate
1630
1631 if(mnRadius)
1632 {
1633 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1634 if(xPropSet.is())
1635 {
1636 try
1637 {
1638 xPropSet->setPropertyValue("CornerRadius", uno::Any( mnRadius ) );
1639 }
1640 catch(const uno::Exception&)
1641 {
1642 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
1643 }
1644 }
1645 }
1646
1647 if(!maChainNextName.isEmpty())
1648 {
1649 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1650 if(xPropSet.is())
1651 {
1652 try
1653 {
1654 xPropSet->setPropertyValue("TextChainNextName",
1656 }
1657 catch(const uno::Exception&)
1658 {
1659 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting name of next chain link");
1660 }
1661 }
1662 }
1663
1664 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1665}
1666
1667
1669 SvXMLImport& rImport,
1670 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1671 uno::Reference< drawing::XShapes > const & rShapes,
1672 bool bTemporaryShape)
1673: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape )
1674{
1675}
1676
1678{
1679}
1680
1681// this is called from the parent group for each unparsed attribute in the attribute list
1683{
1684 switch (aIter.getToken())
1685 {
1687 maFormId = aIter.toString();
1688 break;
1689 default:
1691 }
1692 return true;
1693}
1694
1696 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1697{
1698 // create Control shape
1699 // add, set style and properties from base shape
1700 AddShape("com.sun.star.drawing.ControlShape");
1701 if( !mxShape.is() )
1702 return;
1703
1704 SAL_WARN_IF( !!maFormId.isEmpty(), "xmloff", "draw:control without a form:id attribute!" );
1705 if( !maFormId.isEmpty() )
1706 {
1707 if( GetImport().IsFormsSupported() )
1708 {
1709 uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
1710 if( xControlModel.is() )
1711 {
1712 uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
1713 if( xControl.is() )
1714 xControl->setControl( xControlModel );
1715
1716 }
1717 }
1718 }
1719
1720 SetStyle();
1721 SetLayer();
1722
1723 // set pos, size, shear and rotate
1725
1726 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1727}
1728
1729
1731 SvXMLImport& rImport,
1732 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1733 uno::Reference< drawing::XShapes > const & rShapes,
1734 bool bTemporaryShape)
1735: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
1736 maStart(0,0),
1737 maEnd(1,1),
1738 mnType( drawing::ConnectorType_STANDARD ),
1739 mnStartGlueId(-1),
1740 mnEndGlueId(-1),
1741 mnDelta1(0),
1742 mnDelta2(0),
1743 mnDelta3(0)
1744{
1745}
1746
1748{
1749}
1750
1751bool SvXMLImport::needFixPositionAfterZ() const
1752{
1753 bool bWrongPositionAfterZ( false );
1754 sal_Int32 nUPD( 0 );
1755 sal_Int32 nBuildId( 0 );
1756 if ( getBuildIds( nUPD, nBuildId ) && // test OOo and old versions of LibO and AOO
1757 ( ( ( nUPD == 641 ) || ( nUPD == 645 ) || ( nUPD == 680 ) || ( nUPD == 300 ) ||
1758 ( nUPD == 310 ) || ( nUPD == 320 ) || ( nUPD == 330 ) || ( nUPD == 340 ) ||
1759 ( nUPD == 350 && nBuildId < 202 ) )
1760 || (getGeneratorVersion() == SvXMLImport::AOO_40x))) // test if AOO 4.0.x
1761 // apparently bug was fixed in AOO by i#123433 f15874d8f976f3874bdbcb53429eeefa65c28841
1762 {
1763 bWrongPositionAfterZ = true;
1764 }
1765 return bWrongPositionAfterZ;
1766}
1767
1768
1769// this is called from the parent group for each unparsed attribute in the attribute list
1771{
1772 switch( aIter.getToken() )
1773 {
1775 maStartShapeId = aIter.toString();
1776 break;
1778 mnStartGlueId = aIter.toInt32();
1779 break;
1781 maEndShapeId = aIter.toString();
1782 break;
1784 mnEndGlueId = aIter.toInt32();
1785 break;
1787 {
1788 OUString sValue = aIter.toString();
1789 SvXMLTokenEnumerator aTokenEnum( sValue );
1790 std::u16string_view aToken;
1791 if( aTokenEnum.getNextToken( aToken ) )
1792 {
1793 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1794 mnDelta1, aToken);
1795 if( aTokenEnum.getNextToken( aToken ) )
1796 {
1797 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1798 mnDelta2, aToken);
1799 if( aTokenEnum.getNextToken( aToken ) )
1800 {
1801 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1802 mnDelta3, aToken);
1803 }
1804 }
1805 }
1806 break;
1807 }
1808 case XML_ELEMENT(DRAW, XML_TYPE):
1809 {
1811 break;
1812 }
1813 // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these
1815 mnTransform.SetString(aIter.toString(), GetImport().GetMM100UnitConverter());
1816 break;
1817
1818 case XML_ELEMENT(SVG, XML_X1):
1819 case XML_ELEMENT(SVG_COMPAT, XML_X1):
1820 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1821 maStart.X, aIter.toView());
1822 break;
1823 case XML_ELEMENT(SVG, XML_Y1):
1824 case XML_ELEMENT(SVG_COMPAT, XML_Y1):
1825 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1826 maStart.Y, aIter.toView());
1827 break;
1828 case XML_ELEMENT(SVG, XML_X2):
1829 case XML_ELEMENT(SVG_COMPAT, XML_X2):
1830 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1831 maEnd.X, aIter.toView());
1832 break;
1833 case XML_ELEMENT(SVG, XML_Y2):
1834 case XML_ELEMENT(SVG_COMPAT, XML_Y2):
1835 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1836 maEnd.Y, aIter.toView());
1837 break;
1838 case XML_ELEMENT(SVG, XML_D):
1839 case XML_ELEMENT(SVG_COMPAT, XML_D):
1840 {
1841 basegfx::B2DPolyPolygon aPolyPolygon;
1842
1843 if(basegfx::utils::importFromSvgD(aPolyPolygon, aIter.toString(), GetImport().needFixPositionAfterZ(), nullptr))
1844 {
1845 if(aPolyPolygon.count())
1846 {
1847 drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1848
1850 aPolyPolygon,
1851 aSourcePolyPolygon);
1852 maPath <<= aSourcePolyPolygon;
1853 }
1854 }
1855 break;
1856 }
1857 default:
1859 }
1860 return true;
1861}
1862
1864 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1865{
1866 // For security reasons, do not add empty connectors. There may have been an error in EA2
1867 // that created empty, far set off connectors (e.g. 63 meters below top of document). This
1868 // is not guaranteed, but it's definitely safe to not add empty connectors.
1869 bool bDoAdd(true);
1870
1871 if( maStartShapeId.isEmpty()
1872 && maEndShapeId.isEmpty()
1873 && maStart.X == maEnd.X
1874 && maStart.Y == maEnd.Y
1875 && 0 == mnDelta1
1876 && 0 == mnDelta2
1877 && 0 == mnDelta3
1878 )
1879 {
1880 bDoAdd = false;
1881 }
1882
1883 if(!bDoAdd)
1884 return;
1885
1886 // create Connector shape
1887 // add, set style and properties from base shape
1888 AddShape("com.sun.star.drawing.ConnectorShape");
1889 if(!mxShape.is())
1890 return;
1891
1892 // #121965# if draw:transform is used, apply directly to the start
1893 // and end positions before using these
1895 {
1896 // transformation is used, apply to object.
1899
1900 if(!aMat.isIdentity())
1901 {
1902 basegfx::B2DPoint aStart(maStart.X, maStart.Y);
1903 basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y);
1904
1905 aStart = aMat * aStart;
1906 aEnd = aMat * aEnd;
1907
1908 maStart.X = basegfx::fround(aStart.getX());
1909 maStart.Y = basegfx::fround(aStart.getY());
1910 maEnd.X = basegfx::fround(aEnd.getX());
1911 maEnd.Y = basegfx::fround(aEnd.getY());
1912 }
1913 }
1914
1915 // add connection ids
1916 if( !maStartShapeId.isEmpty() )
1917 GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId );
1918 if( !maEndShapeId.isEmpty() )
1919 GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId );
1920
1921 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
1922 if( xProps.is() )
1923 {
1924 xProps->setPropertyValue("StartPosition", Any(maStart));
1925 xProps->setPropertyValue("EndPosition", Any(maEnd) );
1926 xProps->setPropertyValue("EdgeKind", Any(mnType) );
1927 xProps->setPropertyValue("EdgeLine1Delta", Any(mnDelta1) );
1928 xProps->setPropertyValue("EdgeLine2Delta", Any(mnDelta2) );
1929 xProps->setPropertyValue("EdgeLine3Delta", Any(mnDelta3) );
1930 }
1931 SetStyle();
1932 SetLayer();
1933
1934 if ( maPath.hasValue() )
1935 {
1936 // #i115492#
1937 // Ignore svg:d attribute for text documents created by OpenOffice.org
1938 // versions before OOo 3.3, because these OOo versions are storing
1939 // svg:d values not using the correct unit.
1940 bool bApplySVGD( true );
1941 if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
1942 {
1943 sal_Int32 nUPD( 0 );
1944 sal_Int32 nBuild( 0 );
1945 const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
1946 if ( GetImport().IsTextDocInOOoFileFormat() ||
1947 ( bBuildIdFound &&
1948 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1949 ( nUPD == 680 ) || // OOo 2.x
1950 ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1
1951 ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1
1952 ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1
1953 {
1954 bApplySVGD = false;
1955 }
1956 }
1957
1958 if ( bApplySVGD )
1959 {
1960 // tdf#83360 use path data only when redundant data of start and end point coordinates of
1961 // path start/end and connector start/end is equal. This is to avoid using erraneous
1962 // or inconsistent path data at import of foreign formats. Office itself always
1963 // writes out a consistent data set. Not using it when there is inconsistency
1964 // is okay since the path data is redundant, buffered data just to avoid recalculation
1965 // of the connector's layout at load time, no real information would be lost.
1966 // A 'connected' end has prio to direct coordinate data in Start/EndPosition
1967 // to the path data (which should have the start/end redundant in the path)
1968 const drawing::PolyPolygonBezierCoords* pSource = static_cast< const drawing::PolyPolygonBezierCoords* >(maPath.getValue());
1969 const sal_uInt32 nSequenceCount(pSource->Coordinates.getLength());
1970 bool bStartEqual(false);
1971 bool bEndEqual(false);
1972
1973 if(nSequenceCount)
1974 {
1975 const drawing::PointSequence& rStartSeq = pSource->Coordinates[0];
1976 const sal_uInt32 nStartCount = rStartSeq.getLength();
1977
1978 if(nStartCount)
1979 {
1980 const awt::Point& rStartPoint = rStartSeq.getConstArray()[0];
1981
1982 if(rStartPoint.X == maStart.X && rStartPoint.Y == maStart.Y)
1983 {
1984 bStartEqual = true;
1985 }
1986 }
1987
1988 const drawing::PointSequence& rEndSeq = pSource->Coordinates[nSequenceCount - 1];
1989 const sal_uInt32 nEndCount = rEndSeq.getLength();
1990
1991 if(nEndCount)
1992 {
1993 const awt::Point& rEndPoint = rEndSeq.getConstArray()[nEndCount - 1];
1994
1995 if(rEndPoint.X == maEnd.X && rEndPoint.Y == maEnd.Y)
1996 {
1997 bEndEqual = true;
1998 }
1999 }
2000 }
2001
2002 if(!bStartEqual || !bEndEqual)
2003 {
2004 bApplySVGD = false;
2005 }
2006 }
2007
2008 if ( bApplySVGD )
2009 {
2011 xProps->setPropertyValue("PolyPolygonBezier", maPath);
2012 }
2013 }
2014
2015 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2016}
2017
2018
2020 SvXMLImport& rImport,
2021 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2022 uno::Reference< drawing::XShapes > const & rShapes,
2023 bool bTemporaryShape)
2024: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
2025 maStart(0,0),
2026 maEnd(1,1)
2027{
2028}
2029
2031{
2032}
2033
2034// this is called from the parent group for each unparsed attribute in the attribute list
2036{
2037 switch( aIter.getToken() )
2038 {
2039 case XML_ELEMENT(SVG, XML_X1):
2040 case XML_ELEMENT(SVG_COMPAT, XML_X1):
2041 {
2042 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2043 maStart.X, aIter.toView());
2044 break;
2045 }
2046 case XML_ELEMENT(SVG, XML_Y1):
2047 case XML_ELEMENT(SVG_COMPAT, XML_Y1):
2048 {
2049 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2050 maStart.Y, aIter.toView());
2051 break;
2052 }
2053 case XML_ELEMENT(SVG, XML_X2):
2054 case XML_ELEMENT(SVG_COMPAT, XML_X2):
2055 {
2056 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2057 maEnd.X, aIter.toView());
2058 break;
2059 }
2060 case XML_ELEMENT(SVG, XML_Y2):
2061 case XML_ELEMENT(SVG_COMPAT, XML_Y2):
2062 {
2063 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2064 maEnd.Y, aIter.toView());
2065 break;
2066 }
2067 default:
2069 }
2070 return true;
2071}
2072
2074 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2075{
2076 // create Measure shape
2077 // add, set style and properties from base shape
2078 AddShape("com.sun.star.drawing.MeasureShape");
2079 if(!mxShape.is())
2080 return;
2081
2082 SetStyle();
2083 SetLayer();
2084
2085 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2086 if( xProps.is() )
2087 {
2088 xProps->setPropertyValue("StartPosition", Any(maStart));
2089 xProps->setPropertyValue("EndPosition", Any(maEnd) );
2090 }
2091
2092 // delete pre created fields
2093 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2094 if( xText.is() )
2095 {
2096 xText->setString( " " );
2097 }
2098
2099 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2100}
2101
2103{
2104 do
2105 {
2106 // delete pre created fields
2107 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2108 if( !xText.is() )
2109 break;
2110
2111 uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() );
2112 if( !xCursor.is() )
2113 break;
2114
2115 xCursor->collapseToStart();
2116 xCursor->goRight( 1, true );
2117 xCursor->setString( "" );
2118 }
2119 while(false);
2120
2122}
2123
2124
2126 SvXMLImport& rImport,
2127 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2128 uno::Reference< drawing::XShapes > const & rShapes,
2129 bool bTemporaryShape)
2130: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0)
2131{
2133}
2134
2136{
2137}
2138
2139// this is called from the parent group for each unparsed attribute in the attribute list
2141{
2142 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_PAGE_NUMBER) )
2143 mnPageNumber = aIter.toInt32();
2144 else
2146 return true;
2147}
2148
2150 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2151{
2152 // create Page shape
2153 // add, set style and properties from base shape
2154
2155 // #86163# take into account which type of PageShape needs to
2156 // be constructed. It's a pres shape if presentation:XML_CLASS == XML_PAGE.
2157 bool bIsPresentation = !maPresentationClass.isEmpty() &&
2158 GetImport().GetShapeImport()->IsPresentationShapesSupported();
2159
2160 uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY );
2161 const bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService("com.sun.star.presentation.HandoutMasterPage");
2162
2163 if( bIsOnHandoutPage )
2164 {
2165 AddShape("com.sun.star.presentation.HandoutShape");
2166 }
2167 else
2168 {
2169 if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PAGE ) )
2170 {
2171 bIsPresentation = false;
2172 }
2173
2174 if(bIsPresentation)
2175 {
2176 AddShape("com.sun.star.presentation.PageShape");
2177 }
2178 else
2179 {
2180 AddShape("com.sun.star.drawing.PageShape");
2181 }
2182 }
2183
2184 if(!mxShape.is())
2185 return;
2186
2187 SetStyle();
2188 SetLayer();
2189
2190 // set pos, size, shear and rotate
2192
2193 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2194 if(xPropSet.is())
2195 {
2196 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2197 static const OUStringLiteral aPageNumberStr(u"PageNumber");
2198 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2199 xPropSet->setPropertyValue(aPageNumberStr, uno::Any( mnPageNumber ));
2200 }
2201
2202 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2203}
2204
2205
2207 SvXMLImport& rImport,
2208 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2209 uno::Reference< drawing::XShapes > const & rShapes,
2210 bool bTemporaryShape)
2211: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
2212 // #86616# for correct edge rounding import mnRadius needs to be initialized
2213 mnRadius( 0 )
2214{
2215}
2216
2218{
2219}
2220
2222 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2223{
2224 // create Caption shape
2225 // add, set style and properties from base shape
2226 AddShape("com.sun.star.drawing.CaptionShape");
2227 if( !mxShape.is() )
2228 return;
2229
2230 SetStyle();
2231 SetLayer();
2232
2233 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2234
2235 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2236 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2237 // is the default setting, so the top left reference point that is used by the caption point is
2238 // no longer correct) There are two ways to solve this problem, temporarily disabling the
2239 // autogrowwidth as we are doing here or to apply the CaptionPoint after setting text
2240 bool bIsAutoGrowWidth = false;
2241 if ( xProps.is() )
2242 {
2243 uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") );
2244 aAny >>= bIsAutoGrowWidth;
2245
2246 if ( bIsAutoGrowWidth )
2247 xProps->setPropertyValue("TextAutoGrowWidth", uno::Any( false ) );
2248 }
2249
2250 // set pos, size, shear and rotate
2252 if( xProps.is() )
2253 xProps->setPropertyValue("CaptionPoint", uno::Any( maCaptionPoint ) );
2254
2255 if ( bIsAutoGrowWidth )
2256 xProps->setPropertyValue("TextAutoGrowWidth", uno::Any( true ) );
2257
2258 if(mnRadius)
2259 {
2260 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2261 if(xPropSet.is())
2262 {
2263 try
2264 {
2265 xPropSet->setPropertyValue("CornerRadius", uno::Any( mnRadius ) );
2266 }
2267 catch(const uno::Exception&)
2268 {
2269 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
2270 }
2271 }
2272 }
2273
2274 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2275}
2276
2277// this is called from the parent group for each unparsed attribute in the attribute list
2279{
2280 switch (aIter.getToken())
2281 {
2283 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2284 maCaptionPoint.X, aIter.toView());
2285 break;
2287 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2288 maCaptionPoint.Y, aIter.toView());
2289 break;
2291 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2292 mnRadius, aIter.toView());
2293 break;
2294 default:
2296 }
2297 return true;
2298}
2299
2300
2302 SvXMLImport& rImport,
2303 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2304 uno::Reference< drawing::XShapes > const & rShapes)
2305: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
2306{
2307}
2308
2309// this is called from the parent group for each unparsed attribute in the attribute list
2311{
2312 if( aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF) )
2313 maURL = aIter.toString();
2314 else
2316 return true;
2317}
2318
2320 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2321{
2322 // create graphic object shape
2323 OUString service;
2324
2325 if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2326 {
2327 service = "com.sun.star.presentation.GraphicObjectShape";
2328 }
2329 else
2330 {
2331 service = "com.sun.star.drawing.GraphicObjectShape";
2332 }
2333
2334 AddShape(service);
2335
2336 if(!mxShape.is())
2337 return;
2338
2339 SetStyle();
2340 SetLayer();
2341
2342 uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
2343 if(xPropset.is())
2344 {
2345 // since OOo 1.x had no line or fill style for graphics, but may create
2346 // documents with them, we have to override them here
2347 sal_Int32 nUPD, nBuildId;
2348 if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try
2349 {
2350 xPropset->setPropertyValue("FillStyle", Any( FillStyle_NONE ) );
2351 xPropset->setPropertyValue("LineStyle", Any( LineStyle_NONE ) );
2352 }
2353 catch(const Exception&)
2354 {
2355 }
2356
2357 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
2358 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2359 xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::Any( mbIsPlaceholder ) );
2360
2361 if( !mbIsPlaceholder )
2362 {
2363 if( !maURL.isEmpty() )
2364 {
2365 uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maURL);
2366 if (xGraphic.is())
2367 {
2368 xPropset->setPropertyValue("Graphic", uno::Any(xGraphic));
2369 }
2370 }
2371 }
2372 }
2373
2375 {
2376 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2377 if(xProps.is())
2378 {
2379 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2380 if( xPropsInfo.is() )
2381 {
2382 if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2383 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2384 }
2385 }
2386 }
2387
2388 // set pos, size, shear and rotate
2390
2391 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2392}
2393
2395{
2396 if (mxBase64Stream.is())
2397 {
2398 uno::Reference<graphic::XGraphic> xGraphic(GetImport().loadGraphicFromBase64(mxBase64Stream));
2399 if (xGraphic.is())
2400 {
2401 uno::Reference<beans::XPropertySet> xProperties(mxShape, uno::UNO_QUERY);
2402 if (xProperties.is())
2403 {
2404 xProperties->setPropertyValue("Graphic", uno::Any(xGraphic));
2405 }
2406 }
2407 }
2408
2410}
2411
2412css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGraphicObjectShapeContext::createFastChildContext(
2413 sal_Int32 nElement,
2414 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2415{
2416 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
2417
2418 if( nElement == XML_ELEMENT(OFFICE, XML_BINARY_DATA) )
2419 {
2420 if( maURL.isEmpty() && !mxBase64Stream.is() )
2421 {
2422 mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
2423 if( mxBase64Stream.is() )
2424 xContext = new XMLBase64ImportContext( GetImport(),
2426 }
2427 }
2428
2429 // delegate to parent class if no context could be created
2430 if (!xContext)
2432 xAttrList);
2433
2434 if (!xContext)
2435 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2436
2437 return xContext;
2438}
2439
2441{
2442
2443}
2444
2445
2447 SvXMLImport& rImport,
2448 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2449 uno::Reference< drawing::XShapes > const & rShapes,
2450 bool bTemporaryShape)
2451: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape )
2452{
2453}
2454
2456 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2457{
2458 const bool bIsPresentation = isPresentationShape();
2459
2460 AddShape(
2461 bIsPresentation
2462 ? OUString("com.sun.star.presentation.ChartShape")
2463 : OUString("com.sun.star.drawing.OLE2Shape"));
2464
2465 if(!mxShape.is())
2466 return;
2467
2468 SetStyle();
2469 SetLayer();
2470
2471 if( !mbIsPlaceholder )
2472 {
2473 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2474 if(xProps.is())
2475 {
2476 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2477 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2478 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2479
2480 uno::Any aAny;
2481
2482 xProps->setPropertyValue("CLSID", Any(OUString("12DCAE26-281F-416F-a234-c3086127382e")) );
2483
2484 aAny = xProps->getPropertyValue("Model");
2485 uno::Reference< frame::XModel > xChartModel;
2486 if( aAny >>= xChartModel )
2487 {
2488#if !ENABLE_WASM_STRIP_CHART
2489 // WASM_CHART change
2490 // TODO: Maybe use SdXMLGraphicObjectShapeContext completely instead
2491 // or try to create as mbIsPlaceholder object adding a Chart visualization
2492 // that should be available somehow
2493 mxChartContext.set( GetImport().GetChartImport()->CreateChartContext( GetImport(), xChartModel ) );
2494#endif
2495 }
2496 }
2497 }
2498
2500 {
2501 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2502 if(xProps.is())
2503 {
2504 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2505 if( xPropsInfo.is() )
2506 {
2507 if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2508 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2509 }
2510 }
2511 }
2512
2513 // set pos, size, shear and rotate
2515
2516 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2517
2518 if( mxChartContext.is() )
2519 mxChartContext->startFastElement( nElement, xAttrList );
2520}
2521
2523{
2524 if( mxChartContext.is() )
2525 mxChartContext->endFastElement(nElement);
2526
2528}
2529
2530void SdXMLChartShapeContext::characters( const OUString& rChars )
2531{
2532 if( mxChartContext.is() )
2533 mxChartContext->characters( rChars );
2534}
2535
2536css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLChartShapeContext::createFastChildContext(
2537 sal_Int32 nElement,
2538 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2539{
2540 if( mxChartContext.is() )
2541 return mxChartContext->createFastChildContext( nElement, xAttrList );
2542
2543 return nullptr;
2544}
2545
2546
2548 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2549 css::uno::Reference< css::drawing::XShapes > const & rShapes)
2550: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
2551{
2552}
2553
2555{
2556}
2557
2559 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
2560{
2561 // #96717# in theorie, if we don't have a URL we shouldn't even
2562 // export this OLE shape. But practically it's too risky right now
2563 // to change this so we better dispose this on load
2564 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2565 // return;
2566
2567 // #100592# this BugFix prevents that a shape is created. CL
2568 // is thinking about an alternative.
2569 // #i13140# Check for more than empty string in maHref, there are
2570 // other possibilities that maHref results in empty container
2571 // storage names
2572 if( !(GetImport().getImportFlags() & SvXMLImportFlags::EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2573 return;
2574
2575 OUString service("com.sun.star.drawing.OLE2Shape");
2576
2577 bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2578
2579 if( bIsPresShape )
2580 {
2582 {
2583 service = "com.sun.star.presentation.ChartShape";
2584 }
2586 {
2587 service = "com.sun.star.presentation.CalcShape";
2588 }
2590 {
2591 service = "com.sun.star.presentation.OLE2Shape";
2592 }
2593 }
2594
2595 AddShape(service);
2596
2597 if( !mxShape.is() )
2598 return;
2599
2600 SetLayer();
2601
2602 if(bIsPresShape)
2603 {
2604 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2605 if(xProps.is())
2606 {
2607 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2608 if( xPropsInfo.is() )
2609 {
2610 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2611 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2612
2613 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2614 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2615 }
2616 }
2617 }
2618
2619 if( !mbIsPlaceholder && !maHref.isEmpty() )
2620 {
2621 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2622
2623 if( xProps.is() )
2624 {
2625 OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
2626
2627 if ( GetImport().IsPackageURL( maHref ) )
2628 {
2629 static const OUStringLiteral sURL( u"vnd.sun.star.EmbeddedObject:" );
2630
2631 if ( aPersistName.startsWith( sURL ) )
2632 aPersistName = aPersistName.copy( sURL.getLength() );
2633
2634 xProps->setPropertyValue("PersistName",
2635 uno::Any( aPersistName ) );
2636 }
2637 else
2638 {
2639 // this is OOo link object
2640 xProps->setPropertyValue("LinkURL",
2641 uno::Any( aPersistName ) );
2642 }
2643 }
2644 }
2645
2646 // set pos, size, shear and rotate
2648
2649 SetStyle();
2650
2651 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2652}
2653
2655{
2656 if (GetImport().isGeneratorVersionOlderThan(
2657 SvXMLImport::OOo_34x, SvXMLImport::LO_41x)) // < LO 4.0
2658 {
2659 // #i118485#
2660 // If it's an old file from us written before OOo3.4, we need to correct
2661 // FillStyle and LineStyle for OLE2 objects. The error was that the old paint
2662 // implementations just ignored added fill/linestyles completely, thus
2663 // those objects need to be corrected to not show blue and hairline which
2664 // always was the default, but would be shown now
2665 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2666
2667 if( xProps.is() )
2668 {
2669 xProps->setPropertyValue("FillStyle", uno::Any(drawing::FillStyle_NONE));
2670 xProps->setPropertyValue("LineStyle", uno::Any(drawing::LineStyle_NONE));
2671 }
2672 }
2673
2674 if( mxBase64Stream.is() )
2675 {
2676 OUString aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2677 static const OUStringLiteral sURL( u"vnd.sun.star.EmbeddedObject:" );
2678
2679 aPersistName = aPersistName.copy( sURL.getLength() );
2680
2681 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2682 if( xProps.is() )
2683 xProps->setPropertyValue("PersistName", uno::Any( aPersistName ) );
2684 }
2685
2687}
2688
2689// this is called from the parent group for each unparsed attribute in the attribute list
2691{
2692 switch( aIter.getToken() )
2693 {
2695 maCLSID = aIter.toString();
2696 break;
2697 case XML_ELEMENT(XLINK, XML_HREF):
2698 maHref = aIter.toString();
2699 break;
2700 default:
2702 }
2703 return true;
2704}
2705
2706css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLObjectShapeContext::createFastChildContext(
2707 sal_Int32 nElement,
2708 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2709{
2710 if(nElement == XML_ELEMENT(OFFICE, XML_BINARY_DATA))
2711 {
2712 mxBase64Stream = GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2713 if( mxBase64Stream.is() )
2715 }
2716 else if( nElement == XML_ELEMENT(OFFICE, XML_DOCUMENT) ||
2717 nElement == XML_ELEMENT(MATH, XML_MATH) )
2718 {
2720 new XMLEmbeddedObjectImportContext(GetImport(), nElement, xAttrList));
2721 maCLSID = xEContext->GetFilterCLSID();
2722 if( !maCLSID.isEmpty() )
2723 {
2724 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2725 if( xPropSet.is() )
2726 {
2727 xPropSet->setPropertyValue("CLSID", uno::Any( maCLSID ) );
2728
2729 uno::Reference< lang::XComponent > xComp;
2730 xPropSet->getPropertyValue("Model") >>= xComp;
2731 SAL_WARN_IF( !xComp.is(), "xmloff", "no xModel for own OLE format" );
2732 xEContext->SetComponent(xComp);
2733 }
2734 }
2735 return xEContext;
2736 }
2737
2738 // delegate to parent class if no context could be created
2739 return SdXMLShapeContext::createFastChildContext(nElement, xAttrList);
2740}
2741
2743 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2744 css::uno::Reference< css::drawing::XShapes > const & rShapes)
2745: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ),
2746 mbIsScript( false )
2747{
2748}
2749
2751{
2752}
2753
2755 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
2756{
2757 AddShape("com.sun.star.drawing.AppletShape");
2758
2759 if( mxShape.is() )
2760 {
2761 SetLayer();
2762
2763 // set pos, size, shear and rotate
2765 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2766 }
2767}
2768
2769// this is called from the parent group for each unparsed attribute in the attribute list
2771{
2772 switch( aIter.getToken() )
2773 {
2775 maAppletName = aIter.toString();
2776 break;
2777 case XML_ELEMENT(DRAW, XML_CODE):
2778 maAppletCode = aIter.toString();
2779 break;
2781 mbIsScript = IsXMLToken( aIter, XML_TRUE );
2782 break;
2783 case XML_ELEMENT(XLINK, XML_HREF):
2784 maHref = GetImport().GetAbsoluteReference(aIter.toString());
2785 break;
2786 default:
2788 }
2789 return true;
2790}
2791
2793{
2794 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2795 if( xProps.is() )
2796 {
2797 if ( maSize.Width && maSize.Height )
2798 {
2799 // the visual area for applet must be set on loading
2800 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
2801 xProps->setPropertyValue("VisibleArea", Any(aRect) );
2802 }
2803
2804 if( maParams.hasElements() )
2805 {
2806 xProps->setPropertyValue("AppletCommands", Any(maParams) );
2807 }
2808
2809 if( !maHref.isEmpty() )
2810 {
2811 xProps->setPropertyValue("AppletCodeBase", Any(maHref) );
2812 }
2813
2814 if( !maAppletName.isEmpty() )
2815 {
2816 xProps->setPropertyValue("AppletName", Any(maAppletName) );
2817 }
2818
2819 if( mbIsScript )
2820 {
2821 xProps->setPropertyValue("AppletIsScript", Any(mbIsScript) );
2822
2823 }
2824
2825 if( !maAppletCode.isEmpty() )
2826 {
2827 xProps->setPropertyValue("AppletCode", Any(maAppletCode) );
2828 }
2829
2830 xProps->setPropertyValue("AppletDocBase", Any(GetImport().GetDocumentBase()) );
2831
2832 SetThumbnail();
2833 }
2834
2836}
2837
2838css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLAppletShapeContext::createFastChildContext(
2839 sal_Int32 nElement,
2840 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2841{
2842 if( nElement == XML_ELEMENT(DRAW, XML_PARAM) )
2843 {
2844 OUString aParamName, aParamValue;
2845 // now parse the attribute list and look for draw:name and draw:value
2846 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
2847 {
2848 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAME) )
2849 aParamName = aIter.toString();
2850 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_VALUE) )
2851 aParamValue = aIter.toString();
2852 }
2853
2854 if( !aParamName.isEmpty() )
2855 {
2856 sal_Int32 nIndex = maParams.getLength();
2857 maParams.realloc( nIndex + 1 );
2858 auto pParams = maParams.getArray();
2859 pParams[nIndex].Name = aParamName;
2860 pParams[nIndex].Handle = -1;
2861 pParams[nIndex].Value <<= aParamValue;
2862 pParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
2863 }
2864
2865 return new SvXMLImportContext( GetImport() );
2866 }
2867
2868 return SdXMLShapeContext::createFastChildContext( nElement, xAttrList );
2869}
2870
2871
2873 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2874 css::uno::Reference< css::drawing::XShapes > const & rShapes) :
2875SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ),
2876mbMedia( false )
2877{
2878}
2879
2881{
2882}
2883
2885 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2886{
2887
2888 // watch for MimeType attribute to see if we have a media object
2889 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
2890 {
2891 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_MIME_TYPE) )
2892 {
2893 if( aIter.toView() == "application/vnd.sun.star.media" )
2894 mbMedia = true;
2895 // leave this loop
2896 break;
2897 }
2898 }
2899
2900 OUString service;
2901
2902 bool bIsPresShape = false;
2903
2904 if( mbMedia )
2905 {
2906 service = "com.sun.star.drawing.MediaShape";
2907
2908 bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2909 if( bIsPresShape )
2910 {
2912 {
2913 service = "com.sun.star.presentation.MediaShape";
2914 }
2915 }
2916 }
2917 else
2918 service = "com.sun.star.drawing.PluginShape";
2919
2920 AddShape(service);
2921
2922 if( !mxShape.is() )
2923 return;
2924
2925 if (mbMedia)
2926 {
2927 // The media may have a crop, apply it.
2928 SetStyle(/*bSupportsStyle=*/false);
2929 }
2930
2931 SetLayer();
2932
2933 if(bIsPresShape)
2934 {
2935 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2936 if(xProps.is())
2937 {
2938 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2939 if( xPropsInfo.is() )
2940 {
2941 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2942 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2943
2944 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2945 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2946 }
2947 }
2948 }
2949
2950 // set pos, size, shear and rotate
2952 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2953}
2954
2955static OUString
2956lcl_GetMediaReference(SvXMLImport const& rImport, OUString const& rURL)
2957{
2958 if (rImport.IsPackageURL(rURL))
2959 {
2960 return "vnd.sun.star.Package:" + rURL;
2961 }
2962 else
2963 {
2964 return rImport.GetAbsoluteReference(rURL);
2965 }
2966}
2967
2968// this is called from the parent group for each unparsed attribute in the attribute list
2970{
2971 switch( aIter.getToken() )
2972 {
2974 maMimeType = aIter.toString();
2975 break;
2976 case XML_ELEMENT(XLINK, XML_HREF):
2978 break;
2979 default:
2981 }
2982 return true;
2983}
2984
2986{
2987 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2988
2989 if( xProps.is() )
2990 {
2991 if ( maSize.Width && maSize.Height )
2992 {
2993 static const OUStringLiteral sVisibleArea( u"VisibleArea" );
2994 uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() );
2995 if ( !aXPropSetInfo.is() || aXPropSetInfo->hasPropertyByName( sVisibleArea ) )
2996 {
2997 // the visual area for a plugin must be set on loading
2998 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
2999 xProps->setPropertyValue( sVisibleArea, Any(aRect) );
3000 }
3001 }
3002
3003 if( !mbMedia )
3004 {
3005 // in case we have a plugin object
3006 if( maParams.hasElements() )
3007 {
3008 xProps->setPropertyValue("PluginCommands", Any(maParams) );
3009 }
3010
3011 if( !maMimeType.isEmpty() )
3012 {
3013 xProps->setPropertyValue("PluginMimeType", Any(maMimeType) );
3014 }
3015
3016 if( !maHref.isEmpty() )
3017 {
3018 xProps->setPropertyValue("PluginURL", Any(maHref) );
3019 }
3020 }
3021 else
3022 {
3023 // in case we have a media object
3024 xProps->setPropertyValue( "MediaURL", uno::Any(maHref));
3025
3026 xProps->setPropertyValue("MediaMimeType", uno::Any(maMimeType) );
3027
3028 for( const auto& rParam : std::as_const(maParams) )
3029 {
3030 const OUString& rName = rParam.Name;
3031
3032 if( rName == "Loop" )
3033 {
3034 OUString aValueStr;
3035 rParam.Value >>= aValueStr;
3036 xProps->setPropertyValue("Loop",
3037 uno::Any( aValueStr == "true" ) );
3038 }
3039 else if( rName == "Mute" )
3040 {
3041 OUString aValueStr;
3042 rParam.Value >>= aValueStr;
3043 xProps->setPropertyValue("Mute",
3044 uno::Any( aValueStr == "true" ) );
3045 }
3046 else if( rName == "VolumeDB" )
3047 {
3048 OUString aValueStr;
3049 rParam.Value >>= aValueStr;
3050 xProps->setPropertyValue("VolumeDB",
3051 uno::Any( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
3052 }
3053 else if( rName == "Zoom" )
3054 {
3055 OUString aZoomStr;
3056 media::ZoomLevel eZoomLevel;
3057
3058 rParam.Value >>= aZoomStr;
3059
3060 if( aZoomStr == "25%" )
3061 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
3062 else if( aZoomStr == "50%" )
3063 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2;
3064 else if( aZoomStr == "100%" )
3065 eZoomLevel = media::ZoomLevel_ORIGINAL;
3066 else if( aZoomStr == "200%" )
3067 eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1;
3068 else if( aZoomStr == "400%" )
3069 eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1;
3070 else if( aZoomStr == "fit" )
3071 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
3072 else if( aZoomStr == "fixedfit" )
3073 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT;
3074 else if( aZoomStr == "fullscreen" )
3075 eZoomLevel = media::ZoomLevel_FULLSCREEN;
3076 else
3077 eZoomLevel = media::ZoomLevel_NOT_AVAILABLE;
3078
3079 xProps->setPropertyValue("Zoom", uno::Any( eZoomLevel ) );
3080 }
3081 }
3082 }
3083
3084 SetThumbnail();
3085 }
3086
3088}
3089
3090css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLPluginShapeContext::createFastChildContext(
3091 sal_Int32 nElement,
3092 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
3093{
3094 if( nElement == XML_ELEMENT(DRAW, XML_PARAM) )
3095 {
3096 OUString aParamName, aParamValue;
3097 // now parse the attribute list and look for draw:name and draw:value
3098 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
3099 {
3100 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAME) )
3101 aParamName = aIter.toString();
3102 else if( aIter.getToken() == XML_ELEMENT(DRAW, XML_VALUE) )
3103 aParamValue = aIter.toString();
3104 }
3105
3106 if( !aParamName.isEmpty() )
3107 {
3108 sal_Int32 nIndex = maParams.getLength();
3109 maParams.realloc( nIndex + 1 );
3110 auto pParams = maParams.getArray();
3111 pParams[nIndex].Name = aParamName;
3112 pParams[nIndex].Handle = -1;
3113 pParams[nIndex].Value <<= aParamValue;
3114 pParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3115 }
3116
3117 return new SvXMLImportContext( GetImport() );
3118 }
3119
3120 return SdXMLShapeContext::createFastChildContext( nElement, xAttrList );
3121}
3122
3123
3125 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
3126 css::uno::Reference< css::drawing::XShapes > const & rShapes)
3127: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
3128{
3129}
3130
3132{
3133}
3134
3136 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
3137{
3138 AddShape("com.sun.star.drawing.FrameShape");
3139
3140 if( !mxShape.is() )
3141 return;
3142
3143 SetLayer();
3144
3145 // set pos, size, shear and rotate
3147
3148 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3149 if( xProps.is() )
3150 {
3151 if( !maFrameName.isEmpty() )
3152 {
3153 xProps->setPropertyValue("FrameName", Any(maFrameName) );
3154 }
3155
3156 if( !maHref.isEmpty() )
3157 {
3158 if (INetURLObject(maHref).GetProtocol() == INetProtocol::Macro)
3159 GetImport().NotifyMacroEventRead();
3160
3161 xProps->setPropertyValue("FrameURL", Any(maHref) );
3162 }
3163 }
3164
3165 SetStyle();
3166
3167 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3168}
3169
3170// this is called from the parent group for each unparsed attribute in the attribute list
3172{
3173 switch( aIter.getToken() )
3174 {
3176 maFrameName = aIter.toString();
3177 break;
3178 case XML_ELEMENT(XLINK, XML_HREF):
3179 maHref = GetImport().GetAbsoluteReference(aIter.toString());
3180 break;
3181 default:
3183 }
3184 return true;
3185}
3186
3188{
3189 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3190
3191 if( xProps.is() )
3192 {
3193 if ( maSize.Width && maSize.Height )
3194 {
3195 // the visual area for a floating frame must be set on loading
3196 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3197 xProps->setPropertyValue("VisibleArea", Any(aRect) );
3198 }
3199 }
3200
3201 SetThumbnail();
3203}
3204
3205
3207 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
3208 css::uno::Reference< css::drawing::XShapes > const & rShapes,
3209 bool bTemporaryShape)
3210: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
3211 mbSupportsReplacement( false )
3212{
3213 uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
3214 if( xClone.is() )
3215 mxAttrList.set( xClone->createClone(), uno::UNO_QUERY );
3216 else
3218}
3219
3221{
3222}
3223
3225{
3226 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3227
3228 if(!pSdXMLGraphicObjectShapeContext)
3229 return;
3230
3231 try
3232 {
3233 uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3234
3235 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
3236
3237 // remove from parent
3238 xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
3239
3240 // dispose
3241 uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
3242
3243 if(xComp.is())
3244 {
3245 xComp->dispose();
3246 }
3247 }
3248 catch( uno::Exception& )
3249 {
3250 DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." );
3251 }
3252}
3253
3254namespace
3255{
3256uno::Reference<beans::XPropertySet> getGraphicPropertySetFromImportContext(const SvXMLImportContext& rContext)
3257{
3258 uno::Reference<beans::XPropertySet> aPropertySet;
3259 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast<const SdXMLGraphicObjectShapeContext*>(&rContext);
3260
3261 if (pSdXMLGraphicObjectShapeContext)
3262 aPropertySet.set(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY);
3263
3264 return aPropertySet;
3265}
3266
3267} // end anonymous namespace
3268
3269uno::Reference<graphic::XGraphic> SdXMLFrameShapeContext::getGraphicFromImportContext(const SvXMLImportContext& rContext) const
3270{
3271 uno::Reference<graphic::XGraphic> xGraphic;
3272 try
3273 {
3274 const uno::Reference<beans::XPropertySet> xPropertySet = getGraphicPropertySetFromImportContext(rContext);
3275
3276 if (xPropertySet.is())
3277 {
3278 xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
3279 }
3280 }
3281 catch( uno::Exception& )
3282 {
3283 DBG_UNHANDLED_EXCEPTION("xmloff", "Error in cleanup of multiple graphic object import.");
3284 }
3285
3286 return xGraphic;
3287}
3288
3290{
3291 OUString aRetval;
3292 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3293
3294 if(pSdXMLGraphicObjectShapeContext)
3295 {
3296 try
3297 {
3298 const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3299
3300 xPropSet->getPropertyValue("GraphicStreamURL") >>= aRetval;
3301 }
3302 catch( uno::Exception& )
3303 {
3304 DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." );
3305 }
3306 }
3307
3308 return aRetval;
3309}
3310
3311css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLFrameShapeContext::createFastChildContext(
3312 sal_Int32 nElement,
3313 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
3314{
3315 SvXMLImportContextRef xContext;
3316 if( !mxImplContext.is() )
3317 {
3319 GetImport(), nElement, xAttrList, mxShapes, mxAttrList );
3320
3321 xContext = pShapeContext;
3322
3323 // propagate the hyperlink to child context
3324 if ( !msHyperlink.isEmpty() )
3325 pShapeContext->setHyperlink( msHyperlink );
3326
3327 auto nToken = nElement & TOKEN_MASK;
3328 bool bMedia = false;
3329 // Ignore gltf model if necessary and so the fallback image will be imported
3330 if( nToken == XML_PLUGIN )
3331 {
3332 SdXMLPluginShapeContext* pPluginContext = dynamic_cast<SdXMLPluginShapeContext*>(pShapeContext);
3333 if( pPluginContext && pPluginContext->getMimeType() == "model/vnd.gltf+json" )
3334 {
3335 mxImplContext = nullptr;
3336 return new SvXMLImportContext(GetImport());
3337 }
3338 else if (pPluginContext && pPluginContext->getMimeType() == "application/vnd.sun.star.media")
3339 {
3340 // The media may have a preview, import it.
3341 bMedia = true;
3342 }
3343 }
3344
3345 mxImplContext = xContext;
3348
3349 if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get()))
3350 {
3351 if ( !maShapeId.isEmpty() )
3352 GetImport().getInterfaceToIdentifierMapper().reserveIdentifier( maShapeId );
3353
3355 }
3356 }
3357 else if(getSupportsMultipleContents() && nElement == XML_ELEMENT(DRAW, XML_IMAGE))
3358 {
3359 // read another image
3361 GetImport(), nElement, xAttrList, mxShapes, mxAttrList);
3362 mxImplContext = xContext;
3363
3364 if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get()))
3365 {
3367 }
3368 }
3369 else if( mbSupportsReplacement && !mxReplImplContext.is() &&
3370 nElement == XML_ELEMENT(DRAW, XML_IMAGE) )
3371 {
3372 // read replacement image
3373 SvXMLImportContext *pImplContext = mxImplContext.get();
3374 SdXMLShapeContext *pSContext =
3375 dynamic_cast<SdXMLShapeContext*>( pImplContext );
3376 if( pSContext )
3377 {
3378 uno::Reference < beans::XPropertySet > xPropSet(
3379 pSContext->getShape(), uno::UNO_QUERY );
3380 if( xPropSet.is() )
3381 {
3382 xContext = new XMLReplacementImageContext( GetImport(),
3383 nElement, xAttrList, xPropSet );
3384 mxReplImplContext = xContext;
3385 }
3386 }
3387 }
3388 else if( nElement == XML_ELEMENT(SVG, XML_TITLE) || // #i68101#
3389 nElement == XML_ELEMENT(SVG_COMPAT, XML_TITLE) ||
3390 nElement == XML_ELEMENT(SVG, XML_DESC) ||
3391 nElement == XML_ELEMENT(SVG_COMPAT, XML_DESC) ||
3392 nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ||
3393 nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) ||
3394 nElement == XML_ELEMENT(DRAW, XML_THUMBNAIL) )
3395 {
3397 { // tdf#103567 ensure props are set on surviving shape
3398 // note: no more draw:image can be added once we get here
3400 }
3401 SvXMLImportContext *pImplContext = mxImplContext.get();
3402 xContext = static_cast<SvXMLImportContext*>(dynamic_cast<SdXMLShapeContext&>(*pImplContext).createFastChildContext( nElement,
3403 xAttrList ).get());
3404 }
3405 else if ( nElement == XML_ELEMENT(DRAW, XML_IMAGE_MAP) )
3406 {
3408 { // tdf#103567 ensure props are set on surviving shape
3409 // note: no more draw:image can be added once we get here
3411 }
3412 SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( mxImplContext.get() );
3413 if( pSContext )
3414 {
3415 uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY );
3416 if (xPropSet.is())
3417 {
3418 xContext = new XMLImageMapContext(GetImport(), xPropSet);
3419 }
3420 }
3421 }
3422 else if ( nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE) )
3423 {
3424 SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
3425 if (pSContext)
3426 {
3427 uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
3428 if (xPropSet.is())
3429 {
3430 xContext = new SignatureLineContext(GetImport(), nElement, xAttrList,
3431 pSContext->getShape());
3432 }
3433 }
3434 }
3435 else if ( nElement == XML_ELEMENT(LO_EXT, XML_QRCODE))
3436 {
3437 SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
3438 if (pSContext)
3439 {
3440 uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
3441 if (xPropSet.is())
3442 {
3443 xContext = new QRCodeContext(GetImport(), nElement, xAttrList,
3444 pSContext->getShape());
3445 }
3446 }
3447 }
3448
3449 return xContext;
3450}
3451
3452void SdXMLFrameShapeContext::startFastElement (sal_Int32 /*nElement*/,
3453 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
3454{
3455 // ignore
3456}
3457
3459{
3460 // solve if multiple image child contexts were imported
3461 SvXMLImportContextRef const pSelectedContext(solveMultipleImages());
3462 const SdXMLGraphicObjectShapeContext* pShapeContext(
3463 dynamic_cast<const SdXMLGraphicObjectShapeContext*>(pSelectedContext.get()));
3464 if ( pShapeContext )
3465 {
3466 assert( mxImplContext.is() );
3467 const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() );
3468 GetImport().getInterfaceToIdentifierMapper().registerReservedReference( maShapeId, xShape );
3469 }
3470
3471 if( !mxImplContext.is() )
3472 {
3473 // now check if this is an empty presentation object
3475 {
3476 switch (aIter.getToken())
3477 {
3478 case XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER):
3480 break;
3481 case XML_ELEMENT(PRESENTATION, XML_CLASS):
3482 maPresentationClass = aIter.toString();
3483 break;
3484 default:;
3485 }
3486 }
3487
3488 if( (!maPresentationClass.isEmpty()) && mbIsPlaceholder )
3489 {
3490 uno::Reference< xml::sax::XFastAttributeList> xEmpty;
3491
3493
3495 {
3496 eToken = XML_IMAGE;
3497
3498 }
3500 {
3502 }
3506 {
3508 }
3509
3510 auto x = XML_ELEMENT(DRAW, eToken);
3512 GetImport(), x, mxAttrList, mxShapes, xEmpty );
3513
3514 if( mxImplContext.is() )
3515 {
3516 mxImplContext->startFastElement( x, mxAttrList );
3517 mxImplContext->endFastElement(x);
3518 }
3519 }
3520 }
3521
3522 mxImplContext = nullptr;
3524}
3525
3527{
3528 bool bId( false );
3529
3530 switch ( aIter.getToken() )
3531 {
3532 case XML_ELEMENT(DRAW, XML_ID):
3533 case XML_ELEMENT(DRAW_EXT, XML_ID):
3534 case XML_ELEMENT(NONE, XML_ID):
3535 case XML_ELEMENT(XML, XML_ID) :
3536 bId = true;
3537 break;
3538 default:;
3539 }
3540
3541 if ( bId )
3543 return true; // deliberately ignoring other attributes
3544}
3545
3546
3548 SvXMLImport& rImport,
3549 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
3550 uno::Reference< drawing::XShapes > const & rShapes)
3551: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
3552{
3553 // See the XMLTextFrameContext ctor, a frame has Writer content (and not
3554 // editeng) if its autostyle has a parent style. Do the same for shapes as well.
3555 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
3556 {
3557 if (aIter.getToken() == XML_ELEMENT(DRAW, XML_STYLE_NAME))
3558 {
3559 OUString aStyleName = aIter.toString();
3560 if(!aStyleName.isEmpty())
3561 {
3562 rtl::Reference<XMLTextImportHelper> xTxtImport = GetImport().GetTextImport();
3563 XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName);
3564 // Note that this an API name, so intentionally not localized.
3565 // Also allow other Frame styles with the same prefix, we just want to reject
3566 // Graphics after all.
3567 if (pStyle && pStyle->GetParentName().startsWith("Frame"))
3568 {
3569 mbTextBox = true;
3570 break;
3571 }
3572 }
3573 }
3574 }
3575}
3576
3578{
3579}
3580
3581// this is called from the parent group for each unparsed attribute in the attribute list
3583{
3584 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_ENGINE) )
3585 {
3586 maCustomShapeEngine = aIter.toString();
3587 }
3588 else if (aIter.getToken() == XML_ELEMENT(DRAW, XML_DATA) )
3589 {
3590 maCustomShapeData = aIter.toString();
3591 }
3592 else
3594 return true;
3595}
3596
3598 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
3599{
3600 // create rectangle shape
3601 AddShape("com.sun.star.drawing.CustomShape");
3602 if ( !mxShape.is() )
3603 return;
3604
3605 // Add, set Style and properties from base shape
3606 SetStyle();
3607 SetLayer();
3608
3609 // set pos, size, shear and rotate
3611
3612 try
3613 {
3614 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3615 if( xPropSet.is() )
3616 {
3617 if ( !maCustomShapeEngine.isEmpty() )
3618 {
3619 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), Any(maCustomShapeEngine) );
3620 }
3621 if ( !maCustomShapeData.isEmpty() )
3622 {
3623 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), Any(maCustomShapeData) );
3624 }
3625 }
3626 }
3627 catch(const uno::Exception&)
3628 {
3629 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" );
3630 }
3631 SdXMLShapeContext::startFastElement(nElement, xAttrList);
3632}
3633
3635{
3636 // Customshapes remember mirror state in its enhanced geometry.
3637 // SetTransformation() in StartElement() may have applied mirroring, but that is not yet
3638 // contained. Merge that information here before writing the property.
3640 {
3641 basegfx::B2DVector aScale, aTranslate;
3642 double fRotate, fShearX;
3643
3644 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
3645
3646 if (aScale.getX() < 0.0)
3647 {
3648 static const OUStringLiteral sName(u"MirroredX");
3649 //fdo#84043 Merge, if property exists, otherwise append it
3650 auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
3651 [](beans::PropertyValue& rValue) { return rValue.Name == sName; });
3652 if (aI != maCustomShapeGeometry.end())
3653 {
3654 beans::PropertyValue& rItem = *aI;
3655 bool bMirroredX = *o3tl::doAccess<bool>(rItem.Value);
3656 rItem.Value <<= !bMirroredX;
3657 rItem.Handle = -1;
3658 rItem.State = beans::PropertyState_DIRECT_VALUE;
3659 }
3660 else
3661 {
3662 beans::PropertyValue* pItem;
3663 maCustomShapeGeometry.emplace_back();
3664 pItem = &maCustomShapeGeometry.back();
3665 pItem->Name = sName;
3666 pItem->Handle = -1;
3667 pItem->Value <<= true;
3668 pItem->State = beans::PropertyState_DIRECT_VALUE;
3669 }
3670 }
3671
3672 if (aScale.getY() < 0.0)
3673 {
3674 static const OUStringLiteral sName(u"MirroredY");
3675 //fdo#84043 Merge, if property exists, otherwise append it
3676 auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
3677 [](beans::PropertyValue& rValue) { return rValue.Name == sName; });
3678 if (aI != maCustomShapeGeometry.end())
3679 {
3680 beans::PropertyValue& rItem = *aI;
3681 bool bMirroredY = *o3tl::doAccess<bool>(rItem.Value);
3682 rItem.Value <<= !bMirroredY;
3683 rItem.Handle = -1;
3684 rItem.State = beans::PropertyState_DIRECT_VALUE;
3685 }
3686 else
3687 {
3688 beans::PropertyValue* pItem;
3689 maCustomShapeGeometry.emplace_back();
3690 pItem = &maCustomShapeGeometry.back();
3691 pItem->Name = sName;
3692 pItem->Handle = -1;
3693 pItem->Value <<= true;
3694 pItem->State = beans::PropertyState_DIRECT_VALUE;
3695 }
3696 }
3697 }
3698
3699 if ( !maCustomShapeGeometry.empty() )
3700 {
3701 // converting the vector to a sequence
3702 uno::Sequence< beans::PropertyValue > aSeq( comphelper::containerToSequence(maCustomShapeGeometry) );
3703
3704 try
3705 {
3706 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3707 if( xPropSet.is() )
3708 {
3709 xPropSet->setPropertyValue( "CustomShapeGeometry", Any(aSeq) );
3710 }
3711 }
3712 catch(const uno::Exception&)
3713 {
3714 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" );
3715 }
3716
3717 sal_Int32 nUPD;
3718 sal_Int32 nBuild;
3719 if (GetImport().getBuildIds(nUPD, nBuild))
3720 {
3721 if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) )
3722 {
3723 Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY );
3724 if( xDefaulter.is() )
3725 {
3726 xDefaulter->createCustomShapeDefaults( "" );
3727 }
3728 }
3729 }
3730 }
3731
3733
3734 // tdf#98163 call a custom slot to be able to reset the UNO API
3735 // implementations held on the SdrObjects of type
3736 // SdrObjCustomShape - those tend to linger until the entire file
3737 // is loaded. For large files with a lot of these, 32bit systems
3738 // may crash due to being out of resources after ca. 4200
3739 // Outliners and VirtualDevices used there as RefDevice
3740 try
3741 {
3742 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
3743
3744 if(xPropSet.is())
3745 {
3746 xPropSet->setPropertyValue(
3747 "FlushCustomShapeUnoApiObjects", css::uno::Any(true));
3748 }
3749 }
3750 catch(const uno::Exception&)
3751 {
3752 DBG_UNHANDLED_EXCEPTION("xmloff", "flushing after load");
3753 }
3754}
3755
3756css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLCustomShapeContext::createFastChildContext(
3757 sal_Int32 nElement,
3758 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
3759{
3760 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
3761 if ( nElement == XML_ELEMENT(DRAW, XML_ENHANCED_GEOMETRY) )
3762 {
3763 uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
3764 if ( xPropSet.is() )
3766 }
3767 // delegate to parent class if no context could be created
3768 if (!xContext)
3769 xContext = SdXMLShapeContext::createFastChildContext( nElement,
3770 xAttrList);
3771 return xContext;
3772}
3773
3774SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes )
3775: SdXMLShapeContext( rImport, xAttrList, rShapes, false )
3776{
3777}
3778
3780{
3781}
3782
3784 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
3785{
3786 OUString service("com.sun.star.drawing.TableShape");
3787
3788 bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3789 if( bIsPresShape )
3790 {
3792 {
3793 service = "com.sun.star.presentation.TableShape";
3794 }
3795 }
3796
3797 AddShape(service);
3798
3799 if( !mxShape.is() )
3800 return;
3801
3802 SetLayer();
3803
3804 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
3805
3806 if(bIsPresShape && xProps.is())
3807 {
3808 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3809 if( xPropsInfo.is() )
3810 {
3811 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
3812 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
3813
3814 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
3815 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
3816 }
3817 }
3818
3819 SetStyle();
3820
3821 if( xProps.is() )
3822 {
3823 if( !msTemplateStyleName.isEmpty() ) try
3824 {
3825 Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
3826 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
3827 Reference< XNameAccess > xTableFamily( xFamilies->getByName( "table" ), UNO_QUERY_THROW );
3828 Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
3829 xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) );
3830 }
3831 catch(const Exception&)
3832 {
3833 DBG_UNHANDLED_EXCEPTION("xmloff.draw");
3834 }
3835
3837 for( int i = 0; !pEntry->IsEnd() && (i < 6); i++, pEntry++ )
3838 {
3839 try
3840 {
3841 xProps->setPropertyValue( pEntry->getApiName(), Any( maTemplateStylesUsed[i] ) );
3842 }
3843 catch(const Exception&)
3844 {
3845 DBG_UNHANDLED_EXCEPTION("xmloff.draw");
3846 }
3847 }
3848 }
3849
3850 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3851
3852 const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3853 if( xTableImport.is() && xProps.is() )
3854 {
3855 uno::Reference< table::XColumnRowRange > xColumnRowRange(
3856 xProps->getPropertyValue("Model"), uno::UNO_QUERY );
3857
3858 if( xColumnRowRange.is() )
3859 mxTableImportContext = xTableImport->CreateTableContext( xColumnRowRange );
3860
3861 if( mxTableImportContext.is() )
3862 mxTableImportContext->startFastElement( nElement, xAttrList );
3863 }
3864}
3865
3867{
3868 if( mxTableImportContext.is() )
3869 mxTableImportContext->endFastElement(nElement);
3870
3872
3873 if( mxShape.is() )
3874 {
3875 // set pos, size, shear and rotate
3877 }
3878}
3879
3880// this is called from the parent group for each unparsed attribute in the attribute list
3882{
3883 auto nElement = aIter.getToken();
3885 {
3886 if( (nElement & TOKEN_MASK) == XML_TEMPLATE_NAME )
3887 {
3888 msTemplateStyleName = aIter.toString();
3889 }
3890 else
3891 {
3892 int i = 0;
3894 while( !pEntry->IsEnd() && (i < 6) )
3895 {
3896 if( (nElement & TOKEN_MASK) == pEntry->meXMLName )
3897 {
3898 if( IsXMLToken( aIter, XML_TRUE ) )
3899 maTemplateStylesUsed[i] = true;
3900 break;
3901 }
3902 pEntry++;
3903 i++;
3904 }
3905 }
3906 }
3908}
3909
3910css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLTableShapeContext::createFastChildContext(
3911 sal_Int32 nElement,
3912 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
3913{
3915 return mxTableImportContext->createFastChildContext(nElement, xAttrList);
3916 return SdXMLShapeContext::createFastChildContext(nElement, xAttrList);
3917}
3918
3919/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
geometry::RealPoint2D maPosition
geometry::RealSize2D maSize
Point maStart
const Point maEnd
PropertiesInfo aProperties
bool getSupportsMultipleContents() const
read/write access to boolean switch
SvXMLImportContextRef solveMultipleImages()
solve multiple imported images.
void setSupportsMultipleContents(bool bNew)
void addContent(const SvXMLImportContext &rSvXMLImportContext)
add a content to the remembered image import contexts
virtual ~SdXMLAppletShapeContext() override
Definition: ximpshap.cxx:2750
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2754
css::uno::Sequence< css::beans::PropertyValue > maParams
Definition: ximpshap.hxx:470
SdXMLAppletShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2742
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2838
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2770
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:2792
virtual ~SdXMLCaptionShapeContext() override
Definition: ximpshap.cxx:2217
SdXMLCaptionShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:2206
css::awt::Point maCaptionPoint
Definition: ximpshap.hxx:364
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2278
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2221
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
Definition: ximpshap.cxx:2530
SdXMLChartShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:2446
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: ximpshap.cxx:2536
SvXMLImportContextRef mxChartContext
Definition: ximpshap.hxx:413
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2455
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:2522
css::drawing::ConnectorType mnType
Definition: ximpshap.hxx:286
virtual ~SdXMLConnectorShapeContext() override
Definition: ximpshap.cxx:1747
SdXMLConnectorShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:1730
css::awt::Point maEnd
Definition: ximpshap.hxx:283
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1863
css::awt::Point maStart
Definition: ximpshap.hxx:282
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1770
virtual ~SdXMLControlShapeContext() override
Definition: ximpshap.cxx:1677
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1682
SdXMLControlShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:1668
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1695
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3597
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:3634
std::vector< css::beans::PropertyValue > maCustomShapeGeometry
Definition: ximpshap.hxx:586
virtual ~SdXMLCustomShapeContext() override
Definition: ximpshap.cxx:3577
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: ximpshap.cxx:3756
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3582
SdXMLCustomShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:3547
OUString maCustomShapeEngine
Definition: ximpshap.hxx:583
css::drawing::CircleKind meKind
Definition: ximpshap.hxx:172
SdXMLEllipseShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:1095
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1116
virtual ~SdXMLEllipseShapeContext() override
Definition: ximpshap.cxx:1111
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1170
virtual ~SdXMLFloatingFrameShapeContext() override
Definition: ximpshap.cxx:3131
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:3187
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3171
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3135
SdXMLFloatingFrameShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:3124
SdXMLFrameShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:3206
SvXMLImportContextRef mxReplImplContext
Definition: ximpshap.hxx:554
css::uno::Reference< css::graphic::XGraphic > getGraphicFromImportContext(const SvXMLImportContext &rContext) const override
Definition: ximpshap.cxx:3269
void removeGraphicFromImportContext(const SvXMLImportContext &rContext) override
helper to get the created xShape instance, needs to be overridden
Definition: ximpshap.cxx:3224
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3452
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:3458
virtual ~SdXMLFrameShapeContext() override
Definition: ximpshap.cxx:3220
OUString getGraphicPackageURLFromImportContext(const SvXMLImportContext &rContext) const override
Definition: ximpshap.cxx:3289
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: ximpshap.cxx:3311
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3526
SvXMLImportContextRef mxImplContext
Definition: ximpshap.hxx:553
SdXMLGraphicObjectShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2301
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2310
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:2394
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2319
css::uno::Reference< css::io::XOutputStream > mxBase64Stream
Definition: ximpshap.hxx:388
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2412
virtual ~SdXMLGraphicObjectShapeContext() override
Definition: ximpshap.cxx:2440
bool NeedsAction() const
Definition: xexptran.hxx:55
void SetString(const OUString &rNew, const SvXMLUnitConverter &rConv)
Definition: xexptran.cxx:349
void GetFullTransform(::basegfx::B2DHomMatrix &rFullTrans)
Definition: xexptran.cxx:482
double GetHeight() const
Definition: xexptran.hxx:97
double GetY() const
Definition: xexptran.hxx:95
double GetX() const
Definition: xexptran.hxx:94
double GetWidth() const
Definition: xexptran.hxx:96
SdXMLLineShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:986
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1004
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1034
virtual ~SdXMLLineShapeContext() override
Definition: ximpshap.cxx:999
css::awt::Point maStart
Definition: ximpshap.hxx:319
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:2102
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2073
css::awt::Point maEnd
Definition: ximpshap.hxx:320
virtual ~SdXMLMeasureShapeContext() override
Definition: ximpshap.cxx:2030
SdXMLMeasureShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:2019
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2035
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:2654
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: ximpshap.cxx:2706
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2558
SdXMLObjectShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2547
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2690
css::uno::Reference< css::io::XOutputStream > mxBase64Stream
Definition: ximpshap.hxx:439
virtual ~SdXMLObjectShapeContext() override
Definition: ximpshap.cxx:2554
virtual ~SdXMLPageShapeContext() override
Definition: ximpshap.cxx:2135
SdXMLPageShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:2125
sal_Int32 mnPageNumber
Definition: ximpshap.hxx:343
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2149
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2140
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1367
SdXMLPathShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:1335
virtual ~SdXMLPathShapeContext() override
Definition: ximpshap.cxx:1344
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1349
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2884
css::uno::Sequence< css::beans::PropertyValue > maParams
Definition: ximpshap.hxx:500
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:2985
const OUString & getMimeType() const
Definition: ximpshap.hxx:520
virtual ~SdXMLPluginShapeContext() override
Definition: ximpshap.cxx:2880
SdXMLPluginShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2872
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3090
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2969
virtual ~SdXMLPolygonShapeContext() override
Definition: ximpshap.cxx:1259
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1263
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1242
SdXMLPolygonShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bClosed, bool bTemporaryShape)
Definition: ximpshap.cxx:1232
SdXMLRectShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:923
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:938
virtual ~SdXMLRectShapeContext() override
Definition: ximpshap.cxx:933
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:952
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:322
sal_Int32 mnZOrder
Definition: ximpshap.hxx:67
OUString maDrawStyleName
Definition: ximpshap.hxx:54
basegfx::B2DHomMatrix maUsedTransformation
Definition: ximpshap.hxx:76
OUString maThumbnailURL
Definition: ximpshap.hxx:58
css::awt::Point maPosition
Definition: ximpshap.hxx:75
OUString maTextStyleName
Definition: ximpshap.hxx:55
void addGluePoint(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: ximpshap.cxx:245
css::uno::Reference< css::document::XActionLockable > mxLockable
Definition: ximpshap.hxx:52
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: ximpshap.cxx:174
void AddShape(css::uno::Reference< css::drawing::XShape > &xShape)
OUString maLayerName
Definition: ximpshap.hxx:69
OUString maShapeName
Definition: ximpshap.hxx:57
SdXMLShapeContext(SvXMLImport &rImport, css::uno::Reference< css::xml::sax::XFastAttributeList > xAttrList, css::uno::Reference< css::drawing::XShapes > xShapes, bool bTemporaryShape)
Definition: ximpshap.cxx:145
bool mbClearDefaultAttributes
Definition: ximpshap.hxx:65
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &)
Definition: ximpshap.cxx:798
void SetTransformation()
Definition: ximpshap.cxx:521
css::uno::Reference< css::text::XTextCursor > mxCursor
Definition: ximpshap.hxx:48
sal_Int16 mnRelWidth
Definition: ximpshap.hxx:73
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
XmlStyleFamily mnStyleFamily
Definition: ximpshap.hxx:63
css::uno::Reference< css::container::XIdentifierContainer > mxGluePoints
Definition: ximpshap.hxx:51
OUString maShapeId
Definition: ximpshap.hxx:68
css::uno::Reference< css::xml::sax::XFastAttributeList > mxAttrList
Definition: ximpshap.hxx:50
virtual ~SdXMLShapeContext() override
Definition: ximpshap.cxx:170
bool mbListContextPushed
whether to restore list context (#91964#)
Definition: ximpshap.hxx:61
SdXMLImExTransform2D mnTransform
Definition: ximpshap.hxx:71
void SetStyle(bool bSupportsStyle=true)
if bSupportsStyle is false, auto styles will be set but not a style
Definition: ximpshap.cxx:599
bool mbTextBox
If the text of this shape is handled by a Writer TextFrame.
Definition: ximpshap.hxx:81
OUString maPresentationClass
Definition: ximpshap.hxx:56
sal_Int16 mnRelHeight
Definition: ximpshap.hxx:74
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:328
css::uno::Reference< css::drawing::XShapes > mxShapes
Definition: ximpshap.hxx:47
bool isPresentationShape() const
Definition: ximpshap.cxx:904
bool mbIsUserTransformed
Definition: ximpshap.hxx:66
css::awt::Size maSize
Definition: ximpshap.hxx:72
css::uno::Reference< css::text::XTextCursor > mxOldCursor
Definition: ximpshap.hxx:49
SvXMLImportContextRef mxTableImportContext
Definition: ximpshap.hxx:630
bool maTemplateStylesUsed[6]
Definition: ximpshap.hxx:632
virtual ~SdXMLTableShapeContext() override
Definition: ximpshap.cxx:3779
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3881
SdXMLTableShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:3774
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: ximpshap.cxx:3866
OUString msTemplateStyleName
Definition: ximpshap.hxx:631
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: ximpshap.cxx:3910
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3783
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1501
SdXMLTextBoxShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:1486
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1518
virtual ~SdXMLTextBoxShapeContext() override
Definition: ximpshap.cxx:1496
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
Definition: xmlictxt.cxx:30
void setHyperlink(const OUString &rHyperlink)
css::uno::Reference< css::drawing::XShape > mxShape
const css::uno::Reference< css::drawing::XShape > & getShape() const
const OUString & GetParentName() const
Definition: xmlstyle.hxx:81
bool getNextToken(std::u16string_view &rToken)
Definition: xmluconv.cxx:528
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
Definition: prstylei.cxx:222
const css::uno::Reference< css::style::XStyle > & GetStyle() const
Definition: prstylei.hxx:106
static SvXMLShapeContext * CreateFrameChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xFrameAttrList)
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void translate(double fX, double fY)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void scale(double fX, double fY)
bool isIdentity() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
bool areControlPointsUsed() const
sal_uInt32 count() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 count() const
bool equal(const Range2D &rRange) const
TYPE getX() const
TYPE getY() const
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
#define DBG_UNHANDLED_EXCEPTION(...)
float u
float x
XmlStyleFamily
Definition: families.hxx:50
DRAW
MATH
sal_Int32 nIndex
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
const char * sName
NONE
bool equalZero(const T &rfVal)
bool importFromSvgPoints(B2DPolygon &o_rPoly, std::u16string_view rSvgPointsAttribute)
void B2DPolyPolygonToUnoPointSequenceSequence(const B2DPolyPolygon &rPolyPolygon, css::drawing::PointSequenceSequence &rPointSequenceSequenceRetval)
bool importFromSvgD(B2DPolyPolygon &o_rPolyPoly, std::u16string_view rSvgDAttribute, bool bHandleRelativeNextPointCompatible, PointIndexSet *pHelpPointIndexSet)
void B2DPolyPolygonToUnoPolyPolygonBezierCoords(const B2DPolyPolygon &rPolyPolygon, css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsRetval)
B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fShearX, double fRadiant, double fTranslateX, double fTranslateY)
B2DHomMatrix createSourceRangeTargetRangeTransform(const B2DRange &rSourceRange, const B2DRange &rTargetRange)
B2IRange fround(const B2DRange &rRange)
@ Exception
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
int i
constexpr T saturating_sub(T a, T b)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
EnhancedCustomShapeTokenEnum EASGet(std::u16string_view rShapeType)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
@ XML_PRESENTATION_OUTLINE
Definition: xmltoken.hxx:1547
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3585
sal_Int16 nId
DefTokenId nToken
sal_Int32 mnType
const XMLPropertyMapEntry aXMLTableShapeAttributes[]
contains the attribute to property mapping for a drawing layer table WARNING: if attributes are added...
Definition: sdpropls.cxx:379
SvXMLEnumMapEntry< drawing::ConnectorType > const aXML_ConnectionKind_EnumMap[]
Definition: sdpropls.cxx:507
SvXMLEnumMapEntry< drawing::CircleKind > const aXML_CircleKind_EnumMap[]
Definition: sdpropls.cxx:579
Represents a property with its API-name, its XML-name and the type of its value.
Definition: maptype.hxx:33
enum::xmloff::token::XMLTokenEnum meXMLName
Property-Name.
Definition: maptype.hxx:35
bool IsEnd() const
Definition: maptype.hxx:132
const OUString & getApiName() const
Definition: maptype.hxx:129
bool mbVisible
@ Shape
Definition: txtimp.hxx:72
@ TextBox
Definition: txtimp.hxx:73
SvXMLEnumMapEntry< drawing::EscapeDirection > const aXML_GlueEscapeDirection_EnumMap[]
Definition: ximpshap.cxx:119
static OUString lcl_GetMediaReference(SvXMLImport const &rImport, OUString const &rURL)
Definition: ximpshap.cxx:2956
SvXMLEnumMapEntry< drawing::Alignment > const aXML_GlueAlignment_EnumMap[]
Definition: ximpshap.cxx:105
static bool ImpIsEmptyURL(std::u16string_view rURL)
Definition: ximpshap.cxx:131
#define XMLERROR_FLAG_ERROR
Definition: xmlerror.hxx:36
#define XMLERROR_API
Definition: xmlerror.hxx:71
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:104
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
constexpr sal_uInt16 XML_NAMESPACE_TABLE
XMLTokenEnum eToken
Definition: xmltoken.cxx:40