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