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