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