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
65
66#include <xmloff/families.hxx>
68#include <xmloff/xmltoken.hxx>
72#include "sdpropls.hxx"
73#include "eventimp.hxx"
74#include "descriptionimp.hxx"
76#include "QRCodeContext.hxx"
77#include "ximpcustomshape.hxx"
79#include <xmloff/xmlerror.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 = 0;
594 aUnoMatrix.Line3.Column2 = 0;
595 aUnoMatrix.Line3.Column3 = 1;
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 if (xFamilies->hasByName("graphics"))
676 xFamilies->getByName("graphics") >>= xFamily;
677 else
678 xFamilies->getByName("GraphicStyles") >>= xFamily;
679
680 aStyleName = GetImport().GetStyleDisplayName(
682 aStyleName );
683 }
684
685 if( xFamily.is() )
686 xFamily->getByName( aStyleName ) >>= xStyle;
687 }
688 }
689 }
690 catch(const uno::Exception&)
691 {
692 DBG_UNHANDLED_EXCEPTION( "xmloff", "finding style for shape" );
693 }
694 }
695
696 if( bSupportsStyle && xStyle.is() )
697 {
698 try
699 {
700 // set style on object
701 xPropSet->setPropertyValue("Style", Any(xStyle));
702 }
703 catch(const uno::Exception&)
704 {
705 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting style for shape" );
706 }
707 }
708
709 // Writer shapes: if this one has a TextBox, set it here. We need to do it before
710 // pDocStyle->FillPropertySet, because setting some properties depend on the format
711 // having RES_CNTNT attribute (e.g., UNO_NAME_TEXT_(LEFT|RIGHT|UPPER|LOWER)DIST; see
712 // SwTextBoxHelper::syncProperty, which indirectly calls SwTextBoxHelper::isTextBox)
713 uno::Reference<beans::XPropertySetInfo> xPropertySetInfo
714 = xPropSet->getPropertySetInfo();
715 static constexpr OUStringLiteral sTextBox = u"TextBox";
716 if (xPropertySetInfo->hasPropertyByName(sTextBox))
717 xPropSet->setPropertyValue(sTextBox, uno::Any(mbTextBox));
718
719 // if this is an auto style, set its properties
720 if(bAutoStyle && pDocStyle)
721 {
722 // set PropertySet on object
723 pDocStyle->FillPropertySet(xPropSet);
724 }
725
726 } while(false);
727
728 // try to set text auto style
729 do
730 {
731 // set style on shape
732 if( maTextStyleName.isEmpty() )
733 break;
734
735 if( nullptr == GetImport().GetShapeImport()->GetAutoStylesContext())
736 break;
737
738 const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XmlStyleFamily::TEXT_PARAGRAPH, maTextStyleName);
739 XMLPropStyleContext* pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast<const XMLPropStyleContext*>( pTempStyle ) ); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
740 if( pStyle == nullptr )
741 break;
742
743 // set PropertySet on object
744 pStyle->FillPropertySet(xPropSet);
745
746 } while(false);
747 }
748 catch(const uno::Exception&)
749 {
750 }
751}
752
754{
755 if( maLayerName.isEmpty() )
756 return;
757
758 try
759 {
760 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
761 if(xPropSet.is() )
762 {
763 xPropSet->setPropertyValue("LayerName", Any(maLayerName));
764 return;
765 }
766 }
767 catch(const uno::Exception&)
768 {
769 }
770}
771
773{
774 if( maThumbnailURL.isEmpty() )
775 return;
776
777 try
778 {
779 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
780 if( !xPropSet.is() )
781 return;
782
783 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
784 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( "ThumbnailGraphic" ) )
785 {
786 // load the thumbnail graphic and export it to a wmf stream so we can set
787 // it at the api
788
789 uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maThumbnailURL);
790 xPropSet->setPropertyValue("ThumbnailGraphic", uno::Any(xGraphic));
791 }
792 }
793 catch(const uno::Exception&)
794 {
795 }
796}
797
798// this is called from the parent group for each unparsed attribute in the attribute list
800{
801 sal_Int32 nTmp;
802 switch (aIter.getToken())
803 {
805 case XML_ELEMENT(DRAW_EXT, XML_ZINDEX):
806 mnZOrder = aIter.toInt32();
807 break;
808 case XML_ELEMENT(DRAW, XML_ID):
809 case XML_ELEMENT(DRAW_EXT, XML_ID):
810 if (!mbHaveXmlId) { maShapeId = aIter.toString(); }
811 break;
813 case XML_ELEMENT(DRAW_EXT, XML_NAME):
814 maShapeName = aIter.toString();
815 break;
817 case XML_ELEMENT(DRAW_EXT, XML_STYLE_NAME):
818 maDrawStyleName = aIter.toString();
819 break;
821 case XML_ELEMENT(DRAW_EXT, XML_TEXT_STYLE_NAME):
822 maTextStyleName = aIter.toString();
823 break;
825 case XML_ELEMENT(DRAW_EXT, XML_LAYER):
826 maLayerName = aIter.toString();
827 break;
829 case XML_ELEMENT(DRAW_EXT, XML_TRANSFORM):
830 mnTransform.SetString(aIter.toString(), GetImport().GetMM100UnitConverter());
831 break;
833 case XML_ELEMENT(DRAW_EXT, XML_DISPLAY):
834 mbVisible = IsXMLToken( aIter, XML_ALWAYS ) || IsXMLToken( aIter, XML_SCREEN );
835 mbPrintable = IsXMLToken( aIter, XML_ALWAYS ) || IsXMLToken( aIter, XML_PRINTER );
836 break;
837 case XML_ELEMENT(PRESENTATION, XML_USER_TRANSFORMED):
839 break;
840 case XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER):
842 if( mbIsPlaceholder )
844 break;
845 case XML_ELEMENT(PRESENTATION, XML_CLASS):
847 break;
848 case XML_ELEMENT(PRESENTATION, XML_STYLE_NAME):
849 maDrawStyleName = aIter.toString();
851 break;
852 case XML_ELEMENT(SVG, XML_X):
853 case XML_ELEMENT(SVG_COMPAT, XML_X):
854 GetImport().GetMM100UnitConverter().convertMeasureToCore(
855 maPosition.X, aIter.toView());
856 break;
857 case XML_ELEMENT(SVG, XML_Y):
858 case XML_ELEMENT(SVG_COMPAT, XML_Y):
859 GetImport().GetMM100UnitConverter().convertMeasureToCore(
860 maPosition.Y, aIter.toView());
861 break;
863 case XML_ELEMENT(SVG_COMPAT, XML_WIDTH):
864 GetImport().GetMM100UnitConverter().convertMeasureToCore(
865 maSize.Width, aIter.toView());
866 if (maSize.Width > 0)
867 maSize.Width = o3tl::saturating_add<sal_Int32>(maSize.Width, 1);
868 else if (maSize.Width < 0)
869 maSize.Width = o3tl::saturating_add<sal_Int32>(maSize.Width, -1);
870 break;
872 case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT):
873 GetImport().GetMM100UnitConverter().convertMeasureToCore(
874 maSize.Height, aIter.toView());
875 if (maSize.Height > 0)
876 maSize.Height = o3tl::saturating_add<sal_Int32>(maSize.Height, 1);
877 else if (maSize.Height < 0)
878 maSize.Height = o3tl::saturating_add<sal_Int32>(maSize.Height, -1);
879 break;
881 case XML_ELEMENT(SVG_COMPAT, XML_TRANSFORM):
882 // because of #85127# take svg:transform into account and handle like
883 // draw:transform for compatibility
884 mnTransform.SetString(aIter.toString(), GetImport().GetMM100UnitConverter());
885 break;
887 if (sax::Converter::convertPercent(nTmp, aIter.toView()))
888 mnRelWidth = static_cast<sal_Int16>(nTmp);
889 break;
891 if (sax::Converter::convertPercent(nTmp, aIter.toView()))
892 mnRelHeight = static_cast<sal_Int16>(nTmp);
893 break;
894 case XML_ELEMENT(NONE, XML_ID):
895 case XML_ELEMENT(XML, XML_ID):
896 maShapeId = aIter.toString();
897 mbHaveXmlId = true;
898 break;
899 default:
900 return false;
901 }
902 return true;
903}
904
906{
907 if( !maPresentationClass.isEmpty() && const_cast<SdXMLShapeContext*>(this)->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
908 {
910 {
911 return true;
912 }
913
916 {
917 return true;
918 }
919 }
920
921 return false;
922}
923
925 SvXMLImport& rImport,
926 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
927 uno::Reference< drawing::XShapes > const & rShapes,
928 bool bTemporaryShape)
929: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
930 mnRadius( 0 )
931{
932}
933
935{
936}
937
938// this is called from the parent group for each unparsed attribute in the attribute list
940{
941 switch (aIter.getToken())
942 {
944 GetImport().GetMM100UnitConverter().convertMeasureToCore(
945 mnRadius, aIter.toView());
946 break;
947 default:
949 }
950 return true;
951}
952
954 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
955{
956 // create rectangle shape
957 AddShape("com.sun.star.drawing.RectangleShape");
958 if(!mxShape.is())
959 return;
960
961 // Add, set Style and properties from base shape
962 SetStyle();
963 SetLayer();
964
965 // set pos, size, shear and rotate
967
968 if(mnRadius)
969 {
970 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
971 if(xPropSet.is())
972 {
973 try
974 {
975 xPropSet->setPropertyValue("CornerRadius", uno::Any( mnRadius ) );
976 }
977 catch(const uno::Exception&)
978 {
979 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
980 }
981 }
982 }
983 SdXMLShapeContext::startFastElement(nElement, xAttrList);
984}
985
986
988 SvXMLImport& rImport,
989 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
990 uno::Reference< drawing::XShapes > const & rShapes,
991 bool bTemporaryShape)
992: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
993 mnX1( 0 ),
994 mnY1( 0 ),
995 mnX2( 1 ),
996 mnY2( 1 )
997{
998}
999
1001{
1002}
1003
1004// this is called from the parent group for each unparsed attribute in the attribute list
1006{
1007 switch (aIter.getToken())
1008 {
1009 case XML_ELEMENT(SVG, XML_X1):
1010 case XML_ELEMENT(SVG_COMPAT, XML_X1):
1011 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1012 mnX1, aIter.toView());
1013 break;
1014 case XML_ELEMENT(SVG, XML_Y1):
1015 case XML_ELEMENT(SVG_COMPAT, XML_Y1):
1016 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1017 mnY1, aIter.toView());
1018 break;
1019 case XML_ELEMENT(SVG, XML_X2):
1020 case XML_ELEMENT(SVG_COMPAT, XML_X2):
1021 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1022 mnX2, aIter.toView());
1023 break;
1024 case XML_ELEMENT(SVG, XML_Y2):
1025 case XML_ELEMENT(SVG_COMPAT, XML_Y2):
1026 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1027 mnY2, aIter.toView());
1028 break;
1029 default:
1031 }
1032 return true;
1033}
1034
1036 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1037{
1038 // #85920# use SetTransformation() to handle import of simple lines.
1039 // This is necessary to take into account all anchor positions and
1040 // other things. All shape imports use the same import schemata now.
1041 // create necessary shape (Line Shape)
1042 AddShape("com.sun.star.drawing.PolyLineShape");
1043
1044 if(!mxShape.is())
1045 return;
1046
1047 // Add, set Style and properties from base shape
1048 SetStyle();
1049 SetLayer();
1050
1051 // get sizes and offsets
1052 awt::Point aTopLeft(mnX1, mnY1);
1053 awt::Point aBottomRight(mnX2, mnY2);
1054
1055 if(mnX1 > mnX2)
1056 {
1057 aTopLeft.X = mnX2;
1058 aBottomRight.X = mnX1;
1059 }
1060
1061 if(mnY1 > mnY2)
1062 {
1063 aTopLeft.Y = mnY2;
1064 aBottomRight.Y = mnY1;
1065 }
1066
1067 // set local parameters on shape
1068 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1069 if(xPropSet.is())
1070 {
1071 drawing::PointSequenceSequence aPolyPoly(1);
1072 drawing::PointSequence* pOuterSequence = aPolyPoly.getArray();
1073 pOuterSequence->realloc(2);
1074 awt::Point* pInnerSequence = pOuterSequence->getArray();
1075
1076 *pInnerSequence = awt::Point(o3tl::saturating_sub(mnX1, aTopLeft.X), o3tl::saturating_sub(mnY1, aTopLeft.Y));
1077 pInnerSequence++;
1078 *pInnerSequence = awt::Point(o3tl::saturating_sub(mnX2, aTopLeft.X), o3tl::saturating_sub(mnY2, aTopLeft.Y));
1079
1080 xPropSet->setPropertyValue("Geometry", Any(aPolyPoly));
1081 }
1082
1083 // Size is included in point coordinates
1084 maSize.Width = 1;
1085 maSize.Height = 1;
1086 maPosition.X = aTopLeft.X;
1087 maPosition.Y = aTopLeft.Y;
1088
1089 // set pos, size, shear and rotate and get copy of matrix
1091
1092 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1093}
1094
1095
1097 SvXMLImport& rImport,
1098 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1099 uno::Reference< drawing::XShapes > const & rShapes,
1100 bool bTemporaryShape)
1101: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
1102 mnCX( 0 ),
1103 mnCY( 0 ),
1104 mnRX( 1 ),
1105 mnRY( 1 ),
1106 meKind( drawing::CircleKind_FULL ),
1107 mnStartAngle( 0 ),
1108 mnEndAngle( 0 )
1109{
1110}
1111
1113{
1114}
1115
1116// this is called from the parent group for each unparsed attribute in the attribute list
1118{
1119 switch (aIter.getToken())
1120 {
1121 case XML_ELEMENT(SVG, XML_RX):
1122 case XML_ELEMENT(SVG_COMPAT, XML_RX):
1123 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1124 mnRX, aIter.toView());
1125 break;
1126 case XML_ELEMENT(SVG, XML_RY):
1127 case XML_ELEMENT(SVG_COMPAT, XML_RY):
1128 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1129 mnRY, aIter.toView());
1130 break;
1131 case XML_ELEMENT(SVG, XML_CX):
1132 case XML_ELEMENT(SVG_COMPAT, XML_CX):
1133 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1134 mnCX, aIter.toView());
1135 break;
1136 case XML_ELEMENT(SVG, XML_CY):
1137 case XML_ELEMENT(SVG_COMPAT, XML_CY):
1138 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1139 mnCY, aIter.toView());
1140 break;
1141 case XML_ELEMENT(SVG, XML_R):
1142 case XML_ELEMENT(SVG_COMPAT, XML_R):
1143 // single radius, it's a circle and both radii are the same
1144 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1145 mnRX, aIter.toView());
1146 mnRY = mnRX;
1147 break;
1148 case XML_ELEMENT(DRAW, XML_KIND):
1150 break;
1152 {
1153 double dStartAngle;
1154 if (::sax::Converter::convertDouble( dStartAngle, aIter.toView() ))
1155 mnStartAngle = static_cast<sal_Int32>(dStartAngle * 100.0);
1156 break;
1157 }
1159 {
1160 double dEndAngle;
1161 if (::sax::Converter::convertDouble( dEndAngle, aIter.toView() ))
1162 mnEndAngle = static_cast<sal_Int32>(dEndAngle * 100.0);
1163 break;
1164 }
1165 default:
1167 }
1168 return true;
1169}
1170
1172 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1173{
1174 // create rectangle shape
1175 AddShape("com.sun.star.drawing.EllipseShape");
1176 if(!mxShape.is())
1177 return;
1178
1179 // Add, set Style and properties from base shape
1180 SetStyle();
1181 SetLayer();
1182
1183 if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1)
1184 {
1185 // #i121972# center/radius is used, put to pos and size
1186 maSize.Width = 2 * mnRX;
1187 maSize.Height = 2 * mnRY;
1188 maPosition.X = mnCX - mnRX;
1189 maPosition.Y = mnCY - mnRY;
1190 }
1191 // set pos, size, shear and rotate
1193
1194 if( meKind != drawing::CircleKind_FULL )
1195 {
1196 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
1197 if( xPropSet.is() )
1198 {
1199 // calculate the correct start and end angle
1200 sal_Int32 mnOldStartAngle = mnStartAngle;
1201 sal_Int32 mnOldEndAngle = mnEndAngle;
1202 basegfx::B2DTuple aScale;
1203 basegfx::B2DTuple aTranslate;
1204 double fRotate;
1205 double fShearX;
1206 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
1207 if (aScale.getX() < 0 || aScale.getY() < 0)
1208 {
1209 // The angle for a horizontal flip is the same as the angle for a
1210 // vertical flip because a vertical flip is treated as a horizontal
1211 // flip plus a rotation.
1212
1213 // To perform the flip, the start and end angle are switched and we
1214 // use the fact performing a horizontal flip on a shape will change
1215 // the angle that a radius makes with the origin to 180 degrees
1216 // minus that angle (we use 54000 hundredths of a degree to get the
1217 // modulus operation to give a value between 0 and 36000).
1218
1219 mnStartAngle = (54000 - mnOldEndAngle) % 36000;
1220 mnEndAngle = (54000 - mnOldStartAngle) % 36000;
1221 }
1222
1223 xPropSet->setPropertyValue("CircleKind", Any( meKind) );
1224 xPropSet->setPropertyValue("CircleStartAngle", Any(mnStartAngle) );
1225 xPropSet->setPropertyValue("CircleEndAngle", Any(mnEndAngle) );
1226 }
1227 }
1228
1229 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1230}
1231
1232
1234 SvXMLImport& rImport,
1235 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1236 uno::Reference< drawing::XShapes > const & rShapes, bool bClosed, bool bTemporaryShape)
1237: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
1238 mbClosed( bClosed )
1239{
1240}
1241
1242// this is called from the parent group for each unparsed attribute in the attribute list
1244{
1245 switch (aIter.getToken())
1246 {
1248 case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX):
1249 maViewBox = aIter.toString();
1250 break;
1252 maPoints = aIter.toString();
1253 break;
1254 default:
1256 }
1257 return true;
1258}
1259
1261{
1262}
1263
1265 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1266{
1267 // Add, set Style and properties from base shape
1268 if(mbClosed)
1269 AddShape("com.sun.star.drawing.PolyPolygonShape");
1270 else
1271 AddShape("com.sun.star.drawing.PolyLineShape");
1272
1273 if( !mxShape.is() )
1274 return;
1275
1276 SetStyle();
1277 SetLayer();
1278
1279 // set local parameters on shape
1280 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1281 if(xPropSet.is())
1282 {
1283 // set polygon
1284 if(!maPoints.isEmpty() && !maViewBox.isEmpty())
1285 {
1286 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1287 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1288
1289 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1290 // sense to have the geometry content size different from object size
1291 if(maSize.Width != 0 && maSize.Height != 0)
1292 {
1293 aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1294 }
1295
1296 basegfx::B2DPolygon aPolygon;
1297
1299 {
1300 if(aPolygon.count())
1301 {
1302 const basegfx::B2DRange aSourceRange(
1303 aViewBox.GetX(), aViewBox.GetY(),
1304 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1305 const basegfx::B2DRange aTargetRange(
1306 aViewBox.GetX(), aViewBox.GetY(),
1307 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1308
1309 if(!aSourceRange.equal(aTargetRange))
1310 {
1311 aPolygon.transform(
1313 aSourceRange,
1314 aTargetRange));
1315 }
1316
1317 css::drawing::PointSequenceSequence aPointSequenceSequence;
1319 xPropSet->setPropertyValue("Geometry", Any(aPointSequenceSequence));
1320 // Size is now contained in the point coordinates, adapt maSize for
1321 // to use the correct transformation matrix in SetTransformation()
1322 maSize.Width = 1;
1323 maSize.Height = 1;
1324 }
1325 }
1326 }
1327 }
1328
1329 // set pos, size, shear and rotate and get copy of matrix
1331
1332 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1333}
1334
1335
1337 SvXMLImport& rImport,
1338 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1339 uno::Reference< drawing::XShapes > const & rShapes,
1340 bool bTemporaryShape)
1341: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape )
1342{
1343}
1344
1346{
1347}
1348
1349// this is called from the parent group for each unparsed attribute in the attribute list
1351{
1352 switch (aIter.getToken())
1353 {
1355 case XML_ELEMENT(SVG_COMPAT, XML_VIEWBOX):
1356 maViewBox = aIter.toString();
1357 break;
1358 case XML_ELEMENT(SVG, XML_D):
1359 case XML_ELEMENT(SVG_COMPAT, XML_D):
1360 maD = aIter.toString();
1361 break;
1362 default:
1364 }
1365 return true;
1366}
1367
1369 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1370{
1371 // create polygon shape
1372 if(maD.isEmpty())
1373 return;
1374
1375 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1376 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1377
1378 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1379 // sense to have the geometry content size different from object size
1380 if(maSize.Width != 0 && maSize.Height != 0)
1381 {
1382 aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1383 }
1384
1385 basegfx::B2DPolyPolygon aPolyPolygon;
1386
1387 if(!basegfx::utils::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), nullptr))
1388 return;
1389
1390 if(!aPolyPolygon.count())
1391 return;
1392
1393 const basegfx::B2DRange aSourceRange(
1394 aViewBox.GetX(), aViewBox.GetY(),
1395 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1396 const basegfx::B2DRange aTargetRange(
1397 aViewBox.GetX(), aViewBox.GetY(),
1398 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1399
1400 if(!aSourceRange.equal(aTargetRange))
1401 {
1402 aPolyPolygon.transform(
1404 aSourceRange,
1405 aTargetRange));
1406 }
1407
1408 // create shape
1409 OUString service;
1410
1411 if(aPolyPolygon.areControlPointsUsed())
1412 {
1413 if(aPolyPolygon.isClosed())
1414 {
1415 service = "com.sun.star.drawing.ClosedBezierShape";
1416 }
1417 else
1418 {
1419 service = "com.sun.star.drawing.OpenBezierShape";
1420 }
1421 }
1422 else
1423 {
1424 if(aPolyPolygon.isClosed())
1425 {
1426 service = "com.sun.star.drawing.PolyPolygonShape";
1427 }
1428 else
1429 {
1430 service = "com.sun.star.drawing.PolyLineShape";
1431 }
1432 }
1433
1434 // Add, set Style and properties from base shape
1435 AddShape(service);
1436
1437 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1438 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1439 // is used by the writer.
1440 if( !mxShape.is() )
1441 return;
1442
1443 SetStyle();
1444 SetLayer();
1445
1446 // set local parameters on shape
1447 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1448
1449 if(xPropSet.is())
1450 {
1451 uno::Any aAny;
1452
1453 // set polygon data
1454 if(aPolyPolygon.areControlPointsUsed())
1455 {
1456 drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1457
1459 aPolyPolygon,
1460 aSourcePolyPolygon);
1461 aAny <<= aSourcePolyPolygon;
1462 }
1463 else
1464 {
1465 drawing::PointSequenceSequence aSourcePolyPolygon;
1466
1468 aPolyPolygon,
1469 aSourcePolyPolygon);
1470 aAny <<= aSourcePolyPolygon;
1471 }
1472
1473 xPropSet->setPropertyValue("Geometry", aAny);
1474 // Size is now contained in the point coordinates, adapt maSize for
1475 // to use the correct transformation matrix in SetTransformation()
1476 maSize.Width = 1;
1477 maSize.Height = 1;
1478 }
1479
1480 // set pos, size, shear and rotate
1482
1483 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1484}
1485
1486
1488 SvXMLImport& rImport,
1489 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1490 uno::Reference< drawing::XShapes > const & rShapes)
1491: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ),
1492 mnRadius(0),
1493 maChainNextName("")
1494{
1495}
1496
1498{
1499}
1500
1501// this is called from the parent group for each unparsed attribute in the attribute list
1503{
1504 switch (aIter.getToken())
1505 {
1507 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1508 mnRadius, aIter.toView());
1509 break;
1511 maChainNextName = aIter.toString();
1512 break;
1513 default:
1515 }
1516 return true;
1517}
1518
1520 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1521{
1522 // create textbox shape
1523 bool bIsPresShape = false;
1524 bool bClearText = false;
1525
1526 OUString service;
1527
1528 if( isPresentationShape() )
1529 {
1530 // check if the current document supports presentation shapes
1531 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1532 {
1534 {
1535 // XmlShapeType::PresSubtitleShape
1536 service = "com.sun.star.presentation.SubtitleShape";
1537 }
1539 {
1540 // XmlShapeType::PresOutlinerShape
1541 service = "com.sun.star.presentation.OutlinerShape";
1542 }
1544 {
1545 // XmlShapeType::PresNotesShape
1546 service = "com.sun.star.presentation.NotesShape";
1547 }
1549 {
1550 // XmlShapeType::PresHeaderShape
1551 service = "com.sun.star.presentation.HeaderShape";
1552 bClearText = true;
1553 }
1555 {
1556 // XmlShapeType::PresFooterShape
1557 service = "com.sun.star.presentation.FooterShape";
1558 bClearText = true;
1559 }
1561 {
1562 // XmlShapeType::PresSlideNumberShape
1563 service = "com.sun.star.presentation.SlideNumberShape";
1564 bClearText = true;
1565 }
1567 {
1568 // XmlShapeType::PresDateTimeShape
1569 service = "com.sun.star.presentation.DateTimeShape";
1570 bClearText = true;
1571 }
1572 else // IsXMLToken( maPresentationClass, XML_TITLE ) )
1573 {
1574 // XmlShapeType::PresTitleTextShape
1575 service = "com.sun.star.presentation.TitleTextShape";
1576 }
1577 bIsPresShape = true;
1578 }
1579 }
1580
1581 if( service.isEmpty() )
1582 {
1583 // normal text shape
1584 service = "com.sun.star.drawing.TextShape";
1585 }
1586
1587 // Add, set Style and properties from base shape
1588 AddShape(service);
1589
1590 if( !mxShape.is() )
1591 return;
1592
1593 SetStyle();
1594 SetLayer();
1595
1596 if(bIsPresShape)
1597 {
1598 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
1599 if(xProps.is())
1600 {
1601 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
1602 if( xPropsInfo.is() )
1603 {
1604 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
1605 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
1606
1607 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
1608 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
1609 }
1610 }
1611 }
1612
1613 if( bClearText )
1614 {
1615 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1616 xText->setString( "" );
1617 }
1618
1619 // set parameters on shape
1620//A AW->CL: Eventually You need to strip scale and translate from the transformation
1621//A to reach the same goal again.
1622//A if(!bIsPresShape || mbIsUserTransformed)
1623//A {
1624//A // set pos and size on shape, this should remove binding
1625//A // to pres object on masterpage
1626//A SetSizeAndPosition();
1627//A }
1628
1629 // set pos, size, shear and rotate
1631
1632 if(mnRadius)
1633 {
1634 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1635 if(xPropSet.is())
1636 {
1637 try
1638 {
1639 xPropSet->setPropertyValue("CornerRadius", uno::Any( mnRadius ) );
1640 }
1641 catch(const uno::Exception&)
1642 {
1643 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
1644 }
1645 }
1646 }
1647
1648 if(!maChainNextName.isEmpty())
1649 {
1650 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1651 if(xPropSet.is())
1652 {
1653 try
1654 {
1655 xPropSet->setPropertyValue("TextChainNextName",
1657 }
1658 catch(const uno::Exception&)
1659 {
1660 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting name of next chain link");
1661 }
1662 }
1663 }
1664
1665 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1666}
1667
1668
1670 SvXMLImport& rImport,
1671 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1672 uno::Reference< drawing::XShapes > const & rShapes,
1673 bool bTemporaryShape)
1674: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape )
1675{
1676}
1677
1679{
1680}
1681
1682// this is called from the parent group for each unparsed attribute in the attribute list
1684{
1685 switch (aIter.getToken())
1686 {
1688 maFormId = aIter.toString();
1689 break;
1690 default:
1692 }
1693 return true;
1694}
1695
1697 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1698{
1699 // create Control shape
1700 // add, set style and properties from base shape
1701 AddShape("com.sun.star.drawing.ControlShape");
1702 if( !mxShape.is() )
1703 return;
1704
1705 SAL_WARN_IF( !!maFormId.isEmpty(), "xmloff", "draw:control without a form:id attribute!" );
1706 if( !maFormId.isEmpty() )
1707 {
1708 if( GetImport().IsFormsSupported() )
1709 {
1710 uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
1711 if( xControlModel.is() )
1712 {
1713 uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
1714 if( xControl.is() )
1715 xControl->setControl( xControlModel );
1716
1717 }
1718 }
1719 }
1720
1721 SetStyle();
1722 SetLayer();
1723
1724 // set pos, size, shear and rotate
1726
1727 SdXMLShapeContext::startFastElement(nElement, xAttrList);
1728}
1729
1730
1732 SvXMLImport& rImport,
1733 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
1734 uno::Reference< drawing::XShapes > const & rShapes,
1735 bool bTemporaryShape)
1736: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
1737 maStart(0,0),
1738 maEnd(1,1),
1739 mnType( drawing::ConnectorType_STANDARD ),
1740 mnStartGlueId(-1),
1741 mnEndGlueId(-1),
1742 mnDelta1(0),
1743 mnDelta2(0),
1744 mnDelta3(0)
1745{
1746}
1747
1749{
1750}
1751
1752bool SvXMLImport::needFixPositionAfterZ() const
1753{
1754 bool bWrongPositionAfterZ( false );
1755 sal_Int32 nUPD( 0 );
1756 sal_Int32 nBuildId( 0 );
1757 if ( getBuildIds( nUPD, nBuildId ) && // test OOo and old versions of LibO and AOO
1758 ( ( ( nUPD == 641 ) || ( nUPD == 645 ) || ( nUPD == 680 ) || ( nUPD == 300 ) ||
1759 ( nUPD == 310 ) || ( nUPD == 320 ) || ( nUPD == 330 ) || ( nUPD == 340 ) ||
1760 ( nUPD == 350 && nBuildId < 202 ) )
1761 || (getGeneratorVersion() == SvXMLImport::AOO_40x))) // test if AOO 4.0.x
1762 // apparently bug was fixed in AOO by i#123433 f15874d8f976f3874bdbcb53429eeefa65c28841
1763 {
1764 bWrongPositionAfterZ = true;
1765 }
1766 return bWrongPositionAfterZ;
1767}
1768
1769
1770// this is called from the parent group for each unparsed attribute in the attribute list
1772{
1773 switch( aIter.getToken() )
1774 {
1776 maStartShapeId = aIter.toString();
1777 break;
1779 mnStartGlueId = aIter.toInt32();
1780 break;
1782 maEndShapeId = aIter.toString();
1783 break;
1785 mnEndGlueId = aIter.toInt32();
1786 break;
1788 {
1789 OUString sValue = aIter.toString();
1790 SvXMLTokenEnumerator aTokenEnum( sValue );
1791 std::u16string_view aToken;
1792 if( aTokenEnum.getNextToken( aToken ) )
1793 {
1794 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1795 mnDelta1, aToken);
1796 if( aTokenEnum.getNextToken( aToken ) )
1797 {
1798 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1799 mnDelta2, aToken);
1800 if( aTokenEnum.getNextToken( aToken ) )
1801 {
1802 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1803 mnDelta3, aToken);
1804 }
1805 }
1806 }
1807 break;
1808 }
1809 case XML_ELEMENT(DRAW, XML_TYPE):
1810 {
1812 break;
1813 }
1814 // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these
1816 mnTransform.SetString(aIter.toString(), GetImport().GetMM100UnitConverter());
1817 break;
1818
1819 case XML_ELEMENT(SVG, XML_X1):
1820 case XML_ELEMENT(SVG_COMPAT, XML_X1):
1821 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1822 maStart.X, aIter.toView());
1823 break;
1824 case XML_ELEMENT(SVG, XML_Y1):
1825 case XML_ELEMENT(SVG_COMPAT, XML_Y1):
1826 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1827 maStart.Y, aIter.toView());
1828 break;
1829 case XML_ELEMENT(SVG, XML_X2):
1830 case XML_ELEMENT(SVG_COMPAT, XML_X2):
1831 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1832 maEnd.X, aIter.toView());
1833 break;
1834 case XML_ELEMENT(SVG, XML_Y2):
1835 case XML_ELEMENT(SVG_COMPAT, XML_Y2):
1836 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1837 maEnd.Y, aIter.toView());
1838 break;
1839 case XML_ELEMENT(SVG, XML_D):
1840 case XML_ELEMENT(SVG_COMPAT, XML_D):
1841 {
1842 basegfx::B2DPolyPolygon aPolyPolygon;
1843
1844 if(basegfx::utils::importFromSvgD(aPolyPolygon, aIter.toString(), GetImport().needFixPositionAfterZ(), nullptr))
1845 {
1846 if(aPolyPolygon.count())
1847 {
1848 drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1849
1851 aPolyPolygon,
1852 aSourcePolyPolygon);
1853 maPath <<= aSourcePolyPolygon;
1854 }
1855 }
1856 break;
1857 }
1858 default:
1860 }
1861 return true;
1862}
1863
1865 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1866{
1867 // For security reasons, do not add empty connectors. There may have been an error in EA2
1868 // that created empty, far set off connectors (e.g. 63 meters below top of document). This
1869 // is not guaranteed, but it's definitely safe to not add empty connectors.
1870 bool bDoAdd(true);
1871
1872 if( maStartShapeId.isEmpty()
1873 && maEndShapeId.isEmpty()
1874 && maStart.X == maEnd.X
1875 && maStart.Y == maEnd.Y
1876 && 0 == mnDelta1
1877 && 0 == mnDelta2
1878 && 0 == mnDelta3
1879 )
1880 {
1881 bDoAdd = false;
1882 }
1883
1884 if(!bDoAdd)
1885 return;
1886
1887 // create Connector shape
1888 // add, set style and properties from base shape
1889 AddShape("com.sun.star.drawing.ConnectorShape");
1890 if(!mxShape.is())
1891 return;
1892
1893 // #121965# if draw:transform is used, apply directly to the start
1894 // and end positions before using these
1896 {
1897 // transformation is used, apply to object.
1900
1901 if(!aMat.isIdentity())
1902 {
1903 basegfx::B2DPoint aStart(maStart.X, maStart.Y);
1904 basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y);
1905
1906 aStart = aMat * aStart;
1907 aEnd = aMat * aEnd;
1908
1909 maStart.X = basegfx::fround(aStart.getX());
1910 maStart.Y = basegfx::fround(aStart.getY());
1911 maEnd.X = basegfx::fround(aEnd.getX());
1912 maEnd.Y = basegfx::fround(aEnd.getY());
1913 }
1914 }
1915
1916 // add connection ids
1917 if( !maStartShapeId.isEmpty() )
1918 GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId );
1919 if( !maEndShapeId.isEmpty() )
1920 GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId );
1921
1922 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
1923 if( xProps.is() )
1924 {
1925 xProps->setPropertyValue("StartPosition", Any(maStart));
1926 xProps->setPropertyValue("EndPosition", Any(maEnd) );
1927 xProps->setPropertyValue("EdgeKind", Any(mnType) );
1928 xProps->setPropertyValue("EdgeLine1Delta", Any(mnDelta1) );
1929 xProps->setPropertyValue("EdgeLine2Delta", Any(mnDelta2) );
1930 xProps->setPropertyValue("EdgeLine3Delta", Any(mnDelta3) );
1931 }
1932 SetStyle();
1933 SetLayer();
1934
1935 if ( maPath.hasValue() )
1936 {
1937 // #i115492#
1938 // Ignore svg:d attribute for text documents created by OpenOffice.org
1939 // versions before OOo 3.3, because these OOo versions are storing
1940 // svg:d values not using the correct unit.
1941 bool bApplySVGD( true );
1942 if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
1943 {
1944 sal_Int32 nUPD( 0 );
1945 sal_Int32 nBuild( 0 );
1946 const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
1947 if ( GetImport().IsTextDocInOOoFileFormat() ||
1948 ( bBuildIdFound &&
1949 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1950 ( nUPD == 680 ) || // OOo 2.x
1951 ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1
1952 ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1
1953 ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1
1954 {
1955 bApplySVGD = false;
1956 }
1957 }
1958
1959 if ( bApplySVGD )
1960 {
1961 // tdf#83360 use path data only when redundant data of start and end point coordinates of
1962 // path start/end and connector start/end is equal. This is to avoid using erraneous
1963 // or inconsistent path data at import of foreign formats. Office itself always
1964 // writes out a consistent data set. Not using it when there is inconsistency
1965 // is okay since the path data is redundant, buffered data just to avoid recalculation
1966 // of the connector's layout at load time, no real information would be lost.
1967 // A 'connected' end has prio to direct coordinate data in Start/EndPosition
1968 // to the path data (which should have the start/end redundant in the path)
1969 const drawing::PolyPolygonBezierCoords* pSource = static_cast< const drawing::PolyPolygonBezierCoords* >(maPath.getValue());
1970 const sal_uInt32 nSequenceCount(pSource->Coordinates.getLength());
1971 bool bStartEqual(false);
1972 bool bEndEqual(false);
1973
1974 if(nSequenceCount)
1975 {
1976 const drawing::PointSequence& rStartSeq = pSource->Coordinates[0];
1977 const sal_uInt32 nStartCount = rStartSeq.getLength();
1978
1979 if(nStartCount)
1980 {
1981 const awt::Point& rStartPoint = rStartSeq.getConstArray()[0];
1982
1983 if(rStartPoint.X == maStart.X && rStartPoint.Y == maStart.Y)
1984 {
1985 bStartEqual = true;
1986 }
1987 }
1988
1989 const drawing::PointSequence& rEndSeq = pSource->Coordinates[nSequenceCount - 1];
1990 const sal_uInt32 nEndCount = rEndSeq.getLength();
1991
1992 if(nEndCount)
1993 {
1994 const awt::Point& rEndPoint = rEndSeq.getConstArray()[nEndCount - 1];
1995
1996 if(rEndPoint.X == maEnd.X && rEndPoint.Y == maEnd.Y)
1997 {
1998 bEndEqual = true;
1999 }
2000 }
2001 }
2002
2003 if(!bStartEqual || !bEndEqual)
2004 {
2005 bApplySVGD = false;
2006 }
2007 }
2008
2009 if ( bApplySVGD )
2010 {
2012 xProps->setPropertyValue("PolyPolygonBezier", maPath);
2013 }
2014 }
2015
2016 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2017}
2018
2019
2021 SvXMLImport& rImport,
2022 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2023 uno::Reference< drawing::XShapes > const & rShapes,
2024 bool bTemporaryShape)
2025: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
2026 maStart(0,0),
2027 maEnd(1,1)
2028{
2029}
2030
2032{
2033}
2034
2035// this is called from the parent group for each unparsed attribute in the attribute list
2037{
2038 switch( aIter.getToken() )
2039 {
2040 case XML_ELEMENT(SVG, XML_X1):
2041 case XML_ELEMENT(SVG_COMPAT, XML_X1):
2042 {
2043 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2044 maStart.X, aIter.toView());
2045 break;
2046 }
2047 case XML_ELEMENT(SVG, XML_Y1):
2048 case XML_ELEMENT(SVG_COMPAT, XML_Y1):
2049 {
2050 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2051 maStart.Y, aIter.toView());
2052 break;
2053 }
2054 case XML_ELEMENT(SVG, XML_X2):
2055 case XML_ELEMENT(SVG_COMPAT, XML_X2):
2056 {
2057 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2058 maEnd.X, aIter.toView());
2059 break;
2060 }
2061 case XML_ELEMENT(SVG, XML_Y2):
2062 case XML_ELEMENT(SVG_COMPAT, XML_Y2):
2063 {
2064 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2065 maEnd.Y, aIter.toView());
2066 break;
2067 }
2068 default:
2070 }
2071 return true;
2072}
2073
2075 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2076{
2077 // create Measure shape
2078 // add, set style and properties from base shape
2079 AddShape("com.sun.star.drawing.MeasureShape");
2080 if(!mxShape.is())
2081 return;
2082
2083 SetStyle();
2084 SetLayer();
2085
2086 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2087 if( xProps.is() )
2088 {
2089 xProps->setPropertyValue("StartPosition", Any(maStart));
2090 xProps->setPropertyValue("EndPosition", Any(maEnd) );
2091 }
2092
2093 // delete pre created fields
2094 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2095 if( xText.is() )
2096 {
2097 xText->setString( " " );
2098 }
2099
2100 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2101}
2102
2104{
2105 do
2106 {
2107 // delete pre created fields
2108 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2109 if( !xText.is() )
2110 break;
2111
2112 uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() );
2113 if( !xCursor.is() )
2114 break;
2115
2116 xCursor->collapseToStart();
2117 xCursor->goRight( 1, true );
2118 xCursor->setString( "" );
2119 }
2120 while(false);
2121
2123}
2124
2125
2127 SvXMLImport& rImport,
2128 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2129 uno::Reference< drawing::XShapes > const & rShapes,
2130 bool bTemporaryShape)
2131: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0)
2132{
2134}
2135
2137{
2138}
2139
2140// this is called from the parent group for each unparsed attribute in the attribute list
2142{
2143 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_PAGE_NUMBER) )
2144 mnPageNumber = aIter.toInt32();
2145 else
2147 return true;
2148}
2149
2151 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2152{
2153 // create Page shape
2154 // add, set style and properties from base shape
2155
2156 // #86163# take into account which type of PageShape needs to
2157 // be constructed. It's a pres shape if presentation:XML_CLASS == XML_PAGE.
2158 bool bIsPresentation = !maPresentationClass.isEmpty() &&
2159 GetImport().GetShapeImport()->IsPresentationShapesSupported();
2160
2161 uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY );
2162 const bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService("com.sun.star.presentation.HandoutMasterPage");
2163
2164 if( bIsOnHandoutPage )
2165 {
2166 AddShape("com.sun.star.presentation.HandoutShape");
2167 }
2168 else
2169 {
2170 if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PAGE ) )
2171 {
2172 bIsPresentation = false;
2173 }
2174
2175 if(bIsPresentation)
2176 {
2177 AddShape("com.sun.star.presentation.PageShape");
2178 }
2179 else
2180 {
2181 AddShape("com.sun.star.drawing.PageShape");
2182 }
2183 }
2184
2185 if(!mxShape.is())
2186 return;
2187
2188 SetStyle();
2189 SetLayer();
2190
2191 // set pos, size, shear and rotate
2193
2194 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2195 if(xPropSet.is())
2196 {
2197 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2198 static constexpr OUStringLiteral aPageNumberStr(u"PageNumber");
2199 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2200 xPropSet->setPropertyValue(aPageNumberStr, uno::Any( mnPageNumber ));
2201 }
2202
2203 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2204}
2205
2206
2208 SvXMLImport& rImport,
2209 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2210 uno::Reference< drawing::XShapes > const & rShapes,
2211 bool bTemporaryShape)
2212: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
2213 // #86616# for correct edge rounding import mnRadius needs to be initialized
2214 mnRadius( 0 )
2215{
2216}
2217
2219{
2220}
2221
2223 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2224{
2225 // create Caption shape
2226 // add, set style and properties from base shape
2227 AddShape("com.sun.star.drawing.CaptionShape");
2228 if( !mxShape.is() )
2229 return;
2230
2231 SetStyle();
2232 SetLayer();
2233
2234 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2235
2236 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2237 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2238 // is the default setting, so the top left reference point that is used by the caption point is
2239 // no longer correct) There are two ways to solve this problem, temporarily disabling the
2240 // autogrowwidth as we are doing here or to apply the CaptionPoint after setting text
2241 bool bIsAutoGrowWidth = false;
2242 if ( xProps.is() )
2243 {
2244 uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") );
2245 aAny >>= bIsAutoGrowWidth;
2246
2247 if ( bIsAutoGrowWidth )
2248 xProps->setPropertyValue("TextAutoGrowWidth", uno::Any( false ) );
2249 }
2250
2251 // set pos, size, shear and rotate
2253 if( xProps.is() )
2254 xProps->setPropertyValue("CaptionPoint", uno::Any( maCaptionPoint ) );
2255
2256 if ( bIsAutoGrowWidth )
2257 xProps->setPropertyValue("TextAutoGrowWidth", uno::Any( true ) );
2258
2259 if(mnRadius)
2260 {
2261 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2262 if(xPropSet.is())
2263 {
2264 try
2265 {
2266 xPropSet->setPropertyValue("CornerRadius", uno::Any( mnRadius ) );
2267 }
2268 catch(const uno::Exception&)
2269 {
2270 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
2271 }
2272 }
2273 }
2274
2275 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2276}
2277
2278// this is called from the parent group for each unparsed attribute in the attribute list
2280{
2281 switch (aIter.getToken())
2282 {
2284 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2285 maCaptionPoint.X, aIter.toView());
2286 break;
2288 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2289 maCaptionPoint.Y, aIter.toView());
2290 break;
2292 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2293 mnRadius, aIter.toView());
2294 break;
2295 default:
2297 }
2298 return true;
2299}
2300
2301
2303 SvXMLImport& rImport,
2304 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2305 uno::Reference< drawing::XShapes > const & rShapes)
2306: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
2307{
2308}
2309
2310// this is called from the parent group for each unparsed attribute in the attribute list
2312{
2313 if( aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF) )
2314 maURL = aIter.toString();
2315 else
2317 return true;
2318}
2319
2321 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2322{
2323 // create graphic object shape
2324 OUString service;
2325
2326 if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2327 {
2328 service = "com.sun.star.presentation.GraphicObjectShape";
2329 }
2330 else
2331 {
2332 service = "com.sun.star.drawing.GraphicObjectShape";
2333 }
2334
2335 AddShape(service);
2336
2337 if(!mxShape.is())
2338 return;
2339
2340 SetStyle();
2341 SetLayer();
2342
2343 uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
2344 if(xPropset.is())
2345 {
2346 // since OOo 1.x had no line or fill style for graphics, but may create
2347 // documents with them, we have to override them here
2348 sal_Int32 nUPD, nBuildId;
2349 if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try
2350 {
2351 xPropset->setPropertyValue("FillStyle", Any( FillStyle_NONE ) );
2352 xPropset->setPropertyValue("LineStyle", Any( LineStyle_NONE ) );
2353 }
2354 catch(const Exception&)
2355 {
2356 }
2357
2358 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
2359 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2360 xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::Any( mbIsPlaceholder ) );
2361
2362 if( !mbIsPlaceholder )
2363 {
2364 if( !maURL.isEmpty() )
2365 {
2366 uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maURL);
2367 if (xGraphic.is())
2368 {
2369 xPropset->setPropertyValue("Graphic", uno::Any(xGraphic));
2370 }
2371 }
2372 }
2373 }
2374
2376 {
2377 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2378 if(xProps.is())
2379 {
2380 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2381 if( xPropsInfo.is() )
2382 {
2383 if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2384 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2385 }
2386 }
2387 }
2388
2389 // set pos, size, shear and rotate
2391
2392 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2393}
2394
2396{
2397 if (mxBase64Stream.is())
2398 {
2399 uno::Reference<graphic::XGraphic> xGraphic(GetImport().loadGraphicFromBase64(mxBase64Stream));
2400 if (xGraphic.is())
2401 {
2402 uno::Reference<beans::XPropertySet> xProperties(mxShape, uno::UNO_QUERY);
2403 if (xProperties.is())
2404 {
2405 xProperties->setPropertyValue("Graphic", uno::Any(xGraphic));
2406 }
2407 }
2408 }
2409
2411}
2412
2413css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLGraphicObjectShapeContext::createFastChildContext(
2414 sal_Int32 nElement,
2415 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2416{
2417 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
2418
2419 if( nElement == XML_ELEMENT(OFFICE, XML_BINARY_DATA) )
2420 {
2421 if( maURL.isEmpty() && !mxBase64Stream.is() )
2422 {
2423 mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
2424 if( mxBase64Stream.is() )
2425 xContext = new XMLBase64ImportContext( GetImport(),
2427 }
2428 }
2429
2430 // delegate to parent class if no context could be created
2431 if (!xContext)
2433 xAttrList);
2434
2435 if (!xContext)
2436 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2437
2438 return xContext;
2439}
2440
2442{
2443
2444}
2445
2446
2448 SvXMLImport& rImport,
2449 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2450 uno::Reference< drawing::XShapes > const & rShapes,
2451 bool bTemporaryShape)
2452: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape )
2453{
2454}
2455
2457 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2458{
2459 const bool bIsPresentation = isPresentationShape();
2460
2461 AddShape(
2462 bIsPresentation
2463 ? OUString("com.sun.star.presentation.ChartShape")
2464 : OUString("com.sun.star.drawing.OLE2Shape"));
2465
2466 if(!mxShape.is())
2467 return;
2468
2469 SetStyle();
2470 SetLayer();
2471
2472 if( !mbIsPlaceholder )
2473 {
2474 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2475 if(xProps.is())
2476 {
2477 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2478 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2479 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2480
2481 uno::Any aAny;
2482
2483 xProps->setPropertyValue("CLSID", Any(OUString("12DCAE26-281F-416F-a234-c3086127382e")) );
2484
2485 aAny = xProps->getPropertyValue("Model");
2486 uno::Reference< frame::XModel > xChartModel;
2487 if( aAny >>= xChartModel )
2488 {
2489#if !ENABLE_WASM_STRIP_CHART
2490 // WASM_CHART change
2491 // TODO: Maybe use SdXMLGraphicObjectShapeContext completely instead
2492 // or try to create as mbIsPlaceholder object adding a Chart visualization
2493 // that should be available somehow
2494 mxChartContext.set( GetImport().GetChartImport()->CreateChartContext( GetImport(), xChartModel ) );
2495#endif
2496 }
2497 }
2498 }
2499
2501 {
2502 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2503 if(xProps.is())
2504 {
2505 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2506 if( xPropsInfo.is() )
2507 {
2508 if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2509 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2510 }
2511 }
2512 }
2513
2514 // set pos, size, shear and rotate
2516
2517 SdXMLShapeContext::startFastElement(nElement, xAttrList);
2518
2519 if( mxChartContext.is() )
2520 mxChartContext->startFastElement( nElement, xAttrList );
2521}
2522
2524{
2525 if( mxChartContext.is() )
2526 mxChartContext->endFastElement(nElement);
2527
2529}
2530
2531void SdXMLChartShapeContext::characters( const OUString& rChars )
2532{
2533 if( mxChartContext.is() )
2534 mxChartContext->characters( rChars );
2535}
2536
2537css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLChartShapeContext::createFastChildContext(
2538 sal_Int32 nElement,
2539 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2540{
2541 if( mxChartContext.is() )
2542 return mxChartContext->createFastChildContext( nElement, xAttrList );
2543
2544 return nullptr;
2545}
2546
2547
2549 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2550 css::uno::Reference< css::drawing::XShapes > const & rShapes)
2551: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
2552{
2553}
2554
2556{
2557}
2558
2560 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
2561{
2562 // #96717# in theorie, if we don't have a URL we shouldn't even
2563 // export this OLE shape. But practically it's too risky right now
2564 // to change this so we better dispose this on load
2565 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2566 // return;
2567
2568 // #100592# this BugFix prevents that a shape is created. CL
2569 // is thinking about an alternative.
2570 // #i13140# Check for more than empty string in maHref, there are
2571 // other possibilities that maHref results in empty container
2572 // storage names
2573 if( !(GetImport().getImportFlags() & SvXMLImportFlags::EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2574 return;
2575
2576 OUString service("com.sun.star.drawing.OLE2Shape");
2577
2578 bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2579
2580 if( bIsPresShape )
2581 {
2583 {
2584 service = "com.sun.star.presentation.ChartShape";
2585 }
2587 {
2588 service = "com.sun.star.presentation.CalcShape";
2589 }
2591 {
2592 service = "com.sun.star.presentation.OLE2Shape";
2593 }
2594 }
2595
2596 AddShape(service);
2597
2598 if( !mxShape.is() )
2599 return;
2600
2601 SetLayer();
2602
2603 if(bIsPresShape)
2604 {
2605 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2606 if(xProps.is())
2607 {
2608 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2609 if( xPropsInfo.is() )
2610 {
2611 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2612 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2613
2614 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2615 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2616 }
2617 }
2618 }
2619
2620 if( !mbIsPlaceholder && !maHref.isEmpty() )
2621 {
2622 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2623
2624 if( xProps.is() )
2625 {
2626 OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
2627
2628 if ( GetImport().IsPackageURL( maHref ) )
2629 {
2630 static constexpr OUStringLiteral sURL( u"vnd.sun.star.EmbeddedObject:" );
2631
2632 if ( aPersistName.startsWith( sURL ) )
2633 aPersistName = aPersistName.copy( sURL.getLength() );
2634
2635 xProps->setPropertyValue("PersistName",
2636 uno::Any( aPersistName ) );
2637 }
2638 else
2639 {
2640 // this is OOo link object
2641 xProps->setPropertyValue("LinkURL",
2642 uno::Any( aPersistName ) );
2643 }
2644 }
2645 }
2646
2647 // set pos, size, shear and rotate
2649
2650 SetStyle();
2651
2652 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2653}
2654
2656{
2657 if (GetImport().isGeneratorVersionOlderThan(
2658 SvXMLImport::OOo_34x, SvXMLImport::LO_41x)) // < LO 4.0
2659 {
2660 // #i118485#
2661 // If it's an old file from us written before OOo3.4, we need to correct
2662 // FillStyle and LineStyle for OLE2 objects. The error was that the old paint
2663 // implementations just ignored added fill/linestyles completely, thus
2664 // those objects need to be corrected to not show blue and hairline which
2665 // always was the default, but would be shown now
2666 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2667
2668 if( xProps.is() )
2669 {
2670 xProps->setPropertyValue("FillStyle", uno::Any(drawing::FillStyle_NONE));
2671 xProps->setPropertyValue("LineStyle", uno::Any(drawing::LineStyle_NONE));
2672 }
2673 }
2674
2675 if( mxBase64Stream.is() )
2676 {
2677 OUString aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2678 static constexpr OUStringLiteral sURL( u"vnd.sun.star.EmbeddedObject:" );
2679
2680 aPersistName = aPersistName.copy( sURL.getLength() );
2681
2682 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2683 if( xProps.is() )
2684 xProps->setPropertyValue("PersistName", uno::Any( aPersistName ) );
2685 }
2686
2688}
2689
2690// this is called from the parent group for each unparsed attribute in the attribute list
2692{
2693 switch( aIter.getToken() )
2694 {
2696 maCLSID = aIter.toString();
2697 break;
2698 case XML_ELEMENT(XLINK, XML_HREF):
2699 maHref = aIter.toString();
2700 break;
2701 default:
2703 }
2704 return true;
2705}
2706
2707css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLObjectShapeContext::createFastChildContext(
2708 sal_Int32 nElement,
2709 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2710{
2711 if(nElement == XML_ELEMENT(OFFICE, XML_BINARY_DATA))
2712 {
2713 mxBase64Stream = GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2714 if( mxBase64Stream.is() )
2716 }
2717 else if( nElement == XML_ELEMENT(OFFICE, XML_DOCUMENT) ||
2718 nElement == XML_ELEMENT(MATH, XML_MATH) )
2719 {
2721 new XMLEmbeddedObjectImportContext(GetImport(), nElement, xAttrList));
2722 maCLSID = xEContext->GetFilterCLSID();
2723 if( !maCLSID.isEmpty() )
2724 {
2725 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2726 if( xPropSet.is() )
2727 {
2728 xPropSet->setPropertyValue("CLSID", uno::Any( maCLSID ) );
2729
2730 uno::Reference< lang::XComponent > xComp;
2731 xPropSet->getPropertyValue("Model") >>= xComp;
2732 SAL_WARN_IF( !xComp.is(), "xmloff", "no xModel for own OLE format" );
2733 xEContext->SetComponent(xComp);
2734 }
2735 }
2736 return xEContext;
2737 }
2738
2739 // delegate to parent class if no context could be created
2740 return SdXMLShapeContext::createFastChildContext(nElement, xAttrList);
2741}
2742
2744 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2745 css::uno::Reference< css::drawing::XShapes > const & rShapes)
2746: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ),
2747 mbIsScript( false )
2748{
2749}
2750
2752{
2753}
2754
2756 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
2757{
2758 AddShape("com.sun.star.drawing.AppletShape");
2759
2760 if( mxShape.is() )
2761 {
2762 SetLayer();
2763
2764 // set pos, size, shear and rotate
2766 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2767 }
2768}
2769
2770// this is called from the parent group for each unparsed attribute in the attribute list
2772{
2773 switch( aIter.getToken() )
2774 {
2776 maAppletName = aIter.toString();
2777 break;
2778 case XML_ELEMENT(DRAW, XML_CODE):
2779 maAppletCode = aIter.toString();
2780 break;
2782 mbIsScript = IsXMLToken( aIter, XML_TRUE );
2783 break;
2784 case XML_ELEMENT(XLINK, XML_HREF):
2785 maHref = GetImport().GetAbsoluteReference(aIter.toString());
2786 break;
2787 default:
2789 }
2790 return true;
2791}
2792
2794{
2795 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2796 if( xProps.is() )
2797 {
2798 if ( maSize.Width && maSize.Height )
2799 {
2800 // the visual area for applet must be set on loading
2801 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
2802 xProps->setPropertyValue("VisibleArea", Any(aRect) );
2803 }
2804
2805 if( maParams.hasElements() )
2806 {
2807 xProps->setPropertyValue("AppletCommands", Any(maParams) );
2808 }
2809
2810 if( !maHref.isEmpty() )
2811 {
2812 xProps->setPropertyValue("AppletCodeBase", Any(maHref) );
2813 }
2814
2815 if( !maAppletName.isEmpty() )
2816 {
2817 xProps->setPropertyValue("AppletName", Any(maAppletName) );
2818 }
2819
2820 if( mbIsScript )
2821 {
2822 xProps->setPropertyValue("AppletIsScript", Any(mbIsScript) );
2823
2824 }
2825
2826 if( !maAppletCode.isEmpty() )
2827 {
2828 xProps->setPropertyValue("AppletCode", Any(maAppletCode) );
2829 }
2830
2831 xProps->setPropertyValue("AppletDocBase", Any(GetImport().GetDocumentBase()) );
2832
2833 SetThumbnail();
2834 }
2835
2837}
2838
2839css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLAppletShapeContext::createFastChildContext(
2840 sal_Int32 nElement,
2841 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2842{
2843 if( nElement == XML_ELEMENT(DRAW, XML_PARAM) )
2844 {
2845 OUString aParamName, aParamValue;
2846 // now parse the attribute list and look for draw:name and draw:value
2847 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
2848 {
2849 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAME) )
2850 aParamName = aIter.toString();
2851 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_VALUE) )
2852 aParamValue = aIter.toString();
2853 }
2854
2855 if( !aParamName.isEmpty() )
2856 {
2857 sal_Int32 nIndex = maParams.getLength();
2858 maParams.realloc( nIndex + 1 );
2859 auto pParams = maParams.getArray();
2860 pParams[nIndex].Name = aParamName;
2861 pParams[nIndex].Handle = -1;
2862 pParams[nIndex].Value <<= aParamValue;
2863 pParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
2864 }
2865
2866 return new SvXMLImportContext( GetImport() );
2867 }
2868
2869 return SdXMLShapeContext::createFastChildContext( nElement, xAttrList );
2870}
2871
2872
2874 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
2875 css::uno::Reference< css::drawing::XShapes > const & rShapes) :
2876SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ ),
2877mbMedia( false )
2878{
2879}
2880
2882{
2883}
2884
2886 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
2887{
2888
2889 // watch for MimeType attribute to see if we have a media object
2890 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
2891 {
2892 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_MIME_TYPE) )
2893 {
2894 if (::comphelper::IsMediaMimeType(aIter.toView()))
2895 mbMedia = true;
2896 // leave this loop
2897 break;
2898 }
2899 }
2900
2901 OUString service;
2902
2903 bool bIsPresShape = false;
2904
2905 if( mbMedia )
2906 {
2907 service = "com.sun.star.drawing.MediaShape";
2908
2909 bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2910 if( bIsPresShape )
2911 {
2913 {
2914 service = "com.sun.star.presentation.MediaShape";
2915 }
2916 }
2917 }
2918 else
2919 service = "com.sun.star.drawing.PluginShape";
2920
2921 AddShape(service);
2922
2923 if( !mxShape.is() )
2924 return;
2925
2926 if (mbMedia)
2927 {
2928 // The media may have a crop, apply it.
2929 SetStyle(/*bSupportsStyle=*/false);
2930 }
2931
2932 SetLayer();
2933
2934 if(bIsPresShape)
2935 {
2936 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2937 if(xProps.is())
2938 {
2939 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2940 if( xPropsInfo.is() )
2941 {
2942 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2943 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2944
2945 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2946 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2947 }
2948 }
2949 }
2950
2951 // set pos, size, shear and rotate
2953 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2954}
2955
2956static OUString
2957lcl_GetMediaReference(SvXMLImport const& rImport, OUString const& rURL)
2958{
2959 if (rImport.IsPackageURL(rURL))
2960 {
2961 return "vnd.sun.star.Package:" + rURL;
2962 }
2963 else
2964 {
2965 return rImport.GetAbsoluteReference(rURL);
2966 }
2967}
2968
2969// this is called from the parent group for each unparsed attribute in the attribute list
2971{
2972 switch( aIter.getToken() )
2973 {
2975 maMimeType = aIter.toString();
2976 break;
2977 case XML_ELEMENT(XLINK, XML_HREF):
2979 break;
2980 default:
2982 }
2983 return true;
2984}
2985
2987{
2988 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2989
2990 if( xProps.is() )
2991 {
2992 if ( maSize.Width && maSize.Height )
2993 {
2994 static constexpr OUStringLiteral sVisibleArea( u"VisibleArea" );
2995 uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() );
2996 if ( !aXPropSetInfo.is() || aXPropSetInfo->hasPropertyByName( sVisibleArea ) )
2997 {
2998 // the visual area for a plugin must be set on loading
2999 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3000 xProps->setPropertyValue( sVisibleArea, Any(aRect) );
3001 }
3002 }
3003
3004 if( !mbMedia )
3005 {
3006 // in case we have a plugin object
3007 if( maParams.hasElements() )
3008 {
3009 xProps->setPropertyValue("PluginCommands", Any(maParams) );
3010 }
3011
3012 if( !maMimeType.isEmpty() )
3013 {
3014 xProps->setPropertyValue("PluginMimeType", Any(maMimeType) );
3015 }
3016
3017 if( !maHref.isEmpty() )
3018 {
3019 xProps->setPropertyValue("PluginURL", Any(maHref) );
3020 }
3021 }
3022 else
3023 {
3024 // in case we have a media object
3025 xProps->setPropertyValue( "MediaURL", uno::Any(maHref));
3026
3027 xProps->setPropertyValue("MediaMimeType", uno::Any(maMimeType) );
3028
3029 for( const auto& rParam : std::as_const(maParams) )
3030 {
3031 const OUString& rName = rParam.Name;
3032
3033 if( rName == "Loop" )
3034 {
3035 OUString aValueStr;
3036 rParam.Value >>= aValueStr;
3037 xProps->setPropertyValue("Loop",
3038 uno::Any( aValueStr == "true" ) );
3039 }
3040 else if( rName == "Mute" )
3041 {
3042 OUString aValueStr;
3043 rParam.Value >>= aValueStr;
3044 xProps->setPropertyValue("Mute",
3045 uno::Any( aValueStr == "true" ) );
3046 }
3047 else if( rName == "VolumeDB" )
3048 {
3049 OUString aValueStr;
3050 rParam.Value >>= aValueStr;
3051 xProps->setPropertyValue("VolumeDB",
3052 uno::Any( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
3053 }
3054 else if( rName == "Zoom" )
3055 {
3056 OUString aZoomStr;
3057 media::ZoomLevel eZoomLevel;
3058
3059 rParam.Value >>= aZoomStr;
3060
3061 if( aZoomStr == "25%" )
3062 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
3063 else if( aZoomStr == "50%" )
3064 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2;
3065 else if( aZoomStr == "100%" )
3066 eZoomLevel = media::ZoomLevel_ORIGINAL;
3067 else if( aZoomStr == "200%" )
3068 eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1;
3069 else if( aZoomStr == "400%" )
3070 eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1;
3071 else if( aZoomStr == "fit" )
3072 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
3073 else if( aZoomStr == "fixedfit" )
3074 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT;
3075 else if( aZoomStr == "fullscreen" )
3076 eZoomLevel = media::ZoomLevel_FULLSCREEN;
3077 else
3078 eZoomLevel = media::ZoomLevel_NOT_AVAILABLE;
3079
3080 xProps->setPropertyValue("Zoom", uno::Any( eZoomLevel ) );
3081 }
3082 }
3083 }
3084
3085 SetThumbnail();
3086 }
3087
3089}
3090
3091css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLPluginShapeContext::createFastChildContext(
3092 sal_Int32 nElement,
3093 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
3094{
3095 if( nElement == XML_ELEMENT(DRAW, XML_PARAM) )
3096 {
3097 OUString aParamName, aParamValue;
3098 // now parse the attribute list and look for draw:name and draw:value
3099 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
3100 {
3101 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAME) )
3102 aParamName = aIter.toString();
3103 else if( aIter.getToken() == XML_ELEMENT(DRAW, XML_VALUE) )
3104 aParamValue = aIter.toString();
3105 }
3106
3107 if( !aParamName.isEmpty() )
3108 {
3109 sal_Int32 nIndex = maParams.getLength();
3110 maParams.realloc( nIndex + 1 );
3111 auto pParams = maParams.getArray();
3112 pParams[nIndex].Name = aParamName;
3113 pParams[nIndex].Handle = -1;
3114 pParams[nIndex].Value <<= aParamValue;
3115 pParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3116 }
3117
3118 return new SvXMLImportContext( GetImport() );
3119 }
3120
3121 return SdXMLShapeContext::createFastChildContext( nElement, xAttrList );
3122}
3123
3124
3126 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
3127 css::uno::Reference< css::drawing::XShapes > const & rShapes)
3128: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
3129{
3130}
3131
3133{
3134}
3135
3137{
3138 uno::Reference<lang::XMultiServiceFactory> xServiceFact(GetImport().GetModel(), uno::UNO_QUERY);
3139 if (!xServiceFact.is())
3140 return nullptr;
3141 uno::Reference<drawing::XShape> xShape(
3142 xServiceFact->createInstance("com.sun.star.drawing.FrameShape"), uno::UNO_QUERY);
3143 return xShape;
3144}
3145
3147 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
3148{
3149 uno::Reference<drawing::XShape> xShape(SdXMLFloatingFrameShapeContext::CreateFloatingFrameShape());
3150
3151 uno::Reference< beans::XPropertySet > xProps(xShape, uno::UNO_QUERY);
3152 // set FrameURL before AddShape, we have to do it again later because it
3153 // gets cleared when the SdrOle2Obj is attached to the XShape. But we want
3154 // FrameURL to exist when AddShape triggers SetPersistName which itself
3155 // triggers SdrOle2Obj::CheckFileLink_Impl and at that point we want to
3156 // know what URL will end up being used. So bodge this by setting FrameURL
3157 // to the temp pre-SdrOle2Obj attached properties and we can smuggle it
3158 // eventually into SdrOle2Obj::SetPersistName at the right point after
3159 // PersistName is set but before SdrOle2Obj::CheckFileLink_Impl is called
3160 // in order to inform the link manager that this is an IFrame that links to
3161 // a URL
3162 if (xProps && !maHref.isEmpty())
3163 xProps->setPropertyValue("FrameURL", Any(maHref));
3164
3165 AddShape(xShape);
3166
3167 if( !mxShape.is() )
3168 return;
3169
3170 SetLayer();
3171
3172 // set pos, size, shear and rotate
3174
3175 if( xProps.is() )
3176 {
3177 if( !maFrameName.isEmpty() )
3178 {
3179 xProps->setPropertyValue("FrameName", Any(maFrameName) );
3180 }
3181
3182 if( !maHref.isEmpty() )
3183 {
3184 if (INetURLObject(maHref).GetProtocol() == INetProtocol::Macro)
3185 GetImport().NotifyMacroEventRead();
3186
3187 xProps->setPropertyValue("FrameURL", Any(maHref) );
3188 }
3189 }
3190
3191 SetStyle();
3192
3193 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3194}
3195
3196// this is called from the parent group for each unparsed attribute in the attribute list
3198{
3199 switch( aIter.getToken() )
3200 {
3202 maFrameName = aIter.toString();
3203 break;
3204 case XML_ELEMENT(XLINK, XML_HREF):
3205 maHref = GetImport().GetAbsoluteReference(aIter.toString());
3206 break;
3207 default:
3209 }
3210 return true;
3211}
3212
3214{
3215 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3216
3217 if( xProps.is() )
3218 {
3219 if ( maSize.Width && maSize.Height )
3220 {
3221 // the visual area for a floating frame must be set on loading
3222 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3223 xProps->setPropertyValue("VisibleArea", Any(aRect) );
3224 }
3225 }
3226
3227 SetThumbnail();
3229}
3230
3231
3233 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
3234 css::uno::Reference< css::drawing::XShapes > const & rShapes,
3235 bool bTemporaryShape)
3236: SdXMLShapeContext( rImport, xAttrList, rShapes, bTemporaryShape ),
3237 mbSupportsReplacement( false )
3238{
3239 uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
3240 if( xClone.is() )
3241 mxAttrList.set( xClone->createClone(), uno::UNO_QUERY );
3242 else
3244}
3245
3247{
3248}
3249
3251{
3252 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3253
3254 if(!pSdXMLGraphicObjectShapeContext)
3255 return;
3256
3257 try
3258 {
3259 uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3260
3261 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
3262
3263 // remove from parent
3264 xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
3265
3266 // dispose
3267 uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
3268
3269 if(xComp.is())
3270 {
3271 xComp->dispose();
3272 }
3273 }
3274 catch( uno::Exception& )
3275 {
3276 DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." );
3277 }
3278}
3279
3280namespace
3281{
3282uno::Reference<beans::XPropertySet> getGraphicPropertySetFromImportContext(const SvXMLImportContext& rContext)
3283{
3284 uno::Reference<beans::XPropertySet> aPropertySet;
3285 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast<const SdXMLGraphicObjectShapeContext*>(&rContext);
3286
3287 if (pSdXMLGraphicObjectShapeContext)
3288 aPropertySet.set(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY);
3289
3290 return aPropertySet;
3291}
3292
3293} // end anonymous namespace
3294
3295uno::Reference<graphic::XGraphic> SdXMLFrameShapeContext::getGraphicFromImportContext(const SvXMLImportContext& rContext) const
3296{
3297 uno::Reference<graphic::XGraphic> xGraphic;
3298 try
3299 {
3300 const uno::Reference<beans::XPropertySet> xPropertySet = getGraphicPropertySetFromImportContext(rContext);
3301
3302 if (xPropertySet.is())
3303 {
3304 xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
3305 }
3306 }
3307 catch( uno::Exception& )
3308 {
3309 DBG_UNHANDLED_EXCEPTION("xmloff", "Error in cleanup of multiple graphic object import.");
3310 }
3311
3312 return xGraphic;
3313}
3314
3316{
3317 OUString aRetval;
3318 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3319
3320 if(pSdXMLGraphicObjectShapeContext)
3321 {
3322 try
3323 {
3324 const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3325
3326 xPropSet->getPropertyValue("GraphicStreamURL") >>= aRetval;
3327 }
3328 catch( uno::Exception& )
3329 {
3330 DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." );
3331 }
3332 }
3333
3334 return aRetval;
3335}
3336
3337css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLFrameShapeContext::createFastChildContext(
3338 sal_Int32 nElement,
3339 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
3340{
3341 SvXMLImportContextRef xContext;
3342 if( !mxImplContext.is() )
3343 {
3345 GetImport(), nElement, xAttrList, mxShapes, mxAttrList );
3346
3347 xContext = pShapeContext;
3348
3349 // propagate the hyperlink to child context
3350 if ( !msHyperlink.isEmpty() )
3351 pShapeContext->setHyperlink( msHyperlink );
3352
3353 auto nToken = nElement & TOKEN_MASK;
3354 bool bMedia = false;
3355 // Ignore gltf model if necessary and so the fallback image will be imported
3356 if( nToken == XML_PLUGIN )
3357 {
3358 SdXMLPluginShapeContext* pPluginContext = dynamic_cast<SdXMLPluginShapeContext*>(pShapeContext);
3359 if( pPluginContext && pPluginContext->getMimeType() == "model/vnd.gltf+json" )
3360 {
3361 mxImplContext = nullptr;
3362 return new SvXMLImportContext(GetImport());
3363 }
3364 else if (pPluginContext && ::comphelper::IsMediaMimeType(pPluginContext->getMimeType()))
3365 {
3366 // The media may have a preview, import it.
3367 bMedia = true;
3368 }
3369 }
3370
3371 mxImplContext = xContext;
3374
3375 if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get()))
3376 {
3377 if ( !maShapeId.isEmpty() )
3378 GetImport().getInterfaceToIdentifierMapper().reserveIdentifier( maShapeId );
3379
3381 }
3382 }
3383 else if(getSupportsMultipleContents() && nElement == XML_ELEMENT(DRAW, XML_IMAGE))
3384 {
3385 // read another image
3387 GetImport(), nElement, xAttrList, mxShapes, mxAttrList);
3388 mxImplContext = xContext;
3389
3390 if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get()))
3391 {
3393 }
3394 }
3395 else if( mbSupportsReplacement && !mxReplImplContext.is() &&
3396 nElement == XML_ELEMENT(DRAW, XML_IMAGE) )
3397 {
3398 // read replacement image
3399 SvXMLImportContext *pImplContext = mxImplContext.get();
3400 SdXMLShapeContext *pSContext =
3401 dynamic_cast<SdXMLShapeContext*>( pImplContext );
3402 if( pSContext )
3403 {
3404 uno::Reference < beans::XPropertySet > xPropSet(
3405 pSContext->getShape(), uno::UNO_QUERY );
3406 if( xPropSet.is() )
3407 {
3408 xContext = new XMLReplacementImageContext( GetImport(),
3409 nElement, xAttrList, xPropSet );
3410 mxReplImplContext = xContext;
3411 }
3412 }
3413 }
3414 else if( nElement == XML_ELEMENT(SVG, XML_TITLE) || // #i68101#
3415 nElement == XML_ELEMENT(SVG_COMPAT, XML_TITLE) ||
3416 nElement == XML_ELEMENT(SVG, XML_DESC) ||
3417 nElement == XML_ELEMENT(SVG_COMPAT, XML_DESC) ||
3418 nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) ||
3419 nElement == XML_ELEMENT(DRAW, XML_GLUE_POINT) ||
3420 nElement == XML_ELEMENT(DRAW, XML_THUMBNAIL) )
3421 {
3423 { // tdf#103567 ensure props are set on surviving shape
3424 // note: no more draw:image can be added once we get here
3426 }
3427 SvXMLImportContext *pImplContext = mxImplContext.get();
3428 xContext = static_cast<SvXMLImportContext*>(dynamic_cast<SdXMLShapeContext&>(*pImplContext).createFastChildContext( nElement,
3429 xAttrList ).get());
3430 }
3431 else if ( nElement == XML_ELEMENT(DRAW, XML_IMAGE_MAP) )
3432 {
3434 { // tdf#103567 ensure props are set on surviving shape
3435 // note: no more draw:image can be added once we get here
3437 }
3438 SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( mxImplContext.get() );
3439 if( pSContext )
3440 {
3441 uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY );
3442 if (xPropSet.is())
3443 {
3444 xContext = new XMLImageMapContext(GetImport(), xPropSet);
3445 }
3446 }
3447 }
3448 else if ( nElement == XML_ELEMENT(LO_EXT, XML_SIGNATURELINE) )
3449 {
3450 SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
3451 if (pSContext)
3452 {
3453 uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
3454 if (xPropSet.is())
3455 {
3456 xContext = new SignatureLineContext(GetImport(), nElement, xAttrList,
3457 pSContext->getShape());
3458 }
3459 }
3460 }
3461 else if ( nElement == XML_ELEMENT(LO_EXT, XML_QRCODE))
3462 {
3463 SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
3464 if (pSContext)
3465 {
3466 uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
3467 if (xPropSet.is())
3468 {
3469 xContext = new QRCodeContext(GetImport(), nElement, xAttrList,
3470 pSContext->getShape());
3471 }
3472 }
3473 }
3474
3475 return xContext;
3476}
3477
3478void SdXMLFrameShapeContext::startFastElement (sal_Int32 /*nElement*/,
3479 const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/)
3480{
3481 // ignore
3482}
3483
3485{
3486 // solve if multiple image child contexts were imported
3487 SvXMLImportContextRef const pSelectedContext(solveMultipleImages());
3488 const SdXMLGraphicObjectShapeContext* pShapeContext(
3489 dynamic_cast<const SdXMLGraphicObjectShapeContext*>(pSelectedContext.get()));
3490 if ( pShapeContext )
3491 {
3492 assert( mxImplContext.is() );
3493 const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() );
3494 GetImport().getInterfaceToIdentifierMapper().registerReservedReference( maShapeId, xShape );
3495 }
3496
3497 if( !mxImplContext.is() )
3498 {
3499 // now check if this is an empty presentation object
3501 {
3502 switch (aIter.getToken())
3503 {
3504 case XML_ELEMENT(PRESENTATION, XML_PLACEHOLDER):
3506 break;
3507 case XML_ELEMENT(PRESENTATION, XML_CLASS):
3508 maPresentationClass = aIter.toString();
3509 break;
3510 default:;
3511 }
3512 }
3513
3514 if( (!maPresentationClass.isEmpty()) && mbIsPlaceholder )
3515 {
3516 uno::Reference< xml::sax::XFastAttributeList> xEmpty;
3517
3519
3521 {
3522 eToken = XML_IMAGE;
3523
3524 }
3526 {
3528 }
3532 {
3534 }
3535
3536 auto x = XML_ELEMENT(DRAW, eToken);
3538 GetImport(), x, mxAttrList, mxShapes, xEmpty );
3539
3540 if( mxImplContext.is() )
3541 {
3542 mxImplContext->startFastElement( x, mxAttrList );
3543 mxImplContext->endFastElement(x);
3544 }
3545 }
3546 }
3547
3548 mxImplContext = nullptr;
3550}
3551
3553{
3554 bool bId( false );
3555
3556 switch ( aIter.getToken() )
3557 {
3558 case XML_ELEMENT(DRAW, XML_ID):
3559 case XML_ELEMENT(DRAW_EXT, XML_ID):
3560 case XML_ELEMENT(NONE, XML_ID):
3561 case XML_ELEMENT(XML, XML_ID) :
3562 bId = true;
3563 break;
3564 default:;
3565 }
3566
3567 if ( bId )
3569 return true; // deliberately ignoring other attributes
3570}
3571
3572
3574 SvXMLImport& rImport,
3575 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
3576 uno::Reference< drawing::XShapes > const & rShapes)
3577: SdXMLShapeContext( rImport, xAttrList, rShapes, false/*bTemporaryShape*/ )
3578{
3579 // See the XMLTextFrameContext ctor, a frame has Writer content (and not
3580 // editeng) if its autostyle has a parent style. Do the same for shapes as well.
3581 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
3582 {
3583 if (aIter.getToken() == XML_ELEMENT(DRAW, XML_STYLE_NAME))
3584 {
3585 OUString aStyleName = aIter.toString();
3586 if(!aStyleName.isEmpty())
3587 {
3588 rtl::Reference<XMLTextImportHelper> xTxtImport = GetImport().GetTextImport();
3589 XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName);
3590 // Note that this an API name, so intentionally not localized.
3591 // Also allow other Frame styles with the same prefix, we just want to reject
3592 // Graphics after all.
3593 if (pStyle && pStyle->GetParentName().startsWith("Frame"))
3594 {
3595 mbTextBox = true;
3596 break;
3597 }
3598 }
3599 }
3600 }
3601}
3602
3604{
3605}
3606
3607// this is called from the parent group for each unparsed attribute in the attribute list
3609{
3610 if( aIter.getToken() == XML_ELEMENT(DRAW, XML_ENGINE) )
3611 {
3612 maCustomShapeEngine = aIter.toString();
3613 }
3614 else if (aIter.getToken() == XML_ELEMENT(DRAW, XML_DATA) )
3615 {
3616 maCustomShapeData = aIter.toString();
3617 }
3618 else
3620 return true;
3621}
3622
3624 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
3625{
3626 // create rectangle shape
3627 AddShape("com.sun.star.drawing.CustomShape");
3628 if ( !mxShape.is() )
3629 return;
3630
3631 // Add, set Style and properties from base shape
3632 SetStyle();
3633 SetLayer();
3634
3635 // set pos, size, shear and rotate
3637
3638 try
3639 {
3640 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3641 if( xPropSet.is() )
3642 {
3643 if ( !maCustomShapeEngine.isEmpty() )
3644 {
3645 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), Any(maCustomShapeEngine) );
3646 }
3647 if ( !maCustomShapeData.isEmpty() )
3648 {
3649 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), Any(maCustomShapeData) );
3650 }
3651 }
3652 }
3653 catch(const uno::Exception&)
3654 {
3655 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" );
3656 }
3657 SdXMLShapeContext::startFastElement(nElement, xAttrList);
3658}
3659
3661{
3662 // Customshapes remember mirror state in its enhanced geometry.
3663 // SetTransformation() in StartElement() may have applied mirroring, but that is not yet
3664 // contained. Merge that information here before writing the property.
3666 {
3667 basegfx::B2DVector aScale, aTranslate;
3668 double fRotate, fShearX;
3669
3670 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
3671
3672 if (aScale.getX() < 0.0)
3673 {
3674 static constexpr OUStringLiteral sName(u"MirroredX");
3675 //fdo#84043 Merge, if property exists, otherwise append it
3676 auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
3677 [](beans::PropertyValue& rValue) { return rValue.Name == sName; });
3678 if (aI != maCustomShapeGeometry.end())
3679 {
3680 beans::PropertyValue& rItem = *aI;
3681 bool bMirroredX = *o3tl::doAccess<bool>(rItem.Value);
3682 rItem.Value <<= !bMirroredX;
3683 rItem.Handle = -1;
3684 rItem.State = beans::PropertyState_DIRECT_VALUE;
3685 }
3686 else
3687 {
3688 beans::PropertyValue* pItem;
3689 maCustomShapeGeometry.emplace_back();
3690 pItem = &maCustomShapeGeometry.back();
3691 pItem->Name = sName;
3692 pItem->Handle = -1;
3693 pItem->Value <<= true;
3694 pItem->State = beans::PropertyState_DIRECT_VALUE;
3695 }
3696 }
3697
3698 if (aScale.getY() < 0.0)
3699 {
3700 static constexpr OUStringLiteral sName(u"MirroredY");
3701 //fdo#84043 Merge, if property exists, otherwise append it
3702 auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
3703 [](beans::PropertyValue& rValue) { return rValue.Name == sName; });
3704 if (aI != maCustomShapeGeometry.end())
3705 {
3706 beans::PropertyValue& rItem = *aI;
3707 bool bMirroredY = *o3tl::doAccess<bool>(rItem.Value);
3708 rItem.Value <<= !bMirroredY;
3709 rItem.Handle = -1;
3710 rItem.State = beans::PropertyState_DIRECT_VALUE;
3711 }
3712 else
3713 {
3714 beans::PropertyValue* pItem;
3715 maCustomShapeGeometry.emplace_back();
3716 pItem = &maCustomShapeGeometry.back();
3717 pItem->Name = sName;
3718 pItem->Handle = -1;
3719 pItem->Value <<= true;
3720 pItem->State = beans::PropertyState_DIRECT_VALUE;
3721 }
3722 }
3723 }
3724
3725 if ( !maCustomShapeGeometry.empty() )
3726 {
3727 // converting the vector to a sequence
3728 uno::Sequence< beans::PropertyValue > aSeq( comphelper::containerToSequence(maCustomShapeGeometry) );
3729
3730 try
3731 {
3732 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3733 if( xPropSet.is() )
3734 {
3735 xPropSet->setPropertyValue( "CustomShapeGeometry", Any(aSeq) );
3736 }
3737 }
3738 catch(const uno::Exception&)
3739 {
3740 DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" );
3741 }
3742
3743 sal_Int32 nUPD;
3744 sal_Int32 nBuild;
3745 if (GetImport().getBuildIds(nUPD, nBuild))
3746 {
3747 if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) )
3748 {
3749 Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY );
3750 if( xDefaulter.is() )
3751 {
3752 xDefaulter->createCustomShapeDefaults( "" );
3753 }
3754 }
3755 }
3756 }
3757
3759
3760 // tdf#98163 call a custom slot to be able to reset the UNO API
3761 // implementations held on the SdrObjects of type
3762 // SdrObjCustomShape - those tend to linger until the entire file
3763 // is loaded. For large files with a lot of these, 32bit systems
3764 // may crash due to being out of resources after ca. 4200
3765 // Outliners and VirtualDevices used there as RefDevice
3766 try
3767 {
3768 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
3769
3770 if(xPropSet.is())
3771 {
3772 xPropSet->setPropertyValue(
3773 "FlushCustomShapeUnoApiObjects", css::uno::Any(true));
3774 }
3775 }
3776 catch(const uno::Exception&)
3777 {
3778 DBG_UNHANDLED_EXCEPTION("xmloff", "flushing after load");
3779 }
3780}
3781
3782css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLCustomShapeContext::createFastChildContext(
3783 sal_Int32 nElement,
3784 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
3785{
3786 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
3787 if ( nElement == XML_ELEMENT(DRAW, XML_ENHANCED_GEOMETRY) )
3788 {
3789 uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
3790 if ( xPropSet.is() )
3792 }
3793 // delegate to parent class if no context could be created
3794 if (!xContext)
3795 xContext = SdXMLShapeContext::createFastChildContext( nElement,
3796 xAttrList);
3797 return xContext;
3798}
3799
3800SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes )
3801: SdXMLShapeContext( rImport, xAttrList, rShapes, false )
3802{
3803}
3804
3806{
3807}
3808
3810 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
3811{
3812 OUString service("com.sun.star.drawing.TableShape");
3813
3814 bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3815 if( bIsPresShape )
3816 {
3818 {
3819 service = "com.sun.star.presentation.TableShape";
3820 }
3821 }
3822
3823 AddShape(service);
3824
3825 if( !mxShape.is() )
3826 return;
3827
3828 SetLayer();
3829
3830 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
3831
3832 if(bIsPresShape && xProps.is())
3833 {
3834 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3835 if( xPropsInfo.is() )
3836 {
3837 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
3838 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
3839
3840 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
3841 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
3842 }
3843 }
3844
3845 SetStyle();
3846
3847 if( xProps.is() )
3848 {
3849 if( !msTemplateStyleName.isEmpty() ) try
3850 {
3851 Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
3852 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
3853 Reference< XNameAccess > xTableFamily( xFamilies->getByName( "table" ), UNO_QUERY_THROW );
3854 Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
3855 xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) );
3856 }
3857 catch(const Exception&)
3858 {
3859 DBG_UNHANDLED_EXCEPTION("xmloff.draw");
3860 }
3861
3863 for( int i = 0; !pEntry->IsEnd() && (i < 6); i++, pEntry++ )
3864 {
3865 try
3866 {
3867 xProps->setPropertyValue( pEntry->getApiName(), Any( maTemplateStylesUsed[i] ) );
3868 }
3869 catch(const Exception&)
3870 {
3871 DBG_UNHANDLED_EXCEPTION("xmloff.draw");
3872 }
3873 }
3874 }
3875
3876 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3877
3878 const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3879 if( xTableImport.is() && xProps.is() )
3880 {
3881 uno::Reference< table::XColumnRowRange > xColumnRowRange(
3882 xProps->getPropertyValue("Model"), uno::UNO_QUERY );
3883
3884 if( xColumnRowRange.is() )
3885 mxTableImportContext = xTableImport->CreateTableContext( xColumnRowRange );
3886
3887 if( mxTableImportContext.is() )
3888 mxTableImportContext->startFastElement( nElement, xAttrList );
3889 }
3890}
3891
3893{
3894 if( mxTableImportContext.is() )
3895 mxTableImportContext->endFastElement(nElement);
3896
3898
3899 if( mxShape.is() )
3900 {
3901 // set pos, size, shear and rotate
3903 }
3904}
3905
3906// this is called from the parent group for each unparsed attribute in the attribute list
3908{
3909 auto nElement = aIter.getToken();
3911 {
3912 if( (nElement & TOKEN_MASK) == XML_TEMPLATE_NAME )
3913 {
3914 msTemplateStyleName = aIter.toString();
3915 }
3916 else
3917 {
3918 int i = 0;
3920 while( !pEntry->IsEnd() && (i < 6) )
3921 {
3922 if( (nElement & TOKEN_MASK) == pEntry->meXMLName )
3923 {
3924 if( IsXMLToken( aIter, XML_TRUE ) )
3925 maTemplateStylesUsed[i] = true;
3926 break;
3927 }
3928 pEntry++;
3929 i++;
3930 }
3931 }
3932 }
3934}
3935
3936css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLTableShapeContext::createFastChildContext(
3937 sal_Int32 nElement,
3938 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
3939{
3941 return mxTableImportContext->createFastChildContext(nElement, xAttrList);
3942 return SdXMLShapeContext::createFastChildContext(nElement, xAttrList);
3943}
3944
3945/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
geometry::RealPoint2D maPosition
geometry::RealSize2D maSize
Point maStart
const Point maEnd
PropertiesInfo aProperties
bool getSupportsMultipleContents() const
read/write access to boolean switch
SvXMLImportContextRef solveMultipleImages()
solve multiple imported images.
void setSupportsMultipleContents(bool bNew)
void addContent(const SvXMLImportContext &rSvXMLImportContext)
add a content to the remembered image import contexts
virtual ~SdXMLAppletShapeContext() override
Definition: ximpshap.cxx:2751
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2755
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:2743
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:2839
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2771
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:2793
virtual ~SdXMLCaptionShapeContext() override
Definition: ximpshap.cxx:2218
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:2207
css::awt::Point maCaptionPoint
Definition: ximpshap.hxx:364
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2279
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2222
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:2531
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:2447
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:2537
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:2456
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:2523
css::drawing::ConnectorType mnType
Definition: ximpshap.hxx:286
virtual ~SdXMLConnectorShapeContext() override
Definition: ximpshap.cxx:1748
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:1731
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:1864
css::awt::Point maStart
Definition: ximpshap.hxx:282
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1771
virtual ~SdXMLControlShapeContext() override
Definition: ximpshap.cxx:1678
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1683
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:1669
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1696
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3623
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:3660
std::vector< css::beans::PropertyValue > maCustomShapeGeometry
Definition: ximpshap.hxx:588
virtual ~SdXMLCustomShapeContext() override
Definition: ximpshap.cxx:3603
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:3782
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3608
SdXMLCustomShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:3573
OUString maCustomShapeEngine
Definition: ximpshap.hxx:585
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:1096
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1117
virtual ~SdXMLEllipseShapeContext() override
Definition: ximpshap.cxx:1112
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1171
virtual ~SdXMLFloatingFrameShapeContext() override
Definition: ximpshap.cxx:3132
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:3213
css::uno::Reference< css::drawing::XShape > CreateFloatingFrameShape() const
Definition: ximpshap.cxx:3136
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3197
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3146
SdXMLFloatingFrameShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:3125
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:3232
SvXMLImportContextRef mxReplImplContext
Definition: ximpshap.hxx:556
css::uno::Reference< css::graphic::XGraphic > getGraphicFromImportContext(const SvXMLImportContext &rContext) const override
Definition: ximpshap.cxx:3295
void removeGraphicFromImportContext(const SvXMLImportContext &rContext) override
helper to get the created xShape instance, needs to be overridden
Definition: ximpshap.cxx:3250
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3478
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:3484
virtual ~SdXMLFrameShapeContext() override
Definition: ximpshap.cxx:3246
OUString getGraphicPackageURLFromImportContext(const SvXMLImportContext &rContext) const override
Definition: ximpshap.cxx:3315
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:3337
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3552
SvXMLImportContextRef mxImplContext
Definition: ximpshap.hxx:555
SdXMLGraphicObjectShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2302
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2311
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:2395
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2320
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:2413
virtual ~SdXMLGraphicObjectShapeContext() override
Definition: ximpshap.cxx:2441
bool NeedsAction() const
Definition: xexptran.hxx:55
void SetString(const OUString &rNew, const SvXMLUnitConverter &rConv)
Definition: xexptran.cxx:347
void GetFullTransform(::basegfx::B2DHomMatrix &rFullTrans)
Definition: xexptran.cxx:480
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:987
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1005
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1035
virtual ~SdXMLLineShapeContext() override
Definition: ximpshap.cxx:1000
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:2103
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2074
css::awt::Point maEnd
Definition: ximpshap.hxx:320
virtual ~SdXMLMeasureShapeContext() override
Definition: ximpshap.cxx:2031
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:2020
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2036
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:2655
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:2707
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2559
SdXMLObjectShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2548
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2691
css::uno::Reference< css::io::XOutputStream > mxBase64Stream
Definition: ximpshap.hxx:439
virtual ~SdXMLObjectShapeContext() override
Definition: ximpshap.cxx:2555
virtual ~SdXMLPageShapeContext() override
Definition: ximpshap.cxx:2136
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:2126
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:2150
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2141
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1368
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:1336
virtual ~SdXMLPathShapeContext() override
Definition: ximpshap.cxx:1345
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1350
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:2885
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:2986
const OUString & getMimeType() const
Definition: ximpshap.hxx:520
virtual ~SdXMLPluginShapeContext() override
Definition: ximpshap.cxx:2881
SdXMLPluginShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:2873
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:3091
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:2970
virtual ~SdXMLPolygonShapeContext() override
Definition: ximpshap.cxx:1260
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1264
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1243
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:1233
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:924
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:939
virtual ~SdXMLRectShapeContext() override
Definition: ximpshap.cxx:934
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:953
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:799
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:905
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:632
bool maTemplateStylesUsed[6]
Definition: ximpshap.hxx:634
virtual ~SdXMLTableShapeContext() override
Definition: ximpshap.cxx:3805
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:3907
SdXMLTableShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:3800
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:3892
OUString msTemplateStyleName
Definition: ximpshap.hxx:633
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:3936
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:3809
virtual bool processAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &) override
Definition: ximpshap.cxx:1502
SdXMLTextBoxShapeContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximpshap.cxx:1487
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: ximpshap.cxx:1519
virtual ~SdXMLTextBoxShapeContext() override
Definition: ximpshap.cxx:1497
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:529
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
Definition: prstylei.cxx:222
const css::uno::Reference< css::style::XStyle > & GetStyle() const
Definition: prstylei.hxx:106
static SvXMLShapeContext * CreateFrameChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xFrameAttrList)
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void translate(double fX, double fY)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void scale(double fX, double fY)
bool isIdentity() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
bool areControlPointsUsed() const
sal_uInt32 count() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 count() const
bool equal(const Range2D &rRange) const
TYPE getX() const
TYPE getY() const
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
#define DBG_UNHANDLED_EXCEPTION(...)
float u
float x
XmlStyleFamily
Definition: families.hxx:50
DRAW
MATH
OUString sName
sal_Int32 nIndex
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
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:1552
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3597
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:2957
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:97
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:104
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
constexpr sal_uInt16 XML_NAMESPACE_TABLE
XMLTokenEnum eToken
Definition: xmltoken.cxx:40