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>
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  return;
494 
495  try
496  {
497  /* Since fix for issue i33294 the Writer model doesn't support
498  com.sun.star.drawing.OLE2Shape anymore.
499  To handle Draw OLE objects it's decided to import these
500  objects as com.sun.star.drawing.OLE2Shape and convert these
501  objects after the import into com.sun.star.drawing.GraphicObjectShape.
502  */
503  uno::Reference< drawing::XShape > xShape;
504  if ( serviceName == "com.sun.star.drawing.OLE2Shape" &&
505  uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
506  {
507  xShape.set(xServiceFact->createInstance("com.sun.star.drawing.temporaryForXMLImportOLE2Shape"), uno::UNO_QUERY);
508  }
509  else if (serviceName == "com.sun.star.drawing.GraphicObjectShape"
510  || serviceName == "com.sun.star.drawing.MediaShape"
511  || serviceName == "com.sun.star.presentation.MediaShape")
512  {
513  css::uno::Sequence<css::uno::Any> args(1);
514  args[0] <<= GetImport().GetDocumentBase();
515  xShape.set( xServiceFact->createInstanceWithArguments(serviceName, args),
516  css::uno::UNO_QUERY);
517  }
518  else
519  {
520  xShape.set(xServiceFact->createInstance(serviceName), uno::UNO_QUERY);
521  }
522  if( xShape.is() )
523  AddShape( xShape );
524  }
525  catch(const uno::Exception& e)
526  {
527  uno::Sequence<OUString> aSeq { serviceName };
529  aSeq, e.Message, nullptr );
530  }
531 }
532 
534 {
535  if(!mxShape.is())
536  return;
537 
538  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
539  if(!xPropSet.is())
540  return;
541 
543 
544  if(maSize.Width != 1 || maSize.Height != 1)
545  {
546  // take care there are no zeros used by error
547  if(0 == maSize.Width)
548  maSize.Width = 1;
549  if(0 == maSize.Height)
550  maSize.Height = 1;
551 
552  // set global size. This should always be used.
553  maUsedTransformation.scale(maSize.Width, maSize.Height);
554  }
555 
556  if(maPosition.X != 0 || maPosition.Y != 0)
557  {
558  // if global position is used, add it to transformation
560  }
561 
563  {
564  // transformation is used, apply to object.
565  // NOTICE: The transformation is applied AFTER evtl. used
566  // global positioning and scaling is used, so any shear or
567  // rotate used herein is applied around the (0,0) position
568  // of the PAGE object !!!
571 
572  // now add to transformation
573  maUsedTransformation *= aMat;
574  }
575 
576  // now set transformation for this object
577 
578  // maUsedTransformtion contains the mathematical correct matrix, which if
579  // applied to a unit square would generate the transformed shape. But the property
580  // "Transformation" contains a matrix, which can be used in TRSetBaseGeometry
581  // and would be created by TRGetBaseGeometry. And those use a mathematically wrong
582  // sign for the shearing angle. So we need to adapt the matrix here.
583  basegfx::B2DTuple aScale;
584  basegfx::B2DTuple aTranslate;
585  double fRotate;
586  double fShearX;
587  maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
588  basegfx::B2DHomMatrix aB2DHomMatrix;
590  aScale,
591  basegfx::fTools::equalZero(fShearX) ? 0.0 : -fShearX,
592  basegfx::fTools::equalZero(fRotate) ? 0.0 : fRotate,
593  aTranslate);
594  drawing::HomogenMatrix3 aUnoMatrix;
595 
596  aUnoMatrix.Line1.Column1 = aB2DHomMatrix.get(0, 0);
597  aUnoMatrix.Line1.Column2 = aB2DHomMatrix.get(0, 1);
598  aUnoMatrix.Line1.Column3 = aB2DHomMatrix.get(0, 2);
599 
600  aUnoMatrix.Line2.Column1 = aB2DHomMatrix.get(1, 0);
601  aUnoMatrix.Line2.Column2 = aB2DHomMatrix.get(1, 1);
602  aUnoMatrix.Line2.Column3 = aB2DHomMatrix.get(1, 2);
603 
604  aUnoMatrix.Line3.Column1 = aB2DHomMatrix.get(2, 0);
605  aUnoMatrix.Line3.Column2 = aB2DHomMatrix.get(2, 1);
606  aUnoMatrix.Line3.Column3 = aB2DHomMatrix.get(2, 2);
607 
608  xPropSet->setPropertyValue("Transformation", Any(aUnoMatrix));
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  return;
763 
764  try
765  {
766  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
767  if(xPropSet.is() )
768  {
769  xPropSet->setPropertyValue("LayerName", Any(maLayerName));
770  return;
771  }
772  }
773  catch(const uno::Exception&)
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  return;
983 
984  // Add, set Style and properties from base shape
985  SetStyle();
986  SetLayer();
987 
988  // set pos, size, shear and rotate
990 
991  if(mnRadius)
992  {
993  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
994  if(xPropSet.is())
995  {
996  try
997  {
998  xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) );
999  }
1000  catch(const uno::Exception&)
1001  {
1002  DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
1003  }
1004  }
1005  }
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  return;
1215 
1216  // Add, set Style and properties from base shape
1217  SetStyle();
1218  SetLayer();
1219 
1220  if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1)
1221  {
1222  // #i121972# center/radius is used, put to pos and size
1223  maSize.Width = 2 * mnRX;
1224  maSize.Height = 2 * mnRY;
1225  maPosition.X = mnCX - mnRX;
1226  maPosition.Y = mnCY - mnRY;
1227  }
1228 
1229  // set pos, size, shear and rotate
1231 
1232  if( meKind != drawing::CircleKind_FULL )
1233  {
1234  uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
1235  if( xPropSet.is() )
1236  {
1237  xPropSet->setPropertyValue("CircleKind", Any( meKind) );
1238  xPropSet->setPropertyValue("CircleStartAngle", Any(mnStartAngle) );
1239  xPropSet->setPropertyValue("CircleEndAngle", Any(mnEndAngle) );
1240  }
1241  }
1242 
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  return;
1295 
1296  SetStyle();
1297  SetLayer();
1298 
1299  // set local parameters on shape
1300  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1301  if(xPropSet.is())
1302  {
1303  // set polygon
1304  if(!maPoints.isEmpty() && !maViewBox.isEmpty())
1305  {
1306  const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1307  basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1308 
1309  // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1310  // sense to have the geometry content size different from object size
1311  if(maSize.Width != 0 && maSize.Height != 0)
1312  {
1313  aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1314  }
1315 
1316  basegfx::B2DPolygon aPolygon;
1317 
1319  {
1320  if(aPolygon.count())
1321  {
1322  const basegfx::B2DRange aSourceRange(
1323  aViewBox.GetX(), aViewBox.GetY(),
1324  aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1325  const basegfx::B2DRange aTargetRange(
1326  aViewBox.GetX(), aViewBox.GetY(),
1327  aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1328 
1329  if(!aSourceRange.equal(aTargetRange))
1330  {
1331  aPolygon.transform(
1333  aSourceRange,
1334  aTargetRange));
1335  }
1336 
1337  css::drawing::PointSequenceSequence aPointSequenceSequence;
1339  xPropSet->setPropertyValue("Geometry", Any(aPointSequenceSequence));
1340  // Size is now contained in the point coordinates, adapt maSize for
1341  // to use the correct transformation matrix in SetTransformation()
1342  maSize.Width = 1;
1343  maSize.Height = 1;
1344  }
1345  }
1346  }
1347  }
1348 
1349  // set pos, size, shear and rotate and get copy of matrix
1351 
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  return;
1396 
1397  const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1398  basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1399 
1400  // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1401  // sense to have the geometry content size different from object size
1402  if(maSize.Width != 0 && maSize.Height != 0)
1403  {
1404  aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1405  }
1406 
1407  basegfx::B2DPolyPolygon aPolyPolygon;
1408 
1409  if(!basegfx::utils::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), nullptr))
1410  return;
1411 
1412  if(!aPolyPolygon.count())
1413  return;
1414 
1415  const basegfx::B2DRange aSourceRange(
1416  aViewBox.GetX(), aViewBox.GetY(),
1417  aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1418  const basegfx::B2DRange aTargetRange(
1419  aViewBox.GetX(), aViewBox.GetY(),
1420  aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1421 
1422  if(!aSourceRange.equal(aTargetRange))
1423  {
1424  aPolyPolygon.transform(
1426  aSourceRange,
1427  aTargetRange));
1428  }
1429 
1430  // create shape
1431  OUString service;
1432 
1433  if(aPolyPolygon.areControlPointsUsed())
1434  {
1435  if(aPolyPolygon.isClosed())
1436  {
1437  service = "com.sun.star.drawing.ClosedBezierShape";
1438  }
1439  else
1440  {
1441  service = "com.sun.star.drawing.OpenBezierShape";
1442  }
1443  }
1444  else
1445  {
1446  if(aPolyPolygon.isClosed())
1447  {
1448  service = "com.sun.star.drawing.PolyPolygonShape";
1449  }
1450  else
1451  {
1452  service = "com.sun.star.drawing.PolyLineShape";
1453  }
1454  }
1455 
1456  // Add, set Style and properties from base shape
1457  AddShape(service);
1458 
1459  // #89344# test for mxShape.is() and not for mxShapes.is() to support
1460  // shape import helper classes WITHOUT XShapes (member mxShapes). This
1461  // is used by the writer.
1462  if( !mxShape.is() )
1463  return;
1464 
1465  SetStyle();
1466  SetLayer();
1467 
1468  // set local parameters on shape
1469  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1470 
1471  if(xPropSet.is())
1472  {
1473  uno::Any aAny;
1474 
1475  // set polygon data
1476  if(aPolyPolygon.areControlPointsUsed())
1477  {
1478  drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1479 
1481  aPolyPolygon,
1482  aSourcePolyPolygon);
1483  aAny <<= aSourcePolyPolygon;
1484  }
1485  else
1486  {
1487  drawing::PointSequenceSequence aSourcePolyPolygon;
1488 
1490  aPolyPolygon,
1491  aSourcePolyPolygon);
1492  aAny <<= aSourcePolyPolygon;
1493  }
1494 
1495  xPropSet->setPropertyValue("Geometry", aAny);
1496  // Size is now contained in the point coordinates, adapt maSize for
1497  // to use the correct transformation matrix in SetTransformation()
1498  maSize.Width = 1;
1499  maSize.Height = 1;
1500  }
1501 
1502  // set pos, size, shear and rotate
1504 
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  return;
1620 
1621  SetStyle();
1622  SetLayer();
1623 
1624  if(bIsPresShape)
1625  {
1626  uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
1627  if(xProps.is())
1628  {
1629  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
1630  if( xPropsInfo.is() )
1631  {
1632  if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
1633  xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
1634 
1635  if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
1636  xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
1637  }
1638  }
1639  }
1640 
1641  if( bClearText )
1642  {
1643  uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1644  xText->setString( "" );
1645  }
1646 
1647  // set parameters on shape
1648 //A AW->CL: Eventually You need to strip scale and translate from the transformation
1649 //A to reach the same goal again.
1650 //A if(!bIsPresShape || mbIsUserTransformed)
1651 //A {
1652 //A // set pos and size on shape, this should remove binding
1653 //A // to pres object on masterpage
1654 //A SetSizeAndPosition();
1655 //A }
1656 
1657  // set pos, size, shear and rotate
1659 
1660  if(mnRadius)
1661  {
1662  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1663  if(xPropSet.is())
1664  {
1665  try
1666  {
1667  xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) );
1668  }
1669  catch(const uno::Exception&)
1670  {
1671  DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
1672  }
1673  }
1674  }
1675 
1676  if(!maChainNextName.isEmpty())
1677  {
1678  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1679  if(xPropSet.is())
1680  {
1681  try
1682  {
1683  xPropSet->setPropertyValue("TextChainNextName",
1684  uno::makeAny( maChainNextName ) );
1685  }
1686  catch(const uno::Exception&)
1687  {
1688  DBG_UNHANDLED_EXCEPTION( "xmloff", "setting name of next chain link");
1689  }
1690  }
1691  }
1692 
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  return;
1734 
1735  SAL_WARN_IF( !!maFormId.isEmpty(), "xmloff", "draw:control without a form:id attribute!" );
1736  if( !maFormId.isEmpty() )
1737  {
1738  if( GetImport().IsFormsSupported() )
1739  {
1740  uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
1741  if( xControlModel.is() )
1742  {
1743  uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
1744  if( xControl.is() )
1745  xControl->setControl( xControlModel );
1746 
1747  }
1748  }
1749  }
1750 
1751  SetStyle();
1752  SetLayer();
1753 
1754  // set pos, size, shear and rotate
1756 
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  return;
1933 
1934  // create Connector shape
1935  // add, set style and properties from base shape
1936  AddShape("com.sun.star.drawing.ConnectorShape");
1937  if(!mxShape.is())
1938  return;
1939 
1940  // #121965# if draw:transform is used, apply directly to the start
1941  // and end positions before using these
1942  if(mnTransform.NeedsAction())
1943  {
1944  // transformation is used, apply to object.
1947 
1948  if(!aMat.isIdentity())
1949  {
1950  basegfx::B2DPoint aStart(maStart.X, maStart.Y);
1951  basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y);
1952 
1953  aStart = aMat * aStart;
1954  aEnd = aMat * aEnd;
1955 
1956  maStart.X = basegfx::fround(aStart.getX());
1957  maStart.Y = basegfx::fround(aStart.getY());
1958  maEnd.X = basegfx::fround(aEnd.getX());
1959  maEnd.Y = basegfx::fround(aEnd.getY());
1960  }
1961  }
1962 
1963  // add connection ids
1964  if( !maStartShapeId.isEmpty() )
1965  GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId );
1966  if( !maEndShapeId.isEmpty() )
1967  GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId );
1968 
1969  uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
1970  if( xProps.is() )
1971  {
1972  xProps->setPropertyValue("StartPosition", Any(maStart));
1973  xProps->setPropertyValue("EndPosition", Any(maEnd) );
1974  xProps->setPropertyValue("EdgeKind", Any(mnType) );
1975  xProps->setPropertyValue("EdgeLine1Delta", Any(mnDelta1) );
1976  xProps->setPropertyValue("EdgeLine2Delta", Any(mnDelta2) );
1977  xProps->setPropertyValue("EdgeLine3Delta", Any(mnDelta3) );
1978  }
1979  SetStyle();
1980  SetLayer();
1981 
1982  if ( maPath.hasValue() )
1983  {
1984  // #i115492#
1985  // Ignore svg:d attribute for text documents created by OpenOffice.org
1986  // versions before OOo 3.3, because these OOo versions are storing
1987  // svg:d values not using the correct unit.
1988  bool bApplySVGD( true );
1989  if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
1990  {
1991  sal_Int32 nUPD( 0 );
1992  sal_Int32 nBuild( 0 );
1993  const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
1994  if ( GetImport().IsTextDocInOOoFileFormat() ||
1995  ( bBuildIdFound &&
1996  ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1997  ( nUPD == 680 ) || // OOo 2.x
1998  ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1
1999  ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1
2000  ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1
2001  {
2002  bApplySVGD = false;
2003  }
2004  }
2005 
2006  if ( bApplySVGD )
2007  {
2008  // tdf#83360 use path data only when redundant data of start and end point coordinates of
2009  // path start/end and connector start/end is equal. This is to avoid using erraneous
2010  // or inconsistent path data at import of foreign formats. Office itself always
2011  // writes out a consistent data set. Not using it when there is inconsistency
2012  // is okay since the path data is redundant, buffered data just to avoid recalculation
2013  // of the connector's layout at load time, no real information would be lost.
2014  // A 'connected' end has prio to direct coordinate data in Start/EndPosition
2015  // to the path data (which should have the start/end redundant in the path)
2016  const drawing::PolyPolygonBezierCoords* pSource = static_cast< const drawing::PolyPolygonBezierCoords* >(maPath.getValue());
2017  const sal_uInt32 nSequenceCount(pSource->Coordinates.getLength());
2018  bool bStartEqual(false);
2019  bool bEndEqual(false);
2020 
2021  if(nSequenceCount)
2022  {
2023  const drawing::PointSequence& rStartSeq = pSource->Coordinates[0];
2024  const sal_uInt32 nStartCount = rStartSeq.getLength();
2025 
2026  if(nStartCount)
2027  {
2028  const awt::Point& rStartPoint = rStartSeq.getConstArray()[0];
2029 
2030  if(rStartPoint.X == maStart.X && rStartPoint.Y == maStart.Y)
2031  {
2032  bStartEqual = true;
2033  }
2034  }
2035 
2036  const drawing::PointSequence& rEndSeq = pSource->Coordinates[nSequenceCount - 1];
2037  const sal_uInt32 nEndCount = rEndSeq.getLength();
2038 
2039  if(nEndCount)
2040  {
2041  const awt::Point& rEndPoint = rEndSeq.getConstArray()[nEndCount - 1];
2042 
2043  if(rEndPoint.X == maEnd.X && rEndPoint.Y == maEnd.Y)
2044  {
2045  bEndEqual = true;
2046  }
2047  }
2048  }
2049 
2050  if(!bStartEqual || !bEndEqual)
2051  {
2052  bApplySVGD = false;
2053  }
2054  }
2055 
2056  if ( bApplySVGD )
2057  {
2059  xProps->setPropertyValue("PolyPolygonBezier", maPath);
2060  }
2061  }
2062 
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  return;
2128 
2129  SetStyle();
2130  SetLayer();
2131 
2132  uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2133  if( xProps.is() )
2134  {
2135  xProps->setPropertyValue("StartPosition", Any(maStart));
2136  xProps->setPropertyValue("EndPosition", Any(maEnd) );
2137  }
2138 
2139  // delete pre created fields
2140  uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2141  if( xText.is() )
2142  {
2143  xText->setString( " " );
2144  }
2145 
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  return;
2239 
2240  SetStyle();
2241  SetLayer();
2242 
2243  // set pos, size, shear and rotate
2245 
2246  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2247  if(xPropSet.is())
2248  {
2249  uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2250  const OUString aPageNumberStr("PageNumber");
2251  if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2252  xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber ));
2253  }
2254 
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  return;
2283 
2284  SetStyle();
2285  SetLayer();
2286 
2287  uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2288 
2289  // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2290  // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2291  // is the default setting, so the top left reference point that is used by the caption point is
2292  // no longer correct) There are two ways to solve this problem, temporarily disabling the
2293  // autogrowwidth as we are doing here or to apply the CaptionPoint after setting text
2294  bool bIsAutoGrowWidth = false;
2295  if ( xProps.is() )
2296  {
2297  uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") );
2298  aAny >>= bIsAutoGrowWidth;
2299 
2300  if ( bIsAutoGrowWidth )
2301  xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( false ) );
2302  }
2303 
2304  // set pos, size, shear and rotate
2306  if( xProps.is() )
2307  xProps->setPropertyValue("CaptionPoint", uno::makeAny( maCaptionPoint ) );
2308 
2309  if ( bIsAutoGrowWidth )
2310  xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( true ) );
2311 
2312  if(mnRadius)
2313  {
2314  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2315  if(xPropSet.is())
2316  {
2317  try
2318  {
2319  xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) );
2320  }
2321  catch(const uno::Exception&)
2322  {
2323  DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius");
2324  }
2325  }
2326  }
2327 
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  return;
2403 
2404  SetStyle();
2405  SetLayer();
2406 
2407  uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
2408  if(xPropset.is())
2409  {
2410  // since OOo 1.x had no line or fill style for graphics, but may create
2411  // documents with them, we have to override them here
2412  sal_Int32 nUPD, nBuildId;
2413  if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try
2414  {
2415  xPropset->setPropertyValue("FillStyle", Any( FillStyle_NONE ) );
2416  xPropset->setPropertyValue("LineStyle", Any( LineStyle_NONE ) );
2417  }
2418  catch(const Exception&)
2419  {
2420  }
2421 
2422  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
2423  if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2424  xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::makeAny( mbIsPlaceholder ) );
2425 
2426  if( !mbIsPlaceholder )
2427  {
2428  if( !maURL.isEmpty() )
2429  {
2430  uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maURL);
2431  if (xGraphic.is())
2432  {
2433  xPropset->setPropertyValue("Graphic", uno::makeAny(xGraphic));
2434  }
2435  }
2436  }
2437  }
2438 
2440  {
2441  uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2442  if(xProps.is())
2443  {
2444  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2445  if( xPropsInfo.is() )
2446  {
2447  if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2448  xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2449  }
2450  }
2451  }
2452 
2453  // set pos, size, shear and rotate
2455 
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  return;
2532 
2533  SetStyle();
2534  SetLayer();
2535 
2536  if( !mbIsPlaceholder )
2537  {
2538  uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2539  if(xProps.is())
2540  {
2541  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2542  if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2543  xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2544 
2545  uno::Any aAny;
2546 
2547  xProps->setPropertyValue("CLSID", Any(OUString("12DCAE26-281F-416F-a234-c3086127382e")) );
2548 
2549  aAny = xProps->getPropertyValue("Model");
2550  uno::Reference< frame::XModel > xChartModel;
2551  if( aAny >>= xChartModel )
2552  {
2553  mxChartContext.set( GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList ) );
2554  }
2555  }
2556  }
2557 
2559  {
2560  uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2561  if(xProps.is())
2562  {
2563  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2564  if( xPropsInfo.is() )
2565  {
2566  if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2567  xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2568  }
2569  }
2570  }
2571 
2572  // set pos, size, shear and rotate
2574 
2576 
2577  if( mxChartContext.is() )
2578  mxChartContext->StartElement( xAttrList );
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  return;
2657 
2658  SetLayer();
2659 
2660  if(bIsPresShape)
2661  {
2662  uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2663  if(xProps.is())
2664  {
2665  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2666  if( xPropsInfo.is() )
2667  {
2668  if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2669  xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2670 
2671  if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2672  xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2673  }
2674  }
2675  }
2676 
2677  if( !mbIsPlaceholder && !maHref.isEmpty() )
2678  {
2679  uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2680 
2681  if( xProps.is() )
2682  {
2683  OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
2684 
2685  if ( GetImport().IsPackageURL( maHref ) )
2686  {
2687  const OUString sURL( "vnd.sun.star.EmbeddedObject:" );
2688 
2689  if ( aPersistName.startsWith( sURL ) )
2690  aPersistName = aPersistName.copy( sURL.getLength() );
2691 
2692  xProps->setPropertyValue("PersistName",
2693  uno::makeAny( aPersistName ) );
2694  }
2695  else
2696  {
2697  // this is OOo link object
2698  xProps->setPropertyValue("LinkURL",
2699  uno::makeAny( aPersistName ) );
2700  }
2701  }
2702  }
2703 
2704  // set pos, size, shear and rotate
2706 
2707  SetStyle();
2708 
2709  GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
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  return;
3021 
3022  SetLayer();
3023 
3024  if(bIsPresShape)
3025  {
3026  uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3027  if(xProps.is())
3028  {
3029  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3030  if( xPropsInfo.is() )
3031  {
3032  if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
3033  xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
3034 
3035  if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
3036  xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
3037  }
3038  }
3039  }
3040 
3041  // set pos, size, shear and rotate
3043  GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
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  return;
3250 
3251  SetLayer();
3252 
3253  // set pos, size, shear and rotate
3255 
3256  uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3257  if( xProps.is() )
3258  {
3259  if( !maFrameName.isEmpty() )
3260  {
3261  xProps->setPropertyValue("FrameName", Any(maFrameName) );
3262  }
3263 
3264  if( !maHref.isEmpty() )
3265  {
3266  xProps->setPropertyValue("FrameURL", Any(maHref) );
3267  }
3268  }
3269 
3270  SetStyle();
3271 
3272  GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
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  return;
3347 
3348  try
3349  {
3350  uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3351 
3352  uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
3353 
3354  // remove from parent
3355  xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
3356 
3357  // dispose
3358  uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
3359 
3360  if(xComp.is())
3361  {
3362  xComp->dispose();
3363  }
3364  }
3365  catch( uno::Exception& )
3366  {
3367  DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." );
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  {
3462  if ( !maShapeId.isEmpty() )
3464 
3466  }
3467  }
3468  else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
3469  {
3470  // read another image
3471  xContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3472  GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
3473  mxImplContext = xContext;
3474 
3475  if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(xContext.get()))
3476  {
3478  }
3479  }
3480  else if( mbSupportsReplacement && !mxReplImplContext.is() &&
3481  XML_NAMESPACE_DRAW == nPrefix &&
3482  IsXMLToken( rLocalName, XML_IMAGE ) )
3483  {
3484  // read replacement image
3485  SvXMLImportContext *pImplContext = mxImplContext.get();
3486  SdXMLShapeContext *pSContext =
3487  dynamic_cast<SdXMLShapeContext*>( pImplContext );
3488  if( pSContext )
3489  {
3490  uno::Reference < beans::XPropertySet > xPropSet(
3491  pSContext->getShape(), uno::UNO_QUERY );
3492  if( xPropSet.is() )
3493  {
3494  xContext = new XMLReplacementImageContext( GetImport(),
3495  nPrefix, rLocalName, xAttrList, xPropSet );
3496  mxReplImplContext = xContext;
3497  }
3498  }
3499  }
3500  else if(
3501  ( nPrefix == XML_NAMESPACE_SVG && // #i68101#
3502  (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) ||
3503  (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) ||
3504  (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) ||
3505  IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) )
3506  {
3508  { // tdf#103567 ensure props are set on surviving shape
3509  // note: no more draw:image can be added once we get here
3511  }
3512  SvXMLImportContext *pImplContext = mxImplContext.get();
3513  xContext = dynamic_cast<SdXMLShapeContext&>(*pImplContext).CreateChildContext( nPrefix,
3514  rLocalName, xAttrList );
3515  }
3516  else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
3517  {
3519  { // tdf#103567 ensure props are set on surviving shape
3520  // note: no more draw:image can be added once we get here
3522  }
3523  SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( mxImplContext.get() );
3524  if( pSContext )
3525  {
3526  uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY );
3527  if (xPropSet.is())
3528  {
3529  xContext = new XMLImageMapContext(GetImport(), nPrefix, rLocalName, xPropSet);
3530  }
3531  }
3532  }
3533  else if ((XML_NAMESPACE_LO_EXT == nPrefix) && IsXMLToken(rLocalName, XML_SIGNATURELINE))
3534  {
3535  SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
3536  if (pSContext)
3537  {
3538  uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
3539  if (xPropSet.is())
3540  {
3541  xContext = new SignatureLineContext(GetImport(), nPrefix, rLocalName, xAttrList,
3542  pSContext->getShape());
3543  }
3544  }
3545  }
3546  else if ((XML_NAMESPACE_LO_EXT == nPrefix) && IsXMLToken(rLocalName, XML_QRCODE))
3547  {
3548  SdXMLShapeContext* pSContext = dynamic_cast<SdXMLShapeContext*>(mxImplContext.get());
3549  if (pSContext)
3550  {
3551  uno::Reference<beans::XPropertySet> xPropSet(pSContext->getShape(), uno::UNO_QUERY);
3552  if (xPropSet.is())
3553  {
3554  xContext = new QRCodeContext(GetImport(), nPrefix, rLocalName, xAttrList,
3555  pSContext->getShape());
3556  }
3557  }
3558  }
3559 
3560  return xContext;
3561 }
3562 
3563 void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
3564 {
3565  // ignore
3566 }
3567 
3569 {
3570  // solve if multiple image child contexts were imported
3571  SvXMLImportContextRef const pSelectedContext(solveMultipleImages());
3572  const SdXMLGraphicObjectShapeContext* pShapeContext(
3573  dynamic_cast<const SdXMLGraphicObjectShapeContext*>(pSelectedContext.get()));
3574  if ( pShapeContext )
3575  {
3576  assert( mxImplContext.is() );
3577  const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() );
3579  }
3580 
3581  if( !mxImplContext.is() )
3582  {
3583  // now check if this is an empty presentation object
3584  sal_Int16 nAttrCount = mxAttrList.is() ? mxAttrList->getLength() : 0;
3585  for(sal_Int16 a(0); a < nAttrCount; a++)
3586  {
3587  OUString aLocalName;
3588  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList->getNameByIndex(a), &aLocalName);
3589 
3590  if( nPrefix == XML_NAMESPACE_PRESENTATION )
3591  {
3592  if( IsXMLToken( aLocalName, XML_PLACEHOLDER ) )
3593  {
3594  mbIsPlaceholder = IsXMLToken( mxAttrList->getValueByIndex(a), XML_TRUE );
3595  }
3596  else if( IsXMLToken( aLocalName, XML_CLASS ) )
3597  {
3598  maPresentationClass = mxAttrList->getValueByIndex(a);
3599  }
3600  }
3601  }
3602 
3603  if( (!maPresentationClass.isEmpty()) && mbIsPlaceholder )
3604  {
3605  uno::Reference< xml::sax::XAttributeList> xEmpty;
3606 
3608 
3610  {
3611  eToken = XML_IMAGE;
3612 
3613  }
3614  else if( IsXMLToken( maPresentationClass, XML_PAGE ) )
3615  {
3616  eToken = XML_PAGE_THUMBNAIL;
3617  }
3618  else if( IsXMLToken( maPresentationClass, XML_CHART ) ||
3621  {
3622  eToken = XML_OBJECT;
3623  }
3624 
3625  mxImplContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3626  GetImport(), XML_NAMESPACE_DRAW, GetXMLToken( eToken ), mxAttrList, mxShapes, xEmpty );
3627 
3628  if( mxImplContext.is() )
3629  {
3630  mxImplContext->StartElement( mxAttrList );
3631  mxImplContext->EndElement();
3632  }
3633  }
3634  }
3635 
3636  mxImplContext = nullptr;
3638 }
3639 
3641  const OUString& rLocalName, const OUString& rValue )
3642 {
3643  bool bId( false );
3644 
3645  switch ( nPrefix )
3646  {
3647  case XML_NAMESPACE_DRAW :
3648  case XML_NAMESPACE_DRAW_EXT :
3649  bId = IsXMLToken( rLocalName, XML_ID );
3650  break;
3651  case XML_NAMESPACE_NONE :
3652  case XML_NAMESPACE_XML :
3653  bId = IsXMLToken( rLocalName, XML_ID );
3654  break;
3655  }
3656 
3657  if ( bId )
3658  SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3659 }
3660 
3661 
3663  SvXMLImport& rImport,
3664  sal_uInt16 nPrfx,
3665  const OUString& rLocalName,
3666  const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
3667  uno::Reference< drawing::XShapes > const & rShapes)
3668 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, false/*bTemporaryShape*/ )
3669 {
3670  // See the XMLTextFrameContext ctor, a frame has Writer content (and not
3671  // editeng) if its autostyle has a parent style. Do the same for shapes as well.
3672  sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3673  for (sal_Int16 i=0; i < nAttrCount; ++i)
3674  {
3675  const OUString& rAttrName = xAttrList->getNameByIndex(i);
3676  OUString aLocalName;
3677  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3678  if (nPrefix == XML_NAMESPACE_DRAW && IsXMLToken(aLocalName, XML_STYLE_NAME))
3679  {
3680  OUString aStyleName = xAttrList->getValueByIndex(i);
3681  if(!aStyleName.isEmpty())
3682  {
3684  XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName);
3685  // Note that this an API name, so intentionally not localized.
3686  if (pStyle && pStyle->GetParentName() == "Frame")
3687  {
3688  mbTextBox = true;
3689  break;
3690  }
3691  }
3692  }
3693  }
3694 }
3695 
3697 {
3698 }
3699 
3700 // this is called from the parent group for each unparsed attribute in the attribute list
3701 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
3702 {
3703  if( XML_NAMESPACE_DRAW == nPrefix )
3704  {
3705  if( IsXMLToken( rLocalName, XML_ENGINE ) )
3706  {
3708  return;
3709  }
3710  if ( IsXMLToken( rLocalName, XML_DATA ) )
3711  {
3713  return;
3714  }
3715  }
3716  SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3717 }
3718 
3719 void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
3720 {
3721  // create rectangle shape
3722  AddShape("com.sun.star.drawing.CustomShape");
3723  if ( !mxShape.is() )
3724  return;
3725 
3726  // Add, set Style and properties from base shape
3727  SetStyle();
3728  SetLayer();
3729 
3730  // set pos, size, shear and rotate
3732 
3733  try
3734  {
3735  uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3736  if( xPropSet.is() )
3737  {
3738  if ( !maCustomShapeEngine.isEmpty() )
3739  {
3740  xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), Any(maCustomShapeEngine) );
3741  }
3742  if ( !maCustomShapeData.isEmpty() )
3743  {
3744  xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), Any(maCustomShapeData) );
3745  }
3746  }
3747  }
3748  catch(const uno::Exception&)
3749  {
3750  DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" );
3751  }
3753 }
3754 
3756 {
3757  // Customshapes remember mirror state in its enhanced geometry.
3758  // SetTransformation() in StartElement() may have applied mirroring, but that is not yet
3759  // contained. Merge that information here before writing the property.
3761  {
3762  basegfx::B2DVector aScale, aTranslate;
3763  double fRotate, fShearX;
3764 
3765  maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
3766 
3767  if (aScale.getX() < 0.0)
3768  {
3769  const OUString sName("MirroredX");
3770  //fdo#84043 Merge, if property exists, otherwise append it
3771  auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
3772  [&sName](beans::PropertyValue& rValue) { return rValue.Name == sName; });
3773  if (aI != maCustomShapeGeometry.end())
3774  {
3775  beans::PropertyValue& rItem = *aI;
3776  bool bMirroredX = *o3tl::doAccess<bool>(rItem.Value);
3777  rItem.Value <<= !bMirroredX;
3778  rItem.Handle = -1;
3779  rItem.State = beans::PropertyState_DIRECT_VALUE;
3780  }
3781  else
3782  {
3783  beans::PropertyValue* pItem;
3784  maCustomShapeGeometry.emplace_back();
3785  pItem = &maCustomShapeGeometry.back();
3786  pItem->Name = sName;
3787  pItem->Handle = -1;
3788  pItem->Value <<= true;
3789  pItem->State = beans::PropertyState_DIRECT_VALUE;
3790  }
3791  }
3792 
3793  if (aScale.getY() < 0.0)
3794  {
3795  const OUString sName("MirroredY");
3796  //fdo#84043 Merge, if property exists, otherwise append it
3797  auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
3798  [&sName](beans::PropertyValue& rValue) { return rValue.Name == sName; });
3799  if (aI != maCustomShapeGeometry.end())
3800  {
3801  beans::PropertyValue& rItem = *aI;
3802  bool bMirroredY = *o3tl::doAccess<bool>(rItem.Value);
3803  rItem.Value <<= !bMirroredY;
3804  rItem.Handle = -1;
3805  rItem.State = beans::PropertyState_DIRECT_VALUE;
3806  }
3807  else
3808  {
3809  beans::PropertyValue* pItem;
3810  maCustomShapeGeometry.emplace_back();
3811  pItem = &maCustomShapeGeometry.back();
3812  pItem->Name = sName;
3813  pItem->Handle = -1;
3814  pItem->Value <<= true;
3815  pItem->State = beans::PropertyState_DIRECT_VALUE;
3816  }
3817  }
3818  }
3819 
3820  if ( !maCustomShapeGeometry.empty() )
3821  {
3822  // converting the vector to a sequence
3823  uno::Sequence< beans::PropertyValue > aSeq( comphelper::containerToSequence(maCustomShapeGeometry) );
3824 
3825  try
3826  {
3827  uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3828  if( xPropSet.is() )
3829  {
3830  xPropSet->setPropertyValue( "CustomShapeGeometry", Any(aSeq) );
3831  }
3832  }
3833  catch(const uno::Exception&)
3834  {
3835  DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" );
3836  }
3837 
3838  sal_Int32 nUPD;
3839  sal_Int32 nBuild;
3840  if (GetImport().getBuildIds(nUPD, nBuild))
3841  {
3842  if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) )
3843  {
3844  Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY );
3845  if( xDefaulter.is() )
3846  {
3847  xDefaulter->createCustomShapeDefaults( "" );
3848  }
3849  }
3850  }
3851  }
3852 
3854 
3855  // tdf#98163 call a custom slot to be able to reset the UNO API
3856  // implementations held on the SdrObjects of type
3857  // SdrObjCustomShape - those tend to linger until the entire file
3858  // is loaded. For large files with a lot of these, 32bit systems
3859  // may crash due to being out of resources after ca. 4200
3860  // Outliners and VirtualDevices used there as RefDevice
3861  try
3862  {
3863  uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
3864 
3865  if(xPropSet.is())
3866  {
3867  xPropSet->setPropertyValue(
3868  "FlushCustomShapeUnoApiObjects", css::uno::Any(true));
3869  }
3870  }
3871  catch(const uno::Exception&)
3872  {
3873  DBG_UNHANDLED_EXCEPTION("xmloff", "flushing after load");
3874  }
3875 }
3876 
3878  sal_uInt16 nPrefix, const OUString& rLocalName,
3879  const uno::Reference<xml::sax::XAttributeList>& xAttrList )
3880 {
3881  SvXMLImportContextRef xContext;
3882  if ( XML_NAMESPACE_DRAW == nPrefix )
3883  {
3884  if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) )
3885  {
3886  uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
3887  if ( xPropSet.is() )
3888  xContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry );
3889  }
3890  }
3891  // delegate to parent class if no context could be created
3892  if (!xContext)
3893  xContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName,
3894  xAttrList);
3895  return xContext;
3896 }
3897 
3898 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 )
3899 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, false )
3900 {
3901 }
3902 
3904 {
3905 }
3906 
3907 void SdXMLTableShapeContext::StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
3908 {
3909  OUString service("com.sun.star.drawing.TableShape");
3910 
3911  bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3912  if( bIsPresShape )
3913  {
3915  {
3916  service = "com.sun.star.presentation.TableShape";
3917  }
3918  }
3919 
3920  AddShape(service);
3921 
3922  if( !mxShape.is() )
3923  return;
3924 
3925  SetLayer();
3926 
3927  uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
3928 
3929  if(bIsPresShape && xProps.is())
3930  {
3931  uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3932  if( xPropsInfo.is() )
3933  {
3934  if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
3935  xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
3936 
3937  if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
3938  xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
3939  }
3940  }
3941 
3942  SetStyle();
3943 
3944  if( xProps.is() )
3945  {
3946  if( !msTemplateStyleName.isEmpty() ) try
3947  {
3948  Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
3949  Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
3950  Reference< XNameAccess > xTableFamily( xFamilies->getByName( "table" ), UNO_QUERY_THROW );
3951  Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
3952  xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) );
3953  }
3954  catch(const Exception&)
3955  {
3956  DBG_UNHANDLED_EXCEPTION("xmloff.draw");
3957  }
3958 
3959  const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
3960  for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ )
3961  {
3962  try
3963  {
3964  const OUString sAPIPropertyName( pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US );
3965  xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) );
3966  }
3967  catch(const Exception&)
3968  {
3969  DBG_UNHANDLED_EXCEPTION("xmloff.draw");
3970  }
3971  }
3972  }
3973 
3974  GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3975 
3976  const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3977  if( xTableImport.is() && xProps.is() )
3978  {
3979  uno::Reference< table::XColumnRowRange > xColumnRowRange(
3980  xProps->getPropertyValue("Model"), uno::UNO_QUERY );
3981 
3982  if( xColumnRowRange.is() )
3983  mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange );
3984 
3985  if( mxTableImportContext.is() )
3986  mxTableImportContext->StartElement( xAttrList );
3987  }
3988 }
3989 
3991 {
3992  if( mxTableImportContext.is() )
3993  mxTableImportContext->EndElement();
3994 
3996 
3997  if( mxShape.is() )
3998  {
3999  // set pos, size, shear and rotate
4001  }
4002 }
4003 
4004 // this is called from the parent group for each unparsed attribute in the attribute list
4005 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
4006 {
4007  if( nPrefix == XML_NAMESPACE_TABLE )
4008  {
4009  if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) )
4010  {
4012  }
4013  else
4014  {
4015  int i = 0;
4016  const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
4017  while( pEntry->msApiName && (i < 6) )
4018  {
4019  if( IsXMLToken( rLocalName, pEntry->meXMLName ) )
4020  {
4021  if( IsXMLToken( rValue, XML_TRUE ) )
4022  maTemplateStylesUsed[i] = true;
4023  break;
4024  }
4025  pEntry++;
4026  i++;
4027  }
4028  }
4029  }
4030  SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
4031 }
4032 
4033 SvXMLImportContextRef SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList )
4034 {
4035  if( mxTableImportContext.is() && (nPrefix == XML_NAMESPACE_TABLE) )
4036  return mxTableImportContext->CreateChildContext(nPrefix, rLocalName, xAttrList);
4037  else
4038  return SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
4039 }
4040 
4041 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetTransformation()
Definition: ximpshap.cxx:533
bool importFromSvgPoints(B2DPolygon &o_rPoly, const OUString &rSvgPointsAttribute)
constexpr sal_uInt16 XML_NAMESPACE_MATH
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:3434
bool reserveIdentifier(const OUString &rIdentifier)
reserves an identifier for later registration.
OUString maLayerName
Definition: ximpshap.hxx:70
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:3563
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
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
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
constexpr sal_uInt16 XML_NAMESPACE_DRAW_EXT
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:4033
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:108
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
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
constexpr sal_uInt16 XML_NAMESPACE_XLINK
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:394
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)
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
geometry::RealPoint2D maPosition
css::uno::Reference< css::io::XOutputStream > GetStreamForEmbeddedObjectURLFromBase64() const
Definition: xmlimp.cxx:1409
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:1334
static const sal_uInt16 AOO_40x
Definition: xmlimp.hxx:541
bool getNextToken(OUString &rToken)
Definition: xmluconv.cxx:449
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:592
static const sal_uInt16 LO_41x
Definition: xmlimp.hxx:550
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
OUString GetDocumentBase() const
Definition: xmlimp.cxx:1868
void setHyperlink(const OUString &rHyperlink)
virtual ~SdXMLObjectShapeContext() override
Definition: ximpshap.cxx:2613
css::awt::Point maEnd
Definition: ximpshap.hxx:314
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:3696
#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:1909
PropertiesInfo aProperties
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:539
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:1852
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:3755
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:3990
void addGluePoint(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
Definition: ximpshap.cxx:258
constexpr sal_uInt16 XML_NAMESPACE_DRAW
css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const
Definition: xmlimp.cxx:1368
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
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
constexpr sal_uInt16 XML_NAMESPACE_XML
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
constexpr sal_uInt16 XML_NAMESPACE_SVG
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:3907
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:223
bool getBuildIds(sal_Int32 &rUPD, sal_Int32 &rBuild) const
returns the upd and build id (f.e.
Definition: xmlimp.cxx:1889
uno_Any a
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:453
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:1286
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:1379
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:1495
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 sal_uInt16 XML_NAMESPACE_NONE
const Point maEnd
virtual void processAttribute(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rValue) override
Definition: ximpshap.cxx:3640
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
bool registerReservedReference(const OUString &rIdentifier, const css::uno::Reference< css::uno::XInterface > &rInterface)
registers the given uno object with reserved identifier.
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:3877
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.
Map an XMLTokenEnum to an enum value.
Definition: ximpshap.hxx:40
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
css::awt::Point maPosition
Definition: ximpshap.hxx:76
virtual void processAttribute(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rValue) override
Definition: ximpshap.cxx:4005
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
constexpr sal_uInt16 XML_NAMESPACE_TABLE
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:101
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:1665
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:3719
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
Definition: xmlimp.cxx:1469
#define SAL_WARN_IF(condition, area, stream)
virtual ~SdXMLTableShapeContext() override
Definition: ximpshap.cxx:3903
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3378
virtual void processAttribute(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rValue) override
Definition: ximpshap.cxx:3701
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:3898
Handling of tokens in XML:
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:396
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
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:3662
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:3568
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
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
constexpr sal_uInt16 XML_NAMESPACE_STYLE
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:600
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